@finsemble/finsemble-electron-adapter 1.0.0-beta-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.
Files changed (146) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +46 -0
  3. package/dist/app.js +3 -0
  4. package/dist/app.js.LICENSE.txt +331 -0
  5. package/dist/app.js.map +1 -0
  6. package/dist/e2o.js +2 -0
  7. package/dist/e2o.js.map +1 -0
  8. package/dist/exports.js +3 -0
  9. package/dist/exports.js.LICENSE.txt +331 -0
  10. package/dist/exports.js.map +1 -0
  11. package/exports.js +10 -0
  12. package/node_modules/electron-ipc-mock/.npmignore +2 -0
  13. package/node_modules/electron-ipc-mock/.travis.yml +8 -0
  14. package/node_modules/electron-ipc-mock/LICENSE +19 -0
  15. package/node_modules/electron-ipc-mock/README.md +42 -0
  16. package/node_modules/electron-ipc-mock/dist/constants.js +8 -0
  17. package/node_modules/electron-ipc-mock/dist/electron-ipc-mock.js +56 -0
  18. package/node_modules/electron-ipc-mock/dist/event.js +25 -0
  19. package/node_modules/electron-ipc-mock/dist/index.js +22 -0
  20. package/node_modules/electron-ipc-mock/dist/ipc-main.js +103 -0
  21. package/node_modules/electron-ipc-mock/dist/ipc-renderer.js +113 -0
  22. package/node_modules/electron-ipc-mock/dist/pipe.js +40 -0
  23. package/node_modules/electron-ipc-mock/dist/utils.js +33 -0
  24. package/node_modules/electron-ipc-mock/package.json +34 -0
  25. package/node_modules/image-size/LICENSE +9 -0
  26. package/node_modules/image-size/Readme.md +182 -0
  27. package/node_modules/image-size/bin/image-size.js +48 -0
  28. package/node_modules/image-size/dist/detector.d.ts +3 -0
  29. package/node_modules/image-size/dist/detector.js +30 -0
  30. package/node_modules/image-size/dist/index.d.ts +11 -0
  31. package/node_modules/image-size/dist/index.js +134 -0
  32. package/node_modules/image-size/dist/readUInt.d.ts +4 -0
  33. package/node_modules/image-size/dist/readUInt.js +11 -0
  34. package/node_modules/image-size/dist/types/bmp.d.ts +2 -0
  35. package/node_modules/image-size/dist/types/bmp.js +14 -0
  36. package/node_modules/image-size/dist/types/cur.d.ts +2 -0
  37. package/node_modules/image-size/dist/types/cur.js +16 -0
  38. package/node_modules/image-size/dist/types/dds.d.ts +2 -0
  39. package/node_modules/image-size/dist/types/dds.js +14 -0
  40. package/node_modules/image-size/dist/types/gif.d.ts +2 -0
  41. package/node_modules/image-size/dist/types/gif.js +16 -0
  42. package/node_modules/image-size/dist/types/icns.d.ts +2 -0
  43. package/node_modules/image-size/dist/types/icns.js +103 -0
  44. package/node_modules/image-size/dist/types/ico.d.ts +2 -0
  45. package/node_modules/image-size/dist/types/ico.js +67 -0
  46. package/node_modules/image-size/dist/types/interface.d.ts +14 -0
  47. package/node_modules/image-size/dist/types/interface.js +2 -0
  48. package/node_modules/image-size/dist/types/j2c.d.ts +2 -0
  49. package/node_modules/image-size/dist/types/j2c.js +15 -0
  50. package/node_modules/image-size/dist/types/jp2.d.ts +2 -0
  51. package/node_modules/image-size/dist/types/jp2.js +58 -0
  52. package/node_modules/image-size/dist/types/jpg.d.ts +2 -0
  53. package/node_modules/image-size/dist/types/jpg.js +123 -0
  54. package/node_modules/image-size/dist/types/ktx.d.ts +2 -0
  55. package/node_modules/image-size/dist/types/ktx.js +15 -0
  56. package/node_modules/image-size/dist/types/png.d.ts +2 -0
  57. package/node_modules/image-size/dist/types/png.js +34 -0
  58. package/node_modules/image-size/dist/types/pnm.d.ts +2 -0
  59. package/node_modules/image-size/dist/types/pnm.js +75 -0
  60. package/node_modules/image-size/dist/types/psd.d.ts +2 -0
  61. package/node_modules/image-size/dist/types/psd.js +14 -0
  62. package/node_modules/image-size/dist/types/svg.d.ts +2 -0
  63. package/node_modules/image-size/dist/types/svg.js +91 -0
  64. package/node_modules/image-size/dist/types/tiff.d.ts +2 -0
  65. package/node_modules/image-size/dist/types/tiff.js +97 -0
  66. package/node_modules/image-size/dist/types/webp.d.ts +2 -0
  67. package/node_modules/image-size/dist/types/webp.js +58 -0
  68. package/node_modules/image-size/dist/types.d.ts +19 -0
  69. package/node_modules/image-size/dist/types.js +38 -0
  70. package/node_modules/image-size/package.json +67 -0
  71. package/node_modules/inherits/LICENSE +16 -0
  72. package/node_modules/inherits/README.md +42 -0
  73. package/node_modules/inherits/inherits.js +9 -0
  74. package/node_modules/inherits/inherits_browser.js +27 -0
  75. package/node_modules/inherits/package.json +29 -0
  76. package/node_modules/queue/LICENSE +8 -0
  77. package/node_modules/queue/index.d.ts +173 -0
  78. package/node_modules/queue/index.js +195 -0
  79. package/node_modules/queue/package.json +43 -0
  80. package/node_modules/queue/readme.md +221 -0
  81. package/package.json +119 -0
  82. package/types/app.d.ts +1 -0
  83. package/types/deploy/deploymentHelpers.d.ts +10 -0
  84. package/types/deploy/installer.d.ts +5 -0
  85. package/types/deploy/packageCreator.d.ts +4 -0
  86. package/types/deploy/schemas/installer.d.ts +3 -0
  87. package/types/deploy/schemas/packager.d.ts +3 -0
  88. package/types/e2o.d.ts +2 -0
  89. package/types/exports.d.ts +19 -0
  90. package/types/logger/classes/LoggerMain.d.ts +21 -0
  91. package/types/logger/classes/LoggerRenderer.d.ts +11 -0
  92. package/types/logger/colorizer.d.ts +2 -0
  93. package/types/logger/config.d.ts +12 -0
  94. package/types/logger/formatters/basic.d.ts +2 -0
  95. package/types/logger/main.d.ts +2 -0
  96. package/types/logger/renderer.d.ts +1 -0
  97. package/types/logger/transports/winston-daily-rotate-file.d.ts +2 -0
  98. package/types/logger/transports/winston-terminal-transport.d.ts +2 -0
  99. package/types/logger/types.d.ts +9 -0
  100. package/types/main/AffinityGroupManager.d.ts +15 -0
  101. package/types/main/BrowserViews.d.ts +38 -0
  102. package/types/main/ExternalApplicationManager.d.ts +37 -0
  103. package/types/main/IAB.d.ts +17 -0
  104. package/types/main/IAC.d.ts +18 -0
  105. package/types/main/Main.d.ts +7 -0
  106. package/types/main/MainBus.d.ts +22 -0
  107. package/types/main/MainSystem.d.ts +75 -0
  108. package/types/main/MainWindow.d.ts +153 -0
  109. package/types/main/Manifest.d.ts +13 -0
  110. package/types/main/MonitorInfo.d.ts +4 -0
  111. package/types/main/PermissionsManager.d.ts +12 -0
  112. package/types/main/ScreenCapture.d.ts +7 -0
  113. package/types/main/SplashScreen.d.ts +13 -0
  114. package/types/main/appDataFolder.d.ts +9 -0
  115. package/types/main/autoUpdaterWrapper.d.ts +37 -0
  116. package/types/main/contentSecurity.d.ts +17 -0
  117. package/types/main/contextMenu.d.ts +2 -0
  118. package/types/main/download.d.ts +18 -0
  119. package/types/main/getWindowIdentity.d.ts +3 -0
  120. package/types/main/listeners.d.ts +6 -0
  121. package/types/main/mainStore.d.ts +3 -0
  122. package/types/main/preloads.d.ts +9 -0
  123. package/types/main/protocolHandler.d.ts +11 -0
  124. package/types/main/updateManager.d.ts +20 -0
  125. package/types/permissions/chromePermissions.d.ts +59 -0
  126. package/types/permissions/defaultWindowOptions.d.ts +377 -0
  127. package/types/render/InterApplicationBus.d.ts +16 -0
  128. package/types/render/Notification.d.ts +3 -0
  129. package/types/render/RequestHelper.d.ts +23 -0
  130. package/types/render/System.d.ts +62 -0
  131. package/types/render/Window.d.ts +75 -0
  132. package/types/render/renderHelpers.d.ts +1 -0
  133. package/types/server/AppD.d.ts +18 -0
  134. package/types/server/AppDStaticConfigPlugin.d.ts +8 -0
  135. package/types/server/CosaicCloud.d.ts +21 -0
  136. package/types/server/Progress.d.ts +26 -0
  137. package/types/server/Server.d.ts +17 -0
  138. package/types/server/SmartDesktop.d.ts +36 -0
  139. package/types/server/SmartDesktopEndpoints.d.ts +99 -0
  140. package/types/server/SmartDesktopStaticConfigPlugin.d.ts +9 -0
  141. package/types/server/cssUtilities.d.ts +6 -0
  142. package/types/server/writeJSON.d.ts +1 -0
  143. package/types/startup/e2oLauncher.d.ts +1 -0
  144. package/types/startup/runScriptInElectron.d.ts +6 -0
  145. package/types/types/types.d.ts +148 -0
  146. package/types/util.d.ts +13 -0
@@ -0,0 +1,182 @@
1
+ # image-size
2
+
3
+ [![Build Status](https://circleci.com/gh/image-size/image-size.svg?style=shield)](https://circleci.com/gh/image-size/image-size)
4
+ [![Package Version](https://img.shields.io/npm/v/image-size.svg)](https://www.npmjs.com/package/image-size)
5
+ [![Downloads](https://img.shields.io/npm/dm/image-size.svg)](http://npm-stat.com/charts.html?package=image-size&author=&from=&to=)
6
+
7
+ A [Node](https://nodejs.org/en/) module to get dimensions of any image file
8
+
9
+ ## Supported formats
10
+
11
+ * BMP
12
+ * CUR
13
+ * DDS
14
+ * GIF
15
+ * ICNS
16
+ * ICO
17
+ * JPEG
18
+ * KTX
19
+ * PNG
20
+ * PNM (PAM, PBM, PFM, PGM, PPM)
21
+ * PSD
22
+ * SVG
23
+ * TIFF
24
+ * WebP
25
+
26
+ ## Programmatic Usage
27
+
28
+ ```shell
29
+ npm install image-size --save
30
+ ```
31
+
32
+ or
33
+
34
+ ```shell
35
+ yarn add image-size
36
+ ```
37
+
38
+ ### Synchronous
39
+
40
+ ```javascript
41
+ const sizeOf = require('image-size')
42
+ const dimensions = sizeOf('images/funny-cats.png')
43
+ console.log(dimensions.width, dimensions.height)
44
+ ```
45
+
46
+ ### Asynchronous
47
+
48
+ ```javascript
49
+ const sizeOf = require('image-size')
50
+ sizeOf('images/funny-cats.png', function (err, dimensions) {
51
+ console.log(dimensions.width, dimensions.height)
52
+ })
53
+ ```
54
+
55
+ NOTE: The asynchronous version doesn't work if the input is a Buffer. Use synchronous version instead.
56
+
57
+ Also, the asynchronous functions have a default concurrency limit of **100**
58
+ To change this limit, you can call the `setConcurrency` function like this:
59
+
60
+ ```javascript
61
+ const sizeOf = require('image-size')
62
+ sizeOf.setConcurrency(123456)
63
+ ```
64
+
65
+ ### Using promises (nodejs 10.x+)
66
+
67
+ ```javascript
68
+ const { promisify } = require('util')
69
+ const sizeOf = promisify(require('image-size'))
70
+ sizeOf('images/funny-cats.png')
71
+ .then(dimensions => { console.log(dimensions.width, dimensions.height) })
72
+ .catch(err => console.error(err))
73
+ ```
74
+
75
+ ### Async/Await (Typescript & ES7)
76
+
77
+ ```javascript
78
+ const { promisify } = require('util')
79
+ const sizeOf = promisify(require('image-size'))
80
+ (async () => {
81
+ try {
82
+ const dimensions = await sizeOf('images/funny-cats.png')
83
+ console.log(dimensions.width, dimensions.height)
84
+ } catch (err) {
85
+ console.error(err)
86
+ }
87
+ })().then(c => console.log(c))
88
+ ```
89
+
90
+ ### Multi-size
91
+
92
+ If the target file is an icon (.ico) or a cursor (.cur), the `width` and `height` will be the ones of the first found image.
93
+
94
+ An additional `images` array is available and returns the dimensions of all the available images
95
+
96
+ ```javascript
97
+ const sizeOf = require('image-size')
98
+ const images = sizeOf('images/multi-size.ico').images
99
+ for (const dimensions of images) {
100
+ console.log(dimensions.width, dimensions.height)
101
+ }
102
+ ```
103
+
104
+ ### Using a URL
105
+
106
+ ```javascript
107
+ const url = require('url')
108
+ const http = require('http')
109
+
110
+ const sizeOf = require('image-size')
111
+
112
+ const imgUrl = 'http://my-amazing-website.com/image.jpeg'
113
+ const options = url.parse(imgUrl)
114
+
115
+ http.get(options, function (response) {
116
+ const chunks = []
117
+ response.on('data', function (chunk) {
118
+ chunks.push(chunk)
119
+ }).on('end', function() {
120
+ const buffer = Buffer.concat(chunks)
121
+ console.log(sizeOf(buffer))
122
+ })
123
+ })
124
+ ```
125
+
126
+ You can optionally check the buffer lengths & stop downloading the image after a few kilobytes.
127
+ **You don't need to download the entire image**
128
+
129
+ ### Disabling certain image types
130
+ ```javascript
131
+ const imageSize = require('image-size')
132
+ imageSize.disableTypes(['tiff', 'ico'])
133
+ ```
134
+
135
+ ### Disabling all file-system reads
136
+ ```javascript
137
+ const imageSize = require('image-size')
138
+ imageSize.disableFS(true)
139
+ ```
140
+
141
+ ### JPEG image orientation
142
+
143
+ If the orientation is present in the JPEG EXIF metadata, it will be returned by the function. The orientation value is a [number between 1 and 8](https://exiftool.org/TagNames/EXIF.html#:~:text=0x0112,8%20=%20Rotate%20270%20CW) representing a type of orientation.
144
+
145
+ ```javascript
146
+ const sizeOf = require('image-size')
147
+ const dimensions = sizeOf('images/photo.jpeg')
148
+ console.log(dimensions.orientation)
149
+ ```
150
+
151
+ ## Command-Line Usage (CLI)
152
+
153
+ ```shell
154
+ npm install image-size --global
155
+ ```
156
+
157
+ or
158
+
159
+ ```shell
160
+ yarn global add image-size
161
+ ```
162
+
163
+ followed by
164
+
165
+ ```shell
166
+ image-size image1 [image2] [image3] ...
167
+ ```
168
+
169
+ ## Hosted API
170
+
171
+ We also provide a hosted API for image-size which may simplify your use case.
172
+
173
+ <a href="https://image-size.saasify.sh">
174
+ <img src="https://badges.saasify.sh?text=View%20Hosted%20API" height="40"/>
175
+ </a>
176
+
177
+ ## Credits
178
+
179
+ not a direct port, but an attempt to have something like
180
+ [dabble's imagesize](https://github.com/dabble/imagesize/blob/master/lib/image_size.rb) as a node module.
181
+
182
+ ## [Contributors](Contributors.md)
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ const fs = require('fs')
5
+ const path = require('path')
6
+ const { imageSize } = require('..')
7
+
8
+ const files = process.argv.slice(2)
9
+
10
+ if (!files.length) {
11
+ console.error('Usage: image-size image1 [image2] [image3] ...')
12
+ process.exit(-1)
13
+ }
14
+
15
+ const red = ['\x1B[31m', '\x1B[39m']
16
+ // const bold = ['\x1B[1m', '\x1B[22m']
17
+ const grey = ['\x1B[90m', '\x1B[39m']
18
+ const green = ['\x1B[32m', '\x1B[39m']
19
+
20
+ function colorize(text, color) {
21
+ return color[0] + text + color[1]
22
+ }
23
+
24
+ files.forEach(function (image) {
25
+ try {
26
+ if (fs.existsSync(path.resolve(image))) {
27
+ const greyX = colorize('x', grey)
28
+ const greyImage = colorize(image, grey)
29
+ const size = imageSize(image)
30
+ const sizes = size.images || [size]
31
+ sizes.forEach(size => {
32
+ let greyType = ''
33
+ if (size.type) {
34
+ greyType = colorize(' (' + size.type + ')', grey)
35
+ }
36
+ console.info(
37
+ colorize(size.width, green) + greyX + colorize(size.height, green)
38
+ + ' - ' + greyImage + greyType
39
+ )
40
+ })
41
+ } else {
42
+ console.error('file doesn\'t exist - ', image)
43
+ }
44
+ } catch (e) {
45
+ // console.error(e.stack)
46
+ console.error(colorize(e.message, red), '-', image)
47
+ }
48
+ })
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ import { imageType } from './types';
3
+ export declare function detector(buffer: Buffer): imageType | undefined;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detector = void 0;
4
+ const types_1 = require("./types");
5
+ const keys = Object.keys(types_1.typeHandlers);
6
+ // This map helps avoid validating for every single image type
7
+ const firstBytes = {
8
+ 0x38: 'psd',
9
+ 0x42: 'bmp',
10
+ 0x44: 'dds',
11
+ 0x47: 'gif',
12
+ 0x49: 'tiff',
13
+ 0x4d: 'tiff',
14
+ 0x52: 'webp',
15
+ 0x69: 'icns',
16
+ 0x89: 'png',
17
+ 0xff: 'jpg'
18
+ };
19
+ function detector(buffer) {
20
+ const byte = buffer[0];
21
+ if (byte in firstBytes) {
22
+ const type = firstBytes[byte];
23
+ if (type && types_1.typeHandlers[type].validate(buffer)) {
24
+ return type;
25
+ }
26
+ }
27
+ const finder = (key) => types_1.typeHandlers[key].validate(buffer);
28
+ return keys.find(finder);
29
+ }
30
+ exports.detector = detector;
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { imageType } from './types';
3
+ import { ISizeCalculationResult } from './types/interface';
4
+ declare type CallbackFn = (e: Error | null, r?: ISizeCalculationResult) => void;
5
+ export default imageSize;
6
+ export declare function imageSize(input: Buffer | string): ISizeCalculationResult;
7
+ export declare function imageSize(input: string, callback: CallbackFn): void;
8
+ export declare const disableFS: (v: boolean) => void;
9
+ export declare const disableTypes: (types: imageType[]) => void;
10
+ export declare const setConcurrency: (c: number) => void;
11
+ export declare const types: string[];
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.types = exports.setConcurrency = exports.disableTypes = exports.disableFS = exports.imageSize = void 0;
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+ const queue_1 = require("queue");
16
+ const types_1 = require("./types");
17
+ const detector_1 = require("./detector");
18
+ // Maximum buffer size, with a default of 512 kilobytes.
19
+ // TO-DO: make this adaptive based on the initial signature of the image
20
+ const MaxBufferSize = 512 * 1024;
21
+ // This queue is for async `fs` operations, to avoid reaching file-descriptor limits
22
+ const queue = new queue_1.default({ concurrency: 100, autostart: true });
23
+ const globalOptions = {
24
+ disabledFS: false,
25
+ disabledTypes: []
26
+ };
27
+ /**
28
+ * Return size information based on a buffer
29
+ *
30
+ * @param {Buffer} buffer
31
+ * @param {String} filepath
32
+ * @returns {Object}
33
+ */
34
+ function lookup(buffer, filepath) {
35
+ // detect the file type.. don't rely on the extension
36
+ const type = (0, detector_1.detector)(buffer);
37
+ if (typeof type !== 'undefined') {
38
+ if (globalOptions.disabledTypes.indexOf(type) > -1) {
39
+ throw new TypeError('disabled file type: ' + type);
40
+ }
41
+ // find an appropriate handler for this file type
42
+ if (type in types_1.typeHandlers) {
43
+ const size = types_1.typeHandlers[type].calculate(buffer, filepath);
44
+ if (size !== undefined) {
45
+ size.type = type;
46
+ return size;
47
+ }
48
+ }
49
+ }
50
+ // throw up, if we don't understand the file
51
+ throw new TypeError('unsupported file type: ' + type + ' (file: ' + filepath + ')');
52
+ }
53
+ /**
54
+ * Reads a file into a buffer.
55
+ * @param {String} filepath
56
+ * @returns {Promise<Buffer>}
57
+ */
58
+ function asyncFileToBuffer(filepath) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const handle = yield fs.promises.open(filepath, 'r');
61
+ try {
62
+ const { size } = yield handle.stat();
63
+ if (size <= 0) {
64
+ throw new Error('Empty file');
65
+ }
66
+ const bufferSize = Math.min(size, MaxBufferSize);
67
+ const buffer = Buffer.alloc(bufferSize);
68
+ yield handle.read(buffer, 0, bufferSize, 0);
69
+ return buffer;
70
+ }
71
+ finally {
72
+ yield handle.close();
73
+ }
74
+ });
75
+ }
76
+ /**
77
+ * Synchronously reads a file into a buffer, blocking the nodejs process.
78
+ *
79
+ * @param {String} filepath
80
+ * @returns {Buffer}
81
+ */
82
+ function syncFileToBuffer(filepath) {
83
+ // read from the file, synchronously
84
+ const descriptor = fs.openSync(filepath, 'r');
85
+ try {
86
+ const { size } = fs.fstatSync(descriptor);
87
+ if (size <= 0) {
88
+ throw new Error('Empty file');
89
+ }
90
+ const bufferSize = Math.min(size, MaxBufferSize);
91
+ const buffer = Buffer.alloc(bufferSize);
92
+ fs.readSync(descriptor, buffer, 0, bufferSize, 0);
93
+ return buffer;
94
+ }
95
+ finally {
96
+ fs.closeSync(descriptor);
97
+ }
98
+ }
99
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
100
+ module.exports = exports = imageSize; // backwards compatibility
101
+ exports.default = imageSize;
102
+ /**
103
+ * @param {Buffer|string} input - buffer or relative/absolute path of the image file
104
+ * @param {Function=} [callback] - optional function for async detection
105
+ */
106
+ function imageSize(input, callback) {
107
+ // Handle buffer input
108
+ if (Buffer.isBuffer(input)) {
109
+ return lookup(input);
110
+ }
111
+ // input should be a string at this point
112
+ if (typeof input !== 'string' || globalOptions.disabledFS) {
113
+ throw new TypeError('invalid invocation. input should be a Buffer');
114
+ }
115
+ // resolve the file path
116
+ const filepath = path.resolve(input);
117
+ if (typeof callback === 'function') {
118
+ queue.push(() => asyncFileToBuffer(filepath)
119
+ .then((buffer) => process.nextTick(callback, null, lookup(buffer, filepath)))
120
+ .catch(callback));
121
+ }
122
+ else {
123
+ const buffer = syncFileToBuffer(filepath);
124
+ return lookup(buffer, filepath);
125
+ }
126
+ }
127
+ exports.imageSize = imageSize;
128
+ const disableFS = (v) => { globalOptions.disabledFS = v; };
129
+ exports.disableFS = disableFS;
130
+ const disableTypes = (types) => { globalOptions.disabledTypes = types; };
131
+ exports.disableTypes = disableTypes;
132
+ const setConcurrency = (c) => { queue.concurrency = c; };
133
+ exports.setConcurrency = setConcurrency;
134
+ exports.types = Object.keys(types_1.typeHandlers);
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ declare type Bits = 16 | 32;
3
+ export declare function readUInt(buffer: Buffer, bits: Bits, offset: number, isBigEndian: boolean): number;
4
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readUInt = void 0;
4
+ // Abstract reading multi-byte unsigned integers
5
+ function readUInt(buffer, bits, offset, isBigEndian) {
6
+ offset = offset || 0;
7
+ const endian = isBigEndian ? 'BE' : 'LE';
8
+ const methodName = ('readUInt' + bits + endian);
9
+ return buffer[methodName].call(buffer, offset);
10
+ }
11
+ exports.readUInt = readUInt;
@@ -0,0 +1,2 @@
1
+ import { IImage } from './interface';
2
+ export declare const BMP: IImage;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BMP = void 0;
4
+ exports.BMP = {
5
+ validate(buffer) {
6
+ return ('BM' === buffer.toString('ascii', 0, 2));
7
+ },
8
+ calculate(buffer) {
9
+ return {
10
+ height: Math.abs(buffer.readInt32LE(22)),
11
+ width: buffer.readUInt32LE(18)
12
+ };
13
+ }
14
+ };
@@ -0,0 +1,2 @@
1
+ import { IImage } from './interface';
2
+ export declare const CUR: IImage;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CUR = void 0;
4
+ const ico_1 = require("./ico");
5
+ const TYPE_CURSOR = 2;
6
+ exports.CUR = {
7
+ validate(buffer) {
8
+ if (buffer.readUInt16LE(0) !== 0) {
9
+ return false;
10
+ }
11
+ return buffer.readUInt16LE(2) === TYPE_CURSOR;
12
+ },
13
+ calculate(buffer) {
14
+ return ico_1.ICO.calculate(buffer);
15
+ }
16
+ };
@@ -0,0 +1,2 @@
1
+ import { IImage } from './interface';
2
+ export declare const DDS: IImage;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DDS = void 0;
4
+ exports.DDS = {
5
+ validate(buffer) {
6
+ return buffer.readUInt32LE(0) === 0x20534444;
7
+ },
8
+ calculate(buffer) {
9
+ return {
10
+ height: buffer.readUInt32LE(12),
11
+ width: buffer.readUInt32LE(16)
12
+ };
13
+ }
14
+ };
@@ -0,0 +1,2 @@
1
+ import { IImage } from './interface';
2
+ export declare const GIF: IImage;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GIF = void 0;
4
+ const gifRegexp = /^GIF8[79]a/;
5
+ exports.GIF = {
6
+ validate(buffer) {
7
+ const signature = buffer.toString('ascii', 0, 6);
8
+ return (gifRegexp.test(signature));
9
+ },
10
+ calculate(buffer) {
11
+ return {
12
+ height: buffer.readUInt16LE(8),
13
+ width: buffer.readUInt16LE(6)
14
+ };
15
+ }
16
+ };
@@ -0,0 +1,2 @@
1
+ import { IImage } from './interface';
2
+ export declare const ICNS: IImage;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ICNS = void 0;
4
+ /**
5
+ * ICNS Header
6
+ *
7
+ * | Offset | Size | Purpose |
8
+ * | 0 | 4 | Magic literal, must be "icns" (0x69, 0x63, 0x6e, 0x73) |
9
+ * | 4 | 4 | Length of file, in bytes, msb first. |
10
+ *
11
+ */
12
+ const SIZE_HEADER = 4 + 4; // 8
13
+ const FILE_LENGTH_OFFSET = 4; // MSB => BIG ENDIAN
14
+ /**
15
+ * Image Entry
16
+ *
17
+ * | Offset | Size | Purpose |
18
+ * | 0 | 4 | Icon type, see OSType below. |
19
+ * | 4 | 4 | Length of data, in bytes (including type and length), msb first. |
20
+ * | 8 | n | Icon data |
21
+ */
22
+ const ENTRY_LENGTH_OFFSET = 4; // MSB => BIG ENDIAN
23
+ const ICON_TYPE_SIZE = {
24
+ ICON: 32,
25
+ 'ICN#': 32,
26
+ // m => 16 x 16
27
+ 'icm#': 16,
28
+ icm4: 16,
29
+ icm8: 16,
30
+ // s => 16 x 16
31
+ 'ics#': 16,
32
+ ics4: 16,
33
+ ics8: 16,
34
+ is32: 16,
35
+ s8mk: 16,
36
+ icp4: 16,
37
+ // l => 32 x 32
38
+ icl4: 32,
39
+ icl8: 32,
40
+ il32: 32,
41
+ l8mk: 32,
42
+ icp5: 32,
43
+ ic11: 32,
44
+ // h => 48 x 48
45
+ ich4: 48,
46
+ ich8: 48,
47
+ ih32: 48,
48
+ h8mk: 48,
49
+ // . => 64 x 64
50
+ icp6: 64,
51
+ ic12: 32,
52
+ // t => 128 x 128
53
+ it32: 128,
54
+ t8mk: 128,
55
+ ic07: 128,
56
+ // . => 256 x 256
57
+ ic08: 256,
58
+ ic13: 256,
59
+ // . => 512 x 512
60
+ ic09: 512,
61
+ ic14: 512,
62
+ // . => 1024 x 1024
63
+ ic10: 1024,
64
+ };
65
+ function readImageHeader(buffer, imageOffset) {
66
+ const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET;
67
+ return [
68
+ buffer.toString('ascii', imageOffset, imageLengthOffset),
69
+ buffer.readUInt32BE(imageLengthOffset)
70
+ ];
71
+ }
72
+ function getImageSize(type) {
73
+ const size = ICON_TYPE_SIZE[type];
74
+ return { width: size, height: size, type };
75
+ }
76
+ exports.ICNS = {
77
+ validate(buffer) {
78
+ return ('icns' === buffer.toString('ascii', 0, 4));
79
+ },
80
+ calculate(buffer) {
81
+ const bufferLength = buffer.length;
82
+ const fileLength = buffer.readUInt32BE(FILE_LENGTH_OFFSET);
83
+ let imageOffset = SIZE_HEADER;
84
+ let imageHeader = readImageHeader(buffer, imageOffset);
85
+ let imageSize = getImageSize(imageHeader[0]);
86
+ imageOffset += imageHeader[1];
87
+ if (imageOffset === fileLength) {
88
+ return imageSize;
89
+ }
90
+ const result = {
91
+ height: imageSize.height,
92
+ images: [imageSize],
93
+ width: imageSize.width
94
+ };
95
+ while (imageOffset < fileLength && imageOffset < bufferLength) {
96
+ imageHeader = readImageHeader(buffer, imageOffset);
97
+ imageSize = getImageSize(imageHeader[0]);
98
+ imageOffset += imageHeader[1];
99
+ result.images.push(imageSize);
100
+ }
101
+ return result;
102
+ }
103
+ };
@@ -0,0 +1,2 @@
1
+ import { IImage } from './interface';
2
+ export declare const ICO: IImage;