@loaders.gl/video 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
Files changed (59) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dist.min.js +23 -21
  3. package/dist/es5/bundle.js +6 -0
  4. package/dist/es5/bundle.js.map +1 -0
  5. package/dist/es5/gif-builder.js +200 -0
  6. package/dist/es5/gif-builder.js.map +1 -0
  7. package/dist/es5/index.js +21 -0
  8. package/dist/es5/index.js.map +1 -0
  9. package/dist/es5/lib/gifshot/gifshot-loader.js +67 -0
  10. package/dist/es5/lib/gifshot/gifshot-loader.js.map +1 -0
  11. package/dist/es5/lib/gifshot/gifshot.js +1924 -0
  12. package/dist/es5/lib/gifshot/gifshot.js.map +1 -0
  13. package/dist/es5/lib/parsers/parse-video.js +31 -0
  14. package/dist/es5/lib/parsers/parse-video.js.map +1 -0
  15. package/dist/es5/lib/utils/assert.js +12 -0
  16. package/dist/es5/lib/utils/assert.js.map +1 -0
  17. package/dist/es5/video-loader.js +28 -0
  18. package/dist/es5/video-loader.js.map +1 -0
  19. package/dist/esm/bundle.js +4 -0
  20. package/dist/esm/bundle.js.map +1 -0
  21. package/dist/esm/gif-builder.js +106 -0
  22. package/dist/esm/gif-builder.js.map +1 -0
  23. package/dist/esm/index.js +3 -0
  24. package/dist/esm/index.js.map +1 -0
  25. package/dist/esm/lib/gifshot/gifshot-loader.js +17 -0
  26. package/dist/esm/lib/gifshot/gifshot-loader.js.map +1 -0
  27. package/dist/esm/lib/gifshot/gifshot.js +1915 -0
  28. package/dist/esm/lib/gifshot/gifshot.js.map +1 -0
  29. package/dist/esm/lib/parsers/parse-video.js +7 -0
  30. package/dist/esm/lib/parsers/parse-video.js.map +1 -0
  31. package/dist/esm/lib/utils/assert.js +6 -0
  32. package/dist/esm/lib/utils/assert.js.map +1 -0
  33. package/dist/esm/video-loader.js +19 -0
  34. package/dist/esm/video-loader.js.map +1 -0
  35. package/dist/gif-builder.js +136 -114
  36. package/dist/index.js +10 -3
  37. package/dist/lib/gifshot/gifshot-loader.js +18 -15
  38. package/dist/lib/gifshot/gifshot.d.ts.map +1 -1
  39. package/dist/lib/gifshot/gifshot.js +2322 -2089
  40. package/dist/lib/parsers/parse-video.js +12 -6
  41. package/dist/lib/utils/assert.js +8 -5
  42. package/dist/video-loader.d.ts +1 -1
  43. package/dist/video-loader.d.ts.map +1 -1
  44. package/dist/video-loader.js +22 -14
  45. package/package.json +6 -6
  46. package/src/lib/gifshot/gifshot.ts +33 -54
  47. package/dist/bundle.js.map +0 -1
  48. package/dist/gif-builder.js.map +0 -1
  49. package/dist/index.js.map +0 -1
  50. package/dist/lib/gifshot/gifshot-loader.js.map +0 -1
  51. package/dist/lib/gifshot/gifshot.js.map +0 -1
  52. package/dist/lib/parsers/parse-video.js.map +0 -1
  53. package/dist/lib/utils/assert.js.map +0 -1
  54. package/dist/lib/utils/globals.d.ts +0 -10
  55. package/dist/lib/utils/globals.d.ts.map +0 -1
  56. package/dist/lib/utils/globals.js +0 -16
  57. package/dist/lib/utils/globals.js.map +0 -1
  58. package/dist/video-loader.js.map +0 -1
  59. package/src/lib/utils/globals.ts +0 -25
@@ -1,120 +1,142 @@
1
- import { assert } from './lib/utils/assert';
2
- import gifshot from './lib/gifshot/gifshot';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // A GIFBuilder based on the gifshot module
7
+ // @ts-nocheck
8
+ const assert_1 = require("./lib/utils/assert");
9
+ const gifshot_1 = __importDefault(require("./lib/gifshot/gifshot")); // TODO - load dynamically to avoid bloating
10
+ // These are gifshot module options
3
11
  const GIF_BUILDER_OPTIONS = {
4
- source: 'images',
5
- width: 200,
6
- height: 200,
7
- crossOrigin: 'Anonymous',
8
- progressCallback: captureProgress => {},
9
- completeCallback: () => {},
10
- numWorkers: 2,
11
- sampleInterval: 10,
12
- interval: 0.1,
13
- offset: null,
14
- numFrames: 10,
15
- frameDuration: 1,
16
- filter: '',
17
- waterMark: null,
18
- waterMarkHeight: null,
19
- waterMarkWidth: null,
20
- waterMarkXCoordinate: 1,
21
- waterMarkYCoordinate: 1,
22
- text: '',
23
- showFrameText: true,
24
- fontWeight: 'normal',
25
- fontSize: '16px',
26
- minFontSize: '10px',
27
- resizeFont: false,
28
- fontFamily: 'sans-serif',
29
- fontColor: '#ffffff',
30
- textAlign: 'center',
31
- textBaseline: 'bottom',
32
- textXCoordinate: null,
33
- textYCoordinate: null,
34
- webcamVideoElement: null,
35
- keepCameraOn: false,
36
- cameraStream: null,
37
- saveRenderingContexts: false,
38
- savedRenderingContexts: []
12
+ source: 'images',
13
+ width: 200,
14
+ height: 200,
15
+ crossOrigin: 'Anonymous',
16
+ // CALLBACKS
17
+ progressCallback: (captureProgress) => { },
18
+ completeCallback: () => { },
19
+ // QUALITY SETTINGS
20
+ numWorkers: 2,
21
+ sampleInterval: 10,
22
+ interval: 0.1,
23
+ offset: null,
24
+ numFrames: 10,
25
+ frameDuration: 1,
26
+ // CSS FILTER OPTIONS
27
+ filter: '',
28
+ // WATERMARK OPTIONS
29
+ waterMark: null,
30
+ waterMarkHeight: null,
31
+ waterMarkWidth: null,
32
+ waterMarkXCoordinate: 1,
33
+ waterMarkYCoordinate: 1,
34
+ // TEXT OPTIONS
35
+ text: '',
36
+ showFrameText: true,
37
+ fontWeight: 'normal',
38
+ fontSize: '16px',
39
+ minFontSize: '10px',
40
+ resizeFont: false,
41
+ fontFamily: 'sans-serif',
42
+ fontColor: '#ffffff',
43
+ textAlign: 'center',
44
+ textBaseline: 'bottom',
45
+ textXCoordinate: null,
46
+ textYCoordinate: null,
47
+ // ADVANCED OPTIONS
48
+ // WEBCAM CAPTURE OPTIONS
49
+ webcamVideoElement: null,
50
+ keepCameraOn: false,
51
+ cameraStream: null,
52
+ // CANVAS OPTIMIZATION OPTIONS
53
+ saveRenderingContexts: false,
54
+ savedRenderingContexts: [] // Array of canvas image data
39
55
  };
40
- export default class GIFBuilder {
41
- static get properties() {
42
- return {
43
- id: 'gif',
44
- name: 'GIF',
45
- extensions: ['gif'],
46
- mimeTypes: ['image/gif'],
47
- builder: GIFBuilder,
48
- options: GIF_BUILDER_OPTIONS
49
- };
50
- }
51
-
52
- constructor(options) {
53
- this.options = { ...options
54
- };
55
- this.source = options.source;
56
- delete options.source;
57
- this.files = [];
58
- this.gifshot = gifshot;
59
- }
60
-
61
- async initialize(options) {}
62
-
63
- async add(file) {
64
- await this.initialize();
65
- this.files.push(file);
66
- }
67
-
68
- async build() {
69
- await this.initialize();
70
-
71
- this._cleanOptions(this.options);
72
-
73
- switch (this.source) {
74
- case 'images':
75
- this.options.images = this.files;
76
- break;
77
-
78
- case 'video':
79
- this.options.video = this.files;
80
- break;
81
-
82
- case 'webcam':
83
- assert(this.files.length === 0);
84
- break;
85
-
86
- default:
87
- throw new Error('GIFBuilder: invalid source');
56
+ class GIFBuilder {
57
+ static get properties() {
58
+ return {
59
+ id: 'gif',
60
+ name: 'GIF',
61
+ extensions: ['gif'],
62
+ mimeTypes: ['image/gif'],
63
+ builder: GIFBuilder,
64
+ options: GIF_BUILDER_OPTIONS
65
+ };
66
+ }
67
+ constructor(options) {
68
+ this.options = { ...options };
69
+ this.source = options.source;
70
+ delete options.source;
71
+ // Allow files to be added
72
+ this.files = [];
73
+ // Expose the gifshot module so that the full gifshot API is available to apps (Experimental)
74
+ this.gifshot = gifshot_1.default;
75
+ }
76
+ async initialize(options) {
77
+ // Expose the gifshot module so that the full gifshot API is available to apps (Experimental)
78
+ // this.gifshot = await loadGifshotModule(options);
79
+ }
80
+ async add(file) {
81
+ await this.initialize();
82
+ this.files.push(file);
83
+ }
84
+ async build() {
85
+ await this.initialize();
86
+ this._cleanOptions(this.options);
87
+ switch (this.source) {
88
+ case 'images':
89
+ this.options.images = this.files;
90
+ break;
91
+ case 'video':
92
+ this.options.video = this.files;
93
+ break;
94
+ case 'webcam':
95
+ (0, assert_1.assert)(this.files.length === 0);
96
+ break;
97
+ default:
98
+ throw new Error('GIFBuilder: invalid source');
99
+ }
100
+ return await this._createGIF();
101
+ }
102
+ // PRIVATE
103
+ async _createGIF() {
104
+ return new Promise((resolve, reject) => {
105
+ this.gifshot.createGIF(this.options, (result) => {
106
+ // callback object properties
107
+ // --------------------------
108
+ // image - Base 64 image
109
+ // cameraStream - The webRTC MediaStream object
110
+ // error - Boolean that determines if an error occurred
111
+ // errorCode - Helpful error label
112
+ // errorMsg - Helpful error message
113
+ // savedRenderingContexts - An array of canvas image data (will only be set if the saveRenderingContexts option was used)
114
+ if (result.error) {
115
+ reject(result.errorMsg);
116
+ return;
117
+ }
118
+ // image - Base 64 image
119
+ resolve(result.image);
120
+ // var image = obj.image,
121
+ // animatedImage = document.createElement('img');
122
+ // animatedImage.src = image;
123
+ // document.body.appendChild(animatedImage);
124
+ });
125
+ });
88
126
  }
89
-
90
- return await this._createGIF();
91
- }
92
-
93
- async _createGIF() {
94
- return new Promise((resolve, reject) => {
95
- this.gifshot.createGIF(this.options, result => {
96
- if (result.error) {
97
- reject(result.errorMsg);
98
- return;
127
+ // Remove some gifshot options
128
+ _cleanOptions(options) {
129
+ if (options.video || options.images || options.gifWidth || options.gifHeight) {
130
+ console.warn('GIFBuilder: ignoring options'); // eslint-disable-line
99
131
  }
100
-
101
- resolve(result.image);
102
- });
103
- });
104
- }
105
-
106
- _cleanOptions(options) {
107
- if (options.video || options.images || options.gifWidth || options.gifHeight) {
108
- console.warn('GIFBuilder: ignoring options');
132
+ // We control these through options.source instead
133
+ delete options.video;
134
+ delete options.images;
135
+ // Use width/height props (to standardize across builders)
136
+ options.gifWidth = options.width;
137
+ options.gifHeight = options.height;
138
+ delete options.width;
139
+ delete options.height;
109
140
  }
110
-
111
- delete options.video;
112
- delete options.images;
113
- options.gifWidth = options.width;
114
- options.gifHeight = options.height;
115
- delete options.width;
116
- delete options.height;
117
- }
118
-
119
141
  }
120
- //# sourceMappingURL=gif-builder.js.map
142
+ exports.default = GIFBuilder;
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
- export { VideoLoader } from './video-loader';
2
- export { default as GIFBuilder } from './gif-builder';
3
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GIFBuilder = exports.VideoLoader = void 0;
7
+ var video_loader_1 = require("./video-loader");
8
+ Object.defineProperty(exports, "VideoLoader", { enumerable: true, get: function () { return video_loader_1.VideoLoader; } });
9
+ var gif_builder_1 = require("./gif-builder");
10
+ Object.defineProperty(exports, "GIFBuilder", { enumerable: true, get: function () { return __importDefault(gif_builder_1).default; } });
@@ -1,19 +1,22 @@
1
- import { loadLibrary } from '@loaders.gl/worker-utils';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadGifshotModule = void 0;
4
+ // @ts-nocheck
5
+ const worker_utils_1 = require("@loaders.gl/worker-utils");
2
6
  let loadGifshotPromise;
3
- export async function loadGifshotModule(options = {}) {
4
- const modules = options.modules || {};
5
-
6
- if (modules.gifshot) {
7
- return modules.gifshot;
8
- }
9
-
10
- loadGifshotPromise = loadGifshotPromise || loadGifshot(options);
11
- return await loadGifshotPromise;
7
+ async function loadGifshotModule(options = {}) {
8
+ const modules = options.modules || {};
9
+ if (modules.gifshot) {
10
+ return modules.gifshot;
11
+ }
12
+ loadGifshotPromise = loadGifshotPromise || loadGifshot(options);
13
+ return await loadGifshotPromise;
12
14
  }
13
-
15
+ exports.loadGifshotModule = loadGifshotModule;
14
16
  async function loadGifshot(options) {
15
- options.libraryPath = options.libraryPath || 'libs/';
16
- const gifshot = await loadLibrary('gifshot.js', 'gifshot', options);
17
- return gifshot || globalThis.gifshot;
17
+ options.libraryPath = options.libraryPath || 'libs/';
18
+ const gifshot = await (0, worker_utils_1.loadLibrary)('gifshot.js', 'gifshot', options);
19
+ // Depends on how import happened...
20
+ // @ts-ignore TS2339: Property does not exist on type
21
+ return gifshot || globalThis.gifshot;
18
22
  }
19
- //# sourceMappingURL=gifshot-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gifshot.d.ts","sourceRoot":"","sources":["../../../src/lib/gifshot/gifshot.ts"],"names":[],"mappings":"AAwYA,iBAAS,WAAW,YAEnB;AAQD,iBAAS,oBAAoB,YAE5B;AASD,iBAAS,aAAa,YAKrB;AASD,iBAAS,2BAA2B,CAAC,MAAM,KAAA,WAmB1C;AA8rDD,iBAAS,kBAAkB,CAAC,OAAO,KAAA,QAGlC;AA0JD,iBAAS,SAAS,CAAC,WAAW,KAAA,EAAE,QAAQ,KAAA,QAwCvC;AAQD,iBAAS,YAAY,CAAC,WAAW,KAAA,EAAE,QAAQ,KAAA,QAc1C;AASD,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYR,CAAC;AAEF,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"gifshot.d.ts","sourceRoot":"","sources":["../../../src/lib/gifshot/gifshot.ts"],"names":[],"mappings":"AAqYA,iBAAS,WAAW,YAEnB;AAOD,iBAAS,oBAAoB,YAE5B;AAQD,iBAAS,aAAa,YAKrB;AAQD,iBAAS,2BAA2B,CAAC,MAAM,KAAA,WAmB1C;AAqrDD,iBAAS,kBAAkB,CAAC,OAAO,KAAA,QAGlC;AAsJD,iBAAS,SAAS,CAAC,WAAW,KAAA,EAAE,QAAQ,KAAA,QAwCvC;AAOD,iBAAS,YAAY,CAAC,WAAW,KAAA,EAAE,QAAQ,KAAA,QAc1C;AAQD,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYR,CAAC;AAEF,eAAe,GAAG,CAAC"}