@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.
Files changed (612) hide show
  1. package/README.md +1 -1
  2. package/data/elements-meta.json +5 -15
  3. package/data/html-meta.json +51 -6
  4. package/dist/chunks/{2020-n6tfwnda.js → 2020-g79n01v9.js} +14 -14
  5. package/dist/chunks/action-group-sp6tna8v.js +118 -0
  6. package/dist/chunks/adapter-nj7tnjfn.js +13 -0
  7. package/dist/chunks/cf-account-picker-qwkm9zrf.js +495 -0
  8. package/dist/chunks/cf-settings-71bv5zn9.js +20 -0
  9. package/dist/chunks/color-area-v17df7b8.js +154 -0
  10. package/dist/chunks/color-field-anwybnkn.js +208 -0
  11. package/dist/chunks/color-slider-44ez96fc.js +79 -0
  12. package/dist/chunks/color-xgg3kfw7.js +35 -0
  13. package/dist/chunks/combobox-5e7jev23.js +236 -0
  14. package/dist/chunks/components-vj72gqtq.js +20 -0
  15. package/dist/chunks/content-source-5mex4x1h.js +46 -0
  16. package/dist/chunks/convert-to-repeater-n64h8znc.js +639 -0
  17. package/dist/chunks/dialog-s890b918.js +85 -0
  18. package/dist/chunks/editor-3qhbg51x.js +35 -0
  19. package/dist/chunks/entry-commands-234hjnqw.js +42 -0
  20. package/dist/chunks/extension-sections-3hpcambp.js +651 -0
  21. package/dist/chunks/file-ops-8yhd83xr.js +47 -0
  22. package/dist/chunks/files-hnxqxtsg.js +72 -0
  23. package/dist/chunks/format-host-779sfp2n.js +40 -0
  24. package/dist/chunks/fs-events-b88z7g4h.js +18 -0
  25. package/dist/chunks/git-panel-xwj8fpab.js +49 -0
  26. package/dist/chunks/icons-yy10wk9r.js +402 -0
  27. package/dist/chunks/iframe-entry-15g3n6xv.js +114 -0
  28. package/dist/chunks/iframe-entry-b27vq81n.js +203 -0
  29. package/dist/chunks/iframe-entry-nbyxee1y.js +154 -0
  30. package/dist/chunks/iframe-host-syr0f9sb.js +115 -0
  31. package/dist/chunks/{index-wcnt3r9g.js → index-mdmyx6s2.js} +11 -11
  32. package/dist/chunks/index-n4j7qxyr.js +109 -0
  33. package/dist/chunks/{javascript-q8kpmfah.js → javascript-xvrfrpkb.js} +8 -9
  34. package/dist/chunks/{jsonMode-dkr040ga.js → jsonMode-tyx2kj6p.js} +526 -527
  35. package/dist/chunks/jx-validate-j0wxk72w.js +15 -0
  36. package/dist/chunks/layers-ff81wthn.js +30 -0
  37. package/dist/chunks/layers-panel-pnnghw12.js +40 -0
  38. package/dist/chunks/listbox-6v2ac08j.js +44 -0
  39. package/dist/chunks/lit-html-m244w9nh.js +17 -0
  40. package/dist/chunks/media-picker-cqhhxhhe.js +33 -0
  41. package/dist/chunks/menu-9p2w46gj.js +15 -0
  42. package/dist/chunks/menu-q99sy9rf.js +285 -0
  43. package/dist/chunks/{monaco-binding-rj6xpx9y.js → monaco-binding-sw6en4dw.js} +12 -15
  44. package/dist/chunks/monaco-buffer-bhy3hb6m.js +24 -0
  45. package/dist/chunks/{monaco-setup-vx9bhp1d.js → monaco-setup-8r62fj6y.js} +27 -37
  46. package/dist/chunks/notify-628t0anh.js +21 -0
  47. package/dist/chunks/number-field-5cndyft8.js +72 -0
  48. package/dist/chunks/parse-0zx14y15.js +10 -0
  49. package/dist/chunks/platform-ts9cg1a4.js +15 -0
  50. package/dist/chunks/popover-47z3ytva.js +25 -0
  51. package/dist/chunks/publish-panel-5zt840sy.js +27 -0
  52. package/dist/chunks/quick-search-3748564r.js +45 -0
  53. package/dist/chunks/references-qvvxej7h.js +26 -0
  54. package/dist/chunks/right-panel-eccz92qt.js +45 -0
  55. package/dist/chunks/section-registry-5pq32t0q.js +25 -0
  56. package/dist/chunks/select-2r16ez41.js +49 -0
  57. package/dist/chunks/split-g7nm1rgb.js +191 -0
  58. package/dist/chunks/studio-0hqbpbd0.js +62 -0
  59. package/dist/chunks/{studio-kryvsw6j.js → studio-1k325pwf.js} +48 -48
  60. package/dist/chunks/{studio-b55y6ewx.js → studio-1knfqgy7.js} +58 -58
  61. package/dist/chunks/{studio-2b946z26.js → studio-1z1kcjv4.js} +3628 -6095
  62. package/dist/chunks/studio-3773086z.js +111 -0
  63. package/dist/chunks/{studio-4r1pv6zf.js → studio-38emantv.js} +22 -5
  64. package/dist/chunks/{studio-x813zp48.js → studio-3rz5md06.js} +30 -30
  65. package/dist/chunks/{studio-ynxwkrzd.js → studio-4wbb9ct0.js} +1953 -1785
  66. package/dist/chunks/studio-5te5tqng.js +81 -0
  67. package/dist/chunks/studio-5wt9nvhd.js +4763 -0
  68. package/dist/chunks/{studio-p4ngc046.js → studio-6ewqv390.js} +9 -9
  69. package/dist/chunks/{studio-9ab8gqsm.js → studio-6nzaktvy.js} +7 -7
  70. package/dist/chunks/studio-6xa21ej9.js +28 -0
  71. package/dist/chunks/{studio-5ehhackm.js → studio-727xh0e3.js} +19 -19
  72. package/dist/chunks/{studio-gcye7qka.js → studio-7e11jpa9.js} +21 -21
  73. package/dist/chunks/{studio-q7v10cg2.js → studio-7r42c6ca.js} +17 -7
  74. package/dist/chunks/studio-7xnmgv66.js +13615 -0
  75. package/dist/chunks/studio-8scdew0e.js +258 -0
  76. package/dist/chunks/{studio-fbf92ckf.js → studio-93zafjcm.js} +275 -163
  77. package/dist/chunks/{studio-dg7zyt5x.js → studio-98b3z07n.js} +1 -1
  78. package/dist/chunks/studio-a79k90n9.js +1162 -0
  79. package/dist/chunks/studio-aj37eer3.js +422 -0
  80. package/dist/chunks/studio-b0k5tqgp.js +2432 -0
  81. package/dist/chunks/studio-b4s9eykd.js +2811 -0
  82. package/dist/chunks/{studio-f3wqjtk5.js → studio-d0300636.js} +5076 -18
  83. package/dist/chunks/{studio-b9b6t1dg.js → studio-e1f24eff.js} +5664 -5666
  84. package/dist/chunks/studio-e1pgga3k.js +839 -0
  85. package/dist/chunks/{studio-g1wdche0.js → studio-esrxgwh6.js} +80 -80
  86. package/dist/chunks/{studio-q43a5y9h.js → studio-g3jevyjt.js} +16 -16
  87. package/dist/chunks/studio-gb13095a.js +2806 -0
  88. package/dist/chunks/{studio-3n4ndrzh.js → studio-h4nvnjvz.js} +303 -303
  89. package/dist/chunks/{studio-dm19q43r.js → studio-hhvs4sdg.js} +10 -10
  90. package/dist/chunks/{studio-x4qkdat5.js → studio-js8nv53n.js} +1749 -2481
  91. package/dist/chunks/{studio-qjy2z9bv.js → studio-jxp12rnj.js} +32 -137
  92. package/dist/chunks/{studio-trxrabqf.js → studio-k75n7vhp.js} +527 -283
  93. package/dist/chunks/{studio-q9jd1a60.js → studio-kcgff4r0.js} +15 -18
  94. package/dist/chunks/studio-kkqkcp3d.js +17668 -0
  95. package/dist/chunks/studio-mhhyamxf.js +763 -0
  96. package/dist/chunks/{studio-cft9r4r7.js → studio-nq5yf5mp.js} +22 -22
  97. package/dist/chunks/{studio-685s0ytq.js → studio-nqgawfks.js} +572 -572
  98. package/dist/chunks/studio-nzzpvzx9.js +185 -0
  99. package/dist/chunks/{studio-xrapxwwc.js → studio-p1dw8wfw.js} +55 -29
  100. package/dist/chunks/{studio-3bqpr0zh.js → studio-pxbgypmg.js} +299 -110
  101. package/dist/chunks/studio-q0a3yk4n.js +33 -0
  102. package/dist/chunks/{studio-wcy8trfx.js → studio-q3x06vmj.js} +23 -22
  103. package/dist/chunks/{studio-6yw4y3my.js → studio-qhhm6hbt.js} +8 -8
  104. package/dist/chunks/studio-qk4bfsq2.js +362 -0
  105. package/dist/chunks/{studio-msd847zn.js → studio-qk90fgqm.js} +361 -90
  106. package/dist/chunks/{studio-jkftxyvz.js → studio-r6nvacqs.js} +5861 -2154
  107. package/dist/chunks/{studio-53n8bp04.js → studio-r6xmmtfh.js} +1 -1
  108. package/dist/chunks/{studio-tvgyw9xw.js → studio-rnyf3f8e.js} +83 -250
  109. package/dist/chunks/studio-rs76k67r.js +12 -0
  110. package/dist/chunks/studio-sbjyc8bt.js +954 -0
  111. package/dist/chunks/{studio-1wagb550.js → studio-syg2tadj.js} +11 -11
  112. package/dist/chunks/{studio-t5wqwzdh.js → studio-tjjk7jvk.js} +1 -1
  113. package/dist/chunks/studio-tqgryxwg.js +1171 -0
  114. package/dist/chunks/studio-try13h8c.js +8448 -0
  115. package/dist/chunks/studio-vfq8qpjt.js +1219 -0
  116. package/dist/chunks/studio-vhv5tgxm.js +51 -0
  117. package/dist/chunks/{studio-ahn3pdgx.js → studio-vw7mzp6z.js} +52 -38
  118. package/dist/chunks/studio-wqpngpsk.js +174 -0
  119. package/dist/chunks/studio-wqz6dggm.js +1356 -0
  120. package/dist/chunks/{studio-92ab2jqe.js → studio-y9zedyjn.js} +14 -14
  121. package/dist/chunks/studio-yxa81f45.js +12 -0
  122. package/dist/chunks/studio-zdn2g6dt.js +148 -0
  123. package/dist/chunks/swatch-group-t0n6h2rn.js +139 -0
  124. package/dist/chunks/tabs-wbp1cdws.js +156 -0
  125. package/dist/chunks/textfield-abk6qyee.js +73 -0
  126. package/dist/chunks/toast-780pvfbv.js +27 -0
  127. package/dist/chunks/toast-host-3sqv46sn.js +116 -0
  128. package/dist/chunks/toolbar-xbh5bhtr.js +194 -0
  129. package/dist/chunks/tooltip-eptb614w.js +369 -0
  130. package/dist/chunks/tree-a73p0pqm.js +367 -0
  131. package/dist/chunks/{tsMode-76kr53q0.js → tsMode-jy4m86rv.js} +83 -85
  132. package/dist/chunks/workspace-t55jdjbx.js +69 -0
  133. package/dist/chunks/{ws-client-6shc5rze.js → ws-client-ny4zc51r.js} +20 -22
  134. package/dist/iframe-entry.js +1873 -673
  135. package/dist/studio.js +52757 -36535
  136. package/dist/workers/editor.worker.js +1040 -1085
  137. package/dist/workers/json.worker.js +1946 -1991
  138. package/dist/workers/ts.worker.js +4960 -5005
  139. package/index.html +1 -0
  140. package/package.json +18 -52
  141. package/src/about/about-modal.ts +72 -123
  142. package/src/browse/library-commands.ts +20 -49
  143. package/src/browse/library-layouts.ts +87 -218
  144. package/src/browse/library-pane.ts +406 -438
  145. package/src/canvas/canvas-helpers.ts +0 -49
  146. package/src/canvas/canvas-live-render.ts +25 -2
  147. package/src/canvas/canvas-render.ts +666 -231
  148. package/src/canvas/canvas-surface.ts +0 -1
  149. package/src/canvas/canvas-utils.ts +333 -113
  150. package/src/canvas/dialog-path.ts +76 -0
  151. package/src/canvas/dialog-state.ts +67 -0
  152. package/src/canvas/diff-marks.ts +252 -0
  153. package/src/canvas/diff-toolbar.ts +349 -0
  154. package/src/canvas/diff-view.ts +123 -0
  155. package/src/canvas/edit-width-drag.ts +187 -0
  156. package/src/canvas/edit-width.ts +150 -0
  157. package/src/canvas/iframe-entry.ts +125 -8
  158. package/src/canvas/iframe-host.ts +271 -15
  159. package/src/canvas/iframe-interaction.ts +133 -13
  160. package/src/canvas/iframe-patch.ts +7 -1
  161. package/src/canvas/iframe-position.ts +5 -6
  162. package/src/canvas/iframe-protocol.ts +106 -5
  163. package/src/canvas/iframe-render.ts +373 -5
  164. package/src/canvas/iframe-slash.ts +2 -2
  165. package/src/canvas/iframe-subtree.ts +5 -8
  166. package/src/canvas/path-mapping.ts +25 -3
  167. package/src/canvas/popover-path.ts +106 -0
  168. package/src/canvas/popover-state.ts +155 -0
  169. package/src/canvas/surface-registry.ts +21 -10
  170. package/src/collab/presence-chips.ts +51 -73
  171. package/src/commands/app-commands.ts +10 -0
  172. package/src/commands/budget.ts +12 -0
  173. package/src/commands/command-args.ts +404 -6
  174. package/src/commands/defaults.ts +44 -14
  175. package/src/commands/live-context.ts +11 -5
  176. package/src/commands/reference.ts +12 -2
  177. package/src/commands/registry.ts +177 -10
  178. package/src/commands/run-reported.ts +120 -0
  179. package/src/content/entry-commands.ts +16 -23
  180. package/src/content/entry-editor.ts +144 -101
  181. package/src/editor/canvas-slash-bridge.ts +2 -2
  182. package/src/editor/context-menu.ts +49 -200
  183. package/src/editor/convert-to-component.ts +42 -82
  184. package/src/editor/convert-to-repeater.ts +132 -173
  185. package/src/editor/inline-edit.ts +11 -0
  186. package/src/editor/shortcuts.ts +76 -49
  187. package/src/editor/slash-menu.ts +150 -157
  188. package/src/files/components.ts +39 -0
  189. package/src/files/file-ops.ts +117 -11
  190. package/src/files/files.ts +944 -660
  191. package/src/files/json-layout.ts +474 -0
  192. package/src/files/serialize-document.ts +8 -1
  193. package/src/format/convert-file.ts +16 -10
  194. package/src/format/format-host.ts +50 -1
  195. package/src/github/github-auth.ts +71 -29
  196. package/src/github/github-publish.ts +57 -65
  197. package/src/grid/cell-editors.ts +46 -4
  198. package/src/grid/cell-popovers.ts +65 -62
  199. package/src/grid/grid-open.ts +86 -64
  200. package/src/grid/grid-panel.ts +390 -469
  201. package/src/grid/redirects-grid.ts +40 -44
  202. package/src/hosting/layout.ts +2 -0
  203. package/src/i18n/i18n-commands.ts +137 -62
  204. package/src/media/media-pane.ts +83 -133
  205. package/src/new-project/add-repo-modal.ts +125 -176
  206. package/src/new-project/import-tab.ts +181 -252
  207. package/src/new-project/location-fields.ts +93 -160
  208. package/src/new-project/new-project-modal.ts +376 -367
  209. package/src/packages/jxsuite-update.ts +76 -18
  210. package/src/packages/pull-package-sync.ts +5 -1
  211. package/src/panels/activity-panel.ts +137 -104
  212. package/src/panels/ai-chat/chat-markdown.ts +15 -13
  213. package/src/panels/ai-chat/chat-view.ts +307 -472
  214. package/src/panels/ai-chat/composer.ts +175 -163
  215. package/src/panels/ai-chat/sessions-view.ts +31 -62
  216. package/src/panels/ai-panel.ts +213 -185
  217. package/src/panels/block-action-bar.ts +444 -645
  218. package/src/panels/bottom-dock.ts +112 -47
  219. package/src/panels/chat-panel.ts +19 -14
  220. package/src/panels/data-explorer.ts +141 -102
  221. package/src/panels/data-grid.ts +183 -150
  222. package/src/panels/dnd.ts +75 -20
  223. package/src/panels/editors.ts +26 -19
  224. package/src/panels/elements-panel.ts +243 -186
  225. package/src/panels/empty-state.ts +26 -42
  226. package/src/panels/events-panel.ts +950 -729
  227. package/src/panels/formula-workspace.ts +434 -207
  228. package/src/panels/frontmatter-fields.ts +185 -153
  229. package/src/panels/frontmatter-panel.ts +411 -187
  230. package/src/panels/git-diff-open.ts +148 -0
  231. package/src/panels/git-panel.ts +679 -605
  232. package/src/panels/head-panel.ts +617 -435
  233. package/src/panels/i18n-panel.ts +148 -135
  234. package/src/panels/imports-panel.ts +388 -414
  235. package/src/panels/jump-bar.ts +175 -147
  236. package/src/panels/layers-panel.ts +785 -671
  237. package/src/panels/left-panel.ts +166 -94
  238. package/src/panels/navigator-panels.ts +1 -1
  239. package/src/panels/pane-context.ts +529 -677
  240. package/src/panels/pane-grid.ts +265 -241
  241. package/src/panels/panel-registry.ts +15 -4
  242. package/src/panels/problems-panel.ts +181 -99
  243. package/src/panels/properties-panel.ts +1525 -966
  244. package/src/panels/provenance.ts +31 -113
  245. package/src/panels/quick-search.ts +223 -184
  246. package/src/panels/right-panel.ts +135 -169
  247. package/src/panels/seo-modal.ts +346 -167
  248. package/src/panels/settings-menu.ts +114 -661
  249. package/src/panels/settings-pane.ts +102 -86
  250. package/src/panels/signals-panel.ts +1318 -1172
  251. package/src/panels/statement-editor.ts +556 -428
  252. package/src/panels/style-panel.ts +1367 -630
  253. package/src/panels/style-utils.ts +36 -32
  254. package/src/panels/stylebook-doc.ts +30 -73
  255. package/src/panels/stylebook-layers-panel.ts +202 -109
  256. package/src/panels/stylebook-panel.ts +124 -88
  257. package/src/panels/tab-strip.ts +386 -288
  258. package/src/platforms/cloud.ts +106 -16
  259. package/src/platforms/devserver.ts +13 -0
  260. package/src/publish/deploy-checklist.ts +124 -78
  261. package/src/publish/publish-commands.ts +4 -12
  262. package/src/publish/publish-panel.ts +134 -328
  263. package/src/services/a11y-report.ts +100 -43
  264. package/src/services/ai-command-tools.ts +538 -0
  265. package/src/services/ai-project-tools.ts +8 -2
  266. package/src/services/ai-session-store.ts +6 -0
  267. package/src/services/ai-system-prompt.ts +112 -24
  268. package/src/services/ai-tools.ts +36 -212
  269. package/src/services/ai-write-report.ts +174 -0
  270. package/src/services/document-assistant.ts +59 -8
  271. package/src/services/idle.ts +16 -14
  272. package/src/services/live-surfaces.ts +237 -0
  273. package/src/services/model-uri.ts +75 -0
  274. package/src/services/notify.ts +63 -6
  275. package/src/services/popover-report.ts +325 -0
  276. package/src/services/surface-registry.ts +56 -0
  277. package/src/services/tool-executor.ts +6 -0
  278. package/src/settings/contexts-section.ts +301 -299
  279. package/src/settings/contributed-section.ts +361 -222
  280. package/src/settings/css-vars-editor.ts +320 -325
  281. package/src/settings/defs-editor.ts +572 -535
  282. package/src/settings/dependencies-editor.ts +79 -107
  283. package/src/settings/extension-commands.ts +379 -0
  284. package/src/settings/extension-rows.ts +113 -0
  285. package/src/settings/extensions-section.ts +287 -0
  286. package/src/settings/general-settings.ts +130 -181
  287. package/src/settings/head-editor.ts +10 -305
  288. package/src/settings/locales-section.ts +146 -196
  289. package/src/settings/preferences-accounts.ts +1 -1
  290. package/src/settings/preferences-dialog.ts +350 -330
  291. package/src/settings/project-sections.ts +108 -181
  292. package/src/settings/schema-field-ui.ts +11 -399
  293. package/src/settings/section-registry.ts +8 -1
  294. package/src/settings/settings-document.ts +31 -29
  295. package/src/shell/tree.ts +42 -87
  296. package/src/shell.ts +48 -36
  297. package/src/studio.ts +104 -69
  298. package/src/style/token-ref.ts +0 -39
  299. package/src/surfaces/about.json +263 -0
  300. package/src/surfaces/about.ts +163 -0
  301. package/src/surfaces/add-repo.json +486 -0
  302. package/src/surfaces/add-repo.ts +236 -0
  303. package/src/surfaces/ai-chat.json +2185 -0
  304. package/src/surfaces/ai-chat.ts +549 -0
  305. package/src/surfaces/ai-credentials-form.json +332 -0
  306. package/src/surfaces/ai-credentials-form.ts +151 -0
  307. package/src/surfaces/ai-managed-connect.json +108 -0
  308. package/src/surfaces/ai-managed-connect.ts +123 -0
  309. package/src/surfaces/ai-model-picker.json +114 -0
  310. package/src/surfaces/ai-model-picker.ts +139 -0
  311. package/src/surfaces/block-action-bar.json +640 -0
  312. package/src/surfaces/block-action-bar.ts +368 -0
  313. package/src/surfaces/bottom-dock.json +154 -0
  314. package/src/surfaces/bottom-dock.ts +125 -0
  315. package/src/surfaces/canvas-stage.json +444 -0
  316. package/src/surfaces/canvas-stage.ts +253 -0
  317. package/src/surfaces/cf-account-picker.json +300 -0
  318. package/src/surfaces/cf-account-picker.ts +214 -0
  319. package/src/surfaces/commandbar.json +985 -0
  320. package/src/{panels/toolbar.ts → surfaces/commandbar.ts} +417 -391
  321. package/src/surfaces/convert-repeater.json +309 -0
  322. package/src/surfaces/convert-repeater.ts +276 -0
  323. package/src/surfaces/data-actions.json +157 -0
  324. package/src/surfaces/data-actions.ts +115 -0
  325. package/src/surfaces/dialog.json +289 -0
  326. package/src/surfaces/dialog.ts +343 -0
  327. package/src/surfaces/diff-toolbar.json +266 -0
  328. package/src/surfaces/diff-toolbar.ts +139 -0
  329. package/src/surfaces/doc-header.json +739 -0
  330. package/src/surfaces/doc-header.ts +223 -0
  331. package/src/surfaces/empty-state.json +152 -0
  332. package/src/surfaces/empty-state.ts +173 -0
  333. package/src/surfaces/entry-editor.json +281 -0
  334. package/src/surfaces/entry-editor.ts +191 -0
  335. package/src/surfaces/expression-editor.json +977 -0
  336. package/src/surfaces/expression-editor.ts +266 -0
  337. package/src/surfaces/files-panel.json +592 -0
  338. package/src/surfaces/files-panel.ts +301 -0
  339. package/src/surfaces/formula-palette.json +364 -0
  340. package/src/surfaces/formula-palette.ts +340 -0
  341. package/src/surfaces/git-panel.json +1822 -0
  342. package/src/surfaces/git-panel.ts +272 -0
  343. package/src/surfaces/github-auth.json +112 -0
  344. package/src/surfaces/github-auth.ts +139 -0
  345. package/src/surfaces/github-publish.json +206 -0
  346. package/src/surfaces/github-publish.ts +169 -0
  347. package/src/surfaces/grid-cell.json +218 -0
  348. package/src/surfaces/grid-cell.ts +120 -0
  349. package/src/surfaces/grid-open.json +147 -0
  350. package/src/surfaces/grid-open.ts +87 -0
  351. package/src/surfaces/grid-panel.json +706 -0
  352. package/src/surfaces/grid-panel.ts +206 -0
  353. package/src/surfaces/grid-replace.json +179 -0
  354. package/src/surfaces/grid-replace.ts +89 -0
  355. package/src/surfaces/grid-views.json +446 -0
  356. package/src/surfaces/grid-views.ts +172 -0
  357. package/src/surfaces/inspector-dock.json +187 -0
  358. package/src/surfaces/inspector-dock.ts +161 -0
  359. package/src/surfaces/jump-bar.json +243 -0
  360. package/src/surfaces/jump-bar.ts +129 -0
  361. package/src/surfaces/jxsuite-update.json +146 -0
  362. package/src/surfaces/jxsuite-update.ts +149 -0
  363. package/src/surfaces/library-pane.json +1509 -0
  364. package/src/surfaces/library-pane.ts +363 -0
  365. package/src/surfaces/logic-panel.json +1949 -0
  366. package/src/surfaces/logic-panel.ts +369 -0
  367. package/src/surfaces/logic-workspace.json +685 -0
  368. package/src/surfaces/logic-workspace.ts +238 -0
  369. package/src/surfaces/media-browser.json +303 -0
  370. package/src/surfaces/media-browser.ts +145 -0
  371. package/src/surfaces/media-field.json +163 -0
  372. package/src/surfaces/media-field.ts +116 -0
  373. package/src/surfaces/media-pane.json +513 -0
  374. package/src/surfaces/media-pane.ts +197 -0
  375. package/src/surfaces/menu.json +232 -0
  376. package/src/surfaces/menu.ts +375 -0
  377. package/src/surfaces/navigator-dock.json +113 -0
  378. package/src/surfaces/navigator-dock.ts +130 -0
  379. package/src/surfaces/new-project.json +1654 -0
  380. package/src/surfaces/new-project.ts +411 -0
  381. package/src/surfaces/palette.json +535 -0
  382. package/src/surfaces/pane-context.json +1497 -0
  383. package/src/surfaces/pane-context.ts +513 -0
  384. package/src/surfaces/pane-grid.json +188 -0
  385. package/src/surfaces/pane-grid.ts +250 -0
  386. package/src/surfaces/panel-activity.json +563 -0
  387. package/src/surfaces/panel-activity.ts +187 -0
  388. package/src/surfaces/panel-data.json +141 -0
  389. package/src/surfaces/panel-data.ts +156 -0
  390. package/src/surfaces/panel-deploy-checklist.json +283 -0
  391. package/src/surfaces/panel-deploy-checklist.ts +175 -0
  392. package/src/surfaces/panel-elements.json +367 -0
  393. package/src/surfaces/panel-elements.ts +175 -0
  394. package/src/surfaces/panel-i18n.json +569 -0
  395. package/src/surfaces/panel-i18n.ts +212 -0
  396. package/src/surfaces/panel-imports.json +780 -0
  397. package/src/surfaces/panel-imports.ts +209 -0
  398. package/src/surfaces/panel-outline.json +734 -0
  399. package/src/surfaces/panel-outline.ts +326 -0
  400. package/src/surfaces/panel-page.json +1017 -0
  401. package/src/surfaces/panel-page.ts +240 -0
  402. package/src/surfaces/panel-problems.json +497 -0
  403. package/src/surfaces/panel-problems.ts +157 -0
  404. package/src/surfaces/panel-signals.json +1973 -0
  405. package/src/surfaces/panel-signals.ts +436 -0
  406. package/src/surfaces/panel-stylebook-layers.json +317 -0
  407. package/src/surfaces/panel-stylebook-layers.ts +155 -0
  408. package/src/surfaces/preferences.json +850 -0
  409. package/src/surfaces/preferences.ts +332 -0
  410. package/src/surfaces/progress-modal.json +110 -0
  411. package/src/surfaces/progress-modal.ts +150 -0
  412. package/src/surfaces/properties-panel.json +1578 -0
  413. package/src/surfaces/properties-panel.ts +337 -0
  414. package/src/surfaces/publish.json +945 -0
  415. package/src/surfaces/publish.ts +392 -0
  416. package/src/surfaces/push-plan.json +110 -0
  417. package/src/surfaces/push-plan.ts +87 -0
  418. package/src/surfaces/rail.json +255 -0
  419. package/src/surfaces/rail.ts +206 -0
  420. package/src/surfaces/reference-field.json +191 -0
  421. package/src/surfaces/reference-field.ts +168 -0
  422. package/src/surfaces/schema-builder.json +1011 -0
  423. package/src/surfaces/schema-builder.ts +181 -0
  424. package/src/surfaces/schema-form.json +1013 -0
  425. package/src/surfaces/schema-form.ts +287 -0
  426. package/src/surfaces/secret-field.json +60 -0
  427. package/src/surfaces/secret-field.ts +146 -0
  428. package/src/surfaces/seo.json +932 -0
  429. package/src/surfaces/seo.ts +334 -0
  430. package/src/surfaces/settings-contexts.json +538 -0
  431. package/src/surfaces/settings-contexts.ts +196 -0
  432. package/src/surfaces/settings-contributed.json +489 -0
  433. package/src/surfaces/settings-contributed.ts +199 -0
  434. package/src/surfaces/settings-css-vars.json +820 -0
  435. package/src/surfaces/settings-css-vars.ts +199 -0
  436. package/src/surfaces/settings-defs.json +1363 -0
  437. package/src/surfaces/settings-defs.ts +232 -0
  438. package/src/surfaces/settings-deploy.json +108 -0
  439. package/src/surfaces/settings-deploy.ts +135 -0
  440. package/src/surfaces/settings-extensions.json +486 -0
  441. package/src/surfaces/settings-extensions.ts +201 -0
  442. package/src/surfaces/settings-head.json +779 -0
  443. package/src/surfaces/settings-head.ts +397 -0
  444. package/src/surfaces/settings-locales.json +420 -0
  445. package/src/surfaces/settings-locales.ts +137 -0
  446. package/src/surfaces/settings-overview.json +423 -0
  447. package/src/surfaces/settings-overview.ts +218 -0
  448. package/src/surfaces/settings-packages.json +549 -0
  449. package/src/surfaces/settings-packages.ts +158 -0
  450. package/src/surfaces/settings-pane.json +147 -0
  451. package/src/surfaces/settings-pane.ts +150 -0
  452. package/src/surfaces/settings-rawjson.json +104 -0
  453. package/src/surfaces/settings-rawjson.ts +107 -0
  454. package/src/surfaces/shell.json +99 -0
  455. package/src/surfaces/shell.ts +30 -0
  456. package/src/surfaces/slash-menu.json +180 -0
  457. package/src/surfaces/slash-menu.ts +272 -0
  458. package/src/surfaces/statements.json +607 -0
  459. package/src/surfaces/statements.ts +238 -0
  460. package/src/surfaces/statusbar.json +94 -0
  461. package/src/{panels → surfaces}/statusbar.ts +164 -90
  462. package/src/surfaces/style-panel.json +1643 -0
  463. package/src/surfaces/style-panel.ts +338 -0
  464. package/src/surfaces/stylebook-chrome.json +122 -0
  465. package/src/surfaces/stylebook-chrome.ts +122 -0
  466. package/src/surfaces/tab-strip.json +448 -0
  467. package/src/surfaces/tab-strip.ts +200 -0
  468. package/src/surfaces/target-line.json +419 -0
  469. package/src/surfaces/target-line.ts +349 -0
  470. package/src/surfaces/toasts.json +189 -0
  471. package/src/surfaces/welcome.json +571 -0
  472. package/src/surfaces/welcome.ts +338 -0
  473. package/src/tabs/project-config.ts +111 -21
  474. package/src/tabs/tab.ts +52 -1
  475. package/src/types.ts +22 -0
  476. package/src/ui/ai-credentials-form.ts +104 -100
  477. package/src/ui/ai-managed-connect.ts +54 -36
  478. package/src/ui/ai-model-picker.ts +75 -47
  479. package/src/ui/cf-account-picker.ts +76 -141
  480. package/src/ui/color-selector.ts +80 -301
  481. package/src/ui/dynamic-slot.ts +43 -283
  482. package/src/ui/expression-editor.ts +797 -576
  483. package/src/ui/field-input.ts +8 -181
  484. package/src/ui/form-controls.ts +838 -366
  485. package/src/ui/formula-chips.ts +80 -85
  486. package/src/ui/kit.ts +33 -0
  487. package/src/ui/layers.ts +296 -593
  488. package/src/ui/media-picker.ts +203 -284
  489. package/src/ui/panel-resize.ts +251 -64
  490. package/src/ui/popover-surface.ts +153 -0
  491. package/src/ui/progress-modal.ts +22 -60
  492. package/src/ui/regions.ts +13 -7
  493. package/src/ui/schema-form.ts +906 -440
  494. package/src/ui/surface.ts +122 -0
  495. package/src/ui/unit-selector.ts +15 -131
  496. package/src/ui/value-source.ts +14 -0
  497. package/src/ui/virtual-window.ts +88 -9
  498. package/src/utils/canvas-media.ts +72 -0
  499. package/src/utils/edit-display.ts +7 -2
  500. package/src/utils/element-selectors.ts +69 -0
  501. package/src/utils/link-target.ts +2 -2
  502. package/src/utils/studio-utils.ts +0 -10
  503. package/src/view.ts +15 -0
  504. package/src/workspace/pane-derive.ts +36 -14
  505. package/src/workspace/workspace.ts +75 -6
  506. package/styles/canvas.css +72 -467
  507. package/styles/forced-colors.css +48 -82
  508. package/styles/forced-colors.json +41 -0
  509. package/styles/inspector.css +2 -1301
  510. package/styles/overlays.css +96 -2823
  511. package/styles/panels.css +6 -1423
  512. package/styles/shell-frame.css +272 -0
  513. package/styles/shell-frame.json +227 -0
  514. package/styles/shell.css +0 -1568
  515. package/styles/tokens.css +65 -136
  516. package/styles/tokens.json +84 -0
  517. package/dist/chunks/Overlay.dev-etqjwyf9.js +0 -23
  518. package/dist/chunks/adapter-jkcyhgtr.js +0 -14
  519. package/dist/chunks/cf-account-picker-en86v7x7.js +0 -163
  520. package/dist/chunks/cf-settings-45fgyx8y.js +0 -21
  521. package/dist/chunks/components-zmx10t62.js +0 -21
  522. package/dist/chunks/content-source-48xg86wj.js +0 -49
  523. package/dist/chunks/convert-to-repeater-43tfn7cs.js +0 -268
  524. package/dist/chunks/editor-cptq5jp1.js +0 -37
  525. package/dist/chunks/entry-commands-e63f1xc0.js +0 -46
  526. package/dist/chunks/extension-sections-txv08xxg.js +0 -311
  527. package/dist/chunks/file-ops-wbh4hhsx.js +0 -48
  528. package/dist/chunks/files-3kfkwhk4.js +0 -93
  529. package/dist/chunks/flow-qbfgrpeh.js +0 -634
  530. package/dist/chunks/focus-trap.esm-9t2drp0g.js +0 -1025
  531. package/dist/chunks/focus-visible-6eg70z18.js +0 -167
  532. package/dist/chunks/format-host-w16q81tf.js +0 -43
  533. package/dist/chunks/fs-events-hrrg328g.js +0 -21
  534. package/dist/chunks/git-panel-532whr1y.js +0 -59
  535. package/dist/chunks/index-zqxmqxmh.js +0 -109
  536. package/dist/chunks/jx-validate-8er6gbxy.js +0 -19
  537. package/dist/chunks/layers-panel-07hm7g5j.js +0 -67
  538. package/dist/chunks/layers-q75tj2mf.js +0 -45
  539. package/dist/chunks/lit-html-j055mkh8.js +0 -22
  540. package/dist/chunks/monaco-buffer-dqw0xxpx.js +0 -25
  541. package/dist/chunks/notify-yjm79n4s.js +0 -30
  542. package/dist/chunks/parse-24d0gay3.js +0 -19
  543. package/dist/chunks/platform-ba1j1gbh.js +0 -16
  544. package/dist/chunks/publish-panel-v9st96ja.js +0 -29
  545. package/dist/chunks/quick-search-zccjp6gv.js +0 -66
  546. package/dist/chunks/references-3qx8fkyp.js +0 -29
  547. package/dist/chunks/right-panel-vm3b6kwy.js +0 -46
  548. package/dist/chunks/section-registry-sx1ykvkw.js +0 -30
  549. package/dist/chunks/sp-overlay.dev-qgvhnxf4.js +0 -18
  550. package/dist/chunks/sp-popover.dev-n2etmqdp.js +0 -9
  551. package/dist/chunks/sp-progress-circle.dev-hryhj0es.js +0 -15
  552. package/dist/chunks/sp-tooltip.dev-4sastdnw.js +0 -15
  553. package/dist/chunks/sp-tray.dev-tkbscm06.js +0 -199
  554. package/dist/chunks/studio-0a5qrh01.js +0 -3
  555. package/dist/chunks/studio-0bq6eh7v.js +0 -12
  556. package/dist/chunks/studio-18j3bmcz.js +0 -14
  557. package/dist/chunks/studio-1ngbejft.js +0 -181
  558. package/dist/chunks/studio-4b5z1x43.js +0 -424
  559. package/dist/chunks/studio-4n2b5gzb.js +0 -357
  560. package/dist/chunks/studio-4rzyrtjz.js +0 -426
  561. package/dist/chunks/studio-5fx3g9jg.js +0 -4325
  562. package/dist/chunks/studio-5myknm0a.js +0 -1903
  563. package/dist/chunks/studio-7afd21nw.js +0 -67
  564. package/dist/chunks/studio-7nte2hj4.js +0 -613
  565. package/dist/chunks/studio-8jpzqk5s.js +0 -128
  566. package/dist/chunks/studio-8q517dfr.js +0 -24
  567. package/dist/chunks/studio-950k0dx6.js +0 -6939
  568. package/dist/chunks/studio-9n4mrmnb.js +0 -184
  569. package/dist/chunks/studio-a0tswy0w.js +0 -58
  570. package/dist/chunks/studio-ahnzd9rg.js +0 -23
  571. package/dist/chunks/studio-bgxt93ga.js +0 -62
  572. package/dist/chunks/studio-cmb03bg5.js +0 -13890
  573. package/dist/chunks/studio-d1ks410h.js +0 -175
  574. package/dist/chunks/studio-ef49pnzx.js +0 -387
  575. package/dist/chunks/studio-eqq1w638.js +0 -113
  576. package/dist/chunks/studio-ew0djmhg.js +0 -341
  577. package/dist/chunks/studio-gfgb8pe6.js +0 -1652
  578. package/dist/chunks/studio-h4rxscfc.js +0 -10
  579. package/dist/chunks/studio-jc994dnr.js +0 -1066
  580. package/dist/chunks/studio-kyh9avvv.js +0 -28
  581. package/dist/chunks/studio-m3hwn7y1.js +0 -120
  582. package/dist/chunks/studio-mtfnaqs9.js +0 -659
  583. package/dist/chunks/studio-n6j9t10q.js +0 -318
  584. package/dist/chunks/studio-n8b9wqwy.js +0 -291
  585. package/dist/chunks/studio-qcy05dp8.js +0 -1743
  586. package/dist/chunks/studio-qq6jym04.js +0 -53
  587. package/dist/chunks/studio-rdx8jcxy.js +0 -83
  588. package/dist/chunks/studio-rn9ta2mz.js +0 -111
  589. package/dist/chunks/studio-t7qb9db8.js +0 -665
  590. package/dist/chunks/studio-tmc5emrw.js +0 -8
  591. package/dist/chunks/studio-z6nw2ek2.js +0 -18
  592. package/dist/chunks/studio-zczps70q.js +0 -378
  593. package/dist/chunks/studio-zqazsct2.js +0 -1823
  594. package/dist/chunks/workspace-fjx52ryv.js +0 -89
  595. package/src/panels/activity-bar.ts +0 -251
  596. package/src/panels/panel-scheduler.ts +0 -219
  597. package/src/panels/style-inputs.ts +0 -237
  598. package/src/panels/target-line.ts +0 -274
  599. package/src/panels/welcome-screen.ts +0 -346
  600. package/src/ui/button-group.ts +0 -102
  601. package/src/ui/choice-field.ts +0 -72
  602. package/src/ui/field-row.ts +0 -249
  603. package/src/ui/formula-palette.ts +0 -213
  604. package/src/ui/icons.ts +0 -52
  605. package/src/ui/jx-theme.ts +0 -130
  606. package/src/ui/spectrum.ts +0 -340
  607. package/src/ui/value-selector.ts +0 -174
  608. package/src/ui/widgets.ts +0 -172
  609. /package/dist/chunks/{javascript-s56a8dpk.css → javascript-4abzjcy9.css} +0 -0
  610. /package/dist/chunks/{jsonMode-zr9sw0c7.css → jsonMode-vvmpmk34.css} +0 -0
  611. /package/dist/chunks/{monaco-setup-pav68602.css → monaco-setup-8vbyqnhr.css} +0 -0
  612. /package/dist/chunks/{tsMode-ef187txx.css → tsMode-hnxxb73h.css} +0 -0
@@ -0,0 +1,2432 @@
1
+ import {
2
+ nothing2
3
+ } from "./studio-1k325pwf.js";
4
+ import {
5
+ errorMessage2
6
+ } from "./studio-yxa81f45.js";
7
+ import {
8
+ localeLabel,
9
+ resolveI18n,
10
+ localeOfPath,
11
+ isCollabPath,
12
+ collectionForDirectory,
13
+ collectionForFile,
14
+ workspace2,
15
+ paneOfTab2,
16
+ receivingPane2,
17
+ setWorkspaceProject2,
18
+ openTab2,
19
+ replaceAllTabs2,
20
+ activateTab2,
21
+ moveTabToPane2,
22
+ renameTab2
23
+ } from "./studio-k75n7vhp.js";
24
+ import {
25
+ registerSurface,
26
+ mountSurface,
27
+ runReported,
28
+ runActiveReported,
29
+ showPromptDialog2
30
+ } from "./studio-vfq8qpjt.js";
31
+ import {
32
+ activeRegistry
33
+ } from "./studio-kkqkcp3d.js";
34
+ import {
35
+ reactive,
36
+ now,
37
+ notify2
38
+ } from "./studio-p1dw8wfw.js";
39
+ import {
40
+ projectState,
41
+ setProjectState,
42
+ requireProjectState
43
+ } from "./studio-6ewqv390.js";
44
+ import {
45
+ getPlatform2,
46
+ hasPlatform2
47
+ } from "./studio-6nzaktvy.js";
48
+ import {
49
+ loadFormats2,
50
+ refreshFormats2,
51
+ refreshExtensionUi2,
52
+ getFormats2,
53
+ formatByExtension2,
54
+ noFormatError2,
55
+ formatForPath2,
56
+ documentExtensions2
57
+ } from "./studio-vw7mzp6z.js";
58
+ import {
59
+ resetIgnoreCache,
60
+ ensureIgnoreLayers,
61
+ isIgnoredEntry,
62
+ markLocalMutation2
63
+ } from "./studio-g3jevyjt.js";
64
+ import {
65
+ invalidateUsages2
66
+ } from "./studio-nq5yf5mp.js";
67
+ import {
68
+ parseJsonDocument,
69
+ restoreSession,
70
+ persistedSession,
71
+ markSessionRestored,
72
+ setActivityTab,
73
+ resetProjectShell
74
+ } from "./studio-qk90fgqm.js";
75
+ import {
76
+ SETTINGS,
77
+ readStoredSetting,
78
+ setSetting
79
+ } from "./studio-y9zedyjn.js";
80
+ import {
81
+ showProgressModal
82
+ } from "./studio-tqgryxwg.js";
83
+ import {
84
+ registerPanel
85
+ } from "./studio-8scdew0e.js";
86
+ import {
87
+ disarmPreviewOverlay,
88
+ parseSourceForPath2,
89
+ confirmFileDelete2,
90
+ renamePromptMessage2
91
+ } from "./studio-gb13095a.js";
92
+ import {
93
+ loadComponentRegistry2
94
+ } from "./studio-zdn2g6dt.js";
95
+ import {
96
+ combine,
97
+ dropTargetForElements2,
98
+ monitorForElements2,
99
+ draggable2
100
+ } from "./studio-esrxgwh6.js";
101
+ import {
102
+ shouldInstallAutomation,
103
+ maybePromptJxsuiteUpdate,
104
+ autoSyncProjectOnOpen,
105
+ isViewableMedia,
106
+ openMediaTab,
107
+ cleanupGitPanel2
108
+ } from "./studio-5wt9nvhd.js";
109
+ import {
110
+ uploadAccept,
111
+ isImage,
112
+ uploadAssets
113
+ } from "./studio-jxp12rnj.js";
114
+ import {
115
+ openCsvGridTab,
116
+ openPagesGrid
117
+ } from "./studio-pxbgypmg.js";
118
+ import {
119
+ openMenu2
120
+ } from "./studio-aj37eer3.js";
121
+ import {
122
+ listWindow,
123
+ revealListRow,
124
+ watchListWindow
125
+ } from "./studio-38emantv.js";
126
+ import {
127
+ collectionOfPath
128
+ } from "./studio-qhhm6hbt.js";
129
+ import {
130
+ __preload
131
+ } from "./studio-5te5tqng.js";
132
+
133
+ // src/packages/ensure-deps.ts
134
+ async function ensureDependenciesInstalled() {
135
+ if (shouldInstallAutomation(location.search)) {
136
+ return false;
137
+ }
138
+ const platform = getPlatform2();
139
+ if (!platform.dependenciesNeedInstall || !platform.installDependencies) {
140
+ return false;
141
+ }
142
+ let needs = false;
143
+ try {
144
+ needs = await platform.dependenciesNeedInstall();
145
+ } catch {
146
+ return false;
147
+ }
148
+ if (!needs) {
149
+ return false;
150
+ }
151
+ const progress = showProgressModal({
152
+ status: "Running bun install…",
153
+ title: "Installing dependencies"
154
+ });
155
+ try {
156
+ const result = await platform.installDependencies();
157
+ if (result.ok) {
158
+ progress.done();
159
+ return true;
160
+ }
161
+ progress.fail(result.log ?? "bun install failed");
162
+ } catch (error) {
163
+ progress.fail(error instanceof Error ? error.message : String(error));
164
+ }
165
+ return false;
166
+ }
167
+
168
+ // src/format/format-choices.ts
169
+ var DOCUMENT_KINDS = ["page", "component"];
170
+ var DOCUMENT_ROOTS = { components: "component", pages: "page" };
171
+ function normalize(path) {
172
+ return path.replaceAll("\\", "/").replace(/^\.\//, "");
173
+ }
174
+ function documentRootOf(path) {
175
+ const lower = normalize(path).toLowerCase();
176
+ for (const [dir, kind] of Object.entries(DOCUMENT_ROOTS)) {
177
+ if (lower.startsWith(`${dir}/`)) {
178
+ return kind;
179
+ }
180
+ }
181
+ return null;
182
+ }
183
+ function declaresDocumentKind(kinds) {
184
+ return DOCUMENT_KINDS.some((kind) => kinds.includes(kind));
185
+ }
186
+ function isLayoutPath(path) {
187
+ const declared = projectState?.projectConfig?.layout;
188
+ if (typeof declared !== "string") {
189
+ return false;
190
+ }
191
+ return normalize(declared).toLowerCase() === normalize(path).toLowerCase();
192
+ }
193
+ function creationFormats(kind) {
194
+ const rows = [{ ext: ".json", label: "JSON (.json)" }];
195
+ for (const ext of documentExtensions2(kind)) {
196
+ const reader = formatByExtension2(ext, "parse");
197
+ if (reader && formatByExtension2(ext, "serialize")) {
198
+ rows.push({ ext, label: `${reader.name} (${ext})` });
199
+ }
200
+ }
201
+ return rows;
202
+ }
203
+ function knownDocumentExtensions() {
204
+ return new Set([".json", ...getFormats2().flatMap((format) => format.extensions)]);
205
+ }
206
+ function convertTargets(path) {
207
+ if (path === null || path === undefined || path === "") {
208
+ return [];
209
+ }
210
+ const root = documentRootOf(path);
211
+ if (root === null || isLayoutPath(path) || collectionForFile(path)) {
212
+ return [];
213
+ }
214
+ const source = formatForPath2(path);
215
+ const readable = source ? Boolean(source.capabilities.parse) && declaresDocumentKind(source.documentKinds) : normalize(path).toLowerCase().endsWith(".json");
216
+ if (!readable) {
217
+ return [];
218
+ }
219
+ const rows = [];
220
+ if (source) {
221
+ rows.push({ ext: ".json", label: "JSON (.json)" });
222
+ }
223
+ for (const ext of documentExtensions2()) {
224
+ const writer = formatByExtension2(ext, "serialize");
225
+ if (!writer || writer.name === source?.name || !declaresDocumentKind(writer.documentKinds) || !writer.documentKinds.includes(root)) {
226
+ continue;
227
+ }
228
+ rows.push({ ext, label: `${writer.name} (${ext})` });
229
+ }
230
+ return rows;
231
+ }
232
+ function convertTargetExtensions() {
233
+ const exts = new Set([".json"]);
234
+ for (const format of getFormats2()) {
235
+ if (!format.capabilities.serialize || !declaresDocumentKind(format.documentKinds)) {
236
+ continue;
237
+ }
238
+ for (const ext of format.extensions) {
239
+ exts.add(ext);
240
+ }
241
+ }
242
+ return [...exts].toSorted();
243
+ }
244
+
245
+ // src/recent-projects.ts
246
+ var STORAGE_KEY = "jx-studio-recent-projects";
247
+ var FILES_STORAGE_KEY = "jx-studio-recent-files";
248
+ var MAX_RECENT = 8;
249
+ var MAX_RECENT_FILES = 10;
250
+ var cache = [];
251
+ function backend() {
252
+ if (!hasPlatform2()) {
253
+ return null;
254
+ }
255
+ const platform = getPlatform2();
256
+ return platform.getRecentProjects && platform.saveRecentProjects ? platform : null;
257
+ }
258
+ function loadFromLocalStorage() {
259
+ try {
260
+ const raw = localStorage.getItem(STORAGE_KEY);
261
+ if (!raw) {
262
+ return [];
263
+ }
264
+ const parsed = JSON.parse(raw);
265
+ return Array.isArray(parsed) ? parsed : [];
266
+ } catch {
267
+ return [];
268
+ }
269
+ }
270
+ function currentList() {
271
+ return backend() ? cache : loadFromLocalStorage();
272
+ }
273
+ function commit(list) {
274
+ cache = list;
275
+ const store = backend();
276
+ if (store) {
277
+ store.saveRecentProjects(list);
278
+ } else {
279
+ try {
280
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(list));
281
+ } catch {}
282
+ }
283
+ }
284
+ async function hydrateRecentProjects() {
285
+ const store = backend();
286
+ if (!store) {
287
+ return;
288
+ }
289
+ try {
290
+ cache = await store.getRecentProjects();
291
+ } catch {
292
+ cache = [];
293
+ }
294
+ }
295
+ function getRecentProjects() {
296
+ return currentList().toSorted((a, b) => b.timestamp - a.timestamp);
297
+ }
298
+ function addRecentProject(name, root) {
299
+ const projects = currentList().filter((p) => p.root !== root);
300
+ projects.unshift({ name, root, timestamp: now() });
301
+ if (projects.length > MAX_RECENT) {
302
+ projects.length = MAX_RECENT;
303
+ }
304
+ commit(projects);
305
+ }
306
+ function removeRecentProject(root) {
307
+ commit(currentList().filter((p) => p.root !== root));
308
+ }
309
+ function clearRecentProjects() {
310
+ cache = [];
311
+ const store = backend();
312
+ if (store) {
313
+ store.saveRecentProjects([]);
314
+ } else {
315
+ localStorage.removeItem(STORAGE_KEY);
316
+ }
317
+ }
318
+ function loadRecentFiles() {
319
+ try {
320
+ const raw = localStorage.getItem(FILES_STORAGE_KEY);
321
+ if (!raw) {
322
+ return [];
323
+ }
324
+ const parsed = JSON.parse(raw);
325
+ return Array.isArray(parsed) ? parsed : [];
326
+ } catch {
327
+ return [];
328
+ }
329
+ }
330
+ function getRecentFiles(root) {
331
+ const all = loadRecentFiles().toSorted((a, b) => b.timestamp - a.timestamp);
332
+ return root == null ? all : all.filter((f) => f.root === root);
333
+ }
334
+ function trackRecentFile(file) {
335
+ const all = loadRecentFiles().filter((f) => !(f.root === file.root && f.path === file.path));
336
+ all.unshift({ name: file.name, path: file.path, root: file.root, timestamp: now() });
337
+ const perRoot = new Map;
338
+ const kept = [];
339
+ for (const f of all.toSorted((a, b) => b.timestamp - a.timestamp)) {
340
+ const n = (perRoot.get(f.root) ?? 0) + 1;
341
+ perRoot.set(f.root, n);
342
+ if (n <= MAX_RECENT_FILES) {
343
+ kept.push(f);
344
+ }
345
+ }
346
+ localStorage.setItem(FILES_STORAGE_KEY, JSON.stringify(kept));
347
+ }
348
+ // src/surfaces/files-panel.json
349
+ var files_panel_default = {
350
+ $schema: "https://jxsuite.com/schema/v1",
351
+ $id: "StudioFilesPanel",
352
+ $description: 'The Navigator\'s Files tree, as a Jx document over the kit. `files/files.ts` keeps every decision — which directories are listed, which entries `.gitignore` masks, which rows the window draws, what a click on a row means, what the context menu offers and what each verb does to the filesystem — and hands this document one projection: a word saying which of three things to draw, a toolbar whose state is already resolved, and rows whose every field is already a string. Nothing here asks what a file is, how tall the Navigator is, or whether a directory has been read. THE TREE IS `jx-tree`, and that is what this document no longer says: `role="tree"`, `role="treeitem"`, `aria-level`, `aria-posinset`, `aria-setsize`, the roving `tabindex` and the five arrow-key cases were each written out here and written out again in `panel-outline.json`, two copies of one keyboard contract with nothing holding them in agreement. The element owns all of it; what is left here is what this tree IS — a flat projection of rows, each already carrying its own level and set counts, because the DOM holds a WINDOW onto the model and an expanded `node_modules` is eleven rows rather than ten thousand. The window reaches the element as `padtop`/`padbottom`, and a caret move past either comes back as `move` for the flow to scroll and repaint. Four facts a row carries are bound against ONE scope field each — the current path, the selected path, the dragged path and the drop target — so moving the caret or dragging a file re-evaluates an attribute per drawn row instead of rebuilding the list under the reader\'s pointer. The pragmatic-drag-and-drop handles are an ISLAND: the document draws the rows and the tree, and the adapter attaches sources and targets to them through `onNodeCreated` (specs/studio-ui-guidelines.md §9.4).',
353
+ tagName: "div",
354
+ attributes: {
355
+ part: "files"
356
+ },
357
+ style: {
358
+ $description: "What the twenty `.file-tree*`, `.files-toolbar`, `.project-header` and `.project-name` rules in `styles/panels.css` said, keyed on `part` and re-pointed at the studio token layer. Three names could not come with the declarations. The five `var(--spectrum-font-size-50 | -75, …)` reads are the kit's `--jx-text-sm` and `--jx-text-md`, which are the same 11px and 12px — a `--spectrum-*` name is declared by `<sp-theme>` and by nothing else in this package, so a document that reads one is a document whose type size changes when a component it does not use is removed. The `.selected`, `.dragging`, `.drag-over` and `.drag-over-root` classes are `data-` attributes on a part, because a part is the handle now and because a state a handler adds and forgets to take off is exactly the defect a cancelled drag used to leave on screen. MOST OF THE ROW'S OWN RULES ARE GONE, and that is the point of the element rather than an omission: `jx-tree-item` declares the flex line, the one-control-height box the window reserves scroll by, the indent (`--jx-tree-indent` times one less than `level` — exactly the `8 + depth * 16` this file composed per row), the hover and focus states, the selected wash and the faded dragged row. What is left here is what is TRUE OF THIS TREE and not of trees in general: it owns its own scrollbar, a click on a row opens it, and the row a drag is over wears the drop mark this file draws.",
359
+ display: "flex",
360
+ flexDirection: "column",
361
+ height: "100%",
362
+ minHeight: "0",
363
+ overflow: "hidden",
364
+ fontFamily: "var(--jx-font-sans)",
365
+ fontSize: "var(--jx-text-md)",
366
+ color: "var(--fg)",
367
+ '& [part="empty"]': {
368
+ $description: "The two states that are not a tree. They are two states and not one sentence: a window with no project at all and a monorepo root that has not been pointed at a site are different situations, and only the second has anything to offer (§11).",
369
+ padding: "var(--jx-space-6)",
370
+ textAlign: "center",
371
+ color: "var(--fg-dim)",
372
+ fontSize: "var(--jx-text-md)",
373
+ display: "flex",
374
+ flexDirection: "column",
375
+ alignItems: "center",
376
+ gap: "var(--jx-space-4)"
377
+ },
378
+ '& [part="empty"] p': {
379
+ margin: "0"
380
+ },
381
+ '& [part="frame"]': {
382
+ display: "flex",
383
+ flexDirection: "column",
384
+ height: "100%",
385
+ minHeight: "0"
386
+ },
387
+ '& [part="project-header"]': {
388
+ display: "flex",
389
+ alignItems: "center",
390
+ gap: "var(--jx-space-3)",
391
+ padding: "var(--jx-space-3) var(--jx-space-4)",
392
+ borderBottom: "1px solid var(--border)",
393
+ flexShrink: "0"
394
+ },
395
+ '& [part="project-name"]': {
396
+ fontSize: "var(--jx-text-md)",
397
+ fontWeight: "600",
398
+ overflow: "hidden",
399
+ textOverflow: "ellipsis",
400
+ whiteSpace: "nowrap"
401
+ },
402
+ '& [part="toolbar"]': {
403
+ display: "flex",
404
+ gap: "var(--jx-space-2)",
405
+ padding: "var(--jx-space-2) var(--jx-space-3)",
406
+ borderBottom: "1px solid var(--border)",
407
+ alignItems: "center",
408
+ flexShrink: "0"
409
+ },
410
+ '& [part="search"]': {
411
+ flex: "1",
412
+ minWidth: "0"
413
+ },
414
+ '& [part="tree"]': {
415
+ $description: "The scroller as well as the list. `ui/virtual-window.ts` walks up from the element it is given looking for the nearest thing that scrolls, and finding itself is the shortest answer — which is why the element declares no `overflow` of its own and leaves the question to the two trees that answer it differently. The colour is re-declared because `jx-tree` sets `--jx-fg` on itself, and this panel's text colour is the studio alias of it.",
416
+ flex: "1",
417
+ minHeight: "0",
418
+ overflowY: "auto",
419
+ color: "var(--fg)"
420
+ },
421
+ '& [part="tree"][data-drop="true"]': {
422
+ background: "var(--hover-bg)"
423
+ },
424
+ '& [part="row"]': {
425
+ $description: "What the element does not decide. A click on a row OPENS it here — a directory unfolds, a file takes a tab — so the pointer is a pointer rather than the element's default arrow; and the gap is the wider one this tree has always drawn between a 16px file glyph and its name.",
426
+ gap: "var(--jx-space-3)",
427
+ cursor: "pointer"
428
+ },
429
+ '& [part="loading-row"]': {
430
+ $description: "A directory whose listing has not arrived yet. It holds the place and it is NOT a row: it is not a `jx-tree-item`, so the caret cannot land on it, the set counts do not include it and typeahead cannot match it — and it is replaced by the real rows on the repaint the listing provokes. It draws the same box by hand because it is the only line in this tree the element does not draw, and a placeholder of a different height would desynchronise the window's scroll reservation from the rows it reserves for.",
431
+ display: "flex",
432
+ alignItems: "center",
433
+ boxSizing: "border-box",
434
+ blockSize: "var(--jx-control-h)",
435
+ paddingInline: "calc(var(--jx-space-3) + var(--depth, 0) * 16px) var(--jx-space-3)",
436
+ color: "var(--fg-dim)",
437
+ fontStyle: "italic",
438
+ cursor: "default",
439
+ userSelect: "none",
440
+ whiteSpace: "nowrap"
441
+ },
442
+ '& [part="row-icon"]': {
443
+ flexShrink: "0",
444
+ display: "flex",
445
+ alignItems: "center",
446
+ "--jx-icon-size": "16px"
447
+ },
448
+ '& [part="locale"]': {
449
+ $description: "The language chip. Deliberately declares no block size, no padding and no line height: the row above is one control-height by contract, and a chip that grew the box would desynchronise the window's scroll reservation from the height it reserves by. It only ever shrinks the text. A chip, not a filter term: the search matches the file's name alone, because a query that silently also matched a language would make “why is this file here” unanswerable from what is on screen.",
450
+ marginInlineStart: "auto",
451
+ flexShrink: "0",
452
+ fontSize: "var(--jx-text-sm)",
453
+ color: "var(--fg-dim)",
454
+ overflow: "hidden",
455
+ textOverflow: "ellipsis",
456
+ whiteSpace: "nowrap",
457
+ maxInlineSize: "6em"
458
+ },
459
+ '& [part="view-slot"], & [part="header-slot"], & [part="locale-slot"]': {
460
+ $description: "A `$switch` renders its own container, and none of these three is a box: each stands exactly where its case does, so the case's own rule is the only one that lays anything out.",
461
+ display: "contents"
462
+ }
463
+ },
464
+ children: [
465
+ {
466
+ tagName: "div",
467
+ attributes: {
468
+ part: "view-slot",
469
+ role: "none"
470
+ },
471
+ $switch: {
472
+ $ref: "#/state/view"
473
+ },
474
+ cases: {
475
+ none: {
476
+ tagName: "div",
477
+ attributes: {
478
+ part: "empty"
479
+ },
480
+ children: [
481
+ {
482
+ tagName: "p",
483
+ textContent: "No project loaded"
484
+ }
485
+ ]
486
+ },
487
+ welcome: {
488
+ tagName: "div",
489
+ attributes: {
490
+ part: "empty"
491
+ },
492
+ children: [
493
+ {
494
+ tagName: "p",
495
+ textContent: "Open a project folder to get started."
496
+ },
497
+ {
498
+ tagName: "jx-button",
499
+ attributes: {
500
+ part: "open-project"
501
+ },
502
+ $props: {
503
+ variant: "accent",
504
+ size: "sm"
505
+ },
506
+ onclick: {
507
+ $prototype: "Function",
508
+ body: [
509
+ {
510
+ operator: "call",
511
+ target: {
512
+ $ref: "#/state/openProject"
513
+ },
514
+ value: []
515
+ }
516
+ ],
517
+ description: "The declared `project.open` command, run through the registry — not a second opener of this surface's own. It is the one the chord, the palette and the status bar's PROJECT field already run, so a window that opens a project from here reports the outcome the same way they do (§12.5)."
518
+ },
519
+ children: [
520
+ {
521
+ tagName: "span",
522
+ textContent: "Open Project"
523
+ }
524
+ ]
525
+ }
526
+ ]
527
+ },
528
+ tree: {
529
+ tagName: "div",
530
+ attributes: {
531
+ part: "frame"
532
+ },
533
+ children: [
534
+ {
535
+ tagName: "div",
536
+ attributes: {
537
+ part: "header-slot",
538
+ role: "none"
539
+ },
540
+ $switch: {
541
+ $ref: "#/state/headerState"
542
+ },
543
+ cases: {
544
+ shown: {
545
+ tagName: "div",
546
+ attributes: {
547
+ part: "project-header"
548
+ },
549
+ children: [
550
+ {
551
+ tagName: "span",
552
+ attributes: {
553
+ part: "project-name",
554
+ title: "${state.projectName}"
555
+ },
556
+ textContent: "${state.projectName}"
557
+ }
558
+ ]
559
+ }
560
+ }
561
+ },
562
+ {
563
+ tagName: "div",
564
+ attributes: {
565
+ part: "toolbar"
566
+ },
567
+ children: [
568
+ {
569
+ tagName: "jx-action-group",
570
+ attributes: {
571
+ part: "toolbar-actions"
572
+ },
573
+ $props: {
574
+ compact: true,
575
+ label: "File tree actions"
576
+ },
577
+ children: [
578
+ {
579
+ tagName: "jx-action-button",
580
+ attributes: {
581
+ part: "new-file"
582
+ },
583
+ $props: {
584
+ size: "sm",
585
+ icon: "plus",
586
+ label: "New File",
587
+ hint: "New File"
588
+ },
589
+ onclick: {
590
+ $prototype: "Function",
591
+ body: [
592
+ {
593
+ operator: "call",
594
+ target: {
595
+ $ref: "#/state/newFile"
596
+ },
597
+ value: []
598
+ }
599
+ ]
600
+ }
601
+ },
602
+ {
603
+ tagName: "jx-action-button",
604
+ attributes: {
605
+ part: "refresh"
606
+ },
607
+ $props: {
608
+ size: "sm",
609
+ icon: "arrows-clockwise",
610
+ label: "Refresh",
611
+ hint: "Refresh"
612
+ },
613
+ onclick: {
614
+ $prototype: "Function",
615
+ body: [
616
+ {
617
+ operator: "call",
618
+ target: {
619
+ $ref: "#/state/refresh"
620
+ },
621
+ value: []
622
+ }
623
+ ],
624
+ description: "The rules go with the listings. Refresh is what an author reaches for after editing a `.gitignore` by hand, and a tree that came back still hiding by the old rules would read as the button not having worked."
625
+ }
626
+ },
627
+ {
628
+ tagName: "jx-action-button",
629
+ attributes: {
630
+ part: "show-ignored"
631
+ },
632
+ $props: {
633
+ size: "sm",
634
+ icon: {
635
+ $ref: "#/state/ignoredIcon"
636
+ },
637
+ label: {
638
+ $ref: "#/state/ignoredLabel"
639
+ },
640
+ hint: {
641
+ $ref: "#/state/ignoredLabel"
642
+ },
643
+ selected: {
644
+ $ref: "#/state/ignoredSelected"
645
+ }
646
+ },
647
+ onclick: {
648
+ $prototype: "Function",
649
+ body: [
650
+ {
651
+ operator: "call",
652
+ target: {
653
+ $ref: "#/state/toggleIgnored"
654
+ },
655
+ value: []
656
+ }
657
+ ],
658
+ description: "A repaint and nothing else: the ignored entries were never dropped from the cached listings, only from the rows built out of them."
659
+ }
660
+ }
661
+ ]
662
+ },
663
+ {
664
+ tagName: "jx-textfield",
665
+ attributes: {
666
+ part: "search"
667
+ },
668
+ $props: {
669
+ label: "Filter files",
670
+ placeholder: "Filter files…",
671
+ size: "sm",
672
+ value: {
673
+ $ref: "#/state/query"
674
+ }
675
+ },
676
+ oninput: {
677
+ $prototype: "Function",
678
+ body: [
679
+ {
680
+ operator: "call",
681
+ target: {
682
+ $ref: "#/state/search"
683
+ },
684
+ value: [
685
+ {
686
+ $ref: "event#/target/value"
687
+ }
688
+ ]
689
+ }
690
+ ],
691
+ description: "The query matches a file's NAME and nothing else. A directory is kept whatever it says, because hiding the folder a match sits in would leave the match with nowhere to be drawn."
692
+ }
693
+ }
694
+ ]
695
+ },
696
+ {
697
+ $description: 'The `role="tree"`, and everything that used to be spelled out under it. The element writes the role, the name, the roving tab stop and every row\'s `aria-level` / `aria-posinset` / `aria-setsize`, and it owns the whole ARIA keyboard: the arrows walk the drawn rows without wrapping, `Home` and `End` reach the ends of the MODEL by way of the pads, `ArrowRight` opens a directory and steps into an open one, `ArrowLeft` closes one and otherwise steps out to its parent, `Enter` activates and a printable character is typeahead. Every chord it does not own — cut, copy, paste, delete, rename — passes straight through to the flow, which is the WCAG 2.5.7 obligation this tree carries because dragging a file is the other way to move it. What reaches this document is five events, and each of them is a decision `files.ts` already owned.',
698
+ tagName: "jx-tree",
699
+ attributes: {
700
+ part: "tree",
701
+ label: "Project files",
702
+ current: "${state.currentPath}",
703
+ padtop: "${state.padTop}",
704
+ padbottom: "${state.padBottom}",
705
+ "data-drop": "${state.rootDrop || null}"
706
+ },
707
+ onselect: {
708
+ $prototype: "Function",
709
+ body: [
710
+ {
711
+ operator: "call",
712
+ target: {
713
+ $ref: "#/state/select"
714
+ },
715
+ value: [
716
+ {
717
+ $ref: "event#/detail/value"
718
+ }
719
+ ]
720
+ }
721
+ ],
722
+ description: "The reader meant that row. This tree is single-select, so the element resolves every modifier to `replace` before it gets here and the detail's `mode` and `anchor` are answers to a question this tree does not ask. There is no `change` handler beside it on purpose: the element OWNS the caret and keeps it across every repaint that does not change `current`, so a second copy of it in the flow would be a variable that only ever went stale."
723
+ },
724
+ onactivate: {
725
+ $prototype: "Function",
726
+ body: [
727
+ {
728
+ operator: "call",
729
+ target: {
730
+ $ref: "#/state/activate"
731
+ },
732
+ value: [
733
+ {
734
+ $ref: "event#/detail"
735
+ }
736
+ ]
737
+ }
738
+ ],
739
+ description: "`Enter` or a double click. The same verb a single click reaches, by the same name."
740
+ },
741
+ onexpand: {
742
+ $prototype: "Function",
743
+ body: [
744
+ {
745
+ operator: "call",
746
+ target: {
747
+ $ref: "#/state/expand"
748
+ },
749
+ value: [
750
+ {
751
+ $ref: "event#/detail/value"
752
+ },
753
+ {
754
+ $ref: "event#/detail/expanded"
755
+ }
756
+ ]
757
+ }
758
+ ],
759
+ description: "`ArrowRight`, `ArrowLeft` or the twisty, with ONE dispatcher between them: the detail says the state the row should be PUT INTO, so the flow never has to work out which way a toggle was going."
760
+ },
761
+ onmove: {
762
+ $prototype: "Function",
763
+ body: [
764
+ {
765
+ operator: "call",
766
+ target: {
767
+ $ref: "#/state/move"
768
+ },
769
+ value: [
770
+ {
771
+ $ref: "event#/detail/from"
772
+ },
773
+ {
774
+ $ref: "event#/detail/key"
775
+ }
776
+ ]
777
+ }
778
+ ],
779
+ description: "The caret has to reach a row the window did not draw. The element knows only that the pad on that side is not zero; where the row is in the model, and how far to scroll to bring it into view, is the flow's — which is why this is an event and not a `scrollIntoView`."
780
+ },
781
+ ontypeahead: {
782
+ $prototype: "Function",
783
+ body: [
784
+ {
785
+ operator: "call",
786
+ target: {
787
+ $ref: "#/state/typeahead"
788
+ },
789
+ value: [
790
+ {
791
+ $ref: "event#/detail/from"
792
+ },
793
+ {
794
+ $ref: "event#/detail/char"
795
+ }
796
+ ]
797
+ }
798
+ ],
799
+ description: "A printable character, on a windowed tree. The same hand-off as `onmove` and for a sharper reason: a move off the end of the slice announces itself, and a letter never does — the element's own search over the drawn rows always answers, and over a `node_modules` of ten thousand entries the answer is whichever of the eleven painted rows happened to start with that letter. So the element dispatches EVERY such character and the flow answers it over the model."
800
+ },
801
+ children: [
802
+ {
803
+ $prototype: "Array",
804
+ items: {
805
+ $ref: "#/state/rows"
806
+ },
807
+ key: {
808
+ $ref: "$map/item/key"
809
+ },
810
+ map: {
811
+ tagName: "div",
812
+ attributes: {
813
+ part: "row-slot",
814
+ role: "none"
815
+ },
816
+ style: {
817
+ display: "contents"
818
+ },
819
+ $switch: {
820
+ $ref: "$map/item/kind"
821
+ },
822
+ cases: {
823
+ item: {
824
+ tagName: "jx-tree-item",
825
+ attributes: {
826
+ part: "row",
827
+ value: "${$map.item.path}",
828
+ label: "${$map.item.name}",
829
+ level: "${$map.item.level}",
830
+ posinset: "${$map.item.posInSet}",
831
+ setsize: "${$map.item.setSize}",
832
+ expanded: "${$map.item.ariaExpanded}",
833
+ selected: "${state.selectedPath === $map.item.path ? 'true' : 'false'}",
834
+ "data-type": "${$map.item.type}",
835
+ "data-dragging": "${state.dragPath === $map.item.path ? '' : null}",
836
+ "data-drop": "${state.dropPath === $map.item.path ? '' : null}"
837
+ },
838
+ onclick: {
839
+ $prototype: "Function",
840
+ body: [
841
+ {
842
+ operator: "call",
843
+ target: {
844
+ $ref: "#/state/activate"
845
+ },
846
+ value: [
847
+ {
848
+ $ref: "$map/item/path"
849
+ }
850
+ ]
851
+ }
852
+ ],
853
+ description: "A single click OPENS the row, which is this tree's own answer and not the element's. `jx-tree` answers a click with `change` and `select`, exactly as it answers an arrow key, and a tree that opened on `select` would open every file the reader arrowed past. So the opening verb is bound here, where a click is a click; what a click MEANS — unfold this directory, take a tab for that file — stays the flow's, and Enter reaches the same verb through `activate`. It does NOT stop the event, which is the correction: the tree's delegated click is what moves the caret and the selection onto the row, so a `stopPropagation` here would leave a reader who clicked a folder with the tab stop still on whatever they had open last. The twisty stops its own click, so opening a directory from the chevron does not also activate the row."
854
+ },
855
+ oncontextmenu: {
856
+ $prototype: "Function",
857
+ body: [
858
+ {
859
+ preventDefault: true
860
+ },
861
+ {
862
+ stopPropagation: true
863
+ },
864
+ {
865
+ operator: "call",
866
+ target: {
867
+ $ref: "#/state/contextMenu"
868
+ },
869
+ value: [
870
+ {
871
+ $ref: "$map/item/path"
872
+ },
873
+ {
874
+ $ref: "event#/clientX"
875
+ },
876
+ {
877
+ $ref: "event#/clientY"
878
+ }
879
+ ]
880
+ }
881
+ ]
882
+ },
883
+ children: [
884
+ {
885
+ tagName: "jx-icon",
886
+ attributes: {
887
+ slot: "icon",
888
+ part: "row-icon",
889
+ "aria-hidden": "true"
890
+ },
891
+ $props: {
892
+ name: {
893
+ $ref: "$map/item/icon"
894
+ }
895
+ }
896
+ },
897
+ {
898
+ tagName: "div",
899
+ attributes: {
900
+ slot: "status",
901
+ part: "locale-slot",
902
+ role: "none"
903
+ },
904
+ $switch: {
905
+ $ref: "$map/item/localeState"
906
+ },
907
+ cases: {
908
+ shown: {
909
+ tagName: "span",
910
+ attributes: {
911
+ part: "locale"
912
+ },
913
+ textContent: "${$map.item.locale}"
914
+ }
915
+ }
916
+ }
917
+ ]
918
+ },
919
+ loading: {
920
+ $description: "A directory whose listing has not arrived yet. Deliberately not a `jx-tree-item`: there is no file there to select, open, rename or drag, and a row the caret could land on that answers to none of the verbs the caret offers is a stop in the walk with nothing behind it.",
921
+ tagName: "div",
922
+ attributes: {
923
+ part: "loading-row",
924
+ role: "none",
925
+ "data-loading": "true",
926
+ style: "--depth:${$map.item.depth}"
927
+ },
928
+ textContent: "Loading…"
929
+ }
930
+ }
931
+ }
932
+ }
933
+ ]
934
+ }
935
+ ]
936
+ }
937
+ }
938
+ }
939
+ ]
940
+ };
941
+
942
+ // src/surfaces/files-panel.ts
943
+ registerSurface("files-panel", files_panel_default);
944
+ function project(scope, values) {
945
+ scope.view = values.view;
946
+ scope.headerState = values.headerState;
947
+ scope.projectName = values.projectName;
948
+ scope.query = values.query;
949
+ scope.ignoredLabel = values.ignoredLabel;
950
+ scope.ignoredIcon = values.ignoredIcon;
951
+ scope.ignoredSelected = values.ignoredSelected;
952
+ scope.padTop = values.padTop;
953
+ scope.padBottom = values.padBottom;
954
+ scope.rows = values.rows;
955
+ scope.selectedPath = values.selectedPath;
956
+ scope.dragPath = values.dragPath;
957
+ scope.dropPath = values.dropPath;
958
+ scope.rootDrop = values.rootDrop;
959
+ scope.currentPath = values.currentPath;
960
+ }
961
+ function emptyFilesPanelValues() {
962
+ return {
963
+ currentPath: "",
964
+ dragPath: "",
965
+ dropPath: "",
966
+ headerState: "hidden",
967
+ ignoredIcon: "eye-slash",
968
+ ignoredLabel: "Show ignored files",
969
+ ignoredSelected: false,
970
+ padBottom: 0,
971
+ padTop: 0,
972
+ projectName: "",
973
+ query: "",
974
+ rootDrop: "",
975
+ rows: [],
976
+ selectedPath: "",
977
+ view: "none"
978
+ };
979
+ }
980
+ function partOf(def) {
981
+ const part = typeof def === "string" ? undefined : def.attributes?.["part"];
982
+ return typeof part === "string" ? part : "";
983
+ }
984
+ function mappedRow(state) {
985
+ const map = state?.["$map"];
986
+ const item = map?.item;
987
+ return typeof item?.path === "string" ? item : null;
988
+ }
989
+ function mountFilesPanelSurface(container, values, actions) {
990
+ const scope = reactive({
991
+ ...emptyFilesPanelValues(),
992
+ ...actions
993
+ });
994
+ project(scope, values);
995
+ let mounted = null;
996
+ let disposed = false;
997
+ const ready = mountSurface("files-panel", scope, container, {
998
+ onNodeCreated: (element, _path, def, state) => {
999
+ if (disposed || !(element instanceof HTMLElement)) {
1000
+ return;
1001
+ }
1002
+ const part = partOf(def);
1003
+ if (part === "tree") {
1004
+ actions.treeHost(element);
1005
+ return;
1006
+ }
1007
+ if (part !== "row") {
1008
+ return;
1009
+ }
1010
+ const row = mappedRow(state);
1011
+ if (row) {
1012
+ actions.rowHost(element, row.path, row.type);
1013
+ }
1014
+ }
1015
+ }).then((surface) => {
1016
+ if (disposed) {
1017
+ surface.dispose();
1018
+ return;
1019
+ }
1020
+ mounted = surface;
1021
+ });
1022
+ return {
1023
+ connected: () => !disposed && (mounted === null || mounted.root.parentNode === container),
1024
+ dispose() {
1025
+ disposed = true;
1026
+ mounted?.dispose();
1027
+ mounted = null;
1028
+ },
1029
+ ready,
1030
+ update: (next) => {
1031
+ project(scope, next);
1032
+ }
1033
+ };
1034
+ }
1035
+
1036
+ // src/files/files.ts
1037
+ async function loadDirectory2(dirPath) {
1038
+ if (!projectState) {
1039
+ return;
1040
+ }
1041
+ try {
1042
+ const platform = getPlatform2();
1043
+ const [entries] = await Promise.all([
1044
+ platform.listDirectory(dirPath),
1045
+ ensureIgnoreLayers(dirPath)
1046
+ ]);
1047
+ projectState.dirs.set(dirPath, entries);
1048
+ } catch {
1049
+ projectState.dirs.set(dirPath, []);
1050
+ }
1051
+ }
1052
+ function showIgnoredFiles() {
1053
+ return readStoredSetting(SETTINGS.showIgnoredFiles) === "true";
1054
+ }
1055
+ function setShowIgnoredFiles(show) {
1056
+ setSetting(SETTINGS.showIgnoredFiles, show ? "true" : "");
1057
+ }
1058
+ async function loadProject2() {
1059
+ try {
1060
+ const platform = getPlatform2();
1061
+ const result = await platform.probeRootProject();
1062
+ if (!result) {
1063
+ return;
1064
+ }
1065
+ const { meta, info } = result;
1066
+ refreshFormats2();
1067
+ loadFormats2();
1068
+ refreshExtensionUi2(platform);
1069
+ resetIgnoreCache();
1070
+ setProjectState({
1071
+ dirs: new Map,
1072
+ expanded: new Set,
1073
+ isSiteProject: info.isSiteProject,
1074
+ name: info.isSiteProject ? info.projectConfig?.name || meta.name : meta.name,
1075
+ projectConfig: (info.isSiteProject ? info.projectConfig : null) || null,
1076
+ projectDirs: info.directories || [],
1077
+ projectRoot: ".",
1078
+ root: meta.root,
1079
+ searchQuery: "",
1080
+ selectedPath: null
1081
+ });
1082
+ if (info.isSiteProject) {
1083
+ setWorkspaceProject2(meta.root || ".", info.projectConfig || null);
1084
+ }
1085
+ if (info.isSiteProject) {
1086
+ addRecentProject(requireProjectState().name, meta.root);
1087
+ await autoSyncProjectOnOpen();
1088
+ if (await ensureDependenciesInstalled()) {
1089
+ refreshFormats2();
1090
+ await loadFormats2();
1091
+ refreshExtensionUi2(platform);
1092
+ }
1093
+ await loadDirectory2(".");
1094
+ await loadComponentRegistry2();
1095
+ await openLastSessionOrHome2();
1096
+ maybePromptJxsuiteUpdate(meta.root);
1097
+ }
1098
+ } catch {}
1099
+ }
1100
+ async function openProject2({
1101
+ renderLeftPanel
1102
+ }) {
1103
+ try {
1104
+ const platform = getPlatform2();
1105
+ const result = await platform.openProject();
1106
+ if (!result) {
1107
+ return false;
1108
+ }
1109
+ const { config, handle } = result;
1110
+ replaceAllTabs2({
1111
+ document: { children: [], tagName: "div" },
1112
+ id: "initial"
1113
+ });
1114
+ disarmPreviewOverlay();
1115
+ refreshFormats2();
1116
+ loadFormats2();
1117
+ refreshExtensionUi2(platform);
1118
+ resetIgnoreCache();
1119
+ setProjectState({
1120
+ ...projectState,
1121
+ dirs: new Map,
1122
+ expanded: new Set,
1123
+ isSiteProject: true,
1124
+ name: config.name || handle.name,
1125
+ projectConfig: config,
1126
+ projectRoot: handle.root,
1127
+ searchQuery: "",
1128
+ selectedPath: null
1129
+ });
1130
+ setWorkspaceProject2(handle.root, config);
1131
+ await autoSyncProjectOnOpen();
1132
+ if (await ensureDependenciesInstalled()) {
1133
+ refreshFormats2();
1134
+ await loadFormats2();
1135
+ refreshExtensionUi2(platform);
1136
+ }
1137
+ await loadDirectory2(".");
1138
+ await loadComponentRegistry2();
1139
+ const conventionalDirs = new Set([
1140
+ "pages",
1141
+ "layouts",
1142
+ "components",
1143
+ "content",
1144
+ "data",
1145
+ "public",
1146
+ "styles"
1147
+ ]);
1148
+ const entries = requireProjectState().dirs.get(".") || [];
1149
+ const foundDirs = [];
1150
+ for (const e of entries) {
1151
+ if (e.type === "directory" && conventionalDirs.has(e.name)) {
1152
+ foundDirs.push(e.name);
1153
+ requireProjectState().expanded.add(e.path || e.name);
1154
+ await loadDirectory2(e.path || e.name);
1155
+ }
1156
+ }
1157
+ requireProjectState().projectDirs = foundDirs;
1158
+ cleanupGitPanel2();
1159
+ resetProjectShell();
1160
+ setActivityTab("files");
1161
+ addRecentProject(requireProjectState().name, requireProjectState().projectRoot);
1162
+ renderLeftPanel();
1163
+ await openLastSessionOrHome2();
1164
+ maybePromptJxsuiteUpdate(requireProjectState().projectRoot);
1165
+ return true;
1166
+ } catch (error) {
1167
+ notify2.error("Could not open the project.", {
1168
+ detail: errorMessage2(error),
1169
+ source: "Open Project"
1170
+ });
1171
+ return false;
1172
+ }
1173
+ }
1174
+ async function initProjectRepo2(root) {
1175
+ const platform = getPlatform2();
1176
+ if (platform.createDestination !== "path") {
1177
+ return false;
1178
+ }
1179
+ try {
1180
+ await platform.activate(root);
1181
+ const status = await platform.gitStatus();
1182
+ if (status.isRepo) {
1183
+ return false;
1184
+ }
1185
+ await platform.gitInit();
1186
+ notify2.success("Initialized a git repository for this project.");
1187
+ return true;
1188
+ } catch (error) {
1189
+ notify2.warn("Could not initialize a git repository — the project itself was written.", {
1190
+ detail: errorMessage2(error),
1191
+ source: "Source Control"
1192
+ });
1193
+ return false;
1194
+ }
1195
+ }
1196
+ async function findHomePage2() {
1197
+ await loadFormats2();
1198
+ const exts = [...documentExtensions2("page"), ".json"];
1199
+ let entries;
1200
+ try {
1201
+ entries = await getPlatform2().listDirectory("pages");
1202
+ } catch {
1203
+ return null;
1204
+ }
1205
+ const files = new Set(entries.filter((e) => e.type === "file").map((e) => e.name));
1206
+ for (const ext of exts) {
1207
+ if (files.has(`index${ext}`)) {
1208
+ return `pages/index${ext}`;
1209
+ }
1210
+ }
1211
+ return null;
1212
+ }
1213
+ async function openHomePage() {
1214
+ const home = await findHomePage2();
1215
+ if (home) {
1216
+ await openFileInTab2(home);
1217
+ }
1218
+ }
1219
+ async function openLastSessionOrHome2() {
1220
+ const session = persistedSession(workspace2.projectRoot);
1221
+ markSessionRestored(workspace2.projectRoot);
1222
+ if (session) {
1223
+ const opened = await restoreSession(session, {
1224
+ ensureSecondPane: () => {
1225
+ receivingPane2();
1226
+ },
1227
+ openFile: (path, paneId) => openFileInTab2(path, { focus: false, paneId })
1228
+ });
1229
+ if (opened > 0) {
1230
+ return true;
1231
+ }
1232
+ }
1233
+ await openHomePage();
1234
+ return false;
1235
+ }
1236
+ function fileIconName(name, type, expanded) {
1237
+ if (type === "directory") {
1238
+ return expanded ? "folder-open" : "folder";
1239
+ }
1240
+ const ext = name.split(".").pop()?.toLowerCase();
1241
+ switch (ext) {
1242
+ case "css":
1243
+ case "js":
1244
+ case "json":
1245
+ case "ts": {
1246
+ return "file-code";
1247
+ }
1248
+ case "md": {
1249
+ return "file-text";
1250
+ }
1251
+ default: {
1252
+ return ext !== undefined && isImage(ext) ? "image" : "file";
1253
+ }
1254
+ }
1255
+ }
1256
+ function renderFilesTemplate2() {
1257
+ return nothing2;
1258
+ }
1259
+ function registerFileTreeDnD2(_ctx) {}
1260
+ var FILE_ROW_HEIGHT = 24;
1261
+ var _fileRows = [];
1262
+ var _fileList = null;
1263
+ var _fileRowEls = new Map;
1264
+ var _fileWatch = null;
1265
+ var _filesRerender = null;
1266
+ function fileRowHeight() {
1267
+ for (const el of _fileRowEls.values()) {
1268
+ if (el.isConnected && el.offsetHeight > 0) {
1269
+ return el.offsetHeight;
1270
+ }
1271
+ }
1272
+ return FILE_ROW_HEIGHT;
1273
+ }
1274
+ function sweepRowElements() {
1275
+ for (const [path, el] of _fileRowEls) {
1276
+ if (!el.isConnected) {
1277
+ _fileRowEls.delete(path);
1278
+ releaseRowDnD(el);
1279
+ }
1280
+ }
1281
+ }
1282
+ function fileRowElement(path) {
1283
+ const el = _fileRowEls.get(path);
1284
+ return el?.isConnected === true ? el : null;
1285
+ }
1286
+ function fileRowAt(path) {
1287
+ return _fileRows.find((row) => !row.loading && row.path === path);
1288
+ }
1289
+ function collectFileRows(dirPath, depth, rows, i18n) {
1290
+ const entries = requireProjectState().dirs.get(dirPath);
1291
+ if (!entries) {
1292
+ loadDirectory2(dirPath).then(() => repaintFiles());
1293
+ rows.push({
1294
+ depth,
1295
+ expanded: false,
1296
+ key: `loading:${dirPath}`,
1297
+ loading: true,
1298
+ name: "Loading…",
1299
+ path: dirPath,
1300
+ posInSet: 1,
1301
+ setSize: 1,
1302
+ type: "file"
1303
+ });
1304
+ return;
1305
+ }
1306
+ const sorted = [...entries].toSorted((a, b) => {
1307
+ if (a.type === "directory" && b.type !== "directory") {
1308
+ return -1;
1309
+ }
1310
+ if (a.type !== "directory" && b.type === "directory") {
1311
+ return 1;
1312
+ }
1313
+ return a.name.localeCompare(b.name);
1314
+ });
1315
+ const visible = showIgnoredFiles() ? sorted : sorted.filter((e) => !isIgnoredEntry(dirPath, e.path, e.type === "directory"));
1316
+ const query = requireProjectState().searchQuery.toLowerCase();
1317
+ const filtered = query ? visible.filter((e) => e.type === "directory" || e.name.toLowerCase().includes(query)) : visible;
1318
+ for (const [index, entry] of filtered.entries()) {
1319
+ const isDir = entry.type === "directory";
1320
+ const isExpanded = isDir && requireProjectState().expanded.has(entry.path);
1321
+ rows.push({
1322
+ depth,
1323
+ expanded: isExpanded,
1324
+ key: entry.path,
1325
+ loading: false,
1326
+ name: entry.name,
1327
+ path: entry.path,
1328
+ locale: localeOfPath(entry.path, i18n) ?? undefined,
1329
+ posInSet: index + 1,
1330
+ setSize: filtered.length,
1331
+ type: entry.type
1332
+ });
1333
+ if (isExpanded) {
1334
+ collectFileRows(entry.path, depth + 1, rows, i18n);
1335
+ }
1336
+ }
1337
+ }
1338
+ function fileIndexOfPath(path) {
1339
+ return path === undefined ? -1 : _fileRows.findIndex((row) => !row.loading && row.path === path);
1340
+ }
1341
+ function fileStep(index, step) {
1342
+ for (let i = index + step;i >= 0 && i < _fileRows.length; i += step) {
1343
+ if (!_fileRows[i].loading) {
1344
+ return i;
1345
+ }
1346
+ }
1347
+ return -1;
1348
+ }
1349
+ function fileParentIndex(index) {
1350
+ const row = _fileRows[index];
1351
+ if (!row) {
1352
+ return -1;
1353
+ }
1354
+ for (let i = index - 1;i >= 0; i--) {
1355
+ const above = _fileRows[i];
1356
+ if (!above.loading && above.depth < row.depth) {
1357
+ return i;
1358
+ }
1359
+ }
1360
+ return -1;
1361
+ }
1362
+ function fileWindowChanged() {
1363
+ if (_fileList?.isConnected !== true || _dragPath !== "") {
1364
+ return;
1365
+ }
1366
+ queueMicrotask(repaintFiles);
1367
+ }
1368
+ function adoptFileTree() {
1369
+ const tree = _fileList;
1370
+ if (tree === null) {
1371
+ return;
1372
+ }
1373
+ _fileWatch = watchListWindow(_fileWatch, tree, {
1374
+ count: () => _fileRows.length,
1375
+ onChange: fileWindowChanged,
1376
+ rowHeight: fileRowHeight
1377
+ });
1378
+ }
1379
+ function fileRowView(row) {
1380
+ const level = String(row.depth + 1);
1381
+ if (row.loading) {
1382
+ return {
1383
+ ariaExpanded: "",
1384
+ depth: String(row.depth),
1385
+ icon: "",
1386
+ key: row.key,
1387
+ kind: "loading",
1388
+ level,
1389
+ locale: "",
1390
+ localeState: "hidden",
1391
+ name: row.name,
1392
+ path: row.path,
1393
+ posInSet: "",
1394
+ setSize: "",
1395
+ type: row.type
1396
+ };
1397
+ }
1398
+ const isDir = row.type === "directory";
1399
+ return {
1400
+ ariaExpanded: isDir ? String(row.expanded) : "",
1401
+ depth: String(row.depth),
1402
+ icon: fileIconName(row.path, row.type, row.expanded),
1403
+ key: row.key,
1404
+ kind: "item",
1405
+ level,
1406
+ locale: row.locale === undefined ? "" : localeLabel(row.locale),
1407
+ localeState: row.locale === undefined ? "hidden" : "shown",
1408
+ name: row.name,
1409
+ path: row.path,
1410
+ posInSet: String(row.posInSet),
1411
+ setSize: String(row.setSize),
1412
+ type: row.type
1413
+ };
1414
+ }
1415
+ function filesPanelValues() {
1416
+ sweepRowElements();
1417
+ if (!projectState) {
1418
+ _fileRows = [];
1419
+ const values = { ...emptyFilesPanelValues(), view: "none" };
1420
+ _lastValues = values;
1421
+ return values;
1422
+ }
1423
+ if (!projectState.isSiteProject && projectState.projectRoot === ".") {
1424
+ _fileRows = [];
1425
+ const values = { ...emptyFilesPanelValues(), view: "welcome" };
1426
+ _lastValues = values;
1427
+ return values;
1428
+ }
1429
+ const state = requireProjectState();
1430
+ _fileRows = [];
1431
+ const { i18n } = resolveI18n(state.projectConfig ?? {});
1432
+ collectFileRows(".", 0, _fileRows, i18n);
1433
+ const range = listWindow(_fileList, { count: _fileRows.length, rowHeight: fileRowHeight() });
1434
+ const drawn = _fileRows.slice(range.start, range.end);
1435
+ const caret = (state.selectedPath !== null && fileRowAt(state.selectedPath) ? state.selectedPath : "") || drawn.find((row) => !row.loading)?.path || "";
1436
+ const showingIgnored = showIgnoredFiles();
1437
+ const values = {
1438
+ currentPath: caret,
1439
+ dragPath: _dragPath,
1440
+ dropPath: _dropPath,
1441
+ headerState: state.isSiteProject ? "shown" : "hidden",
1442
+ ignoredIcon: showingIgnored ? "eye" : "eye-slash",
1443
+ ignoredLabel: showingIgnored ? "Hide ignored files" : "Show ignored files",
1444
+ ignoredSelected: showingIgnored,
1445
+ padBottom: range.padBottom,
1446
+ padTop: range.padTop,
1447
+ projectName: state.projectConfig?.name || state.name,
1448
+ query: state.searchQuery,
1449
+ rootDrop: _rootDrop,
1450
+ rows: drawn.map((row) => fileRowView(row)),
1451
+ selectedPath: state.selectedPath ?? "",
1452
+ view: "tree"
1453
+ };
1454
+ _lastValues = values;
1455
+ return values;
1456
+ }
1457
+ function syncFilesDragState() {
1458
+ if (!_standingFiles || !_lastValues) {
1459
+ return;
1460
+ }
1461
+ _lastValues = {
1462
+ ..._lastValues,
1463
+ dragPath: _dragPath,
1464
+ dropPath: _dropPath,
1465
+ rootDrop: _rootDrop
1466
+ };
1467
+ _standingFiles.handle.update(_lastValues);
1468
+ }
1469
+ function repaintFiles() {
1470
+ _filesRerender?.();
1471
+ }
1472
+ async function refreshFileTree() {
1473
+ const state = requireProjectState();
1474
+ state.dirs.clear();
1475
+ resetIgnoreCache();
1476
+ await loadDirectory2(".");
1477
+ for (const dir of state.expanded) {
1478
+ await loadDirectory2(dir);
1479
+ }
1480
+ repaintFiles();
1481
+ }
1482
+ function activateFileRow(path) {
1483
+ const row = fileRowAt(path);
1484
+ if (!row) {
1485
+ return;
1486
+ }
1487
+ if (row.type === "directory") {
1488
+ toggleTreeDirectory(path).then(() => repaintFiles());
1489
+ return;
1490
+ }
1491
+ openFileInTab2(path);
1492
+ }
1493
+ function expandFileRow(path, expanded) {
1494
+ const state = requireProjectState();
1495
+ if (fileRowAt(path)?.type !== "directory" || state.expanded.has(path) === expanded) {
1496
+ return;
1497
+ }
1498
+ if (!expanded) {
1499
+ state.expanded.delete(path);
1500
+ repaintFiles();
1501
+ return;
1502
+ }
1503
+ toggleTreeDirectory(path).then(() => repaintFiles());
1504
+ }
1505
+ function selectFileRow(path) {
1506
+ if (!projectState || requireProjectState().selectedPath === path) {
1507
+ return;
1508
+ }
1509
+ requireProjectState().selectedPath = path;
1510
+ repaintFiles();
1511
+ }
1512
+ function moveFileCaret(from, key) {
1513
+ const index = fileIndexOfPath(from);
1514
+ let target;
1515
+ switch (key) {
1516
+ case "Home": {
1517
+ target = fileStep(-1, 1);
1518
+ break;
1519
+ }
1520
+ case "End": {
1521
+ target = fileStep(_fileRows.length, -1);
1522
+ break;
1523
+ }
1524
+ case "ArrowUp": {
1525
+ target = fileStep(index, -1);
1526
+ break;
1527
+ }
1528
+ case "ArrowLeft": {
1529
+ target = fileParentIndex(index);
1530
+ break;
1531
+ }
1532
+ case "ArrowDown":
1533
+ case "ArrowRight": {
1534
+ target = fileStep(index, 1);
1535
+ break;
1536
+ }
1537
+ default: {
1538
+ return;
1539
+ }
1540
+ }
1541
+ focusFileRow(target);
1542
+ }
1543
+ function typeaheadFileCaret(from, char) {
1544
+ const start = fileIndexOfPath(from);
1545
+ const total = _fileRows.length;
1546
+ for (let step = 1;step <= total; step++) {
1547
+ const at = (start + step + total) % total;
1548
+ const row = _fileRows[at];
1549
+ if (row && !row.loading && row.name.trim().toLowerCase().startsWith(char)) {
1550
+ focusFileRow(at);
1551
+ return;
1552
+ }
1553
+ }
1554
+ }
1555
+ function focusFileRow(index) {
1556
+ const row = _fileRows[index];
1557
+ if (!row) {
1558
+ return;
1559
+ }
1560
+ selectFileRow(row.path);
1561
+ if (fileRowElement(row.path)) {
1562
+ return;
1563
+ }
1564
+ revealListRow(_fileList, index, fileRowHeight());
1565
+ repaintFiles();
1566
+ }
1567
+ async function toggleTreeDirectory(path) {
1568
+ const state = requireProjectState();
1569
+ if (state.expanded.has(path)) {
1570
+ state.expanded.delete(path);
1571
+ return;
1572
+ }
1573
+ state.expanded.add(path);
1574
+ if (!state.dirs.has(path)) {
1575
+ await loadDirectory2(path);
1576
+ }
1577
+ }
1578
+ var _rowDnd = new Map;
1579
+ var _treeDnd = null;
1580
+ var _dragPath = "";
1581
+ var _overRow = "";
1582
+ var _dropPath = "";
1583
+ var _overRoot = false;
1584
+ var _rootDrop = "";
1585
+ function isFileDrag(e) {
1586
+ return [...e.dataTransfer?.types ?? []].includes("Files");
1587
+ }
1588
+ function registerFileDropTarget(element, dir, setActive) {
1589
+ const onDragOver = (e) => {
1590
+ if (!isFileDrag(e)) {
1591
+ return;
1592
+ }
1593
+ e.preventDefault();
1594
+ e.stopPropagation();
1595
+ if (e.dataTransfer) {
1596
+ e.dataTransfer.dropEffect = "copy";
1597
+ }
1598
+ setActive(true);
1599
+ };
1600
+ const onDragLeave = () => setActive(false);
1601
+ const onDrop = (e) => {
1602
+ setActive(false);
1603
+ const files = e.dataTransfer?.files;
1604
+ if (!files?.length) {
1605
+ return;
1606
+ }
1607
+ e.preventDefault();
1608
+ e.stopPropagation();
1609
+ uploadFilesToDir(files, dir, repaintFiles);
1610
+ };
1611
+ element.addEventListener("dragover", onDragOver);
1612
+ element.addEventListener("dragleave", onDragLeave);
1613
+ element.addEventListener("drop", onDrop);
1614
+ return () => {
1615
+ element.removeEventListener("dragover", onDragOver);
1616
+ element.removeEventListener("dragleave", onDragLeave);
1617
+ element.removeEventListener("drop", onDrop);
1618
+ };
1619
+ }
1620
+ function canMoveInto(srcPath, targetDir) {
1621
+ const src = srcPath.replaceAll("\\", "/");
1622
+ const dir = targetDir.replaceAll("\\", "/");
1623
+ if (!src || src === dir) {
1624
+ return false;
1625
+ }
1626
+ if (src.startsWith(`${dir}/`) || dir.startsWith(`${src}/`)) {
1627
+ return false;
1628
+ }
1629
+ return parentDir(src) !== dir;
1630
+ }
1631
+ function acceptsDrop(srcPath, targetPath, targetType) {
1632
+ return targetType === "directory" && typeof srcPath === "string" && canMoveInto(srcPath, targetPath);
1633
+ }
1634
+ function setRowUnderDrag(row, accepted) {
1635
+ const dropPath = accepted ? row : "";
1636
+ if (_overRow === row && _dropPath === dropPath) {
1637
+ return;
1638
+ }
1639
+ _overRow = row;
1640
+ _dropPath = dropPath;
1641
+ syncRootDrop();
1642
+ }
1643
+ function setRootUnderDrag(active) {
1644
+ if (_overRoot === active) {
1645
+ return;
1646
+ }
1647
+ _overRoot = active;
1648
+ syncRootDrop();
1649
+ }
1650
+ function syncRootDrop() {
1651
+ _rootDrop = _overRoot && _overRow === "" ? "true" : "";
1652
+ syncFilesDragState();
1653
+ }
1654
+ async function uploadFilesToDir(files, dir, renderLeftPanel) {
1655
+ const uploaded = await uploadAssets([...files], { dir });
1656
+ if (uploaded.length === 0) {
1657
+ return;
1658
+ }
1659
+ if (dir !== ".") {
1660
+ requireProjectState().expanded.add(dir);
1661
+ }
1662
+ renderLeftPanel();
1663
+ }
1664
+ function pickAndUploadTo(dir, renderLeftPanel) {
1665
+ const input = document.createElement("input");
1666
+ input.type = "file";
1667
+ input.multiple = true;
1668
+ input.accept = uploadAccept();
1669
+ input.addEventListener("change", () => {
1670
+ if (input.files?.length) {
1671
+ uploadFilesToDir(input.files, dir, renderLeftPanel);
1672
+ }
1673
+ });
1674
+ input.click();
1675
+ }
1676
+ function adoptFileRow(element, path, type) {
1677
+ releaseRowDnD(element);
1678
+ _fileRowEls.set(path, element);
1679
+ const cleanups = [
1680
+ draggable2({
1681
+ element,
1682
+ getInitialData() {
1683
+ return { entryType: type, path, type: "file-tree" };
1684
+ },
1685
+ onDragStart() {
1686
+ _dragPath = path;
1687
+ syncFilesDragState();
1688
+ },
1689
+ onDrop() {
1690
+ _dragPath = "";
1691
+ setRowUnderDrag("", false);
1692
+ syncFilesDragState();
1693
+ }
1694
+ }),
1695
+ registerFileDropTarget(element, type === "directory" ? path : parentDir(path), (active) => {
1696
+ setRowUnderDrag(active ? path : "", active);
1697
+ }),
1698
+ dropTargetForElements2({
1699
+ canDrop({ source }) {
1700
+ return source.data.type === "file-tree";
1701
+ },
1702
+ element,
1703
+ getData({ source }) {
1704
+ return acceptsDrop(source.data.path, path, type) ? { targetDir: path, type: "file-tree-target" } : { type: "file-tree-refused" };
1705
+ },
1706
+ onDrag({ source }) {
1707
+ setRowUnderDrag(path, acceptsDrop(source.data.path, path, type));
1708
+ },
1709
+ onDragEnter({ source }) {
1710
+ setRowUnderDrag(path, acceptsDrop(source.data.path, path, type));
1711
+ },
1712
+ onDragLeave() {
1713
+ setRowUnderDrag("", false);
1714
+ },
1715
+ onDrop() {
1716
+ setRowUnderDrag("", false);
1717
+ }
1718
+ })
1719
+ ];
1720
+ _rowDnd.set(element, combine(...cleanups));
1721
+ }
1722
+ function releaseRowDnD(element) {
1723
+ const cleanup = _rowDnd.get(element);
1724
+ if (cleanup) {
1725
+ cleanup();
1726
+ _rowDnd.delete(element);
1727
+ }
1728
+ }
1729
+ function adoptFileTreeElement(element) {
1730
+ if (_treeDnd?.element === element) {
1731
+ return;
1732
+ }
1733
+ releaseFileTreeDnD();
1734
+ _fileList = element;
1735
+ const rootCleanup = dropTargetForElements2({
1736
+ canDrop({ source }) {
1737
+ return source.data.type === "file-tree" && canMoveInto(source.data.path, ".");
1738
+ },
1739
+ element,
1740
+ getData() {
1741
+ return { targetDir: ".", type: "file-tree-target" };
1742
+ },
1743
+ onDragEnter() {
1744
+ setRootUnderDrag(true);
1745
+ },
1746
+ onDragLeave() {
1747
+ setRootUnderDrag(false);
1748
+ },
1749
+ onDrop() {
1750
+ setRootUnderDrag(false);
1751
+ }
1752
+ });
1753
+ const monitorCleanup = monitorForElements2({
1754
+ onDrop({ source, location: location2 }) {
1755
+ const [target] = location2.current.dropTargets;
1756
+ if (!target) {
1757
+ return;
1758
+ }
1759
+ if (source.data.type !== "file-tree") {
1760
+ return;
1761
+ }
1762
+ if (target.data.type !== "file-tree-target") {
1763
+ return;
1764
+ }
1765
+ const srcPath = source.data.path;
1766
+ const targetDirPath = target.data.targetDir;
1767
+ if (!canMoveInto(srcPath, targetDirPath)) {
1768
+ return;
1769
+ }
1770
+ const fileName = srcPath.split("/").pop();
1771
+ const newPath = targetDirPath === "." ? fileName : `${targetDirPath}/${fileName}`;
1772
+ moveFileEntry(srcPath, newPath, repaintFiles);
1773
+ }
1774
+ });
1775
+ _treeDnd = {
1776
+ cleanup: combine(rootCleanup, monitorCleanup, registerFileDropTarget(element, ".", setRootUnderDrag)),
1777
+ element
1778
+ };
1779
+ adoptFileTree();
1780
+ }
1781
+ function releaseFileTreeDnD() {
1782
+ _treeDnd?.cleanup();
1783
+ _treeDnd = null;
1784
+ for (const cleanup of _rowDnd.values()) {
1785
+ cleanup();
1786
+ }
1787
+ _rowDnd.clear();
1788
+ _fileWatch?.window.destroy();
1789
+ _fileWatch = null;
1790
+ _fileList = null;
1791
+ _dragPath = "";
1792
+ _overRow = "";
1793
+ _dropPath = "";
1794
+ _overRoot = false;
1795
+ _rootDrop = "";
1796
+ }
1797
+ async function moveFileEntry(oldPath, newPath, renderLeftPanel) {
1798
+ const platform = getPlatform2();
1799
+ markLocalMutation2(oldPath, newPath);
1800
+ try {
1801
+ const report = await platform.renameFile(oldPath, newPath);
1802
+ invalidateUsages2();
1803
+ for (const [id] of workspace2.tabs.entries()) {
1804
+ if (id === oldPath) {
1805
+ renameTab2(oldPath, newPath, newPath);
1806
+ } else if (id.startsWith(`${oldPath}/`)) {
1807
+ const newTabPath = newPath + id.slice(oldPath.length);
1808
+ renameTab2(id, newTabPath, newTabPath);
1809
+ }
1810
+ }
1811
+ const oldParent = parentDir(oldPath);
1812
+ const newParent = parentDir(newPath);
1813
+ await loadDirectory2(oldParent);
1814
+ if (newParent !== oldParent) {
1815
+ await loadDirectory2(newParent);
1816
+ }
1817
+ if (newParent !== ".") {
1818
+ requireProjectState().expanded.add(newParent);
1819
+ }
1820
+ reloadRewrittenTabs(report, newPath);
1821
+ renderLeftPanel();
1822
+ notifyMoveOutcome2(`Moved to ${newPath}`, report, newPath);
1823
+ } catch (error) {
1824
+ notify2.error(`Could not move ${oldPath}.`, {
1825
+ detail: errorMessage2(error),
1826
+ path: oldPath,
1827
+ source: "Files"
1828
+ });
1829
+ }
1830
+ }
1831
+ function parentDir(path) {
1832
+ const normalized = path.replaceAll("\\", "/");
1833
+ const lastSlash = normalized.lastIndexOf("/");
1834
+ return lastSlash === -1 ? "." : normalized.slice(0, lastSlash);
1835
+ }
1836
+ var _fileMenu = null;
1837
+ function dismissFileContextMenu() {
1838
+ _fileMenu?.close();
1839
+ _fileMenu = null;
1840
+ }
1841
+ function fileRowFacts(entry) {
1842
+ const facts = {};
1843
+ if (entry.type === "directory") {
1844
+ const collection = collectionForDirectory(entry.path);
1845
+ if (collection?.isSourceRoot === true && !collection.fileBacked) {
1846
+ facts.name = collection.name;
1847
+ }
1848
+ return facts;
1849
+ }
1850
+ if (collectionOfPath(entry.path)) {
1851
+ facts.path = entry.path;
1852
+ }
1853
+ if (convertTargets(entry.path).length > 0) {
1854
+ facts.source = entry.path;
1855
+ }
1856
+ return facts;
1857
+ }
1858
+ function treeMenuRow(id, title, run, extra = {}) {
1859
+ return { destructive: false, disabled: false, dividerAbove: false, id, run, title, ...extra };
1860
+ }
1861
+ function placedFileRows(entry) {
1862
+ const registry = activeRegistry();
1863
+ if (!registry) {
1864
+ return [];
1865
+ }
1866
+ const facts = fileRowFacts(entry);
1867
+ const rows = [];
1868
+ for (const command of registry.forPlacement("context/file")) {
1869
+ const schema = command.args;
1870
+ if (!(schema?.required ?? []).every((key) => (key in facts))) {
1871
+ continue;
1872
+ }
1873
+ const args = {};
1874
+ for (const key of Object.keys(schema?.properties ?? {})) {
1875
+ if (key in facts) {
1876
+ args[key] = facts[key];
1877
+ }
1878
+ }
1879
+ const reason = registry.disabledReason(command.id);
1880
+ rows.push(reason === undefined ? treeMenuRow(command.id, command.title, () => {
1881
+ runReported(registry, command.id, args, "Files");
1882
+ }) : {
1883
+ destructive: false,
1884
+ disabled: true,
1885
+ dividerAbove: false,
1886
+ id: command.id,
1887
+ requires: reason,
1888
+ title: command.title
1889
+ });
1890
+ }
1891
+ return rows;
1892
+ }
1893
+ function fileMenuRows(entry) {
1894
+ const isDir = entry.type === "directory";
1895
+ const rows = [];
1896
+ if (isDir) {
1897
+ rows.push(treeMenuRow("files.newFile", "New File…", () => {
1898
+ createNewFile(entry.path, repaintFiles);
1899
+ }), treeMenuRow("files.upload", "Upload Files…", () => {
1900
+ pickAndUploadTo(entry.path, repaintFiles);
1901
+ }));
1902
+ if (entry.path === "pages" || entry.path.endsWith("/pages")) {
1903
+ rows.push(treeMenuRow("files.pagesGrid", "Edit Pages in Grid", () => {
1904
+ openPagesGrid();
1905
+ }));
1906
+ }
1907
+ } else {
1908
+ rows.push(treeMenuRow("files.open", "Open", () => {
1909
+ openFileInTab2(entry.path);
1910
+ }));
1911
+ }
1912
+ rows.push(...placedFileRows(entry), treeMenuRow("files.rename", "Rename…", () => {
1913
+ renameFile(entry, repaintFiles);
1914
+ }, { dividerAbove: true }), treeMenuRow("files.delete", "Delete", () => {
1915
+ deleteFile(entry, repaintFiles);
1916
+ }, { destructive: true }));
1917
+ return rows;
1918
+ }
1919
+ function showFileContextMenu(path, x, y) {
1920
+ const row = fileRowAt(path);
1921
+ if (!row) {
1922
+ return;
1923
+ }
1924
+ dismissFileContextMenu();
1925
+ const opener = fileRowElement(path);
1926
+ _fileMenu = openMenu2({
1927
+ label: "File actions",
1928
+ onClosed: (handle) => {
1929
+ if (_fileMenu === handle) {
1930
+ _fileMenu = null;
1931
+ }
1932
+ },
1933
+ opener,
1934
+ origin: { x, y },
1935
+ region: "files",
1936
+ rows: fileMenuRows({ name: row.name, path: row.path, type: row.type })
1937
+ });
1938
+ }
1939
+ var BLANK_DOCUMENT = JSON.stringify({ children: [{ children: [], tagName: "p" }], tagName: "div" }, null, 2);
1940
+ var OTHER_FORMAT = "__other__";
1941
+ function slugify(input) {
1942
+ return input.trim().toLowerCase().replaceAll(/\s+/g, "-").replaceAll(/[^a-z\d-]/g, "");
1943
+ }
1944
+ function extensionOfName(name) {
1945
+ const dot = name.lastIndexOf(".");
1946
+ return dot > 0 ? name.slice(dot) : "";
1947
+ }
1948
+ function formatRowsFor(choice) {
1949
+ const rows = choice.kind === "locked" ? [
1950
+ {
1951
+ ext: choice.ext,
1952
+ label: `${formatByExtension2(choice.ext)?.name ?? choice.ext} (${choice.ext})`
1953
+ }
1954
+ ] : creationFormats(choice.docKind);
1955
+ return [
1956
+ ...rows.map((row) => ({ label: row.label, value: row.ext })),
1957
+ { dividerBefore: true, label: "Other…", value: OTHER_FORMAT }
1958
+ ];
1959
+ }
1960
+ function initialPickFor(choice, rows, suggested) {
1961
+ const stated = choice.kind === "choose" ? choice.defaultExt : choice.ext;
1962
+ if (stated !== undefined && rows.some((row) => row.value === stated)) {
1963
+ return stated;
1964
+ }
1965
+ const fromPrefill = extensionOfName(suggested);
1966
+ if (fromPrefill !== "" && rows.some((row) => row.value === fromPrefill)) {
1967
+ return fromPrefill;
1968
+ }
1969
+ return rows[0]?.value ?? OTHER_FORMAT;
1970
+ }
1971
+ async function createFileIn2(request) {
1972
+ const { dir, format: choice, source = "Files" } = request;
1973
+ await loadFormats2();
1974
+ let taken = new Set;
1975
+ try {
1976
+ const listing = await getPlatform2().listDirectory(dir);
1977
+ taken = new Set(listing.map((entry) => entry.name.toLowerCase()));
1978
+ } catch {}
1979
+ const picker = choice !== undefined && choice.kind !== "fixed" ? choice : null;
1980
+ const rows = picker === null ? null : formatRowsFor(picker);
1981
+ const initialPick = picker === null || rows === null ? "" : initialPickFor(picker, rows, request.suggestedName ?? "");
1982
+ const fileNameFor = (input, picked) => {
1983
+ const trimmed = input.trim();
1984
+ if (choice === undefined || picked === OTHER_FORMAT) {
1985
+ return trimmed;
1986
+ }
1987
+ if (choice.kind === "fixed") {
1988
+ const slug = slugify(trimmed);
1989
+ return slug === "" ? "" : `${slug}${choice.ext}`;
1990
+ }
1991
+ return trimmed.toLowerCase().endsWith(picked.toLowerCase()) ? trimmed : `${trimmed}${picked}`;
1992
+ };
1993
+ const known = knownDocumentExtensions();
1994
+ const validate = (value, picked) => {
1995
+ const trimmed = value.trim();
1996
+ if (!trimmed) {
1997
+ return choice?.kind === "fixed" ? "Enter a name." : "Enter a file name.";
1998
+ }
1999
+ if (choice?.kind === "fixed" && slugify(trimmed) === "") {
2000
+ return "Enter at least one letter or number.";
2001
+ }
2002
+ const normalized = trimmed.replaceAll("\\", "/");
2003
+ if (normalized.startsWith("/") || normalized.endsWith("/")) {
2004
+ return "Enter a name, not a path that starts or ends with a slash.";
2005
+ }
2006
+ if (normalized.split("/").includes("..")) {
2007
+ return "A name cannot step outside the destination folder.";
2008
+ }
2009
+ if (normalized.includes("/") && choice !== undefined && picked !== OTHER_FORMAT) {
2010
+ return `Pick Other… to create a file in a subfolder of ${dir === "." ? "the project root" : dir}.`;
2011
+ }
2012
+ const typedExt = extensionOfName(normalized);
2013
+ if (picked !== "" && picked !== OTHER_FORMAT && typedExt !== "" && typedExt.toLowerCase() !== picked.toLowerCase() && known.has(typedExt.toLowerCase())) {
2014
+ const label = rows?.find((row) => row.value === picked)?.label ?? picked;
2015
+ return `You picked ${label}; this name ends in ${typedExt}.`;
2016
+ }
2017
+ if (choice?.kind === "locked" && picked === OTHER_FORMAT) {
2018
+ const foreign = typedExt !== "" && typedExt.toLowerCase() !== choice.ext.toLowerCase();
2019
+ if (foreign && known.has(typedExt.toLowerCase())) {
2020
+ return choice.because;
2021
+ }
2022
+ }
2023
+ const candidate = fileNameFor(value, picked);
2024
+ return taken.has(candidate.toLowerCase()) ? `${candidate} already exists in ${dir}/.` : "";
2025
+ };
2026
+ let picked = initialPick;
2027
+ const entered = await showPromptDialog2(request.title ?? "New File", {
2028
+ ...rows === null ? {} : {
2029
+ choice: {
2030
+ initial: initialPick,
2031
+ label: "Format",
2032
+ onChange: (next) => {
2033
+ picked = next;
2034
+ },
2035
+ options: () => rows
2036
+ }
2037
+ },
2038
+ confirmLabel: "Create",
2039
+ message: dir === "." ? "Creating in the project root." : `Creating in ${dir}/`,
2040
+ ...request.suggestedName === undefined ? {} : { placeholder: request.suggestedName },
2041
+ select: rows === null ? "stem" : "all",
2042
+ validate,
2043
+ value: request.suggestedName ?? "untitled.json"
2044
+ });
2045
+ if (!entered) {
2046
+ return null;
2047
+ }
2048
+ const fileName = fileNameFor(entered, picked);
2049
+ const path = dir === "." ? fileName : `${dir}/${fileName}`;
2050
+ markLocalMutation2(path);
2051
+ const format = formatForPath2(fileName);
2052
+ const suppliedBody = typeof request.content === "function" ? await request.content(extensionOfName(fileName), fileName) : request.content;
2053
+ const chosenAsDocument = choice !== undefined && picked !== OTHER_FORMAT;
2054
+ const content = suppliedBody ?? format?.studio?.newFileTemplate ?? (format ? "" : fileName.toLowerCase().endsWith(".json") ? chosenAsDocument ? BLANK_DOCUMENT : `{}
2055
+ ` : "");
2056
+ try {
2057
+ await getPlatform2().writeFile(path, content);
2058
+ await loadDirectory2(dir);
2059
+ notify2.success(`Created ${path}`);
2060
+ return path;
2061
+ } catch (error) {
2062
+ notify2.error(`Could not create ${path}.`, {
2063
+ detail: errorMessage2(error),
2064
+ path,
2065
+ source
2066
+ });
2067
+ return null;
2068
+ }
2069
+ }
2070
+ async function createNewFile(dirPath, renderLeftPanel) {
2071
+ await loadFormats2();
2072
+ const collection = collectionForDirectory(dirPath);
2073
+ if (collection?.unresolvedFormat != null) {
2074
+ notify2.error(`New files in ${dirPath}/ cannot be constrained to the collection's format.`, {
2075
+ 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.",
2076
+ path: dirPath,
2077
+ source: "Files"
2078
+ });
2079
+ }
2080
+ const constrained = collection?.ext != null && collection.unresolvedFormat === null;
2081
+ const seedable = constrained && collection.isSourceRoot && collection.def.schema !== undefined;
2082
+ let created;
2083
+ if (seedable) {
2084
+ const { createEntry } = await (__preload("234hjnqw"), import("./entry-commands-234hjnqw.js"));
2085
+ created = await createEntry(collection.name, { dir: dirPath });
2086
+ } else {
2087
+ created = await createFileIn2({
2088
+ dir: dirPath,
2089
+ format: constrained && collection.ext !== null ? {
2090
+ because: `${collection.name} entries are ${collection.ext} files, so a document of another format here would not be one.`,
2091
+ ext: collection.ext,
2092
+ kind: "locked"
2093
+ } : { defaultExt: ".json", kind: "choose" },
2094
+ suggestedName: "untitled"
2095
+ });
2096
+ }
2097
+ if (created !== null) {
2098
+ renderLeftPanel();
2099
+ }
2100
+ }
2101
+ async function showRenameFileDialog(currentName, path) {
2102
+ const message = await renamePromptMessage2(path);
2103
+ return showPromptDialog2("Rename", {
2104
+ confirmLabel: "Rename",
2105
+ ...message === undefined ? {} : { message },
2106
+ select: "stem",
2107
+ validate: (v) => v.trim() ? "" : "Enter a file name.",
2108
+ value: currentName
2109
+ });
2110
+ }
2111
+ function renameStatus(newName, report) {
2112
+ const refs = report.references;
2113
+ const tagNote = report.tag ? `; tag → <${report.tag.to}> (${report.tag.refsUpdated})` : "";
2114
+ if (refs && refs.refsUpdated > 0) {
2115
+ return `Renamed to ${newName}; updated ${refs.refsUpdated} reference(s) in ${refs.filesChanged} file(s)${tagNote}`;
2116
+ }
2117
+ if (tagNote) {
2118
+ return `Renamed to ${newName}${tagNote}`;
2119
+ }
2120
+ return `Renamed to ${newName}`;
2121
+ }
2122
+ function notifyMoveOutcome2(headline, report, path) {
2123
+ const stuck = report.errors ?? [];
2124
+ if (stuck.length === 0) {
2125
+ notify2.success(headline);
2126
+ return;
2127
+ }
2128
+ const files = stuck.length === 1 ? "1 file" : `${stuck.length} files`;
2129
+ notify2.warn(`${headline} — references in ${files} could not be updated`, {
2130
+ detail: stuck.map((e) => `${e.path}: ${e.error}`).join(`
2131
+ `),
2132
+ path,
2133
+ source: "Files"
2134
+ });
2135
+ }
2136
+ function reloadRewrittenTabs(report, skipPath) {
2137
+ for (const f of report.references?.files ?? []) {
2138
+ if (f.path !== skipPath && workspace2.tabs.has(f.path)) {
2139
+ reloadFileInTab2(f.path);
2140
+ }
2141
+ }
2142
+ }
2143
+ function parentDirOf(path) {
2144
+ const normalized = path.replaceAll("\\", "/");
2145
+ return normalized.includes("/") ? normalized.slice(0, normalized.lastIndexOf("/")) : ".";
2146
+ }
2147
+ async function settleRename2(from, to, report) {
2148
+ invalidateUsages2();
2149
+ const fromDir = parentDirOf(from);
2150
+ const toDir = parentDirOf(to);
2151
+ await loadDirectory2(fromDir);
2152
+ if (toDir !== fromDir) {
2153
+ await loadDirectory2(toDir);
2154
+ }
2155
+ if (requireProjectState().selectedPath === from) {
2156
+ requireProjectState().selectedPath = to;
2157
+ }
2158
+ reloadRewrittenTabs(report, to);
2159
+ }
2160
+ async function renameFile(entry, renderLeftPanel) {
2161
+ const newName = await showRenameFileDialog(entry.name, entry.path);
2162
+ if (!newName || newName === entry.name) {
2163
+ return;
2164
+ }
2165
+ const parentDirPath = parentDirOf(entry.path);
2166
+ const newPath = parentDirPath === "." ? newName : `${parentDirPath}/${newName}`;
2167
+ markLocalMutation2(entry.path, newPath);
2168
+ try {
2169
+ const platform = getPlatform2();
2170
+ const report = await platform.renameFile(entry.path, newPath);
2171
+ if (workspace2.tabs.has(entry.path)) {
2172
+ renameTab2(entry.path, newPath, newPath);
2173
+ }
2174
+ await settleRename2(entry.path, newPath, report);
2175
+ renderLeftPanel();
2176
+ notifyMoveOutcome2(renameStatus(newName, report), report, newPath);
2177
+ } catch (error) {
2178
+ notify2.error(`Could not rename ${entry.name}.`, {
2179
+ detail: errorMessage2(error),
2180
+ path: entry.path,
2181
+ source: "Files"
2182
+ });
2183
+ }
2184
+ }
2185
+ async function deleteFile(entry, renderLeftPanel) {
2186
+ const confirmed = await confirmFileDelete2(entry);
2187
+ if (!confirmed) {
2188
+ return;
2189
+ }
2190
+ try {
2191
+ const platform = getPlatform2();
2192
+ markLocalMutation2(entry.path);
2193
+ await platform.deleteFile(entry.path);
2194
+ invalidateUsages2();
2195
+ const delPath = entry.path.replaceAll("\\", "/");
2196
+ const parentDirPath = delPath.includes("/") ? delPath.slice(0, delPath.lastIndexOf("/")) : ".";
2197
+ await loadDirectory2(parentDirPath);
2198
+ if (requireProjectState().selectedPath === entry.path) {
2199
+ requireProjectState().selectedPath = null;
2200
+ }
2201
+ renderLeftPanel();
2202
+ notify2.success(`Deleted ${entry.name}`);
2203
+ } catch (error) {
2204
+ notify2.error(`Could not delete ${entry.name}.`, {
2205
+ detail: errorMessage2(error),
2206
+ path: entry.path,
2207
+ source: "Files"
2208
+ });
2209
+ }
2210
+ }
2211
+ function revealOpenTab(tabId, opts) {
2212
+ const wanted = opts.paneId;
2213
+ const holder = paneOfTab2(tabId);
2214
+ if (wanted !== undefined && holder && holder.id !== wanted) {
2215
+ if (holder.activeTabId === tabId) {
2216
+ return;
2217
+ }
2218
+ moveTabToPane2(tabId, wanted);
2219
+ }
2220
+ activateTab2(tabId, { focus: opts.focus !== false });
2221
+ }
2222
+ async function openFileInTab2(path, opts = {}) {
2223
+ const follows = opts.focus !== false;
2224
+ for (const [id, tab] of workspace2.tabs.entries()) {
2225
+ if (tab.documentPath === path) {
2226
+ revealOpenTab(id, opts);
2227
+ if (follows) {
2228
+ requireProjectState().selectedPath = path;
2229
+ }
2230
+ return;
2231
+ }
2232
+ }
2233
+ if (isViewableMedia(path)) {
2234
+ openMediaTab(path);
2235
+ if (follows) {
2236
+ requireProjectState().selectedPath = path;
2237
+ }
2238
+ trackRecentFile({
2239
+ name: path.split("/").pop() || path,
2240
+ path,
2241
+ root: requireProjectState().projectRoot
2242
+ });
2243
+ return;
2244
+ }
2245
+ if (path.toLowerCase().endsWith(".csv")) {
2246
+ try {
2247
+ await openCsvGridTab(path);
2248
+ requireProjectState().selectedPath = path;
2249
+ trackRecentFile({
2250
+ name: path.split("/").pop() || path,
2251
+ path,
2252
+ root: requireProjectState().projectRoot
2253
+ });
2254
+ } catch (error) {
2255
+ notify2.error(`Could not open ${path}.`, {
2256
+ detail: errorMessage2(error),
2257
+ path,
2258
+ source: "Open File"
2259
+ });
2260
+ }
2261
+ return;
2262
+ }
2263
+ const platform = getPlatform2();
2264
+ try {
2265
+ const content = await platform.readFile(path);
2266
+ if (!content) {
2267
+ await loadFormats2();
2268
+ if (!formatForPath2(path) && !path.toLowerCase().endsWith(".json")) {
2269
+ throw noFormatError2(path);
2270
+ }
2271
+ return;
2272
+ }
2273
+ await loadFormats2();
2274
+ let document2;
2275
+ let frontmatter;
2276
+ let layout = null;
2277
+ const format = formatForPath2(path);
2278
+ if (format) {
2279
+ const result = await parseSourceForPath2(path, content);
2280
+ ({ document: document2 } = result);
2281
+ ({ frontmatter } = result);
2282
+ } else if (path.endsWith(".json")) {
2283
+ ({ document: document2, layout } = parseJsonDocument(content));
2284
+ } else {
2285
+ throw noFormatError2(path);
2286
+ }
2287
+ const id = path;
2288
+ openTab2({
2289
+ id,
2290
+ documentPath: path,
2291
+ document: document2,
2292
+ ...frontmatter != null && { frontmatter },
2293
+ layout,
2294
+ sourceFormat: format?.name ?? null,
2295
+ ...opts.paneId !== undefined && { paneId: opts.paneId },
2296
+ ...opts.preview === true && { preview: true },
2297
+ ...opts.focus === false && { focus: false }
2298
+ });
2299
+ if (follows) {
2300
+ requireProjectState().selectedPath = path;
2301
+ }
2302
+ trackRecentFile({
2303
+ name: path.split("/").pop() || path,
2304
+ path,
2305
+ root: requireProjectState().projectRoot
2306
+ });
2307
+ } catch (error) {
2308
+ notify2.error(`Could not open ${path}.`, {
2309
+ detail: errorMessage2(error),
2310
+ path,
2311
+ source: "Open File"
2312
+ });
2313
+ }
2314
+ }
2315
+ async function openFileInPane2(paneId, path) {
2316
+ await openFileInTab2(path, { focus: false, paneId, preview: true });
2317
+ }
2318
+ function reloadCleanTab2(path) {
2319
+ if (isCollabPath(path)) {
2320
+ return;
2321
+ }
2322
+ for (const [, tab] of workspace2.tabs.entries()) {
2323
+ if (tab.documentPath === path && !tab.doc.dirty) {
2324
+ reloadFileInTab2(path);
2325
+ return;
2326
+ }
2327
+ }
2328
+ }
2329
+ async function reloadFileInTab2(path) {
2330
+ for (const [, tab] of workspace2.tabs.entries()) {
2331
+ if (tab.documentPath === path) {
2332
+ const platform = getPlatform2();
2333
+ try {
2334
+ const content = await platform.readFile(path);
2335
+ if (!content) {
2336
+ return;
2337
+ }
2338
+ await loadFormats2();
2339
+ if (formatForPath2(path)) {
2340
+ const { document: document2, frontmatter } = await parseSourceForPath2(path, content);
2341
+ tab.doc.document = document2;
2342
+ tab.doc.content.frontmatter = frontmatter;
2343
+ } else if (path.endsWith(".json")) {
2344
+ const parsed = parseJsonDocument(content);
2345
+ tab.doc.document = parsed.document;
2346
+ tab.doc.layout = parsed.layout;
2347
+ }
2348
+ tab.doc.dirty = false;
2349
+ } catch (error) {
2350
+ notify2.error(`Could not reload ${path} after it changed on disk.`, {
2351
+ detail: errorMessage2(error),
2352
+ key: `reload:${path}`,
2353
+ path,
2354
+ source: "Files"
2355
+ });
2356
+ }
2357
+ return;
2358
+ }
2359
+ }
2360
+ }
2361
+ function registerFilesPanel2() {
2362
+ registerPanel({
2363
+ id: "files",
2364
+ title: "Files",
2365
+ level: "project",
2366
+ dock: "navigator",
2367
+ icon: "folder",
2368
+ render: () => nothing2,
2369
+ afterRender: (ctx, host) => {
2370
+ mountFilesPanel(host, ctx.rerender);
2371
+ }
2372
+ });
2373
+ }
2374
+ var FILE_ACTIONS = {
2375
+ activate: activateFileRow,
2376
+ contextMenu: showFileContextMenu,
2377
+ expand: expandFileRow,
2378
+ move: moveFileCaret,
2379
+ newFile: () => {
2380
+ createNewFile(".", repaintFiles);
2381
+ },
2382
+ openProject: () => {
2383
+ runActiveReported("project.open", undefined, "Files");
2384
+ },
2385
+ refresh: () => {
2386
+ refreshFileTree();
2387
+ },
2388
+ rowHost: adoptFileRow,
2389
+ search: (value) => {
2390
+ requireProjectState().searchQuery = value;
2391
+ repaintFiles();
2392
+ },
2393
+ select: selectFileRow,
2394
+ toggleIgnored: () => {
2395
+ setShowIgnoredFiles(!showIgnoredFiles());
2396
+ repaintFiles();
2397
+ },
2398
+ treeHost: adoptFileTreeElement,
2399
+ typeahead: typeaheadFileCaret
2400
+ };
2401
+ var _standingFiles = null;
2402
+ var _lastValues = null;
2403
+ function mountFilesPanel(host, rerender) {
2404
+ const container = host.querySelector(".panel-content") ?? host;
2405
+ _filesRerender = rerender;
2406
+ if (_standingFiles && (_standingFiles.host !== container || !_standingFiles.handle.connected())) {
2407
+ unmountFilesPanel();
2408
+ }
2409
+ const values = filesPanelValues();
2410
+ if (_standingFiles) {
2411
+ _standingFiles.handle.update(values);
2412
+ } else {
2413
+ const handle = mountFilesPanelSurface(container, values, FILE_ACTIONS);
2414
+ _standingFiles = { handle, host: container };
2415
+ handle.ready.then(adoptFileTree);
2416
+ }
2417
+ queueMicrotask(adoptFileTree);
2418
+ }
2419
+ function unmountFilesPanel() {
2420
+ dismissFileContextMenu();
2421
+ _standingFiles?.handle.dispose();
2422
+ _standingFiles = null;
2423
+ _lastValues = null;
2424
+ releaseFileTreeDnD();
2425
+ _fileRowEls.clear();
2426
+ _fileRows = [];
2427
+ }
2428
+
2429
+ export { ensureDependenciesInstalled, convertTargets, convertTargetExtensions, hydrateRecentProjects, getRecentProjects, addRecentProject, removeRecentProject, clearRecentProjects, getRecentFiles, trackRecentFile, loadDirectory2, loadProject2, openProject2, initProjectRepo2, findHomePage2, openLastSessionOrHome2, renderFilesTemplate2, registerFileTreeDnD2, createFileIn2, notifyMoveOutcome2, settleRename2, openFileInTab2, openFileInPane2, reloadCleanTab2, reloadFileInTab2, registerFilesPanel2 };
2430
+
2431
+ //# debugId=E1EE7183DAEAEF7C64756E2164756E21
2432
+ //# sourceMappingURL=studio-b0k5tqgp.js.map