@sixb/core 0.2.7 → 0.2.8
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 +52 -49
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run/context.d.ts.map +1 -1
- package/dist/actions/run/execute.d.ts +3 -0
- package/dist/actions/run/execute.d.ts.map +1 -1
- package/dist/actions/run/executor.d.ts +3 -0
- package/dist/actions/run/executor.d.ts.map +1 -1
- package/dist/actions/run/normalize.d.ts.map +1 -1
- package/dist/actions/run/types.d.ts +6 -0
- package/dist/actions/run/types.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +7 -0
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/agents/context/entries.d.ts +17 -0
- package/dist/agents/context/entries.d.ts.map +1 -1
- package/dist/agents/context/index.js +3 -2
- package/dist/agents/context/index.js.map +1 -1
- package/dist/agents/context-model.d.ts.map +1 -1
- package/dist/agents/context-resolution.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +7 -0
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/index.js +57 -54
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-call-retry.d.ts +28 -0
- package/dist/agents/model-call-retry.d.ts.map +1 -0
- package/dist/agents/model-loop.d.ts +4 -2
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +2 -0
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-plan.d.ts +1 -1
- package/dist/agents/run-plan.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-wire.d.ts +6 -0
- package/dist/agents/run-session-wire.d.ts.map +1 -1
- package/dist/agents/thread-access.d.ts +13 -0
- package/dist/agents/thread-access.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts.map +1 -1
- package/dist/artifacts/caller.d.ts +10 -0
- package/dist/artifacts/caller.d.ts.map +1 -0
- package/dist/artifacts/comment-place.d.ts +26 -0
- package/dist/artifacts/comment-place.d.ts.map +1 -0
- package/dist/artifacts/comment-text.d.ts +12 -4
- package/dist/artifacts/comment-text.d.ts.map +1 -1
- package/dist/artifacts/comments.d.ts +8 -2
- package/dist/artifacts/comments.d.ts.map +1 -1
- package/dist/artifacts/errors.d.ts +1 -1
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +73 -5
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +27 -7
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/entries.d.ts +5 -4
- package/dist/artifacts/frames/entries.d.ts.map +1 -1
- package/dist/artifacts/frames/hyperframes.d.ts +12 -0
- package/dist/artifacts/frames/hyperframes.d.ts.map +1 -0
- package/dist/artifacts/frames/index.d.ts +3 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +20 -6
- package/dist/artifacts/frames/index.js.map +3 -3
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +33 -0
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/video-runtime.d.ts +21 -0
- package/dist/artifacts/frames/video-runtime.d.ts.map +1 -0
- package/dist/artifacts/html.d.ts +23 -0
- package/dist/artifacts/html.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +5 -3
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +71 -10
- package/dist/artifacts/index.js.map +4 -4
- package/dist/artifacts/kinds.d.ts +1 -1
- package/dist/artifacts/kinds.d.ts.map +1 -1
- package/dist/artifacts/limits.d.ts +37 -0
- package/dist/artifacts/limits.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts.map +1 -1
- package/dist/artifacts/live/index.d.ts +6 -2
- package/dist/artifacts/live/index.d.ts.map +1 -1
- package/dist/artifacts/live/index.js +3432 -13
- package/dist/artifacts/live/index.js.map +6 -3
- package/dist/artifacts/live/presence.d.ts +7 -5
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/protocol.d.ts +4 -2
- package/dist/artifacts/live/protocol.d.ts.map +1 -1
- package/dist/artifacts/live/server.d.ts +1 -1
- package/dist/artifacts/live/server.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +36 -31
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/live/state.d.ts +2 -2
- package/dist/artifacts/media/media.d.ts +96 -0
- package/dist/artifacts/media/media.d.ts.map +1 -0
- package/dist/artifacts/media/transcriber.d.ts +29 -0
- package/dist/artifacts/media/transcriber.d.ts.map +1 -0
- package/dist/artifacts/outline.d.ts +26 -1
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/publish/files.d.ts +5 -2
- package/dist/artifacts/publish/files.d.ts.map +1 -1
- package/dist/artifacts/publish/index.d.ts +11 -2
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +110 -33
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/pdf.d.ts.map +1 -1
- package/dist/artifacts/publish/previews.d.ts +7 -2
- package/dist/artifacts/publish/previews.d.ts.map +1 -1
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/html.d.ts +5 -4
- package/dist/artifacts/publish/validate/html.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/video.d.ts +36 -0
- package/dist/artifacts/publish/validate/video.d.ts.map +1 -0
- package/dist/artifacts/publish/video.d.ts +79 -0
- package/dist/artifacts/publish/video.d.ts.map +1 -0
- package/dist/artifacts/resolve.d.ts +9 -0
- package/dist/artifacts/resolve.d.ts.map +1 -1
- package/dist/artifacts/video/composition.d.ts +183 -0
- package/dist/artifacts/video/composition.d.ts.map +1 -0
- package/dist/artifacts/video/edit.d.ts +298 -0
- package/dist/artifacts/video/edit.d.ts.map +1 -0
- package/dist/artifacts/video/export.d.ts +142 -0
- package/dist/artifacts/video/export.d.ts.map +1 -0
- package/dist/artifacts/video/looks.d.ts +133 -0
- package/dist/artifacts/video/looks.d.ts.map +1 -0
- package/dist/artifacts/video/project.d.ts +74 -0
- package/dist/artifacts/video/project.d.ts.map +1 -0
- package/dist/artifacts/video/stills.d.ts +65 -0
- package/dist/artifacts/video/stills.d.ts.map +1 -0
- package/dist/artifacts/video/timeline.d.ts +153 -0
- package/dist/artifacts/video/timeline.d.ts.map +1 -0
- package/dist/auth/index.js +9 -8
- package/dist/auth/index.js.map +1 -1
- package/dist/authorization/index.js +5 -4
- package/dist/authorization/index.js.map +1 -1
- package/dist/blob-storage/browser.d.ts +1 -1
- package/dist/blob-storage/browser.d.ts.map +1 -1
- package/dist/blob-storage/browser.js +8 -4
- package/dist/blob-storage/browser.js.map +1 -1
- package/dist/blob-storage/constants.d.ts +8 -3
- package/dist/blob-storage/constants.d.ts.map +1 -1
- package/dist/blob-storage/download-urls.d.ts +2 -2
- package/dist/blob-storage/download-urls.d.ts.map +1 -1
- package/dist/blob-storage/index.d.ts +1 -1
- package/dist/blob-storage/index.d.ts.map +1 -1
- package/dist/blob-storage/index.js +9 -5
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/blob-storage/internal.d.ts +2 -2
- package/dist/blob-storage/internal.d.ts.map +1 -1
- package/dist/blob-storage/internal.js +10 -4
- package/dist/blob-storage/internal.js.map +1 -1
- package/dist/blob-storage/media-type.d.ts +12 -3
- package/dist/blob-storage/media-type.d.ts.map +1 -1
- package/dist/bootstrap/index.js +61 -58
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-az95tsh3.js → chunk-0fjryajn.js} +3 -2
- package/dist/chunk-0fjryajn.js.map +11 -0
- package/dist/{chunk-9tpmfh3n.js → chunk-0mk8qqp9.js} +3 -3
- package/dist/{chunk-9tpmfh3n.js.map → chunk-0mk8qqp9.js.map} +3 -3
- package/dist/{chunk-88xeh6zx.js → chunk-1g4me5f2.js} +182 -7
- package/dist/{chunk-88xeh6zx.js.map → chunk-1g4me5f2.js.map} +3 -3
- package/dist/{chunk-7mhbs9yy.js → chunk-1z8ccj53.js} +1 -1
- package/dist/{chunk-wkv3h3q7.js → chunk-2138b0ng.js} +115 -8
- package/dist/chunk-2138b0ng.js.map +12 -0
- package/dist/chunk-23eaayw4.js +3757 -0
- package/dist/chunk-23eaayw4.js.map +22 -0
- package/dist/{chunk-m1cwncee.js → chunk-2mxq1yd9.js} +45 -40
- package/dist/{chunk-m1cwncee.js.map → chunk-2mxq1yd9.js.map} +3 -3
- package/dist/{chunk-dmnd9ea6.js → chunk-30a0ftnm.js} +2 -2
- package/dist/chunk-389ybvw9.js.map +2 -2
- package/dist/{chunk-qbd282aa.js → chunk-39q9ybav.js} +2 -2
- package/dist/{chunk-06kpaqg4.js → chunk-3d9w8t4n.js} +110 -22
- package/dist/{chunk-06kpaqg4.js.map → chunk-3d9w8t4n.js.map} +5 -5
- package/dist/chunk-3dvcdn9w.js +8 -0
- package/dist/chunk-3dvcdn9w.js.map +10 -0
- package/dist/{chunk-fdk0ks9p.js → chunk-3x902cja.js} +3 -3
- package/dist/{chunk-c4nrycdy.js → chunk-4q4a5a96.js} +1 -1
- package/dist/{chunk-9cyq87qa.js → chunk-4tdm3fsj.js} +95 -32
- package/dist/{chunk-9cyq87qa.js.map → chunk-4tdm3fsj.js.map} +9 -9
- package/dist/{chunk-cpy282b8.js → chunk-4w8qzy9w.js} +6 -6
- package/dist/{chunk-c29729me.js → chunk-4z9xtxke.js} +8 -7
- package/dist/chunk-4z9xtxke.js.map +12 -0
- package/dist/chunk-5278qwax.js +270 -0
- package/dist/chunk-5278qwax.js.map +11 -0
- package/dist/{chunk-k1g14kk3.js → chunk-6a4hp405.js} +4 -5
- package/dist/{chunk-k1g14kk3.js.map → chunk-6a4hp405.js.map} +3 -3
- package/dist/{chunk-xavet0qs.js → chunk-6whr25gw.js} +2 -2
- package/dist/{chunk-mbwsgjn7.js → chunk-7zygtcqq.js} +14 -2
- package/dist/chunk-7zygtcqq.js.map +11 -0
- package/dist/chunk-88s9z5pf.js +3 -0
- package/dist/{chunk-de5sfbc3.js.map → chunk-88s9z5pf.js.map} +1 -1
- package/dist/{chunk-ygvay56w.js → chunk-896te58g.js} +2 -2
- package/dist/{chunk-pfdq1ga6.js → chunk-8eqqqc1h.js} +3 -3
- package/dist/{chunk-yyj009tv.js → chunk-8tefbhdx.js} +14 -14
- package/dist/{chunk-yyj009tv.js.map → chunk-8tefbhdx.js.map} +1 -1
- package/dist/{chunk-jka26v8c.js → chunk-8x1bsp68.js} +1 -1
- package/dist/{chunk-wzcjhv54.js → chunk-93e4w7te.js} +113 -1
- package/dist/chunk-93e4w7te.js.map +11 -0
- package/dist/{chunk-phs5fbff.js → chunk-990a5bkc.js} +424 -76
- package/dist/chunk-990a5bkc.js.map +21 -0
- package/dist/{chunk-6md802cc.js → chunk-9az7kjv4.js} +6 -6
- package/dist/{chunk-95ps0k5q.js → chunk-9e5t53z0.js} +1 -1
- package/dist/{chunk-js9e6487.js → chunk-9p7kyeqz.js} +4 -4
- package/dist/chunk-a68zz4r0.js +537 -0
- package/dist/chunk-a68zz4r0.js.map +11 -0
- package/dist/{chunk-d7vyc7k6.js → chunk-a700gjc8.js} +10 -2
- package/dist/chunk-a700gjc8.js.map +10 -0
- package/dist/{chunk-gfdh9kqa.js → chunk-a9qzjaz2.js} +2 -5
- package/dist/chunk-a9qzjaz2.js.map +10 -0
- package/dist/{chunk-8qmp9fpa.js → chunk-as94vcty.js} +619 -482
- package/dist/{chunk-8qmp9fpa.js.map → chunk-as94vcty.js.map} +19 -19
- package/dist/{chunk-brybqw5k.js → chunk-bkxm2dzx.js} +1 -1
- package/dist/{chunk-ppxf7gw2.js → chunk-d7t9jnym.js} +3 -3
- package/dist/{chunk-tapdssb5.js → chunk-e3b1r4d2.js} +8 -7
- package/dist/{chunk-tapdssb5.js.map → chunk-e3b1r4d2.js.map} +4 -4
- package/dist/{chunk-cg7cygfj.js → chunk-fdmvaz7x.js} +1 -1
- package/dist/{chunk-191jz8a6.js → chunk-ff0qdk7z.js} +1 -1
- package/dist/{chunk-9vsc919v.js → chunk-fgxvrxx4.js} +22 -2
- package/dist/chunk-fgxvrxx4.js.map +10 -0
- package/dist/{chunk-wx7smkn2.js → chunk-fq8drkp0.js} +1 -1
- package/dist/{chunk-60662fyv.js → chunk-fqms1a8c.js} +132 -4
- package/dist/{chunk-60662fyv.js.map → chunk-fqms1a8c.js.map} +8 -6
- package/dist/{chunk-v8a1qjzp.js → chunk-hpswfrjj.js} +1 -1
- package/dist/{chunk-qttqe1ah.js → chunk-jbg905hn.js} +80 -13
- package/dist/chunk-jbg905hn.js.map +25 -0
- package/dist/{chunk-bz5bnjjt.js → chunk-jjte0h4p.js} +1 -1
- package/dist/{chunk-hvq8xs66.js → chunk-jwjwvzj1.js} +797 -51
- package/dist/chunk-jwjwvzj1.js.map +38 -0
- package/dist/{chunk-k29rdc3h.js → chunk-k3vd2vyz.js} +6 -2
- package/dist/chunk-k3vd2vyz.js.map +10 -0
- package/dist/chunk-kcqpk9w1.js.map +2 -2
- package/dist/chunk-mvz89age.js.map +2 -2
- package/dist/{chunk-xrmbhap8.js → chunk-mwg0nwkb.js} +1 -1
- package/dist/{chunk-a3faa34j.js → chunk-nfjt8k8j.js} +1 -1
- package/dist/{chunk-394zjzjs.js → chunk-nhgqz3g3.js} +3 -3
- package/dist/{chunk-bqr703h4.js → chunk-p0c5kkhn.js} +23 -6
- package/dist/{chunk-bqr703h4.js.map → chunk-p0c5kkhn.js.map} +3 -3
- package/dist/{chunk-92wrka15.js → chunk-q150fnj9.js} +1 -1
- package/dist/{chunk-w3t94hm6.js → chunk-qk3zq25v.js} +1 -1
- package/dist/chunk-rtkqczbr.js.map +2 -2
- package/dist/{chunk-3qtk0070.js → chunk-ssqbrts1.js} +86 -9
- package/dist/chunk-ssqbrts1.js.map +14 -0
- package/dist/{chunk-5qqmndhm.js → chunk-szzhrn3e.js} +1 -1
- package/dist/{chunk-n1hbwc6y.js → chunk-t6pfch4e.js} +1 -1
- package/dist/{chunk-xtztwpkh.js → chunk-v6h4tc2v.js} +86 -5
- package/dist/chunk-v6h4tc2v.js.map +12 -0
- package/dist/{chunk-brhp9d97.js → chunk-vmqjndb3.js} +2 -2
- package/dist/chunk-vtjzwymr.js.map +2 -2
- package/dist/{chunk-fycac8e9.js → chunk-wpba6hhd.js} +10 -10
- package/dist/{chunk-fycac8e9.js.map → chunk-wpba6hhd.js.map} +1 -1
- package/dist/{chunk-t58sktr5.js → chunk-wrb1x1ss.js} +2 -2
- package/dist/{chunk-5sswe5ej.js → chunk-wsv23wvr.js} +2 -2
- package/dist/{chunk-04r2fdsd.js → chunk-x0hqc54n.js} +4 -4
- package/dist/{chunk-sgx82nnt.js → chunk-xg31er4p.js} +43 -4
- package/dist/chunk-xg31er4p.js.map +10 -0
- package/dist/{chunk-3neam1y5.js → chunk-y3qb965a.js} +2 -2
- package/dist/{chunk-5pz3htbe.js → chunk-y57eawng.js} +3 -3
- package/dist/{chunk-8ncg20rd.js → chunk-yah25st6.js} +5 -5
- package/dist/chunk-yah25st6.js.map +10 -0
- package/dist/{chunk-mrs7jy17.js → chunk-ywvxcmqj.js} +106 -13
- package/dist/{chunk-mrs7jy17.js.map → chunk-ywvxcmqj.js.map} +8 -7
- package/dist/{chunk-44hrfmbk.js → chunk-zmq9xc9s.js} +70 -31
- package/dist/{chunk-44hrfmbk.js.map → chunk-zmq9xc9s.js.map} +4 -3
- package/dist/datasets/write.js +8 -7
- package/dist/datasets/write.js.map +1 -1
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/execution/agent.js +52 -49
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/kernel-operation.d.ts +1 -0
- package/dist/execution/kernel-operation.d.ts.map +1 -1
- package/dist/execution/primitive.js +52 -49
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.js +53 -50
- package/dist/execution/request.js.map +2 -2
- package/dist/execution/types.d.ts +5 -0
- 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 +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -65
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +9 -8
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/maintenance/index.js +9 -8
- package/dist/maintenance/index.js.map +2 -2
- package/dist/materializer/index.js +26 -24
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/audio/runtime.d.ts +3 -1
- package/dist/models/audio/runtime.d.ts.map +1 -1
- package/dist/models/audio/speech.d.ts +2 -2
- package/dist/models/audio/speech.d.ts.map +1 -1
- package/dist/models/audio/types.d.ts +23 -3
- package/dist/models/audio/types.d.ts.map +1 -1
- package/dist/models/calls.d.ts +7 -0
- package/dist/models/calls.d.ts.map +1 -1
- package/dist/models/catalog.d.ts +5 -0
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +3 -2
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/errors.d.ts +5 -3
- package/dist/models/errors.d.ts.map +1 -1
- package/dist/models/events.d.ts +2 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/execution/index.d.ts +1 -0
- package/dist/models/execution/index.d.ts.map +1 -1
- package/dist/models/execution/index.js +33 -28
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/execution/model-call-limits.d.ts.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts +8 -0
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/session.d.ts +12 -0
- package/dist/models/execution/session.d.ts.map +1 -1
- package/dist/models/execution/usage.d.ts.map +1 -1
- package/dist/models/execution.d.ts +1 -1
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/generation-types.d.ts +2 -0
- package/dist/models/generation-types.d.ts.map +1 -1
- package/dist/models/index.d.ts +4 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -2
- package/dist/models/input-file.d.ts.map +1 -1
- package/dist/models/pricing.d.ts +2 -1
- package/dist/models/pricing.d.ts.map +1 -1
- package/dist/models/rate-card.d.ts +6 -0
- package/dist/models/rate-card.d.ts.map +1 -1
- package/dist/models/tools.d.ts +5 -0
- package/dist/models/tools.d.ts.map +1 -1
- package/dist/models/video/catalog.d.ts +13 -0
- package/dist/models/video/catalog.d.ts.map +1 -0
- package/dist/models/video/check.d.ts +76 -0
- package/dist/models/video/check.d.ts.map +1 -0
- package/dist/models/video/runtime.d.ts +21 -0
- package/dist/models/video/runtime.d.ts.map +1 -0
- package/dist/models/video/types.d.ts +188 -0
- package/dist/models/video/types.d.ts.map +1 -0
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +52 -49
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/index.js +25 -23
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/ontology/index.js +4 -4
- package/dist/ontology/internal.js +4 -4
- package/dist/pipelines/index.js +28 -26
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +26 -24
- package/dist/projections/internal.js.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/types.d.ts +103 -6
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +3 -1
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +49 -43
- package/dist/runtime/internal.js.map +2 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/index.js +6 -6
- package/dist/security/public.d.ts +6 -4
- package/dist/security/public.d.ts.map +1 -1
- package/dist/security/public.js +5 -3
- package/dist/security/public.js.map +1 -1
- package/dist/shares/internal.js +25 -23
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/agents/in-memory.d.ts +2 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +4 -4
- package/dist/storage/agents/types.d.ts +13 -0
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +1 -0
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/groups.d.ts +2 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +5 -5
- package/dist/storage/ai-cost/types.d.ts +2 -1
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/validation.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +3 -3
- package/dist/storage/ai-limits/provider.js +2 -2
- package/dist/storage/ai-usage/in-memory.d.ts +8 -1
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/index.d.ts +2 -2
- package/dist/storage/ai-usage/index.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts +11 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +80 -1
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/usage.d.ts +1 -1
- package/dist/storage/ai-usage/usage.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +25 -2
- 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 +12 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +198 -6
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +3 -2
- package/dist/storage/executions/provider.js.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +10 -9
- package/dist/storage/file-upload-sessions/provider.js.map +1 -1
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +24 -22
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +2 -2
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +34 -14
- package/dist/storage/internal.js.map +2 -2
- package/dist/storage/workflow-runs/provider.js +10 -9
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +29 -27
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts +3 -0
- 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.js +619 -72
- package/dist/testing/index.js.map +9 -9
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +26 -24
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +5 -5
- package/dist/workers/index.js.map +1 -1
- package/dist/workflows/index.js +58 -55
- package/dist/workflows/index.js.map +1 -1
- package/package.json +3 -1
- package/src/actions/request.ts +2 -0
- package/src/actions/run/context.ts +1 -0
- package/src/actions/run/execute.ts +5 -1
- package/src/actions/run/executor.ts +4 -0
- package/src/actions/run/normalize.ts +4 -0
- package/src/actions/run/types.ts +6 -0
- package/src/actions/types/context.ts +7 -0
- package/src/agents/README.md +3 -1
- package/src/agents/context/entries.ts +63 -9
- package/src/agents/context-model.ts +9 -0
- package/src/agents/context-resolution.ts +7 -0
- package/src/agents/execution.ts +39 -0
- package/src/agents/model-call-retry.ts +69 -0
- package/src/agents/model-loop.ts +86 -12
- package/src/agents/run-artifacts.ts +10 -5
- package/src/agents/run-plan.ts +2 -1
- package/src/agents/run-session-http.ts +1 -0
- package/src/agents/run-session-serve.ts +23 -2
- package/src/agents/run-session-wire.ts +45 -0
- package/src/agents/thread-access.ts +34 -1
- package/src/agents/tool-files.ts +23 -7
- package/src/artifacts/caller.ts +42 -0
- package/src/artifacts/comment-place.ts +51 -0
- package/src/artifacts/comment-text.ts +50 -7
- package/src/artifacts/comments.ts +132 -34
- package/src/artifacts/errors.ts +1 -0
- package/src/artifacts/execution.ts +249 -5
- package/src/artifacts/frames/assets.ts +93 -15
- package/src/artifacts/frames/entries.ts +7 -4
- package/src/artifacts/frames/generated/hyperframes-notices.txt +290 -0
- package/src/artifacts/frames/generated/hyperframes.txt +1145 -0
- package/src/artifacts/frames/generated.d.ts +5 -0
- package/src/artifacts/frames/hyperframes.ts +14 -0
- package/src/artifacts/frames/index.ts +5 -0
- package/src/artifacts/frames/kit.ts +7 -3
- package/src/artifacts/frames/protocol.ts +56 -0
- package/src/artifacts/frames/video-runtime.ts +165 -0
- package/src/artifacts/html.ts +13 -0
- package/src/artifacts/index.ts +7 -0
- package/src/artifacts/kinds.ts +9 -1
- package/src/artifacts/limits.ts +43 -0
- package/src/artifacts/live/document.ts +27 -3
- package/src/artifacts/live/index.ts +58 -2
- package/src/artifacts/live/presence.ts +17 -5
- package/src/artifacts/live/protocol.ts +4 -2
- package/src/artifacts/live/server.ts +1 -1
- package/src/artifacts/live/state.ts +3 -3
- package/src/artifacts/media/README.md +75 -0
- package/src/artifacts/media/media.ts +316 -0
- package/src/artifacts/media/transcriber.ts +84 -0
- package/src/artifacts/outline.ts +28 -0
- package/src/artifacts/publish/files.ts +19 -6
- package/src/artifacts/publish/index.ts +49 -2
- package/src/artifacts/publish/pdf.ts +3 -1
- package/src/artifacts/publish/previews.ts +22 -8
- package/src/artifacts/publish/publish.ts +4 -1
- package/src/artifacts/publish/validate/html.ts +23 -18
- package/src/artifacts/publish/validate/video.ts +309 -0
- package/src/artifacts/publish/video.ts +235 -0
- package/src/artifacts/resolve.ts +45 -0
- package/src/artifacts/video/README.md +402 -0
- package/src/artifacts/video/composition.ts +898 -0
- package/src/artifacts/video/edit.ts +3967 -0
- package/src/artifacts/video/export.ts +352 -0
- package/src/artifacts/video/looks.ts +694 -0
- package/src/artifacts/video/project.ts +198 -0
- package/src/artifacts/video/stills.ts +168 -0
- package/src/artifacts/video/timeline.ts +658 -0
- package/src/blob-storage/browser.ts +1 -1
- package/src/blob-storage/constants.ts +9 -3
- package/src/blob-storage/download-urls.ts +5 -3
- package/src/blob-storage/index.ts +1 -0
- package/src/blob-storage/internal.ts +13 -2
- package/src/blob-storage/media-type.ts +149 -8
- package/src/errors/catalog.ts +2 -1
- package/src/execution/authorization.ts +2 -2
- package/src/execution/kernel-operation.ts +14 -0
- package/src/execution/types.ts +2 -0
- package/src/http/api-routes.ts +117 -0
- package/src/index.ts +18 -1
- package/src/lake-storage/definition-updates.ts +3 -9
- package/src/models/audio/runtime.ts +48 -3
- package/src/models/audio/speech.ts +2 -2
- package/src/models/audio/types.ts +24 -3
- package/src/models/calls.ts +35 -18
- package/src/models/catalog.ts +9 -2
- package/src/models/definitions.ts +4 -2
- package/src/models/errors.ts +5 -3
- package/src/models/events.ts +2 -0
- package/src/models/execution/README.md +68 -2
- package/src/models/execution/index.ts +1 -0
- package/src/models/execution/model-call-limits.ts +11 -5
- package/src/models/execution/model-call-recorder.ts +14 -0
- package/src/models/execution/session.ts +52 -23
- package/src/models/execution/usage.ts +1 -0
- package/src/models/execution.ts +13 -2
- package/src/models/generation-types.ts +2 -0
- package/src/models/index.ts +20 -1
- package/src/models/input-file.ts +7 -2
- package/src/models/pricing.ts +19 -1
- package/src/models/rate-card.ts +15 -3
- package/src/models/tools.ts +5 -0
- package/src/models/video/catalog.ts +101 -0
- package/src/models/video/check.ts +441 -0
- package/src/models/video/runtime.ts +550 -0
- package/src/models/video/types.ts +194 -0
- package/src/objects/execution.ts +2 -0
- package/src/objects/sdk/object-set.ts +2 -0
- package/src/queues/index.ts +5 -0
- package/src/queues/types.ts +126 -5
- package/src/runtime/host.ts +3 -0
- package/src/runtime/internal.ts +3 -1
- package/src/runtime/sixb.ts +12 -4
- package/src/sandboxes/README.md +3 -2
- package/src/security/public.ts +6 -4
- package/src/storage/agents/in-memory.ts +39 -0
- package/src/storage/agents/index.ts +1 -0
- package/src/storage/agents/types.ts +14 -0
- package/src/storage/ai-cost/analytics.ts +2 -0
- package/src/storage/ai-cost/codec.ts +1 -0
- package/src/storage/ai-cost/groups.ts +7 -0
- package/src/storage/ai-cost/types.ts +2 -0
- package/src/storage/ai-cost/validation.ts +2 -0
- package/src/storage/ai-usage/in-memory.ts +93 -0
- package/src/storage/ai-usage/index.ts +10 -0
- package/src/storage/ai-usage/record.ts +106 -0
- package/src/storage/ai-usage/types.ts +102 -1
- package/src/storage/ai-usage/usage.ts +2 -0
- package/src/storage/artifacts/in-memory.ts +108 -11
- package/src/storage/artifacts/index.ts +14 -0
- package/src/storage/artifacts/record.ts +203 -1
- package/src/storage/artifacts/types.ts +199 -6
- package/src/storage/executions/validation.ts +2 -2
- package/src/storage/in-memory/index.ts +1 -1
- package/src/storage/index.ts +22 -1
- package/src/storage/internal.ts +9 -0
- package/src/testing/agent-storage-contract.ts +108 -0
- package/src/testing/ai-cost-storage-contract.ts +1 -0
- package/src/testing/ai-usage-storage-contract.ts +145 -1
- package/src/testing/artifact-storage-contract.ts +320 -0
- package/src/testing/execution-storage-contract.ts +10 -2
- package/src/testing/lake-storage-contract.ts +27 -0
- package/src/testing/queues-contract.ts +71 -0
- package/dist/chunk-3723kgba.js +0 -29
- package/dist/chunk-3723kgba.js.map +0 -10
- package/dist/chunk-3qtk0070.js.map +0 -14
- package/dist/chunk-8ncg20rd.js.map +0 -10
- package/dist/chunk-9vsc919v.js.map +0 -10
- package/dist/chunk-az95tsh3.js.map +0 -11
- package/dist/chunk-c29729me.js.map +0 -12
- package/dist/chunk-d7vyc7k6.js.map +0 -10
- package/dist/chunk-de5sfbc3.js +0 -3
- package/dist/chunk-gfdh9kqa.js.map +0 -11
- package/dist/chunk-hvq8xs66.js.map +0 -34
- package/dist/chunk-k29rdc3h.js.map +0 -10
- package/dist/chunk-mbwsgjn7.js.map +0 -11
- package/dist/chunk-phs5fbff.js.map +0 -19
- package/dist/chunk-qttqe1ah.js.map +0 -24
- package/dist/chunk-sgx82nnt.js.map +0 -10
- package/dist/chunk-vs2s3p8n.js +0 -2274
- package/dist/chunk-vs2s3p8n.js.map +0 -20
- package/dist/chunk-wkv3h3q7.js.map +0 -12
- package/dist/chunk-wzcjhv54.js.map +0 -11
- package/dist/chunk-xtztwpkh.js.map +0 -12
- /package/dist/{chunk-7mhbs9yy.js.map → chunk-1z8ccj53.js.map} +0 -0
- /package/dist/{chunk-dmnd9ea6.js.map → chunk-30a0ftnm.js.map} +0 -0
- /package/dist/{chunk-qbd282aa.js.map → chunk-39q9ybav.js.map} +0 -0
- /package/dist/{chunk-fdk0ks9p.js.map → chunk-3x902cja.js.map} +0 -0
- /package/dist/{chunk-c4nrycdy.js.map → chunk-4q4a5a96.js.map} +0 -0
- /package/dist/{chunk-cpy282b8.js.map → chunk-4w8qzy9w.js.map} +0 -0
- /package/dist/{chunk-xavet0qs.js.map → chunk-6whr25gw.js.map} +0 -0
- /package/dist/{chunk-ygvay56w.js.map → chunk-896te58g.js.map} +0 -0
- /package/dist/{chunk-pfdq1ga6.js.map → chunk-8eqqqc1h.js.map} +0 -0
- /package/dist/{chunk-jka26v8c.js.map → chunk-8x1bsp68.js.map} +0 -0
- /package/dist/{chunk-6md802cc.js.map → chunk-9az7kjv4.js.map} +0 -0
- /package/dist/{chunk-95ps0k5q.js.map → chunk-9e5t53z0.js.map} +0 -0
- /package/dist/{chunk-js9e6487.js.map → chunk-9p7kyeqz.js.map} +0 -0
- /package/dist/{chunk-brybqw5k.js.map → chunk-bkxm2dzx.js.map} +0 -0
- /package/dist/{chunk-ppxf7gw2.js.map → chunk-d7t9jnym.js.map} +0 -0
- /package/dist/{chunk-cg7cygfj.js.map → chunk-fdmvaz7x.js.map} +0 -0
- /package/dist/{chunk-191jz8a6.js.map → chunk-ff0qdk7z.js.map} +0 -0
- /package/dist/{chunk-wx7smkn2.js.map → chunk-fq8drkp0.js.map} +0 -0
- /package/dist/{chunk-v8a1qjzp.js.map → chunk-hpswfrjj.js.map} +0 -0
- /package/dist/{chunk-bz5bnjjt.js.map → chunk-jjte0h4p.js.map} +0 -0
- /package/dist/{chunk-xrmbhap8.js.map → chunk-mwg0nwkb.js.map} +0 -0
- /package/dist/{chunk-a3faa34j.js.map → chunk-nfjt8k8j.js.map} +0 -0
- /package/dist/{chunk-394zjzjs.js.map → chunk-nhgqz3g3.js.map} +0 -0
- /package/dist/{chunk-92wrka15.js.map → chunk-q150fnj9.js.map} +0 -0
- /package/dist/{chunk-w3t94hm6.js.map → chunk-qk3zq25v.js.map} +0 -0
- /package/dist/{chunk-5qqmndhm.js.map → chunk-szzhrn3e.js.map} +0 -0
- /package/dist/{chunk-n1hbwc6y.js.map → chunk-t6pfch4e.js.map} +0 -0
- /package/dist/{chunk-brhp9d97.js.map → chunk-vmqjndb3.js.map} +0 -0
- /package/dist/{chunk-t58sktr5.js.map → chunk-wrb1x1ss.js.map} +0 -0
- /package/dist/{chunk-5sswe5ej.js.map → chunk-wsv23wvr.js.map} +0 -0
- /package/dist/{chunk-04r2fdsd.js.map → chunk-x0hqc54n.js.map} +0 -0
- /package/dist/{chunk-3neam1y5.js.map → chunk-y3qb965a.js.map} +0 -0
- /package/dist/{chunk-5pz3htbe.js.map → chunk-y57eawng.js.map} +0 -0
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import { type DefaultTreeAdapterTypes, parse, parseFragment } from "parse5"
|
|
2
|
+
import type { VideoSourceSpan } from "./composition"
|
|
3
|
+
|
|
4
|
+
// What a composition plays, clip by clip, where its file writes each: the timed elements an editor
|
|
5
|
+
// trims, moves and splits, and the words it shows, which an editor types into. `index.html` plays
|
|
6
|
+
// its own clips over every scene, a soundtrack most often; a scene file plays its own, timed from
|
|
7
|
+
// the scene's start. Browser-safe, as `composition.ts`. See README.md.
|
|
8
|
+
|
|
9
|
+
type Node = DefaultTreeAdapterTypes.Node
|
|
10
|
+
type Element = DefaultTreeAdapterTypes.Element
|
|
11
|
+
|
|
12
|
+
/** What a clip shows or plays. */
|
|
13
|
+
export type VideoClipKind = "video" | "audio" | "image" | "text" | "element"
|
|
14
|
+
|
|
15
|
+
/** The rows an editor lays clips on: what is seen, what is read, and what is heard. */
|
|
16
|
+
export type VideoTrack = "picture" | "text" | "sound"
|
|
17
|
+
|
|
18
|
+
/** An element where its file writes it, for an editor to change it in place. */
|
|
19
|
+
export interface VideoElementSource {
|
|
20
|
+
/** The whole element, its end tag included. */
|
|
21
|
+
readonly element: VideoSourceSpan
|
|
22
|
+
/** Its start tag. */
|
|
23
|
+
readonly tag: VideoSourceSpan
|
|
24
|
+
/** Each attribute it writes, by name, as the span of its name and value. */
|
|
25
|
+
readonly attributes: Readonly<Record<string, VideoSourceSpan>>
|
|
26
|
+
/** What it holds, between its start tag and its end tag; none for a void element. */
|
|
27
|
+
readonly content?: VideoSourceSpan
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A timed element of a composition: footage, a sound, a picture, a line of text. */
|
|
31
|
+
export interface VideoClip {
|
|
32
|
+
/**
|
|
33
|
+
* How an edit names it in its file: its `id`, else `#<n>`, its place among the file's clips.
|
|
34
|
+
* An `id` survives edits around it; a place, only edits that add or remove no clip before it.
|
|
35
|
+
*/
|
|
36
|
+
readonly ref: string
|
|
37
|
+
readonly id?: string
|
|
38
|
+
readonly tag: string
|
|
39
|
+
readonly kind: VideoClipKind
|
|
40
|
+
readonly track: VideoTrack
|
|
41
|
+
/** A caption: a line of what is said, as the Agent's guide writes them. */
|
|
42
|
+
readonly caption: boolean
|
|
43
|
+
/** From its composition's start: a scene's, or the video's for `index.html`. */
|
|
44
|
+
readonly startMs: number
|
|
45
|
+
/** As its `data-duration` writes it; none when it plays until its file or its composition ends. */
|
|
46
|
+
readonly durationMs?: number
|
|
47
|
+
/** Where in its file it starts playing, from `data-media-start`. */
|
|
48
|
+
readonly mediaStartMs: number
|
|
49
|
+
/** The file it plays or shows, as written. */
|
|
50
|
+
readonly src?: string
|
|
51
|
+
/** From `data-volume`, 1 as recorded. */
|
|
52
|
+
readonly volume?: number
|
|
53
|
+
readonly fadeInMs?: number
|
|
54
|
+
readonly fadeOutMs?: number
|
|
55
|
+
/**
|
|
56
|
+
* A clip whose sound is not played, as HyperFrames mixes it: footage `muted`, or with a
|
|
57
|
+
* `data-has-audio` other than "true"; a sound `muted`.
|
|
58
|
+
*/
|
|
59
|
+
readonly silent: boolean
|
|
60
|
+
/** What a text clip says. */
|
|
61
|
+
readonly text?: string
|
|
62
|
+
/**
|
|
63
|
+
* The clip it goes on from, by its id, from `data-continues`: a part of that clip in a later
|
|
64
|
+
* scene, which an editor edits with it as one (see {@link videoChains}).
|
|
65
|
+
*/
|
|
66
|
+
readonly continues?: string
|
|
67
|
+
readonly source: VideoElementSource
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** An element whose words an editor may type over: it holds text alone. */
|
|
71
|
+
export interface VideoText {
|
|
72
|
+
/** Its `id`, else `<tag>:<n>`, its place among the file's texts. */
|
|
73
|
+
readonly ref: string
|
|
74
|
+
readonly tag: string
|
|
75
|
+
readonly text: string
|
|
76
|
+
/** Its `class`, which says what it is to whoever reads the list: a title, a callout. */
|
|
77
|
+
readonly className?: string
|
|
78
|
+
/** Whether it is also a clip: timed by `data-start`. */
|
|
79
|
+
readonly timed: boolean
|
|
80
|
+
readonly source: VideoElementSource
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** One composition's clips and texts, in the order its file writes them. */
|
|
84
|
+
export interface VideoFileTimeline {
|
|
85
|
+
readonly clips: readonly VideoClip[]
|
|
86
|
+
readonly texts: readonly VideoText[]
|
|
87
|
+
/** The composition's own element, which new clips go into. */
|
|
88
|
+
readonly composition: VideoElementSource
|
|
89
|
+
/** The elements it holds itself, in order, each by its tag: where a new clip may go. */
|
|
90
|
+
readonly children: readonly { readonly tag: string; readonly source: VideoElementSource }[]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The tags whose words an editor may type over, when they hold text alone. */
|
|
94
|
+
const TEXT_TAGS: ReadonlySet<string> = new Set([
|
|
95
|
+
"h1",
|
|
96
|
+
"h2",
|
|
97
|
+
"h3",
|
|
98
|
+
"h4",
|
|
99
|
+
"h5",
|
|
100
|
+
"h6",
|
|
101
|
+
"p",
|
|
102
|
+
"span",
|
|
103
|
+
"div",
|
|
104
|
+
"li",
|
|
105
|
+
"strong",
|
|
106
|
+
"em",
|
|
107
|
+
"small",
|
|
108
|
+
"blockquote",
|
|
109
|
+
"figcaption",
|
|
110
|
+
"label",
|
|
111
|
+
"a",
|
|
112
|
+
"button",
|
|
113
|
+
])
|
|
114
|
+
|
|
115
|
+
/** Elements that only break a line inside words. */
|
|
116
|
+
const LINE_BREAKS: ReadonlySet<string> = new Set(["br", "wbr"])
|
|
117
|
+
|
|
118
|
+
/** Elements that only style words inside a line, such as a caption's highlighted word. */
|
|
119
|
+
const INLINE_STYLES: ReadonlySet<string> = new Set([
|
|
120
|
+
"span",
|
|
121
|
+
"b",
|
|
122
|
+
"strong",
|
|
123
|
+
"i",
|
|
124
|
+
"em",
|
|
125
|
+
"u",
|
|
126
|
+
"s",
|
|
127
|
+
"mark",
|
|
128
|
+
"small",
|
|
129
|
+
"sub",
|
|
130
|
+
"sup",
|
|
131
|
+
])
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The clips and texts of a scene file: the timed elements in its `<template>`'s composition,
|
|
135
|
+
* leaving out what a composition it nests holds. Null for a file that is not one.
|
|
136
|
+
*/
|
|
137
|
+
export function readSceneTimeline(html: string): VideoFileTimeline | null {
|
|
138
|
+
const fragment = parseFragment(html, { sourceCodeLocationInfo: true })
|
|
139
|
+
const template = fragment.childNodes.find(
|
|
140
|
+
(node): node is Element => "tagName" in node && node.tagName === "template"
|
|
141
|
+
)
|
|
142
|
+
if (!template) return null
|
|
143
|
+
|
|
144
|
+
const composition = elements(contentOf(template)).find((element) =>
|
|
145
|
+
has(element, "data-composition-id")
|
|
146
|
+
)
|
|
147
|
+
return composition ? timelineOf(composition) : null
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The clips and texts `index.html` plays on its own timeline, beside its scenes: its soundtrack,
|
|
152
|
+
* a logo over every scene. Null for a file without a root composition.
|
|
153
|
+
*/
|
|
154
|
+
export function readRootTimeline(html: string): VideoFileTimeline | null {
|
|
155
|
+
const document = parse(html, { sourceCodeLocationInfo: true })
|
|
156
|
+
const compositions = elements(document.childNodes).filter((element) =>
|
|
157
|
+
has(element, "data-composition-id")
|
|
158
|
+
)
|
|
159
|
+
const root =
|
|
160
|
+
compositions.find((element) => attribute(element, "data-root") === "true") ?? compositions[0]
|
|
161
|
+
return root ? timelineOf(root) : null
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* What `index.html`'s root paints of its own over the scenes before it: each element it holds
|
|
166
|
+
* after its first scene's host, but the hosts, its sounds, and what shows nothing. HyperFrames
|
|
167
|
+
* positions the timed ones, so a scene's `z-index` covers them unless theirs is higher. Empty for a
|
|
168
|
+
* file without a root composition or a scene.
|
|
169
|
+
*/
|
|
170
|
+
export function readRootLayers(html: string): VideoElementSource[] {
|
|
171
|
+
const document = parse(html, { sourceCodeLocationInfo: true })
|
|
172
|
+
const compositions = elements(document.childNodes).filter((element) =>
|
|
173
|
+
has(element, "data-composition-id")
|
|
174
|
+
)
|
|
175
|
+
const root =
|
|
176
|
+
compositions.find((element) => attribute(element, "data-root") === "true") ?? compositions[0]
|
|
177
|
+
const children = root?.childNodes.filter((node): node is Element => "tagName" in node) ?? []
|
|
178
|
+
|
|
179
|
+
const first = children.findIndex((element) => has(element, "data-composition-src"))
|
|
180
|
+
if (first < 0) return []
|
|
181
|
+
return children
|
|
182
|
+
.slice(first + 1)
|
|
183
|
+
.filter((element) => !has(element, "data-composition-src") && !UNSEEN_TAGS.has(element.tagName))
|
|
184
|
+
.map(sourceOf)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** What a composition holds that paints nothing. */
|
|
188
|
+
const UNSEEN_TAGS = new Set(["audio", "script", "style", "template", "link", "meta", "noscript"])
|
|
189
|
+
|
|
190
|
+
function timelineOf(composition: Element): VideoFileTimeline {
|
|
191
|
+
// A nested composition, or a scene's host, and what it holds are its own.
|
|
192
|
+
const own = elements(composition.childNodes, { stop: nests }).filter((element) => !nests(element))
|
|
193
|
+
|
|
194
|
+
const timed = own.filter((element) => isClip(element))
|
|
195
|
+
const ids = new Map<string, Element>()
|
|
196
|
+
for (const element of timed) {
|
|
197
|
+
const id = attribute(element, "id")
|
|
198
|
+
if (id && !ids.has(id)) ids.set(id, element)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const clips: VideoClip[] = []
|
|
202
|
+
const resolved = new Map<Element, VideoClip>()
|
|
203
|
+
const startOf = (element: Element, seen: Set<Element>): number => {
|
|
204
|
+
const known = resolved.get(element)
|
|
205
|
+
if (known) return known.startMs
|
|
206
|
+
const written = attribute(element, "data-start")?.trim() ?? ""
|
|
207
|
+
return clipStart(written, (name) => {
|
|
208
|
+
const other = ids.get(name)
|
|
209
|
+
if (!other || seen.has(other)) return undefined
|
|
210
|
+
seen.add(other)
|
|
211
|
+
const start = startOf(other, seen)
|
|
212
|
+
const duration = readMs(attribute(other, "data-duration"))
|
|
213
|
+
return duration === undefined ? undefined : start + duration
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
timed.forEach((element, index) => {
|
|
218
|
+
const id = attribute(element, "id")?.trim() || undefined
|
|
219
|
+
const kind = clipKind(element)
|
|
220
|
+
const className = attribute(element, "class") ?? ""
|
|
221
|
+
const durationMs = readMs(attribute(element, "data-duration"))
|
|
222
|
+
const volume = readNumber(attribute(element, "data-volume"))
|
|
223
|
+
const fadeInMs = readMs(attribute(element, "data-fade-in"))
|
|
224
|
+
const fadeOutMs = readMs(attribute(element, "data-fade-out"))
|
|
225
|
+
const src = attribute(element, "src")?.trim()
|
|
226
|
+
const text = kind === "text" ? styledWordsOf(element) : undefined
|
|
227
|
+
const continues = attribute(element, "data-continues")?.trim()
|
|
228
|
+
|
|
229
|
+
const clip: VideoClip = {
|
|
230
|
+
ref: id ?? `#${index}`,
|
|
231
|
+
...(id ? { id } : {}),
|
|
232
|
+
tag: element.tagName,
|
|
233
|
+
kind,
|
|
234
|
+
track: kind === "audio" ? "sound" : kind === "text" ? "text" : "picture",
|
|
235
|
+
caption: /\bcaptions?\b/.test(className),
|
|
236
|
+
startMs: startOf(element, new Set([element])),
|
|
237
|
+
...(durationMs === undefined ? {} : { durationMs }),
|
|
238
|
+
mediaStartMs: readMs(attribute(element, "data-media-start")) ?? 0,
|
|
239
|
+
...(src ? { src } : {}),
|
|
240
|
+
...(volume === undefined ? {} : { volume }),
|
|
241
|
+
...(fadeInMs === undefined ? {} : { fadeInMs }),
|
|
242
|
+
...(fadeOutMs === undefined ? {} : { fadeOutMs }),
|
|
243
|
+
silent:
|
|
244
|
+
(kind === "audio" && has(element, "muted")) ||
|
|
245
|
+
(kind === "video" &&
|
|
246
|
+
(has(element, "muted") || (has(element, "data-has-audio") && !hasAudio(element)))),
|
|
247
|
+
...(text === undefined ? {} : { text }),
|
|
248
|
+
...(continues ? { continues } : {}),
|
|
249
|
+
source: sourceOf(element),
|
|
250
|
+
}
|
|
251
|
+
resolved.set(element, clip)
|
|
252
|
+
clips.push(clip)
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
const counts = new Map<string, number>()
|
|
256
|
+
const texts = own.flatMap((element): VideoText[] => {
|
|
257
|
+
const text = TEXT_TAGS.has(element.tagName) ? wordsOf(element) : undefined
|
|
258
|
+
if (text === undefined) return []
|
|
259
|
+
|
|
260
|
+
const place = counts.get(element.tagName) ?? 0
|
|
261
|
+
counts.set(element.tagName, place + 1)
|
|
262
|
+
const id = attribute(element, "id")?.trim()
|
|
263
|
+
const className = attribute(element, "class")?.trim()
|
|
264
|
+
return [
|
|
265
|
+
{
|
|
266
|
+
ref: id || `${element.tagName}:${place}`,
|
|
267
|
+
tag: element.tagName,
|
|
268
|
+
text,
|
|
269
|
+
...(className ? { className } : {}),
|
|
270
|
+
timed: has(element, "data-start"),
|
|
271
|
+
source: sourceOf(element),
|
|
272
|
+
},
|
|
273
|
+
]
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
const children = composition.childNodes
|
|
277
|
+
.filter((node): node is Element => "tagName" in node)
|
|
278
|
+
.map((element) => ({ tag: element.tagName, source: sourceOf(element) }))
|
|
279
|
+
|
|
280
|
+
return { clips, texts, composition: sourceOf(composition), children }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Within this, two instants are one: under a frame at 60 fps. */
|
|
284
|
+
const SAME_MS = 15
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* A frame at the slowest rate a video plays, 24 fps: a recording's pieces this close still go on
|
|
288
|
+
* one from the other, as a placement leaves no piece shorter than a frame at a skip.
|
|
289
|
+
*/
|
|
290
|
+
const FRAME_MS = 42
|
|
291
|
+
|
|
292
|
+
/** A part of a clip laid in the video: its scene's file, the clip there, and when it plays. */
|
|
293
|
+
export interface VideoChainPart {
|
|
294
|
+
readonly file: string
|
|
295
|
+
readonly clip: VideoClip
|
|
296
|
+
readonly startMs: number
|
|
297
|
+
readonly endMs: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* A clip and the parts that go on from it in the scenes after, past each one's end: one clip to
|
|
302
|
+
* whoever edits it, from its first part's start to its last's end. Its parts are in play order,
|
|
303
|
+
* the first, its head, holding the id each other names in `data-continues`. A recording cut by its
|
|
304
|
+
* words goes on in pieces: two back to back in one scene, or across a scene's edge, each playing
|
|
305
|
+
* its own stretch of the file.
|
|
306
|
+
*/
|
|
307
|
+
export interface VideoChain {
|
|
308
|
+
readonly parts: readonly VideoChainPart[]
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* The video's chains: each clip that parts in later scenes go on from, with those parts. A part
|
|
313
|
+
* is one only while it goes on from the one before it, as the edit that cut it wrote it: the same
|
|
314
|
+
* element, starting where that one ends, or where its own scene starts after a gap. One edited
|
|
315
|
+
* apart, or whose head is gone, heads a chain of its own, or stands alone, so a video nobody cut
|
|
316
|
+
* this way has none.
|
|
317
|
+
*/
|
|
318
|
+
export function videoChains(
|
|
319
|
+
scenes: readonly VideoSceneSpan[],
|
|
320
|
+
timelineOf: (file: string) => VideoFileTimeline | undefined
|
|
321
|
+
): VideoChain[] {
|
|
322
|
+
const files = new Map<string, VideoSceneSpan>()
|
|
323
|
+
for (const scene of scenes) if (!files.has(scene.src)) files.set(scene.src, scene)
|
|
324
|
+
|
|
325
|
+
const parts: VideoChainPart[] = []
|
|
326
|
+
const written = new Map<string, number>()
|
|
327
|
+
for (const [file, scene] of files) {
|
|
328
|
+
for (const clip of timelineOf(file)?.clips ?? []) {
|
|
329
|
+
if (clip.id) written.set(clip.id, (written.get(clip.id) ?? 0) + 1)
|
|
330
|
+
if (clip.durationMs === undefined) continue
|
|
331
|
+
const startMs = scene.startMs + clip.startMs
|
|
332
|
+
parts.push({ file, clip, startMs, endMs: startMs + clip.durationMs })
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// A head is the one clip of the video with its id: two that share it, as a copied scene's may,
|
|
336
|
+
// head nothing.
|
|
337
|
+
const byId = new Map(
|
|
338
|
+
parts.flatMap((part) =>
|
|
339
|
+
part.clip.id && written.get(part.clip.id) === 1 ? [[part.clip.id, part]] : []
|
|
340
|
+
)
|
|
341
|
+
)
|
|
342
|
+
const sceneOf = (part: VideoChainPart) => files.get(part.file)
|
|
343
|
+
|
|
344
|
+
const chains: VideoChain[] = []
|
|
345
|
+
const following = new Map<string, VideoChainPart[]>()
|
|
346
|
+
for (const part of parts) {
|
|
347
|
+
if (!part.clip.continues) continue
|
|
348
|
+
following.set(part.clip.continues, [...(following.get(part.clip.continues) ?? []), part])
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
for (const [id, after] of following) {
|
|
352
|
+
// From its head, each link the part that goes on from the last one found, wherever it lies
|
|
353
|
+
// among them, and of two that would, the one playing the file on from where it stops, else a
|
|
354
|
+
// piece beside it in its scene: a part left stale by an edit hides none after it. A part left
|
|
355
|
+
// over heads a chain of its own, as one whose head is gone.
|
|
356
|
+
const left = after.sort((a, b) => a.startMs - b.startMs)
|
|
357
|
+
const head = byId.get(id)
|
|
358
|
+
let start: VideoChainPart | undefined = head ?? left.shift()
|
|
359
|
+
while (start) {
|
|
360
|
+
const chain = [start]
|
|
361
|
+
for (;;) {
|
|
362
|
+
const last = chain[chain.length - 1] as VideoChainPart
|
|
363
|
+
const next = left.filter((part) => goesOn(scenes, last, part, sceneOf))
|
|
364
|
+
const found =
|
|
365
|
+
next.find((part) => playsOn(last, part)) ??
|
|
366
|
+
next.find((part) => part.file === last.file) ??
|
|
367
|
+
next[0]
|
|
368
|
+
if (!found) break
|
|
369
|
+
chain.push(...left.splice(left.indexOf(found), 1))
|
|
370
|
+
}
|
|
371
|
+
if (chain.length > 1) chains.push({ parts: chain })
|
|
372
|
+
start = left.shift()
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return chains.sort((a, b) => (a.parts[0]?.startMs ?? 0) - (b.parts[0]?.startMs ?? 0))
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** A scene's file and where it plays in the video. */
|
|
379
|
+
export interface VideoSceneSpan {
|
|
380
|
+
readonly src: string
|
|
381
|
+
readonly startMs: number
|
|
382
|
+
readonly durationMs: number
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* The scene a clip that runs past `scene`'s end goes on in: the chapter on top at that instant,
|
|
387
|
+
* the later in play order, else the next to start; none past the last. `scenes` in play order.
|
|
388
|
+
* An overlay is never one (see {@link videoChapters}).
|
|
389
|
+
*/
|
|
390
|
+
export function sceneAfter<T extends { readonly startMs: number; readonly durationMs: number }>(
|
|
391
|
+
scenes: readonly T[],
|
|
392
|
+
scene: T
|
|
393
|
+
): T | undefined {
|
|
394
|
+
const chapters = videoChapters(scenes)
|
|
395
|
+
const end = scene.startMs + scene.durationMs
|
|
396
|
+
const onTop = chapters
|
|
397
|
+
.filter((each) => each !== scene && each.startMs <= end && end < each.startMs + each.durationMs)
|
|
398
|
+
.at(-1)
|
|
399
|
+
return onTop ?? chapters.find((each) => each !== scene && each.startMs >= end)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The scenes that are the video's chapters, in play order: every one but an overlay, a scene laid
|
|
404
|
+
* over the others, as captions written over the whole video: one that holds two others whole, or
|
|
405
|
+
* the span of all the others, two at least, from the first's start to the last's end. One short chapter inside a
|
|
406
|
+
* longer one's crossfade leaves both chapters; of two alike, the later is the overlay. An
|
|
407
|
+
* overlay's clips stay its own: no clip goes into it or out.
|
|
408
|
+
*/
|
|
409
|
+
export function videoChapters<T extends { readonly startMs: number; readonly durationMs: number }>(
|
|
410
|
+
scenes: readonly T[]
|
|
411
|
+
): T[] {
|
|
412
|
+
const end = (scene: T) => scene.startMs + scene.durationMs
|
|
413
|
+
const holds = (outer: T, inner: T) => outer.startMs <= inner.startMs && end(inner) <= end(outer)
|
|
414
|
+
// Of two alike, the earlier is held by the later, never the other way round.
|
|
415
|
+
const within = (outer: T, inner: T, outerAt: number, innerAt: number) =>
|
|
416
|
+
holds(outer, inner) && (!holds(inner, outer) || innerAt < outerAt)
|
|
417
|
+
|
|
418
|
+
return scenes.filter((scene, at) => {
|
|
419
|
+
const others = scenes.filter((other) => other !== scene)
|
|
420
|
+
if (others.length === 0) return true
|
|
421
|
+
const held = others.filter((other) => within(scene, other, at, scenes.indexOf(other)))
|
|
422
|
+
if (held.length >= 2) return false
|
|
423
|
+
const first = Math.min(...others.map((other) => other.startMs))
|
|
424
|
+
const last = Math.max(...others.map(end))
|
|
425
|
+
const spans = scene.startMs <= first && last <= end(scene)
|
|
426
|
+
return !(others.length >= 2 && spans && held.length === others.length)
|
|
427
|
+
})
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Whether `next` goes on from `previous` as a placement or a cut wrote it, whatever was done to
|
|
432
|
+
* their scenes since: the same element, and
|
|
433
|
+
* - a recording's piece in the same scene, starting where `previous` ends: a cut by its words
|
|
434
|
+
* left both;
|
|
435
|
+
* - a recording in the scene placement goes on in after `previous`'s, starting no later than that
|
|
436
|
+
* one's end, or its own start after a gap: a scene made shorter under `previous` hides its end,
|
|
437
|
+
* one made longer leaves a gap after it, and both stay one clip, which its next placement makes
|
|
438
|
+
* whole again. Where it plays its file from is its own, a cut at the edge skipping what it took,
|
|
439
|
+
* but only after a part that reaches its scene's end: past a gap, it plays the file on;
|
|
440
|
+
* - anything else in that scene, from where `previous` reaches its scene's end, at least, starting
|
|
441
|
+
* there or where its own scene starts after a gap.
|
|
442
|
+
*/
|
|
443
|
+
function goesOn(
|
|
444
|
+
scenes: readonly VideoSceneSpan[],
|
|
445
|
+
previous: VideoChainPart,
|
|
446
|
+
next: VideoChainPart,
|
|
447
|
+
sceneOf: (part: VideoChainPart) => VideoSceneSpan | undefined
|
|
448
|
+
): boolean {
|
|
449
|
+
const [a, b] = [previous.clip, next.clip]
|
|
450
|
+
if (a.tag !== b.tag || a.src !== b.src || a.text !== b.text) return false
|
|
451
|
+
const recording = b.kind === "video" || b.kind === "audio"
|
|
452
|
+
if (previous.file === next.file) {
|
|
453
|
+
return recording && Math.abs(next.startMs - previous.endMs) <= FRAME_MS
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const before = sceneOf(previous)
|
|
457
|
+
const after = sceneOf(next)
|
|
458
|
+
if (!before || !after || sceneAfter(scenes, before) !== after) return false
|
|
459
|
+
const sceneEnd = before.startMs + before.durationMs
|
|
460
|
+
const from = Math.max(Math.min(previous.endMs, sceneEnd), after.startMs)
|
|
461
|
+
|
|
462
|
+
if (recording) {
|
|
463
|
+
// Past a gap the scene made longer, only where it plays the file on: a part elsewhere in the
|
|
464
|
+
// file goes on only from one that reaches its scene's end, so a stale one never links.
|
|
465
|
+
const reaches = previous.endMs >= sceneEnd - FRAME_MS
|
|
466
|
+
return (
|
|
467
|
+
(reaches || playsOn(previous, next)) &&
|
|
468
|
+
next.startMs <= Math.max(sceneEnd, after.startMs) + FRAME_MS
|
|
469
|
+
)
|
|
470
|
+
}
|
|
471
|
+
if (previous.endMs < sceneEnd - SAME_MS) return false
|
|
472
|
+
return Math.abs(next.startMs - from) <= SAME_MS
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Whether `next` would go on from `previous` as {@link videoChains} links parts, whatever head its
|
|
477
|
+
* `data-continues` names: a part two edits at once left naming another.
|
|
478
|
+
*/
|
|
479
|
+
export function goesOnFrom(
|
|
480
|
+
scenes: readonly VideoSceneSpan[],
|
|
481
|
+
previous: VideoChainPart,
|
|
482
|
+
next: VideoChainPart
|
|
483
|
+
): boolean {
|
|
484
|
+
const sceneOf = (part: VideoChainPart) => scenes.find((scene) => scene.src === part.file)
|
|
485
|
+
return goesOn(scenes, previous, next, sceneOf)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** Whether `next` plays its file on from where `previous`, as written, stops. */
|
|
489
|
+
function playsOn(previous: VideoChainPart, next: VideoChainPart): boolean {
|
|
490
|
+
const stops = previous.clip.mediaStartMs + (previous.clip.durationMs ?? 0)
|
|
491
|
+
return Math.abs(next.clip.mediaStartMs - stops) <= SAME_MS
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/** A composition nested in this one, whose clips are its own. */
|
|
495
|
+
function nests(element: Element): boolean {
|
|
496
|
+
return has(element, "data-composition-id") || has(element, "data-composition-src")
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/** A clip: an element with `data-start`, or a video or a sound, which plays from 0 without one. */
|
|
500
|
+
function isClip(element: Element): boolean {
|
|
501
|
+
if (has(element, "data-composition-src")) return false
|
|
502
|
+
return has(element, "data-start") || element.tagName === "video" || element.tagName === "audio"
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function clipKind(element: Element): VideoClipKind {
|
|
506
|
+
switch (element.tagName) {
|
|
507
|
+
case "video":
|
|
508
|
+
return "video"
|
|
509
|
+
case "audio":
|
|
510
|
+
return "audio"
|
|
511
|
+
case "img":
|
|
512
|
+
case "picture":
|
|
513
|
+
case "svg":
|
|
514
|
+
return "image"
|
|
515
|
+
default:
|
|
516
|
+
return styledWordsOf(element) === undefined ? "element" : "text"
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* A clip's start, in milliseconds: seconds, or the end of the clip it names, `n` seconds later or
|
|
522
|
+
* sooner, as HyperFrames reads a scene's. One it cannot resolve starts at 0.
|
|
523
|
+
*/
|
|
524
|
+
function clipStart(written: string, endOf: (name: string) => number | undefined): number {
|
|
525
|
+
if (written === "") return 0
|
|
526
|
+
|
|
527
|
+
const seconds = Number(written)
|
|
528
|
+
if (Number.isFinite(seconds)) return Math.max(0, Math.round(seconds * 1000))
|
|
529
|
+
|
|
530
|
+
const offset = /^(.*?)\s*([+-])\s*((?:\d*\.)?\d+)$/.exec(written)
|
|
531
|
+
const name = offset ? (offset[1] ?? "") : written
|
|
532
|
+
const shift = offset ? (offset[2] === "-" ? -1 : 1) * Number(offset[3]) * 1000 : 0
|
|
533
|
+
const end = endOf(name)
|
|
534
|
+
return end === undefined ? 0 : Math.max(0, Math.round(end + shift))
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function hasAudio(element: Element): boolean {
|
|
538
|
+
return attribute(element, "data-has-audio")?.trim() === "true"
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* The words an element reads as, its styled words included, such as a caption that colours one of
|
|
543
|
+
* them; undefined for one that holds anything else, or nothing to read. It decides the text track;
|
|
544
|
+
* only `wordsOf` decides what an editor may type over, since typing would drop the styling.
|
|
545
|
+
*/
|
|
546
|
+
function styledWordsOf(element: Element): string | undefined {
|
|
547
|
+
const collect = (node: Element): string | undefined => {
|
|
548
|
+
let words = ""
|
|
549
|
+
for (const child of node.childNodes) {
|
|
550
|
+
if ("tagName" in child) {
|
|
551
|
+
if (LINE_BREAKS.has(child.tagName)) {
|
|
552
|
+
words += " "
|
|
553
|
+
continue
|
|
554
|
+
}
|
|
555
|
+
if (!INLINE_STYLES.has(child.tagName)) return undefined
|
|
556
|
+
|
|
557
|
+
const inner = collect(child)
|
|
558
|
+
if (inner === undefined) return undefined
|
|
559
|
+
words += inner
|
|
560
|
+
} else if (child.nodeName === "#text" && "value" in child) {
|
|
561
|
+
words += child.value
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return words
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const text = collect(element)?.replace(/\s+/g, " ").trim()
|
|
568
|
+
return text === undefined || text === "" ? undefined : text
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* The words an element holds when it holds text alone, line breaks aside, its spaces collapsed;
|
|
573
|
+
* undefined for one that holds elements, or nothing to read.
|
|
574
|
+
*/
|
|
575
|
+
function wordsOf(element: Element): string | undefined {
|
|
576
|
+
let words = ""
|
|
577
|
+
for (const node of element.childNodes) {
|
|
578
|
+
if ("tagName" in node) {
|
|
579
|
+
if (!LINE_BREAKS.has(node.tagName)) return undefined
|
|
580
|
+
words += " "
|
|
581
|
+
} else if (node.nodeName === "#text" && "value" in node) {
|
|
582
|
+
words += node.value
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const text = words.replace(/\s+/g, " ").trim()
|
|
587
|
+
return text === "" ? undefined : text
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function sourceOf(element: Element): VideoElementSource {
|
|
591
|
+
const location = element.sourceCodeLocation
|
|
592
|
+
const span = (at: { readonly startOffset: number; readonly endOffset: number } | undefined) => ({
|
|
593
|
+
start: at?.startOffset ?? 0,
|
|
594
|
+
end: at?.endOffset ?? 0,
|
|
595
|
+
})
|
|
596
|
+
|
|
597
|
+
const tag = span(location?.startTag)
|
|
598
|
+
const end = location?.endTag
|
|
599
|
+
return {
|
|
600
|
+
element: span(location ?? undefined),
|
|
601
|
+
tag,
|
|
602
|
+
attributes: Object.fromEntries(
|
|
603
|
+
Object.entries(location?.attrs ?? {}).map(([name, at]) => [name, span(at)])
|
|
604
|
+
),
|
|
605
|
+
...(end && end.startOffset >= tag.end
|
|
606
|
+
? { content: { start: tag.end, end: end.startOffset } }
|
|
607
|
+
: {}),
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** Seconds written in an attribute, as milliseconds; undefined unless a finite number of 0 or more. */
|
|
612
|
+
function readMs(written: string | undefined): number | undefined {
|
|
613
|
+
const seconds = readNumber(written)
|
|
614
|
+
return seconds === undefined || seconds < 0 ? undefined : Math.round(seconds * 1000)
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function readNumber(written: string | undefined): number | undefined {
|
|
618
|
+
const trimmed = written?.trim() ?? ""
|
|
619
|
+
if (trimmed === "") return undefined
|
|
620
|
+
const value = Number(trimmed)
|
|
621
|
+
return Number.isFinite(value) ? value : undefined
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* The elements among the nodes and their descendants, in source order, a template's content
|
|
626
|
+
* included. `stop` keeps an element but not what it holds.
|
|
627
|
+
*/
|
|
628
|
+
function elements(
|
|
629
|
+
nodes: readonly Node[],
|
|
630
|
+
options: { readonly stop?: (element: Element) => boolean } = {}
|
|
631
|
+
): Element[] {
|
|
632
|
+
const found: Element[] = []
|
|
633
|
+
const visit = (children: readonly Node[]) => {
|
|
634
|
+
for (const node of children) {
|
|
635
|
+
if (!("tagName" in node)) continue
|
|
636
|
+
found.push(node)
|
|
637
|
+
if (options.stop?.(node)) continue
|
|
638
|
+
visit(node.childNodes)
|
|
639
|
+
if (node.tagName === "template") visit(contentOf(node))
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
visit(nodes)
|
|
643
|
+
return found
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function contentOf(element: Element): readonly Node[] {
|
|
647
|
+
return "content" in element
|
|
648
|
+
? (element as DefaultTreeAdapterTypes.Template).content.childNodes
|
|
649
|
+
: []
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function attribute(element: Element, name: string): string | undefined {
|
|
653
|
+
return element.attrs.find((each) => each.name === name)?.value
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function has(element: Element, name: string): boolean {
|
|
657
|
+
return element.attrs.some((each) => each.name === name)
|
|
658
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { FileRef } from "./types"
|
|
7
7
|
|
|
8
|
-
export { DEFAULT_SIMPLE_FILE_UPLOAD_BYTES } from "./constants"
|
|
8
|
+
export { DEFAULT_SIMPLE_FILE_UPLOAD_BYTES, MAX_FILE_UPLOAD_BYTES } from "./constants"
|
|
9
9
|
export { blobDigestHex, blobIdFromDigest } from "./derive"
|
|
10
10
|
export type { BlobDigest, BlobInfo, FileRef } from "./types"
|
|
11
11
|
export { isBlobDigest, isFileRef } from "./validation"
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Maximum size, in bytes, of a
|
|
2
|
+
* Maximum size, in bytes, of a simple upload: one `POST /api/files` request.
|
|
3
3
|
*
|
|
4
4
|
* This is a single source of truth for two sides that must agree: it is both the
|
|
5
5
|
* server's simple-upload ceiling AND the client's threshold for switching to a
|
|
6
|
-
* staged
|
|
7
|
-
*
|
|
6
|
+
* staged upload. Keeping one constant prevents the two limits from drifting apart.
|
|
7
|
+
* A staged upload declared without a size is held to it too.
|
|
8
8
|
*/
|
|
9
9
|
export const DEFAULT_SIMPLE_FILE_UPLOAD_BYTES = 25 * 1024 * 1024
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The most one staged upload may hold. Its bytes go to blob storage as they arrive, or straight to
|
|
13
|
+
* the provider, never whole in the server's memory. A file artifact's one file may be this large.
|
|
14
|
+
*/
|
|
15
|
+
export const MAX_FILE_UPLOAD_BYTES = 2 * 1024 * 1024 * 1024
|