@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.
- package/LICENSE +1 -0
- package/README.md +46 -0
- package/dist/app.js +3 -0
- package/dist/app.js.LICENSE.txt +331 -0
- package/dist/app.js.map +1 -0
- package/dist/e2o.js +2 -0
- package/dist/e2o.js.map +1 -0
- package/dist/exports.js +3 -0
- package/dist/exports.js.LICENSE.txt +331 -0
- package/dist/exports.js.map +1 -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 +182 -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 +134 -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 +16 -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 +67 -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/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 +19 -0
- package/node_modules/image-size/dist/types.js +38 -0
- package/node_modules/image-size/package.json +67 -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 +119 -0
- package/types/app.d.ts +1 -0
- package/types/deploy/deploymentHelpers.d.ts +10 -0
- package/types/deploy/installer.d.ts +5 -0
- package/types/deploy/packageCreator.d.ts +4 -0
- package/types/deploy/schemas/installer.d.ts +3 -0
- package/types/deploy/schemas/packager.d.ts +3 -0
- package/types/e2o.d.ts +2 -0
- package/types/exports.d.ts +19 -0
- package/types/logger/classes/LoggerMain.d.ts +21 -0
- package/types/logger/classes/LoggerRenderer.d.ts +11 -0
- package/types/logger/colorizer.d.ts +2 -0
- package/types/logger/config.d.ts +12 -0
- package/types/logger/formatters/basic.d.ts +2 -0
- package/types/logger/main.d.ts +2 -0
- package/types/logger/renderer.d.ts +1 -0
- package/types/logger/transports/winston-daily-rotate-file.d.ts +2 -0
- package/types/logger/transports/winston-terminal-transport.d.ts +2 -0
- package/types/logger/types.d.ts +9 -0
- package/types/main/AffinityGroupManager.d.ts +15 -0
- package/types/main/BrowserViews.d.ts +38 -0
- package/types/main/ExternalApplicationManager.d.ts +37 -0
- package/types/main/IAB.d.ts +17 -0
- package/types/main/IAC.d.ts +18 -0
- package/types/main/Main.d.ts +7 -0
- package/types/main/MainBus.d.ts +22 -0
- package/types/main/MainSystem.d.ts +75 -0
- package/types/main/MainWindow.d.ts +153 -0
- package/types/main/Manifest.d.ts +13 -0
- package/types/main/MonitorInfo.d.ts +4 -0
- package/types/main/PermissionsManager.d.ts +12 -0
- package/types/main/ScreenCapture.d.ts +7 -0
- package/types/main/SplashScreen.d.ts +13 -0
- package/types/main/appDataFolder.d.ts +9 -0
- package/types/main/autoUpdaterWrapper.d.ts +37 -0
- package/types/main/contentSecurity.d.ts +17 -0
- package/types/main/contextMenu.d.ts +2 -0
- package/types/main/download.d.ts +18 -0
- package/types/main/getWindowIdentity.d.ts +3 -0
- package/types/main/listeners.d.ts +6 -0
- package/types/main/mainStore.d.ts +3 -0
- package/types/main/preloads.d.ts +9 -0
- package/types/main/protocolHandler.d.ts +11 -0
- package/types/main/updateManager.d.ts +20 -0
- package/types/permissions/chromePermissions.d.ts +59 -0
- package/types/permissions/defaultWindowOptions.d.ts +377 -0
- package/types/render/InterApplicationBus.d.ts +16 -0
- package/types/render/Notification.d.ts +3 -0
- package/types/render/RequestHelper.d.ts +23 -0
- package/types/render/System.d.ts +62 -0
- package/types/render/Window.d.ts +75 -0
- package/types/render/renderHelpers.d.ts +1 -0
- package/types/server/AppD.d.ts +18 -0
- package/types/server/AppDStaticConfigPlugin.d.ts +8 -0
- package/types/server/CosaicCloud.d.ts +21 -0
- package/types/server/Progress.d.ts +26 -0
- package/types/server/Server.d.ts +17 -0
- package/types/server/SmartDesktop.d.ts +36 -0
- package/types/server/SmartDesktopEndpoints.d.ts +99 -0
- package/types/server/SmartDesktopStaticConfigPlugin.d.ts +9 -0
- package/types/server/cssUtilities.d.ts +6 -0
- package/types/server/writeJSON.d.ts +1 -0
- package/types/startup/e2oLauncher.d.ts +1 -0
- package/types/startup/runScriptInElectron.d.ts +6 -0
- package/types/types/types.d.ts +148 -0
- package/types/util.d.ts +13 -0
|
@@ -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,19 @@
|
|
|
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
|
+
tiff: import("./types/interface").IImage;
|
|
17
|
+
webp: import("./types/interface").IImage;
|
|
18
|
+
};
|
|
19
|
+
export declare type imageType = keyof typeof typeHandlers;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 tiff_1 = require("./types/tiff");
|
|
20
|
+
const webp_1 = require("./types/webp");
|
|
21
|
+
exports.typeHandlers = {
|
|
22
|
+
bmp: bmp_1.BMP,
|
|
23
|
+
cur: cur_1.CUR,
|
|
24
|
+
dds: dds_1.DDS,
|
|
25
|
+
gif: gif_1.GIF,
|
|
26
|
+
icns: icns_1.ICNS,
|
|
27
|
+
ico: ico_1.ICO,
|
|
28
|
+
j2c: j2c_1.J2C,
|
|
29
|
+
jp2: jp2_1.JP2,
|
|
30
|
+
jpg: jpg_1.JPG,
|
|
31
|
+
ktx: ktx_1.KTX,
|
|
32
|
+
png: png_1.PNG,
|
|
33
|
+
pnm: pnm_1.PNM,
|
|
34
|
+
psd: psd_1.PSD,
|
|
35
|
+
svg: svg_1.SVG,
|
|
36
|
+
tiff: tiff_1.TIFF,
|
|
37
|
+
webp: webp_1.WEBP,
|
|
38
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "image-size",
|
|
3
|
+
"version": "1.0.1",
|
|
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": ">=12.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
|
+
"tiff",
|
|
36
|
+
"webp",
|
|
37
|
+
"svg",
|
|
38
|
+
"icns",
|
|
39
|
+
"ico",
|
|
40
|
+
"cur"
|
|
41
|
+
],
|
|
42
|
+
"repository": "git://github.com/image-size/image-size.git",
|
|
43
|
+
"author": "netroy <aditya@netroy.in> (http://netroy.in/)",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/chai": "4.3.0",
|
|
47
|
+
"@types/glob": "7.2.0",
|
|
48
|
+
"@types/mocha": "9.0.0",
|
|
49
|
+
"@types/node": "17.0.8",
|
|
50
|
+
"@types/sinon": "10.0.6",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "5.9.1",
|
|
52
|
+
"@typescript-eslint/parser": "5.9.1",
|
|
53
|
+
"chai": "4.3.4",
|
|
54
|
+
"eslint": "8.6.0",
|
|
55
|
+
"glob": "7.2.0",
|
|
56
|
+
"mocha": "9.1.3",
|
|
57
|
+
"nyc": "15.1.0",
|
|
58
|
+
"sinon": "12.0.1",
|
|
59
|
+
"ts-node": "10.4.0",
|
|
60
|
+
"typedoc": "0.22.10",
|
|
61
|
+
"typescript": "4.5.4"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"queue": "6.0.2"
|
|
65
|
+
},
|
|
66
|
+
"packageManager": "yarn@3.1.1"
|
|
67
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2014 Jesse Tane <jesse.tane@gmail.com>
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Type definitions for Queue 4.5.1
|
|
2
|
+
// Project: https://github.com/jessetane/queue
|
|
3
|
+
// Definitions by: Alex Miller <https://github.com/codex->
|
|
4
|
+
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
|
|
7
|
+
export interface Options {
|
|
8
|
+
/**
|
|
9
|
+
* Max number of jobs the queue should process concurrently.
|
|
10
|
+
*
|
|
11
|
+
* @default Infinity
|
|
12
|
+
*/
|
|
13
|
+
concurrency?: number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Milliseconds to wait for a job to execute its callback.
|
|
17
|
+
*
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
timeout?: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
autostart?: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An array to set job callback arguments on.
|
|
31
|
+
*
|
|
32
|
+
* @default null
|
|
33
|
+
*/
|
|
34
|
+
results?: any[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Queue extends EventEmitter {
|
|
38
|
+
/**
|
|
39
|
+
* Max number of jobs the queue should process concurrently.
|
|
40
|
+
*/
|
|
41
|
+
concurrency: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Milliseconds to wait for a job to execute its callback.
|
|
45
|
+
*/
|
|
46
|
+
timeout: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Ensures the queue is always running if jobs are available.
|
|
50
|
+
*/
|
|
51
|
+
autostart: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* An array to set job callback arguments on.
|
|
55
|
+
*/
|
|
56
|
+
results: any[] | null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Jobs pending + jobs to process.
|
|
60
|
+
*/
|
|
61
|
+
readonly length: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Adds one or more elements to the end of the Queue and returns the new length of the Queue.
|
|
65
|
+
*
|
|
66
|
+
* @param workers New workers of the Queue.
|
|
67
|
+
*/
|
|
68
|
+
push(...workers: QueueWorker[]): number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Adds one or more elements to the front of the Queue and returns the new length of the Queue.
|
|
72
|
+
*
|
|
73
|
+
* @param workers Workers to insert at the start of the Queue.
|
|
74
|
+
*/
|
|
75
|
+
unshift(...workers: QueueWorker[]): number;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Adds and/or removes elements from the queue.
|
|
79
|
+
*
|
|
80
|
+
* @param start The zero-based location in the Queue from which to start removing elements.
|
|
81
|
+
* @param deleteCount The number of elements to remove.
|
|
82
|
+
*/
|
|
83
|
+
splice(start: number, deleteCount?: number): Queue;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Adds and/or removes elements from the queue.
|
|
87
|
+
*
|
|
88
|
+
* @param start The zero-based location in the Queue from which to start removing elements.
|
|
89
|
+
* @param deleteCount The number of elements to remove.
|
|
90
|
+
* @param workers Workers to insert into the Queue in place of the deleted elements.
|
|
91
|
+
*/
|
|
92
|
+
splice(start: number, deleteCount: number, ...workers: QueueWorker[]): Queue;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Removes the last element from the Queue and returns that element.
|
|
96
|
+
*/
|
|
97
|
+
pop(): QueueWorker | undefined;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Removes the first element from the Queue and returns that element.
|
|
101
|
+
*/
|
|
102
|
+
shift(): QueueWorker | undefined;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Extracts a section of the Queue and returns Queue.
|
|
106
|
+
*
|
|
107
|
+
* @param start The beginning of the specified portion of the Queue.
|
|
108
|
+
* @param end The end of the specified portion of the Queue.
|
|
109
|
+
*/
|
|
110
|
+
slice(start?: number, end?: number): Queue;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Reverses the order of the elements of the Queue in place.
|
|
114
|
+
*/
|
|
115
|
+
reverse(): Queue;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Returns the first (least) index of an element within the Queue equal to the specified value, or -1 if none is found.
|
|
119
|
+
*
|
|
120
|
+
* @param searchElement The value to locate in the Queue.
|
|
121
|
+
* @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at index 0.
|
|
122
|
+
*/
|
|
123
|
+
indexOf(searchElement: QueueWorker, fromIndex?: number): number;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Returns the last (greatest) index of an element within the Queue equal to the specified value, or -1 if none is found.
|
|
127
|
+
*
|
|
128
|
+
* @param searchElement The value to locate in the Queue.
|
|
129
|
+
* @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at the last index in the Queue.
|
|
130
|
+
*/
|
|
131
|
+
lastIndexOf(searchElement: QueueWorker, fromIndex?: number): number;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Starts the queue.
|
|
135
|
+
*
|
|
136
|
+
* @param callback Callback to be called when the queue empties or when an error occurs.
|
|
137
|
+
*/
|
|
138
|
+
start(callback?: (error?: Error) => void): void;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Stops the queue.
|
|
142
|
+
*/
|
|
143
|
+
stop(): void;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Stop and empty the queue immediately.
|
|
147
|
+
*
|
|
148
|
+
* @param error error of why the stop has occurred, to be passed to start callback if supplied.
|
|
149
|
+
*/
|
|
150
|
+
end(error?: Error): void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface QueueConstructor {
|
|
154
|
+
(options?: Options): Queue;
|
|
155
|
+
new (options?: Options): Queue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare const Queue: QueueConstructor;
|
|
159
|
+
|
|
160
|
+
export default Queue;
|
|
161
|
+
|
|
162
|
+
export interface QueueWorker {
|
|
163
|
+
(callback?: QueueWorkerCallback): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Override queue timeout.
|
|
167
|
+
*/
|
|
168
|
+
timeout?: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface QueueWorkerCallback {
|
|
172
|
+
(error?: Error, data?: Object): void;
|
|
173
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
var inherits = require('inherits')
|
|
2
|
+
var EventEmitter = require('events').EventEmitter
|
|
3
|
+
|
|
4
|
+
module.exports = Queue
|
|
5
|
+
module.exports.default = Queue
|
|
6
|
+
|
|
7
|
+
function Queue (options) {
|
|
8
|
+
if (!(this instanceof Queue)) {
|
|
9
|
+
return new Queue(options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
EventEmitter.call(this)
|
|
13
|
+
options = options || {}
|
|
14
|
+
this.concurrency = options.concurrency || Infinity
|
|
15
|
+
this.timeout = options.timeout || 0
|
|
16
|
+
this.autostart = options.autostart || false
|
|
17
|
+
this.results = options.results || null
|
|
18
|
+
this.pending = 0
|
|
19
|
+
this.session = 0
|
|
20
|
+
this.running = false
|
|
21
|
+
this.jobs = []
|
|
22
|
+
this.timers = {}
|
|
23
|
+
}
|
|
24
|
+
inherits(Queue, EventEmitter)
|
|
25
|
+
|
|
26
|
+
var arrayMethods = [
|
|
27
|
+
'pop',
|
|
28
|
+
'shift',
|
|
29
|
+
'indexOf',
|
|
30
|
+
'lastIndexOf'
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
arrayMethods.forEach(function (method) {
|
|
34
|
+
Queue.prototype[method] = function () {
|
|
35
|
+
return Array.prototype[method].apply(this.jobs, arguments)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
Queue.prototype.slice = function (begin, end) {
|
|
40
|
+
this.jobs = this.jobs.slice(begin, end)
|
|
41
|
+
return this
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Queue.prototype.reverse = function () {
|
|
45
|
+
this.jobs.reverse()
|
|
46
|
+
return this
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var arrayAddMethods = [
|
|
50
|
+
'push',
|
|
51
|
+
'unshift',
|
|
52
|
+
'splice'
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
arrayAddMethods.forEach(function (method) {
|
|
56
|
+
Queue.prototype[method] = function () {
|
|
57
|
+
var methodResult = Array.prototype[method].apply(this.jobs, arguments)
|
|
58
|
+
if (this.autostart) {
|
|
59
|
+
this.start()
|
|
60
|
+
}
|
|
61
|
+
return methodResult
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
Object.defineProperty(Queue.prototype, 'length', {
|
|
66
|
+
get: function () {
|
|
67
|
+
return this.pending + this.jobs.length
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
Queue.prototype.start = function (cb) {
|
|
72
|
+
if (cb) {
|
|
73
|
+
callOnErrorOrEnd.call(this, cb)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.running = true
|
|
77
|
+
|
|
78
|
+
if (this.pending >= this.concurrency) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.jobs.length === 0) {
|
|
83
|
+
if (this.pending === 0) {
|
|
84
|
+
done.call(this)
|
|
85
|
+
}
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var self = this
|
|
90
|
+
var job = this.jobs.shift()
|
|
91
|
+
var once = true
|
|
92
|
+
var session = this.session
|
|
93
|
+
var timeoutId = null
|
|
94
|
+
var didTimeout = false
|
|
95
|
+
var resultIndex = null
|
|
96
|
+
var timeout = job.hasOwnProperty('timeout') ? job.timeout : this.timeout
|
|
97
|
+
|
|
98
|
+
function next (err, result) {
|
|
99
|
+
if (once && self.session === session) {
|
|
100
|
+
once = false
|
|
101
|
+
self.pending--
|
|
102
|
+
if (timeoutId !== null) {
|
|
103
|
+
delete self.timers[timeoutId]
|
|
104
|
+
clearTimeout(timeoutId)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (err) {
|
|
108
|
+
self.emit('error', err, job)
|
|
109
|
+
} else if (didTimeout === false) {
|
|
110
|
+
if (resultIndex !== null) {
|
|
111
|
+
self.results[resultIndex] = Array.prototype.slice.call(arguments, 1)
|
|
112
|
+
}
|
|
113
|
+
self.emit('success', result, job)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (self.session === session) {
|
|
117
|
+
if (self.pending === 0 && self.jobs.length === 0) {
|
|
118
|
+
done.call(self)
|
|
119
|
+
} else if (self.running) {
|
|
120
|
+
self.start()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (timeout) {
|
|
127
|
+
timeoutId = setTimeout(function () {
|
|
128
|
+
didTimeout = true
|
|
129
|
+
if (self.listeners('timeout').length > 0) {
|
|
130
|
+
self.emit('timeout', next, job)
|
|
131
|
+
} else {
|
|
132
|
+
next()
|
|
133
|
+
}
|
|
134
|
+
}, timeout)
|
|
135
|
+
this.timers[timeoutId] = timeoutId
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.results) {
|
|
139
|
+
resultIndex = this.results.length
|
|
140
|
+
this.results[resultIndex] = null
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this.pending++
|
|
144
|
+
self.emit('start', job)
|
|
145
|
+
var promise = job(next)
|
|
146
|
+
if (promise && promise.then && typeof promise.then === 'function') {
|
|
147
|
+
promise.then(function (result) {
|
|
148
|
+
return next(null, result)
|
|
149
|
+
}).catch(function (err) {
|
|
150
|
+
return next(err || true)
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (this.running && this.jobs.length > 0) {
|
|
155
|
+
this.start()
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
Queue.prototype.stop = function () {
|
|
160
|
+
this.running = false
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
Queue.prototype.end = function (err) {
|
|
164
|
+
clearTimers.call(this)
|
|
165
|
+
this.jobs.length = 0
|
|
166
|
+
this.pending = 0
|
|
167
|
+
done.call(this, err)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function clearTimers () {
|
|
171
|
+
for (var key in this.timers) {
|
|
172
|
+
var timeoutId = this.timers[key]
|
|
173
|
+
delete this.timers[key]
|
|
174
|
+
clearTimeout(timeoutId)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function callOnErrorOrEnd (cb) {
|
|
179
|
+
var self = this
|
|
180
|
+
this.on('error', onerror)
|
|
181
|
+
this.on('end', onend)
|
|
182
|
+
|
|
183
|
+
function onerror (err) { self.end(err) }
|
|
184
|
+
function onend (err) {
|
|
185
|
+
self.removeListener('error', onerror)
|
|
186
|
+
self.removeListener('end', onend)
|
|
187
|
+
cb(err, this.results)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function done (err) {
|
|
192
|
+
this.session++
|
|
193
|
+
this.running = false
|
|
194
|
+
this.emit('end', err)
|
|
195
|
+
}
|