@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,898 @@
|
|
|
1
|
+
import { type DefaultTreeAdapterTypes, parse, parseFragment } from "parse5"
|
|
2
|
+
import { HTML_FILE_ATTRIBUTES } from "../html"
|
|
3
|
+
import { ARTIFACT_LIMITS } from "../limits"
|
|
4
|
+
|
|
5
|
+
// A video artifact is a HyperFrames project: `index.html`, the root composition, hosts one
|
|
6
|
+
// `<template>` scene file per scene, and the scenes play the files beside them. This reads the
|
|
7
|
+
// project the way HyperFrames resolves it, into the scenes and their times. Publishing checks a
|
|
8
|
+
// version with it, and editors read it in the browser. Browser-safe. See README.md.
|
|
9
|
+
|
|
10
|
+
type Node = DefaultTreeAdapterTypes.Node
|
|
11
|
+
type Element = DefaultTreeAdapterTypes.Element
|
|
12
|
+
|
|
13
|
+
/** The file a video plays from: its root composition, which hosts the scenes. */
|
|
14
|
+
export const VIDEO_ENTRY = "index.html"
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The frame rates a video plays at; a root composition without `data-fps` plays at 30. They are
|
|
18
|
+
* the ones HyperFrames renders a range of a film at, as an export renders a scene that overlaps
|
|
19
|
+
* another: it refuses 50.
|
|
20
|
+
*/
|
|
21
|
+
export const VIDEO_FRAME_RATES = [24, 25, 30, 60] as const
|
|
22
|
+
|
|
23
|
+
const DEFAULT_FPS = 30
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Where a scene starts, as its host's `data-start` writes it: at a number of seconds, or when
|
|
27
|
+
* another scene ends, `offset` seconds later (`demo + 0.5`) or earlier (`demo - 1`). `scene` is
|
|
28
|
+
* the name as written: the other scene's id, or its host's own `id`.
|
|
29
|
+
*/
|
|
30
|
+
export type VideoStart =
|
|
31
|
+
| { readonly type: "at"; readonly seconds: number }
|
|
32
|
+
| { readonly type: "after"; readonly scene: string; readonly offset: number }
|
|
33
|
+
|
|
34
|
+
/** Where something is written in its file: its first character, and the one past its last. */
|
|
35
|
+
export interface VideoSourceSpan {
|
|
36
|
+
readonly start: number
|
|
37
|
+
readonly end: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A file a composition plays or shows: `<video src>`, `<audio src>`, `<img src>`, and others. */
|
|
41
|
+
export interface VideoMediaReference {
|
|
42
|
+
readonly element: string
|
|
43
|
+
readonly attribute: string
|
|
44
|
+
/** As written, its entities decoded: a path, an `artifact:` address, or a URL. */
|
|
45
|
+
readonly value: string
|
|
46
|
+
/** The attribute, name and value, where its file writes it. */
|
|
47
|
+
readonly at: VideoSourceSpan
|
|
48
|
+
/**
|
|
49
|
+
* The file of a video that is never heard, its `src` or one of its `<source>`s': it writes
|
|
50
|
+
* `muted`, or a `data-has-audio` other than "true", as HyperFrames reads them.
|
|
51
|
+
*/
|
|
52
|
+
readonly muted?: true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* An element of `index.html`, a scene's host or the root, where an editor changes its attributes in
|
|
57
|
+
* place.
|
|
58
|
+
*/
|
|
59
|
+
export interface VideoSceneHost {
|
|
60
|
+
/** The whole element, its end tag included. */
|
|
61
|
+
readonly element: VideoSourceSpan
|
|
62
|
+
/** Its start tag. */
|
|
63
|
+
readonly tag: VideoSourceSpan
|
|
64
|
+
/** Each attribute it writes, by name, as the span of its name and value. */
|
|
65
|
+
readonly attributes: Readonly<Record<string, VideoSourceSpan>>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface VideoScene {
|
|
69
|
+
/**
|
|
70
|
+
* Its host's `data-composition-id`, which its file's composition, `#<id>` addresses, comments and
|
|
71
|
+
* the outline name it by.
|
|
72
|
+
*/
|
|
73
|
+
readonly id: string
|
|
74
|
+
/** Its host's own `id`, when it writes another: `data-start` may name the scene by either. */
|
|
75
|
+
readonly hostId?: string
|
|
76
|
+
/** Its host's `data-label`, HyperFrames' name for a scene. */
|
|
77
|
+
readonly label?: string
|
|
78
|
+
/** Its file in the version, from its host's `data-composition-src`. */
|
|
79
|
+
readonly src: string
|
|
80
|
+
readonly start: VideoStart
|
|
81
|
+
readonly startMs: number
|
|
82
|
+
readonly durationMs: number
|
|
83
|
+
/** What its file plays and shows. */
|
|
84
|
+
readonly media: readonly VideoMediaReference[]
|
|
85
|
+
/** The compositions its file nests, each by its `data-composition-src`. */
|
|
86
|
+
readonly compositions: readonly VideoMediaReference[]
|
|
87
|
+
readonly host: VideoSceneHost
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A video's composition: its frame, its length, and its scenes, resolved to times. */
|
|
91
|
+
export interface VideoComposition {
|
|
92
|
+
readonly width: number
|
|
93
|
+
readonly height: number
|
|
94
|
+
readonly fps: number
|
|
95
|
+
readonly durationMs: number
|
|
96
|
+
/**
|
|
97
|
+
* The instant that shows the video before it plays, from the root's `data-poster`, in
|
|
98
|
+
* milliseconds within its length; none when the root writes none.
|
|
99
|
+
*/
|
|
100
|
+
readonly posterMs?: number
|
|
101
|
+
/** In the order they start; scenes that start together, in the order `index.html` lists them. */
|
|
102
|
+
readonly scenes: readonly VideoScene[]
|
|
103
|
+
/** What `index.html` plays and shows itself, under or over every scene: a soundtrack, a logo. */
|
|
104
|
+
readonly media: readonly VideoMediaReference[]
|
|
105
|
+
/** The root composition's element. */
|
|
106
|
+
readonly root: VideoSceneHost
|
|
107
|
+
/**
|
|
108
|
+
* Each `<audio>` `index.html` plays beside its scenes, as the span of its whole element: heard,
|
|
109
|
+
* never seen, since a page shows no `<audio>` without `controls`.
|
|
110
|
+
*/
|
|
111
|
+
readonly sounds: readonly VideoSourceSpan[]
|
|
112
|
+
/**
|
|
113
|
+
* Whether `index.html` shows anything that moves beside its scenes, as its own text says: a
|
|
114
|
+
* timed element, a video, an inline script, which may build a timeline, or a CSS animation or
|
|
115
|
+
* transition. What a scene shows then depends on when it plays. A sound shows nothing, so a
|
|
116
|
+
* soundtrack does not count. A script loaded by its `src` only loads a library; it and the
|
|
117
|
+
* stylesheets the root links are in `links`, for whoever reads the version's files.
|
|
118
|
+
*/
|
|
119
|
+
readonly rootTimeline: boolean
|
|
120
|
+
/** The scripts and stylesheets `index.html` loads beside its scenes, by `src` and `href`. */
|
|
121
|
+
readonly links: {
|
|
122
|
+
readonly scripts: readonly VideoMediaReference[]
|
|
123
|
+
readonly stylesheets: readonly VideoMediaReference[]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* What `index.html` says on its own: the whole timeline, since each host writes its scene's start
|
|
129
|
+
* and length, but not what the scene files play.
|
|
130
|
+
*/
|
|
131
|
+
export interface VideoRoot extends Omit<VideoComposition, "scenes"> {
|
|
132
|
+
readonly scenes: readonly Omit<VideoScene, "media" | "compositions">[]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** A scene file, read on its own, or a composition a scene nests. */
|
|
136
|
+
export interface VideoSceneFile {
|
|
137
|
+
/** The `data-composition-id` of the composition its `<template>` holds. */
|
|
138
|
+
readonly id: string
|
|
139
|
+
readonly media: readonly VideoMediaReference[]
|
|
140
|
+
/**
|
|
141
|
+
* The compositions it nests, each an element with `data-composition-src` in its composition,
|
|
142
|
+
* whose file loads from the project's root, as `index.html`'s scenes do.
|
|
143
|
+
*/
|
|
144
|
+
readonly compositions: readonly VideoMediaReference[]
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
type Read<T> = T | { readonly error: string }
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Reads a whole project: `index.html`, then each scene file its hosts name, which `sceneFile`
|
|
151
|
+
* hands over as text, or undefined when the version has no such file.
|
|
152
|
+
*/
|
|
153
|
+
export function readVideoComposition(
|
|
154
|
+
index: string,
|
|
155
|
+
sceneFile: (path: string) => string | undefined
|
|
156
|
+
): Read<{ readonly composition: VideoComposition }> {
|
|
157
|
+
const root = parseVideoRoot(index)
|
|
158
|
+
if ("error" in root) return root
|
|
159
|
+
|
|
160
|
+
const files = new Map<string, VideoSceneFile>()
|
|
161
|
+
for (const { id, src } of root.root.scenes) {
|
|
162
|
+
const html = sceneFile(src)
|
|
163
|
+
if (html === undefined) return { error: missingScene(id, src) }
|
|
164
|
+
|
|
165
|
+
const scene = parseVideoScene(html, src)
|
|
166
|
+
if ("error" in scene) return scene
|
|
167
|
+
files.set(src, scene.scene)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return composeVideo(root.root, files)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Every file of the version a project plays and shows, as its HTML names them: `index.html`, each
|
|
175
|
+
* scene, and each composition a scene nests, all the way down. `file` hands a file's text over, or
|
|
176
|
+
* undefined when it has none to read; `exists` says whether the version holds a path. Lenient
|
|
177
|
+
* where publishing refuses: a file that cannot be read names nothing, and publishing then says
|
|
178
|
+
* what is wrong with it.
|
|
179
|
+
*/
|
|
180
|
+
export function videoFilesPlayed(
|
|
181
|
+
index: string,
|
|
182
|
+
file: (path: string) => string | undefined,
|
|
183
|
+
exists: (path: string) => boolean
|
|
184
|
+
): ReadonlySet<string> {
|
|
185
|
+
const played = new Set<string>()
|
|
186
|
+
const root = parseVideoRoot(index)
|
|
187
|
+
if ("error" in root) return played
|
|
188
|
+
|
|
189
|
+
const name = (from: string, references: readonly VideoMediaReference[]) => {
|
|
190
|
+
for (const { value } of references) {
|
|
191
|
+
const path = videoFilePath(from, value, exists)
|
|
192
|
+
if (path !== undefined) played.add(path)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
name(VIDEO_ENTRY, root.root.media)
|
|
196
|
+
|
|
197
|
+
// A composition nested twice, or in itself, is read once.
|
|
198
|
+
const read = new Set<string>()
|
|
199
|
+
const visit = (path: string) => {
|
|
200
|
+
if (read.has(path)) return
|
|
201
|
+
read.add(path)
|
|
202
|
+
|
|
203
|
+
const html = file(path)
|
|
204
|
+
const scene = html === undefined ? undefined : parseVideoScene(html, path)
|
|
205
|
+
if (!scene || "error" in scene) return
|
|
206
|
+
|
|
207
|
+
name(path, scene.scene.media)
|
|
208
|
+
for (const { value } of scene.scene.compositions) {
|
|
209
|
+
const nested = videoFilePath(VIDEO_ENTRY, value, exists)
|
|
210
|
+
if (nested !== undefined) visit(nested)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const scene of root.root.scenes) visit(scene.src)
|
|
214
|
+
|
|
215
|
+
return played
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Why a host's scene file is missing, for whoever reads the version's files themselves. */
|
|
219
|
+
export function missingScene(id: string, src: string): string {
|
|
220
|
+
return `${VIDEO_ENTRY}: scene '${id}' plays '${src}', which is not one of the video's files.`
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Reads `index.html`: the root composition, the first element with `data-composition-id`, or the
|
|
225
|
+
* one marked `data-root="true"`, as HyperFrames picks it, and the scene hosts in it, each an
|
|
226
|
+
* element with `data-composition-src`, with every start resolved to a time.
|
|
227
|
+
*/
|
|
228
|
+
export function parseVideoRoot(html: string): Read<{ readonly root: VideoRoot }> {
|
|
229
|
+
try {
|
|
230
|
+
return { root: readRoot(html) }
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (error instanceof CompositionError) return { error: `${VIDEO_ENTRY}: ${error.message}` }
|
|
233
|
+
throw error
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Reads a scene file: a `<template>` holding one composition, whose `data-composition-id` its
|
|
239
|
+
* host names. `file` is its path, which its errors name.
|
|
240
|
+
*/
|
|
241
|
+
export function parseVideoScene(
|
|
242
|
+
html: string,
|
|
243
|
+
file: string
|
|
244
|
+
): Read<{ readonly scene: VideoSceneFile }> {
|
|
245
|
+
try {
|
|
246
|
+
return { scene: readScene(html) }
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (error instanceof CompositionError) return { error: `${file}: ${error.message}` }
|
|
249
|
+
throw error
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Puts a root and its scene files, by path, together: each file holds its host's composition. */
|
|
254
|
+
export function composeVideo(
|
|
255
|
+
root: VideoRoot,
|
|
256
|
+
files: ReadonlyMap<string, VideoSceneFile>
|
|
257
|
+
): Read<{ readonly composition: VideoComposition }> {
|
|
258
|
+
const scenes: VideoScene[] = []
|
|
259
|
+
for (const scene of root.scenes) {
|
|
260
|
+
const file = files.get(scene.src)
|
|
261
|
+
if (!file) return { error: missingScene(scene.id, scene.src) }
|
|
262
|
+
if (file.id !== scene.id) {
|
|
263
|
+
return {
|
|
264
|
+
error: `${scene.src} holds composition '${file.id}', but its host in ${VIDEO_ENTRY} is '${scene.id}': give both one id.`,
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
scenes.push({ ...scene, media: file.media, compositions: file.compositions })
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return { composition: { ...root, scenes } }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The version's file a reference in `file` names, as HyperFrames finds it: a path that climbs out
|
|
275
|
+
* with `../`, or one beside `file` that the version holds, is read from `file`'s folder; any other
|
|
276
|
+
* from the project's root, where scenes are played from. Its `?query` and `#fragment` are not part
|
|
277
|
+
* of the path. Undefined for a reference that names no file of the version: an `artifact:`
|
|
278
|
+
* address, a URL, a path from a site's root, or one that climbs out of the project.
|
|
279
|
+
*/
|
|
280
|
+
export function videoFilePath(
|
|
281
|
+
file: string,
|
|
282
|
+
value: string,
|
|
283
|
+
exists: (path: string) => boolean
|
|
284
|
+
): string | undefined {
|
|
285
|
+
const written = value.trim()
|
|
286
|
+
if (written === "" || written.startsWith("/") || /^[a-z][a-z0-9+.-]*:/i.test(written)) {
|
|
287
|
+
return undefined
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const path = decodePath(written.replace(/[?#].*$/, ""))
|
|
291
|
+
const folder = file.includes("/") ? file.slice(0, file.lastIndexOf("/")) : ""
|
|
292
|
+
if (folder === "") return normalizePath(path)
|
|
293
|
+
|
|
294
|
+
const sibling = normalizePath(`${folder}/${path}`)
|
|
295
|
+
if (path.startsWith("../") || (sibling !== undefined && exists(sibling))) return sibling
|
|
296
|
+
return normalizePath(path)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
class CompositionError extends Error {}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* A scene's id: a letter, then letters, digits, `-` and `_`. HyperFrames reads a `data-start` that
|
|
303
|
+
* is a number as seconds, so an id never reads as one.
|
|
304
|
+
*/
|
|
305
|
+
const SCENE_ID = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/
|
|
306
|
+
|
|
307
|
+
/** What HyperFrames reads as a scene's name in `data-start`, alone or before `+ n` or `- n`. */
|
|
308
|
+
const START_REFERENCE = /^[A-Za-z0-9_.:-]+$/
|
|
309
|
+
const START_OFFSET = /^(.*?)\s*([+-])\s*((?:\d*\.)?\d+)$/
|
|
310
|
+
|
|
311
|
+
const SCENE_EXAMPLE =
|
|
312
|
+
'<div data-composition-id="intro" data-composition-src="scenes/intro.html" data-start="0" data-duration="4"></div>'
|
|
313
|
+
|
|
314
|
+
function readRoot(html: string): VideoRoot {
|
|
315
|
+
const document = parse(html, { sourceCodeLocationInfo: true })
|
|
316
|
+
const live = elements(document.childNodes)
|
|
317
|
+
const compositions = live.filter((element) => has(element, "data-composition-id"))
|
|
318
|
+
const root =
|
|
319
|
+
compositions.find((element) => attribute(element, "data-root") === "true") ?? compositions[0]
|
|
320
|
+
if (!root) {
|
|
321
|
+
throw new CompositionError(
|
|
322
|
+
'it has no root composition: wrap the video in <div data-composition-id="main" data-width="1920" data-height="1080">, its scenes inside.'
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const width = readSize(root, "data-width")
|
|
327
|
+
const height = readSize(root, "data-height")
|
|
328
|
+
const fps = readFps(root)
|
|
329
|
+
|
|
330
|
+
const hosts = elements(root.childNodes).filter((element) => has(element, "data-composition-src"))
|
|
331
|
+
if (hosts.length === 0) {
|
|
332
|
+
throw new CompositionError(
|
|
333
|
+
`its root composition hosts no scene: put each scene in it as ${SCENE_EXAMPLE}, its file a <template>.`
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
if (hosts.length > ARTIFACT_LIMITS.maxVideoScenes) {
|
|
337
|
+
throw new CompositionError(
|
|
338
|
+
`a video holds at most ${ARTIFACT_LIMITS.maxVideoScenes} scenes; this one has ${hosts.length}.`
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const read = hosts.map((host) => readHost(host, root))
|
|
343
|
+
checkNames(read, live, hosts)
|
|
344
|
+
|
|
345
|
+
const starts = resolveStarts(read)
|
|
346
|
+
// Sorting keeps the order of scenes that start together: the order index.html lists them.
|
|
347
|
+
const scenes = read
|
|
348
|
+
.map((scene) => ({ ...scene, startMs: starts.get(scene.id) ?? 0 }))
|
|
349
|
+
.sort((a, b) => a.startMs - b.startMs)
|
|
350
|
+
|
|
351
|
+
const durationMs = videoLength(root, hosts, fps, scenes)
|
|
352
|
+
const posterMs = readPoster(root, durationMs)
|
|
353
|
+
|
|
354
|
+
return {
|
|
355
|
+
width,
|
|
356
|
+
height,
|
|
357
|
+
fps,
|
|
358
|
+
durationMs,
|
|
359
|
+
...(posterMs === undefined ? {} : { posterMs }),
|
|
360
|
+
scenes,
|
|
361
|
+
media: mediaOf(document.childNodes),
|
|
362
|
+
root: hostSource(root),
|
|
363
|
+
sounds: rootSounds(document.childNodes, hosts),
|
|
364
|
+
rootTimeline: playsOnItsOwn(document.childNodes, root, hosts),
|
|
365
|
+
links: rootLinks(document.childNodes, hosts),
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* How long the video plays: until its last scene ends, or for the root's own `data-duration`,
|
|
371
|
+
* which may run past it, under a closing soundtrack or a logo the root shows.
|
|
372
|
+
*/
|
|
373
|
+
function videoLength(
|
|
374
|
+
root: Element,
|
|
375
|
+
hosts: readonly Element[],
|
|
376
|
+
fps: number,
|
|
377
|
+
scenes: readonly { readonly id: string; readonly startMs: number; readonly durationMs: number }[]
|
|
378
|
+
): number {
|
|
379
|
+
const end = Math.max(...scenes.map((scene) => scene.startMs + scene.durationMs))
|
|
380
|
+
|
|
381
|
+
// Without a length of its own, HyperFrames plays the root until the last thing on its timeline
|
|
382
|
+
// ends, a soundtrack as much as a scene, and a sound without data-duration for as long as its
|
|
383
|
+
// file lasts: a length the HTML does not say. The root says it instead.
|
|
384
|
+
const timed = has(root, "data-duration") ? undefined : ownTimeline(root, hosts)
|
|
385
|
+
if (timed) {
|
|
386
|
+
const id = attribute(timed, "id")
|
|
387
|
+
throw new CompositionError(
|
|
388
|
+
`<${timed.tagName}${id ? ` id="${id}"` : ""}> plays on the root composition's own timeline, so HyperFrames would play the video until it ends: give the root composition data-duration, the video's length in seconds.`
|
|
389
|
+
)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const durationMs = has(root, "data-duration")
|
|
393
|
+
? readSeconds(root, "data-duration", "the root composition")
|
|
394
|
+
: end
|
|
395
|
+
|
|
396
|
+
// A rounded start or length can leave the last scene ending a little past the video. Less than
|
|
397
|
+
// a frame past, the video cuts nothing anyone sees; a frame or more past, it cuts a frame.
|
|
398
|
+
if ((end - durationMs) * fps >= 1000) {
|
|
399
|
+
const last = scenes.find((scene) => scene.startMs + scene.durationMs === end)
|
|
400
|
+
throw new CompositionError(
|
|
401
|
+
`scene '${last?.id}' ends at ${end / 1000} s, after the root composition's data-duration of ${durationMs / 1000} s: lengthen the video, or end the scene sooner.`
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
if (durationMs > ARTIFACT_LIMITS.maxVideoSeconds * 1000) {
|
|
405
|
+
throw new CompositionError(
|
|
406
|
+
`the video lasts ${durationMs / 1000} s; a video lasts at most ${ARTIFACT_LIMITS.maxVideoSeconds} s.`
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
return durationMs
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* The first element on the root's own timeline, beside its scenes: one with `data-start`, or a
|
|
414
|
+
* video or sound, which HyperFrames plays from 0 without one. What a host holds is its scene's.
|
|
415
|
+
*/
|
|
416
|
+
function ownTimeline(root: Element, hosts: readonly Element[]): Element | undefined {
|
|
417
|
+
const hosted = hostedBy(hosts)
|
|
418
|
+
return elements(root.childNodes).find((element) => !hosted.has(element) && isTimed(element))
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Whether CSS moves on its own as time passes: an animation or a transition. */
|
|
422
|
+
export function cssMoves(css: string): boolean {
|
|
423
|
+
return /@keyframes|\banimation\b|\btransition\b/i.test(css)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Whether `index.html` shows anything that moves beside its scenes, anywhere in it: what
|
|
428
|
+
* `VideoComposition.rootTimeline` says. A sound is heard, never seen.
|
|
429
|
+
*/
|
|
430
|
+
function playsOnItsOwn(nodes: readonly Node[], root: Element, hosts: readonly Element[]): boolean {
|
|
431
|
+
const hosted = hostedBy(hosts)
|
|
432
|
+
return elements(nodes).some((element) => {
|
|
433
|
+
if (hosted.has(element) || element === root || element.tagName === "audio") return false
|
|
434
|
+
|
|
435
|
+
const inline = element.tagName === "script" && !has(element, "src")
|
|
436
|
+
return (
|
|
437
|
+
isTimed(element) ||
|
|
438
|
+
(inline && textOf(element).trim() !== "") ||
|
|
439
|
+
(element.tagName === "style" && cssMoves(textOf(element))) ||
|
|
440
|
+
cssMoves(attribute(element, "style") ?? "")
|
|
441
|
+
)
|
|
442
|
+
})
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** The `<audio>` elements `index.html` plays beside its scenes, which show nothing. */
|
|
446
|
+
function rootSounds(nodes: readonly Node[], hosts: readonly Element[]): VideoSourceSpan[] {
|
|
447
|
+
const hosted = hostedBy(hosts)
|
|
448
|
+
return elements(nodes).flatMap((element) => {
|
|
449
|
+
const at = element.sourceCodeLocation
|
|
450
|
+
if (element.tagName !== "audio" || hosted.has(element) || has(element, "controls") || !at) {
|
|
451
|
+
return []
|
|
452
|
+
}
|
|
453
|
+
return [{ start: at.startOffset, end: at.endOffset }]
|
|
454
|
+
})
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** The scripts and stylesheets `index.html` loads beside its scenes. */
|
|
458
|
+
function rootLinks(nodes: readonly Node[], hosts: readonly Element[]): VideoComposition["links"] {
|
|
459
|
+
const hosted = hostedBy(hosts)
|
|
460
|
+
const linked = (tag: string, name: string, matches: (element: Element) => boolean) =>
|
|
461
|
+
elements(nodes).flatMap((element) => {
|
|
462
|
+
const value = attribute(element, name)
|
|
463
|
+
const at = element.sourceCodeLocation?.attrs?.[name]
|
|
464
|
+
if (element.tagName !== tag || hosted.has(element) || !matches(element) || !value || !at) {
|
|
465
|
+
return []
|
|
466
|
+
}
|
|
467
|
+
return [
|
|
468
|
+
{ element: tag, attribute: name, value, at: { start: at.startOffset, end: at.endOffset } },
|
|
469
|
+
]
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
return {
|
|
473
|
+
scripts: linked("script", "src", () => true),
|
|
474
|
+
stylesheets: linked("link", "href", (element) =>
|
|
475
|
+
/\bstylesheet\b/i.test(attribute(element, "rel") ?? "")
|
|
476
|
+
),
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** An element on a timeline: one with `data-start`, or a video or a sound. */
|
|
481
|
+
function isTimed(element: Element): boolean {
|
|
482
|
+
return has(element, "data-start") || element.tagName === "audio" || element.tagName === "video"
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** The hosts and what they hold: their scenes', not the root's. */
|
|
486
|
+
function hostedBy(hosts: readonly Element[]): ReadonlySet<Element> {
|
|
487
|
+
return new Set(hosts.flatMap((host) => [host, ...elements(host.childNodes)]))
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** A scene as its host in `index.html` writes it, before its start is resolved. */
|
|
491
|
+
interface HostedScene {
|
|
492
|
+
readonly id: string
|
|
493
|
+
readonly hostId?: string
|
|
494
|
+
readonly label?: string
|
|
495
|
+
readonly src: string
|
|
496
|
+
readonly start: VideoStart
|
|
497
|
+
readonly durationMs: number
|
|
498
|
+
readonly host: VideoSceneHost
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** A scene host, refused unless it sits in the root composition itself. */
|
|
502
|
+
function readHost(host: Element, root: Element): HostedScene {
|
|
503
|
+
const id = attribute(host, "data-composition-id")
|
|
504
|
+
const named = id
|
|
505
|
+
? `scene '${id}'`
|
|
506
|
+
: `the scene playing '${attribute(host, "data-composition-src")}'`
|
|
507
|
+
|
|
508
|
+
const parent = closestComposition(host)
|
|
509
|
+
if (parent !== root) {
|
|
510
|
+
throw new CompositionError(
|
|
511
|
+
`${named} sits inside composition '${parent ? attribute(parent, "data-composition-id") : ""}': put every scene host in the root composition itself.`
|
|
512
|
+
)
|
|
513
|
+
}
|
|
514
|
+
if (id === undefined || !SCENE_ID.test(id)) {
|
|
515
|
+
throw new CompositionError(
|
|
516
|
+
`${named} needs a data-composition-id that starts with a letter, then letters, digits, - or _, such as "intro": it names the scene.`
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const hostId = attribute(host, "id")?.trim()
|
|
521
|
+
|
|
522
|
+
const src = normalizePath(decodePath(attribute(host, "data-composition-src") ?? ""))
|
|
523
|
+
if (src === undefined) {
|
|
524
|
+
throw new CompositionError(
|
|
525
|
+
`scene '${id}': data-composition-src names its file inside the project, such as "scenes/${id}.html".`
|
|
526
|
+
)
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const label = attribute(host, "data-label")?.replace(/\s+/g, " ").trim()
|
|
530
|
+
return {
|
|
531
|
+
id,
|
|
532
|
+
...(hostId && hostId !== id ? { hostId } : {}),
|
|
533
|
+
...(label ? { label: label.slice(0, ARTIFACT_LIMITS.maxTitleLength) } : {}),
|
|
534
|
+
src,
|
|
535
|
+
start: readStart(host, id),
|
|
536
|
+
// HyperFrames' own timeline reads a scene's length from its host alone: a scene file's
|
|
537
|
+
// data-duration leaves a host without one 0 seconds long there.
|
|
538
|
+
durationMs: readSeconds(host, "data-duration", `scene '${id}'`),
|
|
539
|
+
host: hostSource(host),
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Refuses a name `data-start` could read two ways. HyperFrames finds what it names by element `id`
|
|
545
|
+
* first, then by `data-composition-id`: so no two scenes share an id or a host's `id`, no host's
|
|
546
|
+
* `id` is another scene's id, and no other element takes either name.
|
|
547
|
+
*/
|
|
548
|
+
function checkNames(
|
|
549
|
+
hosts: readonly HostedScene[],
|
|
550
|
+
all: readonly Element[],
|
|
551
|
+
hostElements: readonly Element[]
|
|
552
|
+
): void {
|
|
553
|
+
const ids = new Set<string>()
|
|
554
|
+
for (const { id } of hosts) {
|
|
555
|
+
if (ids.has(id)) throw new CompositionError(`two scenes are '${id}': give each its own id.`)
|
|
556
|
+
ids.add(id)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const hostIds = new Set<string>()
|
|
560
|
+
for (const { id, hostId } of hosts) {
|
|
561
|
+
if (hostId === undefined) continue
|
|
562
|
+
if (hostIds.has(hostId)) {
|
|
563
|
+
throw new CompositionError(`two scene hosts have id "${hostId}": give each its own, or none.`)
|
|
564
|
+
}
|
|
565
|
+
if (ids.has(hostId)) {
|
|
566
|
+
throw new CompositionError(
|
|
567
|
+
`scene '${id}''s host has id "${hostId}", which is scene '${hostId}''s id, so data-start="${hostId}" would find '${id}': give the host another id, or none.`
|
|
568
|
+
)
|
|
569
|
+
}
|
|
570
|
+
hostIds.add(hostId)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const other = all.find((element) => {
|
|
574
|
+
const own = attribute(element, "id")
|
|
575
|
+
return (
|
|
576
|
+
own !== undefined && (ids.has(own) || hostIds.has(own)) && !hostElements.includes(element)
|
|
577
|
+
)
|
|
578
|
+
})
|
|
579
|
+
if (other) {
|
|
580
|
+
const name = attribute(other, "id")
|
|
581
|
+
throw new CompositionError(
|
|
582
|
+
`<${other.tagName} id="${name}"> takes the name of a scene, which data-start would find instead of the scene: rename the element.`
|
|
583
|
+
)
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function readScene(html: string): VideoSceneFile {
|
|
588
|
+
const fragment = parseFragment(html, { sourceCodeLocationInfo: true })
|
|
589
|
+
const [template, ...rest] = elements(fragment.childNodes, { deep: false })
|
|
590
|
+
const example = `<template><div data-composition-id="intro" data-width="1920" data-height="1080">…</div></template>`
|
|
591
|
+
|
|
592
|
+
if (!template || template.tagName !== "template" || rest.length > 0) {
|
|
593
|
+
throw new CompositionError(
|
|
594
|
+
`a scene file is one <template> holding its composition, as ${example}.`
|
|
595
|
+
)
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
const [composition] = elements(contentOf(template)).filter((element) =>
|
|
599
|
+
has(element, "data-composition-id")
|
|
600
|
+
)
|
|
601
|
+
const id = composition && attribute(composition, "data-composition-id")
|
|
602
|
+
if (!composition || !id) {
|
|
603
|
+
throw new CompositionError(`its <template> holds no composition: write it as ${example}.`)
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
return {
|
|
607
|
+
id,
|
|
608
|
+
media: mediaOf(fragment.childNodes),
|
|
609
|
+
compositions: elements(composition.childNodes).flatMap((element) => {
|
|
610
|
+
const value = attribute(element, "data-composition-src")
|
|
611
|
+
const at = element.sourceCodeLocation?.attrs?.["data-composition-src"]
|
|
612
|
+
if (value === undefined || !at) return []
|
|
613
|
+
return [
|
|
614
|
+
{
|
|
615
|
+
element: element.tagName,
|
|
616
|
+
attribute: "data-composition-src",
|
|
617
|
+
value,
|
|
618
|
+
at: { start: at.startOffset, end: at.endOffset },
|
|
619
|
+
},
|
|
620
|
+
]
|
|
621
|
+
}),
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Each scene's start, in milliseconds. A scene that starts after another starts when that one
|
|
627
|
+
* ends, so a chain is resolved from its first scene; one that leads back to itself never starts.
|
|
628
|
+
*/
|
|
629
|
+
function resolveStarts(hosts: readonly HostedScene[]): ReadonlyMap<string, number> {
|
|
630
|
+
// A host's own id first, as HyperFrames looks a name up; checkNames keeps the two apart.
|
|
631
|
+
const byName = new Map([
|
|
632
|
+
...hosts.map((host) => [host.id, host] as const),
|
|
633
|
+
...hosts.flatMap((host) => (host.hostId ? [[host.hostId, host] as const] : [])),
|
|
634
|
+
])
|
|
635
|
+
const starts = new Map<string, number>()
|
|
636
|
+
const resolving: string[] = []
|
|
637
|
+
|
|
638
|
+
const startOf = (host: HostedScene): number => {
|
|
639
|
+
const known = starts.get(host.id)
|
|
640
|
+
if (known !== undefined) return known
|
|
641
|
+
|
|
642
|
+
if (resolving.includes(host.id)) {
|
|
643
|
+
const cycle = resolving.slice(resolving.indexOf(host.id)).map((id) => `'${id}'`)
|
|
644
|
+
if (cycle.length === 1) {
|
|
645
|
+
throw new CompositionError(
|
|
646
|
+
`scene '${host.id}' starts after itself, so it never starts: start it at a number of seconds, or after another scene.`
|
|
647
|
+
)
|
|
648
|
+
}
|
|
649
|
+
throw new CompositionError(
|
|
650
|
+
`scenes ${cycle.join(", ")} each start after another of them, so none starts: start one of them at a number of seconds.`
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const { start } = host
|
|
655
|
+
let startMs: number
|
|
656
|
+
if (start.type === "at") {
|
|
657
|
+
startMs = Math.round(start.seconds * 1000)
|
|
658
|
+
} else {
|
|
659
|
+
const after = byName.get(start.scene)
|
|
660
|
+
if (!after) {
|
|
661
|
+
const others = hosts.filter((other) => other.id !== host.id).map((other) => `'${other.id}'`)
|
|
662
|
+
throw new CompositionError(
|
|
663
|
+
`scene '${host.id}' starts after '${start.scene}', which is no scene${others.length > 0 ? `; its scenes are ${others.slice(0, 8).join(", ")}${others.length > 8 ? ", …" : ""}` : ""}.`
|
|
664
|
+
)
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
resolving.push(host.id)
|
|
668
|
+
startMs = startOf(after) + after.durationMs + Math.round(start.offset * 1000)
|
|
669
|
+
resolving.pop()
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (startMs < 0) {
|
|
673
|
+
throw new CompositionError(
|
|
674
|
+
`scene '${host.id}' starts at ${startMs / 1000} s: a scene starts at 0 or later.`
|
|
675
|
+
)
|
|
676
|
+
}
|
|
677
|
+
starts.set(host.id, startMs)
|
|
678
|
+
return startMs
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
for (const host of hosts) startOf(host)
|
|
682
|
+
return starts
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/** A host's `data-start`, read as HyperFrames reads it. */
|
|
686
|
+
function readStart(host: Element, id: string): VideoStart {
|
|
687
|
+
const written = attribute(host, "data-start")?.trim() ?? ""
|
|
688
|
+
const refuse = () =>
|
|
689
|
+
new CompositionError(
|
|
690
|
+
`scene '${id}' needs data-start: a number of seconds, "intro" to start when scene 'intro' ends, or "intro + 0.5" or "intro - 0.5" to start that much later or sooner.`
|
|
691
|
+
)
|
|
692
|
+
if (written === "") throw refuse()
|
|
693
|
+
|
|
694
|
+
const seconds = Number(written)
|
|
695
|
+
if (Number.isFinite(seconds)) return { type: "at", seconds }
|
|
696
|
+
if (START_REFERENCE.test(written)) return { type: "after", scene: written, offset: 0 }
|
|
697
|
+
|
|
698
|
+
const offset = START_OFFSET.exec(written)
|
|
699
|
+
const [, scene = "", sign, magnitude = ""] = offset ?? []
|
|
700
|
+
if (!offset || !START_REFERENCE.test(scene)) throw refuse()
|
|
701
|
+
return { type: "after", scene, offset: (sign === "-" ? -1 : 1) * Number(magnitude) }
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* A root composition's width or height: an even number of pixels, as H.264 encodes. HyperFrames
|
|
706
|
+
* reads it with `parseInt`, so only digits read the same in both: it reads `1e3` as 1.
|
|
707
|
+
*/
|
|
708
|
+
function readSize(root: Element, name: "data-width" | "data-height"): number {
|
|
709
|
+
const written = attribute(root, name)?.trim() ?? ""
|
|
710
|
+
const value = /^\d+$/.test(written) ? Number(written) : Number.NaN
|
|
711
|
+
const max = ARTIFACT_LIMITS.maxVideoSize
|
|
712
|
+
if (!Number.isInteger(value) || value <= 0 || value > max || value % 2 !== 0) {
|
|
713
|
+
throw new CompositionError(
|
|
714
|
+
`the root composition's data-width and data-height are its frame's size in pixels, even numbers up to ${max}, such as 1920 and 1080.`
|
|
715
|
+
)
|
|
716
|
+
}
|
|
717
|
+
return value
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** A root composition's frame rate: whole digits, as HyperFrames reads it, which refuses `30.0`. */
|
|
721
|
+
function readFps(root: Element): number {
|
|
722
|
+
const written = attribute(root, "data-fps")?.trim()
|
|
723
|
+
if (written === undefined || written === "") return DEFAULT_FPS
|
|
724
|
+
|
|
725
|
+
const fps = /^\d+$/.test(written) ? Number(written) : Number.NaN
|
|
726
|
+
if (!(VIDEO_FRAME_RATES as readonly number[]).includes(fps)) {
|
|
727
|
+
throw new CompositionError(
|
|
728
|
+
`data-fps is ${VIDEO_FRAME_RATES.join(", ")} frames a second, or ${DEFAULT_FPS} without one; it is "${written}".`
|
|
729
|
+
)
|
|
730
|
+
}
|
|
731
|
+
return fps
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* The root's `data-poster`, the instant in seconds that shows the video before it plays, as
|
|
736
|
+
* milliseconds: from its start up to its last moment. HyperFrames reads no such attribute.
|
|
737
|
+
*/
|
|
738
|
+
function readPoster(root: Element, durationMs: number): number | undefined {
|
|
739
|
+
const written = attribute(root, "data-poster")?.trim()
|
|
740
|
+
if (written === undefined || written === "") return undefined
|
|
741
|
+
|
|
742
|
+
const ms = Math.round(Number(written) * 1000)
|
|
743
|
+
if (!Number.isFinite(ms) || ms < 0 || ms >= durationMs) {
|
|
744
|
+
throw new CompositionError(
|
|
745
|
+
`the root composition's data-poster is the instant that shows the video before it plays, in seconds from 0 up to its length of ${durationMs / 1000} s, such as 2.5; it is "${written}".`
|
|
746
|
+
)
|
|
747
|
+
}
|
|
748
|
+
return ms
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/** A length in seconds, a millisecond or more, as milliseconds. */
|
|
752
|
+
function readSeconds(element: Element, name: string, what: string): number {
|
|
753
|
+
const written = attribute(element, name)?.trim() ?? ""
|
|
754
|
+
const ms = Math.round(Number(written || Number.NaN) * 1000)
|
|
755
|
+
if (!Number.isFinite(ms) || ms <= 0) {
|
|
756
|
+
throw new CompositionError(
|
|
757
|
+
`${what}'s ${name} is its length in seconds, such as 4 or 2.5; it is "${written}".`
|
|
758
|
+
)
|
|
759
|
+
}
|
|
760
|
+
return ms
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Every file a page of a video plays and shows, inside its templates too, in source order:
|
|
765
|
+
* `index.html`, a scene file, or a composition one nests, whether it reads as one or not.
|
|
766
|
+
*/
|
|
767
|
+
export function videoPageMedia(path: string, html: string): VideoMediaReference[] {
|
|
768
|
+
const options = { sourceCodeLocationInfo: true }
|
|
769
|
+
const page = path === VIDEO_ENTRY ? parse(html, options) : parseFragment(html, options)
|
|
770
|
+
return mediaOf(page.childNodes)
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/** Every file reference among the nodes, inside templates too, in source order. */
|
|
774
|
+
function mediaOf(nodes: readonly Node[]): VideoMediaReference[] {
|
|
775
|
+
return elements(nodes, { templates: true }).flatMap((element) =>
|
|
776
|
+
HTML_FILE_ATTRIBUTES.flatMap(({ element: tag, attribute: name }) => {
|
|
777
|
+
if (element.tagName !== tag) return []
|
|
778
|
+
const value = attribute(element, name)
|
|
779
|
+
const at = element.sourceCodeLocation?.attrs?.[name]
|
|
780
|
+
if (value === undefined || !at) return []
|
|
781
|
+
|
|
782
|
+
const video = tag === "source" ? element.parentNode : element
|
|
783
|
+
const muted = name === "src" && video && "tagName" in video && neverHeard(video)
|
|
784
|
+
return [
|
|
785
|
+
{
|
|
786
|
+
element: tag,
|
|
787
|
+
attribute: name,
|
|
788
|
+
value,
|
|
789
|
+
at: { start: at.startOffset, end: at.endOffset },
|
|
790
|
+
...(muted ? { muted: true as const } : {}),
|
|
791
|
+
},
|
|
792
|
+
]
|
|
793
|
+
})
|
|
794
|
+
)
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Whether an element is a video HyperFrames never mixes into the sound: one that writes `muted`,
|
|
799
|
+
* or `data-has-audio` other than "true", as its `isAudibleVideoElement` reads them.
|
|
800
|
+
*/
|
|
801
|
+
function neverHeard(element: Element): boolean {
|
|
802
|
+
if (element.tagName !== "video") return false
|
|
803
|
+
|
|
804
|
+
const declared = attribute(element, "data-has-audio")
|
|
805
|
+
return has(element, "muted") || (declared !== undefined && declared !== "true")
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function hostSource(host: Element): VideoSceneHost {
|
|
809
|
+
const location = host.sourceCodeLocation
|
|
810
|
+
const span = (at: { readonly startOffset: number; readonly endOffset: number } | undefined) => ({
|
|
811
|
+
start: at?.startOffset ?? 0,
|
|
812
|
+
end: at?.endOffset ?? 0,
|
|
813
|
+
})
|
|
814
|
+
return {
|
|
815
|
+
element: span(location ?? undefined),
|
|
816
|
+
tag: span(location?.startTag),
|
|
817
|
+
attributes: Object.fromEntries(
|
|
818
|
+
Object.entries(location?.attrs ?? {}).map(([name, at]) => [name, span(at)])
|
|
819
|
+
),
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* The elements among the nodes and their descendants, in source order. A template's content is not
|
|
825
|
+
* in the page until a script puts it there, as HyperFrames does with a scene's: it is left out
|
|
826
|
+
* unless `templates` says. `deep: false` keeps the nodes' own elements alone.
|
|
827
|
+
*/
|
|
828
|
+
function elements(
|
|
829
|
+
nodes: readonly Node[],
|
|
830
|
+
options: { readonly templates?: boolean; readonly deep?: boolean } = {}
|
|
831
|
+
): Element[] {
|
|
832
|
+
const { templates = false, deep = true } = options
|
|
833
|
+
const found: Element[] = []
|
|
834
|
+
const visit = (children: readonly Node[]) => {
|
|
835
|
+
for (const node of children) {
|
|
836
|
+
if (!("tagName" in node)) continue
|
|
837
|
+
found.push(node)
|
|
838
|
+
if (!deep) continue
|
|
839
|
+
visit(node.childNodes)
|
|
840
|
+
if (templates && node.tagName === "template") visit(contentOf(node))
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
visit(nodes)
|
|
844
|
+
return found
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function contentOf(element: Element): readonly Node[] {
|
|
848
|
+
return "content" in element
|
|
849
|
+
? (element as DefaultTreeAdapterTypes.Template).content.childNodes
|
|
850
|
+
: []
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/** The nearest composition around an element, not itself: its parent composition. */
|
|
854
|
+
function closestComposition(element: Element): Element | undefined {
|
|
855
|
+
let parent = element.parentNode
|
|
856
|
+
while (parent && "tagName" in parent) {
|
|
857
|
+
if (has(parent, "data-composition-id")) return parent
|
|
858
|
+
parent = parent.parentNode
|
|
859
|
+
}
|
|
860
|
+
return undefined
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** The text an element holds, such as a `<style>`'s CSS. */
|
|
864
|
+
function textOf(element: Element): string {
|
|
865
|
+
return element.childNodes.map((node) => ("value" in node ? node.value : "")).join("")
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
function attribute(element: Element, name: string): string | undefined {
|
|
869
|
+
return element.attrs.find((each) => each.name === name)?.value
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function has(element: Element, name: string): boolean {
|
|
873
|
+
return element.attrs.some((each) => each.name === name)
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/** Percent escapes decoded where they are well formed, as a browser reads a path. */
|
|
877
|
+
function decodePath(path: string): string {
|
|
878
|
+
try {
|
|
879
|
+
return decodeURIComponent(path)
|
|
880
|
+
} catch {
|
|
881
|
+
return path
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** A relative path with `.` and `..` resolved; undefined when it is empty or climbs out. */
|
|
886
|
+
function normalizePath(path: string): string | undefined {
|
|
887
|
+
const segments: string[] = []
|
|
888
|
+
for (const segment of path.split("/")) {
|
|
889
|
+
if (segment === "" || segment === ".") continue
|
|
890
|
+
if (segment !== "..") {
|
|
891
|
+
segments.push(segment)
|
|
892
|
+
continue
|
|
893
|
+
}
|
|
894
|
+
if (segments.length === 0) return undefined
|
|
895
|
+
segments.pop()
|
|
896
|
+
}
|
|
897
|
+
return segments.length > 0 ? segments.join("/") : undefined
|
|
898
|
+
}
|