@tsparticles/plugin-export-video 3.0.2 → 3.1.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.
@@ -1,3 +1,4 @@
1
+ import { millisecondsToSeconds, } from "@tsparticles/engine";
1
2
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
2
3
  "vp9",
3
4
  "vp9.0",
@@ -16,7 +17,7 @@ const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
16
17
  "mp4a",
17
18
  ];
18
19
  function getVideoSupportedMimeTypes() {
19
- const isSupported = MediaRecorder.isTypeSupported, supported = [];
20
+ const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
20
21
  videoTypes.forEach((type) => {
21
22
  const mimeType = `video/${type}`;
22
23
  codecs.forEach((codec) => [
@@ -42,9 +43,9 @@ export class ExportVideoInstance {
42
43
  return;
43
44
  }
44
45
  return new Promise((resolve) => {
45
- const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), mimeType = data.mimeType ?? this._supportedTypes[0], recorder = new MediaRecorder(stream, {
46
+ const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), firstIndex = 0, mimeType = data.mimeType ?? this._supportedTypes[firstIndex], recorder = new MediaRecorder(stream, {
46
47
  mimeType,
47
- }), chunks = [];
48
+ }), chunks = [], defaultDuration = 5;
48
49
  recorder.addEventListener("dataavailable", (event) => {
49
50
  chunks.push(event.data);
50
51
  });
@@ -54,7 +55,7 @@ export class ExportVideoInstance {
54
55
  recorder.start();
55
56
  setTimeout(() => {
56
57
  recorder.stop();
57
- }, data.duration ?? 5000);
58
+ }, data.duration ?? defaultDuration * millisecondsToSeconds);
58
59
  });
59
60
  };
60
61
  this._container = container;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportVideoInstance = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
4
5
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
5
6
  "vp9",
6
7
  "vp9.0",
@@ -19,7 +20,7 @@ const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
19
20
  "mp4a",
20
21
  ];
21
22
  function getVideoSupportedMimeTypes() {
22
- const isSupported = MediaRecorder.isTypeSupported, supported = [];
23
+ const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
23
24
  videoTypes.forEach((type) => {
24
25
  const mimeType = `video/${type}`;
25
26
  codecs.forEach((codec) => [
@@ -45,9 +46,9 @@ class ExportVideoInstance {
45
46
  return;
46
47
  }
47
48
  return new Promise((resolve) => {
48
- const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), mimeType = data.mimeType ?? this._supportedTypes[0], recorder = new MediaRecorder(stream, {
49
+ const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), firstIndex = 0, mimeType = data.mimeType ?? this._supportedTypes[firstIndex], recorder = new MediaRecorder(stream, {
49
50
  mimeType,
50
- }), chunks = [];
51
+ }), chunks = [], defaultDuration = 5;
51
52
  recorder.addEventListener("dataavailable", (event) => {
52
53
  chunks.push(event.data);
53
54
  });
@@ -57,7 +58,7 @@ class ExportVideoInstance {
57
58
  recorder.start();
58
59
  setTimeout(() => {
59
60
  recorder.stop();
60
- }, data.duration ?? 5000);
61
+ }, data.duration ?? defaultDuration * engine_1.millisecondsToSeconds);
61
62
  });
62
63
  };
63
64
  this._container = container;
@@ -1,3 +1,4 @@
1
+ import { millisecondsToSeconds, } from "@tsparticles/engine";
1
2
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
2
3
  "vp9",
3
4
  "vp9.0",
@@ -16,7 +17,7 @@ const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
16
17
  "mp4a",
17
18
  ];
18
19
  function getVideoSupportedMimeTypes() {
19
- const isSupported = MediaRecorder.isTypeSupported, supported = [];
20
+ const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
20
21
  videoTypes.forEach((type) => {
21
22
  const mimeType = `video/${type}`;
22
23
  codecs.forEach((codec) => [
@@ -42,9 +43,9 @@ export class ExportVideoInstance {
42
43
  return;
43
44
  }
44
45
  return new Promise((resolve) => {
45
- const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), mimeType = data.mimeType ?? this._supportedTypes[0], recorder = new MediaRecorder(stream, {
46
+ const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), firstIndex = 0, mimeType = data.mimeType ?? this._supportedTypes[firstIndex], recorder = new MediaRecorder(stream, {
46
47
  mimeType,
47
- }), chunks = [];
48
+ }), chunks = [], defaultDuration = 5;
48
49
  recorder.addEventListener("dataavailable", (event) => {
49
50
  chunks.push(event.data);
50
51
  });
@@ -54,7 +55,7 @@ export class ExportVideoInstance {
54
55
  recorder.start();
55
56
  setTimeout(() => {
56
57
  recorder.stop();
57
- }, data.duration ?? 5000);
58
+ }, data.duration ?? defaultDuration * millisecondsToSeconds);
58
59
  });
59
60
  };
60
61
  this._container = container;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-export-video",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "tsParticles export video plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,7 +100,7 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "^3.0.2"
103
+ "@tsparticles/engine": "^3.1.0"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/plugin-export-video [6 Dec 2023 at 17:43]</title>
6
+ <title>@tsparticles/plugin-export-video [13 Jan 2024 at 23:04]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -31,7 +31,7 @@
31
31
  <body>
32
32
  <div id="app"></div>
33
33
  <script>
34
- window.chartData = [{"label":"tsparticles.plugin.export.video.js","isAsset":true,"statSize":2437,"parsedSize":4807,"gzipSize":1695,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":2437,"groups":[{"id":609,"label":"index.js + 1 modules (concatenated)","path":"./dist/browser/index.js + 1 modules (concatenated)","statSize":2437,"parsedSize":4807,"gzipSize":1695,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser","statSize":2437,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser/index.js","statSize":462,"parsedSize":911,"gzipSize":321,"inaccurateSizes":true},{"id":null,"label":"ExportVideoInstance.js","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser/ExportVideoInstance.js","statSize":1975,"parsedSize":3895,"gzipSize":1373,"inaccurateSizes":true}],"parsedSize":4807,"gzipSize":1695,"inaccurateSizes":true}]}],"parsedSize":4807,"gzipSize":1695}],"isInitialByEntrypoint":{"tsparticles.plugin.export.video":true}}];
34
+ window.chartData = [{"label":"tsparticles.plugin.export.video.js","isAsset":true,"statSize":2655,"parsedSize":6445,"gzipSize":2172,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":2613,"groups":[{"id":192,"label":"index.js + 1 modules (concatenated)","path":"./dist/browser/index.js + 1 modules (concatenated)","statSize":2613,"parsedSize":6445,"gzipSize":2172,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser","statSize":2613,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser/index.js","statSize":462,"parsedSize":1139,"gzipSize":384,"inaccurateSizes":true},{"id":null,"label":"ExportVideoInstance.js","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser/ExportVideoInstance.js","statSize":2151,"parsedSize":5305,"gzipSize":1787,"inaccurateSizes":true}],"parsedSize":6445,"gzipSize":2172,"inaccurateSizes":true}]}],"parsedSize":6445,"gzipSize":2172},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.plugin.export.video":true}}];
35
35
  window.entrypoints = ["tsparticles.plugin.export.video","tsparticles.plugin.export.video.min"];
36
36
  window.defaultSizes = "parsed";
37
37
  </script>
@@ -4,22 +4,54 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.2
7
+ * v3.1.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
11
- module.exports = factory();
11
+ module.exports = factory(require("@tsparticles/engine"));
12
12
  else if(typeof define === 'function' && define.amd)
13
- define([], factory);
13
+ define(["@tsparticles/engine"], factory);
14
14
  else {
15
- var a = factory();
15
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
16
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
17
  }
18
- })(this, () => {
18
+ })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
19
19
  return /******/ (() => { // webpackBootstrap
20
20
  /******/ "use strict";
21
- /******/ // The require scope
22
- /******/ var __webpack_require__ = {};
21
+ /******/ var __webpack_modules__ = ({
22
+
23
+ /***/ 533:
24
+ /***/ ((module) => {
25
+
26
+ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
27
+
28
+ /***/ })
29
+
30
+ /******/ });
31
+ /************************************************************************/
32
+ /******/ // The module cache
33
+ /******/ var __webpack_module_cache__ = {};
34
+ /******/
35
+ /******/ // The require function
36
+ /******/ function __webpack_require__(moduleId) {
37
+ /******/ // Check if module is in cache
38
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
39
+ /******/ if (cachedModule !== undefined) {
40
+ /******/ return cachedModule.exports;
41
+ /******/ }
42
+ /******/ // Create a new module (and put it into the cache)
43
+ /******/ var module = __webpack_module_cache__[moduleId] = {
44
+ /******/ // no module.id needed
45
+ /******/ // no module.loaded needed
46
+ /******/ exports: {}
47
+ /******/ };
48
+ /******/
49
+ /******/ // Execute the module function
50
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
51
+ /******/
52
+ /******/ // Return the exports of the module
53
+ /******/ return module.exports;
54
+ /******/ }
23
55
  /******/
24
56
  /************************************************************************/
25
57
  /******/ /* webpack/runtime/define property getters */
@@ -52,6 +84,8 @@ return /******/ (() => { // webpackBootstrap
52
84
  /******/
53
85
  /************************************************************************/
54
86
  var __webpack_exports__ = {};
87
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
+ (() => {
55
89
  // ESM COMPAT FLAG
56
90
  __webpack_require__.r(__webpack_exports__);
57
91
 
@@ -60,11 +94,14 @@ __webpack_require__.d(__webpack_exports__, {
60
94
  loadExportVideoPlugin: () => (/* binding */ loadExportVideoPlugin)
61
95
  });
62
96
 
97
+ // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
98
+ var engine_root_window_ = __webpack_require__(533);
63
99
  ;// CONCATENATED MODULE: ./dist/browser/ExportVideoInstance.js
100
+
64
101
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"],
65
102
  codecs = ["vp9", "vp9.0", "vp8", "vp8.0", "avc1", "av1", "h265", "h.265", "h264", "h.264", "opus", "pcm", "aac", "mpeg", "mp4a"];
66
103
  function getVideoSupportedMimeTypes() {
67
- const isSupported = MediaRecorder.isTypeSupported,
104
+ const isSupported = type => MediaRecorder.isTypeSupported(type),
68
105
  supported = [];
69
106
  videoTypes.forEach(type => {
70
107
  const mimeType = `video/${type}`;
@@ -89,11 +126,13 @@ class ExportVideoInstance {
89
126
  }
90
127
  return new Promise(resolve => {
91
128
  const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit),
92
- mimeType = data.mimeType ?? this._supportedTypes[0],
129
+ firstIndex = 0,
130
+ mimeType = data.mimeType ?? this._supportedTypes[firstIndex],
93
131
  recorder = new MediaRecorder(stream, {
94
132
  mimeType
95
133
  }),
96
- chunks = [];
134
+ chunks = [],
135
+ defaultDuration = 5;
97
136
  recorder.addEventListener("dataavailable", event => {
98
137
  chunks.push(event.data);
99
138
  });
@@ -105,7 +144,7 @@ class ExportVideoInstance {
105
144
  recorder.start();
106
145
  setTimeout(() => {
107
146
  recorder.stop();
108
- }, data.duration ?? 5000);
147
+ }, data.duration ?? defaultDuration * engine_root_window_.millisecondsToSeconds);
109
148
  });
110
149
  };
111
150
  this._container = container;
@@ -143,6 +182,8 @@ class ExportVideoPlugin {
143
182
  async function loadExportVideoPlugin(engine, refresh = true) {
144
183
  await engine.addPlugin(new ExportVideoPlugin(engine), refresh);
145
184
  }
185
+ })();
186
+
146
187
  /******/ return __webpack_exports__;
147
188
  /******/ })()
148
189
  ;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.export.video.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{loadExportVideoPlugin:()=>i});const o=["webm","ogg","mp4","x-matroska"],r=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","pcm","aac","mpeg","mp4a"];class n{constructor(e,t){this._supportedTypes=[],this._exportVideo=async e=>{const t=this._container.canvas.element;if(t)return new Promise((o=>{const r=t.captureStream(e.fps??this._container.actualOptions.fpsLimit),n=e.mimeType??this._supportedTypes[0],s=new MediaRecorder(r,{mimeType:n}),i=[];s.addEventListener("dataavailable",(e=>{i.push(e.data)})),s.addEventListener("stop",(()=>{o(new Blob(i,{type:n}))})),s.start(),setTimeout((()=>{s.stop()}),e.duration??5e3)}))},this._container=e,this._engine=t,this._supportedTypes=function(){const e=MediaRecorder.isTypeSupported,t=[];return o.forEach((o=>{const n=`video/${o}`;r.forEach((o=>[`${n};codecs=${o}`,`${n};codecs=${o.toUpperCase()}`].forEach((o=>{e(o)&&t.push(o)})))),e(n)&&t.push(n)})),t}()}async export(e,t){const o={supported:!1};if("video"===e)o.supported=!0,o.blob=await this._exportVideo(t);return o}}class s{constructor(e){this.id="export-video",this._engine=e}getPlugin(e){return new n(e,this._engine)}loadOptions(){}needsPlugin(){return!0}}async function i(e,t=!0){await e.addPlugin(new s(e),t)}return t})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,r),s.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{loadExportVideoPlugin:()=>p});var e=r(533);const t=["webm","ogg","mp4","x-matroska"],o=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","pcm","aac","mpeg","mp4a"];class s{constructor(r,n){this._supportedTypes=[],this._exportVideo=async t=>{const o=this._container.canvas.element;if(o)return new Promise((r=>{const n=o.captureStream(t.fps??this._container.actualOptions.fpsLimit),s=t.mimeType??this._supportedTypes[0],i=new MediaRecorder(n,{mimeType:s}),p=[];i.addEventListener("dataavailable",(e=>{p.push(e.data)})),i.addEventListener("stop",(()=>{r(new Blob(p,{type:s}))})),i.start(),setTimeout((()=>{i.stop()}),t.duration??5*e.millisecondsToSeconds)}))},this._container=r,this._engine=n,this._supportedTypes=function(){const e=e=>MediaRecorder.isTypeSupported(e),r=[];return t.forEach((t=>{const n=`video/${t}`;o.forEach((t=>[`${n};codecs=${t}`,`${n};codecs=${t.toUpperCase()}`].forEach((t=>{e(t)&&r.push(t)})))),e(n)&&r.push(n)})),r}()}async export(e,t){const o={supported:!1};if("video"===e)o.supported=!0,o.blob=await this._exportVideo(t);return o}}class i{constructor(e){this.id="export-video",this._engine=e}getPlugin(e){return new s(e,this._engine)}loadOptions(){}needsPlugin(){return!0}}async function p(e,t=!0){await e.addPlugin(new i(e),t)}})(),n})()));
@@ -1 +1 @@
1
- /*! tsParticles Export Video Plugin v3.0.2 by Matteo Bruni */
1
+ /*! tsParticles Export Video Plugin v3.1.0 by Matteo Bruni */
@@ -1,4 +1,4 @@
1
- import type { Container, Engine, ExportResult, IContainerPlugin } from "@tsparticles/engine";
1
+ import { type Container, type Engine, type ExportResult, type IContainerPlugin } from "@tsparticles/engine";
2
2
  export declare class ExportVideoInstance implements IContainerPlugin {
3
3
  private readonly _container;
4
4
  private readonly _engine;
@@ -4,12 +4,13 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ExportVideoInstance = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
13
14
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
14
15
  "vp9",
15
16
  "vp9.0",
@@ -28,7 +29,7 @@
28
29
  "mp4a",
29
30
  ];
30
31
  function getVideoSupportedMimeTypes() {
31
- const isSupported = MediaRecorder.isTypeSupported, supported = [];
32
+ const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
32
33
  videoTypes.forEach((type) => {
33
34
  const mimeType = `video/${type}`;
34
35
  codecs.forEach((codec) => [
@@ -54,9 +55,9 @@
54
55
  return;
55
56
  }
56
57
  return new Promise((resolve) => {
57
- const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), mimeType = data.mimeType ?? this._supportedTypes[0], recorder = new MediaRecorder(stream, {
58
+ const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit), firstIndex = 0, mimeType = data.mimeType ?? this._supportedTypes[firstIndex], recorder = new MediaRecorder(stream, {
58
59
  mimeType,
59
- }), chunks = [];
60
+ }), chunks = [], defaultDuration = 5;
60
61
  recorder.addEventListener("dataavailable", (event) => {
61
62
  chunks.push(event.data);
62
63
  });
@@ -66,7 +67,7 @@
66
67
  recorder.start();
67
68
  setTimeout(() => {
68
69
  recorder.stop();
69
- }, data.duration ?? 5000);
70
+ }, data.duration ?? defaultDuration * engine_1.millisecondsToSeconds);
70
71
  });
71
72
  };
72
73
  this._container = container;