@jxsuite/studio 5.2.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/css-meta.json +28 -27
- package/dist/chunks/{cf-account-picker-h4dab9bq.js → cf-account-picker-3f08rry6.js} +21 -18
- package/dist/chunks/{cf-settings-adg74qsk.js → cf-settings-m79r7p5y.js} +4 -4
- package/dist/chunks/{components-5y78e05d.js → components-xm826zjw.js} +3 -3
- package/dist/chunks/{content-source-sgg1sv6n.js → content-source-jt7rbcbc.js} +22 -22
- package/dist/chunks/{convert-to-repeater-mf1cxgfn.js → convert-to-repeater-vg38bq99.js} +22 -22
- package/dist/chunks/{editor-3qhbg51x.js → editor-ddy019sn.js} +2 -2
- package/dist/chunks/entry-commands-64nb2a9a.js +42 -0
- package/dist/chunks/{extension-sections-c6zwzbre.js → extension-sections-r73an5s6.js} +31 -30
- package/dist/chunks/{file-ops-vrpq1jjk.js → file-ops-3xan8mnj.js} +21 -21
- package/dist/chunks/{files-msaf95y6.js → files-egsb0ry8.js} +30 -29
- package/dist/chunks/{format-host-f64fnesp.js → format-host-mym8qnd0.js} +3 -3
- package/dist/chunks/{fs-events-3y6y0nrm.js → fs-events-z2gg8qjt.js} +4 -4
- package/dist/chunks/{git-panel-bv5e22j0.js → git-panel-a05atk6q.js} +20 -20
- package/dist/chunks/{grid-view-1p6hsyjx.css → grid-view-3g1h2re8.css} +956 -139
- package/dist/chunks/{grid-view-paj67nr5.js → grid-view-qaqer9kr.js} +24 -24
- package/dist/chunks/{icons-yy10wk9r.js → icons-drxq9q10.js} +8 -2
- package/dist/chunks/{iframe-host-dh5np8vk.js → iframe-host-psetcv20.js} +11 -11
- package/dist/chunks/{index-n4j7qxyr.js → index-9yjae3hz.js} +4 -4
- package/dist/chunks/{javascript-4abzjcy9.css → javascript-bc9z461d.css} +688 -54
- package/dist/chunks/{javascript-xvrfrpkb.js → javascript-hr5sg57n.js} +2 -2
- package/dist/chunks/{jsonMode-vvmpmk34.css → jsonMode-qqd9nm1t.css} +1120 -303
- package/dist/chunks/{jsonMode-tyx2kj6p.js → jsonMode-zs88v0wr.js} +4 -4
- package/dist/chunks/{jx-validate-j0wxk72w.js → jx-validate-epp2z3s3.js} +2 -2
- package/dist/chunks/layers-panel-83a16ytx.js +41 -0
- package/dist/chunks/{layers-1vcfdbet.js → layers-s6mc01ry.js} +3 -3
- package/dist/chunks/{listbox-6v2ac08j.js → listbox-b7jxnhq1.js} +19 -3
- package/dist/chunks/{media-picker-p49nhqhs.js → media-picker-nhn6rv4w.js} +11 -11
- package/dist/chunks/{menu-qht48vnc.js → menu-8j4qxjrp.js} +4 -4
- package/dist/chunks/{monaco-binding-sw6en4dw.js → monaco-binding-e8d9wzyk.js} +3 -3
- package/dist/chunks/{monaco-buffer-pykwbm92.js → monaco-buffer-jaq1t9zj.js} +2 -2
- package/dist/chunks/{monaco-setup-8vbyqnhr.css → monaco-setup-ey9cjcm3.css} +954 -137
- package/dist/chunks/{monaco-setup-8r62fj6y.js → monaco-setup-gsjdysze.js} +7 -7
- package/dist/chunks/{platform-ts9cg1a4.js → platform-fnchmhy7.js} +5 -3
- package/dist/chunks/publish-panel-ak6hxfma.js +27 -0
- package/dist/chunks/quick-search-c63mkt3b.js +47 -0
- package/dist/chunks/{references-h69xp9zz.js → references-f7bdv3z5.js} +3 -3
- package/dist/chunks/right-panel-t5n8wttg.js +45 -0
- package/dist/chunks/{split-g7nm1rgb.js → split-4cz4b6ef.js} +14 -3
- package/dist/chunks/{studio-sar8g54p.js → studio-01269reb.js} +8 -8
- package/dist/chunks/{studio-rnyf3f8e.js → studio-0a4gncx0.js} +3 -3
- package/dist/chunks/{studio-e1f24eff.js → studio-0d4p4wxj.js} +6778 -2993
- package/dist/chunks/{studio-4wbb9ct0.js → studio-1tejxvba.js} +3006 -1855
- package/dist/chunks/{studio-p6pmwkvh.js → studio-3nprwbd9.js} +147 -28
- package/dist/chunks/{studio-4c041r8y.js → studio-40z39dme.js} +3 -3
- package/dist/chunks/{studio-68fydsrj.js → studio-482eeazk.js} +20 -20
- package/dist/chunks/{studio-y4f9fdge.js → studio-4998spet.js} +10 -9
- package/dist/chunks/{studio-nq5yf5mp.js → studio-557bmn0x.js} +2 -2
- package/dist/chunks/{studio-hdc2jt3z.js → studio-5w26wza5.js} +3 -3
- package/dist/chunks/{studio-6nzaktvy.js → studio-6pwn9j8c.js} +6 -3
- package/dist/chunks/{studio-wnsyffg1.js → studio-6vg0x5fz.js} +3 -2
- package/dist/chunks/{studio-vn5hske5.js → studio-7d3c1m59.js} +12 -5
- package/dist/chunks/{studio-28vs5k2y.js → studio-9vsvz7w7.js} +7 -7
- package/dist/chunks/{studio-t3adrr56.js → studio-9wm0xzpf.js} +19 -19
- package/dist/chunks/{studio-38emantv.js → studio-a5h5j33a.js} +19 -5
- package/dist/chunks/{studio-ympe0n7a.js → studio-ag3z6shb.js} +10 -4
- package/dist/chunks/studio-aj9drheq.js +177 -0
- package/dist/chunks/{studio-vt0tj32j.js → studio-apv9x70c.js} +189 -130
- package/dist/chunks/{studio-c04nzbby.js → studio-b9q3znz8.js} +2 -2
- package/dist/chunks/{studio-2mdbbc76.js → studio-bh47w0cy.js} +9 -10
- package/dist/chunks/{studio-ez11dmdh.js → studio-dgdm6vvt.js} +264 -52
- package/dist/chunks/{studio-5nz00bhh.js → studio-dwdcr2e8.js} +4 -4
- package/dist/chunks/{studio-nqgawfks.js → studio-fbcyz234.js} +146 -139
- package/dist/chunks/{studio-kcgff4r0.js → studio-fgmfksz8.js} +2 -2
- package/dist/chunks/{studio-x72j58vw.js → studio-fqpkpq1t.js} +7 -4
- package/dist/chunks/{studio-15f3kxqe.js → studio-fy320dfc.js} +62 -68
- package/dist/chunks/{studio-zjjde71a.js → studio-gjj4bbfx.js} +2 -2
- package/dist/chunks/{studio-66arbpc2.js → studio-jfhxy8h3.js} +16 -15
- package/dist/chunks/{studio-d0300636.js → studio-ks2zzth2.js} +17 -2
- package/dist/chunks/{studio-c07s5ckd.js → studio-kwewmhhq.js} +4 -4
- package/dist/chunks/{studio-01jeck2y.js → studio-m58xn8at.js} +26 -25
- package/dist/chunks/{studio-mpzwze9x.js → studio-mfkh1q8d.js} +17 -17
- package/dist/chunks/{studio-etvx9s2g.js → studio-mrh0a92f.js} +17 -17
- package/dist/chunks/{studio-qa7fzxan.js → studio-mt79tn56.js} +3 -3
- package/dist/chunks/{studio-hhskq2mr.js → studio-ne593z1j.js} +39 -32
- package/dist/chunks/{studio-h4nvnjvz.js → studio-ptfcxkz5.js} +418 -232
- package/dist/chunks/{studio-4xmjcrg3.js → studio-qxye31h7.js} +7 -7
- package/dist/chunks/{studio-a1pswps3.js → studio-rav5bpmp.js} +81 -59
- package/dist/chunks/{studio-ncn9e189.js → studio-rwmmbrth.js} +6 -6
- package/dist/chunks/{studio-en82c639.js → studio-sceg8ws0.js} +8 -8
- package/dist/chunks/{studio-wjpgxywa.js → studio-sjas5b3a.js} +19 -13
- package/dist/chunks/{studio-4r14yzyy.js → studio-vd67b66d.js} +3 -3
- package/dist/chunks/{studio-14d9tq4d.js → studio-w475cbf9.js} +10 -10
- package/dist/chunks/{studio-ctm7bhx5.js → studio-w7gpcvfj.js} +9 -9
- package/dist/chunks/{studio-9j6sfeba.js → studio-xrbfdxgk.js} +7 -7
- package/dist/chunks/{studio-x10fp4tp.js → studio-y49b6mjv.js} +35 -35
- package/dist/chunks/{studio-5t7ena5z.js → studio-ygvr9e4q.js} +10 -10
- package/dist/chunks/{studio-z2smx5ce.js → studio-yxmmjy2a.js} +9 -6
- package/dist/chunks/{tsMode-jy4m86rv.js → tsMode-ay4c78ne.js} +4 -4
- package/dist/chunks/{tsMode-hnxxb73h.css → tsMode-c72wyz27.css} +954 -137
- package/dist/chunks/{workspace-bnw54cha.js → workspace-b9k2frks.js} +5 -5
- package/dist/chunks/{ws-client-ny4zc51r.js → ws-client-erze4czt.js} +356 -20
- package/dist/codicon.ttf +0 -0
- package/dist/iframe-entry.js +20 -18
- package/dist/studio.css +956 -139
- package/dist/studio.js +1511 -851
- package/dist/workers/editor.worker.js +196 -107
- package/dist/workers/json.worker.js +196 -107
- package/dist/workers/ts.worker.js +196 -107
- package/package.json +18 -17
- package/src/about/about-modal.ts +4 -3
- package/src/browse/library-commands.ts +15 -13
- package/src/browse/library-pane.ts +2 -2
- package/src/canvas/canvas-render.ts +97 -83
- package/src/canvas/canvas-surface.ts +2 -2
- package/src/canvas/canvas-utils.ts +42 -32
- package/src/canvas/diff-toolbar.ts +21 -2
- package/src/canvas/diff-view.ts +30 -6
- package/src/canvas/iframe-entry.ts +2 -2
- package/src/canvas/iframe-host.ts +5 -5
- package/src/canvas/iframe-interaction.ts +7 -6
- package/src/canvas/iframe-overlay.ts +1 -1
- package/src/canvas/iframe-protocol.ts +6 -5
- package/src/canvas/iframe-render.ts +3 -3
- package/src/canvas/popover-state.ts +1 -1
- package/src/canvas/stage-scrollbar.ts +112 -0
- package/src/canvas/surface-registry.ts +9 -2
- package/src/collab/collab-commands.ts +8 -6
- package/src/collab/collab-session.ts +4 -4
- package/src/collab/collab-state.ts +4 -4
- package/src/collab/presence-chips.ts +3 -3
- package/src/commands/app-commands.ts +7 -7
- package/src/commands/budget.ts +17 -16
- package/src/commands/command-args.ts +10 -9
- package/src/commands/context.ts +20 -10
- package/src/commands/defaults.ts +30 -29
- package/src/commands/levels.ts +8 -6
- package/src/commands/live-context.ts +12 -10
- package/src/commands/reference.ts +5 -5
- package/src/commands/registry.ts +2 -2
- package/src/content/draft-state.ts +9 -8
- package/src/content/entry-commands.ts +16 -14
- package/src/content/entry-editor.ts +2 -2
- package/src/content/entry-fields.ts +1 -1
- package/src/editor/context-menu.ts +4 -4
- package/src/editor/convert-to-component.ts +6 -5
- package/src/editor/inline-edit.ts +3 -3
- package/src/editor/shortcuts.ts +88 -20
- package/src/editor/slash-menu.ts +11 -10
- package/src/files/elements.ts +4 -5
- package/src/files/file-ops.ts +1 -1
- package/src/files/files.ts +21 -17
- package/src/files/serialize-document.ts +1 -1
- package/src/format/convert-file.ts +5 -5
- package/src/github/github-auth-status.ts +107 -0
- package/src/github/github-auth.ts +18 -82
- package/src/github/github-publish.ts +7 -6
- package/src/grid/cell-editors.ts +8 -7
- package/src/grid/grid-layout.ts +1 -1
- package/src/grid/grid-open.ts +6 -5
- package/src/grid/grid-panel.ts +13 -12
- package/src/grid/redirects-grid.ts +14 -11
- package/src/grid/redirects.ts +10 -5
- package/src/grid/sources/content-source.ts +10 -9
- package/src/hosting/document.ts +28 -1
- package/src/hosting/stage.ts +15 -4
- package/src/i18n/i18n-commands.ts +9 -7
- package/src/new-project/location-fields.ts +16 -3
- package/src/new-project/new-project-modal.ts +23 -7
- package/src/page-params.ts +6 -6
- package/src/panels/activity-panel.ts +11 -10
- package/src/panels/ai-chat/chat-view.ts +27 -14
- package/src/panels/ai-chat/composer.ts +10 -3
- package/src/panels/ai-panel.ts +87 -29
- package/src/panels/block-action-bar.ts +59 -33
- package/src/panels/bottom-dock.ts +22 -22
- package/src/panels/chat-panel.ts +40 -5
- package/src/panels/data-explorer.ts +9 -9
- package/src/panels/data-grid.ts +1 -1
- package/src/panels/editors.ts +8 -8
- package/src/panels/elements-panel.ts +7 -8
- package/src/panels/empty-state.ts +1 -1
- package/src/panels/events-panel.ts +13 -12
- package/src/panels/formula-workspace.ts +8 -5
- package/src/panels/frontmatter-fields.ts +4 -1
- package/src/panels/frontmatter-panel.ts +18 -18
- package/src/panels/git-panel.ts +19 -13
- package/src/panels/head-panel.ts +9 -10
- package/src/panels/i18n-panel.ts +6 -4
- package/src/panels/imports-panel.ts +1 -1
- package/src/panels/jump-bar.ts +20 -18
- package/src/panels/layers-panel.ts +19 -17
- package/src/panels/left-panel.ts +3 -3
- package/src/panels/navigator-panels.ts +8 -8
- package/src/panels/overlays.ts +1 -1
- package/src/panels/pane-context.ts +56 -28
- package/src/panels/pane-grid.ts +9 -8
- package/src/panels/panel-registry.ts +47 -19
- package/src/panels/problems-panel.ts +11 -12
- package/src/panels/properties-panel.ts +21 -20
- package/src/panels/provenance.ts +3 -3
- package/src/panels/quick-search.ts +15 -11
- package/src/panels/right-panel.ts +4 -3
- package/src/panels/seo-modal.ts +5 -4
- package/src/panels/settings-menu.ts +9 -9
- package/src/panels/settings-pane.ts +3 -3
- package/src/panels/signals-panel.ts +16 -9
- package/src/panels/statement-editor.ts +12 -9
- package/src/panels/style-panel.ts +45 -41
- package/src/panels/stylebook-panel.ts +0 -1
- package/src/panels/tab-strip.ts +26 -23
- package/src/platform-errors.ts +2 -2
- package/src/platform.ts +44 -4
- package/src/platforms/cloud.ts +11 -1
- package/src/platforms/default-platform.ts +141 -4
- package/src/platforms/devserver.ts +23 -3
- package/src/publish/deploy-checklist.ts +11 -10
- package/src/publish/publish-commands.ts +9 -8
- package/src/services/a11y-report.ts +1 -1
- package/src/services/ai-ask.ts +39 -16
- package/src/services/ai-command-tools.ts +28 -14
- package/src/services/ai-import-tools.ts +43 -29
- package/src/services/ai-project-tools.ts +20 -38
- package/src/services/ai-settings.ts +55 -2
- package/src/services/ai-tools.ts +69 -58
- package/src/services/ai-write-report.ts +4 -4
- package/src/services/ai-writes.ts +74 -55
- package/src/services/automation.ts +12 -12
- package/src/services/clock.ts +2 -1
- package/src/services/connection.ts +2 -2
- package/src/services/context-manager.ts +69 -6
- package/src/services/directory-picker.ts +93 -27
- package/src/services/document-assistant.ts +86 -17
- package/src/services/gated-registry.ts +4 -3
- package/src/services/idle.ts +5 -4
- package/src/services/live-surfaces.ts +2 -1
- package/src/services/module-preloads.ts +67 -0
- package/src/services/notify.ts +9 -7
- package/src/services/popover-report.ts +3 -3
- package/src/services/preview-eval.ts +1 -1
- package/src/services/project-adoption.ts +34 -1
- package/src/services/project-path.ts +53 -0
- package/src/services/settings/kernel.ts +13 -2
- package/src/services/tool-executor.ts +135 -30
- package/src/services/tool-outcomes.ts +143 -0
- package/src/settings/contexts-section.ts +8 -8
- package/src/settings/contributed-section.ts +6 -6
- package/src/settings/css-vars-editor.ts +6 -5
- package/src/settings/extension-commands.ts +19 -18
- package/src/settings/extension-sections.ts +7 -7
- package/src/settings/extensions-section.ts +3 -3
- package/src/settings/general-settings.ts +21 -18
- package/src/settings/preferences-accounts.ts +3 -3
- package/src/settings/preferences-dialog.ts +9 -8
- package/src/settings/preferences-sections.ts +1 -1
- package/src/settings/project-sections.ts +2 -2
- package/src/settings/section-registry.ts +7 -6
- package/src/settings/settings-document.ts +41 -43
- package/src/shell/tree.ts +29 -0
- package/src/shell.ts +63 -55
- package/src/site-context.ts +1 -1
- package/src/store.ts +2 -2
- package/src/studio.ts +52 -28
- package/src/style/live-preview.ts +8 -8
- package/src/style/project-styles.ts +8 -9
- package/src/style/token-ref.ts +2 -2
- package/src/surfaces/about.json +6 -2
- package/src/surfaces/add-repo.json +2 -2
- package/src/surfaces/add-repo.ts +2 -2
- package/src/surfaces/ai-chat.json +14 -6
- package/src/surfaces/ai-chat.ts +4 -2
- package/src/surfaces/ai-credentials-form.json +53 -49
- package/src/surfaces/ai-credentials-form.ts +18 -4
- package/src/surfaces/ai-managed-connect.json +4 -4
- package/src/surfaces/block-action-bar.json +4 -4
- package/src/surfaces/block-action-bar.ts +3 -3
- package/src/surfaces/boot-failure.json +228 -0
- package/src/surfaces/boot-failure.ts +156 -0
- package/src/surfaces/bottom-dock.json +1 -1
- package/src/surfaces/canvas-stage.json +9 -40
- package/src/surfaces/canvas-stage.ts +9 -9
- package/src/surfaces/cf-account-picker.json +11 -8
- package/src/surfaces/commandbar.ts +11 -10
- package/src/surfaces/convert-repeater.ts +3 -2
- package/src/surfaces/dialog.json +7 -1
- package/src/surfaces/dialog.ts +2 -2
- package/src/surfaces/doc-header.json +6 -13
- package/src/surfaces/doc-header.ts +4 -5
- package/src/surfaces/entry-editor.json +1 -1
- package/src/surfaces/entry-editor.ts +2 -1
- package/src/surfaces/expression-editor.json +5 -5
- package/src/surfaces/files-panel.json +4 -3
- package/src/surfaces/files-panel.ts +1 -1
- package/src/surfaces/formula-palette.json +10 -9
- package/src/surfaces/formula-palette.ts +11 -7
- package/src/surfaces/git-panel.json +167 -109
- package/src/surfaces/git-panel.ts +2 -2
- package/src/surfaces/github-auth.json +2 -1
- package/src/surfaces/github-publish.ts +3 -3
- package/src/surfaces/grid-open.json +1 -1
- package/src/surfaces/grid-panel.json +2 -2
- package/src/surfaces/grid-views.json +1 -1
- package/src/surfaces/inspector-dock.json +2 -2
- package/src/surfaces/jump-bar.json +1 -1
- package/src/surfaces/jump-bar.ts +1 -1
- package/src/surfaces/library-pane.ts +2 -1
- package/src/surfaces/logic-panel.json +7 -7
- package/src/surfaces/logic-panel.ts +6 -4
- package/src/surfaces/logic-workspace.json +2 -2
- package/src/surfaces/logic-workspace.ts +2 -2
- package/src/surfaces/media-browser.ts +3 -3
- package/src/surfaces/media-pane.ts +2 -1
- package/src/surfaces/menu.ts +5 -5
- package/src/surfaces/new-project.json +1 -1
- package/src/surfaces/palette.json +8 -7
- package/src/surfaces/pane-context.json +86 -57
- package/src/surfaces/pane-context.ts +2 -1
- package/src/surfaces/pane-grid.json +3 -3
- package/src/surfaces/panel-activity.json +2 -1
- package/src/surfaces/panel-deploy-checklist.json +1 -1
- package/src/surfaces/panel-elements.ts +2 -1
- package/src/surfaces/panel-i18n.ts +2 -1
- package/src/surfaces/panel-outline.json +1 -1
- package/src/surfaces/panel-outline.ts +4 -3
- package/src/surfaces/panel-page.json +2 -2
- package/src/surfaces/panel-page.ts +4 -1
- package/src/surfaces/panel-problems.json +4 -3
- package/src/surfaces/panel-problems.ts +2 -2
- package/src/surfaces/panel-signals.json +23 -8
- package/src/surfaces/panel-signals.ts +5 -1
- package/src/surfaces/panel-stylebook-layers.json +1 -1
- package/src/surfaces/panel-stylebook-layers.ts +2 -2
- package/src/surfaces/preferences.json +21 -8
- package/src/surfaces/preferences.ts +9 -1
- package/src/surfaces/properties-panel.json +4 -4
- package/src/surfaces/properties-panel.ts +2 -2
- package/src/surfaces/publish.json +1 -1
- package/src/surfaces/publish.ts +2 -1
- package/src/surfaces/push-plan.json +4 -3
- package/src/surfaces/rail.json +2 -2
- package/src/surfaces/rail.ts +10 -4
- package/src/surfaces/reference-field.json +1 -1
- package/src/surfaces/schema-form.json +2 -2
- package/src/surfaces/schema-form.ts +1 -1
- package/src/surfaces/seo.json +1 -1
- package/src/surfaces/seo.ts +2 -2
- package/src/surfaces/settings-contributed.ts +2 -1
- package/src/surfaces/settings-css-vars.json +4 -4
- package/src/surfaces/settings-deploy.json +4 -4
- package/src/surfaces/settings-deploy.ts +2 -1
- package/src/surfaces/settings-extensions.json +6 -6
- package/src/surfaces/settings-extensions.ts +6 -2
- package/src/surfaces/settings-locales.json +4 -4
- package/src/surfaces/settings-overview.ts +2 -1
- package/src/surfaces/settings-pane.ts +3 -2
- package/src/surfaces/settings-rawjson.ts +1 -1
- package/src/surfaces/slash-menu.ts +4 -4
- package/src/surfaces/statements.json +3 -3
- package/src/surfaces/statusbar.ts +23 -23
- package/src/surfaces/style-panel.json +9 -5
- package/src/surfaces/style-panel.ts +3 -3
- package/src/surfaces/tab-strip.json +2 -2
- package/src/surfaces/target-line.json +1 -1
- package/src/surfaces/target-line.ts +12 -10
- package/src/surfaces/welcome.json +7 -2
- package/src/tabs/doc-op-apply.ts +5 -5
- package/src/tabs/patch-ops.ts +3 -3
- package/src/tabs/project-config.ts +10 -10
- package/src/tabs/selection.ts +1 -1
- package/src/tabs/tab.ts +13 -14
- package/src/tabs/transact.ts +18 -24
- package/src/types.ts +27 -3
- package/src/ui/ai-credentials-form.ts +74 -16
- package/src/ui/ai-managed-connect.ts +68 -19
- package/src/ui/color-selector.ts +1 -1
- package/src/ui/expression-editor.ts +3 -3
- package/src/ui/form-controls.ts +6 -5
- package/src/ui/formula-catalog.ts +4 -4
- package/src/ui/formula-chips.ts +2 -2
- package/src/ui/layers.ts +20 -18
- package/src/ui/panel-resize.ts +8 -28
- package/src/ui/popover-surface.ts +2 -2
- package/src/ui/progress-modal.ts +3 -3
- package/src/ui/regions.ts +14 -9
- package/src/ui/schema-form.ts +10 -9
- package/src/ui/timing.ts +9 -7
- package/src/ui/value-source.ts +4 -4
- package/src/ui/virtual-window.ts +58 -5
- package/src/utils/base64.ts +20 -1
- package/src/utils/canvas-media.ts +1 -1
- package/src/utils/studio-utils.ts +0 -31
- package/src/view.ts +4 -3
- package/src/workspace/pane-derive.ts +14 -13
- package/src/workspace/session.ts +7 -6
- package/src/workspace/workspace.ts +49 -39
- package/styles/canvas.css +1 -27
- package/styles/inspector.css +4 -3
- package/styles/overlays.css +1 -1
- package/styles/tokens.css +17 -1
- package/styles/tokens.json +6 -1
- package/dist/chunks/entry-commands-w9qsxa6q.js +0 -42
- package/dist/chunks/layers-panel-fksbdg4q.js +0 -40
- package/dist/chunks/publish-panel-vz23wwmg.js +0 -27
- package/dist/chunks/quick-search-e9rp74m8.js +0 -46
- package/dist/chunks/right-panel-j97t2yvy.js +0 -45
- package/dist/chunks/studio-727xh0e3.js +0 -76
- package/src/files/json-layout.ts +0 -474
- package/src/services/ai-turn-signal.ts +0 -70
package/src/files/json-layout.ts
DELETED
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A JSON document's layout — the facts about a file's text that `JSON.parse` throws away and a save
|
|
3
|
-
* has to put back.
|
|
4
|
-
*
|
|
5
|
-
* Studio's native JSON branch used to be `JSON.stringify(document, null, 2)`, and that is not the
|
|
6
|
-
* layout the repository is kept in. The formatter (`oxfmt`, Prettier-compatible for JSON) keeps a
|
|
7
|
-
* short object on the one line its author wrote it on, so every
|
|
8
|
-
* `packages/studio/src/surfaces/*.json` and `packages/ui/components/*.json` — files Studio now
|
|
9
|
-
* opens as projects — carries hundreds of `{ "part": "bar" }`s that a save expanded to three lines
|
|
10
|
-
* each. One edit became a whole-file diff, and the line the author actually changed was buried in
|
|
11
|
-
* it (issue 308).
|
|
12
|
-
*
|
|
13
|
-
* Two halves. {@link deriveJsonLayout} reads the source text once, when a file is read into a tab,
|
|
14
|
-
* and records the things the formatter would preserve; {@link serializeJson} writes a document back
|
|
15
|
-
* with those facts honoured and everything else laid out the way the formatter lays it out. The
|
|
16
|
-
* test that proves the pair is byte-identity over every formatted document in this repository.
|
|
17
|
-
*
|
|
18
|
-
* **What is recorded, and why nothing else.** The formatter preserves three authored choices and
|
|
19
|
-
* relays everything else. (1) Whether an object's `{` is followed by a line break: an object
|
|
20
|
-
* written on one line stays on one line while it fits the print width, and one whose first key sits
|
|
21
|
-
* on its own line stays expanded however short it is. (2) A blank line between two members of an
|
|
22
|
-
* object or an array — one, however many were written, and never one against a bracket. (3) A
|
|
23
|
-
* non-ASCII character an author spelt as a `\uXXXX` escape, which `JSON.stringify` would otherwise
|
|
24
|
-
* turn into the literal character and so touch a line the edit never reached. Arrays are relaid
|
|
25
|
-
* from scratch every time — `[\n 1, 2 ]` comes back as `[1, 2]` — so an array's own line break is a
|
|
26
|
-
* fact the serializer would then have to ignore, and it is not recorded.
|
|
27
|
-
*
|
|
28
|
-
* **Keyed by JSON Pointer**, so the record survives every edit that leaves a node where it was: a
|
|
29
|
-
* changed value, a new sibling, a removed one. An object with no entry — one the edit created —
|
|
30
|
-
* takes its parent's answer, so a new `{ "$ref": … }` inside an inline `attributes` lands inline
|
|
31
|
-
* beside its siblings rather than blowing the object open; at an expanded level, or in a document
|
|
32
|
-
* that has no layout at all, it expands, which is what the formatter does with `JSON.stringify`
|
|
33
|
-
* output.
|
|
34
|
-
*
|
|
35
|
-
* The width rules are measured against `oxfmt`, not recalled from Prettier: a container is inline
|
|
36
|
-
* when the whole line, trailing comma included, is at most `printWidth` columns; a container with
|
|
37
|
-
* an expanded object or a blank line anywhere inside it expands (a break propagates outward); an
|
|
38
|
-
* array of two or more elements that are all objects with more than one key, or all arrays with
|
|
39
|
-
* more than one element, always expands one element per line; and an array of two or more numbers
|
|
40
|
-
* fills its lines instead of taking one per line. Width is DISPLAY width, as the formatter measures
|
|
41
|
-
* it, not string length: a CJK or fullwidth character and an emoji are two columns, a combining
|
|
42
|
-
* mark or a format character is none ({@link displayWidth}; probed against oxfmt, which uses the
|
|
43
|
-
* `unicode-width` tables — the ranges here are Prettier's, and agree with those on everything a
|
|
44
|
-
* document is likely to hold). Scalars are `JSON.stringify`'s, so `1e5` reads back as `100000` and
|
|
45
|
-
* `1.50` as `1.5` — the parsed value has already lost the spelling, and no document in this
|
|
46
|
-
* repository writes a number either way. `package.json` is the one file the formatter lays out as
|
|
47
|
-
* `JSON.stringify` does, every array expanded; it is not a document and nothing here writes one.
|
|
48
|
-
*
|
|
49
|
-
* @docs studio/interface/tabs
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/** A JSON Pointer (RFC 6901) segment: `~` and `/` are the two characters that need escaping. */
|
|
53
|
-
function segment(key: string): string {
|
|
54
|
-
return key.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* What a source text said about its own layout, by JSON Pointer.
|
|
59
|
-
*
|
|
60
|
-
* `inline` maps an object to whether its `{` and first key shared a line; an empty object has no
|
|
61
|
-
* entry because `{}` is `{}` either way. `blankAfter` holds the members a blank line followed.
|
|
62
|
-
* `escaped` maps a string to the UTF-16 code units its source spelt as `\uXXXX` — the units rather
|
|
63
|
-
* than a flag, because `"— Julio Cortázar"` with only the dash escaped is a string this repository
|
|
64
|
-
* holds, and a flag would have had to choose which half of it to rewrite.
|
|
65
|
-
*/
|
|
66
|
-
export interface JsonLayout {
|
|
67
|
-
inline: Map<string, boolean>;
|
|
68
|
-
blankAfter: Set<string>;
|
|
69
|
-
escaped: Map<string, Set<number>>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** The print width the repository formats to — `.oxfmtrc.json` leaves oxfmt's default in place. */
|
|
73
|
-
export const JSON_PRINT_WIDTH = 100;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Read the layout facts out of a JSON text.
|
|
77
|
-
*
|
|
78
|
-
* A scanner rather than a parser: the text has already been through `JSON.parse` by the time this
|
|
79
|
-
* runs (see {@link parseJsonDocument}), so it is known to be well-formed and the scanner only has to
|
|
80
|
-
* find its way from one container to the next. Keys are decoded with `JSON.parse` so the pointer
|
|
81
|
-
* matches the key the document actually holds, escapes and all.
|
|
82
|
-
*/
|
|
83
|
-
export function deriveJsonLayout(text: string): JsonLayout {
|
|
84
|
-
const layout: JsonLayout = { blankAfter: new Set(), escaped: new Map(), inline: new Map() };
|
|
85
|
-
let i = 0;
|
|
86
|
-
|
|
87
|
-
/** Skip whitespace; report how many line breaks were among it. */
|
|
88
|
-
const space = (): number => {
|
|
89
|
-
let newlines = 0;
|
|
90
|
-
while (
|
|
91
|
-
i < text.length &&
|
|
92
|
-
(text[i] === " " || text[i] === "\t" || text[i] === "\r" || text[i] === "\n")
|
|
93
|
-
) {
|
|
94
|
-
if (text[i] === "\n") {
|
|
95
|
-
newlines += 1;
|
|
96
|
-
}
|
|
97
|
-
i += 1;
|
|
98
|
-
}
|
|
99
|
-
return newlines;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/** Consume the string starting at `i`; return its raw text and the code units it escaped. */
|
|
103
|
-
const string = (): { raw: string; escaped: Set<number> } => {
|
|
104
|
-
const start = i;
|
|
105
|
-
const escaped = new Set<number>();
|
|
106
|
-
i += 1;
|
|
107
|
-
while (i < text.length && text[i] !== '"') {
|
|
108
|
-
if (text[i] === "\\") {
|
|
109
|
-
if (text[i + 1] === "u") {
|
|
110
|
-
const unit = Number.parseInt(text.slice(i + 2, i + 6), 16);
|
|
111
|
-
if (unit >= 0x80) {
|
|
112
|
-
escaped.add(unit);
|
|
113
|
-
}
|
|
114
|
-
i += 6;
|
|
115
|
-
} else {
|
|
116
|
-
i += 2;
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
i += 1;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
i += 1;
|
|
123
|
-
return { escaped, raw: text.slice(start, i) };
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* After a member: consume its separator and note a blank line before the next one. Returns
|
|
128
|
-
* whether the container closed instead.
|
|
129
|
-
*/
|
|
130
|
-
const separator = (memberPath: string, close: string): boolean => {
|
|
131
|
-
let newlines = space();
|
|
132
|
-
if (text[i] === close) {
|
|
133
|
-
i += 1;
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
i += 1; // ","
|
|
137
|
-
newlines += space();
|
|
138
|
-
if (newlines >= 2) {
|
|
139
|
-
layout.blankAfter.add(memberPath);
|
|
140
|
-
}
|
|
141
|
-
return false;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const value = (path: string): void => {
|
|
145
|
-
space();
|
|
146
|
-
const c = text[i];
|
|
147
|
-
if (c === "{") {
|
|
148
|
-
i += 1;
|
|
149
|
-
const broken = space() > 0;
|
|
150
|
-
if (text[i] === "}") {
|
|
151
|
-
i += 1;
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
layout.inline.set(path, !broken);
|
|
155
|
-
while (i < text.length) {
|
|
156
|
-
const key = JSON.parse(string().raw) as string;
|
|
157
|
-
space();
|
|
158
|
-
i += 1; // ":"
|
|
159
|
-
const member = `${path}/${segment(key)}`;
|
|
160
|
-
value(member);
|
|
161
|
-
if (separator(member, "}")) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
} else if (c === "[") {
|
|
166
|
-
i += 1;
|
|
167
|
-
space();
|
|
168
|
-
if (text[i] === "]") {
|
|
169
|
-
i += 1;
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
for (let index = 0; i < text.length; index += 1) {
|
|
173
|
-
const member = `${path}/${index}`;
|
|
174
|
-
value(member);
|
|
175
|
-
if (separator(member, "]")) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
} else if (c === '"') {
|
|
180
|
-
const { escaped } = string();
|
|
181
|
-
if (escaped.size > 0) {
|
|
182
|
-
layout.escaped.set(path, escaped);
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
// A number or a literal: runs to the next delimiter.
|
|
186
|
-
while (i < text.length && !",]} \t\r\n".includes(text[i]!)) {
|
|
187
|
-
i += 1;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
value("");
|
|
193
|
-
return layout;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/** Parse a JSON file into the document it holds and the layout it was written in. */
|
|
197
|
-
export function parseJsonDocument(text: string): {
|
|
198
|
-
document: Record<string, unknown>;
|
|
199
|
-
layout: JsonLayout;
|
|
200
|
-
} {
|
|
201
|
-
const document = JSON.parse(text) as Record<string, unknown>;
|
|
202
|
-
return { document, layout: deriveJsonLayout(text) };
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ─── Writing ──────────────────────────────────────────────────────────────────
|
|
206
|
-
|
|
207
|
-
/** Anything outside printable ASCII: the one case {@link displayWidth} has to count. */
|
|
208
|
-
const NOT_ASCII = /[^\u0020-\u007E]/;
|
|
209
|
-
|
|
210
|
-
/** A mark or a format character (a zero-width joiner, say) takes no column. */
|
|
211
|
-
const ZERO_WIDTH = /^[\p{Mn}\p{Me}\p{Cf}]$/u;
|
|
212
|
-
|
|
213
|
-
/** A character the formatter draws two columns wide: East Asian Wide/Fullwidth, or an emoji. */
|
|
214
|
-
const EMOJI = /^\p{Emoji_Presentation}$/u;
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* East Asian Wide and Fullwidth (`is-fullwidth-code-point`'s table, which is what Prettier's
|
|
218
|
-
* `getStringWidth` consults): Hangul Jamo, CJK and its punctuation, Hangul syllables, the
|
|
219
|
-
* compatibility ideographs, vertical and small forms, the fullwidth Latin block, and the
|
|
220
|
-
* supplementary ideographic planes.
|
|
221
|
-
*/
|
|
222
|
-
function isWide(cp: number): boolean {
|
|
223
|
-
return (
|
|
224
|
-
cp >= 0x11_00 &&
|
|
225
|
-
(cp <= 0x11_5f ||
|
|
226
|
-
cp === 0x23_29 ||
|
|
227
|
-
cp === 0x23_2a ||
|
|
228
|
-
(cp >= 0x2e_80 && cp <= 0x32_47 && cp !== 0x30_3f) ||
|
|
229
|
-
(cp >= 0x32_50 && cp <= 0x4d_bf) ||
|
|
230
|
-
(cp >= 0x4e_00 && cp <= 0xa4_c6) ||
|
|
231
|
-
(cp >= 0xa9_60 && cp <= 0xa9_7c) ||
|
|
232
|
-
(cp >= 0xac_00 && cp <= 0xd7_a3) ||
|
|
233
|
-
(cp >= 0xf9_00 && cp <= 0xfa_ff) ||
|
|
234
|
-
(cp >= 0xfe_10 && cp <= 0xfe_19) ||
|
|
235
|
-
(cp >= 0xfe_30 && cp <= 0xfe_6b) ||
|
|
236
|
-
(cp >= 0xff_01 && cp <= 0xff_60) ||
|
|
237
|
-
(cp >= 0xff_e0 && cp <= 0xff_e6) ||
|
|
238
|
-
(cp >= 0x1_b0_00 && cp <= 0x1_b0_01) ||
|
|
239
|
-
(cp >= 0x1_f2_00 && cp <= 0x1_f2_51) ||
|
|
240
|
-
(cp >= 0x2_00_00 && cp <= 0x3_ff_fd))
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* How many columns a line of output occupies — what the formatter compares against the print width.
|
|
246
|
-
* `String.length` counts UTF-16 units, and the two part company exactly where a document holds
|
|
247
|
-
* non-Latin text: `"漢"` is one unit and two columns, an emoji is two units and two columns, `"é"`
|
|
248
|
-
* written as `e` plus a combining acute is two units and one column. Measured with the length, a
|
|
249
|
-
* line of CJK could sit "inline" at 62 units and 106 columns, and the formatter would break it open
|
|
250
|
-
* on the next run — a save that is not formatter-stable.
|
|
251
|
-
*/
|
|
252
|
-
export function displayWidth(text: string): number {
|
|
253
|
-
if (!NOT_ASCII.test(text)) {
|
|
254
|
-
return text.length;
|
|
255
|
-
}
|
|
256
|
-
let width = 0;
|
|
257
|
-
for (const c of text) {
|
|
258
|
-
if (ZERO_WIDTH.test(c)) {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
width += isWide(c.codePointAt(0)!) || EMOJI.test(c) ? 2 : 1;
|
|
262
|
-
}
|
|
263
|
-
return width;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
type Entry = [key: string, value: unknown];
|
|
267
|
-
|
|
268
|
-
/** Whether `JSON.stringify` would drop this value from an object. */
|
|
269
|
-
function omitted(value: unknown): boolean {
|
|
270
|
-
return value === undefined || typeof value === "function" || typeof value === "symbol";
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function entriesOf(value: object): Entry[] {
|
|
274
|
-
return Object.entries(value).filter(([, v]) => !omitted(v));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function isObject(value: unknown): value is Record<string, unknown> {
|
|
278
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Whether the formatter forces this array open: two or more elements, all objects with more than
|
|
283
|
-
* one key or all arrays with more than one element (Prettier's "concisely printed" rule,
|
|
284
|
-
* inverted).
|
|
285
|
-
*/
|
|
286
|
-
function forcedOpen(items: unknown[]): boolean {
|
|
287
|
-
if (items.length < 2) {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
const kind = Array.isArray(items[0]) ? "array" : isObject(items[0]) ? "object" : null;
|
|
291
|
-
if (kind === null) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
return items.every((item) =>
|
|
295
|
-
kind === "array"
|
|
296
|
-
? Array.isArray(item) && item.length > 1
|
|
297
|
-
: isObject(item) && entriesOf(item).length > 1,
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/** Two or more numbers: the formatter fills lines with them rather than stacking one per line. */
|
|
302
|
-
function isNumberRun(items: unknown[]): boolean {
|
|
303
|
-
return items.length > 1 && items.every((item) => typeof item === "number");
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/** A scalar, as `JSON.stringify` spells it — with the code units the source escaped, escaped. */
|
|
307
|
-
function scalar(value: unknown, escaped?: Set<number>): string {
|
|
308
|
-
const text = JSON.stringify(value) ?? "null";
|
|
309
|
-
return escaped === undefined
|
|
310
|
-
? text
|
|
311
|
-
: text.replaceAll(/[\u0080-\uFFFF]/g, (c) => {
|
|
312
|
-
const unit = c.codePointAt(0)!;
|
|
313
|
-
return escaped.has(unit) ? `\\u${unit.toString(16).padStart(4, "0")}` : c;
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Write a document in the layout the formatter would keep it in.
|
|
319
|
-
*
|
|
320
|
-
* `layout` is what {@link deriveJsonLayout} read from the file this document came from, or `null`
|
|
321
|
-
* for a document that has no file yet (or whose file was not JSON) — every object then expands and
|
|
322
|
-
* every array is laid by fit, which is the formatter's own answer for `JSON.stringify` output. The
|
|
323
|
-
* result ends with exactly one newline, as every formatted file does.
|
|
324
|
-
*/
|
|
325
|
-
export function serializeJson(
|
|
326
|
-
value: unknown,
|
|
327
|
-
layout: JsonLayout | null,
|
|
328
|
-
printWidth = JSON_PRINT_WIDTH,
|
|
329
|
-
): string {
|
|
330
|
-
const inline = layout?.inline ?? new Map<string, boolean>();
|
|
331
|
-
const blankAfter = layout?.blankAfter ?? new Set<string>();
|
|
332
|
-
const escaped = layout?.escaped ?? new Map<string, Set<number>>();
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Whether an object is a candidate for one line: its own record, or its parent's when it has
|
|
336
|
-
* none.
|
|
337
|
-
*/
|
|
338
|
-
const soft = (path: string, inherited: boolean): boolean => inline.get(path) ?? inherited;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* The one-line rendering, or `null` when something inside is forced open — an expanded object, a
|
|
342
|
-
* blank line, or an array the formatter always breaks — so that the break propagates outward the
|
|
343
|
-
* way the formatter's does.
|
|
344
|
-
*/
|
|
345
|
-
const flat = (v: unknown, path: string, inherited: boolean): string | null => {
|
|
346
|
-
if (Array.isArray(v)) {
|
|
347
|
-
if (v.length === 0) {
|
|
348
|
-
return "[]";
|
|
349
|
-
}
|
|
350
|
-
if (forcedOpen(v)) {
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
const parts: string[] = [];
|
|
354
|
-
for (const [index, item] of v.entries()) {
|
|
355
|
-
const member = `${path}/${index}`;
|
|
356
|
-
const part = blankAfter.has(member) ? null : flat(item, member, inherited);
|
|
357
|
-
if (part === null) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
parts.push(part);
|
|
361
|
-
}
|
|
362
|
-
return `[${parts.join(", ")}]`;
|
|
363
|
-
}
|
|
364
|
-
if (isObject(v)) {
|
|
365
|
-
const entries = entriesOf(v);
|
|
366
|
-
if (entries.length === 0) {
|
|
367
|
-
return "{}";
|
|
368
|
-
}
|
|
369
|
-
if (!soft(path, inherited)) {
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
const parts: string[] = [];
|
|
373
|
-
for (const [key, item] of entries) {
|
|
374
|
-
const member = `${path}/${segment(key)}`;
|
|
375
|
-
const part = blankAfter.has(member) ? null : flat(item, member, true);
|
|
376
|
-
if (part === null) {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
parts.push(`${JSON.stringify(key)}: ${part}`);
|
|
380
|
-
}
|
|
381
|
-
return `{ ${parts.join(", ")} }`;
|
|
382
|
-
}
|
|
383
|
-
return scalar(v, escaped.get(path));
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
/** Members one per line, with the blank lines the source had between them. */
|
|
387
|
-
const stack = (members: { path: string; text: string }[]): string =>
|
|
388
|
-
members
|
|
389
|
-
.map(({ path, text }, index) =>
|
|
390
|
-
index === members.length - 1 ? text : `${text},\n${blankAfter.has(path) ? "\n" : ""}`,
|
|
391
|
-
)
|
|
392
|
-
.join("");
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* A value at `column`, followed on its last line by `trailing` more characters (the comma a
|
|
396
|
-
* parent adds, which counts toward the width the formatter measures).
|
|
397
|
-
*/
|
|
398
|
-
const render = (
|
|
399
|
-
v: unknown,
|
|
400
|
-
path: string,
|
|
401
|
-
indent: number,
|
|
402
|
-
column: number,
|
|
403
|
-
inherited: boolean,
|
|
404
|
-
trailing: number,
|
|
405
|
-
): string => {
|
|
406
|
-
const line = flat(v, path, inherited);
|
|
407
|
-
// A scalar is never broken, however long: only a container has a second layout to fall to.
|
|
408
|
-
const container = Array.isArray(v) || isObject(v);
|
|
409
|
-
if (line !== null && (!container || column + displayWidth(line) + trailing <= printWidth)) {
|
|
410
|
-
return line;
|
|
411
|
-
}
|
|
412
|
-
const pad = " ".repeat(indent + 2);
|
|
413
|
-
const close = `\n${" ".repeat(indent)}`;
|
|
414
|
-
if (Array.isArray(v)) {
|
|
415
|
-
if (isNumberRun(v)) {
|
|
416
|
-
const blank = (index: number) => blankAfter.has(`${path}/${index}`);
|
|
417
|
-
return `[\n${fill(v, pad, printWidth, blank)}${close}]`;
|
|
418
|
-
}
|
|
419
|
-
const items = v.map((item, index) => {
|
|
420
|
-
const member = `${path}/${index}`;
|
|
421
|
-
const last = index === v.length - 1;
|
|
422
|
-
const text = render(item, member, indent + 2, pad.length, inherited, last ? 0 : 1);
|
|
423
|
-
return { path: member, text: `${pad}${text}` };
|
|
424
|
-
});
|
|
425
|
-
return `[\n${stack(items)}${close}]`;
|
|
426
|
-
}
|
|
427
|
-
const entries = entriesOf(v as object);
|
|
428
|
-
const own = soft(path, inherited);
|
|
429
|
-
const members = entries.map(([key, item], index) => {
|
|
430
|
-
const member = `${path}/${segment(key)}`;
|
|
431
|
-
const prefix = `${JSON.stringify(key)}: `;
|
|
432
|
-
const last = index === entries.length - 1;
|
|
433
|
-
const at = pad.length + displayWidth(prefix);
|
|
434
|
-
const text = render(item, member, indent + 2, at, own, last ? 0 : 1);
|
|
435
|
-
return { path: member, text: `${pad}${prefix}${text}` };
|
|
436
|
-
});
|
|
437
|
-
return `{\n${stack(members)}${close}}`;
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
return `${render(value, "", 0, 0, false, 0)}\n`;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Numbers packed onto lines greedily: the next one joins the line when it fits with its comma, and
|
|
445
|
-
* opens a new line otherwise. Each line carries `pad`. A blank line the source had after a number
|
|
446
|
-
* (`blank`) ends its line and stays, as it does between any other two members. Lengths, not
|
|
447
|
-
* {@link displayWidth}: a line of numbers and spaces is ASCII, so the two agree.
|
|
448
|
-
*/
|
|
449
|
-
function fill(
|
|
450
|
-
numbers: unknown[],
|
|
451
|
-
pad: string,
|
|
452
|
-
printWidth: number,
|
|
453
|
-
blank: (index: number) => boolean,
|
|
454
|
-
): string {
|
|
455
|
-
const lines: string[] = [];
|
|
456
|
-
let line = "";
|
|
457
|
-
for (const [index, n] of numbers.entries()) {
|
|
458
|
-
const item = `${scalar(n)}${index === numbers.length - 1 ? "" : ","}`;
|
|
459
|
-
if (line === "") {
|
|
460
|
-
line = `${pad}${item}`;
|
|
461
|
-
} else if (line.length + 1 + item.length <= printWidth) {
|
|
462
|
-
line = `${line} ${item}`;
|
|
463
|
-
} else {
|
|
464
|
-
lines.push(line);
|
|
465
|
-
line = `${pad}${item}`;
|
|
466
|
-
}
|
|
467
|
-
if (blank(index) && index < numbers.length - 1) {
|
|
468
|
-
lines.push(line, "");
|
|
469
|
-
line = "";
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
lines.push(line);
|
|
473
|
-
return lines.join("\n");
|
|
474
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ai-turn-signal.ts — what the agent loop knows that a tool needs and cannot be passed.
|
|
3
|
-
*
|
|
4
|
-
* `ToolRegistry.execute(name, args)` takes no signal, and its signature is fixed in the published
|
|
5
|
-
* `@jxsuite/ai`. So `runAgentLoop` could hand its signal to `streamChat` and to nothing else: a tool
|
|
6
|
-
* that ran for minutes (an import) could not be cancelled, and a tool that waits for a human
|
|
7
|
-
* (`ask_user`) would have hung on Stop forever, because the promise the loop is awaiting has no
|
|
8
|
-
* other way to learn the turn is over.
|
|
9
|
-
*
|
|
10
|
-
* An ambient slot rather than a parameter, for the same reason `services/ai-writes.ts` is one: the
|
|
11
|
-
* loop already brackets each turn with `beginTurn`/`endTurn` in a try/finally, and this rides that
|
|
12
|
-
* bracket. Only one turn runs at a time — `sendMessage` and `beginAssistantTurn` are both no-ops
|
|
13
|
-
* while streaming — so a module-level slot is the whole of the state.
|
|
14
|
-
*
|
|
15
|
-
* @license MIT
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
let _signal: AbortSignal | undefined;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Publish the turn's signal for the tools it will run. Called by `runAgentLoop`.
|
|
22
|
-
*
|
|
23
|
-
* @param {AbortSignal} [signal] - The turn's signal; `undefined` leaves tools uncancellable, which
|
|
24
|
-
* is what a caller that passed no signal asked for.
|
|
25
|
-
*/
|
|
26
|
-
export function beginTurnSignal(signal?: AbortSignal): void {
|
|
27
|
-
_signal = signal;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The running turn's signal, or `undefined` outside a turn.
|
|
32
|
-
*
|
|
33
|
-
* A tool must treat `undefined` as "not cancellable" rather than as an error: the evals runner and
|
|
34
|
-
* several tests drive the loop with no signal at all.
|
|
35
|
-
*
|
|
36
|
-
* @returns {AbortSignal | undefined}
|
|
37
|
-
*/
|
|
38
|
-
export function turnSignal(): AbortSignal | undefined {
|
|
39
|
-
return _signal;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Clear the slots. Called from `runAgentLoop`'s `finally`, so it runs on every exit path. */
|
|
43
|
-
export function endTurnSignal(): void {
|
|
44
|
-
_signal = undefined;
|
|
45
|
-
_toolCallId = "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let _toolCallId = "";
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Publish the id of the call about to execute. Called by `runAgentLoop` per tool call.
|
|
52
|
-
*
|
|
53
|
-
* A tool that outlives its own execution — `ask_user`, whose question stays on screen until a human
|
|
54
|
-
* answers — needs the id to join what it registered to the chip the transcript is drawing. Without
|
|
55
|
-
* it a restored, permanently unanswered question is indistinguishable from the live one.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} id
|
|
58
|
-
*/
|
|
59
|
-
export function beginToolCall(id: string): void {
|
|
60
|
-
_toolCallId = id;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The id of the tool call currently executing, or `""` outside one.
|
|
65
|
-
*
|
|
66
|
-
* @returns {string}
|
|
67
|
-
*/
|
|
68
|
-
export function currentToolCallId(): string {
|
|
69
|
-
return _toolCallId;
|
|
70
|
-
}
|