@jxsuite/studio 4.1.0 → 5.0.0

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