@shba007/unascii 0.3.5 → 0.3.7
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/cli.cjs
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
const citty = require('citty');
|
|
4
4
|
const consola = require('consola');
|
|
5
5
|
const pathe = require('pathe');
|
|
6
|
+
const stdEnv = require('std-env');
|
|
6
7
|
const unstorage = require('unstorage');
|
|
7
8
|
const fsDriver = require('unstorage/drivers/fs');
|
|
8
|
-
const index = require('./shared/unascii.
|
|
9
|
+
const index = require('./shared/unascii.B3Cdk6nG.cjs');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
12
|
|
|
@@ -14,7 +15,7 @@ const pathe__default = /*#__PURE__*/_interopDefaultCompat(pathe);
|
|
|
14
15
|
const fsDriver__default = /*#__PURE__*/_interopDefaultCompat(fsDriver);
|
|
15
16
|
|
|
16
17
|
const name = "@shba007/unascii";
|
|
17
|
-
const version = "0.3.
|
|
18
|
+
const version = "0.3.7";
|
|
18
19
|
const description = "Print any image in ascii anywhere (browser/cli)";
|
|
19
20
|
|
|
20
21
|
const storage = unstorage.createStorage({
|
|
@@ -67,7 +68,7 @@ const main = citty.defineCommand({
|
|
|
67
68
|
},
|
|
68
69
|
async run({ args }) {
|
|
69
70
|
if (args.verbose) {
|
|
70
|
-
|
|
71
|
+
stdEnv.env.DEBUG = stdEnv.env.DEBUG || "true";
|
|
71
72
|
}
|
|
72
73
|
const print = await index.asciiPrint(args.path, {
|
|
73
74
|
width: args.width ? Number.parseInt(args.width) ?? void 0 : void 0,
|
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { defineCommand, runMain as runMain$1 } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import pathe from 'pathe';
|
|
4
|
+
import { env } from 'std-env';
|
|
4
5
|
import { createStorage } from 'unstorage';
|
|
5
6
|
import fsDriver from 'unstorage/drivers/fs';
|
|
6
|
-
import { a as asciiPrint, i as isURL } from './shared/unascii.
|
|
7
|
+
import { a as asciiPrint, i as isURL } from './shared/unascii.B-n97ykJ.mjs';
|
|
7
8
|
|
|
8
9
|
const name = "@shba007/unascii";
|
|
9
|
-
const version = "0.3.
|
|
10
|
+
const version = "0.3.7";
|
|
10
11
|
const description = "Print any image in ascii anywhere (browser/cli)";
|
|
11
12
|
|
|
12
13
|
const storage = createStorage({
|
|
@@ -59,7 +60,7 @@ const main = defineCommand({
|
|
|
59
60
|
},
|
|
60
61
|
async run({ args }) {
|
|
61
62
|
if (args.verbose) {
|
|
62
|
-
|
|
63
|
+
env.DEBUG = env.DEBUG || "true";
|
|
63
64
|
}
|
|
64
65
|
const print = await asciiPrint(args.path, {
|
|
65
66
|
width: args.width ? Number.parseInt(args.width) ?? void 0 : void 0,
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import 'std-env';
|
|
2
|
+
export { a as asciiPrint } from './shared/unascii.B-n97ykJ.mjs';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { env, runtime } from 'std-env';
|
|
2
|
+
|
|
1
3
|
const asciiCharacterSet = {
|
|
2
4
|
minimalist: "#+-.",
|
|
3
5
|
normal: "@%#*+=-:.",
|
|
@@ -31,7 +33,7 @@ let createCanvas;
|
|
|
31
33
|
let loadImage;
|
|
32
34
|
let colorizer;
|
|
33
35
|
async function loadFunctions() {
|
|
34
|
-
if (
|
|
36
|
+
if (runtime === "") {
|
|
35
37
|
let createCanvasBrowser = function(width, height) {
|
|
36
38
|
const canvas = document.createElement("canvas");
|
|
37
39
|
canvas.width = width;
|
|
@@ -94,26 +96,26 @@ function imageDataToASCII(imageData, widthScale, characterSet, isGrayscale, outp
|
|
|
94
96
|
return ascii;
|
|
95
97
|
}
|
|
96
98
|
async function imagePathToASCII(imagePath, width, widthSkew, widthScale, characterSet, isGrayscale, outputType) {
|
|
97
|
-
if (
|
|
99
|
+
if (env.DEBUG) console.time("loadImage");
|
|
98
100
|
const image = await loadImage(imagePath);
|
|
99
|
-
if (
|
|
101
|
+
if (env.DEBUG) console.timeEnd("loadImage");
|
|
100
102
|
const aspectRatio = image.width / image.height;
|
|
101
103
|
const canvas = createCanvas(width * widthSkew, Math.floor(width / aspectRatio));
|
|
102
104
|
const ctx = canvas.getContext("2d");
|
|
103
105
|
if (!ctx) throw new Error("Canvas Context Undefined");
|
|
104
106
|
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
105
107
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
106
|
-
if (
|
|
108
|
+
if (env.DEBUG) console.time("imageDataToASCII");
|
|
107
109
|
const data = imageDataToASCII(imageData, widthScale, characterSet, isGrayscale, outputType);
|
|
108
|
-
if (
|
|
110
|
+
if (env.DEBUG) console.timeEnd("imageDataToASCII");
|
|
109
111
|
return data;
|
|
110
112
|
}
|
|
111
113
|
async function asciiPrint(imagePath, opts) {
|
|
112
114
|
const { width = 32, widthSkew = 1.75, widthScale = 1, output = "console", characters = "alphanumeric", grayscale = false } = opts ?? {};
|
|
113
115
|
await loadFunctions();
|
|
114
|
-
if (
|
|
116
|
+
if (env.DEBUG) console.time("imagePathToASCII");
|
|
115
117
|
const image = imagePathToASCII(imagePath, width, widthSkew, widthScale, characters, grayscale, output);
|
|
116
|
-
if (
|
|
118
|
+
if (env.DEBUG) console.timeEnd("imagePathToASCII");
|
|
117
119
|
return {
|
|
118
120
|
getImage: async () => image
|
|
119
121
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const stdEnv = require('std-env');
|
|
4
|
+
|
|
3
5
|
const asciiCharacterSet = {
|
|
4
6
|
minimalist: "#+-.",
|
|
5
7
|
normal: "@%#*+=-:.",
|
|
@@ -33,7 +35,7 @@ let createCanvas;
|
|
|
33
35
|
let loadImage;
|
|
34
36
|
let colorizer;
|
|
35
37
|
async function loadFunctions() {
|
|
36
|
-
if (
|
|
38
|
+
if (stdEnv.runtime === "") {
|
|
37
39
|
let createCanvasBrowser = function(width, height) {
|
|
38
40
|
const canvas = document.createElement("canvas");
|
|
39
41
|
canvas.width = width;
|
|
@@ -96,26 +98,26 @@ function imageDataToASCII(imageData, widthScale, characterSet, isGrayscale, outp
|
|
|
96
98
|
return ascii;
|
|
97
99
|
}
|
|
98
100
|
async function imagePathToASCII(imagePath, width, widthSkew, widthScale, characterSet, isGrayscale, outputType) {
|
|
99
|
-
if (
|
|
101
|
+
if (stdEnv.env.DEBUG) console.time("loadImage");
|
|
100
102
|
const image = await loadImage(imagePath);
|
|
101
|
-
if (
|
|
103
|
+
if (stdEnv.env.DEBUG) console.timeEnd("loadImage");
|
|
102
104
|
const aspectRatio = image.width / image.height;
|
|
103
105
|
const canvas = createCanvas(width * widthSkew, Math.floor(width / aspectRatio));
|
|
104
106
|
const ctx = canvas.getContext("2d");
|
|
105
107
|
if (!ctx) throw new Error("Canvas Context Undefined");
|
|
106
108
|
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
107
109
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
108
|
-
if (
|
|
110
|
+
if (stdEnv.env.DEBUG) console.time("imageDataToASCII");
|
|
109
111
|
const data = imageDataToASCII(imageData, widthScale, characterSet, isGrayscale, outputType);
|
|
110
|
-
if (
|
|
112
|
+
if (stdEnv.env.DEBUG) console.timeEnd("imageDataToASCII");
|
|
111
113
|
return data;
|
|
112
114
|
}
|
|
113
115
|
async function asciiPrint(imagePath, opts) {
|
|
114
116
|
const { width = 32, widthSkew = 1.75, widthScale = 1, output = "console", characters = "alphanumeric", grayscale = false } = opts ?? {};
|
|
115
117
|
await loadFunctions();
|
|
116
|
-
if (
|
|
118
|
+
if (stdEnv.env.DEBUG) console.time("imagePathToASCII");
|
|
117
119
|
const image = imagePathToASCII(imagePath, width, widthSkew, widthScale, characters, grayscale, output);
|
|
118
|
-
if (
|
|
120
|
+
if (stdEnv.env.DEBUG) console.timeEnd("imagePathToASCII");
|
|
119
121
|
return {
|
|
120
122
|
getImage: async () => image
|
|
121
123
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shba007/unascii",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Print any image in ascii anywhere (browser/cli)",
|
|
5
5
|
"author": "Shirsendu Bairagi <shirsendu2001@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "
|
|
9
|
+
"url": "https://github.com/shba007/unascii.git"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"sideEffects": false,
|
|
@@ -34,36 +34,37 @@
|
|
|
34
34
|
"bin"
|
|
35
35
|
],
|
|
36
36
|
"volta": {
|
|
37
|
-
"node": "22.
|
|
37
|
+
"node": "22.14.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": "^20.15.0 || ^22.11.0",
|
|
41
|
-
"pnpm": "^9.15.0"
|
|
41
|
+
"pnpm": "^9.15.0 || ^10.2.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"canvas": "^3.0
|
|
44
|
+
"canvas": "^3.1.0",
|
|
45
45
|
"chalk": "^5.4.1",
|
|
46
46
|
"citty": "^0.1.6",
|
|
47
|
-
"consola": "^3.
|
|
48
|
-
"pathe": "^2.0.
|
|
49
|
-
"
|
|
47
|
+
"consola": "^3.4.0",
|
|
48
|
+
"pathe": "^2.0.3",
|
|
49
|
+
"std-env": "^3.8.0",
|
|
50
|
+
"unstorage": "^1.15.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@changesets/cli": "^2.
|
|
53
|
-
"@commitlint/cli": "^19.
|
|
54
|
-
"@commitlint/config-conventional": "^19.
|
|
55
|
-
"@dotenvx/dotenvx": "^1.
|
|
56
|
-
"@types/node": "^22.
|
|
57
|
-
"@vitest/coverage-v8": "^
|
|
58
|
-
"changelogen": "^0.
|
|
59
|
-
"eslint": "^9.
|
|
53
|
+
"@changesets/cli": "^2.28.1",
|
|
54
|
+
"@commitlint/cli": "^19.7.1",
|
|
55
|
+
"@commitlint/config-conventional": "^19.7.1",
|
|
56
|
+
"@dotenvx/dotenvx": "^1.38.3",
|
|
57
|
+
"@types/node": "^22.13.8",
|
|
58
|
+
"@vitest/coverage-v8": "^3.0.7",
|
|
59
|
+
"changelogen": "^0.6.0",
|
|
60
|
+
"eslint": "^9.21.0",
|
|
60
61
|
"eslint-config-unjs": "^0.4.2",
|
|
61
62
|
"husky": "^9.1.7",
|
|
62
63
|
"jiti": "^2.4.2",
|
|
63
|
-
"prettier": "^3.
|
|
64
|
-
"typescript": "^5.
|
|
65
|
-
"unbuild": "3.
|
|
66
|
-
"vitest": "^
|
|
64
|
+
"prettier": "^3.5.3",
|
|
65
|
+
"typescript": "^5.8.2",
|
|
66
|
+
"unbuild": "3.5.0",
|
|
67
|
+
"vitest": "^3.0.7"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|
|
69
70
|
"dev": "vitest dev",
|