@sixb/core 0.2.3 → 0.2.5
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/dist/actions/index.js +28 -28
- package/dist/agents/cancel.d.ts +1 -1
- package/dist/agents/cancel.d.ts.map +1 -1
- package/dist/agents/child-question.d.ts +35 -2
- package/dist/agents/child-question.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +35 -3
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +4 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +9 -7
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +59 -33
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/queued-turn.d.ts +16 -0
- package/dist/agents/queued-turn.d.ts.map +1 -0
- package/dist/agents/request.d.ts +79 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-after-finish.d.ts +10 -0
- package/dist/agents/run-after-finish.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +0 -38
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-events.d.ts +6 -1
- package/dist/agents/run-events.d.ts.map +1 -1
- package/dist/agents/run-session-children.d.ts +9 -0
- package/dist/agents/run-session-children.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +14 -1
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/run-turn.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +1 -1
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.js +1 -1
- package/dist/agents/streams/protocol.d.ts +16 -0
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts +1 -1
- package/dist/agents/tool-files.d.ts.map +1 -1
- package/dist/agents/tool-input-coercion.d.ts +20 -0
- package/dist/agents/tool-input-coercion.d.ts.map +1 -0
- package/dist/agents/turn-answered.d.ts +7 -0
- package/dist/agents/turn-answered.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/artifacts/canvas-display.d.ts +3 -5
- package/dist/artifacts/canvas-display.d.ts.map +1 -1
- package/dist/artifacts/comments.d.ts +14 -3
- package/dist/artifacts/comments.d.ts.map +1 -1
- package/dist/artifacts/document-fill.d.ts +18 -0
- package/dist/artifacts/document-fill.d.ts.map +1 -0
- package/dist/artifacts/errors.d.ts +1 -1
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/events.d.ts +3 -2
- package/dist/artifacts/events.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +40 -4
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +8 -1
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/document-data.d.ts +98 -0
- package/dist/artifacts/frames/document-data.d.ts.map +1 -0
- package/dist/artifacts/frames/entries.d.ts +12 -7
- package/dist/artifacts/frames/entries.d.ts.map +1 -1
- package/dist/artifacts/frames/index.d.ts +2 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +22 -13
- package/dist/artifacts/frames/index.js.map +4 -4
- package/dist/artifacts/frames/kit.d.ts +15 -0
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +65 -3
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/runtime.d.ts +32 -5
- package/dist/artifacts/frames/runtime.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +4 -2
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +35 -3
- package/dist/artifacts/index.js.map +3 -3
- package/dist/artifacts/live/blocks.d.ts +62 -0
- package/dist/artifacts/live/blocks.d.ts.map +1 -0
- package/dist/artifacts/live/board.d.ts +6 -0
- package/dist/artifacts/live/board.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +12 -0
- package/dist/artifacts/live/document.d.ts.map +1 -1
- package/dist/artifacts/live/index.d.ts +2 -0
- package/dist/artifacts/live/index.d.ts.map +1 -1
- package/dist/artifacts/live/index.js +148 -44
- package/dist/artifacts/live/index.js.map +3 -3
- package/dist/artifacts/live/page.d.ts +49 -0
- package/dist/artifacts/live/page.d.ts.map +1 -0
- package/dist/artifacts/live/protocol.d.ts +5 -0
- package/dist/artifacts/live/protocol.d.ts.map +1 -1
- package/dist/artifacts/live/server.d.ts +2 -2
- package/dist/artifacts/live/server.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +23 -19
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/live/state.d.ts +4 -1
- package/dist/artifacts/live/state.d.ts.map +1 -1
- package/dist/artifacts/outline.d.ts +16 -0
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/paper.d.ts +22 -0
- package/dist/artifacts/paper.d.ts.map +1 -0
- package/dist/artifacts/pdf-job.d.ts +9 -0
- package/dist/artifacts/pdf-job.d.ts.map +1 -0
- package/dist/artifacts/publish/fields.d.ts +25 -0
- package/dist/artifacts/publish/fields.d.ts.map +1 -0
- package/dist/artifacts/publish/index.d.ts +2 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +26 -18
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +5 -5
- package/dist/artifacts/publish/merge.d.ts.map +1 -1
- package/dist/artifacts/publish/pdf.d.ts +28 -0
- package/dist/artifacts/publish/pdf.d.ts.map +1 -0
- package/dist/artifacts/publish/previews.d.ts +12 -20
- package/dist/artifacts/publish/previews.d.ts.map +1 -1
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/queries.d.ts +6 -1
- package/dist/artifacts/publish/queries.d.ts.map +1 -1
- package/dist/artifacts/publish/query-answers.d.ts +5 -2
- package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
- package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/document.d.ts +5 -3
- package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts +16 -2
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/index.js +1 -1
- package/dist/blob-storage/index.js +1 -1
- package/dist/bootstrap/index.js +38 -38
- package/dist/{chunk-tqa68kj7.js → chunk-0hkdtwqk.js} +5 -5
- package/dist/{chunk-s5n9617r.js → chunk-0mvjpgvm.js} +5 -5
- package/dist/{chunk-k66rp2hr.js → chunk-1yh6jgtz.js} +1 -1
- package/dist/{chunk-26qet7wh.js → chunk-5t9gm5tt.js} +4 -4
- package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
- package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
- package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
- package/dist/{chunk-hkaa807g.js → chunk-68hm50qh.js} +3 -3
- package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
- package/dist/chunk-8tv3qd65.js.map +12 -0
- package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
- package/dist/{chunk-m7b9q5dk.js → chunk-aw1z0gre.js} +4 -4
- package/dist/chunk-az95tsh3.js.map +2 -2
- package/dist/{chunk-4j0sagwv.js → chunk-b4escq4c.js} +62 -14
- package/dist/{chunk-4j0sagwv.js.map → chunk-b4escq4c.js.map} +7 -7
- package/dist/chunk-bqr703h4.js +1799 -0
- package/dist/chunk-bqr703h4.js.map +13 -0
- package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
- package/dist/chunk-c29729me.js.map +12 -0
- package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
- package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
- package/dist/{chunk-3014rfjz.js → chunk-ewqn51gr.js} +25 -7
- package/dist/{chunk-3014rfjz.js.map → chunk-ewqn51gr.js.map} +3 -3
- package/dist/{chunk-7z5rkf0m.js → chunk-ey1p8w68.js} +175 -5
- package/dist/chunk-ey1p8w68.js.map +13 -0
- package/dist/{chunk-z0t4p2sk.js → chunk-fpf57gca.js} +350 -61
- package/dist/chunk-fpf57gca.js.map +47 -0
- package/dist/{chunk-kv0kvknv.js → chunk-fzae1jpq.js} +7 -7
- package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
- package/dist/chunk-fzbhybya.js.map +11 -0
- package/dist/{chunk-2by73sm2.js → chunk-gjhrz66x.js} +225 -17
- package/dist/{chunk-2by73sm2.js.map → chunk-gjhrz66x.js.map} +5 -5
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-6gtxshcc.js → chunk-k29n4176.js} +6 -6
- package/dist/{chunk-48c1z8nj.js → chunk-k3jh8gsg.js} +10 -2
- package/dist/chunk-k3jh8gsg.js.map +10 -0
- package/dist/{chunk-w9s23r24.js → chunk-m3qx2pns.js} +751 -93
- package/dist/chunk-m3qx2pns.js.map +34 -0
- package/dist/{chunk-smnt672s.js → chunk-m9ketb51.js} +20 -4
- package/dist/chunk-m9ketb51.js.map +10 -0
- package/dist/chunk-mbwsgjn7.js +40 -0
- package/dist/chunk-mbwsgjn7.js.map +11 -0
- package/dist/{chunk-sysnvjce.js → chunk-naxjka9v.js} +2 -2
- package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
- package/dist/chunk-nxysqbt0.js.map +10 -0
- package/dist/{chunk-vzkxqf8h.js → chunk-paxabbqd.js} +49 -5
- package/dist/chunk-paxabbqd.js.map +23 -0
- package/dist/{chunk-8tqnsx3q.js → chunk-pc7kra3k.js} +5 -3
- package/dist/{chunk-8tqnsx3q.js.map → chunk-pc7kra3k.js.map} +3 -3
- package/dist/{chunk-qafng88v.js → chunk-pqvvqc65.js} +4 -4
- package/dist/chunk-pvpq483h.js.map +2 -2
- package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
- package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
- package/dist/{chunk-8t2ynwg0.js → chunk-q8d9p0tb.js} +24 -1
- package/dist/{chunk-8t2ynwg0.js.map → chunk-q8d9p0tb.js.map} +3 -3
- package/dist/{chunk-wa05txmk.js → chunk-qavwr628.js} +49 -5
- package/dist/chunk-qavwr628.js.map +12 -0
- package/dist/{chunk-bkmnd7zq.js → chunk-rg725hry.js} +174 -30
- package/dist/{chunk-bkmnd7zq.js.map → chunk-rg725hry.js.map} +9 -8
- package/dist/{chunk-8p7bze4c.js → chunk-s1mqyqmm.js} +3 -3
- package/dist/{chunk-p351afzm.js → chunk-s5pj68fa.js} +2 -2
- package/dist/{chunk-855w9nvw.js → chunk-vehcr9eb.js} +1 -1
- package/dist/{chunk-qds484t8.js → chunk-vs2s3p8n.js} +932 -21
- package/dist/chunk-vs2s3p8n.js.map +20 -0
- package/dist/chunk-vtjzwymr.js.map +2 -2
- package/dist/{chunk-n68vz95m.js → chunk-wqe9shx2.js} +1 -1
- package/dist/{chunk-0k3r5kb3.js → chunk-xcrnrpfh.js} +1 -1
- package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
- package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
- package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
- package/dist/chunk-xxfj0rr2.js.map +13 -0
- package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
- package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
- package/dist/{chunk-e9w4mgdh.js → chunk-z1njfqqs.js} +589 -53
- package/dist/{chunk-e9w4mgdh.js.map → chunk-z1njfqqs.js.map} +14 -11
- package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
- package/dist/chunk-z4jqb44a.js.map +10 -0
- package/dist/{chunk-s7xqfxs9.js → chunk-zft9bzbc.js} +2 -1
- package/dist/{chunk-s7xqfxs9.js.map → chunk-zft9bzbc.js.map} +3 -3
- package/dist/{chunk-38yvdqzd.js → chunk-zxhym8tr.js} +1 -1
- package/dist/connectors/connection-handles.d.ts +9 -0
- package/dist/connectors/connection-handles.d.ts.map +1 -0
- package/dist/connectors/connections/authorizations.d.ts +9 -0
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/events.d.ts +17 -0
- package/dist/connectors/connections/events.d.ts.map +1 -0
- package/dist/connectors/connections/runs.d.ts +3 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +4 -0
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +7 -1
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +22 -1
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/write.js +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +3 -2
- package/dist/deploy/internal.js.map +3 -3
- package/dist/deploy/services.d.ts.map +1 -1
- package/dist/deploy/types.d.ts +18 -1
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/events/definitions.d.ts +4 -0
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -3
- package/dist/events/outbox-dispatcher.d.ts +7 -0
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/scope.d.ts +1 -0
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/builder.d.ts +9 -1
- package/dist/events/selectors/builder.d.ts.map +1 -1
- package/dist/events/selectors/index.d.ts +2 -2
- package/dist/events/selectors/index.d.ts.map +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/selectors/types.d.ts +18 -3
- package/dist/events/selectors/types.d.ts.map +1 -1
- package/dist/events/types/artifacts.d.ts +7 -1
- package/dist/events/types/artifacts.d.ts.map +1 -1
- package/dist/events/types/connectors.d.ts +32 -0
- package/dist/events/types/connectors.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +3 -1
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/execution/agent.js +28 -28
- package/dist/execution/authorization.d.ts +5 -0
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/primitive.js +28 -28
- package/dist/execution/request.js +29 -29
- package/dist/execution/scopes.d.ts +8 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/script.d.ts +7 -0
- package/dist/execution/script.d.ts.map +1 -0
- package/dist/execution/types.d.ts +16 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -44
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +1 -1
- package/dist/lineage/executors.d.ts +1 -1
- package/dist/lineage/executors.d.ts.map +1 -1
- package/dist/maintenance/index.js +1 -1
- package/dist/materialization/event-envelopes.d.ts +3 -3
- package/dist/materialization/event-envelopes.d.ts.map +1 -1
- package/dist/materialization/events.d.ts +6 -0
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.js +1 -1
- package/dist/materialization/model.d.ts +6 -0
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.js +13 -13
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +2 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +1 -0
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/execution/index.js +12 -12
- package/dist/models/language-model.d.ts +6 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/tools.d.ts +2 -0
- package/dist/models/tools.d.ts.map +1 -1
- package/dist/objects/index.js +28 -28
- package/dist/objects/query/index.js +12 -12
- package/dist/pipelines/index.js +18 -18
- package/dist/projections/builders.d.ts +7 -1
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +1 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.js +13 -13
- package/dist/projections/types.d.ts +10 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +2 -1
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +40 -13
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +13 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +39 -18
- package/dist/runtime/internal.js.map +4 -3
- package/dist/runtime/resolve-definitions.d.ts +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/script.d.ts +39 -0
- package/dist/runtime/script.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +2 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/schedules/builders.d.ts.map +1 -1
- package/dist/schedules/index.js +3 -3
- package/dist/schedules/runtime.d.ts.map +1 -1
- package/dist/schedules/validation.d.ts +2 -0
- package/dist/schedules/validation.d.ts.map +1 -1
- package/dist/shares/internal.js +12 -12
- package/dist/storage/agents/errors.d.ts +1 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +26 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +2 -2
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +12 -3
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +25 -5
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +156 -1
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +7 -1
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/index.d.ts +1 -1
- package/dist/storage/artifacts/index.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +2 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +34 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +3 -3
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +1 -1
- package/dist/storage/executions/types.d.ts +6 -0
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +18 -14
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +8 -6
- package/dist/storage/internal.js.map +2 -2
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/ontology/replacement-plans.d.ts +8 -0
- package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/workflow-runs/provider.js +3 -3
- package/dist/syncs/index.js +19 -19
- package/dist/testing/agent-execution.d.ts +3 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
- package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5524 -4555
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +3 -4
- package/dist/webhooks/connections.d.ts.map +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.js +16 -49
- package/dist/webhooks/internal.js.map +3 -3
- package/dist/webhooks/types.d.ts +2 -11
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
- package/dist/workflows/index.js +35 -35
- package/package.json +6 -1
- package/src/agents/README.md +6 -2
- package/src/agents/approval-outcome.ts +2 -2
- package/src/agents/cancel.ts +2 -2
- package/src/agents/child-question.ts +76 -8
- package/src/agents/execution.ts +168 -30
- package/src/agents/ids.ts +9 -1
- package/src/agents/index.ts +27 -6
- package/src/agents/model-loop.ts +3 -1
- package/src/agents/queued-turn.ts +46 -0
- package/src/agents/request.ts +517 -2
- package/src/agents/run-after-finish.ts +259 -2
- package/src/agents/run-artifacts.ts +3 -93
- package/src/agents/run-events.ts +26 -1
- package/src/agents/run-session-children.ts +33 -0
- package/src/agents/run-session-http.ts +10 -2
- package/src/agents/run-session-serve.ts +3 -8
- package/src/agents/run-session.ts +142 -3
- package/src/agents/run-turn.ts +8 -0
- package/src/agents/streams/index.ts +1 -0
- package/src/agents/streams/protocol.ts +41 -1
- package/src/agents/tool-files.ts +1 -1
- package/src/agents/tool-input-coercion.ts +140 -0
- package/src/agents/turn-answered.ts +31 -0
- package/src/agents/validation.ts +13 -3
- package/src/artifacts/canvas-display.ts +4 -6
- package/src/artifacts/comments.ts +70 -17
- package/src/artifacts/document-fill.ts +103 -0
- package/src/artifacts/errors.ts +2 -0
- package/src/artifacts/events.ts +4 -1
- package/src/artifacts/execution.ts +265 -31
- package/src/artifacts/frames/assets.ts +42 -7
- package/src/artifacts/frames/document-data.ts +353 -0
- package/src/artifacts/frames/entries.ts +22 -16
- package/src/artifacts/frames/grants.ts +2 -2
- package/src/artifacts/frames/index.ts +3 -0
- package/src/artifacts/frames/kit.ts +102 -0
- package/src/artifacts/frames/protocol.ts +96 -3
- package/src/artifacts/frames/runtime.ts +709 -19
- package/src/artifacts/index.ts +6 -0
- package/src/artifacts/live/blocks.ts +889 -0
- package/src/artifacts/live/board.ts +195 -42
- package/src/artifacts/live/document.ts +170 -5
- package/src/artifacts/live/index.ts +7 -0
- package/src/artifacts/live/page.ts +807 -0
- package/src/artifacts/live/protocol.ts +5 -0
- package/src/artifacts/live/server.ts +2 -2
- package/src/artifacts/live/state.ts +9 -4
- package/src/artifacts/outline.ts +17 -0
- package/src/artifacts/paper.ts +173 -0
- package/src/artifacts/pdf-job.ts +11 -0
- package/src/artifacts/publish/fields.ts +177 -0
- package/src/artifacts/publish/index.ts +6 -1
- package/src/artifacts/publish/merge.ts +14 -12
- package/src/artifacts/publish/pdf.ts +82 -0
- package/src/artifacts/publish/previews.ts +24 -34
- package/src/artifacts/publish/publish.ts +26 -3
- package/src/artifacts/publish/queries.ts +20 -4
- package/src/artifacts/publish/query-answers.ts +14 -3
- package/src/artifacts/publish/validate/document-html.ts +245 -0
- package/src/artifacts/publish/validate/document.ts +34 -3
- package/src/artifacts/queries.ts +59 -13
- package/src/authorization/event-visibility.ts +13 -0
- package/src/connectors/connection-handles.ts +71 -0
- package/src/connectors/connections/authorizations.ts +50 -2
- package/src/connectors/connections/events.ts +57 -0
- package/src/connectors/connections/runs.ts +5 -0
- package/src/connectors/connections/service.ts +19 -1
- package/src/connectors/execution.ts +30 -2
- package/src/connectors/index.ts +3 -0
- package/src/connectors/types.ts +29 -1
- package/src/deploy/index.ts +1 -0
- package/src/deploy/services.ts +1 -0
- package/src/deploy/types.ts +26 -1
- package/src/events/definitions.ts +14 -0
- package/src/events/execution.ts +9 -2
- package/src/events/index.ts +8 -0
- package/src/events/outbox-dispatcher.ts +12 -2
- package/src/events/scope.ts +3 -0
- package/src/events/selectors/builder.ts +49 -0
- package/src/events/selectors/index.ts +5 -0
- package/src/events/selectors/predicate.ts +2 -0
- package/src/events/selectors/types.ts +30 -1
- package/src/events/types/artifacts.ts +7 -1
- package/src/events/types/connectors.ts +36 -0
- package/src/events/types/index.ts +7 -0
- package/src/execution/authorization.ts +45 -0
- package/src/execution/durable.ts +2 -0
- package/src/execution/scopes.ts +24 -0
- package/src/execution/script.ts +27 -0
- package/src/execution/types.ts +7 -1
- package/src/http/api-routes.ts +26 -1
- package/src/index.ts +21 -2
- package/src/lineage/executors.ts +3 -1
- package/src/materialization/event-envelopes.ts +10 -5
- package/src/materialization/events.ts +2 -0
- package/src/materialization/model.ts +6 -0
- package/src/materializer/README.md +10 -0
- package/src/materializer/projections/replace.ts +42 -1
- package/src/materializer/projections/replacement-plan.ts +44 -4
- package/src/materializer/shared/normalize.ts +4 -0
- package/src/models/language-model.ts +6 -0
- package/src/models/tools.ts +2 -0
- package/src/projections/builders.ts +20 -0
- package/src/projections/index.ts +1 -0
- package/src/projections/registry.ts +1 -0
- package/src/projections/revision.ts +2 -0
- package/src/projections/types.ts +11 -0
- package/src/projections/validation.ts +6 -0
- package/src/queues/in-memory.ts +5 -0
- package/src/queues/index.ts +3 -1
- package/src/queues/types.ts +45 -14
- package/src/runtime/host.ts +112 -4
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/resolve-definitions.ts +4 -1
- package/src/runtime/script.ts +62 -0
- package/src/runtime/sixb.ts +3 -3
- package/src/schedules/builders.ts +4 -1
- package/src/schedules/runtime.ts +3 -0
- package/src/schedules/validation.ts +20 -2
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +229 -1
- package/src/storage/agents/index.ts +16 -0
- package/src/storage/agents/provider.ts +284 -2
- package/src/storage/agents/types.ts +168 -1
- package/src/storage/artifacts/in-memory.ts +32 -1
- package/src/storage/artifacts/index.ts +2 -0
- package/src/storage/artifacts/record.ts +25 -2
- package/src/storage/artifacts/types.ts +37 -0
- package/src/storage/executions/provider.ts +22 -2
- package/src/storage/executions/types.ts +2 -0
- package/src/storage/executions/validation.ts +27 -0
- package/src/storage/index.ts +18 -0
- package/src/storage/internal.ts +1 -0
- package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
- package/src/storage/ontology/replacement-plans.ts +6 -0
- package/src/storage/operation-scope.ts +1 -0
- package/src/testing/agent-execution.ts +45 -2
- package/src/testing/agent-inbox-storage-contract.ts +815 -0
- package/src/testing/agent-storage-contract.ts +103 -0
- package/src/testing/artifact-storage-contract.ts +72 -4
- package/src/testing/execution-storage-contract.ts +31 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/materializer-storage-contract.ts +139 -1
- package/src/testing/queues-contract.ts +22 -0
- package/src/webhooks/connections.ts +9 -50
- package/src/webhooks/index.ts +0 -2
- package/src/webhooks/types.ts +2 -13
- package/src/workers/queued-run-dispatch.ts +8 -1
- package/dist/chunk-48c1z8nj.js.map +0 -10
- package/dist/chunk-58geavnf.js +0 -29
- package/dist/chunk-58geavnf.js.map +0 -10
- package/dist/chunk-7z5rkf0m.js.map +0 -13
- package/dist/chunk-9nsjjd44.js.map +0 -12
- package/dist/chunk-b9qfh2ya.js.map +0 -11
- package/dist/chunk-eptrvnby.js.map +0 -12
- package/dist/chunk-f6ahf5gf.js.map +0 -13
- package/dist/chunk-m2jerfef.js +0 -474
- package/dist/chunk-m2jerfef.js.map +0 -11
- package/dist/chunk-n4zzaf6q.js.map +0 -10
- package/dist/chunk-qds484t8.js.map +0 -18
- package/dist/chunk-smnt672s.js.map +0 -10
- package/dist/chunk-vzkxqf8h.js.map +0 -23
- package/dist/chunk-w9s23r24.js.map +0 -30
- package/dist/chunk-wa05txmk.js.map +0 -11
- package/dist/chunk-yv8hv4wq.js.map +0 -10
- package/dist/chunk-z0t4p2sk.js.map +0 -47
- /package/dist/{chunk-tqa68kj7.js.map → chunk-0hkdtwqk.js.map} +0 -0
- /package/dist/{chunk-s5n9617r.js.map → chunk-0mvjpgvm.js.map} +0 -0
- /package/dist/{chunk-k66rp2hr.js.map → chunk-1yh6jgtz.js.map} +0 -0
- /package/dist/{chunk-26qet7wh.js.map → chunk-5t9gm5tt.js.map} +0 -0
- /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
- /package/dist/{chunk-hkaa807g.js.map → chunk-68hm50qh.js.map} +0 -0
- /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
- /package/dist/{chunk-m7b9q5dk.js.map → chunk-aw1z0gre.js.map} +0 -0
- /package/dist/{chunk-kv0kvknv.js.map → chunk-fzae1jpq.js.map} +0 -0
- /package/dist/{chunk-6gtxshcc.js.map → chunk-k29n4176.js.map} +0 -0
- /package/dist/{chunk-sysnvjce.js.map → chunk-naxjka9v.js.map} +0 -0
- /package/dist/{chunk-qafng88v.js.map → chunk-pqvvqc65.js.map} +0 -0
- /package/dist/{chunk-8p7bze4c.js.map → chunk-s1mqyqmm.js.map} +0 -0
- /package/dist/{chunk-p351afzm.js.map → chunk-s5pj68fa.js.map} +0 -0
- /package/dist/{chunk-855w9nvw.js.map → chunk-vehcr9eb.js.map} +0 -0
- /package/dist/{chunk-n68vz95m.js.map → chunk-wqe9shx2.js.map} +0 -0
- /package/dist/{chunk-0k3r5kb3.js.map → chunk-xcrnrpfh.js.map} +0 -0
- /package/dist/{chunk-38yvdqzd.js.map → chunk-zxhym8tr.js.map} +0 -0
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DocumentData,
|
|
3
|
+
DocumentQueryResult,
|
|
4
|
+
DocumentReads,
|
|
5
|
+
DocumentTree,
|
|
6
|
+
} from "./document-data"
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* The runtime the frame injects before anything else in an entry's `<head>`. It is served as this
|
|
3
|
-
* function's own source, `(${frameRuntime})()`, so it imports nothing
|
|
4
|
-
* itself: the protocol string and the keys repeat what `protocol.ts`
|
|
5
|
-
* the two together. Its tag names the layout, `data-sixb-layout`.
|
|
10
|
+
* function's own source, `(${frameRuntime})(${documentData})`, so it imports nothing but types and
|
|
11
|
+
* names nothing outside itself: the protocol string and the keys repeat what `protocol.ts`
|
|
12
|
+
* declares, and a test holds the two together. Its tag names the layout, `data-sixb-layout`.
|
|
6
13
|
*
|
|
7
14
|
* In every layout it applies the theme the app sends, then fires `sixb:theme` on the window for
|
|
8
15
|
* what draws its own colors; answers the app's requests; and tells the app about the links the
|
|
@@ -14,6 +21,20 @@
|
|
|
14
21
|
* the app about keys and picks in the overview. A page scrolls as it is: it reports the embeds
|
|
15
22
|
* near its view as it scrolls, and its height as it changes.
|
|
16
23
|
*
|
|
24
|
+
* A designed document scrolls as a page does, as one sheet of its paper (`data-sixb-paper`). With
|
|
25
|
+
* `sixb-pages` it is cut into pages instead, once its fonts and images have loaded: its content
|
|
26
|
+
* goes into a flow laid out in columns as wide and tall as the paper's content box, a forced page
|
|
27
|
+
* break becomes a column break, and each column shows on a sheet of its own. The first sheet keeps
|
|
28
|
+
* the original, which is what assistive technology reads; a sheet in view, or next to one, holds
|
|
29
|
+
* a copy of it, made as it comes near and dropped once it is far. It reports how many pages it
|
|
30
|
+
* made. `sixb-section=<slug>` opens it at the heading publishing named so.
|
|
31
|
+
*
|
|
32
|
+
* Its fields and repeated elements show live data, as `documentData`, which the runtime is given,
|
|
33
|
+
* walks them: once it has read the object that holds the document and the queries they name, as
|
|
34
|
+
* the reader, from the document as published, before it is cut into pages; and again, cut anew,
|
|
35
|
+
* whenever one of those changes. Opened on its own, it reads them as `sixb.query` does. Served for
|
|
36
|
+
* editing, it shows what is written in them, which takes no typing.
|
|
37
|
+
*
|
|
17
38
|
* It gives every layout `window.sixb.state`, where a page keeps JSON values for its reader: each
|
|
18
39
|
* call is a message the app answers, and the app keeps the values. Opened on its own, with no app
|
|
19
40
|
* around it, as the layout check opens a page, the values live in memory until it closes.
|
|
@@ -35,10 +56,24 @@
|
|
|
35
56
|
* a script rewrote, is reported as scripted and takes nothing. What others change arrives as
|
|
36
57
|
* patches, element by element; the one the reader is typing in takes its own once they leave it,
|
|
37
58
|
* so their caret stays. What editing reports goes through the port the app hands over with its
|
|
38
|
-
* first `edit` request, taken before the page's scripts run: they cannot post on it.
|
|
59
|
+
* first `edit` request, taken before the page's scripts run: they cannot post on it. Once it holds
|
|
60
|
+
* that port, the frame also sends the reader's pinches, ⌘-wheel turns and ⌘ +, − and 0 through
|
|
61
|
+
* it, for the app to zoom the opened board instead of the browser zooming everything.
|
|
62
|
+
*
|
|
63
|
+
* A board running on the canvas is handed its port with `canvas` instead: the reader uses its page
|
|
64
|
+
* in place, and the frame sends through the port what moves the canvas, their wheel turns unless
|
|
65
|
+
* the page scrolls them, a finger's drag, Space held to drag, and the zooming above, and the words
|
|
66
|
+
* of what they press, for the canvas to follow the arrow they label.
|
|
67
|
+
*
|
|
68
|
+
* A designed document served for editing may be handed its editor with `editor`: the script the
|
|
69
|
+
* app sends runs once, leaving a start function the runtime takes at once, and is handed the port
|
|
70
|
+
* that came with the request and the body, which it edits in place. From then on a click on a link
|
|
71
|
+
* places the caret rather than following it.
|
|
39
72
|
*/
|
|
40
|
-
export function frameRuntime(): void {
|
|
73
|
+
export function frameRuntime(data?: () => DocumentData): void {
|
|
41
74
|
const PROTOCOL = "sixb-frame/1"
|
|
75
|
+
/** Where the editor's script leaves its start, as the app's frame editor names it. */
|
|
76
|
+
const EDITOR_GLOBAL = "__sixbFrameEditor"
|
|
42
77
|
const WIDTH = 1280
|
|
43
78
|
const HEIGHT = 720
|
|
44
79
|
const KEYS = [
|
|
@@ -81,15 +116,43 @@ export function frameRuntime(): void {
|
|
|
81
116
|
"[data-sixb-commenting] [data-sixb-hover] { outline: 2px dashed #0a84ff; outline-offset: 3px; }",
|
|
82
117
|
"[data-sixb-commenting] [data-sixb-picked] { outline: 2px solid #0a84ff; outline-offset: 3px; }",
|
|
83
118
|
].join(" ")
|
|
119
|
+
/**
|
|
120
|
+
* A board running on the canvas: the page takes no touch gesture of its own, which the canvas
|
|
121
|
+
* takes instead, and its scrolling never carries on to the app around it.
|
|
122
|
+
*/
|
|
123
|
+
const CANVAS_CSS =
|
|
124
|
+
"html { overscroll-behavior: none; } html, html * { touch-action: none !important; }"
|
|
84
125
|
const root = document.documentElement
|
|
85
126
|
// Only set while the runtime itself runs, so kept for what reads it later.
|
|
86
127
|
const script = document.currentScript as HTMLScriptElement | null
|
|
87
|
-
const
|
|
128
|
+
const layout = script?.getAttribute("data-sixb-layout") ?? "deck"
|
|
129
|
+
const deck = layout === "deck"
|
|
130
|
+
const designed = layout === "document"
|
|
88
131
|
const start = new URLSearchParams(window.location.hash.slice(1))
|
|
89
132
|
if (deck) {
|
|
90
133
|
root.classList.add("sixb-deck")
|
|
91
134
|
root.dataset.mode = start.has("sixb-fill") ? "fill" : "slide"
|
|
92
135
|
}
|
|
136
|
+
/** A designed document's paper, `[width, height, top, right, bottom, left]` in pixels. */
|
|
137
|
+
const paper = (script?.getAttribute("data-sixb-paper") ?? "")
|
|
138
|
+
.split(" ")
|
|
139
|
+
.map(Number)
|
|
140
|
+
.filter((value) => Number.isFinite(value) && value >= 0)
|
|
141
|
+
const hasPaper = paper.length === 6 && (paper[0] ?? 0) > 0 && (paper[1] ?? 0) > 0
|
|
142
|
+
const paged = designed && hasPaper && start.has("sixb-pages")
|
|
143
|
+
if (designed) {
|
|
144
|
+
root.classList.add("sixb-document")
|
|
145
|
+
if (hasPaper) {
|
|
146
|
+
const [width, height, top, right, bottom, left] = paper
|
|
147
|
+
root.style.setProperty("--sixb-paper-width", `${width}px`)
|
|
148
|
+
root.style.setProperty("--sixb-paper-height", `${height}px`)
|
|
149
|
+
root.style.setProperty("--sixb-paper-margin-top", `${top}px`)
|
|
150
|
+
root.style.setProperty("--sixb-paper-margin-right", `${right}px`)
|
|
151
|
+
root.style.setProperty("--sixb-paper-margin-bottom", `${bottom}px`)
|
|
152
|
+
root.style.setProperty("--sixb-paper-margin-left", `${left}px`)
|
|
153
|
+
}
|
|
154
|
+
if (paged) root.classList.add("sixb-pages")
|
|
155
|
+
}
|
|
93
156
|
let current = Number(start.get("sixb-slide")) || 1
|
|
94
157
|
|
|
95
158
|
const slides = (): HTMLElement[] =>
|
|
@@ -169,7 +232,8 @@ export function frameRuntime(): void {
|
|
|
169
232
|
(element) => {
|
|
170
233
|
const id = idOf(element)
|
|
171
234
|
const rect = element.getBoundingClientRect()
|
|
172
|
-
|
|
235
|
+
// Cut into pages, every page holds every embed: only the one its page shows counts.
|
|
236
|
+
return near(rect) && (!paged || shownOnItsPage(element))
|
|
173
237
|
? [
|
|
174
238
|
{
|
|
175
239
|
id,
|
|
@@ -188,6 +252,191 @@ export function frameRuntime(): void {
|
|
|
188
252
|
})
|
|
189
253
|
}
|
|
190
254
|
|
|
255
|
+
// ── A designed document's pages ─────────────────────────────────────
|
|
256
|
+
|
|
257
|
+
/** Break values that start a new page, each a column break in the flow. */
|
|
258
|
+
const PAGE_BREAKS = ["page", "left", "right", "recto", "verso"]
|
|
259
|
+
/** Between columns of the flow, so nothing on one page bleeds into the next. */
|
|
260
|
+
const COLUMN_GAP = 64
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Whether an element in a page's copy of the flow is on that page: inside its content box, which
|
|
264
|
+
* clips the rest. Anything not in a page is shown.
|
|
265
|
+
*/
|
|
266
|
+
const shownOnItsPage = (element: Element): boolean => {
|
|
267
|
+
const box = element.closest(".sixb-paper-content")
|
|
268
|
+
if (!box) return true
|
|
269
|
+
const rect = element.getBoundingClientRect()
|
|
270
|
+
const page = box.getBoundingClientRect()
|
|
271
|
+
return (
|
|
272
|
+
rect.right > page.left &&
|
|
273
|
+
rect.left < page.right &&
|
|
274
|
+
rect.bottom > page.top &&
|
|
275
|
+
rect.top < page.bottom
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** How many sheets on each side of one in view hold their copy of the flow too. */
|
|
280
|
+
const NEAR_PAGES = 1
|
|
281
|
+
|
|
282
|
+
/** The flow the first sheet holds, the document as published; null until it is cut. */
|
|
283
|
+
let flow: HTMLElement | null = null
|
|
284
|
+
/** How far apart the flow's columns are, one a page. */
|
|
285
|
+
let stride = 0
|
|
286
|
+
/** Which sheets are in view, which keeps a copy of the flow in each sheet near them. */
|
|
287
|
+
let sheetsInView: IntersectionObserver | null = null
|
|
288
|
+
|
|
289
|
+
/** The sheet of page `index`'s copy of the flow, made if it has none: moved to show its column. */
|
|
290
|
+
const pageCopy = (index: number): Element | null => {
|
|
291
|
+
if (index === 0 || !flow) return flow
|
|
292
|
+
const content = document.querySelector(`.sixb-paper[data-page="${index + 1}"] > div`)
|
|
293
|
+
if (!content) return null
|
|
294
|
+
if (content.firstElementChild) return content.firstElementChild
|
|
295
|
+
const copy = flow.cloneNode(true) as HTMLElement
|
|
296
|
+
copy.style.transform = `translateX(${-index * stride}px)`
|
|
297
|
+
copy.setAttribute("aria-hidden", "true")
|
|
298
|
+
copy.inert = true
|
|
299
|
+
content.append(copy)
|
|
300
|
+
return copy
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** What a selector finds where a reader sees it: cut into pages, the copy on the page it is on. */
|
|
304
|
+
const shownCopy = (selector: string): Element | null => {
|
|
305
|
+
const found = (flow ?? document).querySelector(selector)
|
|
306
|
+
if (!found || !flow) return found
|
|
307
|
+
// Its first fragment's column, which is its page.
|
|
308
|
+
const box = flow.getBoundingClientRect()
|
|
309
|
+
const scale = box.width / flow.offsetWidth || 1
|
|
310
|
+
const left = (found.getClientRects()[0] ?? found.getBoundingClientRect()).left
|
|
311
|
+
const copy = pageCopy(Math.max(0, Math.floor((left - box.left) / scale / stride)))
|
|
312
|
+
if (!copy || copy === flow) return found
|
|
313
|
+
// The same element in the copy, by where it sits in the flow.
|
|
314
|
+
const path: number[] = []
|
|
315
|
+
for (let at: Element = found; at !== flow && at.parentElement; at = at.parentElement) {
|
|
316
|
+
path.unshift(Array.prototype.indexOf.call(at.parentElement.children, at))
|
|
317
|
+
}
|
|
318
|
+
return path.reduce<Element | undefined>((node, index) => node?.children[index], copy) ?? found
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** The pages, scaled down to fit a frame narrower than the paper, never up. */
|
|
322
|
+
const fitPages = () => {
|
|
323
|
+
const width = paper[0] ?? 0
|
|
324
|
+
const room = window.innerWidth - 32
|
|
325
|
+
root.style.setProperty("--sixb-zoom", String(width > room ? Math.max(0.2, room / width) : 1))
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Cuts the document into pages. The first sheet holds the flow; each other sheet holds a copy of
|
|
330
|
+
* it, moved to show its column, only while it is in view or next to a sheet that is: a long
|
|
331
|
+
* document holds a few copies at a time, never one a page.
|
|
332
|
+
*/
|
|
333
|
+
const paginate = () => {
|
|
334
|
+
sheetsInView?.disconnect()
|
|
335
|
+
const body = document.body
|
|
336
|
+
const [width = 0, height = 0, top = 0, right = 0, bottom = 0, left = 0] = paper
|
|
337
|
+
const contentWidth = Math.max(1, width - left - right)
|
|
338
|
+
const contentHeight = Math.max(1, height - top - bottom)
|
|
339
|
+
const cut = document.createElement("div")
|
|
340
|
+
cut.className = "sixb-flow"
|
|
341
|
+
cut.style.cssText = `width:${contentWidth}px;height:${contentHeight}px;column-width:${contentWidth}px;column-gap:${COLUMN_GAP}px;column-fill:auto;`
|
|
342
|
+
cut.append(...Array.from(body.childNodes))
|
|
343
|
+
body.append(cut)
|
|
344
|
+
// Every style read before any is written, so the flow is laid out once.
|
|
345
|
+
const breaks = Array.from(cut.querySelectorAll<HTMLElement>("*")).map((element) => {
|
|
346
|
+
const style = getComputedStyle(element)
|
|
347
|
+
return [element, style.breakBefore, style.breakAfter] as const
|
|
348
|
+
})
|
|
349
|
+
for (const [element, before, after] of breaks) {
|
|
350
|
+
if (PAGE_BREAKS.includes(before)) element.style.breakBefore = "column"
|
|
351
|
+
if (PAGE_BREAKS.includes(after)) element.style.breakAfter = "column"
|
|
352
|
+
}
|
|
353
|
+
flow = cut
|
|
354
|
+
stride = contentWidth + COLUMN_GAP
|
|
355
|
+
const count = Math.max(1, Math.ceil((cut.scrollWidth + COLUMN_GAP - 1) / stride))
|
|
356
|
+
const pages = document.createElement("div")
|
|
357
|
+
pages.className = "sixb-pages"
|
|
358
|
+
const sheets = Array.from({ length: count }, (_, index) => {
|
|
359
|
+
const page = document.createElement("article")
|
|
360
|
+
page.className = "sixb-paper"
|
|
361
|
+
page.dataset.page = String(index + 1)
|
|
362
|
+
page.setAttribute("aria-label", `Page ${index + 1} of ${count}`)
|
|
363
|
+
const content = document.createElement("div")
|
|
364
|
+
content.className = "sixb-paper-content"
|
|
365
|
+
if (index === 0) content.append(cut)
|
|
366
|
+
page.append(content)
|
|
367
|
+
return page
|
|
368
|
+
})
|
|
369
|
+
pages.append(...sheets)
|
|
370
|
+
body.replaceChildren(pages)
|
|
371
|
+
fitPages()
|
|
372
|
+
|
|
373
|
+
const shown = new Set<number>()
|
|
374
|
+
sheetsInView = new IntersectionObserver((entries) => {
|
|
375
|
+
for (const entry of entries) {
|
|
376
|
+
const index = Number((entry.target as HTMLElement).dataset.page) - 1
|
|
377
|
+
if (entry.isIntersecting) shown.add(index)
|
|
378
|
+
else shown.delete(index)
|
|
379
|
+
}
|
|
380
|
+
for (const [index, sheet] of sheets.entries()) {
|
|
381
|
+
if (index === 0) continue
|
|
382
|
+
if ([...shown].some((each) => Math.abs(each - index) <= NEAR_PAGES)) pageCopy(index)
|
|
383
|
+
else sheet.firstElementChild?.replaceChildren()
|
|
384
|
+
}
|
|
385
|
+
reportEmbeds()
|
|
386
|
+
})
|
|
387
|
+
for (const sheet of sheets) sheetsInView.observe(sheet)
|
|
388
|
+
root.setAttribute("data-sixb-pages", String(count))
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* As one sheet, a forced page break shows as a gap between sheets, so its sections still read
|
|
393
|
+
* apart: a divider before what starts a page, or after what ends one. None at the top, and none
|
|
394
|
+
* inside a flex or grid box, where an element of its own would move what is laid out there.
|
|
395
|
+
*/
|
|
396
|
+
const markBreaks = () => {
|
|
397
|
+
const body = document.body
|
|
398
|
+
if (!body) return
|
|
399
|
+
const divider = () => {
|
|
400
|
+
const element = document.createElement("div")
|
|
401
|
+
element.className = "sixb-page-break"
|
|
402
|
+
element.setAttribute("aria-hidden", "true")
|
|
403
|
+
return element
|
|
404
|
+
}
|
|
405
|
+
const placed = (element: Element) =>
|
|
406
|
+
element.previousElementSibling?.classList.contains("sixb-page-break") ||
|
|
407
|
+
element.previousElementSibling === null
|
|
408
|
+
for (const element of Array.from(body.querySelectorAll<HTMLElement>("*"))) {
|
|
409
|
+
const parent = element.parentElement
|
|
410
|
+
if (!parent || /flex|grid/.test(getComputedStyle(parent).display)) continue
|
|
411
|
+
const style = getComputedStyle(element)
|
|
412
|
+
if (PAGE_BREAKS.includes(style.breakBefore) && !placed(element) && element.offsetTop > 0) {
|
|
413
|
+
element.before(divider())
|
|
414
|
+
}
|
|
415
|
+
const next = element.nextElementSibling
|
|
416
|
+
if (PAGE_BREAKS.includes(style.breakAfter) && next && !placed(next)) element.after(divider())
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** Waits for what moves text, its fonts and images, a while at most. */
|
|
421
|
+
const settled = (): Promise<void> => {
|
|
422
|
+
const images = Array.from(document.images, (image) => {
|
|
423
|
+
// Cut into pages, an image below the view is laid out on its page all the same: it waits
|
|
424
|
+
// for no scrolling to load.
|
|
425
|
+
if (paged) image.loading = "eager"
|
|
426
|
+
return image.complete ? Promise.resolve() : image.decode().catch(() => {})
|
|
427
|
+
})
|
|
428
|
+
const fonts = document.fonts?.ready ?? Promise.resolve()
|
|
429
|
+
const loaded = Promise.all([fonts, ...images]).then(() => {})
|
|
430
|
+
return Promise.race([loaded, new Promise<void>((resolve) => setTimeout(resolve, 5000))])
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Scrolls to the section the start names, in the page that shows it. */
|
|
434
|
+
const openSection = () => {
|
|
435
|
+
const section = start.get("sixb-section")
|
|
436
|
+
if (!section) return
|
|
437
|
+
shownCopy(`[data-sixb-section="${CSS.escape(section)}"]`)?.scrollIntoView({ block: "start" })
|
|
438
|
+
}
|
|
439
|
+
|
|
191
440
|
/**
|
|
192
441
|
* A page's height as laid out, for a document that shows it to size its frame: its body's, not
|
|
193
442
|
* the document's, which is never less than the frame and so would never let the frame shrink.
|
|
@@ -221,14 +470,15 @@ export function frameRuntime(): void {
|
|
|
221
470
|
|
|
222
471
|
// ── Editing a board ─────────────────────────────────────────────────
|
|
223
472
|
|
|
224
|
-
// What editing reports goes to the app through the port its first `edit` request hands over,
|
|
225
|
-
//
|
|
226
|
-
// post on it, are taken before any of the
|
|
473
|
+
// What editing reports goes to the app through the port its first `edit` request hands over, as
|
|
474
|
+
// a board running on the canvas is handed one with `canvas`, never through the window, where the
|
|
475
|
+
// page's own scripts post too. The port, and the way to post on it, are taken before any of the
|
|
476
|
+
// page's scripts run, which cannot reach either.
|
|
227
477
|
const portPost = typeof MessagePort === "function" ? MessagePort.prototype.postMessage : undefined
|
|
228
478
|
const apply = Reflect.apply
|
|
229
|
-
let
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
479
|
+
let appPort: MessagePort | null = null
|
|
480
|
+
const postPort = (message: Record<string, unknown>) => {
|
|
481
|
+
if (appPort && portPost) apply(portPost, appPort, [{ protocol: PROTOCOL, ...message }])
|
|
232
482
|
}
|
|
233
483
|
|
|
234
484
|
let editing = false
|
|
@@ -327,6 +577,41 @@ export function frameRuntime(): void {
|
|
|
327
577
|
return next
|
|
328
578
|
}
|
|
329
579
|
|
|
580
|
+
/**
|
|
581
|
+
* Collapses the whitespace in a text element's words as CSS showed it, in place: a browser lays
|
|
582
|
+
* out what takes typing as `pre-wrap`, where the line breaks and indents of its source would
|
|
583
|
+
* show. Each run is replaced on its own, from the end, so the caret the click placed stays where
|
|
584
|
+
* it was. What the reader types is merged into the source, which keeps its own whitespace.
|
|
585
|
+
*/
|
|
586
|
+
const collapseSpaces = (element: Element) => {
|
|
587
|
+
// 4 is NodeFilter.SHOW_TEXT: text nodes alone.
|
|
588
|
+
const walker = document.createTreeWalker(element, 4)
|
|
589
|
+
const nodes: Text[] = []
|
|
590
|
+
while (walker.nextNode()) nodes.push(walker.currentNode as Text)
|
|
591
|
+
// At the start of the block, whitespace shows as nothing, as after a space.
|
|
592
|
+
let after = true
|
|
593
|
+
const runs: { node: Text; start: number; length: number; with: string }[] = []
|
|
594
|
+
for (const node of nodes) {
|
|
595
|
+
for (const run of node.data.matchAll(/[ \t\n\r\f]+|[^ \t\n\r\f]+/g)) {
|
|
596
|
+
const index = run.index ?? 0
|
|
597
|
+
if (!/^[ \t\n\r\f]/.test(run[0])) {
|
|
598
|
+
after = false
|
|
599
|
+
continue
|
|
600
|
+
}
|
|
601
|
+
const shown = after ? "" : " "
|
|
602
|
+
if (run[0] !== shown) runs.push({ node, start: index, length: run[0].length, with: shown })
|
|
603
|
+
after = true
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
// At its end, whitespace shows as nothing either.
|
|
607
|
+
const last = runs.at(-1)
|
|
608
|
+
if (last && last.with === " " && last.start + last.length === last.node.data.length) {
|
|
609
|
+
const trailing = nodes.slice(nodes.indexOf(last.node) + 1).every((node) => node.data === "")
|
|
610
|
+
if (trailing) last.with = ""
|
|
611
|
+
}
|
|
612
|
+
for (const run of runs.reverse()) run.node.replaceData(run.start, run.length, run.with)
|
|
613
|
+
}
|
|
614
|
+
|
|
330
615
|
const stopTyping = () => {
|
|
331
616
|
const element = typing
|
|
332
617
|
if (!element) return
|
|
@@ -390,9 +675,15 @@ export function frameRuntime(): void {
|
|
|
390
675
|
picked = mark("data-sixb-picked", picked, commentable(element, event.target))
|
|
391
676
|
// Where the reader clicked, for a comment's pin.
|
|
392
677
|
const at = { x: event.clientX, y: event.clientY }
|
|
393
|
-
|
|
678
|
+
postPort({ event: "edit.select", params: { target, at } })
|
|
394
679
|
if (typable && element instanceof HTMLElement && target.kind === "text") {
|
|
395
680
|
typing = element
|
|
681
|
+
// Unless the page keeps its whitespace, as `pre`, `pre-wrap` and `break-spaces` do. Its
|
|
682
|
+
// words are still the source's, only spaced as they show: it still takes typing.
|
|
683
|
+
if (!/^(pre|pre-wrap|break-spaces)$/.test(getComputedStyle(element).whiteSpace)) {
|
|
684
|
+
collapseSpaces(element)
|
|
685
|
+
element.setAttribute(WORDS, wordsHash(element.textContent ?? ""))
|
|
686
|
+
}
|
|
396
687
|
typedFrom = element.textContent ?? ""
|
|
397
688
|
element.setAttribute("contenteditable", "plaintext-only")
|
|
398
689
|
element.focus()
|
|
@@ -406,13 +697,13 @@ export function frameRuntime(): void {
|
|
|
406
697
|
const shown = commentable(element, event.target)
|
|
407
698
|
if (shown === pointed && shown !== null) return
|
|
408
699
|
pointed = mark("data-sixb-hover", pointed, shown)
|
|
409
|
-
|
|
700
|
+
postPort({ event: "edit.hover", params: { target } })
|
|
410
701
|
})
|
|
411
702
|
// The pointer gone from the page, nothing is under it: it left for nothing of the page.
|
|
412
703
|
document.addEventListener("mouseout", (event) => {
|
|
413
704
|
if (!editing || !event.isTrusted || event.relatedTarget !== null || pointed === null) return
|
|
414
705
|
pointed = mark("data-sixb-hover", pointed, null)
|
|
415
|
-
|
|
706
|
+
postPort({ event: "edit.hover", params: { target: null } })
|
|
416
707
|
})
|
|
417
708
|
document.addEventListener("input", (event) => {
|
|
418
709
|
if (!editing || !event.isTrusted || !typing || !typing.contains(event.target as Node | null)) {
|
|
@@ -421,7 +712,7 @@ export function frameRuntime(): void {
|
|
|
421
712
|
const text = typing.textContent ?? ""
|
|
422
713
|
// Its words are the reader's now: still theirs to type in.
|
|
423
714
|
typing.setAttribute(WORDS, wordsHash(text))
|
|
424
|
-
|
|
715
|
+
postPort({
|
|
425
716
|
event: "edit.text",
|
|
426
717
|
params: { address: typing.getAttribute(AT), base: typedFrom, text },
|
|
427
718
|
})
|
|
@@ -442,8 +733,287 @@ export function frameRuntime(): void {
|
|
|
442
733
|
if (typing && event.target === typing) stopTyping()
|
|
443
734
|
})
|
|
444
735
|
|
|
736
|
+
// ── The reader's gestures over a canvas's board ─────────────────────
|
|
737
|
+
|
|
738
|
+
// A canvas's board is zoomed by the app around it, never by the browser: once the app has handed
|
|
739
|
+
// the port over, a pinch, the wheel with ⌘ or Ctrl, and ⌘ or Ctrl with +, − or 0 go to the app
|
|
740
|
+
// through it, the reader's own alone. Without a port, as a document's or a deck's frame is, they
|
|
741
|
+
// stay the browser's.
|
|
742
|
+
//
|
|
743
|
+
// A board running on the canvas, handed its port with `canvas`, is a page the reader uses in
|
|
744
|
+
// place among the others: its clicks, keys and text stay its own, and what moves the canvas goes
|
|
745
|
+
// to the app. The wheel pans the canvas unless the page scrolls under the pointer; a finger
|
|
746
|
+
// dragging pans it, while a tap stays the page's; Space held outside a field lets the reader
|
|
747
|
+
// drag the canvas.
|
|
748
|
+
const mac = /Mac|iPhone|iPad/.test(window.navigator?.platform ?? "")
|
|
749
|
+
const zoom = (params: Record<string, unknown>) => postPort({ event: "zoom", params })
|
|
750
|
+
const pan = (x: number, y: number, by: "wheel" | "touch") =>
|
|
751
|
+
postPort({ event: "pan", params: { x, y, by } })
|
|
752
|
+
const forwards = (event: Event) => appPort !== null && event.isTrusted
|
|
753
|
+
let onCanvas = false
|
|
754
|
+
/** The canvas is panning by the wheel, as the app last said. */
|
|
755
|
+
let canvasMoving = false
|
|
756
|
+
|
|
757
|
+
/** How long a wheel's turns are one gesture apart: React Flow's own pause before a pan ends. */
|
|
758
|
+
const WHEEL_GESTURE_MS = 150
|
|
759
|
+
/** Less overflow than this is a page's margins, not content to scroll. */
|
|
760
|
+
const MIN_OVERFLOW = 16
|
|
761
|
+
let wheeledAt = Number.NEGATIVE_INFINITY
|
|
762
|
+
let wheelScrolls = false
|
|
763
|
+
|
|
764
|
+
/** Whether what is under `target`, or the page, scrolls further by `x`, `y`. */
|
|
765
|
+
const scrollsUnder = (target: EventTarget | null, x: number, y: number): boolean => {
|
|
766
|
+
const vertical = Math.abs(y) >= Math.abs(x)
|
|
767
|
+
const delta = vertical ? y : x
|
|
768
|
+
if (delta === 0) return false
|
|
769
|
+
|
|
770
|
+
const overflowOf = (element: Element) =>
|
|
771
|
+
getComputedStyle(element)[vertical ? "overflowY" : "overflowX"]
|
|
772
|
+
const scrolls = (size: number, shown: number, at: number) =>
|
|
773
|
+
size - shown >= MIN_OVERFLOW && (delta > 0 ? at + shown < size - 1 : at > 0)
|
|
774
|
+
|
|
775
|
+
for (
|
|
776
|
+
let element = target instanceof Element ? target : null;
|
|
777
|
+
element && element !== root && element !== document.body;
|
|
778
|
+
element = element.parentElement
|
|
779
|
+
) {
|
|
780
|
+
if (!/auto|scroll/.test(overflowOf(element))) continue
|
|
781
|
+
const scrolled = vertical
|
|
782
|
+
? scrolls(element.scrollHeight, element.clientHeight, element.scrollTop)
|
|
783
|
+
: scrolls(element.scrollWidth, element.clientWidth, element.scrollLeft)
|
|
784
|
+
if (scrolled) return true
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
const page = document.scrollingElement
|
|
788
|
+
if (
|
|
789
|
+
!page ||
|
|
790
|
+
[root, document.body].some((each) => each && /hidden|clip/.test(overflowOf(each)))
|
|
791
|
+
) {
|
|
792
|
+
return false
|
|
793
|
+
}
|
|
794
|
+
return vertical
|
|
795
|
+
? scrolls(page.scrollHeight, window.innerHeight, window.scrollY)
|
|
796
|
+
: scrolls(page.scrollWidth, window.innerWidth, window.scrollX)
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
window.addEventListener(
|
|
800
|
+
"wheel",
|
|
801
|
+
(event) => {
|
|
802
|
+
if (!forwards(event)) return
|
|
803
|
+
|
|
804
|
+
if (event.ctrlKey || event.metaKey) {
|
|
805
|
+
event.preventDefault()
|
|
806
|
+
// As the canvas zooms by the wheel: a trackpad's pinch is the wheel with Ctrl, in small steps.
|
|
807
|
+
const unit = event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002
|
|
808
|
+
const factor = 2 ** (-event.deltaY * unit * (event.ctrlKey && mac ? 10 : 1))
|
|
809
|
+
zoom({ factor, at: { x: event.clientX, y: event.clientY } })
|
|
810
|
+
return
|
|
811
|
+
}
|
|
812
|
+
if (!onCanvas) return
|
|
813
|
+
|
|
814
|
+
// Lines, as Firefox turns, count as React Flow counts them; Shift turns the wheel sideways
|
|
815
|
+
// where the system doesn't already.
|
|
816
|
+
const unit = event.deltaMode === 1 ? 20 : event.deltaMode === 2 ? window.innerHeight : 1
|
|
817
|
+
const x = (!mac && event.shiftKey ? event.deltaY : event.deltaX) * unit
|
|
818
|
+
const y = !mac && event.shiftKey ? 0 : event.deltaY * unit
|
|
819
|
+
|
|
820
|
+
// A gesture goes one way from its first turn, as a browser keeps scrolling what it started
|
|
821
|
+
// on. The page scrolls it when something under the pointer scrolls that way and the canvas
|
|
822
|
+
// was not panning: a canvas panned under a still pointer keeps panning as a page comes under
|
|
823
|
+
// it, and a page scrolled to its end lets the next gesture pan.
|
|
824
|
+
if (event.timeStamp - wheeledAt > WHEEL_GESTURE_MS) {
|
|
825
|
+
wheelScrolls = !canvasMoving && scrollsUnder(event.target, x, y)
|
|
826
|
+
}
|
|
827
|
+
wheeledAt = event.timeStamp
|
|
828
|
+
if (wheelScrolls) return
|
|
829
|
+
|
|
830
|
+
event.preventDefault()
|
|
831
|
+
pan(x, y, "wheel")
|
|
832
|
+
},
|
|
833
|
+
{ passive: false }
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
// Two fingers pinch on a touch screen, measured on the screen: the frame grows as the zoom
|
|
837
|
+
// follows them, so in its own pixels they would seem to close. Safari also tells of a pinch as a
|
|
838
|
+
// gesture of its own, which is only stopped here; on a Mac's trackpad, where no finger touches
|
|
839
|
+
// the page, the gesture is it.
|
|
840
|
+
//
|
|
841
|
+
// On the canvas, one finger dragging past a few pixels pans it, and two pan it by their middle as
|
|
842
|
+
// they pinch: the page takes no touch gesture of its own (`touch-action`), and a tap, which
|
|
843
|
+
// moves less, stays a click on the page.
|
|
844
|
+
const TOUCH_SLOP = 6
|
|
845
|
+
let spread = 0
|
|
846
|
+
/** Where the fingers are on screen, one or two's middle, and whether they drag the canvas yet. */
|
|
847
|
+
let touched: { x: number; y: number; dragging: boolean } | null = null
|
|
848
|
+
const spreadOf = (touches: TouchList) => {
|
|
849
|
+
const [one, two] = [touches[0], touches[1]]
|
|
850
|
+
return one && two ? Math.hypot(one.screenX - two.screenX, one.screenY - two.screenY) : 0
|
|
851
|
+
}
|
|
852
|
+
const middleOf = (touches: TouchList) => {
|
|
853
|
+
const fingers = [touches[0], touches[1]].filter((touch) => touch !== undefined)
|
|
854
|
+
const sum = (axis: "screenX" | "screenY") =>
|
|
855
|
+
fingers.reduce((total, touch) => total + touch[axis], 0) / Math.max(1, fingers.length)
|
|
856
|
+
return { x: sum("screenX"), y: sum("screenY") }
|
|
857
|
+
}
|
|
858
|
+
window.addEventListener(
|
|
859
|
+
"touchstart",
|
|
860
|
+
(event) => {
|
|
861
|
+
const ours = forwards(event)
|
|
862
|
+
spread = ours && event.touches.length === 2 ? spreadOf(event.touches) : 0
|
|
863
|
+
touched =
|
|
864
|
+
ours && onCanvas ? { ...middleOf(event.touches), dragging: event.touches.length > 1 } : null
|
|
865
|
+
},
|
|
866
|
+
{ passive: true }
|
|
867
|
+
)
|
|
868
|
+
window.addEventListener(
|
|
869
|
+
"touchmove",
|
|
870
|
+
(event) => {
|
|
871
|
+
if (!forwards(event)) return
|
|
872
|
+
|
|
873
|
+
if (touched && event.touches.length <= 2) {
|
|
874
|
+
// As far as a page would scroll: the other way the fingers move.
|
|
875
|
+
const middle = middleOf(event.touches)
|
|
876
|
+
const x = touched.x - middle.x
|
|
877
|
+
const y = touched.y - middle.y
|
|
878
|
+
if (!touched.dragging && Math.hypot(x, y) < TOUCH_SLOP) return
|
|
879
|
+
|
|
880
|
+
event.preventDefault()
|
|
881
|
+
touched = { ...middle, dragging: true }
|
|
882
|
+
if (x !== 0 || y !== 0) pan(x, y, "touch")
|
|
883
|
+
}
|
|
884
|
+
if (event.touches.length !== 2 || spread === 0) return
|
|
885
|
+
event.preventDefault()
|
|
886
|
+
|
|
887
|
+
const [one, two] = [event.touches[0], event.touches[1]]
|
|
888
|
+
const next = spreadOf(event.touches)
|
|
889
|
+
if (!one || !two || next === 0) return
|
|
890
|
+
zoom({
|
|
891
|
+
factor: next / spread,
|
|
892
|
+
at: { x: (one.clientX + two.clientX) / 2, y: (one.clientY + two.clientY) / 2 },
|
|
893
|
+
})
|
|
894
|
+
spread = next
|
|
895
|
+
},
|
|
896
|
+
{ passive: false }
|
|
897
|
+
)
|
|
898
|
+
const untouch = (event: TouchEvent) => {
|
|
899
|
+
if (event.touches.length < 2) spread = 0
|
|
900
|
+
// A finger lifted: the others drag on from where they are, with no jump.
|
|
901
|
+
if (touched)
|
|
902
|
+
touched = event.touches.length > 0 ? { ...middleOf(event.touches), dragging: true } : null
|
|
903
|
+
}
|
|
904
|
+
window.addEventListener("touchend", untouch)
|
|
905
|
+
window.addEventListener("touchcancel", untouch)
|
|
906
|
+
|
|
907
|
+
let gestured = 1
|
|
908
|
+
const onGesture = (event: Event) => {
|
|
909
|
+
if (!forwards(event)) return
|
|
910
|
+
event.preventDefault()
|
|
911
|
+
|
|
912
|
+
const gesture = event as Event & { scale?: number; clientX?: number; clientY?: number }
|
|
913
|
+
const scale = gesture.scale ?? 1
|
|
914
|
+
if (event.type === "gesturestart" || spread > 0 || scale <= 0) {
|
|
915
|
+
gestured = scale > 0 ? scale : 1
|
|
916
|
+
return
|
|
917
|
+
}
|
|
918
|
+
zoom({ factor: scale / gestured, at: { x: gesture.clientX ?? 0, y: gesture.clientY ?? 0 } })
|
|
919
|
+
gestured = scale
|
|
920
|
+
}
|
|
921
|
+
window.addEventListener("gesturestart", onGesture, { passive: false })
|
|
922
|
+
window.addEventListener("gesturechange", onGesture, { passive: false })
|
|
923
|
+
|
|
924
|
+
// Before the page's own keys, and while the reader types in a text.
|
|
925
|
+
window.addEventListener(
|
|
926
|
+
"keydown",
|
|
927
|
+
(event) => {
|
|
928
|
+
if (!forwards(event) || !(event.metaKey || event.ctrlKey) || event.altKey) return
|
|
929
|
+
const step =
|
|
930
|
+
event.key === "=" || event.key === "+"
|
|
931
|
+
? "in"
|
|
932
|
+
: event.key === "-"
|
|
933
|
+
? "out"
|
|
934
|
+
: event.key === "0"
|
|
935
|
+
? "actual"
|
|
936
|
+
: null
|
|
937
|
+
if (!step) return
|
|
938
|
+
|
|
939
|
+
event.preventDefault()
|
|
940
|
+
zoom({ step })
|
|
941
|
+
},
|
|
942
|
+
true
|
|
943
|
+
)
|
|
944
|
+
|
|
945
|
+
// Space, held on the canvas, lets the reader drag it, as anywhere else on it, unless what has the
|
|
946
|
+
// focus takes Space itself: a field types it, a checkbox or a switch toggles. A button or a link
|
|
947
|
+
// the reader clicked keeps Enter: Space let go over it would press it again after the drag.
|
|
948
|
+
const SPACE_TAKERS = [
|
|
949
|
+
"input:not([type=button], [type=submit], [type=reset], [type=image])",
|
|
950
|
+
"textarea",
|
|
951
|
+
"select",
|
|
952
|
+
...[
|
|
953
|
+
"checkbox",
|
|
954
|
+
"radio",
|
|
955
|
+
"switch",
|
|
956
|
+
"option",
|
|
957
|
+
"menuitemcheckbox",
|
|
958
|
+
"menuitemradio",
|
|
959
|
+
"textbox",
|
|
960
|
+
"searchbox",
|
|
961
|
+
"combobox",
|
|
962
|
+
"slider",
|
|
963
|
+
"spinbutton",
|
|
964
|
+
].map((role) => `[role=${role}]`),
|
|
965
|
+
].join(", ")
|
|
966
|
+
let spaceHeld = false
|
|
967
|
+
const holdSpace = (down: boolean) => {
|
|
968
|
+
if (spaceHeld === down) return
|
|
969
|
+
spaceHeld = down
|
|
970
|
+
postPort({ event: "space", params: { down } })
|
|
971
|
+
}
|
|
972
|
+
const onSpace = (event: KeyboardEvent) => {
|
|
973
|
+
if (!onCanvas || !forwards(event) || event.key !== " ") return
|
|
974
|
+
if (event.metaKey || event.ctrlKey || event.altKey) return
|
|
975
|
+
|
|
976
|
+
const down = event.type === "keydown"
|
|
977
|
+
const focused = document.activeElement
|
|
978
|
+
if (down && focused instanceof HTMLElement) {
|
|
979
|
+
if (focused.isContentEditable || focused.matches(SPACE_TAKERS)) return
|
|
980
|
+
}
|
|
981
|
+
if (!down && !spaceHeld) return
|
|
982
|
+
|
|
983
|
+
event.preventDefault()
|
|
984
|
+
event.stopPropagation()
|
|
985
|
+
holdSpace(down)
|
|
986
|
+
}
|
|
987
|
+
window.addEventListener("keydown", onSpace, true)
|
|
988
|
+
window.addEventListener("keyup", onSpace, true)
|
|
989
|
+
window.addEventListener("blur", () => holdSpace(false))
|
|
990
|
+
|
|
991
|
+
/** The port the app handed over with `editor`, for the editor alone. */
|
|
992
|
+
let editorPort: MessagePort | null = null
|
|
993
|
+
let editorOn = false
|
|
994
|
+
const startEditor = (code: string) => {
|
|
995
|
+
if (editorOn) throw new Error("The editor is already running.")
|
|
996
|
+
if (!designed || !new URLSearchParams(window.location.search).has("sixb-edit")) {
|
|
997
|
+
throw new Error("Only a designed document served for editing takes an editor.")
|
|
998
|
+
}
|
|
999
|
+
if (!editorPort || !document.body) throw new Error("The editor needs its port and a body.")
|
|
1000
|
+
const script = document.createElement("script")
|
|
1001
|
+
script.textContent = code
|
|
1002
|
+
document.head.append(script)
|
|
1003
|
+
script.remove()
|
|
1004
|
+
const scope = window as unknown as Record<string, unknown>
|
|
1005
|
+
const start = scope[EDITOR_GLOBAL]
|
|
1006
|
+
delete scope[EDITOR_GLOBAL]
|
|
1007
|
+
if (typeof start !== "function") throw new Error("The editor did not start.")
|
|
1008
|
+
editorOn = true
|
|
1009
|
+
start({ port: editorPort, body: document.body })
|
|
1010
|
+
}
|
|
1011
|
+
|
|
445
1012
|
const handle = (method: string, params: Record<string, unknown>) => {
|
|
446
1013
|
switch (method) {
|
|
1014
|
+
case "editor":
|
|
1015
|
+
startEditor(String(params.code ?? ""))
|
|
1016
|
+
return
|
|
447
1017
|
case "theme": {
|
|
448
1018
|
// In the theme's layer, not inline: the deck's own CSS, unlayered, still wins.
|
|
449
1019
|
const tokens = (params.tokens ?? {}) as Record<string, string>
|
|
@@ -496,6 +1066,16 @@ export function frameRuntime(): void {
|
|
|
496
1066
|
case "edit":
|
|
497
1067
|
startEditing(params.on === true, params.typing !== false)
|
|
498
1068
|
return
|
|
1069
|
+
case "canvas":
|
|
1070
|
+
onCanvas = true
|
|
1071
|
+
canvasMoving = params.moving === true
|
|
1072
|
+
if (!document.getElementById("sixb-canvas")) {
|
|
1073
|
+
const style = document.createElement("style")
|
|
1074
|
+
style.id = "sixb-canvas"
|
|
1075
|
+
style.textContent = CANVAS_CSS
|
|
1076
|
+
document.head.append(style)
|
|
1077
|
+
}
|
|
1078
|
+
return
|
|
499
1079
|
case "edit.patch": {
|
|
500
1080
|
const patches = Array.isArray(params.patches) ? params.patches : []
|
|
501
1081
|
for (const patch of patches as Record<string, unknown>[]) {
|
|
@@ -649,7 +1229,8 @@ export function frameRuntime(): void {
|
|
|
649
1229
|
if (typeof data.method !== "string") return
|
|
650
1230
|
event.stopImmediatePropagation()
|
|
651
1231
|
const port = event.ports?.[0]
|
|
652
|
-
if (data.method === "edit" && port)
|
|
1232
|
+
if ((data.method === "edit" || data.method === "canvas") && port) appPort = port
|
|
1233
|
+
if (data.method === "editor" && port) editorPort = port
|
|
653
1234
|
try {
|
|
654
1235
|
handle(String(data.method), (data.params ?? {}) as Record<string, unknown>)
|
|
655
1236
|
post({ id: data.id })
|
|
@@ -671,17 +1252,34 @@ export function frameRuntime(): void {
|
|
|
671
1252
|
})
|
|
672
1253
|
|
|
673
1254
|
document.addEventListener("click", (event) => {
|
|
1255
|
+
// The editor's own: a click there places the caret.
|
|
1256
|
+
if (editorOn) return
|
|
674
1257
|
const target = event.target as HTMLElement | null
|
|
675
1258
|
|
|
676
1259
|
// A button, or a link within the page, by its words: on a canvas, an opened board follows the
|
|
677
1260
|
// arrow they label.
|
|
678
1261
|
const pressed = target?.closest<HTMLElement>('button, [role="button"], a[href^="#"]')
|
|
679
1262
|
const words = (pressed?.innerText ?? pressed?.textContent ?? "").replace(/\s+/g, " ").trim()
|
|
680
|
-
if (words && words.length <= MAX_LABEL_LENGTH)
|
|
1263
|
+
if (words && words.length <= MAX_LABEL_LENGTH) {
|
|
1264
|
+
post({ event: "press", params: { text: words } })
|
|
1265
|
+
// On the canvas, the reader's own press also goes through the port, where no script posts.
|
|
1266
|
+
if (onCanvas && event.isTrusted) postPort({ event: "press", params: { text: words } })
|
|
1267
|
+
}
|
|
681
1268
|
|
|
682
1269
|
const link = target?.closest<HTMLAnchorElement>("a[href]")
|
|
683
1270
|
if (link) {
|
|
684
1271
|
const href = link.getAttribute("href") ?? ""
|
|
1272
|
+
// Cut into pages, what a link within the document names is on every page: it moves to the
|
|
1273
|
+
// copy its page shows.
|
|
1274
|
+
if (paged && href.length > 1 && href.startsWith("#") && !event.defaultPrevented) {
|
|
1275
|
+
const id = decodeURIComponent(href.slice(1))
|
|
1276
|
+
const shown = shownCopy(`[id="${CSS.escape(id)}"], [name="${CSS.escape(id)}"]`)
|
|
1277
|
+
if (shown) {
|
|
1278
|
+
event.preventDefault()
|
|
1279
|
+
shown.scrollIntoView({ block: "start" })
|
|
1280
|
+
}
|
|
1281
|
+
return
|
|
1282
|
+
}
|
|
685
1283
|
// A link within the page moves through it, and one the page's own script handled is its.
|
|
686
1284
|
if (href.startsWith("#") || event.defaultPrevented) return
|
|
687
1285
|
|
|
@@ -706,9 +1304,101 @@ export function frameRuntime(): void {
|
|
|
706
1304
|
|
|
707
1305
|
window.addEventListener("resize", () => {
|
|
708
1306
|
if (deck) fit()
|
|
1307
|
+
if (paged) fitPages()
|
|
709
1308
|
reportEmbeds()
|
|
710
1309
|
})
|
|
1310
|
+
/** A designed document's live data, but not while it is served for editing. */
|
|
1311
|
+
const live =
|
|
1312
|
+
designed && data && !new URLSearchParams(window.location.search).has("sixb-edit")
|
|
1313
|
+
? data()
|
|
1314
|
+
: null
|
|
1315
|
+
const tree: DocumentTree<Element> = {
|
|
1316
|
+
children: (node) => Array.from(node.children),
|
|
1317
|
+
attribute: (node, name) => node.getAttribute(name),
|
|
1318
|
+
setAttribute: (node, name, value) => node.setAttribute(name, value),
|
|
1319
|
+
removeAttribute: (node, name) => node.removeAttribute(name),
|
|
1320
|
+
setText: (node, text) => {
|
|
1321
|
+
node.textContent = text
|
|
1322
|
+
},
|
|
1323
|
+
clone: (node) => node.cloneNode(true) as Element,
|
|
1324
|
+
replace: (node, nodes) => node.replaceWith(...nodes),
|
|
1325
|
+
}
|
|
1326
|
+
/** The body as published, which each read of the data is shown in, and what it reads. */
|
|
1327
|
+
let published: Node | null = null
|
|
1328
|
+
let reads: DocumentReads | null = null
|
|
1329
|
+
/** Which read of the data is the latest: an earlier one that answers later shows nothing. */
|
|
1330
|
+
let showing = 0
|
|
1331
|
+
|
|
1332
|
+
/** Reads the data the fields show and shows it, from the body as published. */
|
|
1333
|
+
const showData = async (): Promise<boolean> => {
|
|
1334
|
+
const body = document.body
|
|
1335
|
+
if (!live || !body) return false
|
|
1336
|
+
reads ??= live.reads(live.marks(body, tree))
|
|
1337
|
+
if (!reads.holder && reads.queries.length === 0) return false
|
|
1338
|
+
published ??= body.cloneNode(true)
|
|
1339
|
+
const read = ++showing
|
|
1340
|
+
|
|
1341
|
+
// What the reader may not read keeps its written text.
|
|
1342
|
+
const answer = (name: string) =>
|
|
1343
|
+
query(name).then(
|
|
1344
|
+
(result) => result as DocumentQueryResult,
|
|
1345
|
+
() => undefined
|
|
1346
|
+
)
|
|
1347
|
+
const [holder, ...results] = await Promise.all([
|
|
1348
|
+
reads.holder ? answer("holder") : undefined,
|
|
1349
|
+
...reads.queries.map(answer),
|
|
1350
|
+
])
|
|
1351
|
+
if (read !== showing) return false
|
|
1352
|
+
const queries: Record<string, DocumentQueryResult> = {}
|
|
1353
|
+
reads.queries.forEach((name, index) => {
|
|
1354
|
+
const result = results[index]
|
|
1355
|
+
if (result) queries[name] = result
|
|
1356
|
+
})
|
|
1357
|
+
const row = holder?.objects?.[0]
|
|
1358
|
+
body.replaceChildren(...Array.from(published.cloneNode(true).childNodes))
|
|
1359
|
+
live.fill(body, tree, {
|
|
1360
|
+
sources: { ...(row ? { holder: row } : {}), queries },
|
|
1361
|
+
lang: root.lang,
|
|
1362
|
+
})
|
|
1363
|
+
return true
|
|
1364
|
+
}
|
|
1365
|
+
if (live) {
|
|
1366
|
+
window.addEventListener("sixb:query", (event) => {
|
|
1367
|
+
const name = (event as CustomEvent<{ name?: unknown }>).detail?.name
|
|
1368
|
+
const shows = name === "holder" ? reads?.holder : reads?.queries.includes(String(name))
|
|
1369
|
+
if (!shows) return
|
|
1370
|
+
showData().then(async (shown) => {
|
|
1371
|
+
if (!shown) return
|
|
1372
|
+
if (paged) {
|
|
1373
|
+
// Not yet cut, it is cut once it first settles; cut, it is cut anew once this has.
|
|
1374
|
+
if (!root.hasAttribute("data-sixb-pages")) return
|
|
1375
|
+
await settled()
|
|
1376
|
+
paginate()
|
|
1377
|
+
} else {
|
|
1378
|
+
markBreaks()
|
|
1379
|
+
}
|
|
1380
|
+
reportSize()
|
|
1381
|
+
reportEmbeds()
|
|
1382
|
+
})
|
|
1383
|
+
})
|
|
1384
|
+
}
|
|
1385
|
+
|
|
711
1386
|
const ready = () => {
|
|
1387
|
+
if (paged) {
|
|
1388
|
+
showData()
|
|
1389
|
+
.then(settled)
|
|
1390
|
+
.then(() => {
|
|
1391
|
+
paginate()
|
|
1392
|
+
openSection()
|
|
1393
|
+
reportSize()
|
|
1394
|
+
reportEmbeds()
|
|
1395
|
+
})
|
|
1396
|
+
} else if (designed) {
|
|
1397
|
+
showData().then(() => {
|
|
1398
|
+
markBreaks()
|
|
1399
|
+
settled().then(openSection)
|
|
1400
|
+
})
|
|
1401
|
+
}
|
|
712
1402
|
if (!deck) {
|
|
713
1403
|
post({ event: "ready", params: {} })
|
|
714
1404
|
window.addEventListener("scroll", reportEmbeds, { passive: true })
|