mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-03-17 19:31:11 +00:00
1 line
No EOL
3.9 KiB
JavaScript
1 line
No EOL
3.9 KiB
JavaScript
import{n as e}from"./jsx-runtime-BpGWiA-R.js";import{i as t,n}from"./traditional-DPdbI9gv.js";var r=e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=((e,t,n)=>{let a=e;if(t){let i=n?.equalityFn||Object.is,o=e(r.getState());a=n=>{let r=e(n);if(!i(o,r)){let e=o;t(o=r,e)}},n?.fireImmediately&&t(o,o)}return i(a)}),e(t,n,r)};function i(e){let t=new Map;for(let n of e.state.datablocks.values()){if(n._class!==`tsshapeconstructor`)continue;let e=n.baseshape;if(typeof e!=`string`)continue;let r=e.toLowerCase(),i=r.replace(/\.dts$/i,``)+`_`,a=new Map;for(let e=0;e<=127;e++){let t=n[`sequence${e}`];if(typeof t!=`string`)continue;let r=t.indexOf(` `);if(r===-1)continue;let o=t.slice(0,r).toLowerCase(),s=t.slice(r+1).trim().toLowerCase();if(!s||!o.startsWith(i)||!o.endsWith(`.dsq`))continue;let c=o.slice(i.length,-4);c&&a.set(s,c)}a.size>0&&t.set(r,a)}return t}function a(e,t,n){let r=new Map;for(let n of e){let e=t.clipAction(n);r.set(n.name.toLowerCase(),e)}if(n)for(let[e,t]of n){let n=r.get(t);n&&!r.has(e)&&r.set(e,n)}return r}e();function o(e){return e.toLowerCase()}function s(e){let t=o(e.trim());return t.startsWith(`$`)?t.slice(1):t}function c(e,t,n){return e<t?t:e>n?n:e}function l(e){let t={},n={},r={},i={};for(let n of e.state.objectsById.values())t[n._id]=0,n._name&&(r[o(n._name)]=n._id,n._isDatablock&&(i[o(n._name)]=n._id));for(let t of e.state.globals.keys())n[s(t)]=0;return{objectVersionById:t,globalVersionByName:n,objectIdsByName:r,datablockIdsByName:i}}var u={runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0},playback:{recording:null,status:`stopped`,timeMs:0,rate:1,durationMs:0,streamSnapshot:null}},d=t()(r(e=>({...u,setRuntime(t){let n=l(t),r=i(t);e(e=>({...e,runtime:{runtime:t,sequenceAliases:r,objectVersionById:n.objectVersionById,globalVersionByName:n.globalVersionByName,objectIdsByName:n.objectIdsByName,datablockIdsByName:n.datablockIdsByName,lastRuntimeTick:0}}))},clearRuntime(){e(e=>({...e,runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0}}))},applyRuntimeBatch(t,n){t.length!==0&&e(e=>{let r={...e.runtime.objectVersionById},i={...e.runtime.globalVersionByName},a={...e.runtime.objectIdsByName},c={...e.runtime.datablockIdsByName},l=e=>{e!=null&&(r[e]=(r[e]??0)+1)};for(let e of t){if(e.type===`object.created`){let t=e.object;if(l(e.objectId),t._name){let n=o(t._name);a[n]=e.objectId,t._isDatablock&&(c[n]=e.objectId)}l(t._parent?._id);continue}if(e.type===`object.deleted`){let t=e.object;if(delete r[e.objectId],t?._name){let e=o(t._name);delete a[e],t._isDatablock&&delete c[e]}l(t?._parent?._id);continue}if(e.type===`field.changed`){l(e.objectId);continue}if(e.type===`global.changed`){let t=s(e.name);i[t]=(i[t]??0)+1;continue}}let u=n?.tick??(e.runtime.lastRuntimeTick>0?e.runtime.lastRuntimeTick+1:1);return{...e,runtime:{...e.runtime,objectVersionById:r,globalVersionByName:i,objectIdsByName:a,datablockIdsByName:c,lastRuntimeTick:u}}})},setRecording(t){let n=Math.max(0,(t?.duration??0)*1e3);e(e=>({...e,playback:{recording:t,status:t?`stopped`:e.playback.status,timeMs:t?0:e.playback.timeMs,rate:t?1:e.playback.rate,durationMs:n,streamSnapshot:t?null:e.playback.streamSnapshot}}))},setPlaybackTime(t){e(e=>{let n=c(t,0,e.playback.durationMs);return{...e,playback:{...e.playback,timeMs:n}}})},setPlaybackStatus(t){e(e=>({...e,playback:{...e.playback,status:t}}))},setPlaybackRate(t){let n=Number.isFinite(t)?c(t,.01,16):1;e(e=>({...e,playback:{...e.playback,rate:n}}))},setPlaybackStreamSnapshot(t){e(e=>({...e,playback:{...e.playback,streamSnapshot:t}}))}}))),f=0;function p(){return f}function m(e,t){f+=e*t*1e3}function h(){f=0}d.subscribe(e=>e.playback.status,e=>{e===`stopped`&&h()});function g(){return d}function _(e,t){return n(d,e,t)}export{g as a,_ as i,p as n,a as o,d as r,r as s,m as t}; |