tidepool 1.0.1 → 1.0.3

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.
@@ -0,0 +1,50 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # ESLint is a tool for identifying and reporting on patterns
6
+ # found in ECMAScript/JavaScript code.
7
+ # More details at https://github.com/eslint/eslint
8
+ # and https://eslint.org
9
+
10
+ name: ESLint
11
+
12
+ on:
13
+ push:
14
+ branches: [ "main" ]
15
+ pull_request:
16
+ # The branches below must be a subset of the branches above
17
+ branches: [ "main" ]
18
+ schedule:
19
+ - cron: '21 0 * * 3'
20
+
21
+ jobs:
22
+ eslint:
23
+ name: Run eslint scanning
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ contents: read
27
+ security-events: write
28
+ actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
29
+ steps:
30
+ - name: Checkout code
31
+ uses: actions/checkout@v4
32
+
33
+ - name: Install ESLint
34
+ run: |
35
+ npm install eslint@8.10.0
36
+ npm install @microsoft/eslint-formatter-sarif@2.1.7
37
+
38
+ - name: Run ESLint
39
+ run: npx eslint .
40
+ --config .eslintrc.js
41
+ --ext .js,.jsx,.ts,.tsx
42
+ --format @microsoft/eslint-formatter-sarif
43
+ --output-file eslint-results.sarif
44
+ continue-on-error: true
45
+
46
+ - name: Upload analysis results to GitHub
47
+ uses: github/codeql-action/upload-sarif@v3
48
+ with:
49
+ sarif_file: eslint-results.sarif
50
+ wait-for-processing: true
@@ -49,7 +49,7 @@ class Box {
49
49
  }
50
50
  }
51
51
  }
52
- for (let content of this.contents) {
52
+ for (const content of this.contents) {
53
53
  content.draw(screen, this.x + 1, this.y + 1, this.width - 2);
54
54
  }
55
55
  }
package/dist/screen.d.ts CHANGED
@@ -7,14 +7,18 @@ export declare class TideScreen {
7
7
  components: TideObject[];
8
8
  fps: number | null;
9
9
  updateFunction: (() => void) | null;
10
- constructor(width: number, height: number);
10
+ backgroundColor: string;
11
+ constructor(width: number, height: number, backgroundColor?: string);
11
12
  clearScreen(): void;
12
13
  clearBuffer(): void;
13
14
  addComponent(component: TideObject): void;
14
- renderBuffer(): void;
15
- render(): void;
15
+ private getBackgroundColorCode;
16
+ private renderBuffer;
17
+ applyBackgroundColor(): void;
18
+ private render;
16
19
  setUpdateFunction(fn: () => void): void;
17
20
  setFPS(fps: number): void;
21
+ nextFrame(): void;
18
22
  renderCycle(): void;
19
23
  }
20
24
  //# sourceMappingURL=screen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC1B,cAAc,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAQ;gBAE/B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQzC,WAAW;IAIX,WAAW;IAIX,YAAY,CAAC,SAAS,EAAE,UAAU;IAIlC,YAAY;IAMZ,MAAM;IAMN,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI;IAIhC,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,WAAW;CAkBd"}
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC1B,cAAc,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAQ;IAC3C,eAAe,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAE,MAAsB;IASlF,WAAW;IAIX,WAAW;IAIX,YAAY,CAAC,SAAS,EAAE,UAAU;IAIlC,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,YAAY;IAMpB,oBAAoB;IAUpB,OAAO,CAAC,MAAM;IAOd,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI;IAIhC,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,SAAS;IAQT,WAAW;CAkBd"}
package/dist/screen.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TideScreen = void 0;
4
4
  class TideScreen {
5
- constructor(width, height) {
5
+ constructor(width, height, backgroundColor = 'transparent') {
6
6
  this.fps = null;
7
7
  this.updateFunction = null;
8
8
  this.width = width;
@@ -10,6 +10,7 @@ class TideScreen {
10
10
  this.screen = Array.from({ length: height }, () => Array(width).fill(' '));
11
11
  this.buffer = Array.from({ length: height }, () => Array(width).fill(' '));
12
12
  this.components = [];
13
+ this.backgroundColor = backgroundColor;
13
14
  }
14
15
  clearScreen() {
15
16
  this.screen = Array.from({ length: this.height }, () => Array(this.width).fill(' '));
@@ -20,12 +21,36 @@ class TideScreen {
20
21
  addComponent(component) {
21
22
  this.components.push(component);
22
23
  }
24
+ getBackgroundColorCode(color) {
25
+ const colors = {
26
+ black: '\x1b[40m',
27
+ red: '\x1b[41m',
28
+ green: '\x1b[42m',
29
+ yellow: '\x1b[43m',
30
+ blue: '\x1b[44m',
31
+ magenta: '\x1b[45m',
32
+ cyan: '\x1b[46m',
33
+ white: '\x1b[47m',
34
+ transparent: '\x1b[49m',
35
+ };
36
+ return colors[color.toLowerCase()] || colors['black'];
37
+ }
23
38
  renderBuffer() {
24
39
  this.clearBuffer();
25
40
  this.components.sort((a, b) => b.zIndex - a.zIndex);
26
41
  this.components.forEach(component => component.draw(this.buffer));
27
42
  }
43
+ applyBackgroundColor() {
44
+ const bgColorCode = this.getBackgroundColorCode(this.backgroundColor);
45
+ const resetCode = '\x1b[0m';
46
+ for (let i = 0; i < this.height; i++) {
47
+ for (let j = 0; j < this.width; j++) {
48
+ this.buffer[i][j] = `${bgColorCode}${this.buffer[i][j] || ' '}${resetCode}`;
49
+ }
50
+ }
51
+ }
28
52
  render() {
53
+ this.applyBackgroundColor();
29
54
  console.clear();
30
55
  const output = this.buffer.map(row => row.join('')).join('\n');
31
56
  console.log(output);
@@ -36,6 +61,13 @@ class TideScreen {
36
61
  setFPS(fps) {
37
62
  this.fps = fps;
38
63
  }
64
+ nextFrame() {
65
+ if (this.updateFunction) {
66
+ this.updateFunction();
67
+ }
68
+ this.renderBuffer();
69
+ this.render();
70
+ }
39
71
  renderCycle() {
40
72
  if (this.fps === null) {
41
73
  throw new Error("FPS must be set before starting the render cycle.");
@@ -45,8 +77,8 @@ class TideScreen {
45
77
  if (this.updateFunction) {
46
78
  this.updateFunction();
47
79
  }
48
- this.renderBuffer(); // Prepare the buffer with updated content
49
- this.render(); // Output the buffer to the screen
80
+ this.renderBuffer();
81
+ this.render();
50
82
  setTimeout(loop, interval);
51
83
  };
52
84
  loop();
@@ -0,0 +1,38 @@
1
+ import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
+ import globals from "globals";
3
+ import tsParser from "@typescript-eslint/parser";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import js from "@eslint/js";
7
+ import { FlatCompat } from "@eslint/eslintrc";
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+ const compat = new FlatCompat({
12
+ baseDirectory: __dirname,
13
+ recommendedConfig: js.configs.recommended,
14
+ allConfig: js.configs.all
15
+ });
16
+
17
+ export default [
18
+ ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
19
+ {
20
+ plugins: {
21
+ "@typescript-eslint": typescriptEslint,
22
+ },
23
+
24
+ languageOptions: {
25
+ globals: {
26
+ ...globals.node,
27
+ },
28
+
29
+ parser: tsParser,
30
+ ecmaVersion: 12,
31
+ sourceType: "module",
32
+ },
33
+
34
+ rules: {
35
+ "@typescript-eslint/no-unsafe-function-type": "off",
36
+ },
37
+ },
38
+ ];
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "tidepool",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "author": "stuncs69",
5
5
  "main": "dist/index.js",
6
6
  "devDependencies": {
7
+ "@eslint/js": "^9.9.0",
7
8
  "@types/node": "^22.2.0",
8
- "typescript": "^5.5.4"
9
+ "@typescript-eslint/eslint-plugin": "^8.1.0",
10
+ "@typescript-eslint/parser": "^8.1.0",
11
+ "eslint": "^9.9.0",
12
+ "globals": "^15.9.0",
13
+ "typescript": "^5.5.4",
14
+ "typescript-eslint": "^8.1.0"
9
15
  },
10
16
  "description": "A CLI rendering engine in TypeScript.",
11
17
  "license": "ISC",
12
18
  "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
19
+ "test": "echo \"Error: no test specified\" && exit 1",
20
+ "lint": "eslint ./src/*"
14
21
  }
15
22
  }