@sixb/core 0.2.6 → 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 +53 -50
- 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.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +62 -57
- 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/model-routing.d.ts +15 -4
- package/dist/agents/model-routing.d.ts.map +1 -1
- package/dist/agents/request.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/run-token.d.ts +6 -0
- package/dist/agents/run-token.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.js +2 -2
- 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/discovery.d.ts +6 -0
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.js +63 -60
- 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-s8xxef60.js → chunk-2mxq1yd9.js} +48 -41
- package/dist/{chunk-s8xxef60.js.map → chunk-2mxq1yd9.js.map} +6 -6
- package/dist/{chunk-dmnd9ea6.js → chunk-30a0ftnm.js} +2 -2
- package/dist/{chunk-nxysqbt0.js → chunk-389ybvw9.js} +6 -2
- package/dist/chunk-389ybvw9.js.map +10 -0
- package/dist/{chunk-qbd282aa.js → chunk-39q9ybav.js} +2 -2
- package/dist/{chunk-9c9yknwt.js → chunk-3d9w8t4n.js} +111 -23
- package/dist/{chunk-9c9yknwt.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-bcz9dxtf.js → chunk-3x902cja.js} +3 -3
- package/dist/{chunk-c4nrycdy.js → chunk-4q4a5a96.js} +1 -1
- package/dist/{chunk-7r9mqpva.js → chunk-4tdm3fsj.js} +100 -36
- package/dist/{chunk-7r9mqpva.js.map → chunk-4tdm3fsj.js.map} +10 -10
- package/dist/{chunk-ykchk644.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-kft7mp7z.js → chunk-5xkqasvn.js} +1 -1
- 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-pqj8vff9.js → chunk-8eqqqc1h.js} +3 -3
- package/dist/{chunk-425ydk65.js → chunk-8tefbhdx.js} +14 -14
- package/dist/{chunk-425ydk65.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-ym1bqd98.js → chunk-990a5bkc.js} +424 -76
- package/dist/chunk-990a5bkc.js.map +21 -0
- package/dist/{chunk-fmgf9h5e.js → chunk-9az7kjv4.js} +6 -6
- package/dist/{chunk-eg6xqef7.js → chunk-9e5t53z0.js} +3 -3
- package/dist/{chunk-eg6xqef7.js.map → chunk-9e5t53z0.js.map} +3 -3
- package/dist/{chunk-bs1sd0e0.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-ats8y3d9.js → chunk-as94vcty.js} +688 -504
- package/dist/{chunk-ats8y3d9.js.map → chunk-as94vcty.js.map} +21 -21
- 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-jt012fxq.js → chunk-jwjwvzj1.js} +797 -51
- package/dist/chunk-jwjwvzj1.js.map +38 -0
- package/dist/{chunk-f05994as.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-6hfbz4d0.js → chunk-r588h4ev.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-t19wjmnc.js → chunk-wpba6hhd.js} +54 -20
- package/dist/{chunk-t19wjmnc.js.map → chunk-wpba6hhd.js.map} +3 -3
- package/dist/{chunk-htdzx40w.js → chunk-wrb1x1ss.js} +12 -4
- package/dist/{chunk-htdzx40w.js.map → chunk-wrb1x1ss.js.map} +3 -3
- package/dist/{chunk-5sswe5ej.js → chunk-wsv23wvr.js} +2 -2
- package/dist/{chunk-90nqenq8.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-gaj8djsw.js → chunk-y57eawng.js} +10 -5
- package/dist/{chunk-gaj8djsw.js.map → chunk-y57eawng.js.map} +3 -3
- package/dist/{chunk-8ncg20rd.js → chunk-yah25st6.js} +5 -5
- package/dist/chunk-yah25st6.js.map +10 -0
- package/dist/{chunk-grt2j5vp.js → chunk-ywvxcmqj.js} +106 -13
- package/dist/{chunk-grt2j5vp.js.map → chunk-ywvxcmqj.js.map} +8 -7
- package/dist/{chunk-xf76csps.js → chunk-zmq9xc9s.js} +70 -31
- package/dist/{chunk-xf76csps.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/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +2 -2
- package/dist/deploy/internal.js.map +2 -2
- package/dist/deploy/types.d.ts +8 -58
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/env/index.d.ts +10 -3
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/index.js.map +2 -2
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/execution/agent.js +53 -50
- 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 +53 -50
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.js +54 -51
- 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 +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -67
- 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 +53 -50
- 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/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +14 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +3 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.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/resolve-definitions.d.ts +2 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/errors.d.ts +19 -0
- package/dist/sandboxes/errors.d.ts.map +1 -1
- package/dist/sandboxes/exec.d.ts +2 -0
- package/dist/sandboxes/exec.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +1 -1
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +14 -8
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +15 -1
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +5 -5
- package/dist/storage/agents/types.d.ts +27 -1
- 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 +25 -23
- 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 +686 -75
- package/dist/testing/index.js.map +10 -10
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/sandboxes-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 +60 -57
- 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/index.ts +1 -0
- package/src/agents/model-call-retry.ts +69 -0
- package/src/agents/model-loop.ts +86 -12
- package/src/agents/model-routing.ts +104 -38
- package/src/agents/request.ts +27 -1
- 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/run-token.ts +7 -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/bootstrap/discovery.ts +61 -11
- package/src/deploy/index.ts +0 -5
- package/src/deploy/types.ts +8 -63
- package/src/deploy/validation.ts +1 -1
- package/src/env/index.ts +10 -4
- 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 +21 -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/create.ts +1 -0
- package/src/runtime/definitions.ts +25 -0
- package/src/runtime/host.ts +6 -1
- package/src/runtime/index.ts +6 -1
- package/src/runtime/internal.ts +3 -1
- package/src/runtime/resolve-definitions.ts +7 -1
- package/src/runtime/sixb.ts +12 -4
- package/src/sandboxes/README.md +12 -2
- package/src/sandboxes/errors.ts +27 -0
- package/src/sandboxes/exec.ts +3 -1
- package/src/sandboxes/index.ts +3 -0
- package/src/sandboxes/sandbox.ts +15 -1
- 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/provider.ts +8 -0
- package/src/storage/agents/types.ts +32 -1
- 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 +135 -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 +330 -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/src/testing/sandboxes-contract.ts +50 -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-f05994as.js.map +0 -10
- package/dist/chunk-gfdh9kqa.js.map +0 -11
- package/dist/chunk-jt012fxq.js.map +0 -34
- package/dist/chunk-mbwsgjn7.js.map +0 -11
- package/dist/chunk-nxysqbt0.js.map +0 -10
- 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-ym1bqd98.js.map +0 -19
- /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-bcz9dxtf.js.map → chunk-3x902cja.js.map} +0 -0
- /package/dist/{chunk-c4nrycdy.js.map → chunk-4q4a5a96.js.map} +0 -0
- /package/dist/{chunk-ykchk644.js.map → chunk-4w8qzy9w.js.map} +0 -0
- /package/dist/{chunk-kft7mp7z.js.map → chunk-5xkqasvn.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-pqj8vff9.js.map → chunk-8eqqqc1h.js.map} +0 -0
- /package/dist/{chunk-jka26v8c.js.map → chunk-8x1bsp68.js.map} +0 -0
- /package/dist/{chunk-fmgf9h5e.js.map → chunk-9az7kjv4.js.map} +0 -0
- /package/dist/{chunk-bs1sd0e0.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-6hfbz4d0.js.map → chunk-r588h4ev.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-5sswe5ej.js.map → chunk-wsv23wvr.js.map} +0 -0
- /package/dist/{chunk-90nqenq8.js.map → chunk-x0hqc54n.js.map} +0 -0
- /package/dist/{chunk-3neam1y5.js.map → chunk-y3qb965a.js.map} +0 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
// What styles a clip of a scene, and how that look goes with it to another scene: the rules that
|
|
2
|
+
// style the element itself, in the order the page reads them, each rewritten to reach it alone by
|
|
3
|
+
// its id, one id more specific than it was so they keep their cascade among themselves and outrank
|
|
4
|
+
// the scene they land in, within the `@media` they were in, and the keyframes they animate by,
|
|
5
|
+
// renamed when that scene already has others of the same name. A scene's own rules never change, so
|
|
6
|
+
// the clips it already shows keep their look. What cannot be told from the stylesheets alone, a
|
|
7
|
+
// rule through a wrapper or the clip's place among its siblings, is not carried but said. Strings
|
|
8
|
+
// in, strings out: `edit.ts` reads and writes the files. Browser-safe, as `composition.ts`.
|
|
9
|
+
|
|
10
|
+
/** A rule or an at-rule of a stylesheet: what comes before its braces, and what they hold. */
|
|
11
|
+
export interface CssBlock {
|
|
12
|
+
readonly prelude: string
|
|
13
|
+
readonly body: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** An element, as a selector reads it. */
|
|
17
|
+
export interface LookElement {
|
|
18
|
+
readonly tag: string
|
|
19
|
+
readonly id?: string
|
|
20
|
+
readonly classes: readonly string[]
|
|
21
|
+
readonly attributes: ReadonlyMap<string, string>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A stylesheet that reaches a scene, given in the order the page reads them: the sheets
|
|
26
|
+
* `index.html` links, then its file's own `<style>`, then the look carried for the clip there.
|
|
27
|
+
* `byId` keeps only the rules that name the element by its id, as a scene the clip is not from
|
|
28
|
+
* styles it; `carried` is a look written by {@link writtenLook}, already one id more specific.
|
|
29
|
+
*/
|
|
30
|
+
export interface LookSheet {
|
|
31
|
+
readonly blocks: readonly CssBlock[]
|
|
32
|
+
readonly byId?: boolean
|
|
33
|
+
readonly carried?: boolean
|
|
34
|
+
/** A sheet `index.html` links, which every scene reads: its rules hold wherever a clip goes. */
|
|
35
|
+
readonly shared?: boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Where an element is, as a selector reads it: the elements that hold it, outermost first, the
|
|
40
|
+
* video's root and its scene's host and composition among them.
|
|
41
|
+
*/
|
|
42
|
+
export type LookContext = readonly LookElement[]
|
|
43
|
+
|
|
44
|
+
/** A rule of an element's look, as {@link writtenLook} writes it for another scene. */
|
|
45
|
+
export interface LookRule {
|
|
46
|
+
/** Whether it was scoped to its scene, as it will be to the next. */
|
|
47
|
+
readonly scoped: boolean
|
|
48
|
+
/** Its tag, if it names one, and the rest of what it names the element by, its id aside. */
|
|
49
|
+
readonly tag: string
|
|
50
|
+
readonly rest: string
|
|
51
|
+
/** What it styles inside the element, through it, as written: ` .hot`, ` > span`. */
|
|
52
|
+
readonly tail: string
|
|
53
|
+
/** How many times it names the element's id, which the rewritten rule names it as often. */
|
|
54
|
+
readonly ids: number
|
|
55
|
+
readonly body: string
|
|
56
|
+
/** The `@media`, `@supports`, `@container` or `@layer` it was in, outermost first. */
|
|
57
|
+
readonly within: readonly string[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* An element's look: each rule that styles it itself, in cascade order, the keyframes they
|
|
62
|
+
* animate by, and whether some rule may style it there that cannot be carried.
|
|
63
|
+
*/
|
|
64
|
+
export interface Look {
|
|
65
|
+
readonly rules: readonly LookRule[]
|
|
66
|
+
readonly keyframes: ReadonlyMap<string, string>
|
|
67
|
+
readonly uncertain: boolean
|
|
68
|
+
/** The rules that make it uncertain, which {@link lookDiffers} reads where it was and lands. */
|
|
69
|
+
readonly unsure?: readonly {
|
|
70
|
+
readonly selector: string
|
|
71
|
+
readonly body: string
|
|
72
|
+
readonly sheet: LookSheet
|
|
73
|
+
}[]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The keyframes a scene reads by name: its own and its linked sheets', and the looks carried in. */
|
|
77
|
+
export interface SceneKeyframes {
|
|
78
|
+
readonly own: ReadonlyMap<string, string>
|
|
79
|
+
readonly carried: ReadonlyMap<string, readonly string[]>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The top-level rules and at-rules of a stylesheet, comments aside: `@media` and its kind are
|
|
84
|
+
* blocks of their own, which no rule of theirs is taken from.
|
|
85
|
+
*/
|
|
86
|
+
export function cssBlocks(css: string): CssBlock[] {
|
|
87
|
+
const text = css.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
88
|
+
const blocks: CssBlock[] = []
|
|
89
|
+
let at = 0
|
|
90
|
+
while (at < text.length) {
|
|
91
|
+
const open = text.indexOf("{", at)
|
|
92
|
+
if (open < 0) break
|
|
93
|
+
|
|
94
|
+
// What a statement before it ends, as `@import …;`, is not its prelude.
|
|
95
|
+
const prelude = (text.slice(at, open).split(";").at(-1) ?? "").trim()
|
|
96
|
+
let depth = 0
|
|
97
|
+
let quote = ""
|
|
98
|
+
let close = open
|
|
99
|
+
for (; close < text.length; close += 1) {
|
|
100
|
+
const char = text[close]
|
|
101
|
+
if (quote) {
|
|
102
|
+
if (char === "\\") close += 1
|
|
103
|
+
else if (char === quote) quote = ""
|
|
104
|
+
} else if (char === '"' || char === "'") quote = char
|
|
105
|
+
else if (char === "{") depth += 1
|
|
106
|
+
else if (char === "}" && --depth === 0) break
|
|
107
|
+
}
|
|
108
|
+
blocks.push({ prelude, body: text.slice(open + 1, close) })
|
|
109
|
+
at = close + 1
|
|
110
|
+
}
|
|
111
|
+
return blocks
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The keyframes a stylesheet defines, by name. */
|
|
115
|
+
export function keyframesOf(blocks: readonly CssBlock[]): Map<string, string> {
|
|
116
|
+
const found = new Map<string, string>()
|
|
117
|
+
for (const block of blocks) {
|
|
118
|
+
const name = KEYFRAMES.exec(block.prelude)?.[1]
|
|
119
|
+
if (name && !found.has(name)) found.set(name, block.body)
|
|
120
|
+
}
|
|
121
|
+
return found
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The look an element has in `scene`: each rule of the sheets that reach it there whose selector
|
|
126
|
+
* styles the element itself, by its tag, id, classes, attributes and states, `:is()` and `:not()`
|
|
127
|
+
* read for it, within the scene or within no composition, in the order the page reads them, and
|
|
128
|
+
* each inside the `@media` and its kind it was in. A rule that reaches it through a wrapper, or by
|
|
129
|
+
* its place among its siblings, is not carried, and makes the look uncertain.
|
|
130
|
+
*/
|
|
131
|
+
export function lookOf(element: LookElement, scene: string, sheets: readonly LookSheet[]): Look {
|
|
132
|
+
const rules: LookRule[] = []
|
|
133
|
+
const keyframes = new Map<string, string>()
|
|
134
|
+
const defined = new Map<string, string>()
|
|
135
|
+
const unsure: { selector: string; body: string; sheet: LookSheet }[] = []
|
|
136
|
+
for (const sheet of sheets) {
|
|
137
|
+
for (const [name, body] of keyframesOf(sheet.blocks)) {
|
|
138
|
+
if (!defined.has(name)) defined.set(name, body)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const visit = (blocks: readonly CssBlock[], sheet: LookSheet, within: readonly string[]) => {
|
|
143
|
+
for (const block of blocks) {
|
|
144
|
+
if (GROUPING.test(block.prelude)) {
|
|
145
|
+
visit(cssBlocks(block.body), sheet, [...within, block.prelude])
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
if (block.prelude.startsWith("@")) continue
|
|
149
|
+
|
|
150
|
+
for (const selector of selectorsOf(block.prelude)) {
|
|
151
|
+
const styled = stylesItself(selector, element, scene, sheet)
|
|
152
|
+
if (styled === "uncertain") unsure.push({ selector, body: block.body, sheet })
|
|
153
|
+
if (styled === undefined || styled === "uncertain") continue
|
|
154
|
+
|
|
155
|
+
const rule = { ...styled, body: block.body, within }
|
|
156
|
+
const same = (other: LookRule) =>
|
|
157
|
+
cssKey(JSON.stringify(other)) === cssKey(JSON.stringify(rule))
|
|
158
|
+
if (!rules.some(same)) rules.push(rule)
|
|
159
|
+
for (const [name, frames] of defined) {
|
|
160
|
+
if (animatesBy(block.body, name)) keyframes.set(name, frames)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (const sheet of sheets) visit(sheet.blocks, sheet, [])
|
|
166
|
+
return {
|
|
167
|
+
rules,
|
|
168
|
+
keyframes,
|
|
169
|
+
uncertain: unsure.length > 0,
|
|
170
|
+
...(unsure.length > 0 ? { unsure } : {}),
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Whether an element looks otherwise where it lands than where it was, as far as its look's
|
|
176
|
+
* stylesheets can tell: a rule it could not carry, through what holds it, that styles it in
|
|
177
|
+
* one place and not the other, or that a scene's own sheet gave it; or one a linked sheet gives it
|
|
178
|
+
* in both, whose properties a carried rule now outranks. Without where it is and lands, any such
|
|
179
|
+
* rule makes it so.
|
|
180
|
+
*/
|
|
181
|
+
export function lookDiffers(
|
|
182
|
+
look: Look,
|
|
183
|
+
element: LookElement,
|
|
184
|
+
context?: { readonly from: LookContext; readonly to: LookContext }
|
|
185
|
+
): boolean {
|
|
186
|
+
if (!look.uncertain) return false
|
|
187
|
+
if (!context) return true
|
|
188
|
+
|
|
189
|
+
const both: string[] = []
|
|
190
|
+
for (const { selector, body, sheet } of look.unsure ?? []) {
|
|
191
|
+
if (sheet.carried || sheet.byId) return true
|
|
192
|
+
const from = matchesIn(selector, element, context.from)
|
|
193
|
+
if (from === "uncertain") return true
|
|
194
|
+
if (!sheet.shared) {
|
|
195
|
+
// A scene's own sheet stays with it: what it gave the element there, it gives none here.
|
|
196
|
+
if (from) return true
|
|
197
|
+
continue
|
|
198
|
+
}
|
|
199
|
+
const to = matchesIn(selector, element, context.to)
|
|
200
|
+
if (to === "uncertain" || to !== from) return true
|
|
201
|
+
if (from) both.push(body)
|
|
202
|
+
}
|
|
203
|
+
return both.some((body) => look.rules.some((rule) => sharesProperty(body, rule.body)))
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Whether a selector styles an element where it is, `ancestors` holding it: `"uncertain"` when
|
|
208
|
+
* it depends on what a stylesheet cannot tell, its siblings or its place among them.
|
|
209
|
+
*/
|
|
210
|
+
export function matchesIn(
|
|
211
|
+
selector: string,
|
|
212
|
+
element: LookElement,
|
|
213
|
+
ancestors: LookContext
|
|
214
|
+
): boolean | "uncertain" {
|
|
215
|
+
const compounds = compoundsOf(selector).map((each) => ({
|
|
216
|
+
combinator: each.combinator,
|
|
217
|
+
parts: subjectParts(each.compound),
|
|
218
|
+
}))
|
|
219
|
+
if (compounds.length === 0) return false
|
|
220
|
+
if (compounds.some((each) => !each.parts)) return "uncertain"
|
|
221
|
+
if (compounds.slice(1).some((each) => each.combinator !== " " && each.combinator !== ">")) {
|
|
222
|
+
return "uncertain"
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let uncertain = false
|
|
226
|
+
const holds = (at: number, candidate: LookElement, held: boolean) => {
|
|
227
|
+
const matched = matchCompound(compounds[at]?.parts ?? [], candidate, held)
|
|
228
|
+
if (matched === "uncertain") uncertain = true
|
|
229
|
+
return matched !== false
|
|
230
|
+
}
|
|
231
|
+
// From the element out, each compound on an element holding the one after it: its parent,
|
|
232
|
+
// after `>`, or any further out.
|
|
233
|
+
const within = (at: number, from: number): boolean => {
|
|
234
|
+
if (at < 0) return true
|
|
235
|
+
if (compounds[at + 1]?.combinator === ">") {
|
|
236
|
+
const parent = ancestors[from]
|
|
237
|
+
return parent !== undefined && holds(at, parent, true) && within(at - 1, from - 1)
|
|
238
|
+
}
|
|
239
|
+
for (let outer = from; outer >= 0; outer -= 1) {
|
|
240
|
+
const candidate = ancestors[outer]
|
|
241
|
+
if (candidate && holds(at, candidate, true) && within(at - 1, outer - 1)) return true
|
|
242
|
+
}
|
|
243
|
+
return false
|
|
244
|
+
}
|
|
245
|
+
const last = compounds.length - 1
|
|
246
|
+
const matched = holds(last, element, false) && within(last - 1, ancestors.length - 1)
|
|
247
|
+
return uncertain ? "uncertain" : matched
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Whether two rules' declarations set a property in common, a shorthand and its longhands too. */
|
|
251
|
+
function sharesProperty(one: string, other: string): boolean {
|
|
252
|
+
const names = (body: string) =>
|
|
253
|
+
body
|
|
254
|
+
.split(";")
|
|
255
|
+
.map((declaration) => declaration.split(":")[0]?.trim().toLowerCase() ?? "")
|
|
256
|
+
.filter(Boolean)
|
|
257
|
+
const theirs = names(other)
|
|
258
|
+
return names(one).some((name) =>
|
|
259
|
+
theirs.some(
|
|
260
|
+
(each) => each === name || each.startsWith(`${name}-`) || name.startsWith(`${each}-`)
|
|
261
|
+
)
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A look written for `scene`, once, for every clip that carries it by `data-look="<key>"`: each
|
|
267
|
+
* rule as it was, reaching those clips by their key, as specific as it was and one id more,
|
|
268
|
+
* `[data-composition-id="<scene>"] p:is([data-look="<key>"], #sixb-look).caption`, `:is()` taking
|
|
269
|
+
* its most specific argument's weight, an id none has; so the rules keep their cascade among
|
|
270
|
+
* themselves and outrank the scene's own. In the `@media` each was in, with the keyframes they
|
|
271
|
+
* animate by: a name the scene reads already, with the same frames, is used as it is; with others,
|
|
272
|
+
* the look's take a name of their own, so neither changes the other.
|
|
273
|
+
*/
|
|
274
|
+
export function writtenLook(
|
|
275
|
+
look: Look,
|
|
276
|
+
scene: string,
|
|
277
|
+
key: string,
|
|
278
|
+
seen: SceneKeyframes
|
|
279
|
+
): string[] {
|
|
280
|
+
const renamed = new Map<string, string>()
|
|
281
|
+
const frames: string[] = []
|
|
282
|
+
for (const [name, body] of look.keyframes) {
|
|
283
|
+
const same = (other: string | undefined) =>
|
|
284
|
+
other !== undefined && cssKey(other) === cssKey(body)
|
|
285
|
+
const free = (candidate: string) => {
|
|
286
|
+
const own = seen.own.get(candidate)
|
|
287
|
+
const carried = seen.carried.get(candidate) ?? []
|
|
288
|
+
return (own === undefined || same(own)) && carried.every((each) => same(each))
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
let chosen = name
|
|
292
|
+
for (let n = 2; !free(chosen); n += 1) chosen = `${name}-${n}`
|
|
293
|
+
if (chosen !== name) renamed.set(name, chosen)
|
|
294
|
+
if (!same(seen.own.get(chosen))) frames.push(cssRule(`@keyframes ${chosen}`, body))
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const rules = look.rules.map((rule) => {
|
|
298
|
+
let body = rule.body
|
|
299
|
+
for (const [from, to] of renamed) body = renameAnimation(body, from, to)
|
|
300
|
+
const scope = rule.scoped ? `[data-composition-id="${scene}"] ` : ""
|
|
301
|
+
const reach = `:is([data-look="${key}"], #${LOOK_ID})`.repeat(rule.ids)
|
|
302
|
+
const selector = `${scope}${rule.tag}${reach}${rule.rest}${rule.tail}`
|
|
303
|
+
return rule.within.reduceRight(
|
|
304
|
+
(inner, prelude) => wrapped(prelude, inner),
|
|
305
|
+
cssRule(selector, body)
|
|
306
|
+
)
|
|
307
|
+
})
|
|
308
|
+
return [...rules, ...frames]
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** A rule inside an at-rule: on one line when the rule is, else indented under it. */
|
|
312
|
+
function wrapped(prelude: string, inner: string): string {
|
|
313
|
+
if (!inner.includes("\n")) return `${prelude} { ${inner} }`
|
|
314
|
+
return [`${prelude} {`, ...inner.split("\n").map((line) => ` ${line}`), "}"].join("\n")
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Whether a scene's script names an element as a selector does: by its id or a class. */
|
|
318
|
+
export function scriptNames(scripts: string, element: LookElement): boolean {
|
|
319
|
+
if (scripts.trim() === "") return false
|
|
320
|
+
const byId =
|
|
321
|
+
element.id !== undefined &&
|
|
322
|
+
(inSelector(scripts, `#${element.id}`) ||
|
|
323
|
+
new RegExp(`getElementById\\(\\s*["'\`]${escapeRegExp(element.id)}["'\`]`).test(scripts))
|
|
324
|
+
return byId || element.classes.some((name) => inSelector(scripts, `.${name}`))
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Whether a scene's script reaches an element by what it is rather than by its id: one of its
|
|
329
|
+
* classes, or its tag within the scene, `${scene} video`, as the Agent's timelines write it.
|
|
330
|
+
*/
|
|
331
|
+
export function scriptReaches(scripts: string, element: LookElement): boolean {
|
|
332
|
+
if (scripts.trim() === "") return false
|
|
333
|
+
const byTag = new RegExp(`[\\]}]\\s+${escapeRegExp(element.tag)}(?=["'\`\\s,.:\\[>)])`, "i")
|
|
334
|
+
return byTag.test(scripts) || element.classes.some((name) => inSelector(scripts, `.${name}`))
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Whether a scene's script reaches an element where it lands, `context` holding it: a selector it
|
|
339
|
+
* writes matches it there, as a string, or a template naming the strings it declares,
|
|
340
|
+
* `${scene} video`. A script building one otherwise is read as {@link scriptReaches} reads it.
|
|
341
|
+
*/
|
|
342
|
+
export function scriptReachesIn(
|
|
343
|
+
scripts: string,
|
|
344
|
+
element: LookElement,
|
|
345
|
+
context: LookContext
|
|
346
|
+
): boolean {
|
|
347
|
+
if (scripts.trim() === "") return false
|
|
348
|
+
const strings = [...scripts.matchAll(/(["'`])((?:\\.|(?!\1)[^\\\n])*)\1/g)]
|
|
349
|
+
const declared = new Map<string, string>()
|
|
350
|
+
for (const match of scripts.matchAll(
|
|
351
|
+
/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(["'])((?:\\.|(?!\2)[^\\\n])*)\2/g
|
|
352
|
+
)) {
|
|
353
|
+
if (match[1]) declared.set(match[1], match[3] ?? "")
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let built = false
|
|
357
|
+
const selectors = strings.flatMap((match) => {
|
|
358
|
+
const text = (match[2] ?? "").replace(/\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g, (whole, name) =>
|
|
359
|
+
match[1] === "`" && declared.has(name) ? (declared.get(name) ?? "") : whole
|
|
360
|
+
)
|
|
361
|
+
if (text.includes("${")) built = true
|
|
362
|
+
const selector = text.trim()
|
|
363
|
+
return selector && /^[\w\s\-.#[\]="':(),>+~*|^$]+$/.test(selector) && /[.#[]/.test(selector)
|
|
364
|
+
? [selector]
|
|
365
|
+
: []
|
|
366
|
+
})
|
|
367
|
+
if (built || selectors.length === 0) return scriptReaches(scripts, element)
|
|
368
|
+
return selectors.some((text) =>
|
|
369
|
+
selectorsOf(text).some((selector) => matchesIn(selector, element, context) !== false)
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** A rule as a scene's file writes it: on one line when its body is, else one line each. */
|
|
374
|
+
export function cssRule(prelude: string, body: string): string {
|
|
375
|
+
const lines = body
|
|
376
|
+
.split("\n")
|
|
377
|
+
.map((line) => line.trim())
|
|
378
|
+
.filter(Boolean)
|
|
379
|
+
if (lines.length <= 1) return `${prelude} { ${lines[0] ?? ""} }`
|
|
380
|
+
return [`${prelude} {`, ...lines.map((line) => ` ${line}`), "}"].join("\n")
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const KEYFRAMES = /^@(?:-webkit-)?keyframes\s+([\w-]+)/i
|
|
384
|
+
|
|
385
|
+
/** Each composition a selector names by `[data-composition-id=…]`. */
|
|
386
|
+
const SCOPE = /^\[\s*data-composition-id\s*=\s*(["']?)([^"'\]\s]+)\1\s*\]$/
|
|
387
|
+
|
|
388
|
+
/** An id no element has, which gives a look's rules the weight of one: no edit names one so. */
|
|
389
|
+
export const LOOK_ID = "sixb-look"
|
|
390
|
+
|
|
391
|
+
/** How a carried look's rule reaches its clips, as {@link writtenLook} writes it. */
|
|
392
|
+
const REACH = new RegExp(`^:is\\(\\[data-look="[^"]*"\\], #${LOOK_ID}\\)$`)
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* A look's key, from the scene it is from and what it is: the same look, the same key, whichever
|
|
396
|
+
* clip carries it and wherever it was carried: its keyframes by their place, whatever a scene
|
|
397
|
+
* renamed them, and its rules as {@link cssKey} reads them. Two FNV-1a hashes of it, and its
|
|
398
|
+
* length.
|
|
399
|
+
*/
|
|
400
|
+
export function lookKey(home: string, look: Look): string {
|
|
401
|
+
const names = [...look.keyframes.keys()]
|
|
402
|
+
const rules = look.rules.map((rule) => ({
|
|
403
|
+
...rule,
|
|
404
|
+
within: rule.within.map(cssKey),
|
|
405
|
+
body: cssKey(
|
|
406
|
+
names.reduce((body, name, at) => renameAnimation(body, name, `\0${at}`), rule.body)
|
|
407
|
+
),
|
|
408
|
+
}))
|
|
409
|
+
const frames = [...look.keyframes.values()].map(cssKey)
|
|
410
|
+
const text = `${home}\n${JSON.stringify(rules)}\n${JSON.stringify(frames)}`
|
|
411
|
+
let low = 0x811c9dc5
|
|
412
|
+
let high = 0x01000193
|
|
413
|
+
for (let at = 0; at < text.length; at += 1) {
|
|
414
|
+
const code = text.charCodeAt(at)
|
|
415
|
+
low = Math.imul(low ^ code, 0x01000193)
|
|
416
|
+
high = Math.imul(high ^ code, 0x811c9dc5) ^ (low >>> 15)
|
|
417
|
+
}
|
|
418
|
+
return [high >>> 0, low >>> 0, text.length].map((each) => each.toString(36)).join("")
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** The at-rules whose rules apply under a condition, which a carried rule stays inside. */
|
|
422
|
+
const GROUPING = /^@(?:media|supports|container|layer)\b/i
|
|
423
|
+
|
|
424
|
+
/** States a clip may be in, which a rule keeps as it reaches it elsewhere. */
|
|
425
|
+
const STATES = new Set([
|
|
426
|
+
"hover",
|
|
427
|
+
"focus",
|
|
428
|
+
"focus-visible",
|
|
429
|
+
"focus-within",
|
|
430
|
+
"active",
|
|
431
|
+
"visited",
|
|
432
|
+
"link",
|
|
433
|
+
"any-link",
|
|
434
|
+
"checked",
|
|
435
|
+
"disabled",
|
|
436
|
+
"enabled",
|
|
437
|
+
])
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* How a selector styles an element in `scene`: its own compound, rewritten as {@link LookRule}
|
|
441
|
+
* holds it, when every compound before it is the scene and the last names the element by what it
|
|
442
|
+
* is; `"uncertain"` when it may style it in ways the stylesheet alone cannot tell, through a
|
|
443
|
+
* wrapper or by its place among its siblings; undefined when it does not.
|
|
444
|
+
*/
|
|
445
|
+
function stylesItself(
|
|
446
|
+
selector: string,
|
|
447
|
+
element: LookElement,
|
|
448
|
+
scene: string,
|
|
449
|
+
sheet: LookSheet
|
|
450
|
+
): Omit<LookRule, "body" | "within"> | "uncertain" | undefined {
|
|
451
|
+
const compounds = compoundsOf(selector)
|
|
452
|
+
if (compounds.length === 0) return undefined
|
|
453
|
+
|
|
454
|
+
// The scene it is scoped to, then the compound that would be the clip, then what it holds.
|
|
455
|
+
let first = 0
|
|
456
|
+
while (first < compounds.length - 1 && SCOPE.exec(compounds[first]?.compound ?? "")) first += 1
|
|
457
|
+
const scopes = compounds.slice(0, first).map((each) => SCOPE.exec(each.compound)?.[2])
|
|
458
|
+
if (scopes.some((each) => each !== scene)) return undefined
|
|
459
|
+
const anchor = compounds[first]
|
|
460
|
+
const after = compounds.slice(first + 1)
|
|
461
|
+
if (!anchor) return undefined
|
|
462
|
+
|
|
463
|
+
const parts = subjectParts(anchor.compound)
|
|
464
|
+
const matched = parts ? matchCompound(parts, element) : "uncertain"
|
|
465
|
+
if (matched === false || !parts) {
|
|
466
|
+
// Not the clip: it may be one further on, through a wrapper the stylesheet cannot see.
|
|
467
|
+
const last = compounds.at(-1)
|
|
468
|
+
const lastParts = last && after.length > 0 ? subjectParts(last.compound) : undefined
|
|
469
|
+
if (!parts) return "uncertain"
|
|
470
|
+
return lastParts && matchCompound(lastParts, element) !== false ? "uncertain" : undefined
|
|
471
|
+
}
|
|
472
|
+
if (matched === "uncertain") return "uncertain"
|
|
473
|
+
// What a rule styles beside the clip, its siblings, stays with the scene.
|
|
474
|
+
if (after.some((each) => each.combinator !== " " && each.combinator !== ">")) return "uncertain"
|
|
475
|
+
|
|
476
|
+
let names = false
|
|
477
|
+
let ids = 0
|
|
478
|
+
let tag = ""
|
|
479
|
+
let rest = ""
|
|
480
|
+
for (const part of parts) {
|
|
481
|
+
// A carried look reaches its clips by their key, as an id would: read so, it is the look it
|
|
482
|
+
// was, and takes the same key.
|
|
483
|
+
if (sheet.carried && REACH.test(part)) {
|
|
484
|
+
ids += 1
|
|
485
|
+
names = true
|
|
486
|
+
} else if (part.startsWith("#")) {
|
|
487
|
+
ids += 1
|
|
488
|
+
names = true
|
|
489
|
+
} else if (part.startsWith(".")) {
|
|
490
|
+
if (sheet.byId) return undefined
|
|
491
|
+
names = true
|
|
492
|
+
rest += part
|
|
493
|
+
} else if (/^[a-zA-Z]/.test(part)) {
|
|
494
|
+
if (sheet.byId) return undefined
|
|
495
|
+
names = true
|
|
496
|
+
tag = part
|
|
497
|
+
} else if (part !== "*") {
|
|
498
|
+
// `:is()` and `:where()`, read for the element above, name it by what they hold.
|
|
499
|
+
if (/^:(?:is|where)\(/i.test(part)) names = true
|
|
500
|
+
rest += part
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (!names) return undefined
|
|
504
|
+
if (sheet.byId && ids === 0) return undefined
|
|
505
|
+
|
|
506
|
+
// What it holds, styled through it, as written: `.caption .hot`, `.caption > span`.
|
|
507
|
+
const tail = after
|
|
508
|
+
.map((each) => `${each.combinator === " " ? " " : ` ${each.combinator} `}${each.compound}`)
|
|
509
|
+
.join("")
|
|
510
|
+
|
|
511
|
+
// One id more specific than it was, unless it is a carried look's, which is already.
|
|
512
|
+
return { scoped: first > 0, tag, rest, tail, ids: sheet.carried ? ids : ids + 1 }
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/** A compound's simple selectors, in order; undefined when it holds what is not one. */
|
|
516
|
+
function subjectParts(compound: string): string[] | undefined {
|
|
517
|
+
const parts =
|
|
518
|
+
compound.match(
|
|
519
|
+
/::?[\w-]+(?:\((?:[^()]|\([^()]*\))*\))?|\[[^\]]*\]|[#.](?:[\w-]|\\.)+|\*|[a-zA-Z][\w-]*/g
|
|
520
|
+
) ?? []
|
|
521
|
+
return parts.join("") === compound ? parts : undefined
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Whether a compound's simple selectors match an element: `"uncertain"` when one of them depends
|
|
526
|
+
* on what the element's attributes do not say, its place among its siblings or what it holds.
|
|
527
|
+
*/
|
|
528
|
+
function matchCompound(
|
|
529
|
+
parts: readonly string[],
|
|
530
|
+
element: LookElement,
|
|
531
|
+
held = false
|
|
532
|
+
): boolean | "uncertain" {
|
|
533
|
+
let uncertain = false
|
|
534
|
+
for (const part of parts) {
|
|
535
|
+
if (part.startsWith("::")) continue
|
|
536
|
+
if (part.startsWith(":")) {
|
|
537
|
+
const name = /^:([\w-]+)/.exec(part)?.[1]?.toLowerCase() ?? ""
|
|
538
|
+
const args = /\((.*)\)$/.exec(part)?.[1]
|
|
539
|
+
if (STATES.has(name)) continue
|
|
540
|
+
if ((name === "is" || name === "where" || name === "not") && args !== undefined) {
|
|
541
|
+
const each = selectorsOf(args).map((arg) => {
|
|
542
|
+
const inner = compoundsOf(arg).length === 1 ? subjectParts(arg.trim()) : undefined
|
|
543
|
+
return inner ? matchCompound(inner, element, held) : "uncertain"
|
|
544
|
+
})
|
|
545
|
+
const any = each.includes(true)
|
|
546
|
+
if (name === "not" ? any : !any && !each.includes("uncertain")) return false
|
|
547
|
+
if (each.includes("uncertain") && !(name !== "not" && any)) uncertain = true
|
|
548
|
+
continue
|
|
549
|
+
}
|
|
550
|
+
uncertain = true
|
|
551
|
+
} else if (part.startsWith("#")) {
|
|
552
|
+
if (unescaped(part.slice(1)) !== element.id) return false
|
|
553
|
+
} else if (part.startsWith(".")) {
|
|
554
|
+
if (!element.classes.includes(unescaped(part.slice(1)))) return false
|
|
555
|
+
} else if (part.startsWith("[")) {
|
|
556
|
+
const attribute = /^\[\s*([\w-]+)\s*(?:([~^$*|]?=)\s*(["']?)([^"'\]]*)\3\s*)?\]$/.exec(part)
|
|
557
|
+
const name = attribute?.[1]?.toLowerCase()
|
|
558
|
+
if (!attribute || !name) {
|
|
559
|
+
uncertain = true
|
|
560
|
+
continue
|
|
561
|
+
}
|
|
562
|
+
// A clip is no composition; what holds it may be.
|
|
563
|
+
const value = element.attributes.get(name)
|
|
564
|
+
if ((name === "data-composition-id" && !held) || value === undefined) return false
|
|
565
|
+
if (attribute[2] && !attributeMatches(value, attribute[2], attribute[4] ?? "")) return false
|
|
566
|
+
} else if (part !== "*" && part.toLowerCase() !== element.tag) {
|
|
567
|
+
return false
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return uncertain ? "uncertain" : true
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** A selector's compounds, split at its combinators outside brackets and parentheses. */
|
|
574
|
+
function compoundsOf(
|
|
575
|
+
selector: string
|
|
576
|
+
): { readonly combinator: string; readonly compound: string }[] {
|
|
577
|
+
const compounds: { combinator: string; compound: string }[] = []
|
|
578
|
+
let depth = 0
|
|
579
|
+
let current = ""
|
|
580
|
+
let combinator = ""
|
|
581
|
+
const text = selector.trim()
|
|
582
|
+
for (let at = 0; at < text.length; at += 1) {
|
|
583
|
+
const char = text[at] ?? ""
|
|
584
|
+
if (char === "\\") {
|
|
585
|
+
current += text.slice(at, at + 2)
|
|
586
|
+
at += 1
|
|
587
|
+
continue
|
|
588
|
+
}
|
|
589
|
+
if (char === "[" || char === "(") depth += 1
|
|
590
|
+
if (char === "]" || char === ")") depth -= 1
|
|
591
|
+
if (depth === 0 && /[\s>+~]/.test(char)) {
|
|
592
|
+
if (current)
|
|
593
|
+
compounds.push({
|
|
594
|
+
combinator: compounds.length === 0 ? "" : combinator || " ",
|
|
595
|
+
compound: current,
|
|
596
|
+
})
|
|
597
|
+
if (current) combinator = ""
|
|
598
|
+
current = ""
|
|
599
|
+
if (char !== " " && !/\s/.test(char)) combinator = char
|
|
600
|
+
continue
|
|
601
|
+
}
|
|
602
|
+
current += char
|
|
603
|
+
}
|
|
604
|
+
if (current)
|
|
605
|
+
compounds.push({
|
|
606
|
+
combinator: compounds.length === 0 ? "" : combinator || " ",
|
|
607
|
+
compound: current,
|
|
608
|
+
})
|
|
609
|
+
return compounds
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** A selector list's selectors, split at its commas outside brackets, parentheses and quotes. */
|
|
613
|
+
function selectorsOf(prelude: string): string[] {
|
|
614
|
+
const selectors: string[] = []
|
|
615
|
+
let depth = 0
|
|
616
|
+
let quote = ""
|
|
617
|
+
let start = 0
|
|
618
|
+
for (let at = 0; at < prelude.length; at += 1) {
|
|
619
|
+
const char = prelude[at]
|
|
620
|
+
if (quote) {
|
|
621
|
+
if (char === quote) quote = ""
|
|
622
|
+
} else if (char === '"' || char === "'") quote = char
|
|
623
|
+
else if (char === "(" || char === "[") depth += 1
|
|
624
|
+
else if (char === ")" || char === "]") depth -= 1
|
|
625
|
+
else if (char === "," && depth === 0) {
|
|
626
|
+
selectors.push(prelude.slice(start, at).trim())
|
|
627
|
+
start = at + 1
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
selectors.push(prelude.slice(start).trim())
|
|
631
|
+
return selectors.filter(Boolean)
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** Whether an attribute's value matches an attribute selector's `op` and `wanted`. */
|
|
635
|
+
function attributeMatches(value: string, op: string, wanted: string): boolean {
|
|
636
|
+
switch (op) {
|
|
637
|
+
case "~=":
|
|
638
|
+
return value.split(/\s+/).includes(wanted)
|
|
639
|
+
case "^=":
|
|
640
|
+
return wanted !== "" && value.startsWith(wanted)
|
|
641
|
+
case "$=":
|
|
642
|
+
return wanted !== "" && value.endsWith(wanted)
|
|
643
|
+
case "*=":
|
|
644
|
+
return wanted !== "" && value.includes(wanted)
|
|
645
|
+
case "|=":
|
|
646
|
+
return value === wanted || value.startsWith(`${wanted}-`)
|
|
647
|
+
default:
|
|
648
|
+
return value === wanted
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/** An identifier as a selector escapes it, read: `md\\:big` is the class `md:big`. */
|
|
653
|
+
function unescaped(identifier: string): string {
|
|
654
|
+
return identifier.replace(/\\([0-9a-fA-F]{1,6}\s?|.)/g, (_, escaped: string) =>
|
|
655
|
+
/^[0-9a-fA-F]/.test(escaped) && escaped.trim().length > 1
|
|
656
|
+
? String.fromCodePoint(Number.parseInt(escaped.trim(), 16))
|
|
657
|
+
: escaped.trim() || escaped
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/** Whether a rule's declarations animate by the keyframes `name`. */
|
|
662
|
+
function animatesBy(body: string, name: string): boolean {
|
|
663
|
+
return new RegExp(
|
|
664
|
+
`animation(?:-name)?\\s*:[^;}]*(?<![\\w-])${escapeRegExp(name)}(?![\\w-])`
|
|
665
|
+
).test(body)
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** A rule's declarations, animating by `to` where they animated by `from`. */
|
|
669
|
+
function renameAnimation(body: string, from: string, to: string): string {
|
|
670
|
+
return body.replace(/(animation(?:-name)?\s*:)([^;}]*)/g, (_, property, value: string) => {
|
|
671
|
+
const pattern = new RegExp(`(?<![\\w-])${escapeRegExp(from)}(?![\\w-])`, "g")
|
|
672
|
+
return `${property}${value.replace(pattern, to)}`
|
|
673
|
+
})
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** A token a script writes where a selector does, never as a property, as `demo.from(…)`. */
|
|
677
|
+
function inSelector(scripts: string, token: string): boolean {
|
|
678
|
+
return new RegExp(`(?<![\\w$)\\]])${escapeRegExp(token)}(?![\\w-])`).test(scripts)
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** A rule's text, its spaces aside, to tell two alike. */
|
|
682
|
+
export function cssKey(css: string): string {
|
|
683
|
+
return css
|
|
684
|
+
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
685
|
+
.replace(/\s+/g, " ")
|
|
686
|
+
.replace(/\s*([{};:,>])\s*/g, "$1")
|
|
687
|
+
.replace(/;}/g, "}")
|
|
688
|
+
.replace(/;$/, "")
|
|
689
|
+
.trim()
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function escapeRegExp(value: string): string {
|
|
693
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
694
|
+
}
|