@tsparticles/plugin-export-video 3.9.0 → 4.0.0-alpha.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/973.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 973.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_export_video=this.webpackChunk_tsparticles_plugin_export_video||[]).push([[973],{973(e,t,s){s.d(t,{ExportVideoPlugin:()=>n});var o=s(303);const p=["webm","ogg","mp4","x-matroska"],i=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","pcm","aac","mpeg","mp4a"];class r{constructor(e){this._supportedTypes=[],this._exportVideo=async e=>{const t=this._container.canvas.element;if(t)return new Promise((s=>{const p=t.captureStream(e.fps??this._container.actualOptions.fpsLimit),i=e.mimeType??this._supportedTypes[0],r=new MediaRecorder(p,{mimeType:i}),n=[];r.addEventListener("dataavailable",(e=>{n.push(e.data)})),r.addEventListener("stop",(()=>{s(new Blob(n,{type:i}))})),r.start(),setTimeout((()=>{r.stop()}),e.duration??5*o.millisecondsToSeconds)}))},this._container=e,this._supportedTypes=function(){const e=e=>MediaRecorder.isTypeSupported(e),t=[];return p.forEach((s=>{const o=`video/${s}`;i.forEach((s=>{[`${o};codecs=${s}`,`${o};codecs=${s.toUpperCase()}`].forEach((s=>{e(s)&&t.push(s)}))})),e(o)&&t.push(o)})),t}()}async export(e,t){const s={supported:!1};if("video"===e)s.supported=!0,s.blob=await this._exportVideo(t);return s}}class n{constructor(){this.id="export-video"}getPlugin(e){return Promise.resolve(new r(e))}loadOptions(){}needsPlugin(){return!0}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Export Video Plugin v4.0.0-alpha.0 by Matteo Bruni */
@@ -1,4 +1,4 @@
1
- import { millisecondsToSeconds, } from "@tsparticles/engine";
1
+ import { millisecondsToSeconds } from "@tsparticles/engine";
2
2
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
3
3
  "vp9",
4
4
  "vp9.0",
@@ -20,14 +20,16 @@ function getVideoSupportedMimeTypes() {
20
20
  const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
21
21
  videoTypes.forEach(type => {
22
22
  const mimeType = `video/${type}`;
23
- codecs.forEach(codec => [
24
- `${mimeType};codecs=${codec}`,
25
- `${mimeType};codecs=${codec.toUpperCase()}`,
26
- ].forEach(variation => {
27
- if (isSupported(variation)) {
28
- supported.push(variation);
29
- }
30
- }));
23
+ codecs.forEach(codec => {
24
+ [
25
+ `${mimeType};codecs=${codec}`,
26
+ `${mimeType};codecs=${codec.toUpperCase()}`,
27
+ ].forEach(variation => {
28
+ if (isSupported(variation)) {
29
+ supported.push(variation);
30
+ }
31
+ });
32
+ });
31
33
  if (isSupported(mimeType)) {
32
34
  supported.push(mimeType);
33
35
  }
@@ -35,7 +37,7 @@ function getVideoSupportedMimeTypes() {
35
37
  return supported;
36
38
  }
37
39
  export class ExportVideoInstance {
38
- constructor(container, engine) {
40
+ constructor(container) {
39
41
  this._supportedTypes = [];
40
42
  this._exportVideo = async (data) => {
41
43
  const element = this._container.canvas.element;
@@ -59,7 +61,6 @@ export class ExportVideoInstance {
59
61
  });
60
62
  };
61
63
  this._container = container;
62
- this._engine = engine;
63
64
  this._supportedTypes = getVideoSupportedMimeTypes();
64
65
  }
65
66
  async export(type, data) {
@@ -1,11 +1,10 @@
1
1
  import { ExportVideoInstance } from "./ExportVideoInstance.js";
2
2
  export class ExportVideoPlugin {
3
- constructor(engine) {
3
+ constructor() {
4
4
  this.id = "export-video";
5
- this._engine = engine;
6
5
  }
7
6
  getPlugin(container) {
8
- return Promise.resolve(new ExportVideoInstance(container, this._engine));
7
+ return Promise.resolve(new ExportVideoInstance(container));
9
8
  }
10
9
  loadOptions() {
11
10
  }
package/browser/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { ExportVideoPlugin } from "./ExportVideoPlugin.js";
2
- export async function loadExportVideoPlugin(engine, refresh = true) {
3
- engine.checkVersion("3.9.0");
4
- await engine.addPlugin(new ExportVideoPlugin(engine), refresh);
1
+ export function loadExportVideoPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { ExportVideoPlugin } = await import("./ExportVideoPlugin.js");
5
+ e.addPlugin(new ExportVideoPlugin());
6
+ });
5
7
  }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExportVideoInstance = void 0;
4
- const engine_1 = require("@tsparticles/engine");
1
+ import { millisecondsToSeconds } from "@tsparticles/engine";
5
2
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
6
3
  "vp9",
7
4
  "vp9.0",
@@ -23,22 +20,24 @@ function getVideoSupportedMimeTypes() {
23
20
  const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
24
21
  videoTypes.forEach(type => {
25
22
  const mimeType = `video/${type}`;
26
- codecs.forEach(codec => [
27
- `${mimeType};codecs=${codec}`,
28
- `${mimeType};codecs=${codec.toUpperCase()}`,
29
- ].forEach(variation => {
30
- if (isSupported(variation)) {
31
- supported.push(variation);
32
- }
33
- }));
23
+ codecs.forEach(codec => {
24
+ [
25
+ `${mimeType};codecs=${codec}`,
26
+ `${mimeType};codecs=${codec.toUpperCase()}`,
27
+ ].forEach(variation => {
28
+ if (isSupported(variation)) {
29
+ supported.push(variation);
30
+ }
31
+ });
32
+ });
34
33
  if (isSupported(mimeType)) {
35
34
  supported.push(mimeType);
36
35
  }
37
36
  });
38
37
  return supported;
39
38
  }
40
- class ExportVideoInstance {
41
- constructor(container, engine) {
39
+ export class ExportVideoInstance {
40
+ constructor(container) {
42
41
  this._supportedTypes = [];
43
42
  this._exportVideo = async (data) => {
44
43
  const element = this._container.canvas.element;
@@ -58,11 +57,10 @@ class ExportVideoInstance {
58
57
  recorder.start();
59
58
  setTimeout(() => {
60
59
  recorder.stop();
61
- }, data.duration ?? defaultDuration * engine_1.millisecondsToSeconds);
60
+ }, data.duration ?? defaultDuration * millisecondsToSeconds);
62
61
  });
63
62
  };
64
63
  this._container = container;
65
- this._engine = engine;
66
64
  this._supportedTypes = getVideoSupportedMimeTypes();
67
65
  }
68
66
  async export(type, data) {
@@ -78,4 +76,3 @@ class ExportVideoInstance {
78
76
  return res;
79
77
  }
80
78
  }
81
- exports.ExportVideoInstance = ExportVideoInstance;
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExportVideoPlugin = void 0;
4
- const ExportVideoInstance_js_1 = require("./ExportVideoInstance.js");
5
- class ExportVideoPlugin {
6
- constructor(engine) {
1
+ import { ExportVideoInstance } from "./ExportVideoInstance.js";
2
+ export class ExportVideoPlugin {
3
+ constructor() {
7
4
  this.id = "export-video";
8
- this._engine = engine;
9
5
  }
10
6
  getPlugin(container) {
11
- return Promise.resolve(new ExportVideoInstance_js_1.ExportVideoInstance(container, this._engine));
7
+ return Promise.resolve(new ExportVideoInstance(container));
12
8
  }
13
9
  loadOptions() {
14
10
  }
@@ -16,4 +12,3 @@ class ExportVideoPlugin {
16
12
  return true;
17
13
  }
18
14
  }
19
- exports.ExportVideoPlugin = ExportVideoPlugin;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/index.js CHANGED
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadExportVideoPlugin = loadExportVideoPlugin;
4
- const ExportVideoPlugin_js_1 = require("./ExportVideoPlugin.js");
5
- async function loadExportVideoPlugin(engine, refresh = true) {
6
- engine.checkVersion("3.9.0");
7
- await engine.addPlugin(new ExportVideoPlugin_js_1.ExportVideoPlugin(engine), refresh);
1
+ export function loadExportVideoPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { ExportVideoPlugin } = await import("./ExportVideoPlugin.js");
5
+ e.addPlugin(new ExportVideoPlugin());
6
+ });
8
7
  }
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.0
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_plugin_export_video"] = this["webpackChunk_tsparticles_plugin_export_video"] || []).push([["dist_browser_ExportVideoPlugin_js"],{
19
+
20
+ /***/ "./dist/browser/ExportVideoInstance.js"
21
+ /*!*********************************************!*\
22
+ !*** ./dist/browser/ExportVideoInstance.js ***!
23
+ \*********************************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExportVideoInstance: () => (/* binding */ ExportVideoInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst videoTypes = [\"webm\", \"ogg\", \"mp4\", \"x-matroska\"],\n codecs = [\"vp9\", \"vp9.0\", \"vp8\", \"vp8.0\", \"avc1\", \"av1\", \"h265\", \"h.265\", \"h264\", \"h.264\", \"opus\", \"pcm\", \"aac\", \"mpeg\", \"mp4a\"];\nfunction getVideoSupportedMimeTypes() {\n const isSupported = type => MediaRecorder.isTypeSupported(type),\n supported = [];\n videoTypes.forEach(type => {\n const mimeType = `video/${type}`;\n codecs.forEach(codec => {\n [`${mimeType};codecs=${codec}`, `${mimeType};codecs=${codec.toUpperCase()}`].forEach(variation => {\n if (isSupported(variation)) {\n supported.push(variation);\n }\n });\n });\n if (isSupported(mimeType)) {\n supported.push(mimeType);\n }\n });\n return supported;\n}\nclass ExportVideoInstance {\n constructor(container) {\n this._supportedTypes = [];\n this._exportVideo = async data => {\n const element = this._container.canvas.element;\n if (!element) {\n return;\n }\n return new Promise(resolve => {\n const stream = element.captureStream(data.fps ?? this._container.actualOptions.fpsLimit),\n firstIndex = 0,\n mimeType = data.mimeType ?? this._supportedTypes[firstIndex],\n recorder = new MediaRecorder(stream, {\n mimeType\n }),\n chunks = [],\n defaultDuration = 5;\n recorder.addEventListener(\"dataavailable\", event => {\n chunks.push(event.data);\n });\n recorder.addEventListener(\"stop\", () => {\n resolve(new Blob(chunks, {\n type: mimeType\n }));\n });\n recorder.start();\n setTimeout(() => {\n recorder.stop();\n }, data.duration ?? defaultDuration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds);\n });\n };\n this._container = container;\n this._supportedTypes = getVideoSupportedMimeTypes();\n }\n async export(type, data) {\n const res = {\n supported: false\n };\n switch (type) {\n case \"video\":\n res.supported = true;\n res.blob = await this._exportVideo(data);\n break;\n }\n return res;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-export-video/./dist/browser/ExportVideoInstance.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/ExportVideoPlugin.js"
31
+ /*!*******************************************!*\
32
+ !*** ./dist/browser/ExportVideoPlugin.js ***!
33
+ \*******************************************/
34
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
+
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExportVideoPlugin: () => (/* binding */ ExportVideoPlugin)\n/* harmony export */ });\n/* harmony import */ var _ExportVideoInstance_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ExportVideoInstance.js */ \"./dist/browser/ExportVideoInstance.js\");\n\nclass ExportVideoPlugin {\n constructor() {\n this.id = \"export-video\";\n }\n getPlugin(container) {\n return Promise.resolve(new _ExportVideoInstance_js__WEBPACK_IMPORTED_MODULE_0__.ExportVideoInstance(container));\n }\n loadOptions() {}\n needsPlugin() {\n return true;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-export-video/./dist/browser/ExportVideoPlugin.js?\n}");
37
+
38
+ /***/ }
39
+
40
+ }]);
@@ -1,4 +1,4 @@
1
- import { millisecondsToSeconds, } from "@tsparticles/engine";
1
+ import { millisecondsToSeconds } from "@tsparticles/engine";
2
2
  const videoTypes = ["webm", "ogg", "mp4", "x-matroska"], codecs = [
3
3
  "vp9",
4
4
  "vp9.0",
@@ -20,14 +20,16 @@ function getVideoSupportedMimeTypes() {
20
20
  const isSupported = (type) => MediaRecorder.isTypeSupported(type), supported = [];
21
21
  videoTypes.forEach(type => {
22
22
  const mimeType = `video/${type}`;
23
- codecs.forEach(codec => [
24
- `${mimeType};codecs=${codec}`,
25
- `${mimeType};codecs=${codec.toUpperCase()}`,
26
- ].forEach(variation => {
27
- if (isSupported(variation)) {
28
- supported.push(variation);
29
- }
30
- }));
23
+ codecs.forEach(codec => {
24
+ [
25
+ `${mimeType};codecs=${codec}`,
26
+ `${mimeType};codecs=${codec.toUpperCase()}`,
27
+ ].forEach(variation => {
28
+ if (isSupported(variation)) {
29
+ supported.push(variation);
30
+ }
31
+ });
32
+ });
31
33
  if (isSupported(mimeType)) {
32
34
  supported.push(mimeType);
33
35
  }
@@ -35,7 +37,7 @@ function getVideoSupportedMimeTypes() {
35
37
  return supported;
36
38
  }
37
39
  export class ExportVideoInstance {
38
- constructor(container, engine) {
40
+ constructor(container) {
39
41
  this._supportedTypes = [];
40
42
  this._exportVideo = async (data) => {
41
43
  const element = this._container.canvas.element;
@@ -59,7 +61,6 @@ export class ExportVideoInstance {
59
61
  });
60
62
  };
61
63
  this._container = container;
62
- this._engine = engine;
63
64
  this._supportedTypes = getVideoSupportedMimeTypes();
64
65
  }
65
66
  async export(type, data) {
@@ -1,11 +1,10 @@
1
1
  import { ExportVideoInstance } from "./ExportVideoInstance.js";
2
2
  export class ExportVideoPlugin {
3
- constructor(engine) {
3
+ constructor() {
4
4
  this.id = "export-video";
5
- this._engine = engine;
6
5
  }
7
6
  getPlugin(container) {
8
- return Promise.resolve(new ExportVideoInstance(container, this._engine));
7
+ return Promise.resolve(new ExportVideoInstance(container));
9
8
  }
10
9
  loadOptions() {
11
10
  }
package/esm/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { ExportVideoPlugin } from "./ExportVideoPlugin.js";
2
- export async function loadExportVideoPlugin(engine, refresh = true) {
3
- engine.checkVersion("3.9.0");
4
- await engine.addPlugin(new ExportVideoPlugin(engine), refresh);
1
+ export function loadExportVideoPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { ExportVideoPlugin } = await import("./ExportVideoPlugin.js");
5
+ e.addPlugin(new ExportVideoPlugin());
6
+ });
5
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-export-video",
3
- "version": "3.9.0",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "tsParticles export video plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,9 +100,10 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "3.9.0"
103
+ "@tsparticles/engine": "4.0.0-alpha.0"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"
107
- }
107
+ },
108
+ "type": "module"
108
109
  }