@celljs/ta-host 4.14.0 → 4.15.1
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/README.en.md +2 -1
- package/README.md +2 -1
- package/esm/node/auth-server-impl.d.ts +12 -2
- package/esm/node/auth-server-impl.js +102 -3
- package/esm/node/custom-providers.d.ts +50 -0
- package/esm/node/custom-providers.js +335 -0
- package/esm/node/extension-data.js +7 -3
- package/esm/node/index.d.ts +1 -0
- package/esm/node/index.js +1 -0
- package/esm/node/jpeg-encoder.d.ts +7 -0
- package/esm/node/jpeg-encoder.js +268 -0
- package/esm/node/png-thumbnail.d.ts +40 -0
- package/esm/node/png-thumbnail.js +384 -0
- package/esm/node/serve-updates.d.ts +38 -0
- package/esm/node/serve-updates.js +89 -0
- package/esm/node/sign-in/sign-in-provider.d.ts +44 -0
- package/esm/node/sign-in/sign-in-provider.js +74 -7
- package/esm/node/sign-in/ta-sign-in.d.ts +4 -1
- package/esm/node/sign-in/ta-sign-in.js +6 -2
- package/esm/node/ta-server-impl.d.ts +3 -0
- package/esm/node/ta-server-impl.js +33 -9
- package/esm/node/team/host-team.js +1 -0
- package/esm/node/team/member-accounts.d.ts +25 -8
- package/esm/node/team/member-accounts.js +84 -4
- package/esm/node/team/team-calls.js +5 -0
- package/esm/node/web-extension-util.js +1 -0
- package/esm/node/workspace-files.d.ts +23 -0
- package/esm/node/workspace-files.js +86 -0
- package/lib/node/auth-server-impl.d.ts +12 -2
- package/lib/node/auth-server-impl.js +101 -2
- package/lib/node/custom-providers.d.ts +51 -0
- package/lib/node/custom-providers.js +338 -0
- package/lib/node/extension-data.js +6 -2
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/jpeg-encoder.d.ts +8 -0
- package/lib/node/jpeg-encoder.js +271 -0
- package/lib/node/png-thumbnail.d.ts +41 -0
- package/lib/node/png-thumbnail.js +387 -0
- package/lib/node/serve-updates.d.ts +39 -0
- package/lib/node/serve-updates.js +92 -0
- package/lib/node/sign-in/sign-in-provider.d.ts +44 -0
- package/lib/node/sign-in/sign-in-provider.js +77 -9
- package/lib/node/sign-in/ta-sign-in.d.ts +4 -1
- package/lib/node/sign-in/ta-sign-in.js +6 -2
- package/lib/node/ta-server-impl.d.ts +3 -0
- package/lib/node/ta-server-impl.js +33 -9
- package/lib/node/team/host-team.js +1 -0
- package/lib/node/team/member-accounts.d.ts +25 -8
- package/lib/node/team/member-accounts.js +84 -4
- package/lib/node/team/team-calls.js +5 -0
- package/lib/node/web-extension-util.js +1 -0
- package/lib/node/workspace-files.d.ts +23 -0
- package/lib/node/workspace-files.js +86 -0
- package/package.json +10 -10
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JpegEncoder = void 0;
|
|
4
|
+
/** The order of the 64 coefficients of a block as a JPEG writes them, as indices of its rows one after another. */
|
|
5
|
+
const ZIGZAG = [
|
|
6
|
+
0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29,
|
|
7
|
+
22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
|
|
8
|
+
];
|
|
9
|
+
/** The quantization tables of the JPEG standard (Annex K), by rows. */
|
|
10
|
+
const LUMA_QUANT = [
|
|
11
|
+
16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109,
|
|
12
|
+
103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99,
|
|
13
|
+
];
|
|
14
|
+
const CHROMA_QUANT = [
|
|
15
|
+
17,
|
|
16
|
+
18,
|
|
17
|
+
24,
|
|
18
|
+
47,
|
|
19
|
+
99,
|
|
20
|
+
99,
|
|
21
|
+
99,
|
|
22
|
+
99,
|
|
23
|
+
18,
|
|
24
|
+
21,
|
|
25
|
+
26,
|
|
26
|
+
66,
|
|
27
|
+
99,
|
|
28
|
+
99,
|
|
29
|
+
99,
|
|
30
|
+
99,
|
|
31
|
+
24,
|
|
32
|
+
26,
|
|
33
|
+
56,
|
|
34
|
+
99,
|
|
35
|
+
99,
|
|
36
|
+
99,
|
|
37
|
+
99,
|
|
38
|
+
99,
|
|
39
|
+
47,
|
|
40
|
+
66,
|
|
41
|
+
99,
|
|
42
|
+
99,
|
|
43
|
+
99,
|
|
44
|
+
99,
|
|
45
|
+
99,
|
|
46
|
+
99,
|
|
47
|
+
...new Array(32).fill(99),
|
|
48
|
+
];
|
|
49
|
+
/** The Huffman tables of the standard: how many codes of each length 1 to 16, then their values. */
|
|
50
|
+
const DC_LUMA = { bits: [0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] };
|
|
51
|
+
const DC_CHROMA = { bits: [0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] };
|
|
52
|
+
const AC_LUMA = {
|
|
53
|
+
bits: [0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d],
|
|
54
|
+
values: [
|
|
55
|
+
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23,
|
|
56
|
+
0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
|
|
57
|
+
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64,
|
|
58
|
+
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
|
|
59
|
+
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2,
|
|
60
|
+
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
|
|
61
|
+
0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
const AC_CHROMA = {
|
|
65
|
+
bits: [0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77],
|
|
66
|
+
values: [
|
|
67
|
+
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1,
|
|
68
|
+
0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28,
|
|
69
|
+
0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63,
|
|
70
|
+
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92,
|
|
71
|
+
0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
|
|
72
|
+
0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
|
73
|
+
0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
/** For each value of a table, its code and the length of the code. */
|
|
77
|
+
function codes(table) {
|
|
78
|
+
const code = new Uint16Array(256);
|
|
79
|
+
const length = new Uint8Array(256);
|
|
80
|
+
let next = 0;
|
|
81
|
+
let at = 0;
|
|
82
|
+
for (let size = 1; size <= 16; size++) {
|
|
83
|
+
for (let n = 0; n < table.bits[size - 1]; n++) {
|
|
84
|
+
code[table.values[at]] = next;
|
|
85
|
+
length[table.values[at]] = size;
|
|
86
|
+
next++;
|
|
87
|
+
at++;
|
|
88
|
+
}
|
|
89
|
+
next <<= 1;
|
|
90
|
+
}
|
|
91
|
+
return { code, length };
|
|
92
|
+
}
|
|
93
|
+
/** cos((2x + 1) u π / 16), with the factor of u = 0, for the forward DCT. */
|
|
94
|
+
const COS = (() => {
|
|
95
|
+
const table = new Float64Array(64);
|
|
96
|
+
for (let u = 0; u < 8; u++) {
|
|
97
|
+
for (let x = 0; x < 8; x++) {
|
|
98
|
+
table[u * 8 + x] = Math.cos(((2 * x + 1) * u * Math.PI) / 16) * (u === 0 ? Math.SQRT1_2 : 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return table;
|
|
102
|
+
})();
|
|
103
|
+
class BitWriter {
|
|
104
|
+
constructor() {
|
|
105
|
+
this.bytes = new Uint8Array(64 * 1024);
|
|
106
|
+
this.length = 0;
|
|
107
|
+
this.value = 0;
|
|
108
|
+
this.count = 0;
|
|
109
|
+
}
|
|
110
|
+
byte(byte) {
|
|
111
|
+
if (this.length === this.bytes.length) {
|
|
112
|
+
const larger = new Uint8Array(this.bytes.length * 2);
|
|
113
|
+
larger.set(this.bytes);
|
|
114
|
+
this.bytes = larger;
|
|
115
|
+
}
|
|
116
|
+
this.bytes[this.length++] = byte;
|
|
117
|
+
}
|
|
118
|
+
raw(bytes) {
|
|
119
|
+
for (const byte of bytes) {
|
|
120
|
+
this.byte(byte);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
bits(value, count) {
|
|
124
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
125
|
+
this.value = (this.value << 1) | ((value >> i) & 1);
|
|
126
|
+
if (++this.count === 8) {
|
|
127
|
+
this.byte(this.value);
|
|
128
|
+
// A 0xFF of the data is followed by a 0, so that it is not taken for a marker.
|
|
129
|
+
if (this.value === 0xff) {
|
|
130
|
+
this.byte(0);
|
|
131
|
+
}
|
|
132
|
+
this.value = 0;
|
|
133
|
+
this.count = 0;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** The last bits, padded with ones. */
|
|
138
|
+
flush() {
|
|
139
|
+
if (this.count > 0) {
|
|
140
|
+
this.bits((1 << (8 - this.count)) - 1, 8 - this.count);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
done() {
|
|
144
|
+
return this.bytes.slice(0, this.length);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A baseline JPEG of opaque RGBA, without a library: YCbCr without subsampling (the letters of a screenshot keep
|
|
149
|
+
* their colour), the tables of the standard scaled to `quality` (1–100, as libjpeg reads it).
|
|
150
|
+
*/
|
|
151
|
+
var JpegEncoder;
|
|
152
|
+
(function (JpegEncoder) {
|
|
153
|
+
function encode(rgba, width, height, quality = 80) {
|
|
154
|
+
const scale = quality < 50 ? 5000 / quality : 200 - quality * 2;
|
|
155
|
+
const quant = (base) => base.map(value => Math.min(255, Math.max(1, Math.floor((value * scale + 50) / 100))));
|
|
156
|
+
const luma = quant(LUMA_QUANT);
|
|
157
|
+
const chroma = quant(CHROMA_QUANT);
|
|
158
|
+
const out = new BitWriter();
|
|
159
|
+
out.raw([0xff, 0xd8]);
|
|
160
|
+
// JFIF, version 1.1, no density.
|
|
161
|
+
out.raw([0xff, 0xe0, 0, 16, 0x4a, 0x46, 0x49, 0x46, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0]);
|
|
162
|
+
for (const [id, table] of [luma, chroma].entries()) {
|
|
163
|
+
out.raw([0xff, 0xdb, 0, 67, id, ...ZIGZAG.map(index => table[index])]);
|
|
164
|
+
}
|
|
165
|
+
out.raw([0xff, 0xc0, 0, 17, 8, height >> 8, height & 255, width >> 8, width & 255, 3, 1, 0x11, 0, 2, 0x11, 1, 3, 0x11, 1]);
|
|
166
|
+
for (const [klass, table] of [
|
|
167
|
+
[0x00, DC_LUMA],
|
|
168
|
+
[0x10, AC_LUMA],
|
|
169
|
+
[0x01, DC_CHROMA],
|
|
170
|
+
[0x11, AC_CHROMA],
|
|
171
|
+
]) {
|
|
172
|
+
out.raw([0xff, 0xc4, (19 + table.values.length) >> 8, (19 + table.values.length) & 255, klass, ...table.bits, ...table.values]);
|
|
173
|
+
}
|
|
174
|
+
out.raw([0xff, 0xda, 0, 12, 3, 1, 0x00, 2, 0x11, 3, 0x11, 0, 63, 0]);
|
|
175
|
+
const tables = [
|
|
176
|
+
{ quant: luma, dc: codes(DC_LUMA), ac: codes(AC_LUMA) },
|
|
177
|
+
{ quant: chroma, dc: codes(DC_CHROMA), ac: codes(AC_CHROMA) },
|
|
178
|
+
{ quant: chroma, dc: codes(DC_CHROMA), ac: codes(AC_CHROMA) },
|
|
179
|
+
];
|
|
180
|
+
const previous = [0, 0, 0];
|
|
181
|
+
const planes = [new Float64Array(64), new Float64Array(64), new Float64Array(64)];
|
|
182
|
+
const coefficients = new Int32Array(64);
|
|
183
|
+
const rows = new Float64Array(64);
|
|
184
|
+
for (let top = 0; top < height; top += 8) {
|
|
185
|
+
for (let left = 0; left < width; left += 8) {
|
|
186
|
+
for (let y = 0; y < 8; y++) {
|
|
187
|
+
const row = Math.min(height - 1, top + y) * width;
|
|
188
|
+
for (let x = 0; x < 8; x++) {
|
|
189
|
+
const at = (row + Math.min(width - 1, left + x)) * 4;
|
|
190
|
+
const r = rgba[at];
|
|
191
|
+
const g = rgba[at + 1];
|
|
192
|
+
const b = rgba[at + 2];
|
|
193
|
+
planes[0][y * 8 + x] = 0.299 * r + 0.587 * g + 0.114 * b - 128;
|
|
194
|
+
planes[1][y * 8 + x] = -0.168736 * r - 0.331264 * g + 0.5 * b;
|
|
195
|
+
planes[2][y * 8 + x] = 0.5 * r - 0.418688 * g - 0.081312 * b;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
for (let component = 0; component < 3; component++) {
|
|
199
|
+
const table = tables[component];
|
|
200
|
+
dct(planes[component], rows, coefficients, table.quant);
|
|
201
|
+
previous[component] = block(out, coefficients, previous[component], table.dc, table.ac);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
out.flush();
|
|
206
|
+
out.raw([0xff, 0xd9]);
|
|
207
|
+
return out.done();
|
|
208
|
+
}
|
|
209
|
+
JpegEncoder.encode = encode;
|
|
210
|
+
/** The coefficients of a block of 8 × 8, quantized, in the order of the zigzag. */
|
|
211
|
+
function dct(block, rows, out, quant) {
|
|
212
|
+
for (let y = 0; y < 8; y++) {
|
|
213
|
+
for (let u = 0; u < 8; u++) {
|
|
214
|
+
let sum = 0;
|
|
215
|
+
for (let x = 0; x < 8; x++) {
|
|
216
|
+
sum += block[y * 8 + x] * COS[u * 8 + x];
|
|
217
|
+
}
|
|
218
|
+
rows[y * 8 + u] = sum;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
for (let k = 0; k < 64; k++) {
|
|
222
|
+
const index = ZIGZAG[k];
|
|
223
|
+
const v = index >> 3;
|
|
224
|
+
const u = index & 7;
|
|
225
|
+
let sum = 0;
|
|
226
|
+
for (let y = 0; y < 8; y++) {
|
|
227
|
+
sum += rows[y * 8 + u] * COS[v * 8 + y];
|
|
228
|
+
}
|
|
229
|
+
out[k] = Math.round(sum / 4 / quant[index]);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** One block written with its tables; the DC of it, which the next of its component is written from. */
|
|
233
|
+
function block(out, coefficients, previous, dc, ac) {
|
|
234
|
+
const diff = coefficients[0] - previous;
|
|
235
|
+
const size = category(diff);
|
|
236
|
+
out.bits(dc.code[size], dc.length[size]);
|
|
237
|
+
out.bits(magnitude(diff, size), size);
|
|
238
|
+
let run = 0;
|
|
239
|
+
for (let k = 1; k < 64; k++) {
|
|
240
|
+
const value = coefficients[k];
|
|
241
|
+
if (value === 0) {
|
|
242
|
+
run++;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
while (run > 15) {
|
|
246
|
+
out.bits(ac.code[0xf0], ac.length[0xf0]);
|
|
247
|
+
run -= 16;
|
|
248
|
+
}
|
|
249
|
+
const bits = category(value);
|
|
250
|
+
const symbol = (run << 4) | bits;
|
|
251
|
+
out.bits(ac.code[symbol], ac.length[symbol]);
|
|
252
|
+
out.bits(magnitude(value, bits), bits);
|
|
253
|
+
run = 0;
|
|
254
|
+
}
|
|
255
|
+
if (run > 0) {
|
|
256
|
+
out.bits(ac.code[0], ac.length[0]);
|
|
257
|
+
}
|
|
258
|
+
return coefficients[0];
|
|
259
|
+
}
|
|
260
|
+
function category(value) {
|
|
261
|
+
let size = 0;
|
|
262
|
+
for (let magnitude = Math.abs(value); magnitude > 0; magnitude >>= 1) {
|
|
263
|
+
size++;
|
|
264
|
+
}
|
|
265
|
+
return size;
|
|
266
|
+
}
|
|
267
|
+
function magnitude(value, size) {
|
|
268
|
+
return value < 0 ? value + (1 << size) - 1 : value;
|
|
269
|
+
}
|
|
270
|
+
})(JpegEncoder || (exports.JpegEncoder = JpegEncoder = {}));
|
|
271
|
+
//# sourceMappingURL=jpeg-encoder.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** How a picture fits the box it is made for: all of it in the box, or the box filled (the page cuts what is over). */
|
|
2
|
+
export type ThumbnailFit = 'contain' | 'cover';
|
|
3
|
+
/** The box a smaller picture is asked for, in pixels of the device. */
|
|
4
|
+
export interface ThumbnailBox {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
fit: ThumbnailFit;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A smaller picture of a PNG, made without a library: the image read (any color type, 8 or 16 bits, a palette of 1 to 8,
|
|
11
|
+
* not interlaced), averaged down to the box (alpha weighted, so edges keep their colour) and written again, RGB when
|
|
12
|
+
* it is opaque. It yields to the event loop as it reads. Undefined for what it does not read, and for a picture already
|
|
13
|
+
* near the size of the box: then the picture itself is sent.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace PngThumbnail {
|
|
16
|
+
function isPng(bytes: Uint8Array): boolean;
|
|
17
|
+
/** The size a picture of `width` × `height` takes for `box`, never larger than it is. */
|
|
18
|
+
function size(width: number, height: number, box: ThumbnailBox): {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The smaller picture: a PNG, or a JPEG when the picture is opaque and of a photo (its PNG large for its pixels)
|
|
24
|
+
* and the JPEG is smaller.
|
|
25
|
+
*/
|
|
26
|
+
function make(bytes: Uint8Array, box: ThumbnailBox): Promise<{
|
|
27
|
+
bytes: Uint8Array;
|
|
28
|
+
type: 'image/png' | 'image/jpeg';
|
|
29
|
+
} | undefined>;
|
|
30
|
+
/** The pixels of a PNG as RGBA, as `make` reads them; undefined for one it does not read. */
|
|
31
|
+
function read(bytes: Uint8Array): Promise<{
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
rgba: Uint8Array;
|
|
35
|
+
} | undefined>;
|
|
36
|
+
/** RGBA written as a PNG: RGB when every pixel is opaque, each row with the filter that leaves the smallest sums. */
|
|
37
|
+
function encode(rgba: Uint8Array, width: number, height: number): Uint8Array;
|
|
38
|
+
/** A PNG of these chunks, each with its length and CRC. */
|
|
39
|
+
function chunked(parts: readonly [string, Uint8Array][]): Uint8Array;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=png-thumbnail.d.ts.map
|