@omnimedia/omnitool 1.1.0-71 → 1.1.0-72

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.
@@ -42,7 +42,7 @@ export class Compositor {
42
42
  * get object for current Composition
43
43
  * */
44
44
  getActiveObject(id) {
45
- return this.#activeObjects.get(id);
45
+ return this.#activeObjects.get(id)?.sprite;
46
46
  }
47
47
  async #renderLayer(layer, parent) {
48
48
  if (Array.isArray(layer)) {
@@ -71,16 +71,16 @@ export class Compositor {
71
71
  }
72
72
  }
73
73
  #renderTextLayer(layer, parent) {
74
- const { sprite, dispose } = this.#findOrCreate(layer);
74
+ const sprite = this.#findOrCreate(layer);
75
75
  this.#applyTransform(sprite, layer.matrix);
76
76
  parent.addChild(sprite);
77
77
  return {
78
- dispose: () => dispose()
78
+ dispose: () => { }
79
79
  };
80
80
  }
81
81
  #renderImageLayer(layer, parent) {
82
82
  const texture = Texture.from(layer.frame);
83
- const { sprite, dispose } = this.#findOrCreate(layer);
83
+ const sprite = this.#findOrCreate(layer);
84
84
  sprite.texture = texture;
85
85
  this.#applyTransform(sprite, layer.matrix);
86
86
  parent.addChild(sprite);
@@ -88,7 +88,6 @@ export class Compositor {
88
88
  dispose: () => {
89
89
  texture.destroy(true);
90
90
  layer.frame.close();
91
- dispose();
92
91
  }
93
92
  };
94
93
  }
@@ -124,15 +123,15 @@ export class Compositor {
124
123
  const up = () => this.onPointerUp.publish({ id: layer.id, object: text });
125
124
  text.on("pointerdown", down);
126
125
  text.on("pointerup", up);
127
- return {
128
- sprite: this.#activeObjects
129
- .set(layer.id, text)
130
- .get(layer.id),
131
- dispose: () => {
126
+ return this.#activeObjects
127
+ .set(layer.id, {
128
+ sprite: text,
129
+ dispose() {
132
130
  text.off("pointerdown", down);
133
131
  text.off("pointerup", up);
134
132
  }
135
- };
133
+ })
134
+ .get(layer.id)?.sprite;
136
135
  }
137
136
  case 'image': {
138
137
  const sprite = new Sprite();
@@ -141,23 +140,20 @@ export class Compositor {
141
140
  const up = () => this.onPointerUp.publish({ id: layer.id, object: sprite });
142
141
  sprite.on("pointerdown", down);
143
142
  sprite.on("pointerup", up);
144
- return {
145
- sprite: this.#activeObjects
146
- .set(layer.id, sprite)
147
- .get(layer.id),
148
- dispose: () => {
143
+ return this.#activeObjects
144
+ .set(layer.id, {
145
+ sprite,
146
+ dispose() {
149
147
  sprite.off("pointerdown", down);
150
148
  sprite.off("pointerup", up);
151
149
  }
152
- };
150
+ })
151
+ .get(layer.id)?.sprite;
153
152
  }
154
153
  }
155
154
  }
156
155
  else
157
- return {
158
- sprite: object,
159
- dispose: () => { }
160
- };
156
+ return object.sprite;
161
157
  }
162
158
  #collectIds(layers) {
163
159
  const result = new Set();
@@ -176,8 +172,9 @@ export class Compositor {
176
172
  #cleanup(activeIds) {
177
173
  for (const id of this.#activeObjects.keys()) {
178
174
  if (!activeIds.has(id)) {
179
- const obj = this.#activeObjects.get(id);
180
- obj.destroy(true);
175
+ const { sprite, dispose } = this.#activeObjects.get(id);
176
+ sprite.destroy(true);
177
+ dispose();
181
178
  this.#activeObjects.delete(id);
182
179
  }
183
180
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compositor.js","sourceRoot":"","sources":["../../../s/driver/parts/compositor.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAY,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,SAAS,CAAA;AAItF,OAAO,EAAO,YAAY,EAAC,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAC,cAAc,EAAC,MAAM,yCAAyC,CAAA;AAEtE,MAAM,OAAO,UAAU;IAiBH;IAhBnB,aAAa,GAAG,GAAG,EAAiC,CAAA;IACpD,WAAW,GAAG,GAAG,EAAiC,CAAA;IAElD,MAAM,CAAC,KAAK,CAAC,KAAK;QACjB,MAAM,QAAQ,GAAG,MAAM,kBAAkB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,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,MAAM,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAE,CAAA;gBACtD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBACpB,OAAO,EAAE,CAAA;gBACT,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
package/x/index.html CHANGED
@@ -295,7 +295,7 @@ canvas {
295
295
  }
296
296
  }
297
297
  </style>
298
- <script type=module src="demo/demo.bundle.min.js?v=a5d7817baed9"></script>
298
+ <script type=module src="demo/demo.bundle.min.js?v=ce084a16fd02"></script>
299
299
 
300
300
 
301
301
  <meta name="theme-color" content="#3cff9c">
@@ -317,7 +317,7 @@ canvas {
317
317
  <section>
318
318
  <header class="hero">
319
319
  <div>
320
- <h1>Omnitool <small>v1.1.0-71</small></h1>
320
+ <h1>Omnitool <small>v1.1.0-72</small></h1>
321
321
  <p>Developer demos for decoding, preview, waveform, playback, and export.</p>
322
322
  </div>
323
323
  </header>
@@ -2416,7 +2416,7 @@ vec4 transition(vec2 uv) {
2416
2416
  vec2 uv = vTextureCoord.xy;
2417
2417
  gl_FragColor = transition(vTextureCoord);
2418
2418
  }
2419
- `;function Ic({name:t,renderer:e}){let r=Pc.default.find(c=>c.name===t),n=new Dt,o=new cr,s=new Xr({}),i=new Xr({}),a=new No({glProgram:new zo({vertex:vc,fragment:Sc(r.glsl)}),resources:{from:s,to:i,uniforms:{...Ji.basics,...Ji.custom(r)}}});return n.filters=[a],{render({width:c,height:l,from:d,to:u,progress:m}){return(n.width!==c||n.height!==l)&&(n.setSize({width:c,height:l}),o.source.resize(c,l)),s.resource=d,i.resource=u,s.update(),i.update(),a.resources.uniforms.uniforms.progress=m,e.render({container:n,target:o,clear:!1,width:c,height:l}),o}}}var Fo=class{pixi;onPointerDown=Be();onPointerUp=Be();static async setup(){let e=await ji({width:1920,height:1080,preference:"webgl",background:"black",preferWebGLVersion:2}),r=new Oo;return r.interactive=!0,new this({renderer:e,stage:r})}constructor(e){this.pixi=e}#e=new Map;#t=new Map;async composite(e){let{stage:r,renderer:n}=this.pixi;this.#l(this.#c(e));let{dispose:o}=await this.#r(e,r);n.render(r);let s=new VideoFrame(n.canvas,{timestamp:0,duration:0});return o(),s}getActiveObject(e){return this.#t.get(e)}async#r(e,r){if(Array.isArray(e)){e.reverse();let n=[];for(let o of e){let s=await this.#r(o,r);n.push(s.dispose)}return{dispose:()=>n.forEach(o=>o())}}switch(e.kind){case"text":return this.#n(e,r);case"image":return this.#o(e,r);case"transition":return this.#i(e,r);case"gap":return this.pixi?.renderer.clear(),{dispose:()=>{}};default:return console.warn("Unknown layer kind",e.kind),{dispose:()=>{}}}}#n(e,r){let{sprite:n,dispose:o}=this.#a(e);return this.#s(n,e.matrix),r.addChild(n),{dispose:()=>o()}}#o(e,r){let n=cr.from(e.frame),{sprite:o,dispose:s}=this.#a(e);return o.texture=n,this.#s(o,e.matrix),r.addChild(o),{dispose:()=>{n.destroy(!0),e.frame.close(),s()}}}#i({from:e,to:r,progress:n,name:o},s){let a=(this.#e.get(o)??(this.#e.set(o,Ic({name:"circle",renderer:this.pixi.renderer})),this.#e.get(o))).render({from:e,to:r,progress:n,width:e.displayWidth,height:e.displayHeight}),c=new Dt(a);return s.addChild(c),{dispose:()=>c.destroy(!1)}}#s(e,r){if(!r)return;let n=ja(r);e.setFromMatrix(n)}#a(e){let r=this.#t.get(e.id);if(r)return{sprite:r,dispose:()=>{}};switch(e.kind){case"text":{let n=new Vr({text:e.content,style:e.style});n.eventMode="static";let o=()=>this.onPointerDown.publish({id:e.id,object:n}),s=()=>this.onPointerUp.publish({id:e.id,object:n});return n.on("pointerdown",o),n.on("pointerup",s),{sprite:this.#t.set(e.id,n).get(e.id),dispose:()=>{n.off("pointerdown",o),n.off("pointerup",s)}}}case"image":{let n=new Dt;n.eventMode="static";let o=()=>this.onPointerDown.publish({id:e.id,object:n}),s=()=>this.onPointerUp.publish({id:e.id,object:n});return n.on("pointerdown",o),n.on("pointerup",s),{sprite:this.#t.set(e.id,n).get(e.id),dispose:()=>{n.off("pointerdown",o),n.off("pointerup",s)}}}}}#c(e){let r=new Set,n=o=>{if(Array.isArray(o))for(let s of o)n(s);else r.add(o.id)};return n(e),r}#l(e){for(let r of this.#t.keys())e.has(r)||(this.#t.get(r).destroy(!0),this.#t.delete(r))}};var Cc=t=>_o.host(e=>({async world(){t.count++}}));var it=class{machina;thread;compositor;static async setup(e){let r=new Eo,n=await _o.thread({label:"OmnitoolDriver",workerUrl:e?.workerUrl??"/node_modules/@omnimedia/omnitool/x/driver/driver.worker.bundle.min.js",setupHost:Cc(r)}),o=await Fo.setup();return new this(r,n,o)}constructor(e,r,n){this.machina=e,this.thread=r,this.compositor=n}async hello(){return this.thread.work.hello()}async getAudioDuration(e){let n=await new ue({source:await _e(e),formats:we}).getPrimaryAudioTrack();if(!n)throw new Error("primary audio track not found");return await n.computeDuration()}async getVideoDuration(e){return await(await new ue({source:await _e(e),formats:we}).getPrimaryVideoTrack())?.computeDuration()}decodeVideo(e){let r=null,{port1:n,port2:o}=new MessageChannel,s=new TransformStream({async transform(i,a){let c=await e.onFrame?.(i)??i;r?.close(),a.enqueue(c),r=c}});return this.thread.work.decodeVideo[or]({transfer:[s.writable,o]})({source:e.source,cancel:o,video:s.writable,start:e.start,end:e.end}),{readable:s.readable,cancel(){n.postMessage("close"),n.close()}}}decodeAudio(e){let r=new TransformStream,{port1:n,port2:o}=new MessageChannel;return this.thread.work.decodeAudio[or]({transfer:[r.writable,o]})({source:e.source,cancel:o,audio:r.writable,start:e.start,end:e.end}),{readable:r.readable,cancel(){n.postMessage("close"),n.close()}}}encode({audio:e,video:r,config:n}){let{readable:o,writable:s}=new TransformStream,i=[e,r,s].filter(on.happy),a=this.thread.work.encode[or]({transfer:i})({audio:e,video:r,config:n,writable:s});return{readable:o,done:a}}async composite(e){return await this.compositor.composite(e)}};var Do=class{data;bytes;hash;nickname;constructor(e,r,n,o){this.data=e,this.bytes=r,this.hash=n,this.nickname=o}static async make(e){let r=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.digest("SHA-256",r)),o=nn.fromBytes(n),s=hs.sigil.fromBytes(n);return new this(e,n,o,s)}};var st=class{url;bytes;blob;filename;checksum;constructor(e,r,n,o,s){this.url=e,this.bytes=r,this.blob=n,this.filename=o,this.checksum=s}static async make(e,r){let n=await e.arrayBuffer(),o=new Uint8Array(n),s=await Do.make(o),i=r??s.nickname,a=URL.createObjectURL(e);return new this(a,o,e,i,s)}static async load(e){}};async function ar(t){return fetch(t).then(e=>e.blob())}var Ac=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function de(){let t=await it.setup({workerUrl:Ac}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")});return{driver:t,omni:e,testVideo:r,videoA:n}}var _c=je.suite({"basic demo":async()=>{let t=await it.setup({workerUrl:new URL("../driver/driver.worker.bundle.min.js",import.meta.url)}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")}),o=new q({timeline:e.timeline(l=>l.sequence())}),s=o.require(o.timeline.rootId),i=o.video(n);o.addChildren(s,i);let a=H(i.id,o.timeline),c=H(o.timeline.rootId,o.timeline);P(a).is(c)},"sequence duration is 3x":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.video(e),o.video(e),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*3)},"stack duration is 1x":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.stack(o.video(e),o.video(e),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration)},"nested stack inside sequence":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.video(e),o.stack(o.video(e),o.video(e)),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*3)},"nested sequence inside stack":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.stack(o.video(e),o.sequence(o.video(e),o.video(e))))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*2)},"empty timeline duration is 0":async()=>{let{omni:t}=await de(),e=new q({timeline:t.timeline(s=>s.sequence())}),r=new q({timeline:t.timeline(s=>s.stack())}),n=H(e.timeline.rootId,e.timeline),o=H(r.timeline.rootId,r.timeline);P(n).is(0),P(o).is(0)},"transition in a sequence":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(i=>i.sequence(i.video(e),i.transition.crossfade(r),i.video(e)))}),o=H(n.timeline.rootId,n.timeline),s=e.duration*2-r;P(o).is(s)},"transition in a stack":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(s=>s.stack(s.video(e),s.transition.crossfade(r),s.video(e)))}),o=H(n.timeline.rootId,n.timeline);P(o).is(e.duration)},"ignore invalid transition":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.transition.crossfade(1e3),o.video(e),o.video(e),o.transition.crossfade(1e3)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*2)},"clamp transition duration on overflow":async()=>{let{omni:t,videoA:e}=await de(),r=3e3,n=new q({timeline:t.timeline(s=>s.sequence(s.video(e,{duration:r}),s.transition.crossfade(r*2),s.video(e,{duration:r})))}),o=H(n.timeline.rootId,n.timeline);P(o).is(r)},"multiple transitions":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(i=>i.sequence(i.video(e),i.transition.crossfade(r),i.video(e),i.transition.crossfade(r),i.video(e)))}),o=H(n.timeline.rootId,n.timeline),s=e.duration*3-r*2;P(o).is(s)},"gap item in a sequence":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(i=>i.sequence(i.video(e),i.gap(r),i.video(e)))}),o=H(n.timeline.rootId,n.timeline),s=e.duration*2+r;P(o).is(s)},"gap item in a stack":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.stack(o.video(e),o.gap(1e3),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration)},"load media into Omni":async()=>{let t=await it.setup({workerUrl:Ac}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")});P(e.resources.require(n.datafile.checksum.hash)).happy()},"playback seeks to correct time":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.video(e,{duration:2e3}),o.gap(500),o.video(e,{duration:2500})))}),n=await t.playback(r.timeline);await n.seek(1e3),P(n.currentTime).is(1e3)}});var Ml=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function Ro(){let t=await it.setup({workerUrl:Ml}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")});return{driver:t,omni:e,testVideo:r,videoA:n,resolveMedia:s=>e.resources.require(s).blob}}async function $r(t){let e=[];for await(let r of t)e.push(r);return e}var J=(t,e,r=1e-6)=>Math.abs(t-e)<r,Ec=je.suite({"cursor visual sampler cannot get previous samples":async()=>{let{omni:t,videoA:e,resolveMedia:r,driver:n}=await Ro(),{timeline:o}=new q({timeline:t.timeline(i=>i.sequence(i.video(e,{duration:2e3}),i.gap(500),i.video(e,{duration:2e3}),i.audio(e,{duration:500})))}),s=new rt(n,r,o);await s.next(O(1e3)),await P(async()=>await s.next(O(100))).throwsAsync()},"visual sampler gives correct layer at x time":async()=>{let{omni:t,videoA:e,resolveMedia:r}=await Ro(),{timeline:n}=new q({timeline:t.timeline(l=>l.sequence(l.video(e,{duration:2e3}),l.gap(500),l.video(e,{duration:2e3}),l.audio(e,{duration:500}),l.text("123",{duration:1e3})))}),o=tr(r),s=await o.sample(n,O(1e3));P(s[0].kind).is("image");let i=await o.sample(n,O(2300));P(i[0].kind).is("gap");let a=await o.sample(n,O(2700));P(a[0].kind).is("image");let c=await o.sample(n,O(5500));P(c[0].kind).is("text")},"audio mix sums overlapping chunks":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([.25,.25,.25,.25])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.5,.5,.5,.5])],sampleRate:4,timestamp:.5}}let r=await $r(t.mix(e()));P(r.length).is(2),P(r[0].startFrame).is(0),P(r[0].frames).is(4),P(r[0].channels).is(1),P(r[0].planar[0]).is(.25),P(r[0].planar[1]).is(.25),P(r[0].planar[2]).is(.75),P(r[0].planar[3]).is(.75),P(r[1].startFrame).is(4),P(r[1].planar[0]).is(.5),P(r[1].planar[1]).is(.5),P(r[1].planar[2]).is(0),P(r[1].planar[3]).is(0)},"audio mix clamps output to [-1, 1]":async()=>{let t=new Ee({chunkFrames:4,clamp:!0});async function*e(){yield{planes:[new Float32Array([.9,.9,.9,.9])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.8,.8,.8,.8])],sampleRate:4,timestamp:0}}let r=await $r(t.mix(e()));P(r.length).is(1),P(r[0].planar[0]).is(1),P(r[0].planar[1]).is(1),P(r[0].planar[2]).is(1),P(r[0].planar[3]).is(1)},"audio mix fills gaps with silence":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([2,2,2,2])],sampleRate:4,timestamp:2}}let r=await $r(t.mix(e()));P(r.length).is(3),P(r[0].startFrame).is(0),P(r[0].planar[0]).is(1),P(r[1].startFrame).is(4),P(r[1].planar[0]).is(0),P(r[1].planar[3]).is(0),P(r[2].startFrame).is(8),P(r[2].planar[0]).is(2)},"audio mix truncates negative timestamps":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,2,3,4])],sampleRate:4,timestamp:-.5}}let r=await $r(t.mix(e()));P(r.length).is(1),P(r[0].startFrame).is(0),P(r[0].planar[0]).is(3),P(r[0].planar[1]).is(4),P(r[0].planar[2]).is(0),P(r[0].planar[3]).is(0)},"audio mix handles stereo planar layout":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1]),new Float32Array([2,2,2,2])],sampleRate:4,timestamp:0}}let r=await $r(t.mix(e()));P(r.length).is(1),P(r[0].channels).is(2),P(r[0].planar.length).is(8),P(r[0].planar[0]).is(1),P(r[0].planar[4]).is(2)},"applyGainToPlanar scales values across multiple channels":async()=>{let t=[new Float32Array([.2,-.4]),new Float32Array([.6,-.8])];rr(t,.5),P(J(t[0][0],.1)).ok(),P(J(t[0][1],-.2)).ok(),P(J(t[1][0],.3)).ok(),P(J(t[1][1],-.4)).ok()},"applyGainToPlanar does not mutate when gain is 1":async()=>{let t=[new Float32Array([.5,-.5])];rr(t,1),P(J(t[0][0],.5)).ok(),P(J(t[0][1],-.5)).ok()},"applyGainToPlanar mutes entirely when gain is 0":async()=>{let t=[new Float32Array([.9,-.9])];rr(t,0),P(t[0][0]).is(0),P(t[0][1]).is(0)},"resampleToPlanar returns original data when sample rates match":async()=>{let e=Fe({numberOfFrames:3,numberOfChannels:1,sampleRate:48e3,copyTo:r=>r.set([.1,.2,.3])},48e3);P(e.frames).is(3),P(e.data.length).is(1),P(J(e.data[0][0],.1)).ok(),P(J(e.data[0][1],.2)).ok(),P(J(e.data[0][2],.3)).ok()},"resampleToPlanar upsamples using linear interpolation":async()=>{let e=Fe({numberOfFrames:2,numberOfChannels:1,sampleRate:1,copyTo:r=>r.set([10,20])},2);P(e.frames).is(4),P(J(e.data[0][0],10)).ok(),P(J(e.data[0][1],15)).ok(),P(J(e.data[0][2],20)).ok(),P(J(e.data[0][3],20)).ok()},"resampleToPlanar downsamples correctly":async()=>{let e=Fe({numberOfFrames:4,numberOfChannels:1,sampleRate:4,copyTo:r=>r.set([1,2,3,4])},2);P(e.frames).is(2),P(J(e.data[0][0],1)).ok(),P(J(e.data[0][1],3)).ok()},"resampleToPlanar processes multi-channel planar data":async()=>{let t=[new Float32Array([1,2]),new Float32Array([3,4])],r=Fe({numberOfFrames:2,numberOfChannels:2,sampleRate:1,copyTo:(n,o)=>{n.set(t[o.planeIndex])}},2);P(r.data.length).is(2),P(J(r.data[0][1],1.5)).ok(),P(J(r.data[1][1],3.5)).ok()},"resampleToPlanar handles zero channels gracefully":async()=>{let e=Fe({numberOfFrames:10,numberOfChannels:0,sampleRate:48e3,copyTo:()=>{throw new Error("Should not be called")}},44100);P(e.data.length).is(0),P(e.frames).is(0)},"resampleToPlanar enforces minimum of 1 frame on aggressive downsample":async()=>{let e=Fe({numberOfFrames:1,numberOfChannels:1,sampleRate:48e3,copyTo:r=>r.set([.8])},8e3);P(e.frames).is(1),P(e.data[0].length).is(1),P(J(e.data[0][0],.8)).ok()},"resampleToPlanar calls copyTo with strict contract shape":async()=>{let t=null;Fe({numberOfFrames:2,numberOfChannels:1,sampleRate:48e3,copyTo:(r,n)=>{t=n}},44100),P(t).not.is(null),P(t.planeIndex).is(0),P(t.format).is("f32-planar")},"5s long export at 30fps renders exacly 150 frames":async()=>{let{omni:t,videoA:e,driver:r,resolveMedia:n}=await Ro(),{timeline:o}=new q({timeline:t.timeline(a=>a.sequence(a.video(e,{duration:2e3}),a.gap(500),a.video(e,{duration:2e3}),a.audio(e,{duration:500})))}),s=ho({timeline:o,fps:$e(30),driver:r,resolveMedia:n}),i=0;for await(let a of s)a.close(),i++;P(i).is(150)},"5s long audio export at 48000Hz renders exactly 240000 frames":async()=>{let{omni:t,videoA:e,resolveMedia:r}=await Ro(),{timeline:n}=new q({timeline:t.timeline(i=>i.sequence(i.video(e,{duration:2e3}),i.gap(500),i.video(e,{duration:2e3}),i.audio(e,{duration:500})))}),o=po({timeline:n,resolveMedia:r}),s=0;for await(let i of o)s+=i.numberOfFrames,i.close();P(s).is(24e4)}});await je.run({omniTest:_c,renderersTest:Ec});
2419
+ `;function Ic({name:t,renderer:e}){let r=Pc.default.find(c=>c.name===t),n=new Dt,o=new cr,s=new Xr({}),i=new Xr({}),a=new No({glProgram:new zo({vertex:vc,fragment:Sc(r.glsl)}),resources:{from:s,to:i,uniforms:{...Ji.basics,...Ji.custom(r)}}});return n.filters=[a],{render({width:c,height:l,from:d,to:u,progress:m}){return(n.width!==c||n.height!==l)&&(n.setSize({width:c,height:l}),o.source.resize(c,l)),s.resource=d,i.resource=u,s.update(),i.update(),a.resources.uniforms.uniforms.progress=m,e.render({container:n,target:o,clear:!1,width:c,height:l}),o}}}var Fo=class{pixi;onPointerDown=Be();onPointerUp=Be();static async setup(){let e=await ji({width:1920,height:1080,preference:"webgl",background:"black",preferWebGLVersion:2}),r=new Oo;return r.interactive=!0,new this({renderer:e,stage:r})}constructor(e){this.pixi=e}#e=new Map;#t=new Map;async composite(e){let{stage:r,renderer:n}=this.pixi;this.#l(this.#c(e));let{dispose:o}=await this.#r(e,r);n.render(r);let s=new VideoFrame(n.canvas,{timestamp:0,duration:0});return o(),s}getActiveObject(e){return this.#t.get(e)?.sprite}async#r(e,r){if(Array.isArray(e)){e.reverse();let n=[];for(let o of e){let s=await this.#r(o,r);n.push(s.dispose)}return{dispose:()=>n.forEach(o=>o())}}switch(e.kind){case"text":return this.#n(e,r);case"image":return this.#o(e,r);case"transition":return this.#i(e,r);case"gap":return this.pixi?.renderer.clear(),{dispose:()=>{}};default:return console.warn("Unknown layer kind",e.kind),{dispose:()=>{}}}}#n(e,r){let n=this.#a(e);return this.#s(n,e.matrix),r.addChild(n),{dispose:()=>{}}}#o(e,r){let n=cr.from(e.frame),o=this.#a(e);return o.texture=n,this.#s(o,e.matrix),r.addChild(o),{dispose:()=>{n.destroy(!0),e.frame.close()}}}#i({from:e,to:r,progress:n,name:o},s){let a=(this.#e.get(o)??(this.#e.set(o,Ic({name:"circle",renderer:this.pixi.renderer})),this.#e.get(o))).render({from:e,to:r,progress:n,width:e.displayWidth,height:e.displayHeight}),c=new Dt(a);return s.addChild(c),{dispose:()=>c.destroy(!1)}}#s(e,r){if(!r)return;let n=ja(r);e.setFromMatrix(n)}#a(e){let r=this.#t.get(e.id);if(r)return r.sprite;switch(e.kind){case"text":{let n=new Vr({text:e.content,style:e.style});n.eventMode="static";let o=()=>this.onPointerDown.publish({id:e.id,object:n}),s=()=>this.onPointerUp.publish({id:e.id,object:n});return n.on("pointerdown",o),n.on("pointerup",s),this.#t.set(e.id,{sprite:n,dispose(){n.off("pointerdown",o),n.off("pointerup",s)}}).get(e.id)?.sprite}case"image":{let n=new Dt;n.eventMode="static";let o=()=>this.onPointerDown.publish({id:e.id,object:n}),s=()=>this.onPointerUp.publish({id:e.id,object:n});return n.on("pointerdown",o),n.on("pointerup",s),this.#t.set(e.id,{sprite:n,dispose(){n.off("pointerdown",o),n.off("pointerup",s)}}).get(e.id)?.sprite}}}#c(e){let r=new Set,n=o=>{if(Array.isArray(o))for(let s of o)n(s);else r.add(o.id)};return n(e),r}#l(e){for(let r of this.#t.keys())if(!e.has(r)){let{sprite:n,dispose:o}=this.#t.get(r);n.destroy(!0),o(),this.#t.delete(r)}}};var Cc=t=>_o.host(e=>({async world(){t.count++}}));var it=class{machina;thread;compositor;static async setup(e){let r=new Eo,n=await _o.thread({label:"OmnitoolDriver",workerUrl:e?.workerUrl??"/node_modules/@omnimedia/omnitool/x/driver/driver.worker.bundle.min.js",setupHost:Cc(r)}),o=await Fo.setup();return new this(r,n,o)}constructor(e,r,n){this.machina=e,this.thread=r,this.compositor=n}async hello(){return this.thread.work.hello()}async getAudioDuration(e){let n=await new ue({source:await _e(e),formats:we}).getPrimaryAudioTrack();if(!n)throw new Error("primary audio track not found");return await n.computeDuration()}async getVideoDuration(e){return await(await new ue({source:await _e(e),formats:we}).getPrimaryVideoTrack())?.computeDuration()}decodeVideo(e){let r=null,{port1:n,port2:o}=new MessageChannel,s=new TransformStream({async transform(i,a){let c=await e.onFrame?.(i)??i;r?.close(),a.enqueue(c),r=c}});return this.thread.work.decodeVideo[or]({transfer:[s.writable,o]})({source:e.source,cancel:o,video:s.writable,start:e.start,end:e.end}),{readable:s.readable,cancel(){n.postMessage("close"),n.close()}}}decodeAudio(e){let r=new TransformStream,{port1:n,port2:o}=new MessageChannel;return this.thread.work.decodeAudio[or]({transfer:[r.writable,o]})({source:e.source,cancel:o,audio:r.writable,start:e.start,end:e.end}),{readable:r.readable,cancel(){n.postMessage("close"),n.close()}}}encode({audio:e,video:r,config:n}){let{readable:o,writable:s}=new TransformStream,i=[e,r,s].filter(on.happy),a=this.thread.work.encode[or]({transfer:i})({audio:e,video:r,config:n,writable:s});return{readable:o,done:a}}async composite(e){return await this.compositor.composite(e)}};var Do=class{data;bytes;hash;nickname;constructor(e,r,n,o){this.data=e,this.bytes=r,this.hash=n,this.nickname=o}static async make(e){let r=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.digest("SHA-256",r)),o=nn.fromBytes(n),s=hs.sigil.fromBytes(n);return new this(e,n,o,s)}};var st=class{url;bytes;blob;filename;checksum;constructor(e,r,n,o,s){this.url=e,this.bytes=r,this.blob=n,this.filename=o,this.checksum=s}static async make(e,r){let n=await e.arrayBuffer(),o=new Uint8Array(n),s=await Do.make(o),i=r??s.nickname,a=URL.createObjectURL(e);return new this(a,o,e,i,s)}static async load(e){}};async function ar(t){return fetch(t).then(e=>e.blob())}var Ac=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function de(){let t=await it.setup({workerUrl:Ac}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")});return{driver:t,omni:e,testVideo:r,videoA:n}}var _c=je.suite({"basic demo":async()=>{let t=await it.setup({workerUrl:new URL("../driver/driver.worker.bundle.min.js",import.meta.url)}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")}),o=new q({timeline:e.timeline(l=>l.sequence())}),s=o.require(o.timeline.rootId),i=o.video(n);o.addChildren(s,i);let a=H(i.id,o.timeline),c=H(o.timeline.rootId,o.timeline);P(a).is(c)},"sequence duration is 3x":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.video(e),o.video(e),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*3)},"stack duration is 1x":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.stack(o.video(e),o.video(e),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration)},"nested stack inside sequence":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.video(e),o.stack(o.video(e),o.video(e)),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*3)},"nested sequence inside stack":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.stack(o.video(e),o.sequence(o.video(e),o.video(e))))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*2)},"empty timeline duration is 0":async()=>{let{omni:t}=await de(),e=new q({timeline:t.timeline(s=>s.sequence())}),r=new q({timeline:t.timeline(s=>s.stack())}),n=H(e.timeline.rootId,e.timeline),o=H(r.timeline.rootId,r.timeline);P(n).is(0),P(o).is(0)},"transition in a sequence":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(i=>i.sequence(i.video(e),i.transition.crossfade(r),i.video(e)))}),o=H(n.timeline.rootId,n.timeline),s=e.duration*2-r;P(o).is(s)},"transition in a stack":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(s=>s.stack(s.video(e),s.transition.crossfade(r),s.video(e)))}),o=H(n.timeline.rootId,n.timeline);P(o).is(e.duration)},"ignore invalid transition":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.transition.crossfade(1e3),o.video(e),o.video(e),o.transition.crossfade(1e3)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration*2)},"clamp transition duration on overflow":async()=>{let{omni:t,videoA:e}=await de(),r=3e3,n=new q({timeline:t.timeline(s=>s.sequence(s.video(e,{duration:r}),s.transition.crossfade(r*2),s.video(e,{duration:r})))}),o=H(n.timeline.rootId,n.timeline);P(o).is(r)},"multiple transitions":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(i=>i.sequence(i.video(e),i.transition.crossfade(r),i.video(e),i.transition.crossfade(r),i.video(e)))}),o=H(n.timeline.rootId,n.timeline),s=e.duration*3-r*2;P(o).is(s)},"gap item in a sequence":async()=>{let{omni:t,videoA:e}=await de(),r=1e3,n=new q({timeline:t.timeline(i=>i.sequence(i.video(e),i.gap(r),i.video(e)))}),o=H(n.timeline.rootId,n.timeline),s=e.duration*2+r;P(o).is(s)},"gap item in a stack":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.stack(o.video(e),o.gap(1e3),o.video(e)))}),n=H(r.timeline.rootId,r.timeline);P(n).is(e.duration)},"load media into Omni":async()=>{let t=await it.setup({workerUrl:Ac}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")});P(e.resources.require(n.datafile.checksum.hash)).happy()},"playback seeks to correct time":async()=>{let{omni:t,videoA:e}=await de(),r=new q({timeline:t.timeline(o=>o.sequence(o.video(e,{duration:2e3}),o.gap(500),o.video(e,{duration:2500})))}),n=await t.playback(r.timeline);await n.seek(1e3),P(n.currentTime).is(1e3)}});var Ml=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function Ro(){let t=await it.setup({workerUrl:Ml}),e=new nt(t),r=await ar("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:st.make(r,"test.mp4")});return{driver:t,omni:e,testVideo:r,videoA:n,resolveMedia:s=>e.resources.require(s).blob}}async function $r(t){let e=[];for await(let r of t)e.push(r);return e}var J=(t,e,r=1e-6)=>Math.abs(t-e)<r,Ec=je.suite({"cursor visual sampler cannot get previous samples":async()=>{let{omni:t,videoA:e,resolveMedia:r,driver:n}=await Ro(),{timeline:o}=new q({timeline:t.timeline(i=>i.sequence(i.video(e,{duration:2e3}),i.gap(500),i.video(e,{duration:2e3}),i.audio(e,{duration:500})))}),s=new rt(n,r,o);await s.next(O(1e3)),await P(async()=>await s.next(O(100))).throwsAsync()},"visual sampler gives correct layer at x time":async()=>{let{omni:t,videoA:e,resolveMedia:r}=await Ro(),{timeline:n}=new q({timeline:t.timeline(l=>l.sequence(l.video(e,{duration:2e3}),l.gap(500),l.video(e,{duration:2e3}),l.audio(e,{duration:500}),l.text("123",{duration:1e3})))}),o=tr(r),s=await o.sample(n,O(1e3));P(s[0].kind).is("image");let i=await o.sample(n,O(2300));P(i[0].kind).is("gap");let a=await o.sample(n,O(2700));P(a[0].kind).is("image");let c=await o.sample(n,O(5500));P(c[0].kind).is("text")},"audio mix sums overlapping chunks":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([.25,.25,.25,.25])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.5,.5,.5,.5])],sampleRate:4,timestamp:.5}}let r=await $r(t.mix(e()));P(r.length).is(2),P(r[0].startFrame).is(0),P(r[0].frames).is(4),P(r[0].channels).is(1),P(r[0].planar[0]).is(.25),P(r[0].planar[1]).is(.25),P(r[0].planar[2]).is(.75),P(r[0].planar[3]).is(.75),P(r[1].startFrame).is(4),P(r[1].planar[0]).is(.5),P(r[1].planar[1]).is(.5),P(r[1].planar[2]).is(0),P(r[1].planar[3]).is(0)},"audio mix clamps output to [-1, 1]":async()=>{let t=new Ee({chunkFrames:4,clamp:!0});async function*e(){yield{planes:[new Float32Array([.9,.9,.9,.9])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.8,.8,.8,.8])],sampleRate:4,timestamp:0}}let r=await $r(t.mix(e()));P(r.length).is(1),P(r[0].planar[0]).is(1),P(r[0].planar[1]).is(1),P(r[0].planar[2]).is(1),P(r[0].planar[3]).is(1)},"audio mix fills gaps with silence":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([2,2,2,2])],sampleRate:4,timestamp:2}}let r=await $r(t.mix(e()));P(r.length).is(3),P(r[0].startFrame).is(0),P(r[0].planar[0]).is(1),P(r[1].startFrame).is(4),P(r[1].planar[0]).is(0),P(r[1].planar[3]).is(0),P(r[2].startFrame).is(8),P(r[2].planar[0]).is(2)},"audio mix truncates negative timestamps":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,2,3,4])],sampleRate:4,timestamp:-.5}}let r=await $r(t.mix(e()));P(r.length).is(1),P(r[0].startFrame).is(0),P(r[0].planar[0]).is(3),P(r[0].planar[1]).is(4),P(r[0].planar[2]).is(0),P(r[0].planar[3]).is(0)},"audio mix handles stereo planar layout":async()=>{let t=new Ee({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1]),new Float32Array([2,2,2,2])],sampleRate:4,timestamp:0}}let r=await $r(t.mix(e()));P(r.length).is(1),P(r[0].channels).is(2),P(r[0].planar.length).is(8),P(r[0].planar[0]).is(1),P(r[0].planar[4]).is(2)},"applyGainToPlanar scales values across multiple channels":async()=>{let t=[new Float32Array([.2,-.4]),new Float32Array([.6,-.8])];rr(t,.5),P(J(t[0][0],.1)).ok(),P(J(t[0][1],-.2)).ok(),P(J(t[1][0],.3)).ok(),P(J(t[1][1],-.4)).ok()},"applyGainToPlanar does not mutate when gain is 1":async()=>{let t=[new Float32Array([.5,-.5])];rr(t,1),P(J(t[0][0],.5)).ok(),P(J(t[0][1],-.5)).ok()},"applyGainToPlanar mutes entirely when gain is 0":async()=>{let t=[new Float32Array([.9,-.9])];rr(t,0),P(t[0][0]).is(0),P(t[0][1]).is(0)},"resampleToPlanar returns original data when sample rates match":async()=>{let e=Fe({numberOfFrames:3,numberOfChannels:1,sampleRate:48e3,copyTo:r=>r.set([.1,.2,.3])},48e3);P(e.frames).is(3),P(e.data.length).is(1),P(J(e.data[0][0],.1)).ok(),P(J(e.data[0][1],.2)).ok(),P(J(e.data[0][2],.3)).ok()},"resampleToPlanar upsamples using linear interpolation":async()=>{let e=Fe({numberOfFrames:2,numberOfChannels:1,sampleRate:1,copyTo:r=>r.set([10,20])},2);P(e.frames).is(4),P(J(e.data[0][0],10)).ok(),P(J(e.data[0][1],15)).ok(),P(J(e.data[0][2],20)).ok(),P(J(e.data[0][3],20)).ok()},"resampleToPlanar downsamples correctly":async()=>{let e=Fe({numberOfFrames:4,numberOfChannels:1,sampleRate:4,copyTo:r=>r.set([1,2,3,4])},2);P(e.frames).is(2),P(J(e.data[0][0],1)).ok(),P(J(e.data[0][1],3)).ok()},"resampleToPlanar processes multi-channel planar data":async()=>{let t=[new Float32Array([1,2]),new Float32Array([3,4])],r=Fe({numberOfFrames:2,numberOfChannels:2,sampleRate:1,copyTo:(n,o)=>{n.set(t[o.planeIndex])}},2);P(r.data.length).is(2),P(J(r.data[0][1],1.5)).ok(),P(J(r.data[1][1],3.5)).ok()},"resampleToPlanar handles zero channels gracefully":async()=>{let e=Fe({numberOfFrames:10,numberOfChannels:0,sampleRate:48e3,copyTo:()=>{throw new Error("Should not be called")}},44100);P(e.data.length).is(0),P(e.frames).is(0)},"resampleToPlanar enforces minimum of 1 frame on aggressive downsample":async()=>{let e=Fe({numberOfFrames:1,numberOfChannels:1,sampleRate:48e3,copyTo:r=>r.set([.8])},8e3);P(e.frames).is(1),P(e.data[0].length).is(1),P(J(e.data[0][0],.8)).ok()},"resampleToPlanar calls copyTo with strict contract shape":async()=>{let t=null;Fe({numberOfFrames:2,numberOfChannels:1,sampleRate:48e3,copyTo:(r,n)=>{t=n}},44100),P(t).not.is(null),P(t.planeIndex).is(0),P(t.format).is("f32-planar")},"5s long export at 30fps renders exacly 150 frames":async()=>{let{omni:t,videoA:e,driver:r,resolveMedia:n}=await Ro(),{timeline:o}=new q({timeline:t.timeline(a=>a.sequence(a.video(e,{duration:2e3}),a.gap(500),a.video(e,{duration:2e3}),a.audio(e,{duration:500})))}),s=ho({timeline:o,fps:$e(30),driver:r,resolveMedia:n}),i=0;for await(let a of s)a.close(),i++;P(i).is(150)},"5s long audio export at 48000Hz renders exactly 240000 frames":async()=>{let{omni:t,videoA:e,resolveMedia:r}=await Ro(),{timeline:n}=new q({timeline:t.timeline(i=>i.sequence(i.video(e,{duration:2e3}),i.gap(500),i.video(e,{duration:2e3}),i.audio(e,{duration:500})))}),o=po({timeline:n,resolveMedia:r}),s=0;for await(let i of o)s+=i.numberOfFrames,i.close();P(s).is(24e4)}});await je.run({omniTest:_c,renderersTest:Ec});
2420
2420
  /*! Bundled license information:
2421
2421
 
2422
2422
  mediabunny/dist/modules/src/misc.js: