@thi.ng/text-canvas 2.0.0 → 2.0.6

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 CHANGED
@@ -3,6 +3,54 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@2.0.5...@thi.ng/text-canvas@2.0.6) (2021-10-28)
7
+
8
+ **Note:** Version bump only for package @thi.ng/text-canvas
9
+
10
+
11
+
12
+
13
+
14
+ ## [2.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@2.0.4...@thi.ng/text-canvas@2.0.5) (2021-10-28)
15
+
16
+ **Note:** Version bump only for package @thi.ng/text-canvas
17
+
18
+
19
+
20
+
21
+
22
+ ## [2.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@2.0.3...@thi.ng/text-canvas@2.0.4) (2021-10-25)
23
+
24
+ **Note:** Version bump only for package @thi.ng/text-canvas
25
+
26
+
27
+
28
+
29
+
30
+ ## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@2.0.2...@thi.ng/text-canvas@2.0.3) (2021-10-15)
31
+
32
+ **Note:** Version bump only for package @thi.ng/text-canvas
33
+
34
+
35
+
36
+
37
+
38
+ ## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@2.0.1...@thi.ng/text-canvas@2.0.2) (2021-10-15)
39
+
40
+ **Note:** Version bump only for package @thi.ng/text-canvas
41
+
42
+
43
+
44
+
45
+
46
+ ## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@2.0.0...@thi.ng/text-canvas@2.0.1) (2021-10-13)
47
+
48
+ **Note:** Version bump only for package @thi.ng/text-canvas
49
+
50
+
51
+
52
+
53
+
6
54
  # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/text-canvas@1.1.4...@thi.ng/text-canvas@2.0.0) (2021-10-12)
7
55
 
8
56
 
package/README.md CHANGED
@@ -22,9 +22,6 @@ This project is part of the
22
22
  - [Variations](#variations)
23
23
  - [Combined formats](#combined-formats)
24
24
  - [String conversion format presets](#string-conversion-format-presets)
25
- - [256 color ANSI format](#256-color-ansi-format)
26
- - [16bit color ANSI & HTML formats](#16bit-color-ansi--html-formats)
27
- - [Ad-hoc formatting of strings](#ad-hoc-formatting-of-strings)
28
25
  - [Stroke styles](#stroke-styles)
29
26
  - [Clipping](#clipping)
30
27
  - [Drawing functions](#drawing-functions)
@@ -64,15 +61,16 @@ ES module import:
64
61
 
65
62
  [Skypack documentation](https://docs.skypack.dev/)
66
63
 
67
- For NodeJS (v14.6+):
64
+ For Node.js REPL:
68
65
 
69
66
  ```text
70
- node --experimental-specifier-resolution=node --experimental-repl-await
67
+ # with flag only for < v16
68
+ node --experimental-repl-await
71
69
 
72
70
  > const textCanvas = await import("@thi.ng/text-canvas");
73
71
  ```
74
72
 
75
- Package sizes (gzipped, pre-treeshake): ESM: 5.00 KB
73
+ Package sizes (gzipped, pre-treeshake): ESM: 4.97 KB
76
74
 
77
75
  ## Dependencies
78
76
 
@@ -112,29 +110,30 @@ const c = canvas(width, height, format?, style?);
112
110
 
113
111
  The text canvas stores all characters in a `Uint32Array` with the lower 16 bits
114
112
  used for the UTF-16 code and the upper 16 bits for **abitrary** formatting data.
115
- The package [provides its own format
116
- IDs](https://github.com/thi-ng/umbrella/blob/develop/packages/text-canvas/src/api.ts#L146)
117
- which are tailored for the bundled ANSI & HTML formatters, but users are free to
113
+ The package utilizes [format identifier constants and formatters from the
114
+ @thi.ng/text-format
115
+ package](https://github.com/thi-ng/umbrella/blob/develop/packages/text-format/),
116
+ which are tailored for the included ANSI & HTML formatters, but users are free to
118
117
  choose use any other system (but then will also need to implement a custom
119
118
  string formatter impl).
120
119
 
121
- The default format ID layout is as shown:
120
+ The default format ID layout used by text canvas is as shown:
122
121
 
123
122
  ![format bit layout](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/text-canvas/format-layout.png)
124
123
 
125
124
  Most drawing functions accept an optional `format` arg, but a default
126
125
  format can also be set via `setFormat(canvas, formatID)`.
127
126
 
128
- The following built-in format IDs are only compatible with these formatters:
127
+ The format IDs defined in @thi.ng/text-format are only compatible with these
128
+ formatters (also supplied by that package):
129
129
 
130
130
  - `FMT_ANSI16`
131
131
  - `FMT_HTML_INLINE_CSS`
132
132
  - `FMT_HTML_TACHYONS`
133
133
 
134
- Custom formatters are discussed further below:
135
-
136
- - [`FMT_ANSI256`](#256-color-ansi-format)
137
- - [`FMT_HTML_565`](#16bit-color-html-format)
134
+ **All constants and other formatters are also discussed in detail in the
135
+ [@thi.ng/text-format
136
+ readme](https://github.com/thi-ng/umbrella/blob/develop/packages/text-format/README.md).**
138
137
 
139
138
  #### Colors
140
139
 
@@ -175,101 +174,31 @@ setFormat(canvas, FG_BLACK | BG_LIGHT_CYAN | BOLD | UNDERLINE);
175
174
  ### String conversion format presets
176
175
 
177
176
  Canvas-to-string conversion is completely customizable via the [`StringFormat`
178
- interface](https://github.com/thi-ng/umbrella/blob/develop/packages/text-canvas/src/api.ts#L78)
179
- and the following presets are supplied:
177
+ interface](https://docs.thi.ng/umbrella/text-format/interfaces/StringFormat.html).
178
+ Currently the following presets are supplied (in the
179
+ [@thi.ng/text-format](https://github.com/thi-ng/umbrella/tree/develop/packages/text-format)
180
+ package):
180
181
 
181
- - `FMT_ANSI16` - translate built-in format IDs to 4bit ANSI escape sequences
182
+ - `FMT_ANSI16` - translate built-in format IDs to 4-bit ANSI escape sequences
182
183
  - `FMT_ANSI256` - uses all 16 format bits for fg & bg colors (ANSI esc sequences)
184
+ - `FMT_ANSI565` - uses all 16 format bits for RGB565 fg colors (ANSI esc sequences)
183
185
  - `FMT_ANSI_RAW` - verbatim use of format IDs to ANSI sequences
184
186
  - `FMT_HTML_INLINE_CSS` - HTML `<span>` elements with inline CSS
185
187
  - `FMT_HTML_TACHYONS` - HTML `<span>` elements with [Tachyons
186
188
  CSS](http://tachyons.io/) class names
189
+ - `FMT_HTML565` - HTML `<span>` elements with RGB565 color coding
187
190
  - `FMT_NONE` - dummy formatter outputting plain text only (all format
188
- information discarded)
191
+ information discarded, e.g. for [`NO_COLOR`](https://no-color.org/) support)
189
192
 
190
193
  ```ts
191
194
  // Terminal
192
- console.log(toString(canvas, FMT_ANSI16));
195
+ console.log(formatCanvas(canvas, FMT_ANSI16));
193
196
  // or
194
- console.log(toString(canvas, FMT_ANSI256));
197
+ console.log(formatCanvas(canvas, FMT_ANSI256));
195
198
 
196
199
  // Browser
197
200
  const el = document.createElement("pre");
198
- el.innerHTML = toString(canvas, FMT_HTML_TACHYONS);
199
- ```
200
-
201
- ### 256 color ANSI format
202
-
203
- If targeting this output format, all 16 bits available for formatting
204
- information are used to encode 2x 8bit foreground/background colors. Therefore,
205
- none of the above mentioned preset color names and/or any additional formatting
206
- flags (e.g. bold, underline etc.) **cannot be used**. Instead, use the
207
- `format256()` function to compute a format ID based on given FG, BG colors.
208
-
209
- ```ts
210
- // deep purple on yellow bg
211
- textLine(canvas, 1, 1, "hello color!", format256(19, 226));
212
- ```
213
-
214
- ![ANSI256 color pallette](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/text-canvas/ansi256.png)
215
-
216
- Source: [Wikipedia](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit)
217
-
218
- ### 16bit color ANSI & HTML formats
219
-
220
- Similar to the above custom ANSI format, here all available 16 bits are used to
221
- store color information, in the standard [RGB565
222
- format](https://en.wikipedia.org/wiki/High_color) (5bits red, 6bits green, 5bits
223
- blue). This also means, only either the text or background color<sup>(1)</sup> can be
224
- controlled and no other formatting flag (bold, underline etc.) are available.
225
-
226
- <sup>(1)</sup> In the ANSI version it's always only the text color.
227
-
228
- ```ts
229
- const el = document.createElement("pre");
230
- // format and assign text colors
231
- el.innerHTML = toString(canvas, FMT_HTML565());
232
-
233
- // assign bg colors
234
- el.innerHTML = toString(canvas, FMT_HTML565("background"));
235
- ```
236
-
237
- These formats are primarily intended for image display, see
238
- [section](#image-functions) below for examples...
239
-
240
- ### Ad-hoc formatting of strings
241
-
242
- String formatters can also be used in an ad-hoc manner, without requiring any of
243
- the other text canvas functionality.
244
-
245
- ```ts
246
- // create & use a HTML formatter
247
- defFormat(FMT_HTML_INLINE_CSS, FG_LIGHT_RED | BG_GRAY)("hello")
248
- // "<span style="color:#f55;background:#555;">hello</span>"
249
-
250
- // create & use an ANSI formatter
251
- defFormat(FMT_ANSI16, FG_LIGHT_RED | BG_GRAY)("hello")
252
- // "\x1B[91;100mhello\x1B[0m"
253
-
254
- // ANSI syntax sugar (same result as above)
255
- defAnsi16(FG_LIGHT_RED | BG_GRAY)("hello")
256
- // "\x1B[91;100mhello\x1B[0m"
257
- ```
258
-
259
- Furthermore, `defFormatPresets()` can be used to create formatting functions for
260
- all 16 preset [foreground color IDs](#colors) for a given string format
261
- strategy:
262
-
263
- ```ts
264
- const ansi = defFormatPresets(FMT_ANSI16);
265
-
266
- `${ansi.green("hello")} ${ansi.lightRed("world")}!`;
267
- // '\x1B[32mhello\x1B[0m \x1B[91mworld\x1B[0m!'
268
-
269
- const html = defFormatPresets(FMT_HTML_TACHYONS);
270
-
271
- `${html.green("hello")} ${html.lightRed("world")}!`;
272
- // '<span class="dark-green ">hello</span> <span class="red ">world</span>!'
201
+ el.innerHTML = formatCanvas(canvas, FMT_HTML_TACHYONS);
273
202
  ```
274
203
 
275
204
  ### Stroke styles
@@ -384,6 +313,7 @@ enabling the `hard` option (see example below).
384
313
  ```ts
385
314
  import { repeatedly } from "@thi.ng/transducers";
386
315
  import * as tc from "@thi.ng/text-canvas";
316
+ import * as tf from "@thi.ng/text-format";
387
317
 
388
318
  // generate 20 random values
389
319
  const data = repeatedly(() => Math.random(), 20)
@@ -402,9 +332,9 @@ tc.table(
402
332
  // column defs
403
333
  cols: [{ width: 4 }, { width: 20 }, { width: 8 }],
404
334
  // default cell format
405
- format: tc.FG_BLACK | tc.BG_LIGHT_CYAN,
335
+ format: tf.FG_BLACK | tf.BG_LIGHT_CYAN,
406
336
  // default format for header cells (1st row)
407
- formatHead: tc.FG_RED | tc.BG_LIGHT_CYAN | tc.BOLD | tc.UNDERLINE,
337
+ formatHead: tf.FG_RED | tf.BG_LIGHT_CYAN | tf.BOLD | tf.UNDERLINE,
408
338
  // border line style
409
339
  style: tc.STYLE_DASHED_ROUNDED,
410
340
  // border mode
@@ -420,7 +350,7 @@ tc.table(
420
350
  ["ID", "Main", "Comment"],
421
351
  [
422
352
  "0001",
423
- { body: chart, format: tc.FG_BLUE | tc.BG_LIGHT_CYAN },
353
+ { body: chart, format: tf.FG_BLUE | tf.BG_LIGHT_CYAN },
424
354
  "This is a test!"
425
355
  ],
426
356
  ["0002", "Random data plot", "Word wrapped content"],
@@ -429,14 +359,14 @@ tc.table(
429
359
  );
430
360
 
431
361
  // output as ANSI formatted string
432
- console.log(tc.toString(canvas, tc.FMT_ANSI16));
362
+ console.log(tc.formatCanvas(canvas, tf.FMT_ANSI16));
433
363
  ```
434
364
 
435
365
  For even more detailed control, tables can also be pre-initialized prior
436
366
  to creation of the canvas via
437
- [`initTable()`](https://github.com/thi-ng/umbrella/blob/develop/packages/text-canvas/src/table.ts#L20)
367
+ [`initTable()`](https://github.com/thi-ng/umbrella/blob/develop/packages/text-canvas/src/table.ts#L29)
438
368
  and then drawn via
439
- [`drawTable()`](https://github.com/thi-ng/umbrella/blob/develop/packages/text-canvas/src/table.ts#L80).
369
+ [`drawTable()`](https://github.com/thi-ng/umbrella/blob/develop/packages/text-canvas/src/table.ts#L97).
440
370
  The `initTable` function returns an object also containing the computed
441
371
  table size (`width`, `height` keys) which can then be used to create a
442
372
  canvas with the required size...
@@ -488,12 +418,13 @@ Code for this above example output (CLI version):
488
418
  import * as geom from "@thi.ng/geom";
489
419
  import * as mat from "@thi.ng/matrices";
490
420
  import * as tc from "@thi.ng/text-canvas";
421
+ import * as tf from "@thi.ng/text-format";
491
422
 
492
423
  const W = 64;
493
424
  const H = 32;
494
425
 
495
426
  // create text canvas
496
- const canvas = new tc.Canvas(W, H, tc.BG_BLACK, tc.STYLE_THIN);
427
+ const canvas = new tc.Canvas(W, H, tf.BG_BLACK, tf.STYLE_THIN);
497
428
 
498
429
  // cube corner vertices
499
430
  const cube = geom.vertices(geom.center(geom.aabb(1))!);
@@ -530,10 +461,10 @@ setInterval(() => {
530
461
  for (let e of edges) {
531
462
  const a = pts[e[0]];
532
463
  const b = pts[e[1]];
533
- tc.line(canvas, a[0], a[1], b[0], b[1], "+", tc.FG_WHITE | tc.BG_RED);
464
+ tc.line(canvas, a[0], a[1], b[0], b[1], "+", tf.FG_WHITE | tf.BG_RED);
534
465
  }
535
466
  // draw vertex labels
536
- canvas.format = tc.FG_WHITE | tc.BG_BLUE;
467
+ canvas.format = tf.FG_WHITE | tf.BG_BLUE;
537
468
  for (let i = 0; i < 8; i++) {
538
469
  const p = pts[i];
539
470
  tc.textBox(canvas, p[0] - 1, p[1] - 1, 5, 3, ` ${i} `);
@@ -543,16 +474,16 @@ setInterval(() => {
543
474
  2, 1, 24, -1,
544
475
  `@thi.ng/text-canvas wireframe cube\n\nx: ${rotx.toFixed(2)}\ny: ${roty.toFixed(2)}`,
545
476
  {
546
- format: tc.FG_BLACK | tc.BG_LIGHT_CYAN,
477
+ format: tf.FG_BLACK | tf.BG_LIGHT_CYAN,
547
478
  padding: [1, 0]
548
479
  }
549
480
  );
550
481
  // draw canvas
551
482
  console.clear();
552
483
  // output as ANSI formatted string
553
- console.log(tc.toString(canvas, tc.FMT_ANSI16));
484
+ console.log(tc.formatCanvas(canvas, tf.FMT_ANSI16));
554
485
  // output as plain text
555
- // console.log(tc.toString(canvas));
486
+ // console.log(tc.formatCanvas(canvas));
556
487
  }, 15);
557
488
  ```
558
489
 
package/bars.js CHANGED
@@ -4,7 +4,7 @@ import { padLeft } from "@thi.ng/strings/pad-left";
4
4
  import { padRight } from "@thi.ng/strings/pad-right";
5
5
  import { repeat } from "@thi.ng/strings/repeat";
6
6
  import { map } from "@thi.ng/transducers/map";
7
- import { BARS_H, BARS_V } from "./api";
7
+ import { BARS_H, BARS_V } from "./api.js";
8
8
  export const barChartHLines = (height, vals, min = 0, max = 1) => {
9
9
  const bars = [...map((x) => barVertical(height, x, min, max, ""), vals)];
10
10
  const num = bars.length;
package/canvas.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Fn0, NumOrString } from "@thi.ng/api";
2
- import { ClipRect, StrokeStyle } from "./api";
2
+ import { ClipRect, StrokeStyle } from "./api.js";
3
3
  export declare class Canvas {
4
4
  buf: Uint32Array;
5
5
  width: number;
package/canvas.js CHANGED
@@ -1,16 +1,9 @@
1
1
  import { peek } from "@thi.ng/arrays/peek";
2
2
  import { clamp } from "@thi.ng/math/interval";
3
3
  import { NONE } from "@thi.ng/text-format/api";
4
- import { STYLE_ASCII } from "./api";
5
- import { charCode, intersectRect } from "./utils";
4
+ import { STYLE_ASCII } from "./api.js";
5
+ import { charCode, intersectRect } from "./utils.js";
6
6
  export class Canvas {
7
- buf;
8
- width;
9
- height;
10
- format;
11
- defaultFormat;
12
- styles;
13
- clipRects;
14
7
  constructor(width, height, format = NONE, style = STYLE_ASCII) {
15
8
  this.width = width;
16
9
  this.height = height;
package/circle.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
  * Draws a circle (filled or outline) at given center position and
5
5
  * radius and taking the current clip rect and format into account. If
package/circle.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { peek } from "@thi.ng/arrays/peek";
2
- import { hline } from "./hvline";
3
- import { charCode, intersectRectCircle } from "./utils";
2
+ import { hline } from "./hvline.js";
3
+ import { charCode, intersectRectCircle } from "./utils.js";
4
4
  /**
5
5
  * Draws a circle (filled or outline) at given center position and
6
6
  * radius and taking the current clip rect and format into account. If
package/format.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { StringFormat } from "@thi.ng/text-format";
2
- import type { Canvas } from "./canvas";
2
+ import type { Canvas } from "./canvas.js";
3
3
  /**
4
4
  * Returns string representation of canvas, optionally using given string
5
5
  * formatter. If none is given, returns plain string representation, ignoring
package/hvline.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
  * Draws horizontal line from `x`,`y`, taking the current clip rect,
5
5
  * format and style into account. The optional `s`, `e` (line endings)
package/hvline.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { peek } from "@thi.ng/arrays/peek";
2
- import { charCode } from "./utils";
2
+ import { charCode } from "./utils.js";
3
3
  /**
4
4
  * Draws horizontal line from `x`,`y`, taking the current clip rect,
5
5
  * format and style into account. The optional `s`, `e` (line endings)
package/image.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { UIntArray } from "@thi.ng/api";
2
- import { ImageOpts } from "./api";
3
- import { Canvas } from "./canvas";
2
+ import { ImageOpts } from "./api.js";
3
+ import { Canvas } from "./canvas.js";
4
4
  export declare const blit: (canvas: Canvas, x: number, y: number, src: Canvas) => void;
5
5
  export declare const resize: (canvas: Canvas, newWidth: number, newHeight: number) => void;
6
6
  export declare const extract: (canvas: Canvas, x: number, y: number, w: number, h: number) => Canvas;
package/image.js CHANGED
@@ -2,10 +2,10 @@ import { peek } from "@thi.ng/arrays/peek";
2
2
  import { isNumber } from "@thi.ng/checks/is-number";
3
3
  import { clamp0 } from "@thi.ng/math/interval";
4
4
  import { FMT_ANSI565 } from "@thi.ng/text-format/ansi";
5
- import { SHADES_BLOCK } from "./api";
6
- import { canvas, Canvas } from "./canvas";
7
- import { formatCanvas } from "./format";
8
- import { charCode, intersectRect } from "./utils";
5
+ import { SHADES_BLOCK } from "./api.js";
6
+ import { canvas, Canvas } from "./canvas.js";
7
+ import { formatCanvas } from "./format.js";
8
+ import { charCode, intersectRect } from "./utils.js";
9
9
  export const blit = (canvas, x, y, src) => {
10
10
  x |= 0;
11
11
  y |= 0;
package/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export * from "./api";
2
- export * from "./bars";
3
- export * from "./canvas";
4
- export * from "./circle";
5
- export * from "./format";
6
- export * from "./hvline";
7
- export * from "./image";
8
- export * from "./line";
9
- export * from "./rect";
10
- export * from "./table";
11
- export * from "./text";
12
- export * from "./utils";
1
+ export * from "./api.js";
2
+ export * from "./bars.js";
3
+ export * from "./canvas.js";
4
+ export * from "./circle.js";
5
+ export * from "./format.js";
6
+ export * from "./hvline.js";
7
+ export * from "./image.js";
8
+ export * from "./line.js";
9
+ export * from "./rect.js";
10
+ export * from "./table.js";
11
+ export * from "./text.js";
12
+ export * from "./utils.js";
13
13
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
- export * from "./api";
2
- export * from "./bars";
3
- export * from "./canvas";
4
- export * from "./circle";
5
- export * from "./format";
6
- export * from "./hvline";
7
- export * from "./image";
8
- export * from "./line";
9
- export * from "./rect";
10
- export * from "./table";
11
- export * from "./text";
12
- export * from "./utils";
1
+ export * from "./api.js";
2
+ export * from "./bars.js";
3
+ export * from "./canvas.js";
4
+ export * from "./circle.js";
5
+ export * from "./format.js";
6
+ export * from "./hvline.js";
7
+ export * from "./image.js";
8
+ export * from "./line.js";
9
+ export * from "./rect.js";
10
+ export * from "./table.js";
11
+ export * from "./text.js";
12
+ export * from "./utils.js";
package/line.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
  * Draws a line between `ax`,`ay` and `bx`,`by`, using `char` and taking
5
5
  * the current clip rect and format into account. If `char` is not
package/line.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { peek } from "@thi.ng/arrays/peek";
2
2
  import { liangBarsky2Raw } from "@thi.ng/geom-clip-line/liang-barsky";
3
- import { charCode } from "./utils";
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/text-canvas",
3
- "version": "2.0.0",
3
+ "version": "2.0.6",
4
4
  "description": "Text based canvas, drawing, tables with arbitrary formatting (incl. ANSI/HTML)",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,17 +34,17 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.0.0",
38
- "@thi.ng/arrays": "^2.0.0",
39
- "@thi.ng/checks": "^3.0.0",
40
- "@thi.ng/geom-clip-line": "^2.0.0",
41
- "@thi.ng/math": "^5.0.0",
42
- "@thi.ng/strings": "^3.0.0",
43
- "@thi.ng/text-format": "^0.1.0",
44
- "@thi.ng/transducers": "^8.0.0"
37
+ "@thi.ng/api": "^8.0.6",
38
+ "@thi.ng/arrays": "^2.0.6",
39
+ "@thi.ng/checks": "^3.0.6",
40
+ "@thi.ng/geom-clip-line": "^2.0.6",
41
+ "@thi.ng/math": "^5.0.6",
42
+ "@thi.ng/strings": "^3.1.2",
43
+ "@thi.ng/text-format": "^1.0.6",
44
+ "@thi.ng/transducers": "^8.0.6"
45
45
  },
46
46
  "devDependencies": {
47
- "@thi.ng/testament": "^0.1.0"
47
+ "@thi.ng/testament": "^0.1.6"
48
48
  },
49
49
  "keywords": [
50
50
  "4bit",
@@ -78,6 +78,9 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
+ "engines": {
82
+ "node": ">=12.7"
83
+ },
81
84
  "files": [
82
85
  "*.js",
83
86
  "*.d.ts"
@@ -129,5 +132,5 @@
129
132
  ],
130
133
  "year": 2020
131
134
  },
132
- "gitHead": "9ac1344b38b565eb894306fbf72233b6c0b2d115"
135
+ "gitHead": "c17a556ad25f6882dfa8f806a1d9e8ed7ac7cd71"
133
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
1
  import { peek } from "@thi.ng/arrays/peek";
2
- import { hline, vline } from "./hvline";
3
- import { charCode } from "./utils";
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
1
  import { peek } from "@thi.ng/arrays/peek";
2
2
  import { isString } from "@thi.ng/checks/is-string";
3
3
  import { wordWrapLines } from "@thi.ng/strings/word-wrap";
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";
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
1
  import { peek } from "@thi.ng/arrays/peek";
2
2
  import { clamp0 } from "@thi.ng/math/interval";
3
3
  import { wordWrapLines } from "@thi.ng/strings/word-wrap";
4
- import { beginClip, beginStyle, endClip, endStyle } from "./canvas";
5
- import { fillRect, strokeRect } from "./rect";
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
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>;