@shba007/unascii 0.3.6 → 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.BaMBS4LC.cjs');
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.6";
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,11 +68,11 @@ const main = citty.defineCommand({
67
68
  },
68
69
  async run({ args }) {
69
70
  if (args.verbose) {
70
- process.env.DEBUG = process.env.DEBUG || "true";
71
+ stdEnv.env.DEBUG = stdEnv.env.DEBUG || "true";
71
72
  }
72
73
  const print = await index.asciiPrint(args.path, {
73
- width: args.width ? Number.parseInt(args.width) ?? undefined : undefined,
74
- widthSkew: args.widthSkew ? Number.parseFloat(args.widthSkew) ?? undefined : undefined,
74
+ width: args.width ? Number.parseInt(args.width) ?? void 0 : void 0,
75
+ widthSkew: args.widthSkew ? Number.parseFloat(args.widthSkew) ?? void 0 : void 0,
75
76
  output: args.output,
76
77
  characters: args.characters,
77
78
  grayscale: args.grayscale
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.BIlYtGRb.mjs';
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.6";
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,11 +60,11 @@ const main = defineCommand({
59
60
  },
60
61
  async run({ args }) {
61
62
  if (args.verbose) {
62
- process.env.DEBUG = process.env.DEBUG || "true";
63
+ env.DEBUG = env.DEBUG || "true";
63
64
  }
64
65
  const print = await asciiPrint(args.path, {
65
- width: args.width ? Number.parseInt(args.width) ?? undefined : undefined,
66
- widthSkew: args.widthSkew ? Number.parseFloat(args.widthSkew) ?? undefined : undefined,
66
+ width: args.width ? Number.parseInt(args.width) ?? void 0 : void 0,
67
+ widthSkew: args.widthSkew ? Number.parseFloat(args.widthSkew) ?? void 0 : void 0,
67
68
  output: args.output,
68
69
  characters: args.characters,
69
70
  grayscale: args.grayscale
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/unascii.BaMBS4LC.cjs');
3
+ require('std-env');
4
+ const index = require('./shared/unascii.B3Cdk6nG.cjs');
4
5
 
5
6
 
6
7
 
package/dist/index.mjs CHANGED
@@ -1 +1,2 @@
1
- export { a as asciiPrint } from './shared/unascii.BIlYtGRb.mjs';
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 (process.env.BROWSER) {
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 (process.env.DEBUG) console.time("loadImage");
99
+ if (env.DEBUG) console.time("loadImage");
98
100
  const image = await loadImage(imagePath);
99
- if (process.env.DEBUG) console.timeEnd("loadImage");
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 (process.env.DEBUG) console.time("imageDataToASCII");
108
+ if (env.DEBUG) console.time("imageDataToASCII");
107
109
  const data = imageDataToASCII(imageData, widthScale, characterSet, isGrayscale, outputType);
108
- if (process.env.DEBUG) console.timeEnd("imageDataToASCII");
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 (process.env.DEBUG) console.time("imagePathToASCII");
116
+ if (env.DEBUG) console.time("imagePathToASCII");
115
117
  const image = imagePathToASCII(imagePath, width, widthSkew, widthScale, characters, grayscale, output);
116
- if (process.env.DEBUG) console.timeEnd("imagePathToASCII");
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 (process.env.BROWSER) {
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 (process.env.DEBUG) console.time("loadImage");
101
+ if (stdEnv.env.DEBUG) console.time("loadImage");
100
102
  const image = await loadImage(imagePath);
101
- if (process.env.DEBUG) console.timeEnd("loadImage");
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 (process.env.DEBUG) console.time("imageDataToASCII");
110
+ if (stdEnv.env.DEBUG) console.time("imageDataToASCII");
109
111
  const data = imageDataToASCII(imageData, widthScale, characterSet, isGrayscale, outputType);
110
- if (process.env.DEBUG) console.timeEnd("imageDataToASCII");
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 (process.env.DEBUG) console.time("imagePathToASCII");
118
+ if (stdEnv.env.DEBUG) console.time("imagePathToASCII");
117
119
  const image = imagePathToASCII(imagePath, width, widthSkew, widthScale, characters, grayscale, output);
118
- if (process.env.DEBUG) console.timeEnd("imagePathToASCII");
120
+ if (stdEnv.env.DEBUG) console.timeEnd("imagePathToASCII");
119
121
  return {
120
122
  getImage: async () => image
121
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shba007/unascii",
3
- "version": "0.3.6",
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",
@@ -34,7 +34,7 @@
34
34
  "bin"
35
35
  ],
36
36
  "volta": {
37
- "node": "22.13.1"
37
+ "node": "22.14.0"
38
38
  },
39
39
  "engines": {
40
40
  "node": "^20.15.0 || ^22.11.0",
@@ -45,25 +45,26 @@
45
45
  "chalk": "^5.4.1",
46
46
  "citty": "^0.1.6",
47
47
  "consola": "^3.4.0",
48
- "pathe": "^2.0.2",
49
- "unstorage": "^1.14.4"
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.27.12",
53
+ "@changesets/cli": "^2.28.1",
53
54
  "@commitlint/cli": "^19.7.1",
54
55
  "@commitlint/config-conventional": "^19.7.1",
55
- "@dotenvx/dotenvx": "^1.34.0",
56
- "@types/node": "^22.13.1",
57
- "@vitest/coverage-v8": "^3.0.5",
58
- "changelogen": "^0.5.7",
59
- "eslint": "^9.19.0",
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.4.2",
64
- "typescript": "^5.7.3",
65
- "unbuild": "3.3.1",
66
- "vitest": "^3.0.5"
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",