@loaders.gl/video 3.1.0-alpha.4 → 3.1.0-beta.3

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 (65) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2145 -0
  4. package/dist/es5/bundle.js +1 -1
  5. package/dist/es5/bundle.js.map +1 -1
  6. package/dist/es5/gif-builder.js +76 -187
  7. package/dist/es5/gif-builder.js.map +1 -1
  8. package/dist/es5/index.js +2 -2
  9. package/dist/es5/lib/gifshot/gifshot-loader.js +12 -71
  10. package/dist/es5/lib/gifshot/gifshot-loader.js.map +1 -1
  11. package/dist/es5/lib/gifshot/gifshot.js +2191 -0
  12. package/dist/es5/lib/gifshot/gifshot.js.map +1 -0
  13. package/dist/es5/lib/parsers/parse-video.js +5 -30
  14. package/dist/es5/lib/parsers/parse-video.js.map +1 -1
  15. package/dist/es5/lib/utils/assert.js.map +1 -1
  16. package/dist/es5/lib/utils/globals.js +9 -14
  17. package/dist/es5/lib/utils/globals.js.map +1 -1
  18. package/dist/es5/video-loader.js +6 -6
  19. package/dist/es5/video-loader.js.map +1 -1
  20. package/dist/esm/gif-builder.js +1 -1
  21. package/dist/esm/gif-builder.js.map +1 -1
  22. package/dist/esm/lib/gifshot/gifshot-loader.js.map +1 -1
  23. package/dist/esm/lib/gifshot/gifshot.js +2184 -0
  24. package/dist/esm/lib/gifshot/gifshot.js.map +1 -0
  25. package/dist/esm/lib/utils/assert.js.map +1 -1
  26. package/dist/esm/lib/utils/globals.js +1 -1
  27. package/dist/esm/lib/utils/globals.js.map +1 -1
  28. package/dist/esm/video-loader.js +1 -1
  29. package/dist/esm/video-loader.js.map +1 -1
  30. package/dist/gif-builder.d.ts +53 -0
  31. package/dist/gif-builder.d.ts.map +1 -0
  32. package/dist/gif-builder.js +142 -0
  33. package/dist/index.d.ts +3 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +10 -0
  36. package/dist/lib/gifshot/gifshot-loader.d.ts +2 -0
  37. package/dist/lib/gifshot/gifshot-loader.d.ts.map +1 -0
  38. package/dist/lib/gifshot/gifshot-loader.js +22 -0
  39. package/dist/lib/gifshot/gifshot.d.ts +72 -0
  40. package/dist/lib/gifshot/gifshot.d.ts.map +1 -0
  41. package/dist/lib/gifshot/gifshot.js +2437 -0
  42. package/dist/lib/parsers/parse-video.d.ts +2 -0
  43. package/dist/lib/parsers/parse-video.d.ts.map +1 -0
  44. package/dist/lib/parsers/parse-video.js +13 -0
  45. package/dist/lib/utils/assert.d.ts +2 -0
  46. package/dist/lib/utils/assert.d.ts.map +1 -0
  47. package/dist/lib/utils/assert.js +9 -0
  48. package/dist/lib/utils/globals.d.ts +10 -0
  49. package/dist/lib/utils/globals.d.ts.map +1 -0
  50. package/dist/lib/utils/globals.js +25 -0
  51. package/dist/video-loader.d.ts +17 -0
  52. package/dist/video-loader.d.ts.map +1 -0
  53. package/dist/video-loader.js +27 -0
  54. package/package.json +6 -7
  55. package/src/{gif-builder.js → gif-builder.ts} +7 -6
  56. package/src/lib/gifshot/{gifshot-loader.js → gifshot-loader.ts} +1 -0
  57. package/src/lib/gifshot/gifshot.ts +2415 -0
  58. package/src/lib/utils/assert.ts +5 -0
  59. package/src/lib/utils/{globals.js → globals.ts} +1 -1
  60. package/dist/dist.min.js +0 -2
  61. package/dist/dist.min.js.map +0 -1
  62. package/dist/es5/libs/gifshot.js +0 -2826
  63. package/dist/esm/libs/gifshot.js +0 -2826
  64. package/src/lib/utils/assert.js +0 -5
  65. package/src/libs/gifshot.js +0 -2826
@@ -0,0 +1,142 @@
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
11
+ const GIF_BUILDER_OPTIONS = {
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
55
+ };
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
+ });
126
+ }
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
131
+ }
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;
140
+ }
141
+ }
142
+ exports.default = GIFBuilder;
@@ -0,0 +1,3 @@
1
+ export { VideoLoader } from './video-loader';
2
+ export { default as GIFBuilder } from './gif-builder';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
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; } });
@@ -0,0 +1,2 @@
1
+ export declare function loadGifshotModule(options?: {}): Promise<any>;
2
+ //# sourceMappingURL=gifshot-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gifshot-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/gifshot/gifshot-loader.ts"],"names":[],"mappings":"AAKA,wBAAsB,iBAAiB,CAAC,OAAO,KAAK,gBAOnD"}
@@ -0,0 +1,22 @@
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");
6
+ let 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;
14
+ }
15
+ exports.loadGifshotModule = loadGifshotModule;
16
+ async function loadGifshot(options) {
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;
22
+ }
@@ -0,0 +1,72 @@
1
+ declare function isSupported(): boolean;
2
+ declare function isWebCamGIFSupported(): boolean;
3
+ declare function isSupported$1(): boolean;
4
+ declare function isExistingVideoGIFSupported(codecs: any): boolean;
5
+ declare function stopVideoStreaming(options: any): void;
6
+ declare function createGIF(userOptions: any, callback: any): void;
7
+ declare function takeSnapShot(userOptions: any, callback: any): void;
8
+ declare const API: {
9
+ utils: Readonly<{
10
+ default: any;
11
+ }>;
12
+ error: Readonly<{
13
+ default: {
14
+ validate: (skipObj: any) => {};
15
+ isValid: (skipObj: any) => boolean;
16
+ validators: {
17
+ condition: any;
18
+ errorCode: string;
19
+ errorMsg: string;
20
+ }[];
21
+ messages: {
22
+ videoCodecs: {
23
+ errorCode: string;
24
+ errorMsg: string;
25
+ };
26
+ };
27
+ };
28
+ }>;
29
+ defaultOptions: Readonly<{
30
+ default: {
31
+ sampleInterval: number;
32
+ numWorkers: number;
33
+ filter: string;
34
+ gifWidth: number;
35
+ gifHeight: number;
36
+ interval: number;
37
+ numFrames: number;
38
+ frameDuration: number;
39
+ keepCameraOn: boolean;
40
+ images: never[];
41
+ video: null;
42
+ webcamVideoElement: null;
43
+ cameraStream: null;
44
+ text: string;
45
+ fontWeight: string;
46
+ fontSize: string;
47
+ minFontSize: string;
48
+ resizeFont: boolean;
49
+ fontFamily: string;
50
+ fontColor: string;
51
+ textAlign: string;
52
+ textBaseline: string;
53
+ textXCoordinate: null;
54
+ textYCoordinate: null;
55
+ progressCallback: () => void;
56
+ completeCallback: () => void;
57
+ saveRenderingContexts: boolean;
58
+ savedRenderingContexts: never[];
59
+ crossOrigin: string;
60
+ };
61
+ }>;
62
+ createGIF: typeof createGIF;
63
+ takeSnapShot: typeof takeSnapShot;
64
+ stopVideoStreaming: typeof stopVideoStreaming;
65
+ isSupported: typeof isSupported;
66
+ isWebCamGIFSupported: typeof isWebCamGIFSupported;
67
+ isExistingVideoGIFSupported: typeof isExistingVideoGIFSupported;
68
+ isExistingImagesGIFSupported: typeof isSupported$1;
69
+ VERSION: string;
70
+ };
71
+ export default API;
72
+ //# sourceMappingURL=gifshot.d.ts.map
@@ -0,0 +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"}