@remotion/gif 3.3.32 → 3.3.33
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/Gif.d.ts +1 -0
- package/dist/gifuct/deinterlace.d.ts +4 -0
- package/dist/gifuct/deinterlace.js +26 -0
- package/dist/gifuct/index.d.ts +8 -0
- package/dist/gifuct/index.js +60 -0
- package/dist/gifuct/lzw.d.ts +5 -0
- package/dist/gifuct/lzw.js +119 -0
- package/dist/gifuct/types.d.ts +96 -0
- package/dist/gifuct/types.js +2 -0
- package/dist/parse-generate.d.ts +2 -2
- package/dist/parse-generate.js +25 -8
- package/dist/parser/decompress-frames.d.ts +1 -1
- package/dist/parser/decompress-frames.js +2 -2
- package/dist/ts-schema-binary-parser/index.d.ts +4 -0
- package/dist/ts-schema-binary-parser/index.js +46 -0
- package/dist/ts-schema-binary-parser/types.d.ts +7 -0
- package/dist/ts-schema-binary-parser/types.js +2 -0
- package/dist/worker/source.d.ts +1 -1
- package/dist/worker/source.js +1 -1
- package/package.json +4 -4
package/dist/Gif.d.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deinterlace function from https://github.com/shachaf/jsgif
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deinterlace = void 0;
|
|
7
|
+
const deinterlace = (pixels, width) => {
|
|
8
|
+
const newPixels = new Array(pixels.length);
|
|
9
|
+
const rows = pixels.length / width;
|
|
10
|
+
const cpRow = function (toRow, _fromRow) {
|
|
11
|
+
const fromPixels = pixels.slice(_fromRow * width, (_fromRow + 1) * width);
|
|
12
|
+
newPixels.splice(...[toRow * width, width].concat(fromPixels));
|
|
13
|
+
};
|
|
14
|
+
// See appendix E.
|
|
15
|
+
const offsets = [0, 4, 2, 1];
|
|
16
|
+
const steps = [8, 8, 4, 2];
|
|
17
|
+
let fromRow = 0;
|
|
18
|
+
for (let pass = 0; pass < 4; pass++) {
|
|
19
|
+
for (let toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
|
|
20
|
+
cpRow(toRow, fromRow);
|
|
21
|
+
fromRow++;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return newPixels;
|
|
25
|
+
};
|
|
26
|
+
exports.deinterlace = deinterlace;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Frame, ParsedFrameWithoutPatch, ParsedGif } from './types';
|
|
2
|
+
export declare const parseGIF: (arrayBuffer: ArrayBuffer) => any;
|
|
3
|
+
export declare const decompressFrame: (frame: Frame, gct: [
|
|
4
|
+
number,
|
|
5
|
+
number,
|
|
6
|
+
number
|
|
7
|
+
][]) => ParsedFrameWithoutPatch | undefined;
|
|
8
|
+
export declare const decompressFrames: (parsedGif: ParsedGif) => (ParsedFrameWithoutPatch | undefined)[];
|
|
@@ -0,0 +1,60 @@
|
|
|
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.decompressFrames = exports.decompressFrame = exports.parseGIF = void 0;
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
const js_binary_schema_parser_1 = require("js-binary-schema-parser");
|
|
9
|
+
// @ts-expect-error
|
|
10
|
+
const uint8_1 = require("js-binary-schema-parser/lib/parsers/uint8");
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
const gif_1 = __importDefault(require("js-binary-schema-parser/lib/schemas/gif"));
|
|
13
|
+
const deinterlace_1 = require("./deinterlace");
|
|
14
|
+
const lzw_1 = require("./lzw");
|
|
15
|
+
const parseGIF = (arrayBuffer) => {
|
|
16
|
+
const byteData = new Uint8Array(arrayBuffer);
|
|
17
|
+
return (0, js_binary_schema_parser_1.parse)((0, uint8_1.buildStream)(byteData), gif_1.default);
|
|
18
|
+
};
|
|
19
|
+
exports.parseGIF = parseGIF;
|
|
20
|
+
const decompressFrame = (frame, gct) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
if (!frame.image) {
|
|
23
|
+
console.warn('gif frame does not have associated image.');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const { image } = frame;
|
|
27
|
+
// get the number of pixels
|
|
28
|
+
const totalPixels = image.descriptor.width * image.descriptor.height;
|
|
29
|
+
// do lzw decompression
|
|
30
|
+
let pixels = (0, lzw_1.lzw)(image.data.minCodeSize, image.data.blocks, totalPixels);
|
|
31
|
+
// deal with interlacing if necessary
|
|
32
|
+
if ((_a = image.descriptor.lct) === null || _a === void 0 ? void 0 : _a.interlaced) {
|
|
33
|
+
pixels = (0, deinterlace_1.deinterlace)(pixels, image.descriptor.width);
|
|
34
|
+
}
|
|
35
|
+
const resultImage = {
|
|
36
|
+
pixels,
|
|
37
|
+
dims: {
|
|
38
|
+
top: frame.image.descriptor.top,
|
|
39
|
+
left: frame.image.descriptor.left,
|
|
40
|
+
width: frame.image.descriptor.width,
|
|
41
|
+
height: frame.image.descriptor.height,
|
|
42
|
+
},
|
|
43
|
+
colorTable: ((_b = image.descriptor.lct) === null || _b === void 0 ? void 0 : _b.exists)
|
|
44
|
+
? image.lct
|
|
45
|
+
: gct,
|
|
46
|
+
delay: (frame.gce.delay || 10) * 10,
|
|
47
|
+
disposalType: frame.gce.extras.disposal,
|
|
48
|
+
transparentIndex: frame.gce.extras.transparentColorGiven
|
|
49
|
+
? frame.gce.transparentColorIndex
|
|
50
|
+
: -1,
|
|
51
|
+
};
|
|
52
|
+
return resultImage;
|
|
53
|
+
};
|
|
54
|
+
exports.decompressFrame = decompressFrame;
|
|
55
|
+
const decompressFrames = (parsedGif) => {
|
|
56
|
+
return parsedGif.frames
|
|
57
|
+
.filter((f) => !('application' in f))
|
|
58
|
+
.map((f) => (0, exports.decompressFrame)(f, parsedGif.gct));
|
|
59
|
+
};
|
|
60
|
+
exports.decompressFrames = decompressFrames;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-multi-assign */
|
|
3
|
+
/* eslint-disable no-redeclare */
|
|
4
|
+
/* eslint-disable no-bitwise */
|
|
5
|
+
/* eslint-disable no-var */
|
|
6
|
+
/**
|
|
7
|
+
* javascript port of java LZW decompression
|
|
8
|
+
* Original java author url: https://gist.github.com/devunwired/4479231
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.lzw = void 0;
|
|
12
|
+
const lzw = (minCodeSize, data, pixelCount) => {
|
|
13
|
+
const MAX_STACK_SIZE = 4096;
|
|
14
|
+
const nullCode = -1;
|
|
15
|
+
const npix = pixelCount;
|
|
16
|
+
let available;
|
|
17
|
+
let code_mask;
|
|
18
|
+
let code_size;
|
|
19
|
+
let in_code;
|
|
20
|
+
let old_code;
|
|
21
|
+
var bits;
|
|
22
|
+
let code;
|
|
23
|
+
let i;
|
|
24
|
+
var datum;
|
|
25
|
+
var first;
|
|
26
|
+
var top;
|
|
27
|
+
var bi;
|
|
28
|
+
var pi;
|
|
29
|
+
const dstPixels = new Array(pixelCount);
|
|
30
|
+
const prefix = new Array(MAX_STACK_SIZE);
|
|
31
|
+
const suffix = new Array(MAX_STACK_SIZE);
|
|
32
|
+
const pixelStack = new Array(MAX_STACK_SIZE + 1);
|
|
33
|
+
// Initialize GIF data stream decoder.
|
|
34
|
+
const data_size = minCodeSize;
|
|
35
|
+
const clear = 1 << data_size;
|
|
36
|
+
const end_of_information = clear + 1;
|
|
37
|
+
available = clear + 2;
|
|
38
|
+
old_code = nullCode;
|
|
39
|
+
code_size = data_size + 1;
|
|
40
|
+
code_mask = (1 << code_size) - 1;
|
|
41
|
+
for (code = 0; code < clear; code++) {
|
|
42
|
+
prefix[code] = 0;
|
|
43
|
+
suffix[code] = code;
|
|
44
|
+
}
|
|
45
|
+
// Decode GIF pixel stream.
|
|
46
|
+
var datum;
|
|
47
|
+
var bits;
|
|
48
|
+
var first;
|
|
49
|
+
var top;
|
|
50
|
+
var pi;
|
|
51
|
+
var bi;
|
|
52
|
+
datum = bits = first = top = pi = bi = 0;
|
|
53
|
+
for (i = 0; i < npix;) {
|
|
54
|
+
if (top === 0) {
|
|
55
|
+
if (bits < code_size) {
|
|
56
|
+
// get the next byte
|
|
57
|
+
datum += data[bi] << bits;
|
|
58
|
+
bits += 8;
|
|
59
|
+
bi++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// Get the next code.
|
|
63
|
+
code = datum & code_mask;
|
|
64
|
+
datum >>= code_size;
|
|
65
|
+
bits -= code_size;
|
|
66
|
+
// Interpret the code
|
|
67
|
+
if (code > available || code === end_of_information) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (code === clear) {
|
|
71
|
+
// Reset decoder.
|
|
72
|
+
code_size = data_size + 1;
|
|
73
|
+
code_mask = (1 << code_size) - 1;
|
|
74
|
+
available = clear + 2;
|
|
75
|
+
old_code = nullCode;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (old_code === nullCode) {
|
|
79
|
+
pixelStack[top++] = suffix[code];
|
|
80
|
+
old_code = code;
|
|
81
|
+
first = code;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
in_code = code;
|
|
85
|
+
if (code === available) {
|
|
86
|
+
pixelStack[top++] = first;
|
|
87
|
+
code = old_code;
|
|
88
|
+
}
|
|
89
|
+
while (code > clear) {
|
|
90
|
+
pixelStack[top++] = suffix[code];
|
|
91
|
+
code = prefix[code];
|
|
92
|
+
}
|
|
93
|
+
first = suffix[code] & 0xff;
|
|
94
|
+
pixelStack[top++] = first;
|
|
95
|
+
// add a new string to the table, but only if space is available
|
|
96
|
+
// if not, just continue with current table until a clear code is found
|
|
97
|
+
// (deferred clear code implementation as per GIF spec)
|
|
98
|
+
if (available < MAX_STACK_SIZE) {
|
|
99
|
+
prefix[available] = old_code;
|
|
100
|
+
suffix[available] = first;
|
|
101
|
+
available++;
|
|
102
|
+
if ((available & code_mask) === 0 && available < MAX_STACK_SIZE) {
|
|
103
|
+
code_size++;
|
|
104
|
+
code_mask += available;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
old_code = in_code;
|
|
108
|
+
}
|
|
109
|
+
// Pop a pixel off the pixel stack.
|
|
110
|
+
top--;
|
|
111
|
+
dstPixels[pi++] = pixelStack[top];
|
|
112
|
+
i++;
|
|
113
|
+
}
|
|
114
|
+
for (i = pi; i < npix; i++) {
|
|
115
|
+
dstPixels[i] = 0; // clear missing pixels
|
|
116
|
+
}
|
|
117
|
+
return dstPixels;
|
|
118
|
+
};
|
|
119
|
+
exports.lzw = lzw;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
declare type Dimensions = {
|
|
2
|
+
top: number;
|
|
3
|
+
left: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
declare type Application = {
|
|
8
|
+
application: {
|
|
9
|
+
blockSize: number;
|
|
10
|
+
blocks: number[];
|
|
11
|
+
codes: number[];
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare type Lct = {
|
|
16
|
+
exists: boolean;
|
|
17
|
+
future: number;
|
|
18
|
+
interlaced: boolean;
|
|
19
|
+
size: number;
|
|
20
|
+
sort: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare type Frame = {
|
|
23
|
+
gce: {
|
|
24
|
+
byteSize: number;
|
|
25
|
+
codes: number[];
|
|
26
|
+
delay: number;
|
|
27
|
+
terminator: number;
|
|
28
|
+
transparentColorIndex: number;
|
|
29
|
+
extras: {
|
|
30
|
+
userInput: boolean;
|
|
31
|
+
transparentColorGiven: boolean;
|
|
32
|
+
future: number;
|
|
33
|
+
disposal: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
image: {
|
|
37
|
+
code: number;
|
|
38
|
+
data: {
|
|
39
|
+
minCodeSize: number;
|
|
40
|
+
blocks: number[];
|
|
41
|
+
};
|
|
42
|
+
descriptor: {
|
|
43
|
+
top: number;
|
|
44
|
+
left: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
lct: Lct;
|
|
48
|
+
};
|
|
49
|
+
lct: [number, number, number][] | undefined;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare type ParsedFrame = {
|
|
53
|
+
dims: {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
top: number;
|
|
57
|
+
left: number;
|
|
58
|
+
};
|
|
59
|
+
colorTable: [number, number, number][];
|
|
60
|
+
delay: number;
|
|
61
|
+
disposalType: number;
|
|
62
|
+
patch: Uint8ClampedArray;
|
|
63
|
+
pixels: number[];
|
|
64
|
+
transparentIndex: number;
|
|
65
|
+
};
|
|
66
|
+
export declare type ParsedFrameWithoutPatch = Omit<ParsedFrame, 'patch'>;
|
|
67
|
+
export declare type ParsedGif = {
|
|
68
|
+
frames: (Application | Frame)[];
|
|
69
|
+
gct: [number, number, number][];
|
|
70
|
+
header: {
|
|
71
|
+
signature: string;
|
|
72
|
+
version: string;
|
|
73
|
+
};
|
|
74
|
+
lsd: {
|
|
75
|
+
backgroundColorIndex: number;
|
|
76
|
+
gct: {
|
|
77
|
+
exists: boolean;
|
|
78
|
+
resolution: number;
|
|
79
|
+
size: number;
|
|
80
|
+
sort: boolean;
|
|
81
|
+
};
|
|
82
|
+
height: number;
|
|
83
|
+
width: number;
|
|
84
|
+
pixelAspectRatio: number;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export declare type Image = {
|
|
88
|
+
pixels: number[];
|
|
89
|
+
dims: Dimensions;
|
|
90
|
+
delay?: number;
|
|
91
|
+
transparentIndex?: number;
|
|
92
|
+
colorTable?: [number, number, number][] | Lct;
|
|
93
|
+
disposalType?: unknown;
|
|
94
|
+
patch?: Uint8ClampedArray;
|
|
95
|
+
};
|
|
96
|
+
export {};
|
package/dist/parse-generate.d.ts
CHANGED
package/dist/parse-generate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = exports.parse = void 0;
|
|
4
|
-
const
|
|
4
|
+
const gifuct_1 = require("./gifuct");
|
|
5
5
|
const decompress_frames_1 = require("./parser/decompress-frames");
|
|
6
6
|
const validateAndFix = (gif) => {
|
|
7
7
|
let currentGce = null;
|
|
@@ -20,7 +20,7 @@ const parse = (src, { signal, }) => fetch(src, { signal })
|
|
|
20
20
|
throw Error(`Wrong content type: "${resp.headers.get('Content-Type')}"`);
|
|
21
21
|
return resp.arrayBuffer();
|
|
22
22
|
})
|
|
23
|
-
.then((buffer) => (0,
|
|
23
|
+
.then((buffer) => (0, gifuct_1.parseGIF)(buffer))
|
|
24
24
|
.then((gif) => {
|
|
25
25
|
validateAndFix(gif);
|
|
26
26
|
return gif;
|
|
@@ -32,12 +32,28 @@ const parse = (src, { signal, }) => fetch(src, { signal })
|
|
|
32
32
|
.then(([frames, options]) => {
|
|
33
33
|
const readyFrames = [];
|
|
34
34
|
const size = options.width * options.height * 4;
|
|
35
|
+
let canvas = new Uint8ClampedArray(size);
|
|
35
36
|
for (let i = 0; i < frames.length; ++i) {
|
|
36
37
|
const frame = frames[i];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
readyFrames.push(putPixels(
|
|
38
|
+
// Read about different disposal types
|
|
39
|
+
// https://giflib.sourceforge.net/whatsinagif/animation_and_transparency.html
|
|
40
|
+
const prevCanvas = frames[i].disposalType === 3 ? canvas.slice() : null;
|
|
41
|
+
readyFrames.push(putPixels(canvas, frame, options));
|
|
42
|
+
// Disposal type 2: The canvas should be restored to the background color
|
|
43
|
+
if (frames[i].disposalType === 2) {
|
|
44
|
+
canvas = new Uint8ClampedArray(size);
|
|
45
|
+
}
|
|
46
|
+
// Disposal type 3: The decoder should restore the canvas to its previous state before the current image was drawn
|
|
47
|
+
else if (frames[i].disposalType === 3) {
|
|
48
|
+
if (!prevCanvas) {
|
|
49
|
+
throw Error('Disposal type 3 without previous frame');
|
|
50
|
+
}
|
|
51
|
+
canvas = prevCanvas;
|
|
52
|
+
}
|
|
53
|
+
// Disposal type 1: Draw the next image on top of it
|
|
54
|
+
else {
|
|
55
|
+
canvas = readyFrames[i].slice();
|
|
56
|
+
}
|
|
41
57
|
}
|
|
42
58
|
return {
|
|
43
59
|
...options,
|
|
@@ -56,11 +72,12 @@ const putPixels = (typedArray, frame, gifSize) => {
|
|
|
56
72
|
const colorIndex = frame.pixels[pPos];
|
|
57
73
|
if (colorIndex !== frame.transparentIndex) {
|
|
58
74
|
const taPos = offset + y * gifSize.width + x;
|
|
59
|
-
const color = frame.colorTable[colorIndex]
|
|
75
|
+
const color = frame.colorTable[colorIndex];
|
|
60
76
|
typedArray[taPos * 4] = color[0];
|
|
61
77
|
typedArray[taPos * 4 + 1] = color[1];
|
|
62
78
|
typedArray[taPos * 4 + 2] = color[2];
|
|
63
|
-
typedArray[taPos * 4 + 3] =
|
|
79
|
+
typedArray[taPos * 4 + 3] =
|
|
80
|
+
colorIndex === frame.transparentIndex ? 0 : 255;
|
|
64
81
|
}
|
|
65
82
|
}
|
|
66
83
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ParsedFrameWithoutPatch, ParsedGif } from 'gifuct
|
|
1
|
+
import type { ParsedFrameWithoutPatch, ParsedGif } from '../gifuct/types';
|
|
2
2
|
export declare const decompressFrames: (parsedGif: ParsedGif) => ParsedFrameWithoutPatch[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decompressFrames = void 0;
|
|
4
|
-
const
|
|
4
|
+
const gifuct_1 = require("../gifuct");
|
|
5
5
|
const decompressFrames = (parsedGif) => {
|
|
6
6
|
return parsedGif.frames
|
|
7
7
|
.filter((f) => {
|
|
@@ -9,7 +9,7 @@ const decompressFrames = (parsedGif) => {
|
|
|
9
9
|
})
|
|
10
10
|
.map((f) => {
|
|
11
11
|
const fr = f.image
|
|
12
|
-
? (0,
|
|
12
|
+
? (0, gifuct_1.decompressFrame)(f, parsedGif.gct)
|
|
13
13
|
: null;
|
|
14
14
|
return fr;
|
|
15
15
|
})
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CondFunction, ParseFun, Result, Stream } from './types';
|
|
2
|
+
export declare const parse: (stream: Stream, schema: any, result?: Result, parent?: Result) => Result;
|
|
3
|
+
export declare const conditional: (schema: any, conditionFunc: CondFunction) => (stream: any, result: Result, parent: Result, _parse: ParseFun) => void;
|
|
4
|
+
export declare const loop: (schema: any, continueFunc: any) => (stream: any, result: any, parent: any, parse: any) => {}[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loop = exports.conditional = exports.parse = void 0;
|
|
4
|
+
const parse = (stream, schema, result = {}, parent = result) => {
|
|
5
|
+
if (Array.isArray(schema)) {
|
|
6
|
+
schema.forEach((partSchema) => (0, exports.parse)(stream, partSchema, result, parent));
|
|
7
|
+
}
|
|
8
|
+
else if (typeof schema === 'function') {
|
|
9
|
+
schema(stream, result, parent, exports.parse);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
const key = Object.keys(schema)[0];
|
|
13
|
+
if (Array.isArray(schema[key])) {
|
|
14
|
+
parent[key] = {};
|
|
15
|
+
(0, exports.parse)(stream, schema[key], result, parent[key]);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
parent[key] = schema[key](stream, result, parent, exports.parse);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
exports.parse = parse;
|
|
24
|
+
const conditional = (schema, conditionFunc) => (stream, result, parent, _parse) => {
|
|
25
|
+
if (conditionFunc(stream, result, parent)) {
|
|
26
|
+
_parse(stream, schema, result, parent);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.conditional = conditional;
|
|
30
|
+
const loop = (schema, continueFunc) => (stream, result, parent, parse) => {
|
|
31
|
+
const arr = [];
|
|
32
|
+
let lastStreamPos = stream.pos;
|
|
33
|
+
while (continueFunc(stream, result, parent)) {
|
|
34
|
+
const newParent = {};
|
|
35
|
+
parse(stream, schema, result, newParent);
|
|
36
|
+
// cases when whole file is parsed but no termination is there and stream position is not getting updated as well
|
|
37
|
+
// it falls into infinite recursion, null check to avoid the same
|
|
38
|
+
if (stream.pos === lastStreamPos) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
lastStreamPos = stream.pos;
|
|
42
|
+
arr.push(newParent);
|
|
43
|
+
}
|
|
44
|
+
return arr;
|
|
45
|
+
};
|
|
46
|
+
exports.loop = loop;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare type Schema = SchemaFun | Schema[] | SchemaFun[] | Record<string, Schema>;
|
|
2
|
+
export declare type Stream = unknown;
|
|
3
|
+
export declare type Result = Record<string, unknown>;
|
|
4
|
+
export declare type CondFunction = (a: Stream, b: Result, c: unknown) => boolean;
|
|
5
|
+
export declare type ParseFun = (a: Stream, b: Schema, c: Result | undefined, d: Result | undefined) => Result;
|
|
6
|
+
declare type SchemaFun = (stream: Stream, res: Result, parent: Result | undefined, parseFn: ParseFun) => void;
|
|
7
|
+
export {};
|
package/dist/worker/source.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const src = "\"use strict\";(()=>{var
|
|
1
|
+
export declare const src = "\"use strict\";(()=>{var N=Object.create;var j=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var T=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var re=(t,e,r,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of V(e))!ee.call(t,o)&&o!==r&&j(t,o,{get:()=>e[o],enumerable:!(n=Q(e,o))||n.enumerable});return t};var G=(t,e,r)=>(r=t!=null?N(Y(t)):{},re(e||!t||!t.__esModule?j(r,\"default\",{value:t,enumerable:!0}):r,t));var z=T(y=>{\"use strict\";Object.defineProperty(y,\"__esModule\",{value:!0});y.loop=y.conditional=y.parse=void 0;var te=function t(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:n;if(Array.isArray(r))r.forEach(function(a){return t(e,a,n,o)});else if(typeof r==\"function\")r(e,n,o,t);else{var i=Object.keys(r)[0];Array.isArray(r[i])?(o[i]={},t(e,r[i],n,o[i])):o[i]=r[i](e,n,o,t)}return n};y.parse=te;var ne=function(e,r){return function(n,o,i,a){r(n,o,i)&&a(n,e,o,i)}};y.conditional=ne;var ae=function(e,r){return function(n,o,i,a){for(var c=[],d=n.pos;r(n,o,i);){var u={};if(a(n,e,o,u),n.pos===d)break;d=n.pos,c.push(u)}return c}};y.loop=ae});var E=T(p=>{\"use strict\";Object.defineProperty(p,\"__esModule\",{value:!0});p.readBits=p.readArray=p.readUnsigned=p.readString=p.peekBytes=p.readBytes=p.peekByte=p.readByte=p.buildStream=void 0;var oe=function(e){return{data:e,pos:0}};p.buildStream=oe;var W=function(){return function(e){return e.data[e.pos++]}};p.readByte=W;var ie=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(r){return r.data[r.pos+e]}};p.peekByte=ie;var _=function(e){return function(r){return r.data.subarray(r.pos,r.pos+=e)}};p.readBytes=_;var se=function(e){return function(r){return r.data.subarray(r.pos,r.pos+e)}};p.peekBytes=se;var de=function(e){return function(r){return Array.from(_(e)(r)).map(function(n){return String.fromCharCode(n)}).join(\"\")}};p.readString=de;var ce=function(e){return function(r){var n=_(2)(r);return e?(n[1]<<8)+n[0]:(n[0]<<8)+n[1]}};p.readUnsigned=ce;var ue=function(e,r){return function(n,o,i){for(var a=typeof r==\"function\"?r(n,o,i):r,c=_(e),d=new Array(a),u=0;u<a;u++)d[u]=c(n);return d}};p.readArray=ue;var le=function(e,r,n){for(var o=0,i=0;i<n;i++)o+=e[r+i]&&Math.pow(2,n-i-1);return o},pe=function(e){return function(r){for(var n=W()(r),o=new Array(8),i=0;i<8;i++)o[7-i]=!!(n&1<<i);return Object.keys(e).reduce(function(a,c){var d=e[c];return d.length?a[c]=le(o,d.index,d.length):a[c]=o[d.index],a},{})}};p.readBits=pe});var K=T(I=>{\"use strict\";Object.defineProperty(I,\"__esModule\",{value:!0});I.default=void 0;var h=z(),s=E(),F={blocks:function(e){for(var r=0,n=[],o=e.data.length,i=0,a=(0,s.readByte)()(e);a!==r&&a;a=(0,s.readByte)()(e)){if(e.pos+a>=o){var c=o-e.pos;n.push((0,s.readBytes)(c)(e)),i+=c;break}n.push((0,s.readBytes)(a)(e)),i+=a}for(var d=new Uint8Array(i),u=0,f=0;f<n.length;f++)d.set(n[f],u),u+=n[f].length;return d}},fe=(0,h.conditional)({gce:[{codes:(0,s.readBytes)(2)},{byteSize:(0,s.readByte)()},{extras:(0,s.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,s.readUnsigned)(!0)},{transparentColorIndex:(0,s.readByte)()},{terminator:(0,s.readByte)()}]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===249}),me=(0,h.conditional)({image:[{code:(0,s.readByte)()},{descriptor:[{left:(0,s.readUnsigned)(!0)},{top:(0,s.readUnsigned)(!0)},{width:(0,s.readUnsigned)(!0)},{height:(0,s.readUnsigned)(!0)},{lct:(0,s.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,h.conditional)({lct:(0,s.readArray)(3,function(t,e,r){return Math.pow(2,r.descriptor.lct.size+1)})},function(t,e,r){return r.descriptor.lct.exists}),{data:[{minCodeSize:(0,s.readByte)()},F]}]},function(t){return(0,s.peekByte)()(t)===44}),ge=(0,h.conditional)({text:[{codes:(0,s.readBytes)(2)},{blockSize:(0,s.readByte)()},{preData:function(e,r,n){return(0,s.readBytes)(n.text.blockSize)(e)}},F]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===1}),ye=(0,h.conditional)({application:[{codes:(0,s.readBytes)(2)},{blockSize:(0,s.readByte)()},{id:function(e,r,n){return(0,s.readString)(n.blockSize)(e)}},F]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===255}),he=(0,h.conditional)({comment:[{codes:(0,s.readBytes)(2)},F]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===254}),ve=[{header:[{signature:(0,s.readString)(3)},{version:(0,s.readString)(3)}]},{lsd:[{width:(0,s.readUnsigned)(!0)},{height:(0,s.readUnsigned)(!0)},{gct:(0,s.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,s.readByte)()},{pixelAspectRatio:(0,s.readByte)()}]},(0,h.conditional)({gct:(0,s.readArray)(3,function(t,e){return Math.pow(2,e.lsd.gct.size+1)})},function(t,e){return e.lsd.gct.exists}),{frames:(0,h.loop)([fe,ye,he,me,ge],function(t){var e=(0,s.peekByte)()(t);return e===33||e===44})}],be=ve;I.default=be});var D=G(z()),O=G(E()),R=G(K());var X=(t,e)=>{let r=new Array(t.length),n=t.length/e,o=function(d,u){let f=t.slice(u*e,(u+1)*e);r.splice(...[d*e,e].concat(f))},i=[0,4,2,1],a=[8,8,4,2],c=0;for(let d=0;d<4;d++)for(let u=i[d];u<n;u+=a[d])o(u,c),c++;return r};var Z=(t,e,r)=>{let i=r,a,c,d,u,f;var B;let l,m;var C,b,g,k,P;let v=new Array(r),U=new Array(4096),A=new Array(4096),S=new Array(4096+1),M=t,x=1<<M,J=x+1;for(a=x+2,f=-1,d=M+1,c=(1<<d)-1,l=0;l<x;l++)U[l]=0,A[l]=l;var C,B,b,g,P,k;for(C=B=b=g=P=k=0,m=0;m<i;){if(g===0){if(B<d){C+=e[k]<<B,B+=8,k++;continue}if(l=C&c,C>>=d,B-=d,l>a||l===J)break;if(l===x){d=M+1,c=(1<<d)-1,a=x+2,f=-1;continue}if(f===-1){S[g++]=A[l],f=l,b=l;continue}for(u=l,l===a&&(S[g++]=b,l=f);l>x;)S[g++]=A[l],l=U[l];b=A[l]&255,S[g++]=b,a<4096&&(U[a]=f,A[a]=b,a++,!(a&c)&&a<4096&&(d++,c+=a)),f=u}g--,v[P++]=S[g],m++}for(m=P;m<i;m++)v[m]=0;return v};var q=t=>{let e=new Uint8Array(t);return(0,D.parse)((0,O.buildStream)(e),R.default)},L=(t,e)=>{var a,c;if(!t.image){console.warn(\"gif frame does not have associated image.\");return}let{image:r}=t,n=r.descriptor.width*r.descriptor.height,o=Z(r.data.minCodeSize,r.data.blocks,n);return(a=r.descriptor.lct)!=null&&a.interlaced&&(o=X(o,r.descriptor.width)),{pixels:o,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height},colorTable:(c=r.descriptor.lct)!=null&&c.exists?r.lct:e,delay:(t.gce.delay||10)*10,disposalType:t.gce.extras.disposal,transparentIndex:t.gce.extras.transparentColorGiven?t.gce.transparentColorIndex:-1}};var $=t=>t.frames.filter(e=>!(\"application\"in e)).map(e=>e.image?L(e,t.gct):null).filter(Boolean).map(e=>e);var xe=t=>{let e=null;for(let r of t.frames)e=r.gce?r.gce:e,\"image\"in r&&!(\"gce\"in r)&&e!==null&&(r.gce=e)},H=(t,{signal:e})=>fetch(t,{signal:e}).then(r=>{var n;if(!((n=r.headers.get(\"Content-Type\"))!=null&&n.includes(\"image/gif\")))throw Error(`Wrong content type: \"${r.headers.get(\"Content-Type\")}\"`);return r.arrayBuffer()}).then(r=>q(r)).then(r=>(xe(r),r)).then(r=>Promise.all([$(r),{width:r.lsd.width,height:r.lsd.height}])).then(([r,n])=>{let o=[],i=n.width*n.height*4,a=new Uint8ClampedArray(i);for(let c=0;c<r.length;++c){let d=r[c],u=r[c].disposalType===3?a.slice():null;if(o.push(Be(a,d,n)),r[c].disposalType===2)a=new Uint8ClampedArray(i);else if(r[c].disposalType===3){if(!u)throw Error(\"Disposal type 3 without previous frame\");a=u}else a=o[c].slice()}return{...n,loaded:!0,delays:r.map(c=>c.delay),frames:o}}),Be=(t,e,r)=>{let{width:n,height:o,top:i,left:a}=e.dims,c=i*r.width+a;for(let d=0;d<o;d++)for(let u=0;u<n;u++){let f=d*n+u,l=e.pixels[f];if(l!==e.transparentIndex){let m=c+d*r.width+u,v=e.colorTable[l];t[m*4]=v[0],t[m*4+1]=v[1],t[m*4+2]=v[2],t[m*4+3]=l===e.transparentIndex?0:255}}return t};var w=new Map;self.addEventListener(\"message\",t=>{let{type:e,src:r}=t.data||t;switch(e){case\"parse\":{if(!w.has(r)){let n=new AbortController,o={signal:n.signal};w.set(r,n),H(r,o).then(i=>{self.postMessage(Object.assign(i,{src:r}),i.frames.map(a=>a.buffer))}).catch(i=>{self.postMessage({src:r,error:i,loaded:!0})}).finally(()=>{w.delete(r)})}break}case\"cancel\":{w.has(r)&&(w.get(r).abort(),w.delete(r));break}default:break}});})();\n";
|
package/dist/worker/source.js
CHANGED
|
@@ -4,4 +4,4 @@ exports.src = void 0;
|
|
|
4
4
|
// Auto-generated by build.mjs
|
|
5
5
|
exports.src =
|
|
6
6
|
// eslint-disable-next-line no-template-curly-in-string
|
|
7
|
-
"\"use strict\";(()=>{var
|
|
7
|
+
"\"use strict\";(()=>{var N=Object.create;var j=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var T=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var re=(t,e,r,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of V(e))!ee.call(t,o)&&o!==r&&j(t,o,{get:()=>e[o],enumerable:!(n=Q(e,o))||n.enumerable});return t};var G=(t,e,r)=>(r=t!=null?N(Y(t)):{},re(e||!t||!t.__esModule?j(r,\"default\",{value:t,enumerable:!0}):r,t));var z=T(y=>{\"use strict\";Object.defineProperty(y,\"__esModule\",{value:!0});y.loop=y.conditional=y.parse=void 0;var te=function t(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:n;if(Array.isArray(r))r.forEach(function(a){return t(e,a,n,o)});else if(typeof r==\"function\")r(e,n,o,t);else{var i=Object.keys(r)[0];Array.isArray(r[i])?(o[i]={},t(e,r[i],n,o[i])):o[i]=r[i](e,n,o,t)}return n};y.parse=te;var ne=function(e,r){return function(n,o,i,a){r(n,o,i)&&a(n,e,o,i)}};y.conditional=ne;var ae=function(e,r){return function(n,o,i,a){for(var c=[],d=n.pos;r(n,o,i);){var u={};if(a(n,e,o,u),n.pos===d)break;d=n.pos,c.push(u)}return c}};y.loop=ae});var E=T(p=>{\"use strict\";Object.defineProperty(p,\"__esModule\",{value:!0});p.readBits=p.readArray=p.readUnsigned=p.readString=p.peekBytes=p.readBytes=p.peekByte=p.readByte=p.buildStream=void 0;var oe=function(e){return{data:e,pos:0}};p.buildStream=oe;var W=function(){return function(e){return e.data[e.pos++]}};p.readByte=W;var ie=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(r){return r.data[r.pos+e]}};p.peekByte=ie;var _=function(e){return function(r){return r.data.subarray(r.pos,r.pos+=e)}};p.readBytes=_;var se=function(e){return function(r){return r.data.subarray(r.pos,r.pos+e)}};p.peekBytes=se;var de=function(e){return function(r){return Array.from(_(e)(r)).map(function(n){return String.fromCharCode(n)}).join(\"\")}};p.readString=de;var ce=function(e){return function(r){var n=_(2)(r);return e?(n[1]<<8)+n[0]:(n[0]<<8)+n[1]}};p.readUnsigned=ce;var ue=function(e,r){return function(n,o,i){for(var a=typeof r==\"function\"?r(n,o,i):r,c=_(e),d=new Array(a),u=0;u<a;u++)d[u]=c(n);return d}};p.readArray=ue;var le=function(e,r,n){for(var o=0,i=0;i<n;i++)o+=e[r+i]&&Math.pow(2,n-i-1);return o},pe=function(e){return function(r){for(var n=W()(r),o=new Array(8),i=0;i<8;i++)o[7-i]=!!(n&1<<i);return Object.keys(e).reduce(function(a,c){var d=e[c];return d.length?a[c]=le(o,d.index,d.length):a[c]=o[d.index],a},{})}};p.readBits=pe});var K=T(I=>{\"use strict\";Object.defineProperty(I,\"__esModule\",{value:!0});I.default=void 0;var h=z(),s=E(),F={blocks:function(e){for(var r=0,n=[],o=e.data.length,i=0,a=(0,s.readByte)()(e);a!==r&&a;a=(0,s.readByte)()(e)){if(e.pos+a>=o){var c=o-e.pos;n.push((0,s.readBytes)(c)(e)),i+=c;break}n.push((0,s.readBytes)(a)(e)),i+=a}for(var d=new Uint8Array(i),u=0,f=0;f<n.length;f++)d.set(n[f],u),u+=n[f].length;return d}},fe=(0,h.conditional)({gce:[{codes:(0,s.readBytes)(2)},{byteSize:(0,s.readByte)()},{extras:(0,s.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,s.readUnsigned)(!0)},{transparentColorIndex:(0,s.readByte)()},{terminator:(0,s.readByte)()}]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===249}),me=(0,h.conditional)({image:[{code:(0,s.readByte)()},{descriptor:[{left:(0,s.readUnsigned)(!0)},{top:(0,s.readUnsigned)(!0)},{width:(0,s.readUnsigned)(!0)},{height:(0,s.readUnsigned)(!0)},{lct:(0,s.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,h.conditional)({lct:(0,s.readArray)(3,function(t,e,r){return Math.pow(2,r.descriptor.lct.size+1)})},function(t,e,r){return r.descriptor.lct.exists}),{data:[{minCodeSize:(0,s.readByte)()},F]}]},function(t){return(0,s.peekByte)()(t)===44}),ge=(0,h.conditional)({text:[{codes:(0,s.readBytes)(2)},{blockSize:(0,s.readByte)()},{preData:function(e,r,n){return(0,s.readBytes)(n.text.blockSize)(e)}},F]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===1}),ye=(0,h.conditional)({application:[{codes:(0,s.readBytes)(2)},{blockSize:(0,s.readByte)()},{id:function(e,r,n){return(0,s.readString)(n.blockSize)(e)}},F]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===255}),he=(0,h.conditional)({comment:[{codes:(0,s.readBytes)(2)},F]},function(t){var e=(0,s.peekBytes)(2)(t);return e[0]===33&&e[1]===254}),ve=[{header:[{signature:(0,s.readString)(3)},{version:(0,s.readString)(3)}]},{lsd:[{width:(0,s.readUnsigned)(!0)},{height:(0,s.readUnsigned)(!0)},{gct:(0,s.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,s.readByte)()},{pixelAspectRatio:(0,s.readByte)()}]},(0,h.conditional)({gct:(0,s.readArray)(3,function(t,e){return Math.pow(2,e.lsd.gct.size+1)})},function(t,e){return e.lsd.gct.exists}),{frames:(0,h.loop)([fe,ye,he,me,ge],function(t){var e=(0,s.peekByte)()(t);return e===33||e===44})}],be=ve;I.default=be});var D=G(z()),O=G(E()),R=G(K());var X=(t,e)=>{let r=new Array(t.length),n=t.length/e,o=function(d,u){let f=t.slice(u*e,(u+1)*e);r.splice(...[d*e,e].concat(f))},i=[0,4,2,1],a=[8,8,4,2],c=0;for(let d=0;d<4;d++)for(let u=i[d];u<n;u+=a[d])o(u,c),c++;return r};var Z=(t,e,r)=>{let i=r,a,c,d,u,f;var B;let l,m;var C,b,g,k,P;let v=new Array(r),U=new Array(4096),A=new Array(4096),S=new Array(4096+1),M=t,x=1<<M,J=x+1;for(a=x+2,f=-1,d=M+1,c=(1<<d)-1,l=0;l<x;l++)U[l]=0,A[l]=l;var C,B,b,g,P,k;for(C=B=b=g=P=k=0,m=0;m<i;){if(g===0){if(B<d){C+=e[k]<<B,B+=8,k++;continue}if(l=C&c,C>>=d,B-=d,l>a||l===J)break;if(l===x){d=M+1,c=(1<<d)-1,a=x+2,f=-1;continue}if(f===-1){S[g++]=A[l],f=l,b=l;continue}for(u=l,l===a&&(S[g++]=b,l=f);l>x;)S[g++]=A[l],l=U[l];b=A[l]&255,S[g++]=b,a<4096&&(U[a]=f,A[a]=b,a++,!(a&c)&&a<4096&&(d++,c+=a)),f=u}g--,v[P++]=S[g],m++}for(m=P;m<i;m++)v[m]=0;return v};var q=t=>{let e=new Uint8Array(t);return(0,D.parse)((0,O.buildStream)(e),R.default)},L=(t,e)=>{var a,c;if(!t.image){console.warn(\"gif frame does not have associated image.\");return}let{image:r}=t,n=r.descriptor.width*r.descriptor.height,o=Z(r.data.minCodeSize,r.data.blocks,n);return(a=r.descriptor.lct)!=null&&a.interlaced&&(o=X(o,r.descriptor.width)),{pixels:o,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height},colorTable:(c=r.descriptor.lct)!=null&&c.exists?r.lct:e,delay:(t.gce.delay||10)*10,disposalType:t.gce.extras.disposal,transparentIndex:t.gce.extras.transparentColorGiven?t.gce.transparentColorIndex:-1}};var $=t=>t.frames.filter(e=>!(\"application\"in e)).map(e=>e.image?L(e,t.gct):null).filter(Boolean).map(e=>e);var xe=t=>{let e=null;for(let r of t.frames)e=r.gce?r.gce:e,\"image\"in r&&!(\"gce\"in r)&&e!==null&&(r.gce=e)},H=(t,{signal:e})=>fetch(t,{signal:e}).then(r=>{var n;if(!((n=r.headers.get(\"Content-Type\"))!=null&&n.includes(\"image/gif\")))throw Error(`Wrong content type: \"${r.headers.get(\"Content-Type\")}\"`);return r.arrayBuffer()}).then(r=>q(r)).then(r=>(xe(r),r)).then(r=>Promise.all([$(r),{width:r.lsd.width,height:r.lsd.height}])).then(([r,n])=>{let o=[],i=n.width*n.height*4,a=new Uint8ClampedArray(i);for(let c=0;c<r.length;++c){let d=r[c],u=r[c].disposalType===3?a.slice():null;if(o.push(Be(a,d,n)),r[c].disposalType===2)a=new Uint8ClampedArray(i);else if(r[c].disposalType===3){if(!u)throw Error(\"Disposal type 3 without previous frame\");a=u}else a=o[c].slice()}return{...n,loaded:!0,delays:r.map(c=>c.delay),frames:o}}),Be=(t,e,r)=>{let{width:n,height:o,top:i,left:a}=e.dims,c=i*r.width+a;for(let d=0;d<o;d++)for(let u=0;u<n;u++){let f=d*n+u,l=e.pixels[f];if(l!==e.transparentIndex){let m=c+d*r.width+u,v=e.colorTable[l];t[m*4]=v[0],t[m*4+1]=v[1],t[m*4+2]=v[2],t[m*4+3]=l===e.transparentIndex?0:255}}return t};var w=new Map;self.addEventListener(\"message\",t=>{let{type:e,src:r}=t.data||t;switch(e){case\"parse\":{if(!w.has(r)){let n=new AbortController,o={signal:n.signal};w.set(r,n),H(r,o).then(i=>{self.postMessage(Object.assign(i,{src:r}),i.frames.map(a=>a.buffer))}).catch(i=>{self.postMessage({src:r,error:i,loaded:!0})}).finally(()=>{w.delete(r)})}break}case\"cancel\":{w.has(r)&&(w.get(r).abort(),w.delete(r));break}default:break}});})();\n";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/gif",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.33",
|
|
4
4
|
"description": "Gif component for remotion",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"watch": "tsc -w"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
24
|
+
"js-binary-schema-parser": "^2.0.3",
|
|
25
25
|
"lru_map": "0.4.1",
|
|
26
|
-
"remotion": "3.3.
|
|
26
|
+
"remotion": "3.3.33"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@jonny/eslint-config": "3.0.266",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "0356b9108673ac98c41990f192b101f7a6574ed0"
|
|
57
57
|
}
|