tidepool 1.0.5 â 1.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/README.md +70 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/objects/line.d.ts +11 -0
- package/dist/objects/line.d.ts.map +1 -0
- package/dist/objects/line.js +24 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,2 +1,71 @@
|
|
|
1
1
|
# ð Tidepool
|
|
2
|
-
A TUI library written in TypeScript.
|
|
2
|
+
A TUI library written in TypeScript.
|
|
3
|
+
|
|
4
|
+
### What tidepool offers ðĨ
|
|
5
|
+
- Modular API ð§
|
|
6
|
+
- Lightweight ðŠķ
|
|
7
|
+
- Type-safe âĻïļ
|
|
8
|
+
- Easy to integrate with other technologies ðĄ
|
|
9
|
+
|
|
10
|
+
API Example using readline for movement:
|
|
11
|
+
```ts
|
|
12
|
+
import { TideScreen, Box, Text, Line } from "tidepool";
|
|
13
|
+
import readline from 'readline';
|
|
14
|
+
|
|
15
|
+
// Create new tidepool screen instance
|
|
16
|
+
const tui = new TideScreen(process.stdout.columns-1, process.stdout.rows-1);
|
|
17
|
+
|
|
18
|
+
// Create text to be displayed inside of boxes
|
|
19
|
+
const text = new Text(0, 0, "Welcome to tidepool!", 'cyan', 1);
|
|
20
|
+
const text2 = new Text(0, 1, "This is a tidepool example with readline.", 'green', 1);
|
|
21
|
+
|
|
22
|
+
// search for the middle of the screen and define first box
|
|
23
|
+
const x = Math.floor(process.stdout.columns / 2)
|
|
24
|
+
const y = Math.floor(process.stdout.rows / 2)
|
|
25
|
+
const box = new Box(x, y, 25, 3, 'magenta', 'Tidepool Box', 1);
|
|
26
|
+
|
|
27
|
+
// Define the box that will be under the other box
|
|
28
|
+
const underBox = new Box(x-5, y-5, 25, 10, 'red', 'Under the other one', 2);
|
|
29
|
+
|
|
30
|
+
// Define a cosmetic line
|
|
31
|
+
const line = new Line(0, 0, underBox.width-2, 'yellow', 1);
|
|
32
|
+
|
|
33
|
+
// Add content and components to the screen
|
|
34
|
+
box.addContent(text);
|
|
35
|
+
underBox.addContent(text2);
|
|
36
|
+
underBox.addContent(line);
|
|
37
|
+
|
|
38
|
+
tui.addComponent(box);
|
|
39
|
+
tui.addComponent(underBox);
|
|
40
|
+
|
|
41
|
+
// Render first frame
|
|
42
|
+
tui.nextFrame();
|
|
43
|
+
|
|
44
|
+
readline.emitKeypressEvents(process.stdin);
|
|
45
|
+
process.stdin.setRawMode(true);
|
|
46
|
+
|
|
47
|
+
// Listen for keypresses
|
|
48
|
+
process.stdin.on('keypress', (str, key) => {
|
|
49
|
+
if (key.name === 'q' || (key.ctrl && key.name === 'c')) {
|
|
50
|
+
process.exit();
|
|
51
|
+
} else {
|
|
52
|
+
if (key.name === 'up' && box.y > 0) {
|
|
53
|
+
box.move(0, -1);
|
|
54
|
+
} else if (key.name === 'down' && box.y + box.height < tui.height) {
|
|
55
|
+
box.move(0, 1);
|
|
56
|
+
} else if (key.name === 'left' && box.x > 0) {
|
|
57
|
+
box.move(-1, 0);
|
|
58
|
+
} else if (key.name === 'right' && box.x + box.width < tui.width) {
|
|
59
|
+
box.move(1, 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Render new frame after box moved.
|
|
63
|
+
tui.nextFrame();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Repository
|
|
70
|
+
[GitHub Repository](https://github.com/stuncs69/tidepool)</br>
|
|
71
|
+
[NPM](https://www.npmjs.com/package/tidepool)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Box } from "./objects/box";
|
|
2
|
+
import { Line } from "./objects/line";
|
|
2
3
|
import { Text } from "./objects/text";
|
|
3
4
|
import { TideScreen } from "./screen";
|
|
4
|
-
export { Box, Text, TideScreen };
|
|
5
|
+
export { Box, Text, Line, TideScreen };
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TideScreen = exports.Text = exports.Box = void 0;
|
|
3
|
+
exports.TideScreen = exports.Line = exports.Text = exports.Box = void 0;
|
|
4
4
|
const box_1 = require("./objects/box");
|
|
5
5
|
Object.defineProperty(exports, "Box", { enumerable: true, get: function () { return box_1.Box; } });
|
|
6
|
+
const line_1 = require("./objects/line");
|
|
7
|
+
Object.defineProperty(exports, "Line", { enumerable: true, get: function () { return line_1.Line; } });
|
|
6
8
|
const text_1 = require("./objects/text");
|
|
7
9
|
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return text_1.Text; } });
|
|
8
10
|
const screen_1 = require("./screen");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TideObject } from "../interfaces";
|
|
2
|
+
export declare class Line implements TideObject {
|
|
3
|
+
relativeX: number;
|
|
4
|
+
relativeY: number;
|
|
5
|
+
length: number;
|
|
6
|
+
color: string;
|
|
7
|
+
zIndex: number;
|
|
8
|
+
constructor(x: number, y: number, length: number, color?: string, zIndex?: number);
|
|
9
|
+
draw(screen: string[][], boxX: number, boxY: number): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../src/objects/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,qBAAa,IAAK,YAAW,UAAU;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAU,EAAE,MAAM,SAAI;IAQ7E,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAUtD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Line = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
class Line {
|
|
6
|
+
constructor(x, y, length, color = 'reset', zIndex = 0) {
|
|
7
|
+
this.relativeX = x;
|
|
8
|
+
this.relativeY = y;
|
|
9
|
+
this.length = length;
|
|
10
|
+
this.color = color;
|
|
11
|
+
this.zIndex = zIndex;
|
|
12
|
+
}
|
|
13
|
+
draw(screen, boxX, boxY) {
|
|
14
|
+
const colorCode = (0, util_1.getColorCode)(this.color);
|
|
15
|
+
for (let i = 0; i < this.length; i++) {
|
|
16
|
+
const screenX = boxX + this.relativeX + i;
|
|
17
|
+
const screenY = boxY + this.relativeY;
|
|
18
|
+
if (screenX < screen[0].length && screenY < screen.length) {
|
|
19
|
+
screen[screenY][screenX] = `${colorCode}â\x1b[0m`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Line = Line;
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tidepool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"author": "stuncs69",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/your-username/tidepool.git"
|
|
9
|
+
},
|
|
6
10
|
"devDependencies": {
|
|
7
11
|
"@eslint/js": "^9.9.0",
|
|
8
12
|
"@types/node": "^22.2.0",
|