@thi.ng/text-canvas 1.1.4 → 2.0.4
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/CHANGELOG.md +56 -79
- package/README.md +55 -111
- package/api.d.ts +1 -106
- package/api.js +19 -46
- package/bars.js +7 -4
- package/canvas.d.ts +1 -1
- package/canvas.js +5 -4
- package/circle.d.ts +1 -1
- package/circle.js +3 -3
- package/format.d.ts +8 -100
- package/format.js +41 -205
- package/hvline.d.ts +1 -1
- package/hvline.js +2 -2
- package/image.d.ts +4 -4
- package/image.js +19 -12
- package/index.d.ts +12 -13
- package/index.js +12 -13
- package/line.d.ts +1 -1
- package/line.js +3 -3
- package/package.json +73 -29
- package/rect.d.ts +1 -1
- package/rect.js +3 -3
- package/style.d.ts +1 -1
- package/table.d.ts +3 -3
- package/table.js +9 -9
- package/text.d.ts +2 -2
- package/text.js +11 -6
- package/utils.d.ts +1 -1
- package/lib/index.js +0 -1052
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/string.d.ts +0 -64
- package/string.js +0 -97
package/line.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { peek } from "@thi.ng/arrays";
|
|
2
|
-
import { liangBarsky2Raw } from "@thi.ng/geom-clip-line";
|
|
3
|
-
import { charCode } from "./utils";
|
|
1
|
+
import { peek } from "@thi.ng/arrays/peek";
|
|
2
|
+
import { liangBarsky2Raw } from "@thi.ng/geom-clip-line/liang-barsky";
|
|
3
|
+
import { charCode } from "./utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Draws a line between `ax`,`ay` and `bx`,`by`, using `char` and taking
|
|
6
6
|
* the current clip rect and format into account. If `char` is not
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/text-canvas",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Text based canvas, drawing, tables with arbitrary formatting (incl. ANSI/HTML)",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"module": "./index.js",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"umd:main": "./lib/index.umd.js",
|
|
8
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
@@ -24,34 +24,28 @@
|
|
|
24
24
|
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn clean &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"build:test": "rimraf build && tsc -p test/tsconfig.json",
|
|
31
|
-
"build:check": "tsc --isolatedModules --noEmit",
|
|
32
|
-
"test": "mocha test",
|
|
33
|
-
"cover": "nyc mocha test && nyc report --reporter=lcov",
|
|
34
|
-
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
|
|
35
|
-
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf *.js *.d.ts *.map doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
36
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
|
|
37
|
-
"doc": "
|
|
38
|
-
"
|
|
31
|
+
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
|
|
32
|
+
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
|
|
33
|
+
"pub": "yarn build && yarn publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
39
35
|
},
|
|
40
36
|
"dependencies": {
|
|
41
|
-
"@thi.ng/api": "^
|
|
42
|
-
"@thi.ng/arrays": "^
|
|
43
|
-
"@thi.ng/checks": "^
|
|
44
|
-
"@thi.ng/geom-clip-line": "^
|
|
45
|
-
"@thi.ng/math": "^
|
|
46
|
-
"@thi.ng/
|
|
47
|
-
"@thi.ng/
|
|
48
|
-
"@thi.ng/transducers": "^
|
|
37
|
+
"@thi.ng/api": "^8.0.4",
|
|
38
|
+
"@thi.ng/arrays": "^2.0.4",
|
|
39
|
+
"@thi.ng/checks": "^3.0.4",
|
|
40
|
+
"@thi.ng/geom-clip-line": "^2.0.4",
|
|
41
|
+
"@thi.ng/math": "^5.0.4",
|
|
42
|
+
"@thi.ng/strings": "^3.1.0",
|
|
43
|
+
"@thi.ng/text-format": "^1.0.4",
|
|
44
|
+
"@thi.ng/transducers": "^8.0.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@thi.ng/testament": "^0.1.4"
|
|
49
48
|
},
|
|
50
|
-
"files": [
|
|
51
|
-
"*.js",
|
|
52
|
-
"*.d.ts",
|
|
53
|
-
"lib"
|
|
54
|
-
],
|
|
55
49
|
"keywords": [
|
|
56
50
|
"4bit",
|
|
57
51
|
"8bit",
|
|
@@ -84,9 +78,59 @@
|
|
|
84
78
|
"publishConfig": {
|
|
85
79
|
"access": "public"
|
|
86
80
|
},
|
|
87
|
-
"
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=12.7"
|
|
83
|
+
},
|
|
84
|
+
"files": [
|
|
85
|
+
"*.js",
|
|
86
|
+
"*.d.ts"
|
|
87
|
+
],
|
|
88
|
+
"exports": {
|
|
89
|
+
".": {
|
|
90
|
+
"import": "./index.js"
|
|
91
|
+
},
|
|
92
|
+
"./api": {
|
|
93
|
+
"import": "./api.js"
|
|
94
|
+
},
|
|
95
|
+
"./bars": {
|
|
96
|
+
"import": "./bars.js"
|
|
97
|
+
},
|
|
98
|
+
"./canvas": {
|
|
99
|
+
"import": "./canvas.js"
|
|
100
|
+
},
|
|
101
|
+
"./circle": {
|
|
102
|
+
"import": "./circle.js"
|
|
103
|
+
},
|
|
104
|
+
"./format": {
|
|
105
|
+
"import": "./format.js"
|
|
106
|
+
},
|
|
107
|
+
"./hvline": {
|
|
108
|
+
"import": "./hvline.js"
|
|
109
|
+
},
|
|
110
|
+
"./image": {
|
|
111
|
+
"import": "./image.js"
|
|
112
|
+
},
|
|
113
|
+
"./line": {
|
|
114
|
+
"import": "./line.js"
|
|
115
|
+
},
|
|
116
|
+
"./rect": {
|
|
117
|
+
"import": "./rect.js"
|
|
118
|
+
},
|
|
119
|
+
"./style": {
|
|
120
|
+
"import": "./style.js"
|
|
121
|
+
},
|
|
122
|
+
"./table": {
|
|
123
|
+
"import": "./table.js"
|
|
124
|
+
},
|
|
125
|
+
"./text": {
|
|
126
|
+
"import": "./text.js"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
88
129
|
"thi.ng": {
|
|
130
|
+
"related": [
|
|
131
|
+
"text-format"
|
|
132
|
+
],
|
|
89
133
|
"year": 2020
|
|
90
134
|
},
|
|
91
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "9ff00a103f76cc4917ef3f244132e218f2300a05"
|
|
92
136
|
}
|
package/rect.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NumOrString } from "@thi.ng/api";
|
|
2
|
-
import type { Canvas } from "./canvas";
|
|
2
|
+
import type { Canvas } from "./canvas.js";
|
|
3
3
|
/**
|
|
4
4
|
* Clears/fills the canvas' current clip rect with given char (default:
|
|
5
5
|
* 0x20 / space). If `reset` is true, first resets all internal state
|
package/rect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { peek } from "@thi.ng/arrays";
|
|
2
|
-
import { hline, vline } from "./hvline";
|
|
3
|
-
import { charCode } from "./utils";
|
|
1
|
+
import { peek } from "@thi.ng/arrays/peek";
|
|
2
|
+
import { hline, vline } from "./hvline.js";
|
|
3
|
+
import { charCode } from "./utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Clears/fills the canvas' current clip rect with given char (default:
|
|
6
6
|
* 0x20 / space). If `reset` is true, first resets all internal state
|
package/style.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StrokeStyle } from "./api";
|
|
1
|
+
import type { StrokeStyle } from "./api.js";
|
|
2
2
|
export declare const horizontalOnly: ({ hl, dot }: StrokeStyle) => StrokeStyle;
|
|
3
3
|
export declare const verticalOnly: ({ vl, dot }: StrokeStyle) => StrokeStyle;
|
|
4
4
|
//# sourceMappingURL=style.d.ts.map
|
package/table.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Border, TableOpts } from "./api";
|
|
2
|
-
import { Canvas } from "./canvas";
|
|
1
|
+
import { Border, TableOpts } from "./api.js";
|
|
2
|
+
import { Canvas } from "./canvas.js";
|
|
3
3
|
declare type RawCell = {
|
|
4
4
|
body: string;
|
|
5
5
|
format?: number;
|
|
@@ -13,7 +13,7 @@ declare type Cell = {
|
|
|
13
13
|
height?: number;
|
|
14
14
|
};
|
|
15
15
|
export declare const initTable: (opts: TableOpts, cells: (string | RawCell)[][]) => {
|
|
16
|
-
style: import("./api").StrokeStyle | undefined;
|
|
16
|
+
style: import("./api.js").StrokeStyle | undefined;
|
|
17
17
|
format: number | undefined;
|
|
18
18
|
formatHead: number | undefined;
|
|
19
19
|
width: number;
|
package/table.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { peek } from "@thi.ng/arrays";
|
|
2
|
-
import { isString } from "@thi.ng/checks";
|
|
3
|
-
import { wordWrapLines } from "@thi.ng/strings";
|
|
4
|
-
import { Border } from "./api";
|
|
5
|
-
import { beginClip, beginStyle, canvas, endClip, endStyle, setAt, } from "./canvas";
|
|
6
|
-
import { hline, vline } from "./hvline";
|
|
7
|
-
import { fillRect, strokeRect } from "./rect";
|
|
8
|
-
import { horizontalOnly, verticalOnly } from "./style";
|
|
9
|
-
import { textLines } from "./text";
|
|
1
|
+
import { peek } from "@thi.ng/arrays/peek";
|
|
2
|
+
import { isString } from "@thi.ng/checks/is-string";
|
|
3
|
+
import { wordWrapLines } from "@thi.ng/strings/word-wrap";
|
|
4
|
+
import { Border } from "./api.js";
|
|
5
|
+
import { beginClip, beginStyle, canvas, endClip, endStyle, setAt, } from "./canvas.js";
|
|
6
|
+
import { hline, vline } from "./hvline.js";
|
|
7
|
+
import { fillRect, strokeRect } from "./rect.js";
|
|
8
|
+
import { horizontalOnly, verticalOnly } from "./style.js";
|
|
9
|
+
import { textLines } from "./text.js";
|
|
10
10
|
export const initTable = (opts, cells) => {
|
|
11
11
|
const b = opts.border !== undefined ? opts.border : Border.ALL;
|
|
12
12
|
const bH = b & Border.H ? 1 : 0;
|
package/text.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TextBoxOpts } from "./api";
|
|
2
|
-
import { Canvas } from "./canvas";
|
|
1
|
+
import type { TextBoxOpts } from "./api.js";
|
|
2
|
+
import { Canvas } from "./canvas.js";
|
|
3
3
|
/**
|
|
4
4
|
* Writes given string at position `x`,`y`, taking the current clip rect
|
|
5
5
|
* and format into account. The string MUST not include linebreaks or
|
package/text.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { peek } from "@thi.ng/arrays";
|
|
2
|
-
import { clamp0 } from "@thi.ng/math";
|
|
3
|
-
import { wordWrapLines } from "@thi.ng/strings";
|
|
4
|
-
import { beginClip, beginStyle, endClip, endStyle } from "./canvas";
|
|
5
|
-
import { fillRect, strokeRect } from "./rect";
|
|
1
|
+
import { peek } from "@thi.ng/arrays/peek";
|
|
2
|
+
import { clamp0 } from "@thi.ng/math/interval";
|
|
3
|
+
import { wordWrapLines } from "@thi.ng/strings/word-wrap";
|
|
4
|
+
import { beginClip, beginStyle, endClip, endStyle } from "./canvas.js";
|
|
5
|
+
import { fillRect, strokeRect } from "./rect.js";
|
|
6
6
|
/**
|
|
7
7
|
* Writes given string at position `x`,`y`, taking the current clip rect
|
|
8
8
|
* and format into account. The string MUST not include linebreaks or
|
|
@@ -81,7 +81,12 @@ export const textColumn = (canvas, x, y, width, txt, format = canvas.format, har
|
|
|
81
81
|
* @param opts
|
|
82
82
|
*/
|
|
83
83
|
export const textBox = (canvas, x, y, width, height, txt, opts) => {
|
|
84
|
-
const { format, style, padding: [padX, padY], hard, } =
|
|
84
|
+
const { format, style, padding: [padX, padY], hard, } = {
|
|
85
|
+
format: canvas.format,
|
|
86
|
+
padding: [0, 0],
|
|
87
|
+
hard: false,
|
|
88
|
+
...opts,
|
|
89
|
+
};
|
|
85
90
|
const currFmt = canvas.format;
|
|
86
91
|
canvas.format = format;
|
|
87
92
|
style && beginStyle(canvas, style);
|
package/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FnU2, FnU7, NumOrString } from "@thi.ng/api";
|
|
2
|
-
import type { ClipRect } from "./api";
|
|
2
|
+
import type { ClipRect } from "./api.js";
|
|
3
3
|
export declare const charCode: (x: NumOrString, format: number) => number;
|
|
4
4
|
export declare const intersectRect: FnU2<ClipRect>;
|
|
5
5
|
export declare const intersectRectCircle: FnU7<number, boolean>;
|