@swmansion/smelter-browser-render 0.2.1 → 0.3.0-rc.0

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/index.d.ts CHANGED
@@ -8,6 +8,7 @@ declare const loadWasmModule: (wasmModuleUrl: string) => Promise<void>;
8
8
 
9
9
  type Resolution = Api.Resolution;
10
10
  type ImageSpec = Required<Pick<Api.ImageSpec, 'asset_type' | 'url'>>;
11
+ type ShaderSpec = Api.ShaderSpec;
11
12
  type Component = Extract<Api.Component, {
12
13
  type: 'input_stream' | 'view' | 'rescaler' | 'image' | 'text' | 'tiles';
13
14
  }>;
@@ -20,35 +21,38 @@ type RendererOptions = {
20
21
  * A timeout that defines when the smelter should switch to fallback on the input stream that stopped sending frames.
21
22
  */
22
23
  streamFallbackTimeoutMs: number;
23
- logger_level?: 'error' | 'warn' | 'info' | 'debug' | 'trace';
24
+ loggerLevel?: 'error' | 'warn' | 'info' | 'debug' | 'trace';
24
25
  };
25
- type FrameSet = {
26
+ type InputFrameSet = {
26
27
  ptsMs: number;
27
- frames: {
28
- [id: string]: Frame;
29
- };
28
+ frames: Record<string, InputFrame>;
30
29
  };
31
- type Frame = {
30
+ type OutputFrameSet = {
31
+ ptsMs: number;
32
+ frames: Record<string, OutputFrame>;
33
+ };
34
+ type InputFrame = {
35
+ readonly frame: VideoFrame | HTMLVideoElement;
36
+ readonly ptsMs: number;
37
+ };
38
+ type OutputFrame = {
32
39
  resolution: Resolution;
33
- format: FrameFormat;
34
40
  data: Uint8ClampedArray;
35
41
  };
36
- declare enum FrameFormat {
37
- RGBA_BYTES = "RGBA_BYTES",
38
- YUV_BYTES = "YUV_BYTES"
39
- }
40
42
  declare class Renderer {
41
43
  private renderer;
42
44
  private constructor();
43
45
  static create(options: RendererOptions): Promise<Renderer>;
44
- render(input: FrameSet): FrameSet;
45
- updateScene(outputId: OutputId, resolution: Resolution, scene: Component): void;
46
- registerInput(inputId: InputId): void;
46
+ render(input: InputFrameSet): Promise<OutputFrameSet>;
47
+ updateScene(outputId: OutputId, resolution: Resolution, scene: Component): Promise<void>;
48
+ registerInput(inputId: InputId): Promise<void>;
47
49
  registerImage(rendererId: RendererId, imageSpec: ImageSpec): Promise<void>;
50
+ registerShader(rendererId: RendererId, shaderSpec: ShaderSpec): Promise<void>;
48
51
  registerFont(fontUrl: string): Promise<void>;
49
- unregisterInput(inputId: InputId): void;
50
- unregisterImage(rendererId: RendererId): void;
51
- unregisterOutput(outputId: OutputId): void;
52
+ unregisterInput(inputId: InputId): Promise<void>;
53
+ unregisterImage(rendererId: RendererId): Promise<void>;
54
+ unregisterShader(rendererId: RendererId): Promise<void>;
55
+ unregisterOutput(outputId: OutputId): Promise<void>;
52
56
  }
53
57
 
54
- export { type Component, type Frame, FrameFormat, type FrameSet, type ImageSpec, type InputId, type OutputId, Renderer, type RendererId, type RendererOptions, type Resolution, loadWasmModule };
58
+ export { type Component, type ImageSpec, type InputFrame, type InputFrameSet, type InputId, type OutputFrame, type OutputFrameSet, type OutputId, Renderer, type RendererId, type RendererOptions, type Resolution, type ShaderSpec, loadWasmModule };
package/dist/index.js CHANGED
@@ -74,14 +74,6 @@ function getDataViewMemory0() {
74
74
  return cachedDataViewMemory0;
75
75
  }
76
76
 
77
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
78
-
79
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
80
- function getStringFromWasm0(ptr, len) {
81
- ptr = ptr >>> 0;
82
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
83
- }
84
-
85
77
  function addToExternrefTable0(obj) {
86
78
  const idx = wasm.__externref_table_alloc();
87
79
  wasm.__wbindgen_export_4.set(idx, obj);
@@ -97,6 +89,14 @@ function handleError(f, args) {
97
89
  }
98
90
  }
99
91
 
92
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
93
+
94
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
95
+ function getStringFromWasm0(ptr, len) {
96
+ ptr = ptr >>> 0;
97
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
98
+ }
99
+
100
100
  let cachedFloat32ArrayMemory0 = null;
101
101
 
102
102
  function getFloat32ArrayMemory0() {
@@ -139,6 +139,11 @@ function getArrayU32FromWasm0(ptr, len) {
139
139
  return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
140
140
  }
141
141
 
142
+ function getArrayU8FromWasm0(ptr, len) {
143
+ ptr = ptr >>> 0;
144
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
145
+ }
146
+
142
147
  function isLikeNone(x) {
143
148
  return x === undefined || x === null;
144
149
  }
@@ -262,92 +267,18 @@ function create_renderer(options) {
262
267
  return ret;
263
268
  }
264
269
 
265
- function _assertClass(instance, klass) {
266
- if (!(instance instanceof klass)) {
267
- throw new Error(`expected instance of ${klass.name}`);
268
- }
269
- }
270
-
271
- function takeFromExternrefTable0(idx) {
272
- const value = wasm.__wbindgen_export_4.get(idx);
273
- wasm.__externref_table_dealloc(idx);
274
- return value;
275
- }
276
- function __wbg_adapter_54(arg0, arg1, arg2) {
277
- wasm.closure549_externref_shim(arg0, arg1, arg2);
270
+ function __wbg_adapter_60(arg0, arg1, arg2) {
271
+ wasm.closure1064_externref_shim(arg0, arg1, arg2);
278
272
  }
279
273
 
280
- function __wbg_adapter_718(arg0, arg1, arg2, arg3) {
281
- wasm.closure2694_externref_shim(arg0, arg1, arg2, arg3);
274
+ function __wbg_adapter_739(arg0, arg1, arg2, arg3) {
275
+ wasm.closure3248_externref_shim(arg0, arg1, arg2, arg3);
282
276
  }
283
277
 
284
278
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
285
279
 
286
280
  const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
287
281
 
288
- const FrameSetFinalization = (typeof FinalizationRegistry === 'undefined')
289
- ? { register: () => {}, unregister: () => {} }
290
- : new FinalizationRegistry(ptr => wasm.__wbg_frameset_free(ptr >>> 0, 1));
291
-
292
- class FrameSet {
293
-
294
- static __wrap(ptr) {
295
- ptr = ptr >>> 0;
296
- const obj = Object.create(FrameSet.prototype);
297
- obj.__wbg_ptr = ptr;
298
- FrameSetFinalization.register(obj, obj.__wbg_ptr, obj);
299
- return obj;
300
- }
301
-
302
- __destroy_into_raw() {
303
- const ptr = this.__wbg_ptr;
304
- this.__wbg_ptr = 0;
305
- FrameSetFinalization.unregister(this);
306
- return ptr;
307
- }
308
-
309
- free() {
310
- const ptr = this.__destroy_into_raw();
311
- wasm.__wbg_frameset_free(ptr, 0);
312
- }
313
- /**
314
- * @returns {number}
315
- */
316
- get pts_ms() {
317
- const ret = wasm.__wbg_get_frameset_pts_ms(this.__wbg_ptr);
318
- return ret;
319
- }
320
- /**
321
- * @param {number} arg0
322
- */
323
- set pts_ms(arg0) {
324
- wasm.__wbg_set_frameset_pts_ms(this.__wbg_ptr, arg0);
325
- }
326
- /**
327
- * @param {number} pts_ms
328
- * @param {Map<any, any>} frames
329
- */
330
- constructor(pts_ms, frames) {
331
- const ret = wasm.frameset_new(pts_ms, frames);
332
- this.__wbg_ptr = ret >>> 0;
333
- FrameSetFinalization.register(this, this.__wbg_ptr, this);
334
- return this;
335
- }
336
- /**
337
- * @returns {Map<any, any>}
338
- */
339
- get frames() {
340
- const ret = wasm.frameset_frames(this.__wbg_ptr);
341
- return ret;
342
- }
343
- /**
344
- * @param {Map<any, any>} frames
345
- */
346
- set frames(frames) {
347
- wasm.frameset_set_frames(this.__wbg_ptr, frames);
348
- }
349
- }
350
-
351
282
  const SmelterRendererFinalization = (typeof FinalizationRegistry === 'undefined')
352
283
  ? { register: () => {}, unregister: () => {} }
353
284
  : new FinalizationRegistry(ptr => wasm.__wbg_smelterrenderer_free(ptr >>> 0, 1));
@@ -374,38 +305,34 @@ class SmelterRenderer {
374
305
  wasm.__wbg_smelterrenderer_free(ptr, 0);
375
306
  }
376
307
  /**
377
- * @param {FrameSet} input
378
- * @returns {FrameSet}
308
+ * @param {InputFrameSet} input
309
+ * @returns {Promise<OutputFrameSet>}
379
310
  */
380
311
  render(input) {
381
- _assertClass(input, FrameSet);
382
- var ptr0 = input.__destroy_into_raw();
383
- const ret = wasm.smelterrenderer_render(this.__wbg_ptr, ptr0);
384
- if (ret[2]) {
385
- throw takeFromExternrefTable0(ret[1]);
386
- }
387
- return FrameSet.__wrap(ret[0]);
312
+ const ret = wasm.smelterrenderer_render(this.__wbg_ptr, input);
313
+ return ret;
388
314
  }
389
315
  /**
390
316
  * @param {string} output_id
391
317
  * @param {any} resolution
392
318
  * @param {any} scene
319
+ * @returns {Promise<void>}
393
320
  */
394
321
  update_scene(output_id, resolution, scene) {
395
322
  const ptr0 = passStringToWasm0(output_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
396
323
  const len0 = WASM_VECTOR_LEN;
397
324
  const ret = wasm.smelterrenderer_update_scene(this.__wbg_ptr, ptr0, len0, resolution, scene);
398
- if (ret[1]) {
399
- throw takeFromExternrefTable0(ret[0]);
400
- }
325
+ return ret;
401
326
  }
402
327
  /**
403
328
  * @param {string} input_id
329
+ * @returns {Promise<void>}
404
330
  */
405
331
  register_input(input_id) {
406
332
  const ptr0 = passStringToWasm0(input_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
407
333
  const len0 = WASM_VECTOR_LEN;
408
- wasm.smelterrenderer_register_input(this.__wbg_ptr, ptr0, len0);
334
+ const ret = wasm.smelterrenderer_register_input(this.__wbg_ptr, ptr0, len0);
335
+ return ret;
409
336
  }
410
337
  /**
411
338
  * @param {string} renderer_id
@@ -418,6 +345,17 @@ class SmelterRenderer {
418
345
  const ret = wasm.smelterrenderer_register_image(this.__wbg_ptr, ptr0, len0, image_spec);
419
346
  return ret;
420
347
  }
348
+ /**
349
+ * @param {string} shader_id
350
+ * @param {any} shader_spec
351
+ * @returns {Promise<void>}
352
+ */
353
+ register_shader(shader_id, shader_spec) {
354
+ const ptr0 = passStringToWasm0(shader_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
+ const len0 = WASM_VECTOR_LEN;
356
+ const ret = wasm.smelterrenderer_register_shader(this.__wbg_ptr, ptr0, len0, shader_spec);
357
+ return ret;
358
+ }
421
359
  /**
422
360
  * @param {string} font_url
423
361
  * @returns {Promise<void>}
@@ -430,30 +368,43 @@ class SmelterRenderer {
430
368
  }
431
369
  /**
432
370
  * @param {string} input_id
371
+ * @returns {Promise<void>}
433
372
  */
434
373
  unregister_input(input_id) {
435
374
  const ptr0 = passStringToWasm0(input_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
436
375
  const len0 = WASM_VECTOR_LEN;
437
- wasm.smelterrenderer_unregister_input(this.__wbg_ptr, ptr0, len0);
376
+ const ret = wasm.smelterrenderer_unregister_input(this.__wbg_ptr, ptr0, len0);
377
+ return ret;
438
378
  }
439
379
  /**
440
380
  * @param {string} output_id
381
+ * @returns {Promise<void>}
441
382
  */
442
383
  unregister_output(output_id) {
443
384
  const ptr0 = passStringToWasm0(output_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
444
385
  const len0 = WASM_VECTOR_LEN;
445
- wasm.smelterrenderer_unregister_output(this.__wbg_ptr, ptr0, len0);
386
+ const ret = wasm.smelterrenderer_unregister_output(this.__wbg_ptr, ptr0, len0);
387
+ return ret;
446
388
  }
447
389
  /**
448
390
  * @param {string} renderer_id
391
+ * @returns {Promise<void>}
449
392
  */
450
393
  unregister_image(renderer_id) {
451
394
  const ptr0 = passStringToWasm0(renderer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
452
395
  const len0 = WASM_VECTOR_LEN;
453
396
  const ret = wasm.smelterrenderer_unregister_image(this.__wbg_ptr, ptr0, len0);
454
- if (ret[1]) {
455
- throw takeFromExternrefTable0(ret[0]);
456
- }
397
+ return ret;
398
+ }
399
+ /**
400
+ * @param {string} renderer_id
401
+ * @returns {Promise<void>}
402
+ */
403
+ unregister_shader(renderer_id) {
404
+ const ptr0 = passStringToWasm0(renderer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
405
+ const len0 = WASM_VECTOR_LEN;
406
+ const ret = wasm.smelterrenderer_unregister_shader(this.__wbg_ptr, ptr0, len0);
407
+ return ret;
457
408
  }
458
409
  }
459
410
 
@@ -507,6 +458,10 @@ function __wbg_get_imports() {
507
458
  imports.wbg.__wbg_activeTexture_460f2e367e813fb0 = function(arg0, arg1) {
508
459
  arg0.activeTexture(arg1 >>> 0);
509
460
  };
461
+ imports.wbg.__wbg_allocationSize_da90e777d24e264f = function() { return handleError(function (arg0, arg1) {
462
+ const ret = arg0.allocationSize(arg1);
463
+ return ret;
464
+ }, arguments) };
510
465
  imports.wbg.__wbg_append_8c7dd8d641a5f01b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
511
466
  arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
512
467
  }, arguments) };
@@ -698,6 +653,10 @@ function __wbg_get_imports() {
698
653
  imports.wbg.__wbg_copyTexSubImage3D_32e92c94044e58ca = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
699
654
  arg0.copyTexSubImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
700
655
  };
656
+ imports.wbg.__wbg_copyTo_6a0737a733066d69 = function(arg0, arg1, arg2, arg3) {
657
+ const ret = arg0.copyTo(getArrayU8FromWasm0(arg1, arg2), arg3);
658
+ return ret;
659
+ };
701
660
  imports.wbg.__wbg_createBuffer_7a9ec3d654073660 = function(arg0) {
702
661
  const ret = arg0.createBuffer();
703
662
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -762,19 +721,12 @@ function __wbg_get_imports() {
762
721
  const ret = arg0.createVertexArray();
763
722
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
764
723
  };
765
- imports.wbg.__wbg_crypto_ed58b8e10a292839 = function(arg0) {
766
- const ret = arg0.crypto;
767
- return ret;
768
- };
769
724
  imports.wbg.__wbg_cullFace_187079e6e20a464d = function(arg0, arg1) {
770
725
  arg0.cullFace(arg1 >>> 0);
771
726
  };
772
727
  imports.wbg.__wbg_cullFace_fbae6dd4d5e61ba4 = function(arg0, arg1) {
773
728
  arg0.cullFace(arg1 >>> 0);
774
729
  };
775
- imports.wbg.__wbg_debug_e17b51583ca6a632 = function(arg0, arg1, arg2, arg3) {
776
- console.debug(arg0, arg1, arg2, arg3);
777
- };
778
730
  imports.wbg.__wbg_deleteBuffer_7ed96e1bf7c02e87 = function(arg0, arg1) {
779
731
  arg0.deleteBuffer(arg1);
780
732
  };
@@ -856,6 +808,14 @@ function __wbg_get_imports() {
856
808
  imports.wbg.__wbg_disable_8b53998501a7a85b = function(arg0, arg1) {
857
809
  arg0.disable(arg1 >>> 0);
858
810
  };
811
+ imports.wbg.__wbg_displayHeight_a6ff7964b6182d84 = function(arg0) {
812
+ const ret = arg0.displayHeight;
813
+ return ret;
814
+ };
815
+ imports.wbg.__wbg_displayWidth_d82e7b620f6f4189 = function(arg0) {
816
+ const ret = arg0.displayWidth;
817
+ return ret;
818
+ };
859
819
  imports.wbg.__wbg_document_d249400bd7bd996d = function(arg0) {
860
820
  const ret = arg0.document;
861
821
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -907,10 +867,6 @@ function __wbg_get_imports() {
907
867
  const ret = Object.entries(arg0);
908
868
  return ret;
909
869
  };
910
- imports.wbg.__wbg_entries_c8a90a7ed73e84ce = function(arg0) {
911
- const ret = arg0.entries();
912
- return ret;
913
- };
914
870
  imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
915
871
  let deferred0_0;
916
872
  let deferred0_1;
@@ -922,9 +878,6 @@ function __wbg_get_imports() {
922
878
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
923
879
  }
924
880
  };
925
- imports.wbg.__wbg_error_80de38b3f7cc3c3c = function(arg0, arg1, arg2, arg3) {
926
- console.error(arg0, arg1, arg2, arg3);
927
- };
928
881
  imports.wbg.__wbg_fenceSync_02d142d21e315da6 = function(arg0, arg1, arg2) {
929
882
  const ret = arg0.fenceSync(arg1 >>> 0, arg2 >>> 0);
930
883
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -937,6 +890,12 @@ function __wbg_get_imports() {
937
890
  const ret = arg0.fetch(arg1);
938
891
  return ret;
939
892
  };
893
+ imports.wbg.__wbg_flush_4150080f65c49208 = function(arg0) {
894
+ arg0.flush();
895
+ };
896
+ imports.wbg.__wbg_flush_987c35de09e06fd6 = function(arg0) {
897
+ arg0.flush();
898
+ };
940
899
  imports.wbg.__wbg_framebufferRenderbuffer_2fdd12e89ad81eb9 = function(arg0, arg1, arg2, arg3, arg4) {
941
900
  arg0.framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4);
942
901
  };
@@ -1014,9 +973,6 @@ function __wbg_get_imports() {
1014
973
  const ret = arg0.getQueryParameter(arg1, arg2 >>> 0);
1015
974
  return ret;
1016
975
  };
1017
- imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
1018
- arg0.getRandomValues(arg1);
1019
- }, arguments) };
1020
976
  imports.wbg.__wbg_getShaderInfoLog_7e7b38fb910ec534 = function(arg0, arg1, arg2) {
1021
977
  const ret = arg1.getShaderInfoLog(arg2);
1022
978
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1067,10 +1023,6 @@ function __wbg_get_imports() {
1067
1023
  const ret = Reflect.get(arg0, arg1);
1068
1024
  return ret;
1069
1025
  }, arguments) };
1070
- imports.wbg.__wbg_get_85c3d71662a108c8 = function() { return handleError(function (arg0, arg1) {
1071
- const ret = Reflect.get(arg0, arg1 >>> 0);
1072
- return ret;
1073
- }, arguments) };
1074
1026
  imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
1075
1027
  const ret = arg0[arg1 >>> 0];
1076
1028
  return ret;
@@ -1087,13 +1039,34 @@ function __wbg_get_imports() {
1087
1039
  const ret = arg0.headers;
1088
1040
  return ret;
1089
1041
  };
1042
+ imports.wbg.__wbg_height_1d93eb7f5e355d97 = function(arg0) {
1043
+ const ret = arg0.height;
1044
+ return ret;
1045
+ };
1046
+ imports.wbg.__wbg_height_1f8226c8f6875110 = function(arg0) {
1047
+ const ret = arg0.height;
1048
+ return ret;
1049
+ };
1050
+ imports.wbg.__wbg_height_838cee19ba8597db = function(arg0) {
1051
+ const ret = arg0.height;
1052
+ return ret;
1053
+ };
1054
+ imports.wbg.__wbg_height_d3f39e12f0f62121 = function(arg0) {
1055
+ const ret = arg0.height;
1056
+ return ret;
1057
+ };
1058
+ imports.wbg.__wbg_height_df1aa98dfbbe11ad = function(arg0) {
1059
+ const ret = arg0.height;
1060
+ return ret;
1061
+ };
1062
+ imports.wbg.__wbg_height_e3c322f23d99ad2f = function(arg0) {
1063
+ const ret = arg0.height;
1064
+ return ret;
1065
+ };
1090
1066
  imports.wbg.__wbg_includes_937486a108ec147b = function(arg0, arg1, arg2) {
1091
1067
  const ret = arg0.includes(arg1, arg2);
1092
1068
  return ret;
1093
1069
  };
1094
- imports.wbg.__wbg_info_033d8b8a0838f1d3 = function(arg0, arg1, arg2, arg3) {
1095
- console.info(arg0, arg1, arg2, arg3);
1096
- };
1097
1070
  imports.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
1098
1071
  let result;
1099
1072
  try {
@@ -1114,6 +1087,16 @@ function __wbg_get_imports() {
1114
1087
  const ret = result;
1115
1088
  return ret;
1116
1089
  };
1090
+ imports.wbg.__wbg_instanceof_HtmlVideoElement_7f414b32f362e317 = function(arg0) {
1091
+ let result;
1092
+ try {
1093
+ result = arg0 instanceof HTMLVideoElement;
1094
+ } catch (_) {
1095
+ result = false;
1096
+ }
1097
+ const ret = result;
1098
+ return ret;
1099
+ };
1117
1100
  imports.wbg.__wbg_instanceof_Map_f3469ce2244d2430 = function(arg0) {
1118
1101
  let result;
1119
1102
  try {
@@ -1144,6 +1127,16 @@ function __wbg_get_imports() {
1144
1127
  const ret = result;
1145
1128
  return ret;
1146
1129
  };
1130
+ imports.wbg.__wbg_instanceof_VideoFrame_f362406fe1355687 = function(arg0) {
1131
+ let result;
1132
+ try {
1133
+ result = arg0 instanceof VideoFrame;
1134
+ } catch (_) {
1135
+ result = false;
1136
+ }
1137
+ const ret = result;
1138
+ return ret;
1139
+ };
1147
1140
  imports.wbg.__wbg_instanceof_WebGl2RenderingContext_2b6045efeb76568d = function(arg0) {
1148
1141
  let result;
1149
1142
  try {
@@ -1183,10 +1176,6 @@ function __wbg_get_imports() {
1183
1176
  const ret = Symbol.iterator;
1184
1177
  return ret;
1185
1178
  };
1186
- imports.wbg.__wbg_length_238152a0aedbb6e7 = function(arg0) {
1187
- const ret = arg0.length;
1188
- return ret;
1189
- };
1190
1179
  imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
1191
1180
  const ret = arg0.length;
1192
1181
  return ret;
@@ -1212,9 +1201,6 @@ function __wbg_get_imports() {
1212
1201
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1213
1202
  }
1214
1203
  };
1215
- imports.wbg.__wbg_log_cad59bb680daec67 = function(arg0, arg1, arg2, arg3) {
1216
- console.log(arg0, arg1, arg2, arg3);
1217
- };
1218
1204
  imports.wbg.__wbg_log_cb9e190acc5753fb = function(arg0, arg1) {
1219
1205
  let deferred0_0;
1220
1206
  let deferred0_1;
@@ -1245,10 +1231,6 @@ function __wbg_get_imports() {
1245
1231
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1246
1232
  }
1247
1233
  }, arguments) };
1248
- imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
1249
- const ret = arg0.msCrypto;
1250
- return ret;
1251
- };
1252
1234
  imports.wbg.__wbg_new_018dcc2d6c8c2f6a = function() { return handleError(function () {
1253
1235
  const ret = new Headers();
1254
1236
  return ret;
@@ -1260,7 +1242,7 @@ function __wbg_get_imports() {
1260
1242
  const a = state0.a;
1261
1243
  state0.a = 0;
1262
1244
  try {
1263
- return __wbg_adapter_718(a, state0.b, arg0, arg1);
1245
+ return __wbg_adapter_739(a, state0.b, arg0, arg1);
1264
1246
  } finally {
1265
1247
  state0.a = a;
1266
1248
  }
@@ -1279,18 +1261,10 @@ function __wbg_get_imports() {
1279
1261
  const ret = new Object();
1280
1262
  return ret;
1281
1263
  };
1282
- imports.wbg.__wbg_new_5e0be73521bc8c17 = function() {
1283
- const ret = new Map();
1284
- return ret;
1285
- };
1286
1264
  imports.wbg.__wbg_new_78feb108b6472713 = function() {
1287
1265
  const ret = new Array();
1288
1266
  return ret;
1289
1267
  };
1290
- imports.wbg.__wbg_new_7a91e41fe43b3c92 = function(arg0) {
1291
- const ret = new Uint8ClampedArray(arg0);
1292
- return ret;
1293
- };
1294
1268
  imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
1295
1269
  const ret = new Error();
1296
1270
  return ret;
@@ -1335,10 +1309,6 @@ function __wbg_get_imports() {
1335
1309
  const ret = new Int16Array(arg0, arg1 >>> 0, arg2 >>> 0);
1336
1310
  return ret;
1337
1311
  };
1338
- imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
1339
- const ret = new Uint8Array(arg0 >>> 0);
1340
- return ret;
1341
- };
1342
1312
  imports.wbg.__wbg_newwithstrandinit_06c535e0a867c635 = function() { return handleError(function (arg0, arg1, arg2) {
1343
1313
  const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
1344
1314
  return ret;
@@ -1351,10 +1321,6 @@ function __wbg_get_imports() {
1351
1321
  const ret = arg0.next();
1352
1322
  return ret;
1353
1323
  }, arguments) };
1354
- imports.wbg.__wbg_node_02999533c4ea02e3 = function(arg0) {
1355
- const ret = arg0.node;
1356
- return ret;
1357
- };
1358
1324
  imports.wbg.__wbg_of_2eaf5a02d443ef03 = function(arg0) {
1359
1325
  const ret = Array.of(arg0);
1360
1326
  return ret;
@@ -1371,10 +1337,6 @@ function __wbg_get_imports() {
1371
1337
  imports.wbg.__wbg_polygonOffset_8c11c066486216c4 = function(arg0, arg1, arg2) {
1372
1338
  arg0.polygonOffset(arg1, arg2);
1373
1339
  };
1374
- imports.wbg.__wbg_process_5c1d670bc53614b8 = function(arg0) {
1375
- const ret = arg0.process;
1376
- return ret;
1377
- };
1378
1340
  imports.wbg.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
1379
1341
  const ret = arg0.push(arg1);
1380
1342
  return ret;
@@ -1393,9 +1355,6 @@ function __wbg_get_imports() {
1393
1355
  const ret = arg0.queueMicrotask;
1394
1356
  return ret;
1395
1357
  };
1396
- imports.wbg.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) {
1397
- arg0.randomFillSync(arg1);
1398
- }, arguments) };
1399
1358
  imports.wbg.__wbg_readBuffer_1c35b1e4939f881d = function(arg0, arg1) {
1400
1359
  arg0.readBuffer(arg1 >>> 0);
1401
1360
  };
@@ -1417,10 +1376,6 @@ function __wbg_get_imports() {
1417
1376
  imports.wbg.__wbg_renderbufferStorage_f010012bd3566942 = function(arg0, arg1, arg2, arg3, arg4) {
1418
1377
  arg0.renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4);
1419
1378
  };
1420
- imports.wbg.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
1421
- const ret = module.require;
1422
- return ret;
1423
- }, arguments) };
1424
1379
  imports.wbg.__wbg_resolve_4851785c9c5f573d = function(arg0) {
1425
1380
  const ret = Promise.resolve(arg0);
1426
1381
  return ret;
@@ -1437,19 +1392,9 @@ function __wbg_get_imports() {
1437
1392
  imports.wbg.__wbg_scissor_eb177ca33bf24a44 = function(arg0, arg1, arg2, arg3, arg4) {
1438
1393
  arg0.scissor(arg1, arg2, arg3, arg4);
1439
1394
  };
1440
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
1441
- arg0[arg1] = arg2;
1442
- };
1443
1395
  imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
1444
1396
  arg0.set(arg1, arg2 >>> 0);
1445
1397
  };
1446
- imports.wbg.__wbg_set_6775f73144c2ef27 = function(arg0, arg1, arg2) {
1447
- arg0.set(arg1, arg2 >>> 0);
1448
- };
1449
- imports.wbg.__wbg_set_8fc6bf8a5b1071d1 = function(arg0, arg1, arg2) {
1450
- const ret = arg0.set(arg1, arg2);
1451
- return ret;
1452
- };
1453
1398
  imports.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) {
1454
1399
  const ret = Reflect.set(arg0, arg1, arg2);
1455
1400
  return ret;
@@ -1469,6 +1414,9 @@ function __wbg_get_imports() {
1469
1414
  imports.wbg.__wbg_setheight_da683a33fa99843c = function(arg0, arg1) {
1470
1415
  arg0.height = arg1 >>> 0;
1471
1416
  };
1417
+ imports.wbg.__wbg_setlayout_1a66735c5ff7f19e = function(arg0, arg1) {
1418
+ arg0.layout = arg1;
1419
+ };
1472
1420
  imports.wbg.__wbg_setmethod_3c5280fe5d890842 = function(arg0, arg1, arg2) {
1473
1421
  arg0.method = getStringFromWasm0(arg1, arg2);
1474
1422
  };
@@ -1553,10 +1501,6 @@ function __wbg_get_imports() {
1553
1501
  const ret = JSON.stringify(arg0);
1554
1502
  return ret;
1555
1503
  }, arguments) };
1556
- imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
1557
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1558
- return ret;
1559
- };
1560
1504
  imports.wbg.__wbg_texImage2D_57483314967bdd11 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
1561
1505
  arg0.texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
1562
1506
  }, arguments) };
@@ -1587,6 +1531,9 @@ function __wbg_get_imports() {
1587
1531
  imports.wbg.__wbg_texSubImage2D_061605071aad9d2c = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
1588
1532
  arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
1589
1533
  }, arguments) };
1534
+ imports.wbg.__wbg_texSubImage2D_82670edc2c5acd35 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
1535
+ arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
1536
+ }, arguments) };
1590
1537
  imports.wbg.__wbg_texSubImage2D_aa9a084093764796 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
1591
1538
  arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
1592
1539
  }, arguments) };
@@ -1608,6 +1555,9 @@ function __wbg_get_imports() {
1608
1555
  imports.wbg.__wbg_texSubImage2D_fbdf91268228c757 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
1609
1556
  arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
1610
1557
  }, arguments) };
1558
+ imports.wbg.__wbg_texSubImage3D_02bbdad14919acfc = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
1559
+ arg0.texSubImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 >>> 0, arg10 >>> 0, arg11);
1560
+ }, arguments) };
1611
1561
  imports.wbg.__wbg_texSubImage3D_04731251d7cecc83 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
1612
1562
  arg0.texSubImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 >>> 0, arg10 >>> 0, arg11);
1613
1563
  }, arguments) };
@@ -1759,10 +1709,6 @@ function __wbg_get_imports() {
1759
1709
  const ret = arg0.value;
1760
1710
  return ret;
1761
1711
  };
1762
- imports.wbg.__wbg_versions_c71aa1626a93e0a1 = function(arg0) {
1763
- const ret = arg0.versions;
1764
- return ret;
1765
- };
1766
1712
  imports.wbg.__wbg_vertexAttribDivisorANGLE_11e909d332960413 = function(arg0, arg1, arg2) {
1767
1713
  arg0.vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0);
1768
1714
  };
@@ -1778,14 +1724,54 @@ function __wbg_get_imports() {
1778
1724
  imports.wbg.__wbg_vertexAttribPointer_7a2a506cdbe3aebc = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
1779
1725
  arg0.vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6);
1780
1726
  };
1727
+ imports.wbg.__wbg_videoHeight_3a43327a766c1f03 = function(arg0) {
1728
+ const ret = arg0.videoHeight;
1729
+ return ret;
1730
+ };
1731
+ imports.wbg.__wbg_videoWidth_4b400cf6f4744a4d = function(arg0) {
1732
+ const ret = arg0.videoWidth;
1733
+ return ret;
1734
+ };
1781
1735
  imports.wbg.__wbg_viewport_a1b4d71297ba89af = function(arg0, arg1, arg2, arg3, arg4) {
1782
1736
  arg0.viewport(arg1, arg2, arg3, arg4);
1783
1737
  };
1784
1738
  imports.wbg.__wbg_viewport_e615e98f676f2d39 = function(arg0, arg1, arg2, arg3, arg4) {
1785
1739
  arg0.viewport(arg1, arg2, arg3, arg4);
1786
1740
  };
1787
- imports.wbg.__wbg_warn_aaf1f4664a035bd6 = function(arg0, arg1, arg2, arg3) {
1788
- console.warn(arg0, arg1, arg2, arg3);
1741
+ imports.wbg.__wbg_visibleRect_f7558c0cfa7dfdbf = function(arg0) {
1742
+ const ret = arg0.visibleRect;
1743
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1744
+ };
1745
+ imports.wbg.__wbg_width_4f334fc47ef03de1 = function(arg0) {
1746
+ const ret = arg0.width;
1747
+ return ret;
1748
+ };
1749
+ imports.wbg.__wbg_width_5dde457d606ba683 = function(arg0) {
1750
+ const ret = arg0.width;
1751
+ return ret;
1752
+ };
1753
+ imports.wbg.__wbg_width_8fe4e8f77479c2a6 = function(arg0) {
1754
+ const ret = arg0.width;
1755
+ return ret;
1756
+ };
1757
+ imports.wbg.__wbg_width_b0c1d9f437a95799 = function(arg0) {
1758
+ const ret = arg0.width;
1759
+ return ret;
1760
+ };
1761
+ imports.wbg.__wbg_width_cdaf02311c1621d1 = function(arg0) {
1762
+ const ret = arg0.width;
1763
+ return ret;
1764
+ };
1765
+ imports.wbg.__wbg_width_f54c7178d3c78f16 = function(arg0) {
1766
+ const ret = arg0.width;
1767
+ return ret;
1768
+ };
1769
+ imports.wbg.__wbindgen_array_new = function() {
1770
+ const ret = [];
1771
+ return ret;
1772
+ };
1773
+ imports.wbg.__wbindgen_array_push = function(arg0, arg1) {
1774
+ arg0.push(arg1);
1789
1775
  };
1790
1776
  imports.wbg.__wbindgen_as_number = function(arg0) {
1791
1777
  const ret = +arg0;
@@ -1795,6 +1781,10 @@ function __wbg_get_imports() {
1795
1781
  const ret = arg0;
1796
1782
  return ret;
1797
1783
  };
1784
+ imports.wbg.__wbindgen_bigint_from_u128 = function(arg0, arg1) {
1785
+ const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1);
1786
+ return ret;
1787
+ };
1798
1788
  imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
1799
1789
  const ret = BigInt.asUintN(64, arg0);
1800
1790
  return ret;
@@ -1819,8 +1809,8 @@ function __wbg_get_imports() {
1819
1809
  const ret = false;
1820
1810
  return ret;
1821
1811
  };
1822
- imports.wbg.__wbindgen_closure_wrapper2577 = function(arg0, arg1, arg2) {
1823
- const ret = makeMutClosure(arg0, arg1, 550, __wbg_adapter_54);
1812
+ imports.wbg.__wbindgen_closure_wrapper2885 = function(arg0, arg1, arg2) {
1813
+ const ret = makeMutClosure(arg0, arg1, 1065, __wbg_adapter_60);
1824
1814
  return ret;
1825
1815
  };
1826
1816
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
@@ -1972,11 +1962,6 @@ const loadWasmModule = (() => {
1972
1962
  };
1973
1963
  })();
1974
1964
 
1975
- var FrameFormat;
1976
- (function (FrameFormat) {
1977
- FrameFormat["RGBA_BYTES"] = "RGBA_BYTES";
1978
- FrameFormat["YUV_BYTES"] = "YUV_BYTES";
1979
- })(FrameFormat || (FrameFormat = {}));
1980
1965
  class Renderer {
1981
1966
  renderer;
1982
1967
  constructor(renderer) {
@@ -1985,40 +1970,51 @@ class Renderer {
1985
1970
  static async create(options) {
1986
1971
  const renderer = await create_renderer({
1987
1972
  stream_fallback_timeout_ms: options.streamFallbackTimeoutMs,
1988
- logger_level: options.logger_level ?? 'warn',
1973
+ logger_level: options.loggerLevel ?? 'warn',
1974
+ upload_frames_with_copy_external: self.navigator.userAgent.includes('Macintosh'),
1989
1975
  });
1990
1976
  return new Renderer(renderer);
1991
1977
  }
1992
- render(input) {
1993
- const frames = new Map(Object.entries(input.frames));
1994
- const inputFrameSet = new FrameSet(input.ptsMs, frames);
1995
- const output = this.renderer.render(inputFrameSet);
1978
+ async render(input) {
1979
+ const frames = Object.entries(input.frames).map(([inputId, value]) => {
1980
+ return { inputId, frame: value.frame, ptsMs: value.ptsMs };
1981
+ });
1982
+ const output = await this.renderer.render({
1983
+ ptsMs: input.ptsMs,
1984
+ frames,
1985
+ });
1996
1986
  return {
1997
- ptsMs: output.pts_ms,
1998
- frames: Object.fromEntries(output.frames),
1987
+ ptsMs: output.ptsMs,
1988
+ frames: Object.fromEntries(output.frames.map(({ outputId, ...value }) => [outputId, value])),
1999
1989
  };
2000
1990
  }
2001
- updateScene(outputId, resolution, scene) {
2002
- this.renderer.update_scene(outputId, resolution, scene);
1991
+ async updateScene(outputId, resolution, scene) {
1992
+ await this.renderer.update_scene(outputId, resolution, scene);
2003
1993
  }
2004
- registerInput(inputId) {
2005
- this.renderer.register_input(inputId);
1994
+ async registerInput(inputId) {
1995
+ await this.renderer.register_input(inputId);
2006
1996
  }
2007
1997
  async registerImage(rendererId, imageSpec) {
2008
1998
  await this.renderer.register_image(rendererId, imageSpec);
2009
1999
  }
2000
+ async registerShader(rendererId, shaderSpec) {
2001
+ await this.renderer.register_shader(rendererId, shaderSpec);
2002
+ }
2010
2003
  async registerFont(fontUrl) {
2011
2004
  await this.renderer.register_font(fontUrl);
2012
2005
  }
2013
- unregisterInput(inputId) {
2014
- this.renderer.unregister_input(inputId);
2006
+ async unregisterInput(inputId) {
2007
+ await this.renderer.unregister_input(inputId);
2008
+ }
2009
+ async unregisterImage(rendererId) {
2010
+ await this.renderer.unregister_image(rendererId);
2015
2011
  }
2016
- unregisterImage(rendererId) {
2017
- this.renderer.unregister_image(rendererId);
2012
+ async unregisterShader(rendererId) {
2013
+ await this.renderer.unregister_shader(rendererId);
2018
2014
  }
2019
- unregisterOutput(outputId) {
2020
- this.renderer.unregister_output(outputId);
2015
+ async unregisterOutput(outputId) {
2016
+ await this.renderer.unregister_output(outputId);
2021
2017
  }
2022
2018
  }
2023
2019
 
2024
- export { FrameFormat, Renderer, loadWasmModule };
2020
+ export { Renderer, loadWasmModule };
package/dist/smelter.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/smelter-browser-render",
3
- "version": "0.2.1",
3
+ "version": "0.3.0-rc.0",
4
4
  "author": "Software Mansion <contact@swmansion.com>",
5
5
  "license": "SEE LICENSE IN ./LICENSE",
6
6
  "description": "Smelter rendering engine compiled to WASM",
@@ -21,7 +21,7 @@
21
21
  "wasm-pack": "^0.13.0"
22
22
  },
23
23
  "peerDependencies": {
24
- "@swmansion/smelter": "0.2.1"
24
+ "@swmansion/smelter": "0.3.0-rc.0"
25
25
  },
26
26
  "scripts": {
27
27
  "lint": "eslint .",