@jxsuite/studio 6.1.2 → 8.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 (522) hide show
  1. package/README.md +5 -5
  2. package/dist/chunks/2020-5wtzce5g.js +4 -0
  3. package/dist/chunks/adapter-5tphg7xe.js +4 -0
  4. package/dist/chunks/add-new-flow-psym14sn.js +4 -0
  5. package/dist/chunks/cf-account-picker-haqazq5r.js +4 -0
  6. package/dist/chunks/cf-settings-h2wrh6hq.js +4 -0
  7. package/dist/chunks/{color-area-0fj8a4ga.js → color-area-6rbra5dy.js} +2 -2
  8. package/dist/chunks/{color-field-xch8kx2g.js → color-field-gy56c94g.js} +3 -3
  9. package/dist/chunks/color-m7r1vk54.js +4 -0
  10. package/dist/chunks/{color-slider-jxd8v350.js → color-slider-sqqdyf6c.js} +2 -2
  11. package/dist/chunks/{combobox-p0efwjke.js → combobox-72h32ejk.js} +3 -3
  12. package/dist/chunks/components-r22xca09.js +4 -0
  13. package/dist/chunks/content-source-mmppmcyg.js +4 -0
  14. package/dist/chunks/convert-to-repeater-he70fc2b.js +4 -0
  15. package/dist/chunks/editor-ccd9jwsa.js +4 -0
  16. package/dist/chunks/entry-commands-6qxz9e8p.js +4 -0
  17. package/dist/chunks/extension-sections-0egb88dm.js +4 -0
  18. package/dist/chunks/file-ops-qnab36ek.js +4 -0
  19. package/dist/chunks/files-rcn56qvm.js +4 -0
  20. package/dist/chunks/format-host-yxz0kjjs.js +4 -0
  21. package/dist/chunks/fs-events-d1qxq4z4.js +4 -0
  22. package/dist/chunks/grid-open-4z1g062t.js +4 -0
  23. package/dist/chunks/{grid-view-d2wq9ezg.js → grid-view-qg1b5eqx.js} +25 -25
  24. package/dist/chunks/{icons-pnfz478q.js → icons-63bjtbs7.js} +2 -2
  25. package/dist/chunks/{iframe-entry-jdcktez8.js → iframe-entry-2zggzajv.js} +4 -4
  26. package/dist/chunks/{iframe-entry-zap785cw.js → iframe-entry-76j8vwwx.js} +4 -4
  27. package/dist/chunks/iframe-entry-99nr5zfb.js +5 -0
  28. package/dist/chunks/{iframe-entry-x0ygf2yr.js → iframe-entry-pkgmcgp0.js} +4 -4
  29. package/dist/chunks/iframe-host-ssv7kyj0.js +4 -0
  30. package/dist/chunks/{index-zpjmzqfk.js → index-32eqzv1k.js} +3 -3
  31. package/dist/chunks/index-f0jn7nnp.js +4 -0
  32. package/dist/chunks/{javascript-m54mnwp6.js → javascript-pjp734q4.js} +3 -3
  33. package/dist/chunks/jsonMode-njkvsa02.js +13 -0
  34. package/dist/chunks/jx-validate-ttasrbh7.js +4 -0
  35. package/dist/chunks/layers-bgyr11tr.js +4 -0
  36. package/dist/chunks/layers-panel-7ez66zeq.js +4 -0
  37. package/dist/chunks/{listbox-e74qjyq6.js → listbox-c421cf8c.js} +2 -2
  38. package/dist/chunks/lit-html-v9gh687x.js +4 -0
  39. package/dist/chunks/media-library-sq468wts.js +4 -0
  40. package/dist/chunks/media-picker-shfe59pt.js +4 -0
  41. package/dist/chunks/{menu-n6yzswmy.js → menu-bdpzbfvs.js} +2 -2
  42. package/dist/chunks/{monaco-binding-7gx83x3r.js → monaco-binding-vq1hgnn0.js} +3 -3
  43. package/dist/chunks/monaco-buffer-3afgwvbp.js +4 -0
  44. package/dist/chunks/monaco-setup-xrd2cbkp.js +4 -0
  45. package/dist/chunks/notify-kzrjr3fv.js +4 -0
  46. package/dist/chunks/parse-v77xtwv7.js +4 -0
  47. package/dist/chunks/platform-7v4rtd7m.js +4 -0
  48. package/dist/chunks/popover-b89sfej7.js +4 -0
  49. package/dist/chunks/publish-panel-2z9gw8ee.js +4 -0
  50. package/dist/chunks/publish-quick-qx2455cj.js +4 -0
  51. package/dist/chunks/publish-workspace-wrc1dgwx.js +4 -0
  52. package/dist/chunks/quick-search-n0t0eqxb.js +4 -0
  53. package/dist/chunks/references-9547rg5s.js +4 -0
  54. package/dist/chunks/right-panel-wsgnr9pn.js +4 -0
  55. package/dist/chunks/source-control-kwktr9y6.js +4 -0
  56. package/dist/chunks/{split-n2gfpm5m.js → split-c9zfdgxf.js} +2 -2
  57. package/dist/chunks/studio-03ct6yfv.js +9 -0
  58. package/dist/chunks/studio-07rcfje3.js +5 -0
  59. package/dist/chunks/studio-3e54qh39.js +7 -0
  60. package/dist/chunks/studio-3exxhz5g.js +5 -0
  61. package/dist/chunks/studio-3q40e3rj.js +5 -0
  62. package/dist/chunks/studio-3qeh9t0h.js +6 -0
  63. package/dist/chunks/studio-3qqjeep5.js +6 -0
  64. package/dist/chunks/studio-43sd2mam.js +4 -0
  65. package/dist/chunks/studio-4hp8pkyt.js +5 -0
  66. package/dist/chunks/studio-58xg6j2q.js +9 -0
  67. package/dist/chunks/studio-5g0rprdt.js +7 -0
  68. package/dist/chunks/{studio-2j1cb95x.js → studio-6m380wp7.js} +4 -4
  69. package/dist/chunks/studio-80jyh1xh.js +4 -0
  70. package/dist/chunks/studio-83mk4bgg.js +9 -0
  71. package/dist/chunks/{studio-v0jzqdjm.js → studio-881z1xrx.js} +4 -4
  72. package/dist/chunks/studio-8m0y2qe7.js +5 -0
  73. package/dist/chunks/{studio-d81xfh1g.js → studio-8tr6cfrc.js} +4 -4
  74. package/dist/chunks/studio-8vcvfs7r.js +6 -0
  75. package/dist/chunks/studio-9tmebf0s.js +5 -0
  76. package/dist/chunks/studio-a2bvaptz.js +5 -0
  77. package/dist/chunks/studio-b7y5mr30.js +5 -0
  78. package/dist/chunks/studio-bavb31r0.js +5 -0
  79. package/dist/chunks/{studio-dgz8d0c1.js → studio-bbe4c90a.js} +4 -4
  80. package/dist/chunks/studio-c05wdnt3.js +5 -0
  81. package/dist/chunks/studio-ccv2svc6.js +5 -0
  82. package/dist/chunks/studio-d5grtb9e.js +16 -0
  83. package/dist/chunks/studio-df0baea9.js +5 -0
  84. package/dist/chunks/studio-dgk4dqtx.js +7 -0
  85. package/dist/chunks/studio-e1g64q43.js +5 -0
  86. package/dist/chunks/studio-ed1hp6zf.js +6 -0
  87. package/dist/chunks/studio-ed3xx40h.js +7 -0
  88. package/dist/chunks/studio-f14e1zdj.js +5 -0
  89. package/dist/chunks/studio-fbhxxc5f.js +5 -0
  90. package/dist/chunks/studio-fyh0jc96.js +5 -0
  91. package/dist/chunks/studio-gcxk20n7.js +5 -0
  92. package/dist/chunks/studio-jaaz8ce9.js +5 -0
  93. package/dist/chunks/{studio-90pq9km1.js → studio-jcnsdaep.js} +4 -4
  94. package/dist/chunks/studio-jsgf2q5k.js +7 -0
  95. package/dist/chunks/{studio-0q988f9w.js → studio-k3xxbagr.js} +3 -3
  96. package/dist/chunks/{studio-5ve6bbep.js → studio-k7evxqh4.js} +4 -4
  97. package/dist/chunks/studio-kt3pjkwd.js +5 -0
  98. package/dist/chunks/studio-m8g16bgz.js +5 -0
  99. package/dist/chunks/studio-mn0476ag.js +5 -0
  100. package/dist/chunks/studio-mx1smyq0.js +5 -0
  101. package/dist/chunks/studio-n0c5h6mf.js +5 -0
  102. package/dist/chunks/{studio-485046te.js → studio-nh6d342n.js} +7 -7
  103. package/dist/chunks/studio-nqxqf8p2.js +4 -0
  104. package/dist/chunks/studio-p4nrkvqr.js +5 -0
  105. package/dist/chunks/{studio-1fxkaaea.js → studio-pbxa5fpc.js} +4 -4
  106. package/dist/chunks/studio-pgmvdv7z.js +7 -0
  107. package/dist/chunks/studio-ph84avkf.js +5 -0
  108. package/dist/chunks/{studio-tq0rtfwj.js → studio-q0mvbaq6.js} +4 -4
  109. package/dist/chunks/studio-q0tccd43.js +5 -0
  110. package/dist/chunks/studio-q7rtx6zq.js +14 -0
  111. package/dist/chunks/{studio-a3g98wjr.js → studio-qgh13jtz.js} +4 -4
  112. package/dist/chunks/studio-qmn1xc24.js +5 -0
  113. package/dist/chunks/studio-qwdqwkj0.js +5 -0
  114. package/dist/chunks/studio-r5qy30vx.js +5 -0
  115. package/dist/chunks/studio-rj9eamf8.js +5 -0
  116. package/dist/chunks/studio-rptgsk96.js +5 -0
  117. package/dist/chunks/studio-rthyg42z.js +928 -0
  118. package/dist/chunks/studio-s19tp1xr.js +5 -0
  119. package/dist/chunks/studio-s32578pn.js +5 -0
  120. package/dist/chunks/studio-svb7yyve.js +5 -0
  121. package/dist/chunks/studio-syreb644.js +5 -0
  122. package/dist/chunks/studio-tf9jryb1.js +10 -0
  123. package/dist/chunks/studio-tfkznv39.js +5 -0
  124. package/dist/chunks/studio-tft6r105.js +5 -0
  125. package/dist/chunks/studio-txf2kysx.js +5 -0
  126. package/dist/chunks/studio-v8867ddv.js +12 -0
  127. package/dist/chunks/studio-vxq7fcvv.js +5 -0
  128. package/dist/chunks/studio-w4rz9hdk.js +5 -0
  129. package/dist/chunks/studio-wbcjbhy1.js +9 -0
  130. package/dist/chunks/studio-wc649wss.js +5 -0
  131. package/dist/chunks/studio-wys23mxz.js +5 -0
  132. package/dist/chunks/studio-x1x167jh.js +5 -0
  133. package/dist/chunks/studio-x9hsze61.js +5 -0
  134. package/dist/chunks/studio-y0n7yxea.js +9 -0
  135. package/dist/chunks/studio-y3ahhdpx.js +5 -0
  136. package/dist/chunks/studio-z97c48fk.js +5 -0
  137. package/dist/chunks/studio-zat62m0c.js +5 -0
  138. package/dist/chunks/studio-zcd2e7yz.js +5 -0
  139. package/dist/chunks/studio-zz9qe3rw.js +64 -0
  140. package/dist/chunks/toast-1gv0h53h.js +4 -0
  141. package/dist/chunks/{toast-host-ke5z4ng7.js → toast-host-1yg5ar8d.js} +3 -3
  142. package/dist/chunks/{tooltip-5v8ngwj2.js → tooltip-yypz28gq.js} +3 -3
  143. package/dist/chunks/{tree-mdq3v5cw.js → tree-9xa4hm7n.js} +2 -2
  144. package/dist/chunks/tsMode-epyfz1hv.js +14 -0
  145. package/dist/chunks/workspace-dz7nxfhv.js +4 -0
  146. package/dist/chunks/workspace-home-xsd7hkjw.js +4 -0
  147. package/dist/chunks/{ws-client-nze0k6mv.js → ws-client-bv552sfx.js} +3 -3
  148. package/dist/iframe-entry.js +20 -16
  149. package/dist/manifest.json +77 -63
  150. package/dist/studio.js +103 -104
  151. package/dist/workers/ts.worker.js +3 -3
  152. package/package.json +12 -11
  153. package/src/browse/component-examples.ts +272 -0
  154. package/src/browse/library-commands.ts +64 -104
  155. package/src/browse/library-layouts.ts +263 -49
  156. package/src/browse/library-model.ts +181 -133
  157. package/src/browse/library-pane.ts +738 -446
  158. package/src/browse/library-preview.ts +149 -19
  159. package/src/browse/library-source.ts +308 -41
  160. package/src/browse/preview-root.ts +78 -0
  161. package/src/browse/preview-style.ts +155 -0
  162. package/src/canvas/asset-refs.ts +16 -1
  163. package/src/canvas/canvas-live-render.ts +222 -30
  164. package/src/canvas/canvas-origin.ts +37 -12
  165. package/src/canvas/canvas-page-context.ts +112 -0
  166. package/src/canvas/canvas-render.ts +113 -107
  167. package/src/canvas/canvas-utils.ts +57 -12
  168. package/src/canvas/iframe-drop.ts +107 -0
  169. package/src/canvas/iframe-entry.ts +24 -12
  170. package/src/canvas/iframe-host.ts +134 -62
  171. package/src/canvas/iframe-keys.ts +11 -0
  172. package/src/canvas/iframe-patch.ts +8 -7
  173. package/src/canvas/iframe-protocol.ts +24 -5
  174. package/src/canvas/iframe-render.ts +48 -1
  175. package/src/canvas/iframe-subtree.ts +5 -2
  176. package/src/canvas/npm-modules.ts +22 -0
  177. package/src/canvas/preview-navigate.ts +16 -0
  178. package/src/canvas/repeater-sources.ts +200 -0
  179. package/src/canvas/stage-scrollbar.ts +5 -1
  180. package/src/canvas/surface-registry.ts +6 -0
  181. package/src/commands/app-commands.ts +16 -6
  182. package/src/commands/budget.ts +10 -8
  183. package/src/commands/context.ts +35 -10
  184. package/src/commands/defaults.ts +69 -45
  185. package/src/commands/keymap.ts +9 -0
  186. package/src/commands/levels.ts +11 -5
  187. package/src/commands/live-context.ts +2 -0
  188. package/src/commands/registry.ts +10 -1
  189. package/src/content/collection-match.ts +6 -5
  190. package/src/content/collection-pages.ts +412 -0
  191. package/src/content/content-collections.ts +270 -0
  192. package/src/content/entry-commands.ts +51 -60
  193. package/src/content/entry-editor.ts +111 -18
  194. package/src/content/entry-fields.ts +13 -1
  195. package/src/content/entry-inspector.ts +225 -0
  196. package/src/content/entry-model.ts +17 -3
  197. package/src/content/entry-open.ts +80 -0
  198. package/src/content/entry-summaries.ts +440 -0
  199. package/src/content/file-record-ids.ts +80 -0
  200. package/src/content/file-records.ts +125 -0
  201. package/src/content/page-summaries.ts +129 -0
  202. package/src/content/record-entry.ts +201 -0
  203. package/src/content/writing-banner.ts +177 -0
  204. package/src/create/add-new-commands.ts +185 -0
  205. package/src/create/add-new-flow.ts +1116 -0
  206. package/src/create/add-new.ts +1014 -0
  207. package/src/create/element-name.ts +121 -0
  208. package/src/editor/convert-to-component.ts +67 -43
  209. package/src/editor/file-drop-action.ts +9 -1
  210. package/src/editor/inline-edit-apply.ts +44 -0
  211. package/src/editor/inline-edit.ts +10 -0
  212. package/src/editor/insert-component.ts +91 -0
  213. package/src/editor/insert-zone-action.ts +13 -4
  214. package/src/editor/shortcuts.ts +44 -22
  215. package/src/editor/slash-menu.ts +51 -8
  216. package/src/files/components.ts +74 -10
  217. package/src/files/file-ops.ts +15 -5
  218. package/src/files/files.ts +164 -150
  219. package/src/files/fs-events.ts +18 -7
  220. package/src/files/media-meta.ts +95 -1
  221. package/src/files/media-types.ts +55 -0
  222. package/src/files/media-upload.ts +209 -52
  223. package/src/files/new-file-name.ts +156 -0
  224. package/src/files/serialize-document.ts +13 -3
  225. package/src/format/format-host.ts +15 -0
  226. package/src/github/github-auth.ts +2 -2
  227. package/src/github/github-publish.ts +4 -3
  228. package/src/grid/grid-controller.ts +5 -1
  229. package/src/grid/grid-open.ts +0 -27
  230. package/src/grid/grid-panel.ts +54 -2
  231. package/src/grid/grid-reveal.ts +34 -0
  232. package/src/grid/grid-source.ts +3 -25
  233. package/src/grid/grid-view.ts +31 -6
  234. package/src/grid/sources/content-source.ts +75 -7
  235. package/src/grid/tabulator-tables.d.ts +6 -0
  236. package/src/hosting/document.ts +2 -2
  237. package/src/i18n/i18n-commands.ts +2 -1
  238. package/src/media/media-commands.ts +181 -0
  239. package/src/media/media-library-model.ts +232 -0
  240. package/src/media/media-library.ts +1283 -0
  241. package/src/media/media-pane.ts +47 -19
  242. package/src/packages/pull-package-sync.ts +1 -1
  243. package/src/panels/activity-panel.ts +21 -5
  244. package/src/panels/ai-chat/chat-markdown.ts +8 -8
  245. package/src/panels/block-action-bar.ts +11 -11
  246. package/src/panels/canvas-dnd-bridge.ts +5 -2
  247. package/src/panels/chat-panel.ts +6 -6
  248. package/src/panels/collections-panel.ts +306 -0
  249. package/src/panels/component-preview.ts +35 -13
  250. package/src/panels/data-explorer.ts +1 -1
  251. package/src/panels/data-grid.ts +4 -0
  252. package/src/panels/dnd.ts +17 -30
  253. package/src/panels/elements-panel.ts +9 -2
  254. package/src/panels/empty-state.ts +2 -2
  255. package/src/panels/formula-workspace.ts +2 -3
  256. package/src/panels/frontmatter-fields.ts +9 -9
  257. package/src/panels/git-diff-open.ts +9 -5
  258. package/src/panels/head-panel.ts +369 -103
  259. package/src/panels/i18n-panel.ts +11 -10
  260. package/src/panels/imports-panel.ts +2 -0
  261. package/src/panels/jump-bar.ts +27 -2
  262. package/src/panels/layers-panel.ts +36 -30
  263. package/src/panels/left-panel.ts +22 -8
  264. package/src/panels/navigator-panels.ts +23 -11
  265. package/src/panels/pane-context.ts +111 -29
  266. package/src/panels/pane-grid.ts +6 -6
  267. package/src/panels/panel-registry.ts +14 -9
  268. package/src/panels/properties-panel.ts +7 -3
  269. package/src/panels/right-panel.ts +199 -43
  270. package/src/panels/seo-modal.ts +41 -108
  271. package/src/panels/settings-menu.ts +52 -50
  272. package/src/panels/settings-pane.ts +268 -162
  273. package/src/panels/signals-panel.ts +3 -4
  274. package/src/panels/site-model.ts +367 -0
  275. package/src/panels/site-panel.ts +638 -0
  276. package/src/panels/style-panel.ts +37 -3
  277. package/src/panels/stylebook-doc.ts +142 -10
  278. package/src/panels/stylebook-layers-panel.ts +39 -80
  279. package/src/panels/stylebook-panel.ts +47 -10
  280. package/src/panels/styles-panel.ts +327 -0
  281. package/src/panels/tab-strip.ts +109 -25
  282. package/src/platform.ts +1 -1
  283. package/src/platforms/cloud.ts +28 -1
  284. package/src/platforms/default-platform.ts +4 -4
  285. package/src/platforms/devserver.ts +51 -25
  286. package/src/publish/deploy-checklist.ts +12 -7
  287. package/src/publish/pages-service.ts +38 -14
  288. package/src/publish/publish-changes.ts +491 -0
  289. package/src/publish/publish-commands.ts +83 -18
  290. package/src/publish/publish-ids.ts +49 -0
  291. package/src/publish/publish-quick.ts +148 -0
  292. package/src/publish/publish-workspace.ts +926 -0
  293. package/src/publish/source-control.ts +907 -0
  294. package/src/services/automation.ts +16 -20
  295. package/src/services/cf-settings.ts +4 -4
  296. package/src/services/connection.ts +2 -2
  297. package/src/services/directory-picker.ts +2 -2
  298. package/src/services/references.ts +0 -0
  299. package/src/services/render-critic.ts +21 -2
  300. package/src/services/settings/definitions.ts +25 -14
  301. package/src/settings/contributed-section.ts +49 -10
  302. package/src/settings/css-vars-editor.ts +93 -27
  303. package/src/settings/developer-panels.ts +43 -0
  304. package/src/settings/extension-sections.ts +20 -2
  305. package/src/settings/general-settings.ts +91 -21
  306. package/src/settings/preferences-dialog.ts +8 -1
  307. package/src/settings/project-sections.ts +27 -10
  308. package/src/settings/schema-field-ui.ts +3 -1
  309. package/src/settings/section-registry.ts +116 -11
  310. package/src/settings/settings-dialog.ts +192 -0
  311. package/src/settings/settings-document.ts +182 -162
  312. package/src/shell.ts +467 -431
  313. package/src/site-context.ts +64 -10
  314. package/src/state.ts +28 -9
  315. package/src/studio.ts +194 -41
  316. package/src/style/project-styles.ts +34 -0
  317. package/src/style/stylebook-specimens.ts +89 -0
  318. package/src/style/stylebook-target.ts +26 -0
  319. package/src/style/tag-inheritance.ts +105 -0
  320. package/src/style/variables-focus.ts +61 -0
  321. package/src/style/variables-view.ts +235 -0
  322. package/src/surfaces/add-new.json +1482 -0
  323. package/src/surfaces/add-new.ts +325 -0
  324. package/src/surfaces/ai-chat.ts +2 -2
  325. package/src/surfaces/boot-failure.json +4 -3
  326. package/src/surfaces/bottom-dock.json +1 -1
  327. package/src/surfaces/canvas-stage.json +30 -19
  328. package/src/surfaces/canvas-stage.ts +5 -5
  329. package/src/surfaces/collections-panel.json +615 -0
  330. package/src/surfaces/collections-panel.ts +168 -0
  331. package/src/surfaces/commandbar.json +241 -96
  332. package/src/surfaces/commandbar.ts +134 -99
  333. package/src/surfaces/empty-state.json +1 -1
  334. package/src/surfaces/entry-editor.json +136 -0
  335. package/src/surfaces/entry-editor.ts +21 -0
  336. package/src/surfaces/entry-inspector.json +371 -0
  337. package/src/surfaces/entry-inspector.ts +143 -0
  338. package/src/surfaces/inspector-dock.json +162 -14
  339. package/src/surfaces/inspector-dock.ts +46 -19
  340. package/src/surfaces/library-pane.json +670 -437
  341. package/src/surfaces/library-pane.ts +94 -59
  342. package/src/surfaces/media-browser.json +62 -6
  343. package/src/surfaces/media-browser.ts +15 -1
  344. package/src/surfaces/media-field.json +1 -1
  345. package/src/surfaces/media-library.json +1586 -0
  346. package/src/surfaces/media-library.ts +282 -0
  347. package/src/surfaces/media-pick-dialog.json +71 -0
  348. package/src/surfaces/media-pick-dialog.ts +132 -0
  349. package/src/surfaces/menu.ts +18 -0
  350. package/src/surfaces/pane-context.json +144 -77
  351. package/src/surfaces/pane-context.ts +24 -0
  352. package/src/surfaces/panel-deploy-checklist.json +12 -6
  353. package/src/surfaces/panel-deploy-checklist.ts +3 -1
  354. package/src/surfaces/panel-page.json +72 -2
  355. package/src/surfaces/panel-page.ts +38 -7
  356. package/src/surfaces/panel-signals.json +1 -1
  357. package/src/surfaces/panel-signals.ts +5 -5
  358. package/src/surfaces/panel-stylebook-layers.json +71 -204
  359. package/src/surfaces/panel-stylebook-layers.ts +0 -21
  360. package/src/surfaces/preferences.json +120 -48
  361. package/src/surfaces/preferences.ts +8 -0
  362. package/src/surfaces/publish-quick.json +428 -0
  363. package/src/surfaces/publish-quick.ts +165 -0
  364. package/src/surfaces/publish-workspace.json +2892 -0
  365. package/src/surfaces/publish-workspace.ts +391 -0
  366. package/src/surfaces/rail.json +1 -159
  367. package/src/surfaces/rail.ts +18 -75
  368. package/src/surfaces/schema-form.json +10 -2
  369. package/src/surfaces/schema-form.ts +2 -0
  370. package/src/surfaces/seo.json +1 -1
  371. package/src/surfaces/settings-contributed.json +5 -5
  372. package/src/surfaces/settings-contributed.ts +18 -2
  373. package/src/surfaces/settings-css-vars.json +44 -36
  374. package/src/surfaces/settings-css-vars.ts +77 -4
  375. package/src/surfaces/settings-deploy.json +2 -15
  376. package/src/surfaces/settings-deploy.ts +1 -1
  377. package/src/surfaces/settings-dialog.json +51 -0
  378. package/src/surfaces/settings-dialog.ts +169 -0
  379. package/src/surfaces/settings-overview.json +3 -3
  380. package/src/surfaces/settings-overview.ts +9 -2
  381. package/src/surfaces/settings-pane.json +269 -46
  382. package/src/surfaces/settings-pane.ts +85 -24
  383. package/src/surfaces/shell.json +2 -1
  384. package/src/surfaces/site-panel.json +1029 -0
  385. package/src/surfaces/site-panel.ts +233 -0
  386. package/src/surfaces/slash-menu.json +63 -21
  387. package/src/surfaces/slash-menu.ts +23 -0
  388. package/src/surfaces/statusbar.ts +39 -15
  389. package/src/surfaces/styles-panel.json +735 -0
  390. package/src/surfaces/styles-panel.ts +195 -0
  391. package/src/surfaces/styles-variables.json +149 -0
  392. package/src/surfaces/styles-variables.ts +145 -0
  393. package/src/surfaces/tab-strip.json +4 -4
  394. package/src/surfaces/welcome.ts +1 -1
  395. package/src/surfaces/writing-banner.json +94 -0
  396. package/src/surfaces/writing-banner.ts +80 -0
  397. package/src/tabs/bare-repeaters.ts +101 -0
  398. package/src/tabs/tab.ts +47 -7
  399. package/src/types.ts +21 -26
  400. package/src/ui/form-controls.ts +47 -8
  401. package/src/ui/layers.ts +13 -0
  402. package/src/ui/media-picker.ts +284 -40
  403. package/src/ui/regions.ts +7 -6
  404. package/src/ui/schema-form.ts +259 -27
  405. package/src/ui/virtual-window.ts +26 -1
  406. package/src/utils/base64.ts +3 -3
  407. package/src/utils/edit-display.ts +322 -67
  408. package/src/utils/local-day.ts +18 -0
  409. package/src/workspace/pane-derive.ts +4 -4
  410. package/src/workspace/session.ts +28 -7
  411. package/src/workspace/tab-workspace.ts +137 -0
  412. package/src/workspace/workspace-back.ts +189 -0
  413. package/src/workspace/workspace-home.ts +133 -0
  414. package/src/workspace/workspace-ids.ts +129 -0
  415. package/src/workspace/workspace-switch.ts +372 -0
  416. package/src/workspace/workspace.ts +125 -11
  417. package/styles/shell-frame.css +30 -7
  418. package/styles/shell-frame.json +15 -3
  419. package/dist/chunks/2020-f2gkpy8d.js +0 -4
  420. package/dist/chunks/adapter-4912g339.js +0 -4
  421. package/dist/chunks/cf-account-picker-wccaenh6.js +0 -4
  422. package/dist/chunks/cf-settings-br6105tr.js +0 -4
  423. package/dist/chunks/color-28ksk2qm.js +0 -4
  424. package/dist/chunks/components-db68vsn7.js +0 -4
  425. package/dist/chunks/content-source-1449qesq.js +0 -4
  426. package/dist/chunks/convert-to-repeater-5h457egj.js +0 -4
  427. package/dist/chunks/editor-x9jn86a7.js +0 -4
  428. package/dist/chunks/entry-commands-may24cpt.js +0 -4
  429. package/dist/chunks/extension-sections-pvr14vxr.js +0 -4
  430. package/dist/chunks/file-ops-x9v54pcj.js +0 -4
  431. package/dist/chunks/files-j3knqf0s.js +0 -4
  432. package/dist/chunks/format-host-tyre2trb.js +0 -4
  433. package/dist/chunks/fs-events-64ma9htc.js +0 -4
  434. package/dist/chunks/git-panel-84ps5dex.js +0 -4
  435. package/dist/chunks/iframe-entry-fvbk89gm.js +0 -5
  436. package/dist/chunks/iframe-host-ck6vejt5.js +0 -4
  437. package/dist/chunks/index-b8xw3vy9.js +0 -4
  438. package/dist/chunks/jsonMode-w15cmrcm.js +0 -13
  439. package/dist/chunks/jx-validate-at3zn8wa.js +0 -4
  440. package/dist/chunks/layers-h4xp1pss.js +0 -4
  441. package/dist/chunks/layers-panel-m5hw1d7g.js +0 -4
  442. package/dist/chunks/lit-html-8t8t3dnr.js +0 -4
  443. package/dist/chunks/media-picker-2cweexc5.js +0 -4
  444. package/dist/chunks/menu-ynw13y0s.js +0 -4
  445. package/dist/chunks/monaco-buffer-qzxn567r.js +0 -4
  446. package/dist/chunks/monaco-setup-gxf6656g.js +0 -4
  447. package/dist/chunks/notify-cj5zbrs2.js +0 -4
  448. package/dist/chunks/parse-b7ddhr8m.js +0 -4
  449. package/dist/chunks/platform-3dfws9js.js +0 -4
  450. package/dist/chunks/popover-jt2gxmzs.js +0 -4
  451. package/dist/chunks/publish-panel-1gvxbj21.js +0 -4
  452. package/dist/chunks/quick-search-0dajrwqg.js +0 -4
  453. package/dist/chunks/references-49qgt404.js +0 -4
  454. package/dist/chunks/right-panel-jm1bwe53.js +0 -4
  455. package/dist/chunks/section-registry-6kwc4fky.js +0 -4
  456. package/dist/chunks/studio-0rt52vpq.js +0 -5
  457. package/dist/chunks/studio-18vgbhs5.js +0 -5
  458. package/dist/chunks/studio-24mccdrj.js +0 -5
  459. package/dist/chunks/studio-2eh507zk.js +0 -9
  460. package/dist/chunks/studio-2hcbccfv.js +0 -5
  461. package/dist/chunks/studio-2jbs3rxv.js +0 -5
  462. package/dist/chunks/studio-4h8k4dw9.js +0 -5
  463. package/dist/chunks/studio-5f6n18kx.js +0 -5
  464. package/dist/chunks/studio-5gthpky6.js +0 -5
  465. package/dist/chunks/studio-6ep3js6b.js +0 -9
  466. package/dist/chunks/studio-6wkmf3wz.js +0 -9
  467. package/dist/chunks/studio-841rf3cg.js +0 -5
  468. package/dist/chunks/studio-8gmwgheg.js +0 -5
  469. package/dist/chunks/studio-8qm0ep50.js +0 -5
  470. package/dist/chunks/studio-924p1tm1.js +0 -6
  471. package/dist/chunks/studio-a3shpz9y.js +0 -5
  472. package/dist/chunks/studio-amsbaaar.js +0 -6
  473. package/dist/chunks/studio-at5spjbc.js +0 -7
  474. package/dist/chunks/studio-b2xv945e.js +0 -5
  475. package/dist/chunks/studio-bn5nkafw.js +0 -5
  476. package/dist/chunks/studio-bw6q5xjf.js +0 -9
  477. package/dist/chunks/studio-c7q0t9x1.js +0 -5
  478. package/dist/chunks/studio-camnhc96.js +0 -6
  479. package/dist/chunks/studio-cffqvnzd.js +0 -5
  480. package/dist/chunks/studio-efvfrsf8.js +0 -5
  481. package/dist/chunks/studio-er30bpcx.js +0 -5
  482. package/dist/chunks/studio-ezscgr64.js +0 -5
  483. package/dist/chunks/studio-ffrrncvz.js +0 -5
  484. package/dist/chunks/studio-fpphgn8y.js +0 -10
  485. package/dist/chunks/studio-j1kvhdjk.js +0 -4
  486. package/dist/chunks/studio-j430n16g.js +0 -7
  487. package/dist/chunks/studio-jjkg84nj.js +0 -5
  488. package/dist/chunks/studio-m0q32ars.js +0 -4
  489. package/dist/chunks/studio-m6bdst11.js +0 -5
  490. package/dist/chunks/studio-nv2cptd4.js +0 -64
  491. package/dist/chunks/studio-nwfrc98n.js +0 -5
  492. package/dist/chunks/studio-p1wgvp7r.js +0 -5
  493. package/dist/chunks/studio-pag2wncm.js +0 -5
  494. package/dist/chunks/studio-qvanvzfd.js +0 -5
  495. package/dist/chunks/studio-qwa64kt7.js +0 -5
  496. package/dist/chunks/studio-rk1zc4x3.js +0 -928
  497. package/dist/chunks/studio-se2r3ptc.js +0 -5
  498. package/dist/chunks/studio-sg2a0dh0.js +0 -5
  499. package/dist/chunks/studio-tjzjhe68.js +0 -5
  500. package/dist/chunks/studio-v2w7q8r1.js +0 -7
  501. package/dist/chunks/studio-v5vjq1h0.js +0 -4
  502. package/dist/chunks/studio-v8aga3vp.js +0 -14
  503. package/dist/chunks/studio-vfcdrfmv.js +0 -5
  504. package/dist/chunks/studio-vmfkgdjf.js +0 -5
  505. package/dist/chunks/studio-wt1816jj.js +0 -5
  506. package/dist/chunks/studio-wz73q5kq.js +0 -4
  507. package/dist/chunks/studio-y04qtxvp.js +0 -7
  508. package/dist/chunks/studio-y21g8zzg.js +0 -5
  509. package/dist/chunks/studio-y64hrt8p.js +0 -12
  510. package/dist/chunks/studio-ynn90f58.js +0 -16
  511. package/dist/chunks/studio-yxz682sx.js +0 -5
  512. package/dist/chunks/studio-zp7snvkq.js +0 -5
  513. package/dist/chunks/studio-zq4z6tm6.js +0 -5
  514. package/dist/chunks/toast-c9fn075p.js +0 -4
  515. package/dist/chunks/tsMode-sf49ee9x.js +0 -14
  516. package/dist/chunks/workspace-jtfahpee.js +0 -4
  517. package/src/panels/frontmatter-panel.ts +0 -711
  518. package/src/panels/git-panel.ts +0 -1108
  519. package/src/surfaces/doc-header.json +0 -776
  520. package/src/surfaces/doc-header.ts +0 -222
  521. package/src/surfaces/git-panel.json +0 -1880
  522. package/src/surfaces/git-panel.ts +0 -264
@@ -1,1108 +0,0 @@
1
- /// <reference lib="dom" />
2
- /**
3
- * Source Control — the Navigator panel: sync status, the branch, Local Changes and History.
4
- *
5
- * **The body is a Jx document** (`surfaces/git-panel.json`, mounted by `surfaces/git-panel.ts`), so
6
- * this module draws no markup: it projects. What stays here is everything that is a DECISION — what
7
- * git is asked and in what order, what a comparison is and which file has one, how changed files
8
- * group into components, what a status letter reads aloud, what a commit does before it runs, and
9
- * which of the four moods the panel is in. The surface reads values.
10
- *
11
- * Three consequences worth knowing before editing it.
12
- *
13
- * The first is that the panel keeps ITSELF up to date. A lit body was redrawn because the Navigator
14
- * repainted, and the Navigator repainted on this panel's own badge — a coincidence that happened to
15
- * cover most changes to `shell.git`. {@link mountGitPanel} owns an `effect()` instead, so a
16
- * finished fetch, a typed commit message and a poll that noticed a change made outside Studio each
17
- * reach the document whether or not anything else on screen moved. `renderOnly("leftPanel")` is
18
- * gone with it.
19
- *
20
- * The second is that the split button's dropdown is the KIT MENU. It was a hand-built `<div>` with
21
- * a module-level `_splitMenuOpen` flag, and the flag existed only because the template declared the
22
- * menu `hidden` unconditionally and the two were fighting. `openMenu()` already owns roving focus,
23
- * light dismissal and Escape, so both the markup and the flag go.
24
- *
25
- * The third is the empty states. A document cannot call a lit helper, so the three this panel used
26
- * to render are drawn in the document — under the same studio-ui-guidelines.md §11 copy rules, and,
27
- * for the two that offer buttons, with the buttons still real. This was the last caller that passed
28
- * `EmptyStateAction.icon`, a `TemplateResult` of `sp-icon-*`, and the field went with it.
29
- *
30
- * @docs studio/publish/source-control
31
- */
32
-
33
- import { nothing } from "lit-html";
34
- import { errorMessage } from "@jxsuite/schema/parse";
35
- import { effect, effectScope } from "../reactivity";
36
- import { flushAllCollab } from "../collab/collab-session";
37
- import type { GitDiffState, GitFileStatus, StudioPlatform } from "../types";
38
- import { getPlatform, hasPlatform } from "../platform";
39
- import { now } from "../services/clock";
40
- import { formatForPath } from "../format/format-host";
41
- import { projectState } from "../store";
42
- import { comparisonRefusal, openComparisonTab } from "./git-diff-open";
43
- import type { Tab } from "../tabs/tab";
44
- import { shell } from "../shell";
45
- import type { GitLogEntry } from "../shell";
46
- import { showConfirmDialog, showPromptDialog } from "../ui/layers";
47
- import { POLL_GIT } from "../ui/timing";
48
- import { registerPanel } from "./panel-registry";
49
- import { notify } from "../services/notify";
50
- import { authenticateGithub } from "../github/github-auth";
51
- import { createGithubRepository } from "../github/github-publish";
52
- import { pullWithPackageSync } from "../packages/pull-package-sync";
53
- import { mountGitPanelSurface } from "../surfaces/git-panel";
54
- import { rectOf } from "../utils/geometry";
55
- import type {
56
- GitCommitView,
57
- GitFileRowView,
58
- GitGroupView,
59
- GitPanelActions,
60
- GitPanelSurfaceHandle,
61
- GitPanelValues,
62
- } from "../surfaces/git-panel";
63
- import type { AnyCommand, CommandRegistry } from "../commands/registry";
64
- import type { EffectScope } from "../reactivity";
65
- import type { PanelBody } from "./panel-registry";
66
-
67
- export async function refreshGitStatus() {
68
- if (!projectState) {
69
- return;
70
- }
71
- const plat = getPlatform();
72
- const { git } = shell;
73
- git.loading = true;
74
- git.error = null;
75
- try {
76
- // Settled independently, not Promise.all: outside a work tree `git branch` exits non-zero
77
- // While `git status` answers cleanly with isRepo:false. Letting the branch lookup reject the
78
- // Pair discarded that status, so the panel re-rendered its "no status yet" branch, refreshed
79
- // Again, and span — a request per render for as long as the tab stayed open.
80
- const [status, branches] = await Promise.allSettled([plat.gitStatus(), plat.gitBranches()]);
81
- if (status.status === "fulfilled") {
82
- git.status = status.value;
83
- }
84
- if (branches.status === "fulfilled") {
85
- git.branches = branches.value;
86
- }
87
- // A branch lookup that fails on a repo-less project is expected, not an error worth showing;
88
- // Anything else (including a failed status) surfaces.
89
- const failure: unknown =
90
- status.status === "rejected"
91
- ? status.reason
92
- : branches.status === "rejected" && status.value.isRepo
93
- ? branches.reason
94
- : null;
95
- if (failure) {
96
- git.error = errorMessage(failure);
97
- }
98
- git.lastUpdated = now();
99
- /* THE COMPARISON FOLLOWS THE TREE. Every git verb that can move the working tree ends here —
100
- commit, discard, checkout, pull, fetch — and so does the 30s poll that notices a change made
101
- outside Studio. Bumping the revision is what re-issues a Diff lens's read; the panel's own
102
- slot is re-read below, because nothing else owns it. */
103
- git.rev += 1;
104
- await rereadOpenComparison();
105
- } catch (error) {
106
- git.error = errorMessage(error);
107
- } finally {
108
- git.loading = false;
109
- }
110
- }
111
-
112
- /**
113
- * Re-read the comparison the Source Control panel has open, against the status just fetched.
114
- *
115
- * A file that is no longer changed loses its comparison rather than keeping a stale one: the stage
116
- * then draws "Nothing to compare", which is the truth and is what the author's own commit just made
117
- * true. A read that fails leaves the previous comparison up — a momentary git error is not a reason
118
- * to blank a review someone is in the middle of.
119
- */
120
- async function rereadOpenComparison(): Promise<void> {
121
- const state = shell.git.diffState;
122
- if (!state) {
123
- return;
124
- }
125
- const change = shell.git.status?.files.find((file) => file.path === state.filePath);
126
- if (!change || !isDiffableStatus(change.status)) {
127
- shell.git.diffState = null;
128
- return;
129
- }
130
- try {
131
- shell.git.diffState = await readGitDiff(state.filePath, change.status);
132
- } catch {
133
- // Intentionally ignored: the comparison on screen is still the last one that read cleanly.
134
- }
135
- }
136
-
137
- /**
138
- * Re-read an open comparison because THIS file was just saved.
139
- *
140
- * Separate from the git-status path, and deliberately: a save does not refresh `git.status`, so the
141
- * entry there may not exist yet for a file whose first edit this is. The status the comparison was
142
- * opened with is the right one to re-read against — the file has not changed its relationship to
143
- * HEAD by being written, only its contents.
144
- *
145
- * @param {string | null} path - The project-relative path just written.
146
- */
147
- export async function noteFileSaved(path: string | null): Promise<void> {
148
- shell.git.rev += 1;
149
- const state = shell.git.diffState;
150
- if (!path || state?.filePath !== path) {
151
- return;
152
- }
153
- try {
154
- shell.git.diffState = await readGitDiff(path, state.fileStatus);
155
- } catch {
156
- // Intentionally ignored: see rereadOpenComparison.
157
- }
158
- }
159
-
160
- /**
161
- * Show a dialog to clone a git repository. Returns the cloned project root on success, or null.
162
- *
163
- * @param {{ openRecentProject: (root: string) => Promise<void> }} ctx
164
- */
165
- export async function cloneRepository(ctx: { openRecentProject: (root: string) => Promise<void> }) {
166
- const platform = getPlatform();
167
- if (!platform.gitClone) {
168
- notify.warn("Cloning is not supported on this platform.", { source: "Source Control" });
169
- return;
170
- }
171
-
172
- const url = await showPromptDialog("Clone Git Repository", {
173
- confirmLabel: "Clone",
174
- message: "Repository URL",
175
- placeholder: "https://github.com/user/repo.git",
176
- validate: (v) => (v.trim() ? "" : "Enter a repository URL."),
177
- });
178
-
179
- if (!url) {
180
- return;
181
- }
182
-
183
- try {
184
- notify.info("Cloning repository…", { key: "git.clone", source: "Source Control" });
185
- const result = await platform.gitClone(url);
186
- if (result.root) {
187
- notify.success("Clone complete.", { key: "git.clone" });
188
- await ctx.openRecentProject(result.root);
189
- }
190
- } catch (error) {
191
- notify.error("Could not clone the repository.", {
192
- detail: errorMessage(error),
193
- key: "git.clone",
194
- source: "Source Control",
195
- });
196
- }
197
- }
198
-
199
- /**
200
- * Whether this platform can clone at all.
201
- *
202
- * `hasPlatform()` first, because the question is asked on every projection of the panel and
203
- * `getPlatform()` THROWS when nothing has registered one. "There is no platform" is an answer to
204
- * this question — no, it cannot clone — rather than a failure, and a projection that threw would
205
- * take the whole Navigator's render down with it.
206
- */
207
- export function platformSupportsClone(): boolean {
208
- return hasPlatform() && Boolean(getPlatform().gitClone);
209
- }
210
-
211
- /**
212
- * One file's comparison against HEAD: the committed text and the working copy.
213
- *
214
- * **One definition site, because there are now two callers.** This panel's row click has always
215
- * made this pair of reads; `workspace/pane-derive.ts`'s Diff lens needs the same answer for the
216
- * document its source pane is showing, and it must not reach `shell.git.diffState` — that slot
217
- * holds whatever THIS panel last opened, which is a different file (§18.4, finding 4). A second
218
- * copy of these five lines is how the panel and the lens would come to disagree about what "the
219
- * diff of this file" means, which is the rule {@link initRepository} is written under too.
220
- *
221
- * **Each side is read only where it exists**, and every status is one of the four combinations:
222
- *
223
- * - `M` (modified) — both sides read.
224
- * - `A` (added) and `U` (untracked) — no `HEAD` copy, so the original is the empty string rather than
225
- * a `gitShow` that would throw. The two differ only in whether the new file has been staged,
226
- * which is not a fact a comparison cares about.
227
- * - `D` (deleted) — the mirror, and the one this function used to be unable to express: there is no
228
- * working copy, so `readFile` would throw on a path that is gone, and the current side is empty.
229
- *
230
- * `gitChangeFor`'s docstring used to give "an untracked or deleted file has no pair of texts to put
231
- * side by side" as the REASON for narrowing to `M`/`A`. It was never true: one side is the empty
232
- * string, which is exactly what `A` had always done.
233
- *
234
- * @param {string} path
235
- * @param {string} fileStatus
236
- * @returns {Promise<GitDiffState>}
237
- */
238
- /** How each status reads aloud. The badge is one letter and a colour, which a label cannot be. */
239
- const STATUS_WORDS = new Map([
240
- ["A", "added"],
241
- ["D", "deleted"],
242
- ["M", "modified"],
243
- ["R", "renamed"],
244
- ["U", "untracked"],
245
- ]);
246
-
247
- /** The statuses a comparison can be built for. `R` is absent — see {@link DIFFABLE_STATUSES}. */
248
- export const DIFFABLE_STATUSES = new Set(["M", "A", "U", "D"]);
249
-
250
- /**
251
- * Whether this file's change can be opened as a comparison at all.
252
- *
253
- * `R` (renamed) is the one that cannot: `GitFileStatus` carries a single `path`, so the old name is
254
- * not in hand and there is nothing to compare the new one against. Better refused by name than
255
- * shown as a whole-file rewrite.
256
- */
257
- export function isDiffableStatus(fileStatus: string): boolean {
258
- return DIFFABLE_STATUSES.has(fileStatus);
259
- }
260
-
261
- export async function readGitDiff(path: string, fileStatus: string): Promise<GitDiffState> {
262
- const plat = getPlatform();
263
- const inHead = fileStatus !== "A" && fileStatus !== "U";
264
- const onDisk = fileStatus !== "D";
265
- const [originalContent, currentContent] = await Promise.all([
266
- inHead ? plat.gitShow({ path, ref: "HEAD" }) : Promise.resolve(""),
267
- onDisk ? plat.readFile(path) : Promise.resolve(""),
268
- ]);
269
- return { currentContent, filePath: path, fileStatus, originalContent };
270
- }
271
-
272
- /**
273
- * The Diff lens's reader: {@link readGitDiff}, with a failure the PANE can state.
274
- *
275
- * A rejection here is not an error the shell should raise — the author asked to see a comparison
276
- * beside their page, and "could not read it" is a sentence the derived pane draws in its own empty
277
- * state. `applyDerivation` turns the `null` into exactly that.
278
- *
279
- * @param {string} path
280
- * @param {string} fileStatus
281
- * @returns {Promise<GitDiffState | null>}
282
- */
283
- export async function loadDiffForLens(
284
- path: string,
285
- fileStatus: string,
286
- ): Promise<GitDiffState | null> {
287
- try {
288
- return await readGitDiff(path, fileStatus);
289
- } catch (error) {
290
- // Reported where it can be acted on — the pane says so — rather than as a toast over a
291
- // Document the author did not ask about.
292
- console.warn("loadDiffForLens:", errorMessage(error));
293
- return null;
294
- }
295
- }
296
-
297
- /**
298
- * Start tracking this project with git.
299
- *
300
- * A function rather than an inline click handler because it is now also a command ({@link
301
- * sourceControlCommands}) and the first step of the deploy checklist, and three call sites of the
302
- * same three lines is how the panel and the palette come to disagree about what a verb does.
303
- */
304
- export async function initRepository(): Promise<void> {
305
- try {
306
- notify.info("Initializing repository…", { key: "git.init" });
307
- await getPlatform().gitInit();
308
- notify.success("Repository initialized.", { key: "git.init" });
309
- } catch (error) {
310
- notify.error("Could not initialize the repository.", {
311
- action: "git.init",
312
- detail: errorMessage(error),
313
- key: "git.init",
314
- source: "Source Control",
315
- });
316
- return;
317
- }
318
- await refreshGitStatus();
319
- }
320
-
321
- /** Push the current branch. Same loading/error contract as every other panel verb. */
322
- export async function pushCurrentBranch(): Promise<void> {
323
- await gitAction((plat) => plat.gitPush());
324
- }
325
-
326
- /**
327
- * Sign in to GitHub, or report why it could not.
328
- *
329
- * The report belongs to `github/github-auth.ts` — this only says what a SUCCESS was, which that
330
- * module cannot, because it is also called mid-flow by "Create GitHub Repository" where a toast
331
- * saying "Signed in" in front of a half-finished operation would be noise.
332
- */
333
- export async function signInToGithub(): Promise<void> {
334
- const token = await authenticateGithub();
335
- if (token) {
336
- notify.success("Signed in to GitHub.", { key: "github.auth" });
337
- }
338
- }
339
-
340
- /**
341
- * Run one platform git verb under the panel's loading/error contract.
342
- *
343
- * @param run Calls the verb on the platform it is handed.
344
- * @returns Whether the action succeeded — its failure is already on screen.
345
- */
346
- async function gitAction(run: (plat: StudioPlatform) => Promise<void>): Promise<boolean> {
347
- const plat = getPlatform();
348
- shell.git.loading = true;
349
- shell.git.error = null;
350
- try {
351
- await run(plat);
352
- await refreshGitStatus();
353
- return true;
354
- } catch (error) {
355
- shell.git.error = errorMessage(error);
356
- shell.git.loading = false;
357
- return false;
358
- }
359
- }
360
-
361
- /**
362
- * Put a message back in the field after the commit that took it failed — unless the user has
363
- * already started typing another. The field is cleared before the call so a second click cannot
364
- * commit the same text twice, which used to mean a refused commit (a conflict, a backend that asks
365
- * for an action first) silently threw the message away with it.
366
- */
367
- function restoreCommitMessage(message: string): void {
368
- if (!shell.git.commitMessage) {
369
- shell.git.commitMessage = message;
370
- }
371
- }
372
-
373
- /** Pull via the package-aware orchestrator; same loading/error contract as gitAction. */
374
- async function doPull() {
375
- shell.git.loading = true;
376
- shell.git.error = null;
377
- try {
378
- await pullWithPackageSync();
379
- await refreshGitStatus();
380
- } catch (error) {
381
- shell.git.error = errorMessage(error);
382
- shell.git.loading = false;
383
- }
384
- }
385
-
386
- /**
387
- * The background refresh handle. The interval itself is infrastructure, not state — the sub-tab and
388
- * the "last updated" stamp it used to sit beside are on `shell.git`, so opening a second project no
389
- * longer inherits the first one's History selection and timestamp.
390
- */
391
- let _pollTimer: ReturnType<typeof setInterval> | null = null;
392
-
393
- async function fetchGitLog() {
394
- const plat = getPlatform();
395
- try {
396
- shell.git.logEntries = await plat.gitLog(30);
397
- } catch (error) {
398
- shell.git.error = errorMessage(error);
399
- }
400
- }
401
-
402
- /**
403
- * What the panel is drawn against, and the two writes a row click makes outside `shell.git`.
404
- *
405
- * A subset of `NavigatorPanelDeps`, named here so the projection and the actions state what they
406
- * use rather than taking the Navigator's whole injection list.
407
- */
408
- export interface GitPanelDeps {
409
- setCanvasMode?: (tab: Tab | null, mode: string) => void;
410
- setGitDiffState?: (state: GitDiffState | null) => void;
411
- cloneRepository?: () => void;
412
- }
413
-
414
- /**
415
- * What the panel was mounted with, held at module scope rather than closed over.
416
- *
417
- * The standing surface outlives the repaint that mounted it — a row clicked ten repaints later must
418
- * reach the CURRENT diff-state setter — so the seat is rewritten on every `afterRender` and the
419
- * actions read it (`panels/elements-panel.ts` states the rule at its definition site).
420
- */
421
- let _deps: GitPanelDeps = {};
422
-
423
- /**
424
- * What the branch picker is showing, when that is not the branch that is checked out.
425
- *
426
- * A `<select>` always holds one of its options, and picking "New branch…" must put the control back
427
- * on the current branch when the dialog is dismissed. A document's binding only writes when the
428
- * SCOPE MOVES (studio-ui-guidelines.md §9.3), so writing the current branch over a scope that
429
- * already said it would be a no-op and the control would keep saying "New branch…". Announcing what
430
- * the reader actually chose first is what makes putting it back a change.
431
- */
432
- let _branchOverride: string | null = null;
433
-
434
- /**
435
- * One changed file, as the document draws it.
436
- *
437
- * The path is split HERE rather than in the surface, because "the name and the folder it is in" is
438
- * a decision about paths and the document only lays out two spans. The label is the same fact said
439
- * aloud: the badge beside it is one letter and a colour, which a screen reader cannot read.
440
- */
441
- function fileRowView(file: GitFileStatus): GitFileRowView {
442
- const parts = file.path.split("/");
443
- const name = parts.pop() ?? file.path;
444
- const dir = parts.join("/");
445
- return {
446
- cannotDiscard: file.status === "U",
447
- dir,
448
- hasDir: dir !== "",
449
- key: file.path,
450
- label: `${file.path}, ${STATUS_WORDS.get(file.status) ?? "changed"}`,
451
- name,
452
- path: file.path,
453
- staged: Boolean(file.staged),
454
- status: file.status,
455
- };
456
- }
457
-
458
- /**
459
- * Group files by component — the parent directory for anything the app can render, "Other" for the
460
- * rest.
461
- */
462
- function groupFilesByComponent(files: GitFileStatus[]): GitGroupView[] {
463
- const groups = new Map<string, GitFileStatus[]>();
464
- for (const f of files) {
465
- const parts = f.path.split("/");
466
- let component;
467
- if (f.path.endsWith(".json") || f.path.endsWith(".class.json") || formatForPath(f.path)) {
468
- component = parts.length > 1 ? `/${parts.at(-2)}` : `/${parts[0]}`;
469
- } else {
470
- component = "Other";
471
- }
472
- let group = groups.get(component);
473
- if (!group) {
474
- group = [];
475
- groups.set(component, group);
476
- }
477
- group.push(f);
478
- }
479
- return [...groups.entries()].map(([name, entries]) => ({
480
- files: entries.map((entry) => fileRowView(entry)),
481
- key: name,
482
- name,
483
- }));
484
- }
485
-
486
- /** One commit, as the log draws it. The clock is read here, which is why {@link relativeDate} is. */
487
- function commitView(entry: GitLogEntry): GitCommitView {
488
- return {
489
- hash: entry.hash.slice(0, 7),
490
- key: entry.hash,
491
- message: entry.message,
492
- meta: `${entry.author} · ${relativeDate(entry.date)}`,
493
- };
494
- }
495
-
496
- /** The moment of the last successful refresh, as the sync bar prints it. */
497
- function lastUpdatedLabel(stamp: number | null): string {
498
- return stamp
499
- ? `Last updated ${new Date(stamp).toLocaleTimeString([], {
500
- hour: "2-digit",
501
- minute: "2-digit",
502
- })}`
503
- : "";
504
- }
505
-
506
- /**
507
- * Which of the four moods the panel is in.
508
- *
509
- * Exactly the four branches the lit template took, in the order it took them — and the second is
510
- * the one with a side effect somewhere else: `loading` means nothing has been read yet, and
511
- * {@link mountGitPanel} is what starts the read. A refresh that already FAILED must not land here,
512
- * or the render it triggers becomes the next render's reason to fetch again.
513
- */
514
- function panelView(): GitPanelValues["view"] {
515
- if (!projectState) {
516
- return "no-project";
517
- }
518
- const { error, loading, status } = shell.git;
519
- if (!status && !loading && !error) {
520
- return "loading";
521
- }
522
- return status && !status.isRepo ? "no-repo" : "repo";
523
- }
524
-
525
- /**
526
- * What the surface should be showing right now.
527
- *
528
- * Exported because it is the whole of this module that is worth testing on its own: a pure function
529
- * of `projectState`, the hoisted `shell.git` record and the platform's capabilities. Read inside
530
- * {@link mountGitPanel}'s effect, so every reactive read it makes is a reason for the document to be
531
- * brought up to date.
532
- */
533
- export function gitPanelValues(): GitPanelValues {
534
- const { branches, commitMessage, error, lastUpdated, loading, logEntries, status, subTab } =
535
- shell.git;
536
- const files = status?.files ?? [];
537
- const staged = files.filter((f: GitFileStatus) => f.staged);
538
- const unstaged = files.filter((f: GitFileStatus) => !f.staged);
539
- const all = [...staged, ...unstaged];
540
- const upToDate = !status?.ahead && !status?.behind;
541
- const ahead = status?.ahead ? `${status.ahead} ahead` : "";
542
- const behind = status?.behind ? `${status.behind} behind` : "";
543
- const commits = logEntries ?? [];
544
- const current = branches?.current ?? status?.branch ?? "";
545
- return {
546
- branchName: current || "—",
547
- branchOptions: [
548
- ...(branches?.branches ?? []).map((branch: string) => ({ label: branch, value: branch })),
549
- { label: "+ New branch…", value: NEW_BRANCH },
550
- ],
551
- branchValue: _branchOverride ?? branches?.current ?? "",
552
- busy: Boolean(loading),
553
- canClone: platformSupportsClone(),
554
- changedCount: String(all.length),
555
- changesLabel: all.length > 0 ? `Local Changes (${all.length})` : "Local Changes",
556
- commitMessage,
557
- commits: commits.map((entry: GitLogEntry) => commitView(entry)),
558
- error: error ?? "",
559
- filesState: all.length > 0 ? "listed" : "empty",
560
- groups: groupFilesByComponent(all),
561
- hasError: Boolean(error),
562
- hasLastUpdated: Boolean(lastUpdated),
563
- hasStaged: staged.length > 0,
564
- hasUnstaged: unstaged.length > 0,
565
- historyState: commits.length > 0 ? "listed" : "empty",
566
- lastUpdated: lastUpdatedLabel(lastUpdated),
567
- pullLabel: behind ? `Pull (${behind})` : "Pull",
568
- pushLabel: ahead ? `Push (${ahead})` : "Push",
569
- // A host may omit `remotes` despite the declared type (see deploy-checklist.ts), so its
570
- // Presence is checked rather than assumed.
571
- remoteState: Array.isArray(status?.remotes) && status.remotes.length > 0 ? "remote" : "local",
572
- stagedCount: String(staged.length),
573
- stagedFiles: staged.map((file: GitFileStatus) => fileRowView(file)),
574
- subTab,
575
- syncLabel: upToDate ? "Up to date" : `${ahead}${ahead && behind ? ", " : ""}${behind}`,
576
- view: panelView(),
577
- };
578
- }
579
-
580
- /** The picker row that means "make a new branch" rather than "check this one out". */
581
- const NEW_BRANCH = "__new__";
582
-
583
- /** The changed file at this path, as the last status read saw it. */
584
- function fileAt(path: string): GitFileStatus | undefined {
585
- return shell.git.status?.files.find((file: GitFileStatus) => file.path === path);
586
- }
587
-
588
- /** Commit the message the field holds, if it holds one. Never a commit of nothing. */
589
- async function doCommit(): Promise<void> {
590
- const message = shell.git.commitMessage.trim();
591
- if (!message) {
592
- return;
593
- }
594
- shell.git.commitMessage = "";
595
- // Fold co-editing sessions into the backend's tree first so the commit never misses trailing
596
- // Keystrokes (the mirror is debounced).
597
- await flushAllCollab();
598
- if (!(await gitAction((plat) => plat.gitCommit(message)))) {
599
- restoreCommitMessage(message);
600
- }
601
- }
602
-
603
- /** Commit and push, as one operation with one loading state and one error. */
604
- async function doCommitAndSync(): Promise<void> {
605
- const message = shell.git.commitMessage.trim();
606
- if (!message) {
607
- return;
608
- }
609
- shell.git.commitMessage = "";
610
- shell.git.loading = true;
611
- shell.git.error = null;
612
- await flushAllCollab();
613
- const plat = getPlatform();
614
- let committed = false;
615
- try {
616
- await plat.gitCommit(message);
617
- committed = true;
618
- await plat.gitPush();
619
- await refreshGitStatus();
620
- } catch (error) {
621
- shell.git.error = errorMessage(error);
622
- shell.git.loading = false;
623
- // A push that failed after the commit landed must not offer the same message again.
624
- if (!committed) {
625
- restoreCommitMessage(message);
626
- }
627
- }
628
- }
629
-
630
- /**
631
- * Check a branch out, or mint one.
632
- *
633
- * The override is what puts the control back: see {@link _branchOverride}.
634
- */
635
- async function chooseBranch(value: string): Promise<void> {
636
- const { branches, status } = shell.git;
637
- if (value === NEW_BRANCH) {
638
- _branchOverride = NEW_BRANCH;
639
- syncGitPanel();
640
- const name = await showPromptDialog("New Branch", {
641
- confirmLabel: "Create",
642
- message: `Branching from ${branches?.current || status?.branch || "the current branch"}.`,
643
- placeholder: "feature/my-change",
644
- validate: (v) => (v.trim() ? "" : "Enter a branch name."),
645
- });
646
- _branchOverride = null;
647
- syncGitPanel();
648
- if (name) {
649
- await gitAction((plat) => plat.gitCreateBranch(name));
650
- }
651
- return;
652
- }
653
- if (value !== branches?.current) {
654
- await gitAction((plat) => plat.gitCheckout(value));
655
- }
656
- }
657
-
658
- /**
659
- * Open one changed file's comparison.
660
- *
661
- * EVERY changed row opens something, and it opens the file it names. Two silent returns used to
662
- * live here, and between them they made most of this panel inert: a status that was not `M`/`A`
663
- * returned, and then a path that was not `.json` and had no format class returned again. So a
664
- * changed `.ts`, `.css` or `.yaml` row did nothing at all when clicked, and neither did any deleted
665
- * or untracked file. Renderability now decides which VIEW opens, not whether the row responds; only
666
- * `R` is refused, and it is refused out loud.
667
- *
668
- * **And it opens the file's OWN tab.** This used to end in `setCanvasMode(activeTab.value,
669
- * "git-diff")` — the focused tab, whatever it was. Clicking `components/card.json` while
670
- * `pages/index.md` was open flipped the index.md TAB into git-diff and drew card.json's comparison
671
- * on it: the strip named one file and the stage drew another, which is the §14.1 identity defect
672
- * this repository has paid off three times elsewhere.
673
- */
674
- async function openFileComparison(path: string): Promise<void> {
675
- const file = fileAt(path);
676
- if (!file) {
677
- return;
678
- }
679
- const refusal = isDiffableStatus(file.status)
680
- ? comparisonRefusal(file.path, file.status)
681
- : `"${file.path}" has no change this view can open.`;
682
- if (refusal) {
683
- shell.git.error = refusal;
684
- return;
685
- }
686
- try {
687
- shell.git.loading = true;
688
- const diffState = await readGitDiff(file.path, file.status);
689
- shell.git.diffState = diffState;
690
- /* The tab this comparison belongs to. A renderable document opens (or re-activates) the
691
- ordinary path-keyed tab it would have had anyway; anything else gets a stub tab keyed by the
692
- same path, the way a media file does. Either way the id is the path, so the strip and the
693
- stage agree. */
694
- const tab = await openComparisonTab(file.path);
695
- _deps.setGitDiffState?.(diffState);
696
- if (tab) {
697
- _deps.setCanvasMode?.(tab, "git-diff");
698
- }
699
- } catch (error) {
700
- shell.git.error = `Failed to load diff: ${errorMessage(error)}`;
701
- } finally {
702
- shell.git.loading = false;
703
- }
704
- }
705
-
706
- /**
707
- * Discard one file's changes, once the reader has said so. An untracked file has nothing to go back
708
- * to.
709
- */
710
- async function discardFile(path: string): Promise<void> {
711
- if (fileAt(path)?.status === "U") {
712
- return;
713
- }
714
- const confirmed = await showConfirmDialog("Discard Changes", `Discard changes to ${path}?`, {
715
- confirmLabel: "Discard",
716
- destructive: true,
717
- });
718
- if (!confirmed) {
719
- return;
720
- }
721
- await gitAction((plat) => plat.gitDiscard([path]));
722
- }
723
-
724
- /**
725
- * The split button's second half.
726
- *
727
- * The kit menu, not a `<div>` of this panel's own: `openMenu()` owns the popover, the roving focus,
728
- * the light dismissal and Escape, and it is the answer this shell already settled on
729
- * (studio-ui-guidelines.md §8.4). One row, because there is one thing "Commit and sync" can do
730
- * differently.
731
- */
732
- function openCommitMenu(anchor: HTMLElement): void {
733
- /* Lazily imported for the reason `panels/problems-panel.ts` and `panels/empty-state.ts` already
734
- are: this module is on the static import path of the command registry, the rail and the Start
735
- pane, and a static edge would drag the whole overlay layer stack into each of them for a
736
- dropdown that only exists once somebody clicks it. */
737
- void import("../surfaces/menu.js").then(({ openMenu }) => {
738
- openMenu({
739
- label: "Commit options",
740
- opener: anchor,
741
- place: (box) => {
742
- const rect = rectOf(anchor);
743
- return { x: Math.max(4, rect.right - box.width), y: rect.bottom + 4 };
744
- },
745
- region: "git-commit",
746
- rows: [
747
- {
748
- destructive: false,
749
- disabled: false,
750
- dividerAbove: false,
751
- id: "git.commitWithoutSync",
752
- run: () => {
753
- void doCommit();
754
- },
755
- title: "Commit (don't sync)",
756
- },
757
- ],
758
- });
759
- });
760
- }
761
-
762
- /** Move to the other sub-tab, fetching the log the first time History is asked for. */
763
- function selectTab(tab: string): void {
764
- shell.git.subTab = tab;
765
- if (tab === "history" && !shell.git.logEntries) {
766
- void fetchGitLog();
767
- }
768
- }
769
-
770
- /**
771
- * Everything a control can ask for, defined once.
772
- *
773
- * Every entry is a decision this module owns; the document only names it, and hands back the one
774
- * value it has — a path, a branch, the field's text.
775
- */
776
- const ACTIONS: GitPanelActions = {
777
- chooseBranch: (value) => {
778
- void chooseBranch(value);
779
- },
780
- clone: () => {
781
- _deps.cloneRepository?.();
782
- },
783
- commit: () => {
784
- void doCommit();
785
- },
786
- commitAndSync: () => {
787
- void doCommitAndSync();
788
- },
789
- createRepository: () => {
790
- void createGithubRepository({ projectName: projectState?.name || "my-project" });
791
- },
792
- discard: (path) => {
793
- void discardFile(path);
794
- },
795
- editMessage: (value) => {
796
- shell.git.commitMessage = value;
797
- },
798
- fetch: () => {
799
- void gitAction((plat) => plat.gitFetch());
800
- },
801
- initRepository: () => {
802
- void initRepository();
803
- },
804
- openCommitMenu,
805
- openFile: (path) => {
806
- void openFileComparison(path);
807
- },
808
- pull: () => {
809
- void doPull();
810
- },
811
- push: () => {
812
- void gitAction((plat) => plat.gitPush());
813
- },
814
- refresh: () => {
815
- void refreshGitStatus();
816
- },
817
- selectTab,
818
- stage: (path) => {
819
- void gitAction((plat) => plat.gitStage([path]));
820
- },
821
- stageAll: () => {
822
- const paths = (shell.git.status?.files ?? [])
823
- .filter((file: GitFileStatus) => !file.staged)
824
- .map((file: GitFileStatus) => file.path);
825
- void gitAction((plat) => plat.gitStage(paths));
826
- },
827
- unstage: (path) => {
828
- void gitAction((plat) => plat.gitUnstage([path]));
829
- },
830
- unstageAll: () => {
831
- const paths = (shell.git.status?.files ?? [])
832
- .filter((file: GitFileStatus) => file.staged)
833
- .map((file: GitFileStatus) => file.path);
834
- void gitAction((plat) => plat.gitUnstage(paths));
835
- },
836
- };
837
-
838
- /** A mounted document, the node it is standing in, and the effect feeding it. */
839
- interface Standing {
840
- host: HTMLElement;
841
- handle: GitPanelSurfaceHandle;
842
- scope: EffectScope;
843
- }
844
-
845
- /**
846
- * The one surface this panel has out, if any.
847
- *
848
- * One slot rather than a per-host map, because there is one Navigator: a mount into a DIFFERENT
849
- * node is the old one being replaced, and holding both would leave the first one's effect running
850
- * against a scope nobody reads any more.
851
- */
852
- let _standing: Standing | null = null;
853
-
854
- /** Take the document down and stop the effect feeding it. Safe to call when there is none. */
855
- function unmountStanding(): void {
856
- if (!_standing) {
857
- return;
858
- }
859
- _standing.scope.stop();
860
- _standing.handle.dispose();
861
- _standing = null;
862
- }
863
-
864
- /**
865
- * Push a fresh projection at the standing document, now.
866
- *
867
- * The effect covers every reactive input; this covers the one that is not, {@link _branchOverride},
868
- * which is module state precisely because it is about the CONTROL rather than about the
869
- * repository.
870
- */
871
- function syncGitPanel(): void {
872
- _standing?.handle.update(gitPanelValues());
873
- }
874
-
875
- /** Arm the background refresh, once. Idempotent — the effect calls it on every projection. */
876
- function armPoll(): void {
877
- if (_pollTimer) {
878
- return;
879
- }
880
- _pollTimer = setInterval(() => {
881
- if (shell.leftTab === "git" && !shell.git.loading) {
882
- void refreshGitStatus();
883
- }
884
- }, POLL_GIT);
885
- }
886
-
887
- /**
888
- * Draw the panel — mounting the document the first time, and letting its own effect keep it current
889
- * every time after.
890
- *
891
- * The document goes into `.panel-content`, not into the `.panel-body` this is handed, for the
892
- * reason `panels/elements-panel.ts` states: only one of them is the node lit renders this panel's
893
- * body into, and appending to the other would leave the panel drawn under whatever the Navigator
894
- * paints next.
895
- *
896
- * The first mount is also what starts the first read. A refresh that already failed must NOT re-arm
897
- * it — the Refresh button and the poll are the ways back — which is what {@link panelView}'s
898
- * `loading` branch means.
899
- *
900
- * @param {HTMLElement} host - The painted `.panel-body`
901
- * @param {GitPanelDeps} deps - What `studio.ts` injects through the Navigator
902
- */
903
- export function mountGitPanel(host: HTMLElement, deps: GitPanelDeps): void {
904
- _deps = deps;
905
- const container = host.querySelector<HTMLElement>(".panel-content") ?? host;
906
- /* `hasPlatform()` first, because the Navigator can paint before the bootstrap registers one and
907
- `getPlatform()` THROWS: a panel painted that early has nothing to ask, and a rejected read here
908
- would come back as a render failure of the whole dock. The poll and the Refresh button are the
909
- ways back, exactly as they are after a read that failed. */
910
- if (hasPlatform() && panelView() === "loading") {
911
- void refreshGitStatus();
912
- }
913
- if (_standing && (_standing.host !== container || !_standing.handle.connected())) {
914
- unmountStanding();
915
- }
916
- if (_standing) {
917
- return;
918
- }
919
- const handle = mountGitPanelSurface(container, gitPanelValues(), ACTIONS);
920
- const scope = effectScope();
921
- scope.run(() => {
922
- effect(() => {
923
- const values = gitPanelValues();
924
- /* Armed from inside the projection rather than at mount, because the mount usually happens
925
- one branch earlier: the first paint has no status yet, and "there is a repository here" is
926
- something only a finished read can say. */
927
- if (values.view === "repo") {
928
- armPoll();
929
- }
930
- handle.update(values);
931
- });
932
- });
933
- _standing = { handle, host: container, scope };
934
- }
935
-
936
- /**
937
- * A commit age, relative to {@link now}.
938
- *
939
- * Exported so it is testable at all: reading the wall clock inline meant "yesterday" and the
940
- * locale-date fallback could only be asserted against an offset from the real present, and two
941
- * captures minutes apart legitimately disagreed.
942
- *
943
- * @param {string} iso
944
- */
945
- export function relativeDate(iso: string) {
946
- const d = new Date(iso);
947
- const diff = now() - d.getTime();
948
- const mins = Math.floor(diff / 60_000);
949
- if (mins < 1) {
950
- return "just now";
951
- }
952
- if (mins < 60) {
953
- return `${mins}m ago`;
954
- }
955
- const hours = Math.floor(mins / 60);
956
- if (hours < 24) {
957
- return `${hours}h ago`;
958
- }
959
- const days = Math.floor(hours / 24);
960
- if (days < 30) {
961
- return `${days}d ago`;
962
- }
963
- return d.toLocaleDateString();
964
- }
965
-
966
- /**
967
- * The `Source Control:` family — the four verbs that were only ever buttons.
968
- *
969
- * Every one of them was reachable from exactly one place: two from an empty state that disappears
970
- * the moment the repository exists, one from a 20px icon with a `title` attribute, and the fourth —
971
- * signing in to GitHub — from nowhere at all, because it only ever happened as a side effect of
972
- * something else. That is why a failed sign-in had no Retry to name: there was no record to point
973
- * at. Naming them here gives the palette, `__jxAutomation`, the assistant, the deploy checklist and
974
- * every `notify` Retry the same four ids.
975
- *
976
- * `git.signInToGithub` is `application`-level and the other three are `project`-level, and the
977
- * split is the credential's: a GitHub token is one per machine and is revoked in Preferences ›
978
- * Accounts, while a branch, a remote and a push belong to one repository.
979
- */
980
- export function sourceControlCommands(): AnyCommand[] {
981
- return [
982
- {
983
- category: "Source Control",
984
- id: "git.init",
985
- level: "project",
986
- menus: ["commandbar/overflow", "palette"],
987
- group: "7_scm",
988
- requires: "an open project that git is not already tracking",
989
- when: (ctx) => ctx.project.open,
990
- // `when` already asked about the project; an `enablement` that re-asks is the same rule
991
- // Written twice, and the two places drift.
992
- enablement: (ctx) => !ctx.project.isRepo,
993
- /* No `aiTool`, by studio-ui-guidelines.md §12.4's third deletion rule: outside the tree,
994
- irreversible, and the model has no read to judge by. The git family is reconsidered
995
- together when `git.commit` becomes a record — without it the agent could not ship its own
996
- edits anyway. */
997
- run: async () => {
998
- await initRepository();
999
- },
1000
- title: "Initialize Repository",
1001
- },
1002
- {
1003
- category: "Source Control",
1004
- id: "git.createGithubRepository",
1005
- level: "project",
1006
- menus: ["commandbar/overflow", "palette"],
1007
- group: "7_scm",
1008
- /* THE STRICTEST OF THE THREE, because it is the one that leaves something behind on a
1009
- server. It declared no `enablement` at all while `git.push` — which does strictly less —
1010
- required a tracked repository, so on an untracked project Push was correctly disabled and
1011
- this was fully live from the palette, the overflow, the deploy checklist and the
1012
- `create_github_repository` AI tool it then declared. Its flow creates the repository on
1013
- GitHub BEFORE it touches the local one, so `gitAddRemote` then throws and it reports "The
1014
- repository was created, but the remote could not be added." The refused verb leaves
1015
- nothing behind; the unrefused one leaves an empty repository on the user's account. */
1016
- requires: "a project tracked by git",
1017
- when: (ctx) => ctx.project.open,
1018
- enablement: (ctx) => ctx.project.isRepo,
1019
- /* No `aiTool`, by studio-ui-guidelines.md §12.4's third deletion rule: it creates a
1020
- repository on the person's account. Same family as `git.init`. */
1021
- run: async () => {
1022
- await createGithubRepository({ projectName: projectState?.name || "my-project" });
1023
- },
1024
- title: "Create GitHub Repository",
1025
- },
1026
- {
1027
- category: "Source Control",
1028
- id: "git.push",
1029
- level: "project",
1030
- menus: ["commandbar/overflow", "palette"],
1031
- group: "7_scm",
1032
- requires: "a project tracked by git",
1033
- when: (ctx) => ctx.project.open,
1034
- enablement: (ctx) => ctx.project.isRepo,
1035
- /* No `aiTool`, by studio-ui-guidelines.md §12.4's third deletion rule. Same family as
1036
- `git.init`. */
1037
- run: async () => {
1038
- await pushCurrentBranch();
1039
- },
1040
- title: "Push",
1041
- },
1042
- {
1043
- category: "Source Control",
1044
- id: "git.signInToGithub",
1045
- level: "application",
1046
- menus: ["palette"],
1047
- group: "7_scm",
1048
- run: async () => {
1049
- await signInToGithub();
1050
- },
1051
- title: "Sign In to GitHub",
1052
- },
1053
- ];
1054
- }
1055
-
1056
- /** Register the `Source Control:` family. */
1057
- export function registerSourceControlCommands(registry: CommandRegistry): void {
1058
- registry.registerAll(sourceControlCommands());
1059
- }
1060
-
1061
- /**
1062
- * Stop the background refresh and take the document down. Called on unmount and whenever a
1063
- * different project is opened.
1064
- *
1065
- * The surface goes with the timer, and for the same reason: everything it projects belongs to ONE
1066
- * repository, so a document left standing over a project switch would draw the previous project's
1067
- * branch and changed files until the Navigator next repainted the panel.
1068
- */
1069
- export function cleanupGitPanel() {
1070
- if (_pollTimer) {
1071
- clearInterval(_pollTimer);
1072
- _pollTimer = null;
1073
- }
1074
- unmountStanding();
1075
- }
1076
-
1077
- /**
1078
- * Contribute the Source Control panel.
1079
- *
1080
- * `level: "project"` — a branch, a working tree and a commit belong to the repository, not to
1081
- * whichever document happens to be focused. That is why the badge below reads `ctx.git.dirtyCount`
1082
- * (sourced from the hoisted `shell.git` record) and why this panel's render ignores `ctx.doc`
1083
- * entirely: the count used to come from `activeTab.session.ui.gitStatus`, so it vanished when the
1084
- * last tab closed and two tabs could disagree about the branch.
1085
- */
1086
- export function registerGitPanel(): void {
1087
- registerPanel({
1088
- id: "git",
1089
- title: "Source Control",
1090
- /* The full title is 71px against the rail's 48px label box. The header, the tooltip and the
1091
- accessible name keep it; only the words under the glyph shorten. */
1092
- railLabel: "Source",
1093
- level: "project",
1094
- dock: "navigator",
1095
- // A KEY into the kit's icon manifest, not a tag: this one resolves to
1096
- // `gitBranchIcon`, a hand-drawn inline SVG, because the workflow set has no Git family.
1097
- icon: "git-branch",
1098
- badge: (ctx) => ctx.git.dirtyCount || null,
1099
- // The body is a document, so lit draws nothing and the mount happens against the painted DOM.
1100
- // `afterRender` runs on every repaint; {@link mountGitPanel} is idempotent.
1101
- render: (): PanelBody => nothing,
1102
- // Through `deps`, not a local binding: `studio.ts` owns the wiring (the clone action and the
1103
- // Diff-state setter come from the bootstrap), and the Navigator has injected it all along.
1104
- afterRender: (ctx, host) => {
1105
- mountGitPanel(host, ctx.deps);
1106
- },
1107
- });
1108
- }