fnloom 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -5
- package/package.json +12 -11
- package/packages/build/package.json +2 -2
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/cli.ts +2 -1
- package/packages/cli/src/command.ts +2 -0
- package/packages/cli/src/commands/install.ts +103 -7
- package/packages/cli/src/commands/manage.ts +7 -5
- package/packages/cli/src/commands/store.ts +172 -0
- package/packages/cli/src/hub.ts +26 -7
- package/packages/cli/src/io.ts +1 -0
- package/packages/cli/src/testing.ts +2 -1
- package/packages/core/package.json +4 -4
- package/packages/core/src/context-files.ts +3 -1
- package/packages/core/src/context-graph.ts +4 -0
- package/packages/core/src/context-plan.ts +451 -0
- package/packages/core/src/context-questions.ts +305 -0
- package/packages/core/src/fn-facts.ts +32 -4
- package/packages/core/src/identity.ts +1 -1
- package/packages/core/src/index.ts +4 -1
- package/packages/core/src/link.ts +70 -0
- package/packages/core/src/manifest.ts +20 -1
- package/packages/core/src/model-calls.ts +11 -2
- package/packages/core/src/package.ts +10 -0
- package/packages/core/src/query.ts +3 -2
- package/packages/core/src/records/content.ts +10 -2
- package/packages/core/src/records/runs.ts +12 -0
- package/packages/core/src/records/systems.ts +87 -5
- package/packages/core/src/run.ts +5 -0
- package/packages/core/src/stores.ts +473 -0
- package/packages/core/src/suggestions.ts +3 -0
- package/packages/core/src/system-pages.ts +14 -1
- package/packages/core/src/web.ts +114 -9
- package/packages/hub/package.json +13 -12
- package/packages/hub/src/access/hits.ts +1 -1
- package/packages/hub/src/api/admin-ops.ts +36 -4
- package/packages/hub/src/api/auth.ts +8 -4
- package/packages/hub/src/api/person-ops.ts +6 -0
- package/packages/hub/src/api/store-ops.ts +54 -0
- package/packages/hub/src/api/testing/rig.ts +2 -2
- package/packages/hub/src/api/tls.ts +2 -2
- package/packages/hub/src/api/web/build5.ts +2 -1
- package/packages/hub/src/api/web/context-plans.ts +25 -0
- package/packages/hub/src/api/web/context-review.ts +43 -0
- package/packages/hub/src/api/web/index.ts +4 -0
- package/packages/hub/src/api/web/pages.ts +14 -1
- package/packages/hub/src/api/web/review.ts +16 -0
- package/packages/hub/src/api/web/systems.ts +14 -2
- package/packages/hub/src/boot/admin-fns.ts +8 -0
- package/packages/hub/src/boot/admin-secrets.ts +10 -4
- package/packages/hub/src/boot/env.ts +6 -1
- package/packages/hub/src/boot/hub-fns.ts +3 -3
- package/packages/hub/src/boot/hub-groups.ts +2 -2
- package/packages/hub/src/boot/identity.ts +1 -1
- package/packages/hub/src/boot/index.ts +9 -0
- package/packages/hub/src/boot/modules.ts +12 -3
- package/packages/hub/src/boot/person-fns.ts +5 -0
- package/packages/hub/src/boot/plan-fns.ts +39 -0
- package/packages/hub/src/boot/start.ts +2 -1
- package/packages/hub/src/catalog/catalog.ts +44 -14
- package/packages/hub/src/catalog/index.ts +6 -2
- package/packages/hub/src/chat/testing.ts +2 -2
- package/packages/hub/src/contextor/brought.ts +5 -3
- package/packages/hub/src/contextor/testing.ts +4 -4
- package/packages/hub/src/execution/create.ts +2 -0
- package/packages/hub/src/execution/env.ts +2 -0
- package/packages/hub/src/execution/errors.ts +12 -0
- package/packages/hub/src/execution/executors.ts +14 -2
- package/packages/hub/src/execution/index.ts +8 -0
- package/packages/hub/src/execution/link-handlers.ts +16 -4
- package/packages/hub/src/execution/runs.ts +212 -11
- package/packages/hub/src/execution/testing.ts +2 -1
- package/packages/hub/src/fns/search.ts +23 -4
- package/packages/hub/src/graph/graph.ts +2 -2
- package/packages/hub/src/index/index.ts +9 -2
- package/packages/hub/src/index/indexer.ts +67 -16
- package/packages/hub/src/index/search.ts +1 -0
- package/packages/hub/src/index/suggester.ts +2 -2
- package/packages/hub/src/link/build.ts +47 -10
- package/packages/hub/src/link/connections.ts +41 -3
- package/packages/hub/src/link/describer.ts +19 -2
- package/packages/hub/src/link/env.ts +10 -0
- package/packages/hub/src/link/handlers.ts +6 -0
- package/packages/hub/src/link/index.ts +16 -4
- package/packages/hub/src/link/lifecycle.ts +11 -4
- package/packages/hub/src/link/packages.ts +17 -4
- package/packages/hub/src/link/pairing.ts +2 -2
- package/packages/hub/src/link/process.ts +10 -4
- package/packages/hub/src/link/rig.ts +6 -2
- package/packages/hub/src/link/status.ts +14 -0
- package/packages/hub/src/link/supervisor.ts +17 -1
- package/packages/hub/src/link/systems.ts +16 -5
- package/packages/hub/src/models/roles.ts +74 -7
- package/packages/hub/src/query/columns.ts +4 -1
- package/packages/hub/src/query/contexts.ts +10 -3
- package/packages/hub/src/questions/apply.ts +163 -0
- package/packages/hub/src/questions/carry.ts +30 -0
- package/packages/hub/src/questions/duplicates.ts +181 -0
- package/packages/hub/src/questions/index.ts +112 -0
- package/packages/hub/src/questions/metadata.ts +142 -0
- package/packages/hub/src/questions/pending.ts +64 -0
- package/packages/hub/src/questions/plan-match.ts +79 -0
- package/packages/hub/src/questions/plan-prompts.ts +110 -0
- package/packages/hub/src/questions/planner.ts +382 -0
- package/packages/hub/src/questions/plans.ts +353 -0
- package/packages/hub/src/questions/review.ts +253 -0
- package/packages/hub/src/questions/setting.ts +50 -0
- package/packages/hub/src/questions/testing.ts +131 -0
- package/packages/hub/src/questions/worker.ts +182 -0
- package/packages/hub/src/resources/context.ts +58 -20
- package/packages/hub/src/resources/create.ts +16 -4
- package/packages/hub/src/resources/env.ts +4 -0
- package/packages/hub/src/resources/fns.ts +6 -2
- package/packages/hub/src/resources/index.ts +8 -2
- package/packages/hub/src/resources/testing.ts +18 -2
- package/packages/hub/src/store/codec.ts +23 -5
- package/packages/hub/src/store/context-status.ts +56 -0
- package/packages/hub/src/store/derived.ts +53 -0
- package/packages/hub/src/store/hybrid.ts +33 -6
- package/packages/hub/src/store/lists.ts +2 -1
- package/packages/hub/src/store/migrate-fn-names.ts +5 -2
- package/packages/hub/src/store/rows.ts +8 -1
- package/packages/hub/src/store/schema.ts +2 -1
- package/packages/hub/src/store/sqlite.ts +2 -1
- package/packages/hub/src/stores/backups.ts +163 -0
- package/packages/hub/src/stores/drivers.ts +100 -0
- package/packages/hub/src/stores/guard.ts +116 -0
- package/packages/hub/src/stores/host.ts +459 -0
- package/packages/hub/src/stores/moves.ts +380 -0
- package/packages/hub/src/stores/plugin.ts +42 -0
- package/packages/hub/src/stores/service.ts +340 -0
- package/packages/hub/src/stores/testing.ts +149 -0
- package/packages/sdk/AUTHORING.md +1813 -218
- package/packages/sdk/package.json +12 -8
- package/packages/sdk/src/build.ts +3 -0
- package/packages/sdk/src/client.ts +22 -0
- package/packages/sdk/src/ctx.ts +51 -17
- package/packages/sdk/src/declare.ts +36 -12
- package/packages/sdk/src/hub.ts +222 -10
- package/packages/sdk/src/impl.ts +3 -3
- package/packages/sdk/src/index.ts +6 -3
- package/packages/sdk/src/manifest.ts +5 -0
- package/packages/sdk/src/providers.ts +2 -2
- package/packages/sdk/src/server/asks.ts +12 -1
- package/packages/sdk/src/server/env.ts +13 -1
- package/packages/sdk/src/server/host.ts +81 -10
- package/packages/sdk/src/server/index.ts +21 -2
- package/packages/sdk/src/server/package.ts +11 -2
- package/packages/sdk/src/server/run.ts +6 -1
- package/packages/sdk/src/server/runtime.ts +78 -22
- package/packages/sdk/src/server/start-gate.ts +174 -0
- package/packages/sdk/src/server/store/checksum.ts +162 -0
- package/packages/sdk/src/server/store/engines.ts +400 -0
- package/packages/sdk/src/server/store/extend.ts +25 -0
- package/packages/sdk/src/server/store/keeper.ts +392 -0
- package/packages/sdk/src/server/store/link-driver.ts +142 -0
- package/packages/sdk/src/server/store/measure.ts +45 -0
- package/packages/sdk/src/server/store/migrations.ts +238 -0
- package/packages/sdk/src/server/store/move.ts +488 -0
- package/packages/sdk/src/server/store/portable.ts +288 -0
- package/packages/sdk/src/server/store/stable.ts +146 -0
- package/packages/sdk/src/server/store/tables.ts +28 -0
- package/packages/sdk/src/server/store/vectors.ts +185 -0
- package/packages/sdk/src/server/store/work-checks.ts +288 -0
- package/packages/sdk/src/server/store/work.ts +369 -0
- package/packages/sdk/src/server/table.ts +3 -1
- package/packages/sdk/src/server/testing.ts +116 -3
- package/packages/sdk/src/store.ts +91 -0
- package/packages/sdk/src/system.ts +58 -30
- package/packages/sdk/src/testing/hub.ts +18 -5
- package/packages/web/dist/assets/{ActorSettingsView-BuMYRDqv.js → ActorSettingsView-v2k7v454.js} +2 -2
- package/packages/web/dist/assets/{AdminLayout-sLjVTrmV.js → AdminLayout-B6Jrc_4W.js} +2 -2
- package/packages/web/dist/assets/{ApiServiceForm-BrMTU-7u.js → ApiServiceForm-CuuQgOJc.js} +2 -2
- package/packages/web/dist/assets/{ApiServiceView-BMF2zD6Q.js → ApiServiceView-7bTHSO_Z.js} +2 -2
- package/packages/web/dist/assets/{ApiServicesView-bjLAWO_j.js → ApiServicesView-BXi24n49.js} +2 -2
- package/packages/web/dist/assets/{AppPage-DSzDKCFz.js → AppPage-CFmKZS8G.js} +2 -2
- package/packages/web/dist/assets/{AutoPairPicker-nV38ALjl.js → AutoPairPicker-C61gihmh.js} +2 -2
- package/packages/web/dist/assets/{BrowserFrame-Bic7U7jN.js → BrowserFrame-Sq9EmQRT.js} +2 -2
- package/packages/web/dist/assets/{ChartVisual-DWw7WsfN.js → ChartVisual-C4mgw4wh.js} +4 -4
- package/packages/web/dist/assets/ChatPage-CAhHE03Z.js +4 -0
- package/packages/web/dist/assets/{CodeViewer-xHS3Xah9.js → CodeViewer-tUNXZB77.js} +2 -2
- package/packages/web/dist/assets/{ConfigWithCustom-DreTUdf0.js → ConfigWithCustom-D_-rY66L.js} +3 -3
- package/packages/web/dist/assets/{ConfirmDialog-DjQUzNqk.js → ConfirmDialog-Dd3E4sJt.js} +2 -2
- package/packages/web/dist/assets/{ConnectPage-CfRDrXvJ.js → ConnectPage-CX9acyQH.js} +2 -2
- package/packages/web/dist/assets/ContextItemPage-Cv4G0k_o.css +1 -0
- package/packages/web/dist/assets/ContextItemPage-rUI3-T_L.js +2 -0
- package/packages/web/dist/assets/ContextPage-C8u0UnYl.css +1 -0
- package/packages/web/dist/assets/ContextPage-CtefzyKg.js +3 -0
- package/packages/web/dist/assets/ContextRow-Chx99Xac.css +1 -0
- package/packages/web/dist/assets/ContextRow-DrtPumZ5.js +2 -0
- package/packages/web/dist/assets/{DataPage-wSIoGcb5.js → DataPage-DDSsxHro.js} +2 -2
- package/packages/web/dist/assets/DataTypePage-BW9fWaz8.js +2 -0
- package/packages/web/dist/assets/{DesignPage-DidMUX8m.js → DesignPage-6e0XbOFC.js} +2 -2
- package/packages/web/dist/assets/{ExplorePage-MUyVydVB.js → ExplorePage-B7ND0W0l.js} +2 -2
- package/packages/web/dist/assets/{FnList-CjQRwYaT.js → FnList-Bx6H-kux.js} +2 -2
- package/packages/web/dist/assets/{FnPill-BshAvm2I.js → FnPill-Cp3KuLmP.js} +2 -2
- package/packages/web/dist/assets/FnView-C0XZdnsS.js +2 -0
- package/packages/web/dist/assets/{FnsView-CeqIoaBT.js → FnsView-GTH3p7a0.js} +2 -2
- package/packages/web/dist/assets/{GinExprView-DYVUwZrd.js → GinExprView-DGxns6lH.js} +2 -2
- package/packages/web/dist/assets/{GinForm-D3mwMRTQ.js → GinForm-BDBUzuDP.js} +2 -2
- package/packages/web/dist/assets/{GinTypeView-C0YifSmE.js → GinTypeView-CUsymbVf.js} +2 -2
- package/packages/web/dist/assets/{GinValueView-HfEPq9le.js → GinValueView-jsKIfiEA.js} +2 -2
- package/packages/web/dist/assets/{GraphPage-ySnuA4Hp.js → GraphPage-BCcPPsHu.js} +2 -2
- package/packages/web/dist/assets/{GraphPanel-Cy5-KGo1.js → GraphPanel-9tztGHmu.js} +2 -2
- package/packages/web/dist/assets/{HubPicker-C_vA752L.js → HubPicker-EoOErgmk.js} +2 -2
- package/packages/web/dist/assets/{InboxApprovals-DcPCCmZ5.js → InboxApprovals-Dkq7DFp_.js} +2 -2
- package/packages/web/dist/assets/{InboxPage-C2DT2nuF.js → InboxPage-CHhslePq.js} +2 -2
- package/packages/web/dist/assets/{InjectedList-CJsEFEbz.js → InjectedList-CSWqRiON.js} +2 -2
- package/packages/web/dist/assets/InstallDialog-D-VwfZYF.js +2 -0
- package/packages/web/dist/assets/{InstallDialog-yWLZK_zN.css → InstallDialog-K-j0sdHm.css} +1 -1
- package/packages/web/dist/assets/InstanceTypes-CwVSAULg.css +1 -0
- package/packages/web/dist/assets/InstanceTypes-D3rAEiE7.js +2 -0
- package/packages/web/dist/assets/InstanceView-DoH8C-1j.js +2 -0
- package/packages/web/dist/assets/InstanceView-_9uE70tS.css +1 -0
- package/packages/web/dist/assets/{ItemHistory-CUGa8b6s.js → ItemHistory-NQAP69ma.js} +2 -2
- package/packages/web/dist/assets/LimitsView-DY2C9nYS.js +2 -0
- package/packages/web/dist/assets/ListSearch-BunVrDO0.js +2 -0
- package/packages/web/dist/assets/{LlmCallDetails-2yQftCqd.js → LlmCallDetails-BoVNDTVs.js} +2 -2
- package/packages/web/dist/assets/{LlmCallsView-DOHX3r0K.js → LlmCallsView-BGpV92RC.js} +2 -2
- package/packages/web/dist/assets/{LoadState-DeXfLvYv.js → LoadState-h-K9bTYc.js} +2 -2
- package/packages/web/dist/assets/{McpDialog-CA_0WKWF.js → McpDialog-DhOCk6_E.js} +2 -2
- package/packages/web/dist/assets/{McpServerForm-CAG8Wp2N.js → McpServerForm-Cor3fI7s.js} +2 -2
- package/packages/web/dist/assets/McpServerView-ewXRPEmZ.js +2 -0
- package/packages/web/dist/assets/McpServersView-Dd0xmfws.js +2 -0
- package/packages/web/dist/assets/{McpView-CC2oNOMa.js → McpView-GPXdCMne.js} +2 -2
- package/packages/web/dist/assets/{McpsView-CwJvyyxV.js → McpsView-DJIR2JX5.js} +2 -2
- package/packages/web/dist/assets/{MemoryDialog-Dbvh5uLq.js → MemoryDialog-BTeIHQyA.js} +2 -2
- package/packages/web/dist/assets/{ModelCallsView-RvnW3EBP.js → ModelCallsView-DMcnwF2S.js} +2 -2
- package/packages/web/dist/assets/{ModelPicker-DcjwQFHC.js → ModelPicker-CgkMFxSO.js} +2 -2
- package/packages/web/dist/assets/ModelsView-cMHygeiK.js +2 -0
- package/packages/web/dist/assets/{NotFoundPage-CeSwzTV-.js → NotFoundPage-Tk92K7HN.js} +2 -2
- package/packages/web/dist/assets/PairPage-D0BK8CCw.js +2 -0
- package/packages/web/dist/assets/PairPage-D_aPS1Ot.css +1 -0
- package/packages/web/dist/assets/{PanelHost-BkrFAnPa.js → PanelHost-C-gKrxAk.js} +2 -2
- package/packages/web/dist/assets/{PeopleView-D1QGPYp7.js → PeopleView-DRfeNWK5.js} +2 -2
- package/packages/web/dist/assets/PoliciesView-BRi-QAuo.js +2 -0
- package/packages/web/dist/assets/{RefusalList-DQoyUoPG.js → RefusalList-DVO0bmeB.js} +2 -2
- package/packages/web/dist/assets/{RemoteAuthFields-nxGWfmhf.js → RemoteAuthFields-CgiufuqQ.js} +2 -2
- package/packages/web/dist/assets/{ResourceViewer-Po24y4pj.js → ResourceViewer-Do0chYxU.js} +2 -2
- package/packages/web/dist/assets/ResourcesPage-BBx2u2mw.js +2 -0
- package/packages/web/dist/assets/{ResultGrid-uoq4yUYj.js → ResultGrid-Bj-0I5HY.js} +2 -2
- package/packages/web/dist/assets/{ReviewSummaryStrip-k3HevESg.js → ReviewSummaryStrip-DO3p64Qj.js} +2 -2
- package/packages/web/dist/assets/ReviewView-DZF9E1hb.js +3 -0
- package/packages/web/dist/assets/{RuleRow-CoXDA-SH.js → RuleRow-DX9v4iGP.js} +2 -2
- package/packages/web/dist/assets/{RunCard-CBSGdwdQ.js → RunCard-BnrtK2Yp.js} +2 -2
- package/packages/web/dist/assets/{RunDetails-CGhQQ6OI.js → RunDetails-DjR206q6.js} +2 -2
- package/packages/web/dist/assets/{RunDot-Ch_45985.js → RunDot-lHRICdM5.js} +2 -2
- package/packages/web/dist/assets/{RunPage-C_t20pB7.js → RunPage-CbAQ_WPR.js} +2 -2
- package/packages/web/dist/assets/{RunProgress-VrZUHUEC.js → RunProgress-C3-B4tQf.js} +2 -2
- package/packages/web/dist/assets/RunsView-DMkPmkqX.js +2 -0
- package/packages/web/dist/assets/ServiceRows-4WythFpF.js +2 -0
- package/packages/web/dist/assets/{ServiceRows-6BU4-MeL.css → ServiceRows-HPQ0pN6b.css} +1 -1
- package/packages/web/dist/assets/SettingsPage-BN4oSzoL.js +3 -0
- package/packages/web/dist/assets/{SignInPage-DrXZ1sG2.js → SignInPage-ByqGEZfj.js} +2 -2
- package/packages/web/dist/assets/{StatusBadge-Dpb9uG5e.js → StatusBadge-CXne0sRZ.js} +2 -2
- package/packages/web/dist/assets/StorePlacementStep-B6SwTmdM.js +2 -0
- package/packages/web/dist/assets/StorePlacementStep-D_G4e3ue.css +1 -0
- package/packages/web/dist/assets/{SystemConfig-72qKRkUk.js → SystemConfig-vQDL_eUl.js} +2 -2
- package/packages/web/dist/assets/{SystemPageHost-DLNg2FYK.js → SystemPageHost-DrMrEPyh.js} +2 -2
- package/packages/web/dist/assets/SystemView-Be6TBM4j.js +2 -0
- package/packages/web/dist/assets/{SystemView-C8ScHUe2.css → SystemView-_9q6eDfV.css} +1 -1
- package/packages/web/dist/assets/{SystemsView-B6HEL9VS.css → SystemsView-CWKnupLW.css} +1 -1
- package/packages/web/dist/assets/SystemsView-DZtT3laz.js +2 -0
- package/packages/web/dist/assets/{TableViewer-BQ7bYLOP.js → TableViewer-Boxx86f5.js} +3 -3
- package/packages/web/dist/assets/{ThemePicker-C2nJ21Vd.js → ThemePicker-CIg_oRQX.js} +2 -2
- package/packages/web/dist/assets/{TurnTree-CORdfTHj.js → TurnTree-Ecm0yA5g.js} +2 -2
- package/packages/web/dist/assets/UserMessage-BlnqZDVU.js +9 -0
- package/packages/web/dist/assets/{ValueVisual-aXEUaQ5Y.js → ValueVisual-C-MWpp7c.js} +2 -2
- package/packages/web/dist/assets/WidgetView-DX4ejNb6.js +3 -0
- package/packages/web/dist/assets/actor-names-OdvpVZeb.js +4 -0
- package/packages/web/dist/assets/{fn-modal-DqcxUhOQ.js → fn-modal-B98MR7JN.js} +2 -2
- package/packages/web/dist/assets/{fn-notices-BYaH6IoA.js → fn-notices-CfTa1E8y.js} +2 -2
- package/packages/web/dist/assets/{formats-DI__ADVG.js → formats-JwoKfXIq.js} +2 -2
- package/packages/web/dist/assets/index-6ScWTFy2.js +4 -0
- package/packages/web/dist/assets/{index-CSisx5mi.css → index-CEslGcrX.css} +1 -1
- package/packages/web/dist/assets/{labels-BhJpmLWA.js → labels-BFbk11BE.js} +2 -2
- package/packages/web/dist/assets/{layout-DQKldU13.js → layout-D1gf481r.js} +2 -2
- package/packages/web/dist/assets/{metrics-Cio5ykX6.js → metrics-CBPX3W5Y.js} +2 -2
- package/packages/web/dist/assets/{problems-BZY0Dwif.js → problems-t1E_ovSz.js} +2 -2
- package/packages/web/dist/assets/{push-payload-D5efGCzd.js → push-payload-BeU1ADYt.js} +64 -64
- package/packages/web/dist/assets/{record-edits-CveFEsal.js → record-edits-Bfsi4lU3.js} +2 -2
- package/packages/web/dist/assets/{remote-config-BkaarDf3.js → remote-config-BNQhSDzB.js} +2 -2
- package/packages/web/dist/assets/{review-CGUGvRV9.js → review-fP-l9D6H.js} +3 -3
- package/packages/web/dist/assets/routes-DV4IJpwe.js +4 -0
- package/packages/web/dist/assets/runs-CveC2kKo.js +2 -0
- package/packages/web/dist/assets/{shared-DTpYDMc_.js → shared-LbaIHjbV.js} +2 -2
- package/packages/web/dist/assets/{size-BwnshyOe.js → size-Bh__w5aI.js} +2 -2
- package/packages/web/dist/assets/{sources-Bm-TrxhL.js → sources-VPrtgLIi.js} +2 -2
- package/packages/web/dist/assets/src-CT3TeFaM.js +43 -0
- package/packages/web/dist/assets/state-xfQqaQPX.js +2 -0
- package/packages/web/dist/assets/{systems-DIp94AET.js → systems-BqE3WTSF.js} +2 -2
- package/packages/web/dist/assets/ui-BzgWquIU.js +17 -0
- package/packages/web/dist/assets/{ui-C7ZH_6oC.css → ui-DycHjPTZ.css} +1 -1
- package/packages/web/dist/assets/{url-BIg5IhGs.js → url-DKGcECT1.js} +2 -2
- package/packages/web/dist/assets/{widget-host-BCf6Tlt5.js → widget-host-B87MTaTn.js} +2 -2
- package/packages/web/dist/assets/{widgets-CrbkovMT.js → widgets-BBCuSS6E.js} +2 -2
- package/packages/web/dist/index.html +44 -44
- package/packages/web/dist/sw.js +1 -1
- package/packages/web/package.json +2 -2
- package/premade/claude.zip +0 -0
- package/premade/database.zip +0 -0
- package/premade/web.zip +0 -0
- package/scripts/run-stack.ts +3 -2
- package/scripts/stack.ts +73 -16
- package/scripts/start.ts +11 -2
- package/systems/api/package.json +3 -3
- package/systems/code/package.json +3 -3
- package/systems/embedder/package.json +1 -1
- package/systems/fs/client/fakes.ts +2 -0
- package/systems/fs/client/index.ts +4 -2
- package/systems/fs/client/machines/CoreHeatmap.vue +94 -0
- package/systems/fs/client/machines/MachineFiles.vue +121 -0
- package/systems/fs/client/machines/MachineMetrics.vue +330 -0
- package/systems/fs/client/machines/MachinesPage.vue +119 -0
- package/systems/fs/client/machines/TimeChart.vue +128 -0
- package/systems/fs/client/machines/fakes.ts +95 -0
- package/systems/fs/client/machines/files/ChangesPane.vue +90 -0
- package/systems/fs/client/machines/files/CodeView.vue +158 -0
- package/systems/fs/client/machines/files/CommentComposer.vue +86 -0
- package/systems/fs/client/machines/files/CommentThread.vue +115 -0
- package/systems/fs/client/machines/files/CommitPane.vue +80 -0
- package/systems/fs/client/machines/files/ComparePane.vue +81 -0
- package/systems/fs/client/machines/files/FileHistory.vue +89 -0
- package/systems/fs/client/machines/files/FilePane.vue +199 -0
- package/systems/fs/client/machines/files/FileTree.vue +26 -0
- package/systems/fs/client/machines/files/FolderPane.vue +154 -0
- package/systems/fs/client/machines/files/HistoryPane.vue +106 -0
- package/systems/fs/client/machines/files/ImageView.vue +160 -0
- package/systems/fs/client/machines/files/PatchView.vue +31 -0
- package/systems/fs/client/machines/files/QuickOpen.vue +67 -0
- package/systems/fs/client/machines/files/SearchPane.vue +87 -0
- package/systems/fs/client/machines/files/TreeNode.vue +72 -0
- package/systems/fs/client/machines/files/api.ts +127 -0
- package/systems/fs/client/machines/files/fake-kinds.ts +16 -0
- package/systems/fs/client/machines/files/fakes.ts +305 -0
- package/systems/fs/client/machines/files/ink.ts +117 -0
- package/systems/fs/client/machines/files/logic.ts +205 -0
- package/systems/fs/client/machines/files/state.ts +187 -0
- package/systems/fs/client/machines/files/viewers/CsvView.vue +29 -0
- package/systems/fs/client/machines/files/viewers/HexView.vue +27 -0
- package/systems/fs/client/machines/files/viewers/HtmlView.vue +17 -0
- package/systems/fs/client/machines/files/viewers/JsonNode.vue +45 -0
- package/systems/fs/client/machines/files/viewers/JsonView.vue +25 -0
- package/systems/fs/client/machines/metrics.ts +245 -0
- package/systems/fs/client/machines/palette.ts +97 -0
- package/systems/fs/client/preview/machines.ts +323 -0
- package/systems/fs/context/authoring/index.md +4 -0
- package/systems/fs/context/authoring/parts/actions.md +5 -1
- package/systems/fs/context/authoring/parts/actions.reference.md +6 -2
- package/systems/fs/context/authoring/parts/calling.md +5 -1
- package/systems/fs/context/authoring/parts/calling.reference.md +4 -0
- package/systems/fs/context/authoring/parts/client.md +9 -1
- package/systems/fs/context/authoring/parts/client.reference/client.md +4 -0
- package/systems/fs/context/authoring/parts/client.reference/resultview.md +56 -53
- package/systems/fs/context/authoring/parts/client.reference/{fnpillprops.md → textareaprops.md} +58 -4
- package/systems/fs/context/authoring/parts/client.reference.md +8 -4
- package/systems/fs/context/authoring/parts/context/questions.md +49 -0
- package/systems/fs/context/authoring/parts/context.md +23 -1
- package/systems/fs/context/authoring/parts/context.reference.md +27 -3
- package/systems/fs/context/authoring/parts/contract.md +10 -0
- package/systems/fs/context/authoring/parts/contract.reference.md +26 -9
- package/systems/fs/context/authoring/parts/core-types/access-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/admin-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/api-index-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/approvals-ts.md +11 -7
- package/systems/fs/context/authoring/parts/core-types/auto-pair-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/checks-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/claims-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/config-secrets-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/connections-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/context-files-ts.md +8 -0
- package/systems/fs/context/authoring/parts/core-types/context-graph-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/context-questions-ts.md +26 -0
- package/systems/fs/context/authoring/parts/core-types/contextdecl.md +9 -1
- package/systems/fs/context/authoring/parts/core-types/data-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/decisions-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/fn-block-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/fn-facts-ts.md +11 -0
- package/systems/fs/context/authoring/parts/core-types/gin-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/grants-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/lifecycle-ts.md +18 -5
- package/systems/fs/context/authoring/parts/core-types/link-ts.md +7 -3
- package/systems/fs/context/authoring/parts/core-types/llm-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/manifest.md +15 -2
- package/systems/fs/context/authoring/parts/core-types/manifestpatch.md +9 -1
- package/systems/fs/context/authoring/parts/core-types/mention-search-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/model-calls-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/model-names-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/modes-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/owner-runs-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/package-ts.md +9 -0
- package/systems/fs/context/authoring/parts/core-types/primitives-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/query-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-actors-ts.md +7 -3
- package/systems/fs/context/authoring/parts/core-types/records-chat-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-content-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-runs-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-systems-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/registries-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/remote-auth-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/resources-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/run-ts.md +7 -0
- package/systems/fs/context/authoring/parts/core-types/sensitivity-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/stores-ts.md +199 -0
- package/systems/fs/context/authoring/parts/core-types/system-events-ts.md +8 -1
- package/systems/fs/context/authoring/parts/core-types/system-pages-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/system-providers-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/validation-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/visuals-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/web-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/widgets-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types.md +12 -2
- package/systems/fs/context/authoring/parts/ctx/update-result.md +33 -0
- package/systems/fs/context/authoring/parts/ctx.md +11 -1
- package/systems/fs/context/authoring/parts/ctx.reference/{hubai.md → adminnotices.md} +45 -4
- package/systems/fs/context/authoring/parts/ctx.reference/fnctx.md +21 -23
- package/systems/fs/context/authoring/parts/ctx.reference.md +8 -4
- package/systems/fs/context/authoring/parts/data.md +11 -6
- package/systems/fs/context/authoring/parts/data.reference.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-findview-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-index-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-notecard-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-noteinput-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-notespage-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-reviewform-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-wordcount-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/package-json.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-env-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-impl-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-index-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-main-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-notes-test-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/shared-index-ts.md +10 -0
- package/systems/fs/context/authoring/parts/examples/system-json.md +4 -0
- package/systems/fs/context/authoring/parts/examples/{systems-fs-shared-index-ts-lines-1-189.md → systems-fs-shared-index-ts-lines-1-178.md} +23 -30
- package/systems/fs/context/authoring/parts/examples/{systems-fs-shared-index-ts-lines-190-370.md → systems-fs-shared-index-ts-lines-179-382.md} +33 -6
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-383-567.md +210 -0
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-568-660.md +117 -0
- package/systems/fs/context/authoring/parts/examples/tsconfig-json.md +5 -1
- package/systems/fs/context/authoring/parts/examples.md +18 -11
- package/systems/fs/context/authoring/parts/fns.md +5 -1
- package/systems/fs/context/authoring/parts/fns.reference/fillclaims.md +5 -1
- package/systems/fs/context/authoring/parts/fns.reference/fn.md +6 -2
- package/systems/fs/context/authoring/parts/fns.reference.md +4 -0
- package/systems/fs/context/authoring/parts/folder.md +4 -0
- package/systems/fs/context/authoring/parts/gin.md +4 -0
- package/systems/fs/context/authoring/parts/gin.reference.md +4 -0
- package/systems/fs/context/authoring/parts/handlers-progress.md +5 -1
- package/systems/fs/context/authoring/parts/handlers-progress.reference.md +4 -0
- package/systems/fs/context/authoring/parts/hooks.md +5 -1
- package/systems/fs/context/authoring/parts/hooks.reference.md +5 -1
- package/systems/fs/context/authoring/parts/hub/context-questions.md +40 -0
- package/systems/fs/context/authoring/parts/hub/{hub-run-background.md → hub-ctx-from-resource.md} +51 -56
- package/systems/fs/context/authoring/parts/hub/hub-fns-load.md +35 -42
- package/systems/fs/context/authoring/parts/hub/hub-install-package.md +327 -0
- package/systems/fs/context/authoring/parts/hub/kinds-of-hub.md +8 -0
- package/systems/fs/context/authoring/parts/hub.md +14 -8
- package/systems/fs/context/authoring/parts/hub.reference.md +9 -0
- package/systems/fs/context/authoring/parts/internals/manifestof.md +4 -0
- package/systems/fs/context/authoring/parts/internals/permissionargs.md +4 -0
- package/systems/fs/context/authoring/parts/internals/usagefromwire.md +47 -2
- package/systems/fs/context/authoring/parts/internals.md +6 -2
- package/systems/fs/context/authoring/parts/kinds-agents.md +5 -1
- package/systems/fs/context/authoring/parts/kinds-agents.reference/authoringsession.md +4 -0
- package/systems/fs/context/authoring/parts/kinds-agents.reference/kind.md +7 -3
- package/systems/fs/context/authoring/parts/kinds-agents.reference.md +4 -0
- package/systems/fs/context/authoring/parts/lifecycle.md +8 -3
- package/systems/fs/context/authoring/parts/lifecycle.reference.md +6 -2
- package/systems/fs/context/authoring/parts/mentions.md +5 -1
- package/systems/fs/context/authoring/parts/mentions.reference.md +6 -2
- package/systems/fs/context/authoring/parts/mistakes.md +7 -2
- package/systems/fs/context/authoring/parts/named-types.md +4 -0
- package/systems/fs/context/authoring/parts/named-types.reference.md +6 -2
- package/systems/fs/context/authoring/parts/outcomes.md +5 -1
- package/systems/fs/context/authoring/parts/outcomes.reference.md +4 -0
- package/systems/fs/context/authoring/parts/owner-runs.md +5 -1
- package/systems/fs/context/authoring/parts/owner-runs.reference.md +36 -11
- package/systems/fs/context/authoring/parts/packaging.md +10 -3
- package/systems/fs/context/authoring/parts/packaging.reference.md +7 -2
- package/systems/fs/context/authoring/parts/providers.md +5 -1
- package/systems/fs/context/authoring/parts/providers.reference.md +5 -1
- package/systems/fs/context/authoring/parts/remote.md +5 -1
- package/systems/fs/context/authoring/parts/remote.reference.md +4 -0
- package/systems/fs/context/authoring/parts/resources.md +5 -1
- package/systems/fs/context/authoring/parts/resources.reference.md +4 -0
- package/systems/fs/context/authoring/parts/server.md +5 -1
- package/systems/fs/context/authoring/parts/server.reference.md +41 -20
- package/systems/fs/context/authoring/parts/settings-attachments.md +5 -1
- package/systems/fs/context/authoring/parts/settings-attachments.reference.md +4 -0
- package/systems/fs/context/authoring/parts/start.md +5 -1
- package/systems/fs/context/authoring/parts/state-forms.md +5 -1
- package/systems/fs/context/authoring/parts/state-forms.reference.md +4 -0
- package/systems/fs/context/authoring/parts/store/ctx-store.md +49 -0
- package/systems/fs/context/authoring/parts/store/declare.md +32 -0
- package/systems/fs/context/authoring/parts/store/engines.md +25 -0
- package/systems/fs/context/authoring/parts/store/migrations.md +53 -0
- package/systems/fs/context/authoring/parts/store/moves.md +38 -0
- package/systems/fs/context/authoring/parts/store/placement.md +25 -0
- package/systems/fs/context/authoring/parts/store/serve.md +30 -0
- package/systems/fs/context/authoring/parts/store/store-tables.md +24 -0
- package/systems/fs/context/authoring/parts/store/vectors.md +32 -0
- package/systems/fs/context/authoring/parts/store/when-to-use.md +27 -0
- package/systems/fs/context/authoring/parts/store/work.md +37 -0
- package/systems/fs/context/authoring/parts/store.md +65 -0
- package/systems/fs/context/authoring/parts/store.reference.md +459 -0
- package/systems/fs/context/authoring/parts/testing.md +14 -1
- package/systems/fs/context/authoring/parts/testing.reference/{memoryjournal.md → equal.md} +55 -48
- package/systems/fs/context/authoring/parts/testing.reference/fakehub.md +26 -45
- package/systems/fs/context/authoring/parts/testing.reference/{toolcall.md → kindprops.md} +111 -4
- package/systems/fs/context/authoring/parts/testing.reference/openmemorystore.md +105 -0
- package/systems/fs/context/authoring/parts/testing.reference.md +16 -9
- package/systems/fs/context/authoring/parts/widgets.md +5 -1
- package/systems/fs/context/authoring/parts/widgets.reference/hub-visuals.md +4 -0
- package/systems/fs/context/authoring/parts/widgets.reference/sourcecompatible.md +4 -0
- package/systems/fs/context/authoring/parts/widgets.reference.md +4 -0
- package/systems/fs/context/authoring/topics/begin.md +4 -0
- package/systems/fs/context/authoring/topics/client.md +4 -0
- package/systems/fs/context/authoring/topics/declare.md +4 -0
- package/systems/fs/context/authoring/topics/examples.md +4 -0
- package/systems/fs/context/authoring/topics/fns.md +4 -0
- package/systems/fs/context/authoring/topics/server.md +4 -0
- package/systems/fs/context/authoring/topics/types.md +8 -1
- package/systems/fs/context/comments/answer.md +21 -0
- package/systems/fs/context/comments/find.md +23 -0
- package/systems/fs/context/comments/read.md +26 -0
- package/systems/fs/context/comments.md +23 -0
- package/systems/fs/context/files-page.md +30 -0
- package/systems/fs/context/guide/attachments.md +16 -0
- package/systems/fs/context/guide/change.md +23 -0
- package/systems/fs/context/guide/commands.md +19 -0
- package/systems/fs/context/guide/documents.md +21 -0
- package/systems/fs/context/guide/find.md +25 -0
- package/systems/fs/context/guide/paths.md +24 -0
- package/systems/fs/context/guide/read.md +21 -0
- package/systems/fs/context/machine/history.md +25 -0
- package/systems/fs/context/machine/now.md +25 -0
- package/systems/fs/context/machine/processes.md +20 -0
- package/systems/fs/context/machine/recording.md +19 -0
- package/systems/fs/context/machine.md +24 -0
- package/systems/fs/package.json +5 -3
- package/systems/fs/server/files-page/browse.ts +391 -0
- package/systems/fs/server/files-page/comments.ts +439 -0
- package/systems/fs/server/files-page/fns.ts +158 -0
- package/systems/fs/server/files-page/git-view.ts +391 -0
- package/systems/fs/server/files-page/kinds.ts +56 -0
- package/systems/fs/server/impl.ts +66 -7
- package/systems/fs/server/main.ts +20 -4
- package/systems/fs/server/metrics/collector.ts +424 -0
- package/systems/fs/server/metrics/index.ts +181 -0
- package/systems/fs/server/metrics/os.ts +144 -0
- package/systems/fs/server/metrics/parsers.ts +268 -0
- package/systems/fs/server/metrics/rrd.ts +363 -0
- package/systems/fs/server/metrics/testing.ts +80 -0
- package/systems/fs/server/snapshots.ts +216 -33
- package/systems/fs/server/testing.ts +15 -9
- package/systems/fs/shared/files-page.ts +506 -0
- package/systems/fs/shared/index.ts +137 -10
- package/systems/fs/shared/metrics.ts +179 -0
- package/systems/fs/system.json +10 -1
- package/systems/google-calendar/package.json +1 -1
- package/systems/input/package.json +3 -3
- package/systems/mcp/package.json +3 -3
- package/systems/mcp/server/oauth.ts +1 -1
- package/systems/ollama/package.json +3 -3
- package/systems/schedule/package.json +3 -4
- package/systems/schedule/server/env.ts +1 -1
- package/systems/schedule/server/fns.ts +5 -4
- package/systems/schedule/server/impl.ts +2 -2
- package/systems/schedule/server/import.ts +189 -0
- package/systems/schedule/server/index.ts +2 -0
- package/systems/schedule/server/main.ts +3 -1
- package/systems/schedule/server/placements.ts +41 -0
- package/systems/schedule/server/store.ts +159 -79
- package/systems/schedule/server/timer.ts +142 -107
- package/systems/schedule/shared/index.ts +2 -1
- package/systems/schedule/system.json +5 -1
- package/systems/schedule/tsconfig.json +1 -1
- package/systems/template/package.json +1 -1
- package/systems/widgets/package.json +3 -3
- package/packages/web/dist/assets/ChatPage-7Yebk7rl.js +0 -4
- package/packages/web/dist/assets/ContextItemPage-B6rJG3OT.js +0 -2
- package/packages/web/dist/assets/ContextItemPage-BRsWxOmu.css +0 -1
- package/packages/web/dist/assets/ContextPage-CloIZ_2y.js +0 -2
- package/packages/web/dist/assets/ContextPage-rYKxjiVI.css +0 -1
- package/packages/web/dist/assets/ContextRow-Byz_7HG-.css +0 -1
- package/packages/web/dist/assets/ContextRow-Dvv8CTFk.js +0 -2
- package/packages/web/dist/assets/DataTypePage-Ba_zBV4b.js +0 -4
- package/packages/web/dist/assets/FnView-B8MGAOoB.js +0 -2
- package/packages/web/dist/assets/InstallDialog-C9GDoUI2.js +0 -2
- package/packages/web/dist/assets/InstanceTypes-D8Jcxn70.js +0 -2
- package/packages/web/dist/assets/InstanceTypes-DAowwLB7.css +0 -1
- package/packages/web/dist/assets/InstanceView-CuBD3JPU.css +0 -1
- package/packages/web/dist/assets/InstanceView-p7tMaylE.js +0 -2
- package/packages/web/dist/assets/LimitsView-DsZG6u5P.js +0 -2
- package/packages/web/dist/assets/ListSearch-BK4p7Nxa.js +0 -2
- package/packages/web/dist/assets/McpServerView-CD8qw6W_.js +0 -2
- package/packages/web/dist/assets/McpServersView-DNycG35u.js +0 -2
- package/packages/web/dist/assets/ModelsView-C_iN19xt.js +0 -2
- package/packages/web/dist/assets/PairPage-Bs2KuRjC.css +0 -1
- package/packages/web/dist/assets/PairPage-TEXPpsqi.js +0 -2
- package/packages/web/dist/assets/PoliciesView-BU1fudNF.js +0 -2
- package/packages/web/dist/assets/ResourcesPage-YluNBqIv.js +0 -2
- package/packages/web/dist/assets/ReviewView-79Z5rU1v.js +0 -3
- package/packages/web/dist/assets/RunsView-Dz9Xsvu5.js +0 -2
- package/packages/web/dist/assets/ServiceRows-DNzDiutg.js +0 -2
- package/packages/web/dist/assets/SettingsPage-CykfuYj1.js +0 -3
- package/packages/web/dist/assets/SystemView-Es5wtkYU.js +0 -2
- package/packages/web/dist/assets/SystemsView-CeuSFhlF.js +0 -2
- package/packages/web/dist/assets/UserMessage-qyc8dG5D.js +0 -9
- package/packages/web/dist/assets/WidgetView-BZyDyYRI.js +0 -3
- package/packages/web/dist/assets/index-Bv42jNvr.js +0 -4
- package/packages/web/dist/assets/routes-qP_j74V5.js +0 -4
- package/packages/web/dist/assets/runs-k76usGfd.js +0 -2
- package/packages/web/dist/assets/src-DLK1P7oz.js +0 -43
- package/packages/web/dist/assets/state-CjE-qA2w.js +0 -2
- package/packages/web/dist/assets/ui-W12UYhVu.js +0 -17
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-371-533.md +0 -183
- package/systems/fs/context/authoring/parts/hub/hub-auto-pair-revoke.md +0 -189
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* One folder of the file tree and what is in it: folders open in place (loaded the first time), files open in the
|
|
4
|
+
* file view. Each row shows its git mark and its open comments; the open file and folder are marked.
|
|
5
|
+
*/
|
|
6
|
+
import { computed, ref } from 'vue';
|
|
7
|
+
import type { FolderEntry } from '../../../shared/files-page.ts';
|
|
8
|
+
import { MARK_WORDS } from './logic.ts';
|
|
9
|
+
import { useFiles } from './state.ts';
|
|
10
|
+
|
|
11
|
+
defineOptions({ name: 'TreeNode' });
|
|
12
|
+
const props = defineProps<{ entry: FolderEntry; depth: number }>();
|
|
13
|
+
const { state } = useFiles();
|
|
14
|
+
|
|
15
|
+
/** Folders on the way to the open folder or file start open. */
|
|
16
|
+
const startsOpen = (): boolean => {
|
|
17
|
+
const target = state.open.value || state.dir.value;
|
|
18
|
+
return props.entry.type === 'folder' && (target === props.entry.path || target.startsWith(`${props.entry.path}/`));
|
|
19
|
+
};
|
|
20
|
+
const expanded = ref(startsOpen());
|
|
21
|
+
// a refresh loads the same folders again in place, so the tree follows it
|
|
22
|
+
const children = computed(() => (expanded.value && props.entry.type === 'folder' ? state.treeFolder(props.entry.path) : undefined));
|
|
23
|
+
const current = computed(() => (props.entry.type === 'folder' ? state.dir.value === props.entry.path && state.open.value === '' : state.open.value === props.entry.path));
|
|
24
|
+
|
|
25
|
+
function choose(): void {
|
|
26
|
+
if (props.entry.type === 'folder') {
|
|
27
|
+
expanded.value = !expanded.value || !current.value;
|
|
28
|
+
state.goFolder(props.entry.path);
|
|
29
|
+
} else {
|
|
30
|
+
state.openFile(props.entry.path);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<li class="node">
|
|
37
|
+
<button
|
|
38
|
+
type="button" class="row" :class="{ current, folder: entry.type === 'folder' }" :style="{ paddingLeft: `${8 + depth * 14}px` }"
|
|
39
|
+
:aria-expanded="entry.type === 'folder' ? expanded : undefined" :aria-current="current ? 'page' : undefined" @click="choose"
|
|
40
|
+
>
|
|
41
|
+
<span class="twist" aria-hidden="true">{{ entry.type === 'folder' ? (expanded ? '▾' : '▸') : '' }}</span>
|
|
42
|
+
<span class="name">{{ entry.name }}</span>
|
|
43
|
+
<span v-if="entry.comments > 0" class="count" :title="`${entry.comments} open ${entry.comments === 1 ? 'comment' : 'comments'}`">{{ entry.comments }}</span>
|
|
44
|
+
<span v-if="entry.git" class="mark" :class="entry.git" :title="MARK_WORDS[entry.git].word">{{ MARK_WORDS[entry.git].letter }}</span>
|
|
45
|
+
</button>
|
|
46
|
+
<ul v-if="children" class="kids">
|
|
47
|
+
<li v-if="children.loading.value && !children.value.value" class="note" :style="{ paddingLeft: `${22 + depth * 14}px` }">Loading…</li>
|
|
48
|
+
<li v-else-if="children.problem.value" class="note bad" :style="{ paddingLeft: `${22 + depth * 14}px` }">{{ children.problem.value }}</li>
|
|
49
|
+
<TreeNode v-for="kid in children.value.value?.entries ?? []" :key="kid.path" :entry="kid" :depth="depth + 1" />
|
|
50
|
+
</ul>
|
|
51
|
+
</li>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<style scoped>
|
|
55
|
+
.node, .kids { list-style: none; margin: 0; padding: 0; }
|
|
56
|
+
.row {
|
|
57
|
+
display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; padding: 3px 8px; border: 0; border-radius: var(--radius-sm, 6px);
|
|
58
|
+
background: transparent; color: var(--text); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer;
|
|
59
|
+
}
|
|
60
|
+
.row:hover { background: var(--surface-2); }
|
|
61
|
+
.row.current { background: var(--accent-soft); color: var(--accent); }
|
|
62
|
+
.twist { width: 10px; flex: none; color: var(--text-dim); font-size: 10px; }
|
|
63
|
+
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
64
|
+
.folder .name { font-weight: 500; }
|
|
65
|
+
.count { flex: none; min-width: 18px; padding: 0 5px; border-radius: var(--radius-full); background: var(--accent); color: var(--on-accent, #fff); font-size: 11px; text-align: center; }
|
|
66
|
+
.mark { flex: none; width: 14px; font: 600 11px var(--mono); text-align: center; }
|
|
67
|
+
.mark.new, .mark.added { color: var(--ok); }
|
|
68
|
+
.mark.modified, .mark.renamed { color: var(--warn); }
|
|
69
|
+
.mark.deleted, .mark.conflict { color: var(--danger); }
|
|
70
|
+
.note { padding: 2px 8px; color: var(--text-dim); font-size: var(--text-xs); }
|
|
71
|
+
.note.bad { color: var(--danger); }
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the Files tab reaches the machine whose files it shows. Reads go through the hub's quiet read (`readFn`), run as
|
|
3
|
+
* the signed-in person on the fs instance picked (`on`), so the hub's access rules apply and nothing lands in a chat.
|
|
4
|
+
* Comment writes are the person's own runs (`host.runs`, in a chat named for the machine, which records them). A
|
|
5
|
+
* picture, a recording or a pdf is downloaded the way the app's own viewer does (`downloadResource`, a presigned URL).
|
|
6
|
+
* Every answer is parsed with the schemas the fns are declared with.
|
|
7
|
+
*/
|
|
8
|
+
import { InstanceName, QualifiedName, ResourceUri, jsonOf, type Json } from '@harness/core';
|
|
9
|
+
import type { PageHost, PageRuns } from '@harness/sdk';
|
|
10
|
+
import type { z } from 'zod';
|
|
11
|
+
import {
|
|
12
|
+
Blob, Comment, CommentList, CommentedFiles, CommitView, Deleted, FileDiff, FileLog, FileView, FolderView, GitStatusView,
|
|
13
|
+
PathList, PhotoAdded, RepoHistory, SearchHits, Versions, ZipFile, type Area, type CommentStatus, type Strokes,
|
|
14
|
+
} from '../../../shared/files-page.ts';
|
|
15
|
+
|
|
16
|
+
/** A search as the page asks it. */
|
|
17
|
+
export interface SearchQuery {
|
|
18
|
+
readonly query: string;
|
|
19
|
+
readonly path?: string | undefined;
|
|
20
|
+
readonly regex: boolean;
|
|
21
|
+
readonly caseSensitive: boolean;
|
|
22
|
+
readonly word: boolean;
|
|
23
|
+
readonly include?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A new comment as the page writes it. */
|
|
27
|
+
export interface NewComment {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly line?: number | undefined;
|
|
30
|
+
readonly endLine?: number | undefined;
|
|
31
|
+
readonly quote?: string | undefined;
|
|
32
|
+
readonly selected?: boolean | undefined;
|
|
33
|
+
readonly body: string;
|
|
34
|
+
readonly area?: Area | undefined;
|
|
35
|
+
readonly strokes?: Strokes | undefined;
|
|
36
|
+
/** The marked-up picture, base64. */
|
|
37
|
+
readonly markup?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A photo shrunk on the device, ready to send. */
|
|
41
|
+
export interface PhotoData { readonly mime: 'image/jpeg' | 'image/png' | 'image/webp'; readonly data: string }
|
|
42
|
+
|
|
43
|
+
/** Everything the Files tab asks of its machine. */
|
|
44
|
+
export interface FilesApi {
|
|
45
|
+
folder(path: string): Promise<FolderView>;
|
|
46
|
+
file(path: string): Promise<FileView>;
|
|
47
|
+
paths(root?: string): Promise<PathList>;
|
|
48
|
+
search(query: SearchQuery): Promise<SearchHits>;
|
|
49
|
+
zip(path: string): Promise<ZipFile>;
|
|
50
|
+
versions(paths: readonly string[]): Promise<Versions>;
|
|
51
|
+
status(root?: string): Promise<GitStatusView>;
|
|
52
|
+
diff(path: string, rev?: string, from?: string): Promise<FileDiff>;
|
|
53
|
+
log(path: string, skip: number, limit: number): Promise<FileLog>;
|
|
54
|
+
history(root: string, skip: number, limit: number, query?: string): Promise<RepoHistory>;
|
|
55
|
+
commit(root: string, rev: string): Promise<CommitView>;
|
|
56
|
+
blob(path: string, rev: string): Promise<Blob>;
|
|
57
|
+
/** A URL the browser can load a file's bytes from (a picture, a recording, a pdf). */
|
|
58
|
+
download(uri: string): Promise<{ url: string; mime: string; size: number }>;
|
|
59
|
+
comments(path: string | undefined, status: CommentStatus | 'all'): Promise<CommentList>;
|
|
60
|
+
commentedFiles(): Promise<CommentedFiles>;
|
|
61
|
+
photo(id: string): Promise<Blob>;
|
|
62
|
+
addComment(comment: NewComment): Promise<Comment>;
|
|
63
|
+
addPhoto(id: string, photo: PhotoData): Promise<void>;
|
|
64
|
+
reply(id: string, body: string): Promise<Comment>;
|
|
65
|
+
resolve(id: string, resolved: boolean): Promise<Comment>;
|
|
66
|
+
remove(id: string): Promise<boolean>;
|
|
67
|
+
/** Start a chat that opens with the comment and its lines (`fs/comment`, run there as the person's own run). */
|
|
68
|
+
sendToChat(comment: Comment, uri: string | undefined): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A qualified fs fn name. */
|
|
72
|
+
const fsFn = (name: string): QualifiedName => QualifiedName.parse(`fs/${name}`);
|
|
73
|
+
|
|
74
|
+
/** The api over the page's host, on one fs instance. */
|
|
75
|
+
export function hubFilesApi(host: PageHost, instance: string): FilesApi {
|
|
76
|
+
const on = InstanceName.parse(instance);
|
|
77
|
+
const readFn = host.hub.caller('readFn');
|
|
78
|
+
let runs: PageRuns | undefined;
|
|
79
|
+
const read = async <S extends z.ZodType>(name: string, args: Record<string, unknown>, schema: S): Promise<z.infer<S>> => {
|
|
80
|
+
const raw = await readFn.call({ fn: fsFn(name), args: jsonArgs(args), on });
|
|
81
|
+
return schema.parse(raw);
|
|
82
|
+
};
|
|
83
|
+
const write = async <S extends z.ZodType>(name: string, args: Record<string, unknown>, schema: S): Promise<z.infer<S>> => {
|
|
84
|
+
runs ??= host.runs({ title: () => `Comments on ${instance}` });
|
|
85
|
+
const outcome = await runs.run(fsFn(name), jsonOf(withoutUndefined(args)), { on });
|
|
86
|
+
if (!outcome.ok) { throw new Error(outcome.problem); }
|
|
87
|
+
return schema.parse(outcome.output);
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
folder: (path) => read('files_folder', { path }, FolderView),
|
|
91
|
+
file: (path) => read('files_file', { path }, FileView),
|
|
92
|
+
paths: (root) => read('files_paths', { root }, PathList),
|
|
93
|
+
search: (query) => read('files_search', { ...query }, SearchHits),
|
|
94
|
+
zip: (path) => read('files_zip', { path }, ZipFile),
|
|
95
|
+
versions: (paths) => read('files_versions', { paths: [...paths] }, Versions),
|
|
96
|
+
status: (root) => read('git_status', { root }, GitStatusView),
|
|
97
|
+
diff: (path, rev, from) => read('git_diff', { path, rev, from }, FileDiff),
|
|
98
|
+
log: (path, skip, limit) => read('git_log', { path, skip, limit }, FileLog),
|
|
99
|
+
history: (root, skip, limit, query) => read('git_history', { root, skip, limit, query: query === '' ? undefined : query }, RepoHistory),
|
|
100
|
+
commit: (root, rev) => read('git_commit', { root, rev }, CommitView),
|
|
101
|
+
blob: (path, rev) => read('git_blob', { path, rev }, Blob),
|
|
102
|
+
download: (uri) => host.hub.caller('downloadResource').call({ uri: ResourceUri.parse(uri) }),
|
|
103
|
+
comments: (path, status) => read('comments', { path, status, limit: 200 }, CommentList),
|
|
104
|
+
commentedFiles: () => read('commented_files', { status: 'all' }, CommentedFiles),
|
|
105
|
+
photo: (id) => read('comment_photo', { photo: id }, Blob),
|
|
106
|
+
addComment: (comment) => write('comment_add', { ...comment }, Comment),
|
|
107
|
+
addPhoto: async (id, photo) => { await write('comment_photo_add', { id, mime: photo.mime, data: photo.data }, PhotoAdded); },
|
|
108
|
+
reply: (id, body) => write('comment_reply', { id, body }, Comment),
|
|
109
|
+
resolve: (id, resolved) => write('comment_resolve', { id, resolved }, Comment),
|
|
110
|
+
remove: async (id) => (await write('comment_delete', { id }, Deleted)).deleted,
|
|
111
|
+
sendToChat: (comment, uri) => host.openChat({
|
|
112
|
+
title: `Comment on ${comment.path}`,
|
|
113
|
+
run: { fn: fsFn('comment'), args: jsonOf(withoutUndefined({ id: comment.id, uri })) },
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Args without their undefined fields, as JSON. */
|
|
119
|
+
function jsonArgs(args: Record<string, unknown>): Record<string, Json> {
|
|
120
|
+
const out: Record<string, Json> = {};
|
|
121
|
+
for (const [key, value] of Object.entries(args)) { if (value !== undefined) { out[key] = jsonOf(value); } }
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function withoutUndefined(args: Record<string, unknown>): Record<string, unknown> {
|
|
126
|
+
return Object.fromEntries(Object.entries(args).filter(([, value]) => value !== undefined));
|
|
127
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** What a fake file is, from its name alone (the real machine reads its bytes too), for the fake machine. */
|
|
2
|
+
import type { FileKind } from '../../../shared/files-page.ts';
|
|
3
|
+
|
|
4
|
+
const BY_EXTENSION: Readonly<Record<string, { kind: FileKind; mime: string; language?: string }>> = {
|
|
5
|
+
ts: { kind: 'code', mime: 'text/plain', language: 'typescript' },
|
|
6
|
+
md: { kind: 'markdown', mime: 'text/markdown', language: 'markdown' },
|
|
7
|
+
csv: { kind: 'csv', mime: 'text/csv' },
|
|
8
|
+
json: { kind: 'json', mime: 'application/json', language: 'json' },
|
|
9
|
+
png: { kind: 'image', mime: 'image/png' },
|
|
10
|
+
html: { kind: 'html', mime: 'text/html', language: 'html' },
|
|
11
|
+
bin: { kind: 'binary', mime: 'application/octet-stream' },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function kindFromName(name: string): { kind: FileKind; mime: string; language?: string } {
|
|
15
|
+
return BY_EXTENSION[name.slice(name.lastIndexOf('.') + 1).toLowerCase()] ?? { kind: 'text', mime: 'text/plain' };
|
|
16
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A machine's files in memory, for the Files tab's tests and its preview page: a small repository (code, a README, a
|
|
3
|
+
* plan, a picture, a CSV, JSON), its changes and history, and comments that are written, answered and resolved in
|
|
4
|
+
* place. Also a page host whose components are plain stand-ins, so components mount without the app.
|
|
5
|
+
*/
|
|
6
|
+
import { client } from '@ayepi/core/client';
|
|
7
|
+
import { hubWebSpec, type HubWebSpec } from '@harness/core';
|
|
8
|
+
import type { ButtonProps, HubClient, LoadStateProps, PageHost, PageRuns, SharedComponents, TextareaProps } from '@harness/sdk';
|
|
9
|
+
import { h, reactive, type FunctionalComponent } from 'vue';
|
|
10
|
+
import type { Comment, CommitLine, FileView, FolderEntry, FolderView, GitMark } from '../../../shared/files-page.ts';
|
|
11
|
+
import type { FilesApi, NewComment } from './api.ts';
|
|
12
|
+
import { kindFromName } from './fake-kinds.ts';
|
|
13
|
+
|
|
14
|
+
/** The picture in the fake repository: a drawn logo, as an SVG data URL a canvas can read back. */
|
|
15
|
+
export const LOGO_URL = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
|
|
16
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="640" height="400" viewBox="0 0 640 400"><defs><linearGradient id="g" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="#6d5dfc"/><stop offset="1" stop-color="#22c3a6"/></linearGradient></defs><rect width="640" height="400" fill="#f4f2ff"/><circle cx="220" cy="200" r="120" fill="url(#g)"/><rect x="330" y="120" width="220" height="40" rx="12" fill="#2b2a3a"/><rect x="330" y="185" width="170" height="28" rx="10" fill="#8b88a6"/><rect x="330" y="235" width="200" height="28" rx="10" fill="#c9c6dd"/></svg>',
|
|
17
|
+
)}`;
|
|
18
|
+
|
|
19
|
+
const T0 = Date.UTC(2026, 10, 27, 9, 30);
|
|
20
|
+
|
|
21
|
+
const TEXTS: Readonly<Record<string, string>> = {
|
|
22
|
+
'app/README.md': '# Shop app\n\nThe storefront and its checkout.\n\n- `src/` the app\n- `docs/` plans and notes\n\n```mermaid\nflowchart LR\n Cart --> Checkout --> Paid\n```\n',
|
|
23
|
+
'app/src/main.ts': [
|
|
24
|
+
"import { loadSettings } from './settings.ts';",
|
|
25
|
+
"import { createCart } from './cart.ts';",
|
|
26
|
+
'',
|
|
27
|
+
'/** Starts the shop: reads the settings, then opens the cart. */',
|
|
28
|
+
'export async function start(): Promise<void> {',
|
|
29
|
+
' const settings = await loadSettings();',
|
|
30
|
+
' const cart = createCart(settings.currency);',
|
|
31
|
+
" console.info('shop.started', { items: cart.size });",
|
|
32
|
+
'}',
|
|
33
|
+
'',
|
|
34
|
+
'export const VERSION = 3;',
|
|
35
|
+
].join('\n'),
|
|
36
|
+
'app/src/cart.ts': 'export function createCart(currency: string) {\n return { currency, size: 0 };\n}\n',
|
|
37
|
+
'app/docs/plan.md': '# Checkout plan\n\n1. Pay by card.\n2. Pay later.\n\nMath: $e^{i\\pi} + 1 = 0$\n',
|
|
38
|
+
'app/data/people.csv': 'name,role,city\nAda,admin,London\nGrace,member,Arlington\n"Lin, Jr.",member,Taipei\n',
|
|
39
|
+
'app/package.json': '{\n "name": "shop",\n "version": "3.0.0",\n "scripts": { "dev": "vite" },\n "dependencies": { "vue": "^3.5.0" }\n}\n',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** The tree: each folder's entries. */
|
|
43
|
+
const TREE: Readonly<Record<string, ReadonlyArray<{ name: string; type: 'file' | 'folder'; size: number; git?: GitMark }>>> = {
|
|
44
|
+
app: [
|
|
45
|
+
{ name: 'assets', type: 'folder', size: 0 }, { name: 'data', type: 'folder', size: 0 }, { name: 'docs', type: 'folder', size: 0 },
|
|
46
|
+
{ name: 'src', type: 'folder', size: 0, git: 'modified' }, { name: 'README.md', type: 'file', size: 180 }, { name: 'package.json', type: 'file', size: 120 },
|
|
47
|
+
],
|
|
48
|
+
'app/src': [{ name: 'main.ts', type: 'file', size: 420, git: 'modified' }, { name: 'cart.ts', type: 'file', size: 70, git: 'new' }],
|
|
49
|
+
'app/docs': [{ name: 'plan.md', type: 'file', size: 90 }],
|
|
50
|
+
'app/assets': [{ name: 'logo.png', type: 'file', size: 48_211, git: 'modified' }],
|
|
51
|
+
'app/data': [{ name: 'people.csv', type: 'file', size: 85 }],
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const DIFF_MAIN = [
|
|
55
|
+
'diff --git a/src/main.ts b/src/main.ts', '--- a/src/main.ts', '+++ b/src/main.ts', '@@ -3,7 +3,7 @@',
|
|
56
|
+
' ', ' /** Starts the shop: reads the settings, then opens the cart. */', ' export async function start(): Promise<void> {',
|
|
57
|
+
'- const settings = loadSettingsSync();', '+ const settings = await loadSettings();', ' const cart = createCart(settings.currency);',
|
|
58
|
+
"+ console.info('shop.started', { items: cart.size });", ' }', '',
|
|
59
|
+
].join('\n');
|
|
60
|
+
|
|
61
|
+
const COMMITS: CommitLine[] = [
|
|
62
|
+
{ hash: 'c3f2a9c1e0d4b5a6978812ab34cd56ef78901234', short: 'c3f2a9c', author: 'Ada', time: T0 - 3_600_000, subject: 'Checkout: pay later', parents: [], state: 'local' },
|
|
63
|
+
{ hash: 'b2e1d8f0aa11bb22cc33dd44ee55ff6677889900', short: 'b2e1d8f', author: 'Grace', time: T0 - 86_400_000, subject: 'Cart keeps its currency', parents: [], state: 'pushed' },
|
|
64
|
+
{ hash: 'a1d0c7e9ff00ee11dd22cc33bb44aa5566778899', short: 'a1d0c7e', author: 'Ada', time: T0 - 3 * 86_400_000, subject: 'First version of the shop', parents: [], state: 'pushed' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** The comments the fake machine starts with: a thread on lines of code, and a marked area of the picture. */
|
|
68
|
+
export function startingComments(): Comment[] {
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
id: 'c_lines', path: 'app/src/main.ts', line: 6, endLine: 7, quote: ' const settings = await loadSettings();\n const cart = createCart(settings.currency);',
|
|
72
|
+
body: 'Should the cart wait for the settings? Starting it with the default currency would show the page sooner.',
|
|
73
|
+
author: { id: 'act_ada', name: 'Ada' }, from: 'person', status: 'open', createdAt: T0 - 7_200_000, photos: [],
|
|
74
|
+
replies: [{ id: 'r_1', author: { id: 'act_ada', name: 'Ada' }, from: 'agent', body: 'It needs the currency for prices; I can start it with the saved currency and update it once the settings load.', at: T0 - 3_000_000 }],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'c_area', path: 'app/assets/logo.png', body: 'Make the circle a little smaller so the title has room.', author: { id: 'act_bob', name: 'Bob' }, from: 'person',
|
|
78
|
+
status: 'open', createdAt: T0 - 1_800_000, area: { x: 90, y: 70, w: 260, h: 260 },
|
|
79
|
+
strokes: [[0.2, 0.25, 0.3, 0.18, 0.45, 0.2, 0.52, 0.35, 0.5, 0.65, 0.4, 0.8, 0.25, 0.78, 0.16, 0.6, 0.17, 0.38, 0.2, 0.25]],
|
|
80
|
+
photos: [], replies: [],
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** A fake machine: its files, git and comments, in memory. */
|
|
86
|
+
export class FakeFilesApi implements FilesApi {
|
|
87
|
+
readonly comments_ = reactive<Comment[]>(startingComments());
|
|
88
|
+
readonly calls: Array<{ fn: string; args: unknown }> = [];
|
|
89
|
+
readonly chats: Array<{ id: string; uri: string | undefined }> = [];
|
|
90
|
+
nextId = 1;
|
|
91
|
+
|
|
92
|
+
entriesOf(path: string): FolderEntry[] {
|
|
93
|
+
const list = TREE[path] ?? [];
|
|
94
|
+
return list.map((e) => {
|
|
95
|
+
const full = `${path}/${e.name}`;
|
|
96
|
+
const comments = this.comments_.filter((c) => c.status === 'open' && (c.path === full || c.path.startsWith(`${full}/`))).length;
|
|
97
|
+
return { name: e.name, path: full, uri: `file:///work/${full}`, type: e.type, size: e.size, modifiedAt: T0 - 600_000, comments, ...(e.git === undefined ? {} : { git: e.git }) };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
folder(path: string): Promise<FolderView> {
|
|
102
|
+
this.calls.push({ fn: 'folder', args: path });
|
|
103
|
+
if (path === '') {
|
|
104
|
+
const open = this.comments_.filter((c) => c.status === 'open').length;
|
|
105
|
+
return Promise.resolve({ path: '', root: '', entries: [{ name: 'app', path: 'app', uri: 'file:///work/app', type: 'folder', size: 0, modifiedAt: T0, comments: open }], hidden: 0, truncated: false, repo: false });
|
|
106
|
+
}
|
|
107
|
+
if (TREE[path] === undefined) { return Promise.reject(new Error(`${path} isn't a folder.`)); }
|
|
108
|
+
const readme = TEXTS[`${path}/README.md`];
|
|
109
|
+
return Promise.resolve({
|
|
110
|
+
path, root: 'app', entries: this.entriesOf(path), hidden: path === 'app' ? 2 : 0, truncated: false, repo: true,
|
|
111
|
+
...(readme === undefined ? {} : { readme: { path: `${path}/README.md`, text: readme } }),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
file(path: string): Promise<FileView> {
|
|
116
|
+
this.calls.push({ fn: 'file', args: path });
|
|
117
|
+
const name = path.split('/').at(-1) ?? path;
|
|
118
|
+
const parent = path.slice(0, path.lastIndexOf('/'));
|
|
119
|
+
const entry = TREE[parent]?.find((e) => e.name === name);
|
|
120
|
+
if (entry === undefined) { return Promise.reject(new Error(`${path} doesn't exist.`)); }
|
|
121
|
+
const { kind, mime, language } = kindFromName(name);
|
|
122
|
+
const text = TEXTS[path];
|
|
123
|
+
return Promise.resolve({
|
|
124
|
+
path, uri: `file:///work/${path}`, name, kind, mime, size: entry.size, modifiedAt: T0 - 600_000, version: '1', truncated: false, repo: true,
|
|
125
|
+
...(language === undefined ? {} : { language }), ...(text === undefined ? {} : { text }), ...(entry.git === undefined ? {} : { git: entry.git }),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
paths(): Promise<{ paths: string[]; truncated: boolean }> {
|
|
130
|
+
return Promise.resolve({ paths: Object.entries(TREE).flatMap(([folder, list]) => list.filter((e) => e.type === 'file').map((e) => `${folder}/${e.name}`)), truncated: false });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
search(query: { query: string; caseSensitive: boolean }) {
|
|
134
|
+
this.calls.push({ fn: 'search', args: query });
|
|
135
|
+
const matches = Object.entries(TEXTS).flatMap(([path, text]) => text.split('\n').flatMap((line, i) => {
|
|
136
|
+
const hit = query.caseSensitive ? line.includes(query.query) : line.toLowerCase().includes(query.query.toLowerCase());
|
|
137
|
+
return hit ? [{ path, line: i + 1, text: line }] : [];
|
|
138
|
+
}));
|
|
139
|
+
return Promise.resolve({ matches, hidden: 0, truncated: false });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
zip(path: string) { return Promise.resolve({ name: `${path.split('/').at(-1) ?? 'files'}.zip`, data: 'UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==', size: 22 }); }
|
|
143
|
+
versions(paths: readonly string[]) { return Promise.resolve({ versions: paths.map((path) => ({ path, version: '1' })) }); }
|
|
144
|
+
|
|
145
|
+
status() {
|
|
146
|
+
return Promise.resolve({
|
|
147
|
+
repos: [{
|
|
148
|
+
root: 'app', branch: 'main', upstream: 'origin/main', ahead: 1, behind: 0, head: 'c3f2a9c', hidden: 1,
|
|
149
|
+
changes: [
|
|
150
|
+
{ path: 'app/src/main.ts', state: 'modified' as const, staged: false, unstaged: true, added: 2, removed: 1 },
|
|
151
|
+
{ path: 'app/src/cart.ts', state: 'new' as const, staged: false, unstaged: true, added: 3, removed: 0 },
|
|
152
|
+
{ path: 'app/assets/logo.png', state: 'modified' as const, staged: false, unstaged: true },
|
|
153
|
+
],
|
|
154
|
+
}],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
diff(path: string) {
|
|
159
|
+
const diff = path === 'app/src/main.ts' ? DIFF_MAIN : path === 'app/src/cart.ts'
|
|
160
|
+
? 'diff --git a/src/cart.ts b/src/cart.ts\nnew file mode 100644\n--- /dev/null\n+++ b/src/cart.ts\n@@ -0,0 +1,3 @@\n+export function createCart(currency: string) {\n+ return { currency, size: 0 };\n+}\n'
|
|
161
|
+
: '';
|
|
162
|
+
return Promise.resolve({ path, diff, binary: false, truncated: false });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
log(_path: string, skip: number, limit: number) { return Promise.resolve({ commits: COMMITS.slice(skip, skip + limit), more: skip + limit < COMMITS.length }); }
|
|
166
|
+
|
|
167
|
+
history() {
|
|
168
|
+
return Promise.resolve({
|
|
169
|
+
commits: COMMITS, incoming: [{ hash: 'd4a3b2c1', short: 'd4a3b2c', author: 'Grace', time: T0 - 1_200_000, subject: 'Prices in two currencies', parents: [], state: 'incoming' as const }],
|
|
170
|
+
incomingTotal: 1, localTotal: '1', more: false, remotes: true, upstream: 'origin/main',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
commit(_root: string, rev: string) {
|
|
175
|
+
const commit = COMMITS.find((c) => c.hash === rev || c.short === rev) ?? COMMITS[0];
|
|
176
|
+
if (commit === undefined) { return Promise.reject(new Error('no commit')); }
|
|
177
|
+
return Promise.resolve({ commit: { ...commit, email: 'ada@example.com', body: '' }, files: [{ path: 'app/src/main.ts', state: 'modified' as const, added: 2, removed: 1 }], hidden: 0 });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
blob() {
|
|
181
|
+
const svg = LOGO_URL.slice(LOGO_URL.indexOf(',') + 1);
|
|
182
|
+
return Promise.resolve({ mime: 'image/svg+xml', data: btoa(decodeURIComponent(svg).replace('#22c3a6', '#f59e0b')), size: 1000 });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
download(uri: string) { return Promise.resolve({ url: uri.endsWith('.png') ? LOGO_URL : 'about:blank', mime: 'image/svg+xml', size: 1000 }); }
|
|
186
|
+
|
|
187
|
+
commentsOf(path: string | undefined): Comment[] {
|
|
188
|
+
return this.comments_.filter((c) => path === undefined || c.path === path || c.path.startsWith(`${path}/`));
|
|
189
|
+
}
|
|
190
|
+
comments(path: string | undefined) { return Promise.resolve({ comments: this.commentsOf(path).map((c) => ({ ...c })), more: false }); }
|
|
191
|
+
commentedFiles() { return Promise.resolve({ files: [] }); }
|
|
192
|
+
photo() { return Promise.resolve({ mime: 'image/svg+xml', data: btoa(decodeURIComponent(LOGO_URL.slice(LOGO_URL.indexOf(',') + 1))), size: 1000 }); }
|
|
193
|
+
|
|
194
|
+
addComment(comment: NewComment): Promise<Comment> {
|
|
195
|
+
this.calls.push({ fn: 'addComment', args: comment });
|
|
196
|
+
const made: Comment = {
|
|
197
|
+
id: `c_${this.nextId++}`, path: comment.path, body: comment.body, author: { id: 'act_ada', name: 'Ada' }, from: 'person', status: 'open', createdAt: T0, photos: [], replies: [],
|
|
198
|
+
...(comment.line === undefined ? {} : { line: comment.line }), ...(comment.endLine === undefined ? {} : { endLine: comment.endLine }),
|
|
199
|
+
...(comment.quote === undefined ? {} : { quote: comment.quote }), ...(comment.selected === true ? { selected: true } : {}),
|
|
200
|
+
...(comment.area === undefined ? {} : { area: comment.area }), ...(comment.strokes === undefined ? {} : { strokes: comment.strokes }),
|
|
201
|
+
...(comment.markup === undefined ? {} : { markup: { id: `p_${this.nextId++}`, mime: 'image/png', size: comment.markup.length } }),
|
|
202
|
+
};
|
|
203
|
+
this.comments_.unshift(made);
|
|
204
|
+
return Promise.resolve(made);
|
|
205
|
+
}
|
|
206
|
+
addPhoto(id: string) {
|
|
207
|
+
this.calls.push({ fn: 'addPhoto', args: id });
|
|
208
|
+
const c = this.comments_.find((x) => x.id === id);
|
|
209
|
+
c?.photos.push({ id: `p_${this.nextId++}`, mime: 'image/jpeg', size: 1 });
|
|
210
|
+
return Promise.resolve();
|
|
211
|
+
}
|
|
212
|
+
change(id: string, change: (c: Comment) => void): Promise<Comment> {
|
|
213
|
+
const c = this.comments_.find((x) => x.id === id);
|
|
214
|
+
if (c === undefined) { return Promise.reject(new Error(`There is no comment ${id}`)); }
|
|
215
|
+
change(c);
|
|
216
|
+
return Promise.resolve({ ...c });
|
|
217
|
+
}
|
|
218
|
+
reply(id: string, body: string) { this.calls.push({ fn: 'reply', args: { id, body } }); return this.change(id, (c) => { c.replies.push({ id: `r_${this.nextId++}`, author: { id: 'act_ada', name: 'Ada' }, from: 'person', body, at: T0 }); }); }
|
|
219
|
+
resolve(id: string, resolved: boolean) { this.calls.push({ fn: 'resolve', args: { id, resolved } }); return this.change(id, (c) => { c.status = resolved ? 'resolved' : 'open'; }); }
|
|
220
|
+
remove(id: string) {
|
|
221
|
+
const at = this.comments_.findIndex((c) => c.id === id);
|
|
222
|
+
if (at >= 0) { this.comments_.splice(at, 1); }
|
|
223
|
+
return Promise.resolve(at >= 0);
|
|
224
|
+
}
|
|
225
|
+
sendToChat(comment: Comment, uri: string | undefined) { this.chats.push({ id: comment.id, uri }); return Promise.resolve(); }
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** A stand-in for one of the app's components: a plain element with its slots (a closed dialog draws none). */
|
|
229
|
+
function standIn<P extends object>(name: string, tag = 'div'): FunctionalComponent<P> {
|
|
230
|
+
const part: FunctionalComponent<P> = (props, { slots, attrs }) => {
|
|
231
|
+
const open: unknown = Reflect.get(props, 'open');
|
|
232
|
+
return h(tag, { 'data-ui': name, class: attrs['class'] }, open === false ? [] : [slots['default']?.(), slots['footer']?.()]);
|
|
233
|
+
};
|
|
234
|
+
part.displayName = `Fake${name}`;
|
|
235
|
+
return part;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** A button stand-in that clicks (and submits its form when it is a submit button). */
|
|
239
|
+
const Button: FunctionalComponent<ButtonProps, { click: [] }> = (props, { slots, emit }) =>
|
|
240
|
+
h('button', { 'data-ui': 'Button', type: props.type ?? 'button', onClick: () => { emit('click'); } }, slots['default']?.());
|
|
241
|
+
// the click is emitted once, not also passed through as an attribute
|
|
242
|
+
Button.inheritAttrs = false;
|
|
243
|
+
|
|
244
|
+
/** A text area stand-in that works with `v-model`. */
|
|
245
|
+
const Textarea: FunctionalComponent<TextareaProps, { 'update:modelValue': [value: string] }> = (props, { emit }) =>
|
|
246
|
+
h('textarea', { value: props.modelValue, onInput: (event: Event) => { const t = event.target; if (t instanceof HTMLTextAreaElement) { emit('update:modelValue', t.value); } } });
|
|
247
|
+
|
|
248
|
+
/** A load state stand-in: its slot once ready, its problem otherwise. */
|
|
249
|
+
const LoadState: FunctionalComponent<LoadStateProps> = (props, { slots }) =>
|
|
250
|
+
(props.problem !== '' ? h('p', { class: 'problem' }, props.problem) : props.ready ? h('div', slots['default']?.()) : h('p', 'Loading'));
|
|
251
|
+
|
|
252
|
+
/** The app's components as stand-ins, for mounting the tab's parts in a test. */
|
|
253
|
+
export const STAND_INS: SharedComponents = {
|
|
254
|
+
Frame: standIn('Frame'), Input: standIn('Input', 'input'), Markdown: standIn('Markdown'), Icon: standIn('Icon', 'span'), Empty: standIn('Empty'), LoadState,
|
|
255
|
+
Reasoning: standIn('Reasoning'), Typing: standIn('Typing'), ResourceViewer: standIn('ResourceViewer'), ValueEditor: standIn('ValueEditor'),
|
|
256
|
+
Button, Select: standIn('Select'), Textarea, Dialog: standIn('Dialog'), Banner: standIn('Banner'), Badge: standIn('Badge', 'span'), Skeleton: standIn('Skeleton'),
|
|
257
|
+
FnPill: standIn('FnPill'), Approval: standIn('Approval'), Conversation: standIn('Conversation'), Composer: standIn('Composer'),
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The hub's web API as a real client whose answers come from the test (`answer(endpoint, body)`), so what the tab asks
|
|
262
|
+
* is checked against the hub's own spec; each request is kept.
|
|
263
|
+
*/
|
|
264
|
+
export function fakeHub(answer: (name: string, body: unknown) => unknown = (name) => { throw new Error(`the fake hub has no ${name}`); }) {
|
|
265
|
+
const asked: Array<{ name: string; body: unknown }> = [];
|
|
266
|
+
const hub: HubClient = client<HubWebSpec>({
|
|
267
|
+
baseUrl: 'http://hub.test/api', manifest: hubWebSpec,
|
|
268
|
+
fetchImpl: async (request) => {
|
|
269
|
+
const name = new URL(request.url).pathname.split('/').filter((part) => part !== '').at(-1) ?? '';
|
|
270
|
+
const text = await request.text();
|
|
271
|
+
const body: unknown = text === '' ? undefined : JSON.parse(text);
|
|
272
|
+
asked.push({ name, body });
|
|
273
|
+
try {
|
|
274
|
+
return Response.json(answer(name, body));
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return Response.json({ error: { code: 'FAILED', message: error instanceof Error ? error.message : String(error) } }, { status: 422 });
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
return { hub, asked };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** A page host over a query kept in memory, with the components given (stand-ins by default). */
|
|
284
|
+
export function fakeHost(components: SharedComponents = STAND_INS, query: Record<string, string> = {}, more: { hub?: HubClient; runs?: (title: string) => PageRuns } = {}): PageHost & { readonly toasts: string[] } {
|
|
285
|
+
const values = reactive<Record<string, string>>({ ...query });
|
|
286
|
+
const toasts: string[] = [];
|
|
287
|
+
const unused = (what: string) => () => { throw new Error(`the Files tab doesn't use ${what} here`); };
|
|
288
|
+
return {
|
|
289
|
+
toasts,
|
|
290
|
+
user: { kind: 'user', id: 'act_ada', name: 'Ada', email: 'ada@example.com', role: 'admin' },
|
|
291
|
+
hub: more.hub ?? fakeHub().hub,
|
|
292
|
+
query: {
|
|
293
|
+
get values() { return values; },
|
|
294
|
+
get: (key) => values[key],
|
|
295
|
+
set: (patch) => { for (const [key, value] of Object.entries(patch)) { if (value === undefined || value === '') { Reflect.deleteProperty(values, key); } else { values[key] = value; } } },
|
|
296
|
+
bind: (key, fallback = '') => ({ get value() { return values[key] ?? fallback; }, set value(next: string) { values[key] = next; } }),
|
|
297
|
+
},
|
|
298
|
+
href: () => '#', chatHref: () => '#', goChat: () => undefined, runHref: () => '#', goRun: () => undefined, go: () => undefined,
|
|
299
|
+
openChat: () => Promise.resolve(), components, runs: more.runs === undefined ? unused('runs') : (options) => (more.runs ?? unused('runs'))(options.title()),
|
|
300
|
+
inbox: { byRun: () => undefined, load: () => Promise.resolve(), decide: () => Promise.resolve(false), problem: '' },
|
|
301
|
+
notify: { ok: (title) => { toasts.push(title); }, error: (title, detail) => { toasts.push(`${title}${detail === undefined ? '' : `: ${detail}`}`); } },
|
|
302
|
+
format: { cost: (usd) => `$${usd.toFixed(2)}`, relativeTime: (at, now) => `${Math.max(1, Math.round((now - at) / 60_000))}m ago`, fullTime: (at) => new Date(at).toISOString() },
|
|
303
|
+
live: () => undefined,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marking up a picture (hitl's `client/src/ink.js`): hand-drawn strokes kept as fractions (0–1) of the picture's size,
|
|
3
|
+
* the area they cover in the picture's own pixels, a copy of the picture with them drawn on, and earlier marks as SVG
|
|
4
|
+
* points. Photos picked for a comment are shrunk on the device (hitl's `photos.js`) before they are sent.
|
|
5
|
+
*/
|
|
6
|
+
import { PHOTO_SIDE_MAX, type Area, type Strokes } from '../../../shared/files-page.ts';
|
|
7
|
+
import type { PhotoData } from './api.ts';
|
|
8
|
+
|
|
9
|
+
/** The ink's colour, and the halo drawn under it so it shows on any picture. */
|
|
10
|
+
export const INK = '#ff2d55';
|
|
11
|
+
const HALO = 'rgba(255,255,255,.85)';
|
|
12
|
+
|
|
13
|
+
/** Points closer than this (as a fraction of the picture) are not added to a stroke. */
|
|
14
|
+
export const MIN_STEP = 0.002;
|
|
15
|
+
|
|
16
|
+
/** A point on a picture, as fractions of its size, clamped to it. */
|
|
17
|
+
export function pointIn(rect: { left: number; top: number; width: number; height: number }, x: number, y: number): [number, number] {
|
|
18
|
+
const fx = rect.width === 0 ? 0 : (x - rect.left) / rect.width;
|
|
19
|
+
const fy = rect.height === 0 ? 0 : (y - rect.top) / rect.height;
|
|
20
|
+
return [Math.min(1, Math.max(0, fx)), Math.min(1, Math.max(0, fy))];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The area strokes cover, with a little room, in the picture's own pixels. */
|
|
24
|
+
export function areaOf(strokes: Strokes, width: number, height: number, pad = 0.01): Area {
|
|
25
|
+
let x0 = 1, y0 = 1, x1 = 0, y1 = 0;
|
|
26
|
+
for (const stroke of strokes) {
|
|
27
|
+
for (let i = 0; i + 1 < stroke.length; i += 2) {
|
|
28
|
+
const x = stroke[i] ?? 0;
|
|
29
|
+
const y = stroke[i + 1] ?? 0;
|
|
30
|
+
x0 = Math.min(x0, x); x1 = Math.max(x1, x); y0 = Math.min(y0, y); y1 = Math.max(y1, y);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
x0 = Math.max(0, x0 - pad); y0 = Math.max(0, y0 - pad); x1 = Math.min(1, x1 + pad); y1 = Math.min(1, y1 + pad);
|
|
34
|
+
return { x: Math.round(x0 * width), y: Math.round(y0 * height), w: Math.max(1, Math.round((x1 - x0) * width)), h: Math.max(1, Math.round((y1 - y0) * height)) };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Strokes rounded to four places, as they are kept. */
|
|
38
|
+
export function rounded(strokes: Strokes): Strokes {
|
|
39
|
+
return strokes.map((stroke) => stroke.map((v) => Math.round(v * 10_000) / 10_000));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A stroke as SVG polyline points in a 0–1 box (a single point drawn as a dot). */
|
|
43
|
+
export function svgPoints(stroke: readonly number[]): string {
|
|
44
|
+
const out: string[] = [];
|
|
45
|
+
for (let i = 0; i + 1 < stroke.length; i += 2) { out.push(`${stroke[i] ?? 0},${stroke[i + 1] ?? 0}`); }
|
|
46
|
+
if (out.length === 1) { out.push(out[0] ?? '0,0'); }
|
|
47
|
+
return out.join(' ');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Draw strokes on a canvas `width` × `height`, the halo first. */
|
|
51
|
+
export function drawStrokes(g: CanvasRenderingContext2D, strokes: Strokes, width: number, height: number, line: number): void {
|
|
52
|
+
g.lineCap = 'round';
|
|
53
|
+
g.lineJoin = 'round';
|
|
54
|
+
for (const [colour, lw] of [[HALO, line * 2], [INK, line]] as const) {
|
|
55
|
+
g.strokeStyle = colour;
|
|
56
|
+
g.lineWidth = lw;
|
|
57
|
+
for (const stroke of strokes) {
|
|
58
|
+
g.beginPath();
|
|
59
|
+
g.moveTo((stroke[0] ?? 0) * width, (stroke[1] ?? 0) * height);
|
|
60
|
+
if (stroke.length === 2) { g.lineTo((stroke[0] ?? 0) * width + 0.1, (stroke[1] ?? 0) * height); }
|
|
61
|
+
for (let i = 2; i + 1 < stroke.length; i += 2) { g.lineTo((stroke[i] ?? 0) * width, (stroke[i + 1] ?? 0) * height); }
|
|
62
|
+
g.stroke();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Base64 of a data URL's bytes. */
|
|
68
|
+
function dataOf(url: string): string {
|
|
69
|
+
return url.slice(url.indexOf(',') + 1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The picture with its marks drawn on, at most `PHOTO_SIDE_MAX` px, as base64 PNG; `undefined` when the browser won't
|
|
74
|
+
* read the picture back (one from another origin).
|
|
75
|
+
*/
|
|
76
|
+
export function markedCopy(img: HTMLImageElement, strokes: Strokes): string | undefined {
|
|
77
|
+
const w0 = img.naturalWidth || img.clientWidth;
|
|
78
|
+
const h0 = img.naturalHeight || img.clientHeight;
|
|
79
|
+
const k = Math.min(1, PHOTO_SIDE_MAX / Math.max(w0, h0, 1));
|
|
80
|
+
const canvas = document.createElement('canvas');
|
|
81
|
+
canvas.width = Math.max(1, Math.round(w0 * k));
|
|
82
|
+
canvas.height = Math.max(1, Math.round(h0 * k));
|
|
83
|
+
const g = canvas.getContext('2d');
|
|
84
|
+
if (g === null) { return undefined; }
|
|
85
|
+
try {
|
|
86
|
+
g.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
87
|
+
drawStrokes(g, strokes, canvas.width, canvas.height, Math.max(3, canvas.width / 250));
|
|
88
|
+
return dataOf(canvas.toDataURL('image/png'));
|
|
89
|
+
} catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A picked photo shrunk to at most `PHOTO_SIDE_MAX` px: a small PNG screenshot stays PNG, the rest become JPEG. */
|
|
95
|
+
export async function shrinkPhoto(file: File): Promise<PhotoData & { url: string }> {
|
|
96
|
+
const url = URL.createObjectURL(file);
|
|
97
|
+
try {
|
|
98
|
+
const img = await new Promise<HTMLImageElement>((resolve, reject) => {
|
|
99
|
+
const pic = new Image();
|
|
100
|
+
pic.onload = () => { resolve(pic); };
|
|
101
|
+
pic.onerror = () => { reject(new Error('That picture couldn\'t be read.')); };
|
|
102
|
+
pic.src = url;
|
|
103
|
+
});
|
|
104
|
+
const k = Math.min(1, PHOTO_SIDE_MAX / Math.max(img.naturalWidth, img.naturalHeight, 1));
|
|
105
|
+
const canvas = document.createElement('canvas');
|
|
106
|
+
canvas.width = Math.max(1, Math.round(img.naturalWidth * k));
|
|
107
|
+
canvas.height = Math.max(1, Math.round(img.naturalHeight * k));
|
|
108
|
+
const g = canvas.getContext('2d');
|
|
109
|
+
if (g === null) { throw new Error('This browser can\'t shrink pictures.'); }
|
|
110
|
+
g.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
111
|
+
const png = file.type === 'image/png' && file.size < 1.5 * 1024 * 1024;
|
|
112
|
+
const shrunk = png ? canvas.toDataURL('image/png') : canvas.toDataURL('image/jpeg', 0.85);
|
|
113
|
+
return { mime: png ? 'image/png' : 'image/jpeg', data: dataOf(shrunk), url: shrunk };
|
|
114
|
+
} finally {
|
|
115
|
+
URL.revokeObjectURL(url);
|
|
116
|
+
}
|
|
117
|
+
}
|