@finsemble/finsemble-electron-adapter 0.0.0
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/LICENSE +1 -0
- package/README.md +9 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +3 -0
- package/dist/app.js.LICENSE.txt +334 -0
- package/dist/app.js.map +1 -0
- package/dist/deploy/deploymentHelpers.d.ts +46 -0
- package/dist/deploy/installer.d.ts +5 -0
- package/dist/deploy/packageCreator.d.ts +4 -0
- package/dist/e2o.d.ts +2 -0
- package/dist/e2o.js +2 -0
- package/dist/e2o.js.map +1 -0
- package/dist/exports.d.ts +16 -0
- package/dist/exports.js +3 -0
- package/dist/exports.js.LICENSE.txt +334 -0
- package/dist/exports.js.map +1 -0
- package/dist/logger/classes/LoggerMain.d.ts +30 -0
- package/dist/logger/classes/LoggerRenderer.d.ts +11 -0
- package/dist/logger/colorizer.d.ts +2 -0
- package/dist/logger/config.d.ts +12 -0
- package/dist/logger/formatters/basic.d.ts +2 -0
- package/dist/logger/main.d.ts +2 -0
- package/dist/logger/renderer.d.ts +1 -0
- package/dist/logger/transports/winston-daily-rotate-file.d.ts +2 -0
- package/dist/logger/transports/winston-terminal-transport.d.ts +2 -0
- package/dist/logger/types.d.ts +9 -0
- package/dist/main/AffinityGroupManager.d.ts +15 -0
- package/dist/main/BrowserViews.d.ts +39 -0
- package/dist/main/Config.d.ts +16 -0
- package/dist/main/DownloadManager.d.ts +31 -0
- package/dist/main/ExternalApplicationManager.d.ts +42 -0
- package/dist/main/IAB.d.ts +17 -0
- package/dist/main/IAC.d.ts +33 -0
- package/dist/main/Main.d.ts +6 -0
- package/dist/main/MainBus.d.ts +22 -0
- package/dist/main/MainSystem.d.ts +82 -0
- package/dist/main/MainWindow.d.ts +154 -0
- package/dist/main/Manifest.d.ts +13 -0
- package/dist/main/MonitorInfo.d.ts +4 -0
- package/dist/main/PermissionsManager.d.ts +12 -0
- package/dist/main/ScreenCapture.d.ts +7 -0
- package/dist/main/SplashScreen.d.ts +13 -0
- package/dist/main/appDataFolder.d.ts +9 -0
- package/dist/main/autoUpdaterWrapper.d.ts +37 -0
- package/dist/main/contentSecurity.d.ts +17 -0
- package/dist/main/contextMenu.d.ts +2 -0
- package/dist/main/download.d.ts +28 -0
- package/dist/main/getWindowIdentity.d.ts +3 -0
- package/dist/main/listeners.d.ts +7 -0
- package/dist/main/mainStore.d.ts +3 -0
- package/dist/main/preloads.d.ts +8 -0
- package/dist/main/protocolHandler.d.ts +11 -0
- package/dist/main/updateManager.d.ts +20 -0
- package/dist/makeInstaller.d.ts +9 -0
- package/dist/makeInstaller.js +3 -0
- package/dist/makeInstaller.js.LICENSE.txt +12 -0
- package/dist/makeInstaller.js.map +1 -0
- package/dist/permissions/chromePermissions.d.ts +59 -0
- package/dist/permissions/defaultWindowOptions.d.ts +385 -0
- package/dist/render/InterApplicationBus.d.ts +16 -0
- package/dist/render/Notification.d.ts +3 -0
- package/dist/render/RequestHelper.d.ts +23 -0
- package/dist/render/System.d.ts +72 -0
- package/dist/render/Window.d.ts +75 -0
- package/dist/render/renderHelpers.d.ts +1 -0
- package/dist/server/AppD.d.ts +18 -0
- package/dist/server/AppDStaticConfigPlugin.d.ts +8 -0
- package/dist/server/CosaicCloud.d.ts +21 -0
- package/dist/server/Progress.d.ts +26 -0
- package/dist/server/Server.d.ts +18 -0
- package/dist/server/SmartDesktop.d.ts +41 -0
- package/dist/server/SmartDesktopEndpoints.d.ts +106 -0
- package/dist/server/SmartDesktopStaticConfigPlugin.d.ts +10 -0
- package/dist/server/cssUtilities.d.ts +6 -0
- package/dist/server/writeJSON.d.ts +1 -0
- package/dist/startup/e2oLauncher.d.ts +1 -0
- package/dist/startup/runScriptInElectron.d.ts +6 -0
- package/dist/types/types.d.ts +144 -0
- package/dist/util.d.ts +24 -0
- package/exports.js +10 -0
- package/node_modules/electron-ipc-mock/.npmignore +2 -0
- package/node_modules/electron-ipc-mock/.travis.yml +8 -0
- package/node_modules/electron-ipc-mock/LICENSE +19 -0
- package/node_modules/electron-ipc-mock/README.md +42 -0
- package/node_modules/electron-ipc-mock/dist/constants.js +8 -0
- package/node_modules/electron-ipc-mock/dist/electron-ipc-mock.js +56 -0
- package/node_modules/electron-ipc-mock/dist/event.js +25 -0
- package/node_modules/electron-ipc-mock/dist/index.js +22 -0
- package/node_modules/electron-ipc-mock/dist/ipc-main.js +103 -0
- package/node_modules/electron-ipc-mock/dist/ipc-renderer.js +113 -0
- package/node_modules/electron-ipc-mock/dist/pipe.js +40 -0
- package/node_modules/electron-ipc-mock/dist/utils.js +33 -0
- package/node_modules/electron-ipc-mock/package.json +34 -0
- package/node_modules/image-size/LICENSE +9 -0
- package/node_modules/image-size/Readme.md +185 -0
- package/node_modules/image-size/bin/image-size.js +48 -0
- package/node_modules/image-size/dist/detector.d.ts +3 -0
- package/node_modules/image-size/dist/detector.js +30 -0
- package/node_modules/image-size/dist/index.d.ts +11 -0
- package/node_modules/image-size/dist/index.js +123 -0
- package/node_modules/image-size/dist/readUInt.d.ts +4 -0
- package/node_modules/image-size/dist/readUInt.js +11 -0
- package/node_modules/image-size/dist/types/bmp.d.ts +2 -0
- package/node_modules/image-size/dist/types/bmp.js +14 -0
- package/node_modules/image-size/dist/types/cur.d.ts +2 -0
- package/node_modules/image-size/dist/types/cur.js +19 -0
- package/node_modules/image-size/dist/types/dds.d.ts +2 -0
- package/node_modules/image-size/dist/types/dds.js +14 -0
- package/node_modules/image-size/dist/types/gif.d.ts +2 -0
- package/node_modules/image-size/dist/types/gif.js +16 -0
- package/node_modules/image-size/dist/types/icns.d.ts +2 -0
- package/node_modules/image-size/dist/types/icns.js +103 -0
- package/node_modules/image-size/dist/types/ico.d.ts +2 -0
- package/node_modules/image-size/dist/types/ico.js +70 -0
- package/node_modules/image-size/dist/types/interface.d.ts +14 -0
- package/node_modules/image-size/dist/types/interface.js +2 -0
- package/node_modules/image-size/dist/types/j2c.d.ts +2 -0
- package/node_modules/image-size/dist/types/j2c.js +15 -0
- package/node_modules/image-size/dist/types/jp2.d.ts +2 -0
- package/node_modules/image-size/dist/types/jp2.js +58 -0
- package/node_modules/image-size/dist/types/jpg.d.ts +2 -0
- package/node_modules/image-size/dist/types/jpg.js +123 -0
- package/node_modules/image-size/dist/types/ktx.d.ts +2 -0
- package/node_modules/image-size/dist/types/ktx.js +15 -0
- package/node_modules/image-size/dist/types/png.d.ts +2 -0
- package/node_modules/image-size/dist/types/png.js +34 -0
- package/node_modules/image-size/dist/types/pnm.d.ts +2 -0
- package/node_modules/image-size/dist/types/pnm.js +75 -0
- package/node_modules/image-size/dist/types/psd.d.ts +2 -0
- package/node_modules/image-size/dist/types/psd.js +14 -0
- package/node_modules/image-size/dist/types/svg.d.ts +2 -0
- package/node_modules/image-size/dist/types/svg.js +91 -0
- package/node_modules/image-size/dist/types/tga.d.ts +2 -0
- package/node_modules/image-size/dist/types/tga.js +14 -0
- package/node_modules/image-size/dist/types/tiff.d.ts +2 -0
- package/node_modules/image-size/dist/types/tiff.js +97 -0
- package/node_modules/image-size/dist/types/webp.d.ts +2 -0
- package/node_modules/image-size/dist/types/webp.js +58 -0
- package/node_modules/image-size/dist/types.d.ts +20 -0
- package/node_modules/image-size/dist/types.js +40 -0
- package/node_modules/image-size/package.json +68 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/queue/LICENSE +8 -0
- package/node_modules/queue/index.d.ts +173 -0
- package/node_modules/queue/index.js +195 -0
- package/node_modules/queue/package.json +43 -0
- package/node_modules/queue/readme.md +221 -0
- package/package.json +106 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PNG = void 0;
|
|
4
|
+
const pngSignature = 'PNG\r\n\x1a\n';
|
|
5
|
+
const pngImageHeaderChunkName = 'IHDR';
|
|
6
|
+
// Used to detect "fried" png's: http://www.jongware.com/pngdefry.html
|
|
7
|
+
const pngFriedChunkName = 'CgBI';
|
|
8
|
+
exports.PNG = {
|
|
9
|
+
validate(buffer) {
|
|
10
|
+
if (pngSignature === buffer.toString('ascii', 1, 8)) {
|
|
11
|
+
let chunkName = buffer.toString('ascii', 12, 16);
|
|
12
|
+
if (chunkName === pngFriedChunkName) {
|
|
13
|
+
chunkName = buffer.toString('ascii', 28, 32);
|
|
14
|
+
}
|
|
15
|
+
if (chunkName !== pngImageHeaderChunkName) {
|
|
16
|
+
throw new TypeError('Invalid PNG');
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
calculate(buffer) {
|
|
23
|
+
if (buffer.toString('ascii', 12, 16) === pngFriedChunkName) {
|
|
24
|
+
return {
|
|
25
|
+
height: buffer.readUInt32BE(36),
|
|
26
|
+
width: buffer.readUInt32BE(32)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
height: buffer.readUInt32BE(20),
|
|
31
|
+
width: buffer.readUInt32BE(16)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PNM = void 0;
|
|
4
|
+
const PNMTypes = {
|
|
5
|
+
P1: 'pbm/ascii',
|
|
6
|
+
P2: 'pgm/ascii',
|
|
7
|
+
P3: 'ppm/ascii',
|
|
8
|
+
P4: 'pbm',
|
|
9
|
+
P5: 'pgm',
|
|
10
|
+
P6: 'ppm',
|
|
11
|
+
P7: 'pam',
|
|
12
|
+
PF: 'pfm'
|
|
13
|
+
};
|
|
14
|
+
const Signatures = Object.keys(PNMTypes);
|
|
15
|
+
const handlers = {
|
|
16
|
+
default: (lines) => {
|
|
17
|
+
let dimensions = [];
|
|
18
|
+
while (lines.length > 0) {
|
|
19
|
+
const line = lines.shift();
|
|
20
|
+
if (line[0] === '#') {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
dimensions = line.split(' ');
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (dimensions.length === 2) {
|
|
27
|
+
return {
|
|
28
|
+
height: parseInt(dimensions[1], 10),
|
|
29
|
+
width: parseInt(dimensions[0], 10),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new TypeError('Invalid PNM');
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
pam: (lines) => {
|
|
37
|
+
const size = {};
|
|
38
|
+
while (lines.length > 0) {
|
|
39
|
+
const line = lines.shift();
|
|
40
|
+
if (line.length > 16 || line.charCodeAt(0) > 128) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const [key, value] = line.split(' ');
|
|
44
|
+
if (key && value) {
|
|
45
|
+
size[key.toLowerCase()] = parseInt(value, 10);
|
|
46
|
+
}
|
|
47
|
+
if (size.height && size.width) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (size.height && size.width) {
|
|
52
|
+
return {
|
|
53
|
+
height: size.height,
|
|
54
|
+
width: size.width
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new TypeError('Invalid PAM');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.PNM = {
|
|
63
|
+
validate(buffer) {
|
|
64
|
+
const signature = buffer.toString('ascii', 0, 2);
|
|
65
|
+
return Signatures.includes(signature);
|
|
66
|
+
},
|
|
67
|
+
calculate(buffer) {
|
|
68
|
+
const signature = buffer.toString('ascii', 0, 2);
|
|
69
|
+
const type = PNMTypes[signature];
|
|
70
|
+
// TODO: this probably generates garbage. move to a stream based parser
|
|
71
|
+
const lines = buffer.toString('ascii', 3).split(/[\r\n]+/);
|
|
72
|
+
const handler = handlers[type] || handlers.default;
|
|
73
|
+
return handler(lines);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PSD = void 0;
|
|
4
|
+
exports.PSD = {
|
|
5
|
+
validate(buffer) {
|
|
6
|
+
return ('8BPS' === buffer.toString('ascii', 0, 4));
|
|
7
|
+
},
|
|
8
|
+
calculate(buffer) {
|
|
9
|
+
return {
|
|
10
|
+
height: buffer.readUInt32BE(14),
|
|
11
|
+
width: buffer.readUInt32BE(18)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SVG = void 0;
|
|
4
|
+
const svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
|
|
5
|
+
const extractorRegExps = {
|
|
6
|
+
height: /\sheight=(['"])([^%]+?)\1/,
|
|
7
|
+
root: svgReg,
|
|
8
|
+
viewbox: /\sviewBox=(['"])(.+?)\1/i,
|
|
9
|
+
width: /\swidth=(['"])([^%]+?)\1/,
|
|
10
|
+
};
|
|
11
|
+
const INCH_CM = 2.54;
|
|
12
|
+
const units = {
|
|
13
|
+
in: 96,
|
|
14
|
+
cm: 96 / INCH_CM,
|
|
15
|
+
em: 16,
|
|
16
|
+
ex: 8,
|
|
17
|
+
m: 96 / INCH_CM * 100,
|
|
18
|
+
mm: 96 / INCH_CM / 10,
|
|
19
|
+
pc: 96 / 72 / 12,
|
|
20
|
+
pt: 96 / 72,
|
|
21
|
+
px: 1
|
|
22
|
+
};
|
|
23
|
+
const unitsReg = new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join('|')})?$`);
|
|
24
|
+
function parseLength(len) {
|
|
25
|
+
const m = unitsReg.exec(len);
|
|
26
|
+
if (!m) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return Math.round(Number(m[1]) * (units[m[2]] || 1));
|
|
30
|
+
}
|
|
31
|
+
function parseViewbox(viewbox) {
|
|
32
|
+
const bounds = viewbox.split(' ');
|
|
33
|
+
return {
|
|
34
|
+
height: parseLength(bounds[3]),
|
|
35
|
+
width: parseLength(bounds[2])
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function parseAttributes(root) {
|
|
39
|
+
const width = root.match(extractorRegExps.width);
|
|
40
|
+
const height = root.match(extractorRegExps.height);
|
|
41
|
+
const viewbox = root.match(extractorRegExps.viewbox);
|
|
42
|
+
return {
|
|
43
|
+
height: height && parseLength(height[2]),
|
|
44
|
+
viewbox: viewbox && parseViewbox(viewbox[2]),
|
|
45
|
+
width: width && parseLength(width[2]),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function calculateByDimensions(attrs) {
|
|
49
|
+
return {
|
|
50
|
+
height: attrs.height,
|
|
51
|
+
width: attrs.width,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function calculateByViewbox(attrs, viewbox) {
|
|
55
|
+
const ratio = viewbox.width / viewbox.height;
|
|
56
|
+
if (attrs.width) {
|
|
57
|
+
return {
|
|
58
|
+
height: Math.floor(attrs.width / ratio),
|
|
59
|
+
width: attrs.width,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (attrs.height) {
|
|
63
|
+
return {
|
|
64
|
+
height: attrs.height,
|
|
65
|
+
width: Math.floor(attrs.height * ratio),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
height: viewbox.height,
|
|
70
|
+
width: viewbox.width,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.SVG = {
|
|
74
|
+
validate(buffer) {
|
|
75
|
+
const str = String(buffer);
|
|
76
|
+
return svgReg.test(str);
|
|
77
|
+
},
|
|
78
|
+
calculate(buffer) {
|
|
79
|
+
const root = buffer.toString('utf8').match(extractorRegExps.root);
|
|
80
|
+
if (root) {
|
|
81
|
+
const attrs = parseAttributes(root[0]);
|
|
82
|
+
if (attrs.width && attrs.height) {
|
|
83
|
+
return calculateByDimensions(attrs);
|
|
84
|
+
}
|
|
85
|
+
if (attrs.viewbox) {
|
|
86
|
+
return calculateByViewbox(attrs, attrs.viewbox);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
throw new TypeError('Invalid SVG');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TGA = void 0;
|
|
4
|
+
exports.TGA = {
|
|
5
|
+
validate(buffer) {
|
|
6
|
+
return buffer.readUInt16LE(0) === 0 && buffer.readUInt16LE(4) === 0;
|
|
7
|
+
},
|
|
8
|
+
calculate(buffer) {
|
|
9
|
+
return {
|
|
10
|
+
height: buffer.readUInt16LE(14),
|
|
11
|
+
width: buffer.readUInt16LE(12),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TIFF = void 0;
|
|
4
|
+
// based on http://www.compix.com/fileformattif.htm
|
|
5
|
+
// TO-DO: support big-endian as well
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const readUInt_1 = require("../readUInt");
|
|
8
|
+
// Read IFD (image-file-directory) into a buffer
|
|
9
|
+
function readIFD(buffer, filepath, isBigEndian) {
|
|
10
|
+
const ifdOffset = (0, readUInt_1.readUInt)(buffer, 32, 4, isBigEndian);
|
|
11
|
+
// read only till the end of the file
|
|
12
|
+
let bufferSize = 1024;
|
|
13
|
+
const fileSize = fs.statSync(filepath).size;
|
|
14
|
+
if (ifdOffset + bufferSize > fileSize) {
|
|
15
|
+
bufferSize = fileSize - ifdOffset - 10;
|
|
16
|
+
}
|
|
17
|
+
// populate the buffer
|
|
18
|
+
const endBuffer = Buffer.alloc(bufferSize);
|
|
19
|
+
const descriptor = fs.openSync(filepath, 'r');
|
|
20
|
+
fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset);
|
|
21
|
+
fs.closeSync(descriptor);
|
|
22
|
+
return endBuffer.slice(2);
|
|
23
|
+
}
|
|
24
|
+
// TIFF values seem to be messed up on Big-Endian, this helps
|
|
25
|
+
function readValue(buffer, isBigEndian) {
|
|
26
|
+
const low = (0, readUInt_1.readUInt)(buffer, 16, 8, isBigEndian);
|
|
27
|
+
const high = (0, readUInt_1.readUInt)(buffer, 16, 10, isBigEndian);
|
|
28
|
+
return (high << 16) + low;
|
|
29
|
+
}
|
|
30
|
+
// move to the next tag
|
|
31
|
+
function nextTag(buffer) {
|
|
32
|
+
if (buffer.length > 24) {
|
|
33
|
+
return buffer.slice(12);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Extract IFD tags from TIFF metadata
|
|
37
|
+
function extractTags(buffer, isBigEndian) {
|
|
38
|
+
const tags = {};
|
|
39
|
+
let temp = buffer;
|
|
40
|
+
while (temp && temp.length) {
|
|
41
|
+
const code = (0, readUInt_1.readUInt)(temp, 16, 0, isBigEndian);
|
|
42
|
+
const type = (0, readUInt_1.readUInt)(temp, 16, 2, isBigEndian);
|
|
43
|
+
const length = (0, readUInt_1.readUInt)(temp, 32, 4, isBigEndian);
|
|
44
|
+
// 0 means end of IFD
|
|
45
|
+
if (code === 0) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// 256 is width, 257 is height
|
|
50
|
+
// if (code === 256 || code === 257) {
|
|
51
|
+
if (length === 1 && (type === 3 || type === 4)) {
|
|
52
|
+
tags[code] = readValue(temp, isBigEndian);
|
|
53
|
+
}
|
|
54
|
+
// move to the next tag
|
|
55
|
+
temp = nextTag(temp);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return tags;
|
|
59
|
+
}
|
|
60
|
+
// Test if the TIFF is Big Endian or Little Endian
|
|
61
|
+
function determineEndianness(buffer) {
|
|
62
|
+
const signature = buffer.toString('ascii', 0, 2);
|
|
63
|
+
if ('II' === signature) {
|
|
64
|
+
return 'LE';
|
|
65
|
+
}
|
|
66
|
+
else if ('MM' === signature) {
|
|
67
|
+
return 'BE';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const signatures = [
|
|
71
|
+
// '492049', // currently not supported
|
|
72
|
+
'49492a00',
|
|
73
|
+
'4d4d002a', // Big Endian
|
|
74
|
+
// '4d4d002a', // BigTIFF > 4GB. currently not supported
|
|
75
|
+
];
|
|
76
|
+
exports.TIFF = {
|
|
77
|
+
validate(buffer) {
|
|
78
|
+
return signatures.includes(buffer.toString('hex', 0, 4));
|
|
79
|
+
},
|
|
80
|
+
calculate(buffer, filepath) {
|
|
81
|
+
if (!filepath) {
|
|
82
|
+
throw new TypeError('Tiff doesn\'t support buffer');
|
|
83
|
+
}
|
|
84
|
+
// Determine BE/LE
|
|
85
|
+
const isBigEndian = determineEndianness(buffer) === 'BE';
|
|
86
|
+
// read the IFD
|
|
87
|
+
const ifdBuffer = readIFD(buffer, filepath, isBigEndian);
|
|
88
|
+
// extract the tags from the IFD
|
|
89
|
+
const tags = extractTags(ifdBuffer, isBigEndian);
|
|
90
|
+
const width = tags[256];
|
|
91
|
+
const height = tags[257];
|
|
92
|
+
if (!width || !height) {
|
|
93
|
+
throw new TypeError('Invalid Tiff. Missing tags');
|
|
94
|
+
}
|
|
95
|
+
return { height, width };
|
|
96
|
+
}
|
|
97
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WEBP = void 0;
|
|
4
|
+
function calculateExtended(buffer) {
|
|
5
|
+
return {
|
|
6
|
+
height: 1 + buffer.readUIntLE(7, 3),
|
|
7
|
+
width: 1 + buffer.readUIntLE(4, 3)
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function calculateLossless(buffer) {
|
|
11
|
+
return {
|
|
12
|
+
height: 1 + (((buffer[4] & 0xF) << 10) | (buffer[3] << 2) | ((buffer[2] & 0xC0) >> 6)),
|
|
13
|
+
width: 1 + (((buffer[2] & 0x3F) << 8) | buffer[1])
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function calculateLossy(buffer) {
|
|
17
|
+
// `& 0x3fff` returns the last 14 bits
|
|
18
|
+
// TO-DO: include webp scaling in the calculations
|
|
19
|
+
return {
|
|
20
|
+
height: buffer.readInt16LE(8) & 0x3fff,
|
|
21
|
+
width: buffer.readInt16LE(6) & 0x3fff
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.WEBP = {
|
|
25
|
+
validate(buffer) {
|
|
26
|
+
const riffHeader = 'RIFF' === buffer.toString('ascii', 0, 4);
|
|
27
|
+
const webpHeader = 'WEBP' === buffer.toString('ascii', 8, 12);
|
|
28
|
+
const vp8Header = 'VP8' === buffer.toString('ascii', 12, 15);
|
|
29
|
+
return (riffHeader && webpHeader && vp8Header);
|
|
30
|
+
},
|
|
31
|
+
calculate(buffer) {
|
|
32
|
+
const chunkHeader = buffer.toString('ascii', 12, 16);
|
|
33
|
+
buffer = buffer.slice(20, 30);
|
|
34
|
+
// Extended webp stream signature
|
|
35
|
+
if (chunkHeader === 'VP8X') {
|
|
36
|
+
const extendedHeader = buffer[0];
|
|
37
|
+
const validStart = (extendedHeader & 0xc0) === 0;
|
|
38
|
+
const validEnd = (extendedHeader & 0x01) === 0;
|
|
39
|
+
if (validStart && validEnd) {
|
|
40
|
+
return calculateExtended(buffer);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// TODO: breaking change
|
|
44
|
+
throw new TypeError('Invalid WebP');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Lossless webp stream signature
|
|
48
|
+
if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) {
|
|
49
|
+
return calculateLossy(buffer);
|
|
50
|
+
}
|
|
51
|
+
// Lossy webp stream signature
|
|
52
|
+
const signature = buffer.toString('hex', 3, 6);
|
|
53
|
+
if (chunkHeader === 'VP8L' && signature !== '9d012a') {
|
|
54
|
+
return calculateLossless(buffer);
|
|
55
|
+
}
|
|
56
|
+
throw new TypeError('Invalid WebP');
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const typeHandlers: {
|
|
2
|
+
bmp: import("./types/interface").IImage;
|
|
3
|
+
cur: import("./types/interface").IImage;
|
|
4
|
+
dds: import("./types/interface").IImage;
|
|
5
|
+
gif: import("./types/interface").IImage;
|
|
6
|
+
icns: import("./types/interface").IImage;
|
|
7
|
+
ico: import("./types/interface").IImage;
|
|
8
|
+
j2c: import("./types/interface").IImage;
|
|
9
|
+
jp2: import("./types/interface").IImage;
|
|
10
|
+
jpg: import("./types/interface").IImage;
|
|
11
|
+
ktx: import("./types/interface").IImage;
|
|
12
|
+
png: import("./types/interface").IImage;
|
|
13
|
+
pnm: import("./types/interface").IImage;
|
|
14
|
+
psd: import("./types/interface").IImage;
|
|
15
|
+
svg: import("./types/interface").IImage;
|
|
16
|
+
tga: import("./types/interface").IImage;
|
|
17
|
+
tiff: import("./types/interface").IImage;
|
|
18
|
+
webp: import("./types/interface").IImage;
|
|
19
|
+
};
|
|
20
|
+
export declare type imageType = keyof typeof typeHandlers;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typeHandlers = void 0;
|
|
4
|
+
// load all available handlers explicitely for browserify support
|
|
5
|
+
const bmp_1 = require("./types/bmp");
|
|
6
|
+
const cur_1 = require("./types/cur");
|
|
7
|
+
const dds_1 = require("./types/dds");
|
|
8
|
+
const gif_1 = require("./types/gif");
|
|
9
|
+
const icns_1 = require("./types/icns");
|
|
10
|
+
const ico_1 = require("./types/ico");
|
|
11
|
+
const j2c_1 = require("./types/j2c");
|
|
12
|
+
const jp2_1 = require("./types/jp2");
|
|
13
|
+
const jpg_1 = require("./types/jpg");
|
|
14
|
+
const ktx_1 = require("./types/ktx");
|
|
15
|
+
const png_1 = require("./types/png");
|
|
16
|
+
const pnm_1 = require("./types/pnm");
|
|
17
|
+
const psd_1 = require("./types/psd");
|
|
18
|
+
const svg_1 = require("./types/svg");
|
|
19
|
+
const tga_1 = require("./types/tga");
|
|
20
|
+
const tiff_1 = require("./types/tiff");
|
|
21
|
+
const webp_1 = require("./types/webp");
|
|
22
|
+
exports.typeHandlers = {
|
|
23
|
+
bmp: bmp_1.BMP,
|
|
24
|
+
cur: cur_1.CUR,
|
|
25
|
+
dds: dds_1.DDS,
|
|
26
|
+
gif: gif_1.GIF,
|
|
27
|
+
icns: icns_1.ICNS,
|
|
28
|
+
ico: ico_1.ICO,
|
|
29
|
+
j2c: j2c_1.J2C,
|
|
30
|
+
jp2: jp2_1.JP2,
|
|
31
|
+
jpg: jpg_1.JPG,
|
|
32
|
+
ktx: ktx_1.KTX,
|
|
33
|
+
png: png_1.PNG,
|
|
34
|
+
pnm: pnm_1.PNM,
|
|
35
|
+
psd: psd_1.PSD,
|
|
36
|
+
svg: svg_1.SVG,
|
|
37
|
+
tga: tga_1.TGA,
|
|
38
|
+
tiff: tiff_1.TIFF,
|
|
39
|
+
webp: webp_1.WEBP,
|
|
40
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "image-size",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "get dimensions of any image file",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"bin/image-size.js"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=14.0.0"
|
|
13
|
+
},
|
|
14
|
+
"bin": "bin/image-size.js",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"pretest": "eslint --ext .ts,.js bin lib specs",
|
|
17
|
+
"test": "nyc mocha",
|
|
18
|
+
"clean": "rm -rf dist docs",
|
|
19
|
+
"generate-docs": "typedoc",
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"prepack": "yarn clean && yarn build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"image",
|
|
25
|
+
"size",
|
|
26
|
+
"dimensions",
|
|
27
|
+
"resolution",
|
|
28
|
+
"width",
|
|
29
|
+
"height",
|
|
30
|
+
"png",
|
|
31
|
+
"jpeg",
|
|
32
|
+
"bmp",
|
|
33
|
+
"gif",
|
|
34
|
+
"psd",
|
|
35
|
+
"tga",
|
|
36
|
+
"tiff",
|
|
37
|
+
"webp",
|
|
38
|
+
"svg",
|
|
39
|
+
"icns",
|
|
40
|
+
"ico",
|
|
41
|
+
"cur"
|
|
42
|
+
],
|
|
43
|
+
"repository": "git://github.com/image-size/image-size.git",
|
|
44
|
+
"author": "netroy <aditya@netroy.in> (http://netroy.in/)",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/chai": "4.3.1",
|
|
48
|
+
"@types/glob": "7.2.0",
|
|
49
|
+
"@types/mocha": "9.1.1",
|
|
50
|
+
"@types/node": "18.0.3",
|
|
51
|
+
"@types/sinon": "10.0.12",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "5.30.6",
|
|
53
|
+
"@typescript-eslint/parser": "5.30.6",
|
|
54
|
+
"chai": "4.3.6",
|
|
55
|
+
"eslint": "8.19.0",
|
|
56
|
+
"glob": "8.0.3",
|
|
57
|
+
"mocha": "10.0.0",
|
|
58
|
+
"nyc": "15.1.0",
|
|
59
|
+
"sinon": "14.0.0",
|
|
60
|
+
"ts-node": "10.8.2",
|
|
61
|
+
"typedoc": "0.23.7",
|
|
62
|
+
"typescript": "4.7.4"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"queue": "6.0.2"
|
|
66
|
+
},
|
|
67
|
+
"packageManager": "yarn@3.2.0"
|
|
68
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
The ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Isaac Z. Schlueter
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
11
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Browser-friendly inheritance fully compatible with standard node.js
|
|
2
|
+
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
|
|
3
|
+
|
|
4
|
+
This package exports standard `inherits` from node.js `util` module in
|
|
5
|
+
node environment, but also provides alternative browser-friendly
|
|
6
|
+
implementation through [browser
|
|
7
|
+
field](https://gist.github.com/shtylman/4339901). Alternative
|
|
8
|
+
implementation is a literal copy of standard one located in standalone
|
|
9
|
+
module to avoid requiring of `util`. It also has a shim for old
|
|
10
|
+
browsers with no `Object.create` support.
|
|
11
|
+
|
|
12
|
+
While keeping you sure you are using standard `inherits`
|
|
13
|
+
implementation in node.js environment, it allows bundlers such as
|
|
14
|
+
[browserify](https://github.com/substack/node-browserify) to not
|
|
15
|
+
include full `util` package to your client code if all you need is
|
|
16
|
+
just `inherits` function. It worth, because browser shim for `util`
|
|
17
|
+
package is large and `inherits` is often the single function you need
|
|
18
|
+
from it.
|
|
19
|
+
|
|
20
|
+
It's recommended to use this package instead of
|
|
21
|
+
`require('util').inherits` for any code that has chances to be used
|
|
22
|
+
not only in node.js but in browser too.
|
|
23
|
+
|
|
24
|
+
## usage
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
var inherits = require('inherits');
|
|
28
|
+
// then use exactly as the standard one
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## note on version ~1.0
|
|
32
|
+
|
|
33
|
+
Version ~1.0 had completely different motivation and is not compatible
|
|
34
|
+
neither with 2.0 nor with standard node.js `inherits`.
|
|
35
|
+
|
|
36
|
+
If you are using version ~1.0 and planning to switch to ~2.0, be
|
|
37
|
+
careful:
|
|
38
|
+
|
|
39
|
+
* new version uses `super_` instead of `super` for referencing
|
|
40
|
+
superclass
|
|
41
|
+
* new version overwrites current prototype while old one preserves any
|
|
42
|
+
existing fields on it
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
if (typeof Object.create === 'function') {
|
|
2
|
+
// implementation from standard node.js 'util' module
|
|
3
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
4
|
+
if (superCtor) {
|
|
5
|
+
ctor.super_ = superCtor
|
|
6
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
7
|
+
constructor: {
|
|
8
|
+
value: ctor,
|
|
9
|
+
enumerable: false,
|
|
10
|
+
writable: true,
|
|
11
|
+
configurable: true
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
} else {
|
|
17
|
+
// old school shim for old browsers
|
|
18
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
19
|
+
if (superCtor) {
|
|
20
|
+
ctor.super_ = superCtor
|
|
21
|
+
var TempCtor = function () {}
|
|
22
|
+
TempCtor.prototype = superCtor.prototype
|
|
23
|
+
ctor.prototype = new TempCtor()
|
|
24
|
+
ctor.prototype.constructor = ctor
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "inherits",
|
|
3
|
+
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
|
|
4
|
+
"version": "2.0.4",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"inheritance",
|
|
7
|
+
"class",
|
|
8
|
+
"klass",
|
|
9
|
+
"oop",
|
|
10
|
+
"object-oriented",
|
|
11
|
+
"inherits",
|
|
12
|
+
"browser",
|
|
13
|
+
"browserify"
|
|
14
|
+
],
|
|
15
|
+
"main": "./inherits.js",
|
|
16
|
+
"browser": "./inherits_browser.js",
|
|
17
|
+
"repository": "git://github.com/isaacs/inherits",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "tap"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"tap": "^14.2.4"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"inherits.js",
|
|
27
|
+
"inherits_browser.js"
|
|
28
|
+
]
|
|
29
|
+
}
|