koonjs 0.6.0 → 0.6.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/index.js +28 -19
- package/package.json +9 -4
- package/koon.linux-x64-gnu.node +0 -0
- package/koon.win32-x64-msvc.node +0 -0
package/index.js
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
const { platform, arch } = process;
|
|
2
|
-
|
|
3
2
|
const platformArch = `${platform}-${arch}`;
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
'win32-x64': '
|
|
7
|
-
'linux-x64': '
|
|
8
|
-
'darwin-x64': '
|
|
9
|
-
'darwin-arm64': '
|
|
10
|
-
'linux-arm64': '
|
|
4
|
+
const packages = {
|
|
5
|
+
'win32-x64': '@koonjs/win32-x64-msvc',
|
|
6
|
+
'linux-x64': '@koonjs/linux-x64-gnu',
|
|
7
|
+
'darwin-x64': '@koonjs/darwin-x64',
|
|
8
|
+
'darwin-arm64': '@koonjs/darwin-arm64',
|
|
9
|
+
'linux-arm64': '@koonjs/linux-arm64-gnu',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const localFiles = {
|
|
13
|
+
'win32-x64': './koon.win32-x64-msvc.node',
|
|
14
|
+
'linux-x64': './koon.linux-x64-gnu.node',
|
|
15
|
+
'darwin-x64': './koon.darwin-x64.node',
|
|
16
|
+
'darwin-arm64': './koon.darwin-arm64.node',
|
|
17
|
+
'linux-arm64': './koon.linux-arm64-gnu.node',
|
|
11
18
|
};
|
|
12
19
|
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
20
|
+
const pkg = packages[platformArch];
|
|
21
|
+
if (!pkg) {
|
|
15
22
|
throw new Error(
|
|
16
23
|
`koon: unsupported platform ${platformArch}. ` +
|
|
17
|
-
`Supported: ${Object.keys(
|
|
24
|
+
`Supported: ${Object.keys(packages).join(', ')}`
|
|
18
25
|
);
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
let nativeModule;
|
|
22
29
|
try {
|
|
23
|
-
nativeModule = require(
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
nativeModule = require(pkg);
|
|
31
|
+
} catch (_) {
|
|
32
|
+
try {
|
|
33
|
+
nativeModule = require(localFiles[platformArch]);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`koon: failed to load native module for ${platformArch}.\n` +
|
|
37
|
+
`Install the platform package: npm install ${pkg}\n` +
|
|
38
|
+
`Original error: ${e.message}`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
module.exports = nativeModule;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koonjs",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Browser-impersonating HTTP client with TLS/HTTP2 fingerprint spoofing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"author": "
|
|
8
|
+
"author": "Wedge",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/scrape-hub/koon.git",
|
|
@@ -18,9 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"index.js",
|
|
21
|
-
"index.d.ts"
|
|
22
|
-
"koon.*.node"
|
|
21
|
+
"index.d.ts"
|
|
23
22
|
],
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@koonjs/win32-x64-msvc": "0.6.1",
|
|
25
|
+
"@koonjs/linux-x64-gnu": "0.6.1",
|
|
26
|
+
"@koonjs/darwin-arm64": "0.6.1",
|
|
27
|
+
"@koonjs/darwin-x64": "0.6.1"
|
|
28
|
+
},
|
|
24
29
|
"scripts": {
|
|
25
30
|
"build": "cargo build --release -p koon-node && node -e \"require('fs').copyFileSync(require('path').resolve(__dirname,'../../target/release/koon_node.dll'), require('path').resolve(__dirname,'koon.win32-x64-msvc.node'))\"",
|
|
26
31
|
"build:linux": "cargo build --release -p koon-node && cp ../../target/release/libkoon_node.so koon.linux-x64-gnu.node",
|
package/koon.linux-x64-gnu.node
DELETED
|
Binary file
|
package/koon.win32-x64-msvc.node
DELETED
|
Binary file
|