@loaders.gl/video 4.0.0-alpha.1 → 4.0.0-alpha.11
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +2147 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/gif-builder.js +200 -0
- package/dist/es5/gif-builder.js.map +1 -0
- package/dist/es5/index.js +21 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/gifshot/gifshot-loader.js +67 -0
- package/dist/es5/lib/gifshot/gifshot-loader.js.map +1 -0
- package/dist/es5/lib/gifshot/gifshot.js +1924 -0
- package/dist/es5/lib/gifshot/gifshot.js.map +1 -0
- package/dist/es5/lib/parsers/parse-video.js +31 -0
- package/dist/es5/lib/parsers/parse-video.js.map +1 -0
- package/dist/es5/lib/utils/assert.js +12 -0
- package/dist/es5/lib/utils/assert.js.map +1 -0
- package/dist/es5/video-loader.js +28 -0
- package/dist/es5/video-loader.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/gif-builder.js +106 -0
- package/dist/esm/gif-builder.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/{src → dist/esm}/lib/gifshot/gifshot-loader.js +4 -8
- package/dist/esm/lib/gifshot/gifshot-loader.js.map +1 -0
- package/dist/esm/lib/gifshot/gifshot.js +1915 -0
- package/dist/esm/lib/gifshot/gifshot.js.map +1 -0
- package/dist/esm/lib/parsers/parse-video.js +7 -0
- package/dist/esm/lib/parsers/parse-video.js.map +1 -0
- package/{src → dist/esm}/lib/utils/assert.js +1 -0
- package/dist/esm/lib/utils/assert.js.map +1 -0
- package/dist/esm/video-loader.js +19 -0
- package/dist/esm/video-loader.js.map +1 -0
- package/dist/gif-builder.d.ts +53 -0
- package/dist/gif-builder.d.ts.map +1 -0
- package/dist/gif-builder.js +136 -114
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -3
- package/dist/lib/gifshot/gifshot-loader.d.ts +2 -0
- package/dist/lib/gifshot/gifshot-loader.d.ts.map +1 -0
- package/dist/lib/gifshot/gifshot-loader.js +18 -15
- package/dist/lib/gifshot/gifshot.d.ts +72 -0
- package/dist/lib/gifshot/gifshot.d.ts.map +1 -0
- package/dist/lib/gifshot/gifshot.js +2417 -0
- package/dist/lib/parsers/parse-video.d.ts +2 -0
- package/dist/lib/parsers/parse-video.d.ts.map +1 -0
- package/dist/lib/parsers/parse-video.js +12 -6
- package/dist/lib/utils/assert.d.ts +2 -0
- package/dist/lib/utils/assert.d.ts.map +1 -0
- package/dist/lib/utils/assert.js +8 -5
- package/dist/video-loader.d.ts +17 -0
- package/dist/video-loader.d.ts.map +1 -0
- package/dist/video-loader.js +22 -14
- package/package.json +8 -8
- package/src/{gif-builder.js → gif-builder.ts} +6 -6
- package/src/lib/gifshot/gifshot.ts +2394 -0
- package/dist/bundle.js.map +0 -1
- package/dist/gif-builder.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/gifshot/gifshot-loader.js.map +0 -1
- package/dist/lib/parsers/parse-video.js.map +0 -1
- package/dist/lib/utils/assert.js.map +0 -1
- package/dist/lib/utils/globals.js +0 -16
- package/dist/lib/utils/globals.js.map +0 -1
- package/dist/libs/gifshot.js +0 -2826
- package/dist/video-loader.js.map +0 -1
- package/src/lib/utils/globals.js +0 -25
- package/src/libs/gifshot.js +0 -2826
package/dist/gif-builder.js
CHANGED
|
@@ -1,120 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
142
|
+
exports.default = GIFBuilder;
|
package/dist/index.d.ts
ADDED
|
@@ -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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 @@
|
|
|
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"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
@@ -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":"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"}
|