@mailwoman/map-tui 10.0.0 → 10.1.0

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.
Files changed (58) hide show
  1. package/README.md +5 -6
  2. package/{lib/cli → cli}/args.ts +49 -28
  3. package/{lib/cli/index.ts → cli/main.ts} +12 -23
  4. package/lib/browser.ts +33 -76
  5. package/lib/frame.ts +50 -28
  6. package/lib/input.ts +46 -69
  7. package/lib/mercator.ts +13 -12
  8. package/lib/mvt.ts +2 -2
  9. package/lib/raster.ts +53 -27
  10. package/lib/renderer.ts +19 -38
  11. package/lib/style.ts +21 -15
  12. package/lib/tile-source.ts +30 -19
  13. package/out/browser.d.ts +24 -33
  14. package/out/browser.d.ts.map +1 -1
  15. package/out/browser.js +27 -72
  16. package/out/browser.js.map +1 -1
  17. package/out/cli/args.d.ts +18 -8
  18. package/out/cli/args.d.ts.map +1 -1
  19. package/out/cli/args.js +41 -25
  20. package/out/cli/args.js.map +1 -1
  21. package/out/cli/{index.d.ts → main.d.ts} +1 -1
  22. package/out/cli/main.d.ts.map +1 -0
  23. package/out/cli/{index.js → main.js} +13 -24
  24. package/out/cli/main.js.map +1 -0
  25. package/out/cli/tsconfig.tsbuildinfo +1 -0
  26. package/out/frame.d.ts +40 -23
  27. package/out/frame.d.ts.map +1 -1
  28. package/out/frame.js +48 -26
  29. package/out/frame.js.map +1 -1
  30. package/out/input.d.ts +18 -36
  31. package/out/input.d.ts.map +1 -1
  32. package/out/input.js +37 -63
  33. package/out/input.js.map +1 -1
  34. package/out/mercator.d.ts +12 -11
  35. package/out/mercator.d.ts.map +1 -1
  36. package/out/mercator.js +4 -10
  37. package/out/mercator.js.map +1 -1
  38. package/out/mvt.js +2 -2
  39. package/out/raster.d.ts +45 -23
  40. package/out/raster.d.ts.map +1 -1
  41. package/out/raster.js +44 -22
  42. package/out/raster.js.map +1 -1
  43. package/out/renderer.d.ts +6 -7
  44. package/out/renderer.d.ts.map +1 -1
  45. package/out/renderer.js +13 -22
  46. package/out/renderer.js.map +1 -1
  47. package/out/style.d.ts +17 -11
  48. package/out/style.d.ts.map +1 -1
  49. package/out/style.js +11 -9
  50. package/out/style.js.map +1 -1
  51. package/out/tile-source.d.ts +12 -8
  52. package/out/tile-source.d.ts.map +1 -1
  53. package/out/tile-source.js +21 -14
  54. package/out/tile-source.js.map +1 -1
  55. package/out/tsconfig.test.tsbuildinfo +1 -1
  56. package/package.json +35 -83
  57. package/out/cli/index.d.ts.map +0 -1
  58. package/out/cli/index.js.map +0 -1
package/out/frame.js CHANGED
@@ -6,17 +6,24 @@
6
6
  /**
7
7
  * Braille frame value + conversion for map-tui's debug view.
8
8
  *
9
- * `rasterizeToFrame` turns an `RGBAGrid` (drawn by ./raster.ts) into a `MapFrame`: one codepoint and one packed color
10
- * per cell. The braille dither/luminance work is asciify's — `FrameRasterizer` subclasses `AsciifyTerminal` with a
11
- * no-op sink purely to reach its protected `_computeBrailleCells`, `_cellChars`, `_cellColors`, so this module never
12
- * re-implements the dot math. `frameToANSILines` and `overlayText` then work on the plain `MapFrame` value, with no
13
- * further asciify dependency; `blitFrame` is the path back the other way, for callers driving a live terminal.
9
+ * `rasterizeToFrame` turns an `RGBAGrid` (drawn by ./raster.ts) into a `MapFrame`:
10
+ * one codepoint and one packed color per cell.
11
+ * The braille dither/luminance work is asciify's.
12
+ *
13
+ * `FrameRasterizer` subclasses `AsciifyTerminal` with a no-op sink purely to reach its guarded
14
+ * `_computeBrailleCells`, `_cellChars`, `_cellColors`, so this module never re-implements the dot math.
15
+ *
16
+ * `frameToANSILines` and `overlayText` then work on the plain `MapFrame` value, with no further
17
+ * asciify dependency; `blitFrame` is the path back the other way, for callers driving a live terminal.
14
18
  */
15
19
  import { AsciifyTerminal, SGR_RESET } from "@sister.software/asciify/tui";
16
20
  /**
17
- * Reaches asciify's protected braille conversion from the outside. Constructed fresh per {@link rasterizeToFrame} call
18
- * — cheap, since the state is just two typed arrays sized to the cell grid. The `write` sink is never invoked: this
19
- * class only ever calls `_computeBrailleCells` directly, never `rasterize`/`flush`.
21
+ * Reaches asciify's guarded braille conversion from the outside.
22
+ *
23
+ * Constructed fresh per {@link rasterizeToFrame} call — cheap, since the state
24
+ * is just two typed arrays sized to the cell grid.
25
+ * The `write` sink is never invoked: this class only ever calls `_computeBrailleCells`
26
+ * directly, never `rasterize`/`flush`.
20
27
  */
21
28
  class FrameRasterizer extends AsciifyTerminal {
22
29
  constructor(columns, rows) {
@@ -29,10 +36,12 @@ class FrameRasterizer extends AsciifyTerminal {
29
36
  }
30
37
  }
31
38
  /**
32
- * Converts a 2×4-subpixel RGBA grid into braille cells. Grid must be `columns * 2` x `rows * 4`.
39
+ * Converts a 2×4-subpixel rgba grid into braille cells.
33
40
  *
34
- * @throws If the grid's dimensions don't match `columns * 2` x `rows * 4` — a caller sizing bug, not something to
35
- * silently clip.
41
+ * Grid must be `columns * 2` x `rows * 4`.
42
+ *
43
+ * @throws If the grid's dimensions don't match `columns * 2` x `rows * 4` —
44
+ * a caller sizing bug rather than something to silently clip.
36
45
  */
37
46
  export function rasterizeToFrame(grid, columns, rows, attribution) {
38
47
  if (grid.width !== columns * 2 || grid.height !== rows * 4) {
@@ -43,11 +52,14 @@ export function rasterizeToFrame(grid, columns, rows, attribution) {
43
52
  return { columns, rows, chars, colors, attribution };
44
53
  }
45
54
  /**
46
- * One SGR-styled string per row. `color: false` strips styling (NO_COLOR consumers).
55
+ * One SGR-styled string per row.
56
+ *
57
+ * `color: false` strips styling (NO_COLOR consumers).
47
58
  *
48
- * Inkless cells (packed color 0) never emit a color escape, matching asciify's own damage emitter — a cell going from
49
- * inked to inkless shouldn't touch color state. Each styled line ends with the SGR reset so a truncated terminal write
50
- * never bleeds color into whatever follows.
59
+ * Inkless cells (packed color 0) never emit a color escape, matching asciify's own damage
60
+ * emitter — a cell going from inked to inkless shouldn't touch color state.
61
+ * Each styled line ends with the SGR reset so a truncated terminal write never
62
+ * bleeds color into whatever follows.
51
63
  */
52
64
  export function frameToANSILines(frame, options) {
53
65
  const colorEnabled = options?.color ?? true;
@@ -73,9 +85,11 @@ export function frameToANSILines(frame, options) {
73
85
  /**
74
86
  * Writes text into cells (clipped); occupied is the label-collision bitmap, updated in place.
75
87
  *
76
- * When `occupied` is given, every target cell plus one cell of padding on each side is checked before anything is
77
- * written — a single colliding cell rejects the whole label rather than partially overlaying it. Without `occupied`,
78
- * writes proceed unconditionally (still clipped to the frame's bounds) and always report success.
88
+ * When `occupied` is given, every target cell plus one cell of padding on each side is
89
+ * checked before anything is written — a single colliding cell rejects the whole label
90
+ * rather than partially overlaying it.
91
+ * Without `occupied`, writes proceed unconditionally (still clipped to the frame's bounds)
92
+ * and always report success.
79
93
  */
80
94
  export function overlayText(frame, column, row, text, color, occupied) {
81
95
  if (row < 0 || row >= frame.rows)
@@ -107,23 +121,31 @@ export function overlayText(frame, column, row, text, color, occupied) {
107
121
  return true;
108
122
  }
109
123
  /**
110
- * Packs RGB channels into the frame's 0xRRGGBB color representation. Shared with Task 8's marker colors so both sides
111
- * of the frame boundary agree on the packing.
124
+ * Packs RGB channels into the frame's 0xRRGGBB color representation.
125
+ *
126
+ * Shared with Task 8's marker colors so both sides of the frame boundary agree on the packing.
112
127
  */
113
128
  export function rgbToPacked(color) {
114
129
  return (color[0] << 16) | (color[1] << 8) | color[2];
115
130
  }
116
131
  /**
117
- * Codepoint written for a cell the frame left empty. `MapFrame` stores 0 there; `AsciifyTerminal` expects a real
118
- * character, and normalizes a space to the inkless color itself.
132
+ * Codepoint written for a cell the frame left empty.
133
+ *
134
+ * `MapFrame` stores 0 there.
135
+ * `AsciifyTerminal` expects a real character. and normalizes a space to the inkless color itself.
119
136
  */
120
137
  const SPACE_CODEPOINT = 0x20;
121
138
  /**
122
- * Writes a frame's cells into an `AsciifyTerminal`'s current frame. Call `flush()` afterwards to emit the damage.
139
+ * Writes a frame's cells into an `AsciifyTerminal`'s current frame.
140
+ *
141
+ * Call `flush()` afterwards to emit the damage.
142
+ *
143
+ * The frame's packed color is the exact representation asciify canonicalizes truecolor to,
144
+ * so this is a copy and not a conversion.
145
+ * The channels are unpacked here only because {@linkcode AsciifyTerminal.setCell} takes them apart.
123
146
  *
124
- * The frame's packed color is the exact representation asciify canonicalizes truecolor to, so this is a copy and not a
125
- * conversion — the channels are unpacked here only because {@linkcode AsciifyTerminal.setCell} takes them apart. Cells
126
- * beyond the terminal's own grid are dropped by `setCell`, so a frame larger than the pane clips rather than throws.
147
+ * Cells beyond the terminal's own grid are dropped by `setCell`, so a frame
148
+ * larger than the pane clips rather than throws.
127
149
  */
128
150
  export function blitFrame(terminal, frame) {
129
151
  for (let row = 0; row < frame.rows; row++) {
package/out/frame.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"frame.js","sourceRoot":"","sources":["../lib/frame.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAsBzE;;;;GAIG;AACH,MAAM,eAAgB,SAAQ,eAAe;IAC5C,YAAY,OAAe,EAAE,IAAY;QACxC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAA;QACpH,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,CAAC,MAAyB;QAChC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QAExC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAA;IAC5E,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAg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C,CAAC,CAAA;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,IAAI,CAAA;AAE5B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,QAAyB,EAAE,KAAe;IACnE,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;QAC3C,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;YACvD,MAAM,SAAS,GAAG,GAAG,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA;YAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAE,CAAA;YACpC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAE,CAAA;YAEtC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE;gBAClE,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI;gBACpB,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI;gBACnB,KAAK,GAAG,IAAI;aACZ,CAAC,CAAA;QACH,CAAC;IACF,CAAC;AACF,CAAC"}
package/out/input.d.ts CHANGED
@@ -4,50 +4,32 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
6
  /**
7
- * Terminal input decoding for the interactive map browser.
8
- *
9
- * `decodeInputChunk` turns a raw-mode stdin chunk into zero or more {@link MapTUIInput} events. It stays pure — the
10
- * caller owns the only state there is, the unresolved trailing fragment the function hands back — so one chunk in gives
11
- * the same events out every time.
12
- *
13
- * THE FALLBACK IS THE DANGEROUS PART. An ESC this decoder had no rule for used to mean "the Esc key", i.e. QUIT, which
14
- * made every unrecognized escape sequence a quit: F1 (`ESC O P`), an OSC reply the terminal sends unasked (`ESC ] 11 ;
15
- * rgb:… BEL`), and — worst, because it needs no exotic key at all — a mouse report split across two stdin reads, whose
16
- * first half ends inside the sequence. So the fallback now separates three cases:
17
- *
18
- * - A sequence this decoder recognizes is consumed and acted on (arrows, SGR mouse).
19
- * - A sequence it does NOT recognize is consumed WHOLE and ignored: CSI (`ESC [ … final`), SS3 (`ESC O final`), and the
20
- * string family (OSC/DCS/SOS/PM/APC, terminated by BEL or ST). Re-scanning their bodies as characters is how a `q`
21
- * inside a cursor-position report quit the app.
22
- * - A chunk that ENDS mid-sequence — including a lone trailing ESC, which is byte-for-byte the start of one — is not
23
- * decoded at all: it comes back as {@link DecodedInput.pending} for the caller to prepend to the next chunk. Quit is
24
- * emitted only for an ESC that is neither, i.e. one whose following byte cannot continue a sequence.
25
- *
26
- * Holding costs a lone Esc keypress its effect until the next byte arrives. That is the right side of the trade for a
27
- * browser whose advertised quit keys are `q` and Ctrl+C: the alternative is a drag ending the session because the
28
- * kernel split a read.
29
- *
30
- * Mouse reports are SGR-encoded (DEC private mode 1006), which is what {@link MOUSE_ENABLE} asks for. Their coordinates
31
- * are 1-based on the wire and 0-based in every event here — the off-by-one lives at this boundary and nowhere else.
7
+ * The fallback separates a sequence this decoder recognizes (consumed and acted on), a complete
8
+ * but unrecognized sequence (consumed whole so a `q` inside it cannot quit the app), and a
9
+ * chunk that ends mid-sequence (returned as {@link DecodedInput.pending} rather than decoded),
10
+ * emitting quit only for an ESC whose following byte cannot continue a sequence.
32
11
  */
33
12
  /**
34
- * Enables mouse reporting: button events (1000), drag/button-motion tracking (1002), and SGR extended coordinates
35
- * (1006) so columns past 223 survive.
13
+ * Enables mouse reporting: button events (1000), drag/button-motion tracking (1002),
14
+ * and SGR extended coordinates (1006) so columns past 223 survive.
36
15
  */
37
16
  export declare const MOUSE_ENABLE = "\u001B[?1000h\u001B[?1002h\u001B[?1006h";
38
17
  /**
39
- * Disables mouse reporting, in the reverse order it was enabled.
18
+ * Disables the three mouse-reporting modes {@link MOUSE_ENABLE} turns on.
40
19
  */
41
20
  export declare const MOUSE_DISABLE = "\u001B[?1006l\u001B[?1002l\u001B[?1000l";
42
21
  /**
43
- * A decoded input event. Pan and zoom carry direction and magnitude only — how far a step moves the map is the
44
- * browser's decision, not the decoder's.
22
+ * A decoded input event.
23
+ *
24
+ * Pan and zoom encode direction and magnitude only, since how far a step moves the
25
+ * map is the browser's decision rather than the decoder's.
45
26
  */
46
27
  export type MapTUIInput = {
47
28
  kind: "quit";
48
29
  }
49
30
  /**
50
- * Ctrl+C. Distinct from `quit` because the process must exit 130, and because raw mode means no SIGINT is raised.
31
+ * Ctrl+C sends an interrupt. The process exits with status 130.
32
+ * Raw mode prevents the terminal from raising SIGINT.
51
33
  */
52
34
  | {
53
35
  kind: "interrupt";
@@ -75,19 +57,19 @@ export type MapTUIInput = {
75
57
  kind: "release";
76
58
  };
77
59
  /**
78
- * One decoded chunk: its events, plus whatever trailing bytes could not be decoded YET.
60
+ * One decoded chunk: its events, plus whatever trailing bytes could not be decoded yet.
79
61
  */
80
62
  export interface DecodedInput {
81
63
  events: MapTUIInput[];
82
64
  /**
83
- * An unresolved escape fragment from the end of the chunk — prepend it to the next one. Empty when the chunk ended
84
- * cleanly, which is the overwhelmingly common case.
65
+ * An unresolved escape fragment from the end of the chunk to prepend to the next,
66
+ * empty when the chunk ended cleanly.
85
67
  */
86
68
  pending: string;
87
69
  }
88
70
  /**
89
- * Decodes one raw-mode stdin chunk into input events. Unrecognized bytes are dropped; an unresolved trailing escape
90
- * fragment is returned rather than decoded, and the caller passes it back as `pending` with the next chunk.
71
+ * Decodes one raw-mode stdin chunk into input events, dropping unrecognized bytes
72
+ * and returning an unresolved trailing escape fragment as `pending`.
91
73
  */
92
74
  export declare function decodeInputChunk(chunk: string, pending?: string): DecodedInput;
93
75
  //# sourceMappingURL=input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../lib/input.ts"],"names":[],"mappings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,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,aAAa,4CAA4C,CAAA;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACpB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;AAClB;;;GAGG;GACD;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAyGtB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;CACf;AAkCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG,YAAY,CAqE1E"}
package/out/input.js CHANGED
@@ -4,39 +4,18 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
6
  /**
7
- * Terminal input decoding for the interactive map browser.
8
- *
9
- * `decodeInputChunk` turns a raw-mode stdin chunk into zero or more {@link MapTUIInput} events. It stays pure — the
10
- * caller owns the only state there is, the unresolved trailing fragment the function hands back — so one chunk in gives
11
- * the same events out every time.
12
- *
13
- * THE FALLBACK IS THE DANGEROUS PART. An ESC this decoder had no rule for used to mean "the Esc key", i.e. QUIT, which
14
- * made every unrecognized escape sequence a quit: F1 (`ESC O P`), an OSC reply the terminal sends unasked (`ESC ] 11 ;
15
- * rgb:… BEL`), and — worst, because it needs no exotic key at all — a mouse report split across two stdin reads, whose
16
- * first half ends inside the sequence. So the fallback now separates three cases:
17
- *
18
- * - A sequence this decoder recognizes is consumed and acted on (arrows, SGR mouse).
19
- * - A sequence it does NOT recognize is consumed WHOLE and ignored: CSI (`ESC [ … final`), SS3 (`ESC O final`), and the
20
- * string family (OSC/DCS/SOS/PM/APC, terminated by BEL or ST). Re-scanning their bodies as characters is how a `q`
21
- * inside a cursor-position report quit the app.
22
- * - A chunk that ENDS mid-sequence — including a lone trailing ESC, which is byte-for-byte the start of one — is not
23
- * decoded at all: it comes back as {@link DecodedInput.pending} for the caller to prepend to the next chunk. Quit is
24
- * emitted only for an ESC that is neither, i.e. one whose following byte cannot continue a sequence.
25
- *
26
- * Holding costs a lone Esc keypress its effect until the next byte arrives. That is the right side of the trade for a
27
- * browser whose advertised quit keys are `q` and Ctrl+C: the alternative is a drag ending the session because the
28
- * kernel split a read.
29
- *
30
- * Mouse reports are SGR-encoded (DEC private mode 1006), which is what {@link MOUSE_ENABLE} asks for. Their coordinates
31
- * are 1-based on the wire and 0-based in every event here — the off-by-one lives at this boundary and nowhere else.
7
+ * The fallback separates a sequence this decoder recognizes (consumed and acted on), a complete
8
+ * but unrecognized sequence (consumed whole so a `q` inside it cannot quit the app), and a
9
+ * chunk that ends mid-sequence (returned as {@link DecodedInput.pending} rather than decoded),
10
+ * emitting quit only for an ESC whose following byte cannot continue a sequence.
32
11
  */
33
12
  /**
34
- * Enables mouse reporting: button events (1000), drag/button-motion tracking (1002), and SGR extended coordinates
35
- * (1006) so columns past 223 survive.
13
+ * Enables mouse reporting: button events (1000), drag/button-motion tracking (1002),
14
+ * and SGR extended coordinates (1006) so columns past 223 survive.
36
15
  */
37
16
  export const MOUSE_ENABLE = "\u001B[?1000h\u001B[?1002h\u001B[?1006h";
38
17
  /**
39
- * Disables mouse reporting, in the reverse order it was enabled.
18
+ * Disables the three mouse-reporting modes {@link MOUSE_ENABLE} turns on.
40
19
  */
41
20
  export const MOUSE_DISABLE = "\u001B[?1006l\u001B[?1002l\u001B[?1000l";
42
21
  const ESC = "\u001B";
@@ -52,46 +31,48 @@ const MOUSE_SGR_PATTERN = /\u001B\[<(\d+);(\d+);(\d+)([Mm])/y;
52
31
  */
53
32
  const ARROW_PATTERN = /\u001B(?:\[|O)([ABCD])/y;
54
33
  /**
55
- * Any other CSI sequence, consumed whole and ignored. Without this, an unhandled sequence's body would be re-scanned as
56
- * individual key presses, and a stray `q` inside one would quit the app.
34
+ * Any other CSI sequence, consumed whole and ignored so an unhandled body is not re-scanned as key presses.
57
35
  */
58
36
  const UNKNOWN_CSI_PATTERN = /\u001B\[[\d;<>?]*[\u0020-\u002F]*[\u0040-\u007E]/y;
59
37
  /**
60
- * Any other SS3 sequence (`ESC O <final>`) — F1–F4 on xterm, and the numeric keypad in application mode. Two bytes
61
- * shorter than a CSI, and until this pattern existed the likeliest key on a keyboard to quit the browser by accident.
38
+ * Any other SS3 sequence (`ESC O <final>`).
39
+ *
40
+ * On xterm this includes F1–F4 and the application-mode numeric keypad.
62
41
  */
63
42
  const UNKNOWN_SS3_PATTERN = /\u001BO[\u0040-\u007E]/y;
64
43
  /**
65
- * The string-sequence family: OSC (`ESC ]`), DCS (`ESC P`), SOS (`ESC X`), PM (`ESC ^`), APC (`ESC _`), each running to
66
- * a BEL or an ST (`ESC \`). A terminal sends these UNASKED — an OSC colour or clipboard reply lands on stdin with no
67
- * key pressed — so consuming them is not a nicety.
44
+ * The string-sequence family (OSC, DCS, SOS, PM, APC), each running to a BEL
45
+ * or an ST, sent unasked by a terminal with no key pressed.
68
46
  */
69
47
  const STRING_SEQUENCE_PATTERN = /\u001B[P\]X^_][\s\S]*?(?:\u0007|\u001B\\)/y;
70
48
  /**
71
- * Every "unrecognized but complete" sequence, in the order they are tried. Sharing one list is what keeps a new
72
- * sequence family from being added to the consumer and forgotten in the incomplete test below.
49
+ * Every "unrecognized but complete" sequence, in the order they are tried.
50
+ *
51
+ * One shared list keeps a new family from being added here and forgotten in the incomplete test.
73
52
  */
74
53
  const UNRECOGNIZED_PATTERNS = [UNKNOWN_CSI_PATTERN, UNKNOWN_SS3_PATTERN, STRING_SEQUENCE_PATTERN];
75
54
  /**
76
- * A chunk that STOPS inside a sequence. The end-anchors are what make these "incomplete" rather than "unrecognized":
77
- * each requires the WHOLE remainder of the chunk to be a legal prefix and nothing more. The first covers both a lone
78
- * trailing ESC and an `ESC O` still waiting for its final byte.
55
+ * A chunk that stops inside a sequence, each end-anchored pattern requiring the whole
56
+ * remainder of the chunk to be a legal prefix and no more.
79
57
  */
80
58
  const PARTIAL_PATTERNS = [/\u001BO?$/y, /\u001B\[[\d;<>?]*[\u0020-\u002F]*$/y, /\u001B[P\]X^_][^\u0007]*$/y];
81
59
  /* oxlint-enable no-control-regex */
82
60
  /**
83
- * Wheel reports set bit 6 of the button field; the low bit then separates up (0) from down (1).
61
+ * Wheel reports set bit 6 of the button field.
62
+ * The low bit separates up (0) from down (1).
84
63
  */
85
64
  const WHEEL_FLAG = 64;
86
65
  /**
87
- * Motion reports set bit 5. With mode 1002 that means "moved with a button held" — a drag.
66
+ * Motion reports set bit 5.
67
+ *
68
+ * In mode 1002, that bit means "moved with a button held" — a drag.
88
69
  */
89
70
  const MOTION_FLAG = 32;
90
71
  const BUTTON_MASK = 3;
91
72
  const LEFT_BUTTON = 0;
92
73
  /**
93
- * The longest fragment worth holding for the next chunk (64 KB). See the drop site: this bounds an unterminated string
94
- * sequence, not a real key.
74
+ * The longest fragment held for the next chunk (64 KB), bounding an unterminated
75
+ * string sequence rather than a real key.
95
76
  */
96
77
  const MAX_PENDING_LENGTH = 65_536;
97
78
  const ARROW_INPUTS = {
@@ -101,9 +82,13 @@ const ARROW_INPUTS = {
101
82
  D: { kind: "pan", dx: -1, dy: 0 },
102
83
  };
103
84
  /**
104
- * Single-character bindings. `a`/`z` are mapscii's zoom keys, `+`/`-` the ones every other map uses, and `hjkl` the vim
105
- * pan set mapscii also accepts. `y` joins `z` for zoom-out because on a QWERTZ keyboard it sits where `z` does on
106
- * QWERTY — mapscii binds both for the same reason.
85
+ * Single-character bindings taken from mapscii.
86
+ *
87
+ * `a` and `z` zoom.
88
+ * `+` and `-` form the common pair.
89
+ *
90
+ * `hjkl` pans like vim.
91
+ * `y` zooms out beside `z` on QWERTZ keyboards, where QWERTY places `z`.
107
92
  */
108
93
  const CHARACTER_INPUTS = {
109
94
  q: { kind: "quit" },
@@ -120,9 +105,6 @@ const CHARACTER_INPUTS = {
120
105
  k: { kind: "pan", dx: 0, dy: -1 },
121
106
  l: { kind: "pan", dx: 1, dy: 0 },
122
107
  };
123
- /**
124
- * The length of the unrecognized-but-complete sequence at `index`, or null when there isn't one.
125
- */
126
108
  function consumeUnrecognized(buffer, index) {
127
109
  for (const pattern of UNRECOGNIZED_PATTERNS) {
128
110
  pattern.lastIndex = index;
@@ -131,10 +113,6 @@ function consumeUnrecognized(buffer, index) {
131
113
  }
132
114
  return null;
133
115
  }
134
- /**
135
- * True when everything from `index` to the end of the chunk is a legal PREFIX of a sequence — i.e. the terminal is
136
- * mid-sequence and the rest is in the next read.
137
- */
138
116
  function isIncompleteSequence(buffer, index) {
139
117
  for (const pattern of PARTIAL_PATTERNS) {
140
118
  pattern.lastIndex = index;
@@ -143,9 +121,6 @@ function isIncompleteSequence(buffer, index) {
143
121
  }
144
122
  return false;
145
123
  }
146
- /**
147
- * Builds the event for one SGR mouse report.
148
- */
149
124
  function mouseInput(button, column, row, final) {
150
125
  if (button & WHEEL_FLAG) {
151
126
  return { kind: "wheel", delta: button & 1 ? -1 : 1, column, row };
@@ -157,8 +132,8 @@ function mouseInput(button, column, row, final) {
157
132
  return button & MOTION_FLAG ? { kind: "drag", column, row } : { kind: "press", column, row };
158
133
  }
159
134
  /**
160
- * Decodes one raw-mode stdin chunk into input events. Unrecognized bytes are dropped; an unresolved trailing escape
161
- * fragment is returned rather than decoded, and the caller passes it back as `pending` with the next chunk.
135
+ * Decodes one raw-mode stdin chunk into input events, dropping unrecognized bytes
136
+ * and returning an unresolved trailing escape fragment as `pending`.
162
137
  */
163
138
  export function decodeInputChunk(chunk, pending = "") {
164
139
  const events = [];
@@ -199,10 +174,9 @@ export function decodeInputChunk(chunk, pending = "") {
199
174
  // The buffer stops inside a sequence — hand the fragment back instead of guessing at it.
200
175
  if (isIncompleteSequence(buffer, index)) {
201
176
  const fragment = buffer.slice(index);
202
- // …unless it has stopped being plausible. An unterminated string sequence would otherwise grow the held
203
- // fragment for the life of the process. Dropping is the safe failure: it emits nothing, where flushing
204
- // the fragment back through the decoder would read its body as keys, which is the bug this all exists
205
- // for. The cap is generous because an OSC 52 clipboard reply is legitimately large.
177
+ // An unterminated string sequence could grow the held fragment for the life of the process.
178
+ // Drop an overlong fragment.
179
+ // A body flush would make terminal content read as key presses.
206
180
  return { events, pending: fragment.length > MAX_PENDING_LENGTH ? "" : fragment };
207
181
  }
208
182
  // An ESC whose next byte cannot continue a sequence: the Esc KEY.
package/out/input.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sourceRoot":"","sources":["../lib/input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,yCAAyC,CAAA;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,yCAAyC,CAAA;AAmBtE,MAAM,GAAG,GAAG,QAAQ,CAAA;AACpB,MAAM,MAAM,GAAG,QAAQ,CAAA;AAEvB;6FAC6F;AAE7F;;GAEG;AACH,MAAM,iBAAiB,GAAG,mCAAmC,CAAA;AAE7D;;GAEG;AACH,MAAM,aAAa,GAAG,yBAAyB,CAAA;AAE/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,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QACjF,CAAC;QAED,kEAAkE;QAClE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;QAC7B,KAAK,IAAI,CAAC,CAAA;IACX,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;AAC/B,CAAC"}
package/out/mercator.d.ts CHANGED
@@ -6,33 +6,34 @@
6
6
  /**
7
7
  * Web-Mercator projection math for map-tui.
8
8
  *
9
- * This module reimplements the standard Web-Mercator projection (EPSG:3857) math locally rather than importing from
10
- * `@mailwoman/cartographer` or `@mailwoman/spatial`. The cartographer dependency drags maplibre-gl +
11
- * `@mailwoman/tiger`; spatial drags `@mailwoman/core`'s shipped data. map-tui maintains a dependency-lean surface for
12
- * the standalone `npx` story (the nuts-lookup precedent).
9
+ * This module reimplements the standard Web-Mercator projection (epsg:3857) math locally
10
+ * rather than importing from `@mailwoman/cartographer` or `@mailwoman/spatial`.
11
+ * The cartographer dependency drags maplibre-gl + `@mailwoman/tiger`;
12
+ * spatial drags `@mailwoman/core`'s shipped data.
13
+ *
14
+ * Map-tui maintains a dependency-lean surface for the standalone `npx` story (the nuts-lookup precedent).
13
15
  */
16
+ import type { LatLon } from "@mailwoman/spatial";
14
17
  /**
15
18
  * Number of pixels per tile in the Web-Mercator projection (standard: 256).
16
19
  */
17
20
  export declare const TILE_SIZE = 256;
18
- export interface LonLat {
19
- lon: number;
20
- lat: number;
21
- }
22
21
  export interface WorldPx {
23
22
  x: number;
24
23
  y: number;
25
24
  }
26
25
  export declare function lonLatToWorldPx(lon: number, lat: number, zoom: number): WorldPx;
27
- export declare function worldPxToLonLat(x: number, y: number, zoom: number): LonLat;
26
+ export declare function worldPxToLonLat(x: number, y: number, zoom: number): LatLon;
28
27
  export declare function metersPerPixel(lat: number, zoom: number): number;
29
28
  /**
30
29
  * Wraps a longitude into [-180, 180) so panning past the antimeridian continues rather than running off the pyramid.
31
30
  */
32
31
  export declare function wrapLongitude(lon: number): number;
33
32
  /**
34
- * Subpixel dimensions of one braille cell — 2 columns wide, 4 rows tall. The unit every projection-to-cell conversion
35
- * works in, shared by the renderer and the browser so both sides of the frame boundary agree on the grid.
33
+ * Subpixel dimensions of one braille cell — 2 columns wide, 4 rows tall.
34
+ *
35
+ * The unit every projection-to-cell conversion works in, shared by the renderer
36
+ * and the browser so both sides of the frame boundary agree on the grid.
36
37
  */
37
38
  export declare const SUBPIXEL_COLUMNS_PER_CELL = 2;
38
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mercator.d.ts","sourceRoot":"","sources":["../lib/mercator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,MAAM,WAAW,MAAM;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,OAAO;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACT;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ/E;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ1E;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA"}
1
+ {"version":3,"file":"mercator.d.ts","sourceRoot":"","sources":["../lib/mercator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,MAAM,WAAW,OAAO;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACT;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ/E;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ1E;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA"}
package/out/mercator.js CHANGED
@@ -3,14 +3,6 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
- /**
7
- * Web-Mercator projection math for map-tui.
8
- *
9
- * This module reimplements the standard Web-Mercator projection (EPSG:3857) math locally rather than importing from
10
- * `@mailwoman/cartographer` or `@mailwoman/spatial`. The cartographer dependency drags maplibre-gl +
11
- * `@mailwoman/tiger`; spatial drags `@mailwoman/core`'s shipped data. map-tui maintains a dependency-lean surface for
12
- * the standalone `npx` story (the nuts-lookup precedent).
13
- */
14
6
  /**
15
7
  * Number of pixels per tile in the Web-Mercator projection (standard: 256).
16
8
  */
@@ -43,8 +35,10 @@ export function wrapLongitude(lon) {
43
35
  return wrapped - 180;
44
36
  }
45
37
  /**
46
- * Subpixel dimensions of one braille cell — 2 columns wide, 4 rows tall. The unit every projection-to-cell conversion
47
- * works in, shared by the renderer and the browser so both sides of the frame boundary agree on the grid.
38
+ * Subpixel dimensions of one braille cell — 2 columns wide, 4 rows tall.
39
+ *
40
+ * The unit every projection-to-cell conversion works in, shared by the renderer
41
+ * and the browser so both sides of the frame boundary agree on the grid.
48
42
  */
49
43
  export const SUBPIXEL_COLUMNS_PER_CELL = 2;
50
44
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mercator.js","sourceRoot":"","sources":["../lib/mercator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAY5B,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,GAAW,EAAE,IAAY;IACrE,MAAM,KAAK,GAAG,SAAS,GAAG,CAAC,IAAI,IAAI,CAAA;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;IAE3C,OAAO;QACN,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QAC5B,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;KACrE,CAAA;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS,EAAE,IAAY;IACjE,MAAM,KAAK,GAAG,SAAS,GAAG,CAAC,IAAI,IAAI,CAAA;IACnC,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,G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AG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;IAEjD,OAAO,OAAO,GAAG,GAAG,CAAA;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA"}
package/out/mvt.js CHANGED
@@ -6,8 +6,8 @@
6
6
  /**
7
7
  * Mapbox Vector Tile (MVT) decoding for map-tui.
8
8
  *
9
- * Wraps @mapbox/vector-tile + pbf behind a plain-data shape (DecodedLayer / DecodedFeature) so the rest of map-tui
10
- * never touches the upstream library's lazy-geometry classes.
9
+ * Wraps @mapbox/vector-tile + pbf behind a plain-data shape (DecodedLayer / DecodedFeature)
10
+ * so the rest of map-tui never touches the upstream library's lazy-geometry classes.
11
11
  */
12
12
  import { VectorTile } from "@mapbox/vector-tile";
13
13
  import { PbfReader } from "pbf";