@fedify/cli 2.3.0-dev.1371 → 2.3.0-dev.1372
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/dist/deno.js +1 -1
- package/dist/nodeinfo.js +40 -1
- package/package.json +11 -9
package/dist/deno.js
CHANGED
package/dist/nodeinfo.js
CHANGED
|
@@ -14,7 +14,9 @@ import webp from "@jimp/wasm-webp";
|
|
|
14
14
|
import { getLogger } from "@logtape/logtape";
|
|
15
15
|
import { isICO, parseICO } from "icojs";
|
|
16
16
|
import { defaultFormats, defaultPlugins, intToRGBA } from "jimp";
|
|
17
|
+
import { Buffer } from "node:buffer";
|
|
17
18
|
import ora from "ora";
|
|
19
|
+
import { PNG } from "pngjs";
|
|
18
20
|
//#region src/nodeinfo.ts
|
|
19
21
|
const logger = getLogger([
|
|
20
22
|
"fedify",
|
|
@@ -25,6 +27,43 @@ const Jimp = createJimp({
|
|
|
25
27
|
formats: [...defaultFormats, webp],
|
|
26
28
|
plugins: defaultPlugins
|
|
27
29
|
});
|
|
30
|
+
const PNG_SIGNATURE = [
|
|
31
|
+
137,
|
|
32
|
+
80,
|
|
33
|
+
78,
|
|
34
|
+
71,
|
|
35
|
+
13,
|
|
36
|
+
10,
|
|
37
|
+
26,
|
|
38
|
+
10
|
|
39
|
+
];
|
|
40
|
+
function toUint8Array(buffer) {
|
|
41
|
+
return buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
42
|
+
}
|
|
43
|
+
function toNodeBuffer(buffer) {
|
|
44
|
+
return Buffer.from(toUint8Array(buffer));
|
|
45
|
+
}
|
|
46
|
+
function isPng(buffer) {
|
|
47
|
+
const bytes = toUint8Array(buffer);
|
|
48
|
+
return PNG_SIGNATURE.every((byte, index) => bytes[index] === byte);
|
|
49
|
+
}
|
|
50
|
+
async function decodePng(buffer) {
|
|
51
|
+
return await new Promise((resolve, reject) => {
|
|
52
|
+
new PNG().parse(toNodeBuffer(buffer), (error, png) => {
|
|
53
|
+
if (error != null) reject(error);
|
|
54
|
+
else resolve(png);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async function readImage(buffer) {
|
|
59
|
+
if (!isPng(buffer)) return await Jimp.read(toNodeBuffer(buffer));
|
|
60
|
+
const png = await decodePng(buffer);
|
|
61
|
+
return new Jimp({
|
|
62
|
+
width: png.width,
|
|
63
|
+
height: png.height,
|
|
64
|
+
data: png.data
|
|
65
|
+
});
|
|
66
|
+
}
|
|
28
67
|
const nodeInfoOption = merge(object("Display options", {
|
|
29
68
|
raw: bindConfig(flag("-r", "--raw", { description: message`Show NodeInfo document in the raw JSON format` }), {
|
|
30
69
|
context: configContext,
|
|
@@ -103,7 +142,7 @@ async function runNodeInfo(command) {
|
|
|
103
142
|
if (images.length < 1) throw new Error("No images found in the ICO file.");
|
|
104
143
|
buffer = images[0].buffer;
|
|
105
144
|
}
|
|
106
|
-
layout = getAsciiArt(await
|
|
145
|
+
layout = getAsciiArt(await readImage(buffer), DEFAULT_IMAGE_WIDTH, checkTerminalColorSupport(), colors).split("\n").map((line) => ` ${line} `);
|
|
107
146
|
defaultWidth = 41;
|
|
108
147
|
} else {
|
|
109
148
|
logger.error("Failed to fetch the favicon: {status} {statusText}", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.3.0-dev.
|
|
3
|
+
"version": "2.3.0-dev.1372+2402d49b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -85,23 +85,25 @@
|
|
|
85
85
|
"inquirer-toggle": "^1.0.1",
|
|
86
86
|
"jimp": "^1.6.1",
|
|
87
87
|
"ora": "^8.2.0",
|
|
88
|
+
"pngjs": "^7.0.0",
|
|
88
89
|
"shiki": "^1.6.4",
|
|
89
90
|
"smol-toml": "^1.6.1",
|
|
90
91
|
"srvx": "^0.8.7",
|
|
91
92
|
"valibot": "^1.4.0",
|
|
92
93
|
"yaml": "^2.9.0",
|
|
93
|
-
"@fedify/fedify": "2.3.0-dev.
|
|
94
|
-
"@fedify/
|
|
95
|
-
"@fedify/
|
|
96
|
-
"@fedify/
|
|
97
|
-
"@fedify/vocab": "2.3.0-dev.
|
|
98
|
-
"@fedify/
|
|
99
|
-
"@fedify/vocab-tools": "2.3.0-dev.
|
|
100
|
-
"@fedify/webfinger": "2.3.0-dev.
|
|
94
|
+
"@fedify/fedify": "2.3.0-dev.1372+2402d49b",
|
|
95
|
+
"@fedify/sqlite": "2.3.0-dev.1372+2402d49b",
|
|
96
|
+
"@fedify/vocab": "2.3.0-dev.1372+2402d49b",
|
|
97
|
+
"@fedify/init": "2.3.0-dev.1372+2402d49b",
|
|
98
|
+
"@fedify/vocab-runtime": "2.3.0-dev.1372+2402d49b",
|
|
99
|
+
"@fedify/relay": "2.3.0-dev.1372+2402d49b",
|
|
100
|
+
"@fedify/vocab-tools": "2.3.0-dev.1372+2402d49b",
|
|
101
|
+
"@fedify/webfinger": "2.3.0-dev.1372+2402d49b"
|
|
101
102
|
},
|
|
102
103
|
"devDependencies": {
|
|
103
104
|
"@types/bun": "^1.2.23",
|
|
104
105
|
"@types/node": "^22.17.0",
|
|
106
|
+
"@types/pngjs": "^6.0.5",
|
|
105
107
|
"tsdown": "^0.22.0",
|
|
106
108
|
"typescript": "^6.0.0"
|
|
107
109
|
},
|