create-textmode 1.0.5 → 1.0.7

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 (46) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +120 -80
  3. package/bin/index.js +8 -8
  4. package/package.json +70 -54
  5. package/src/args.js +57 -30
  6. package/src/banner.js +57 -57
  7. package/src/cli.js +166 -154
  8. package/src/constants.js +59 -19
  9. package/src/fs-utils.js +136 -85
  10. package/src/packageManager.js +18 -18
  11. package/src/prompts.js +102 -90
  12. package/src/runCommand.js +46 -46
  13. package/src/summary.js +43 -33
  14. package/src/textmodeVersion.js +57 -45
  15. package/src/usage.js +21 -18
  16. package/src/versions.js +56 -52
  17. package/templates/vanilla-js/.prettierrc +8 -8
  18. package/templates/vanilla-js/_gitignore +2 -2
  19. package/templates/vanilla-js/eslint.config.js +22 -0
  20. package/templates/vanilla-js/index.html +25 -26
  21. package/templates/vanilla-js/package.json +26 -24
  22. package/templates/vanilla-js/src/sketch.js +28 -28
  23. package/templates/vanilla-js/vite.config.js +7 -7
  24. package/templates/vanilla-js-tweakpane/_gitignore +2 -0
  25. package/templates/vanilla-js-tweakpane/eslint.config.js +22 -0
  26. package/templates/vanilla-js-tweakpane/index.html +37 -0
  27. package/templates/vanilla-js-tweakpane/package.json +27 -0
  28. package/templates/vanilla-js-tweakpane/src/sketch.js +62 -0
  29. package/templates/vanilla-js-tweakpane/vite.config.js +7 -0
  30. package/templates/vanilla-ts/.prettierrc +8 -8
  31. package/templates/vanilla-ts/_gitignore +1 -1
  32. package/templates/vanilla-ts/eslint.config.js +23 -0
  33. package/templates/vanilla-ts/index.html +26 -27
  34. package/templates/vanilla-ts/package.json +30 -29
  35. package/templates/vanilla-ts/src/sketch.ts +28 -28
  36. package/templates/vanilla-ts/tsconfig.json +15 -15
  37. package/templates/vanilla-ts/vite.config.ts +7 -7
  38. package/templates/vanilla-ts-tweakpane/_gitignore +2 -0
  39. package/templates/vanilla-ts-tweakpane/eslint.config.js +23 -0
  40. package/templates/vanilla-ts-tweakpane/index.html +37 -0
  41. package/templates/vanilla-ts-tweakpane/package.json +32 -0
  42. package/templates/vanilla-ts-tweakpane/src/sketch.ts +72 -0
  43. package/templates/vanilla-ts-tweakpane/tsconfig.json +15 -0
  44. package/templates/vanilla-ts-tweakpane/vite.config.ts +7 -0
  45. package/templates/vanilla-js/.eslintrc.json +0 -13
  46. package/templates/vanilla-ts/.eslintrc.json +0 -19
@@ -0,0 +1,23 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import prettierConfig from "eslint-config-prettier";
4
+ import tseslint from "typescript-eslint";
5
+
6
+ export default tseslint.config(
7
+ {
8
+ ignores: ["dist/**", "node_modules/**"],
9
+ },
10
+ js.configs.recommended,
11
+ ...tseslint.configs.recommended,
12
+ prettierConfig,
13
+ {
14
+ files: ["**/*.{ts,tsx}"],
15
+ languageOptions: {
16
+ ecmaVersion: "latest",
17
+ sourceType: "module",
18
+ globals: {
19
+ ...globals.browser,
20
+ },
21
+ },
22
+ }
23
+ );
@@ -0,0 +1,37 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>{{name}}</title>
8
+
9
+ <style>
10
+ html,
11
+ body {
12
+ margin: 0;
13
+ padding: 0;
14
+ }
15
+
16
+ canvas {
17
+ display: block;
18
+ }
19
+
20
+ #pane {
21
+ position: fixed;
22
+ top: 12px;
23
+ right: 12px;
24
+ width: 260px;
25
+ z-index: 10;
26
+ pointer-events: auto;
27
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
28
+ }
29
+ </style>
30
+ </head>
31
+
32
+ <body>
33
+ <div id="pane"></div>
34
+ <script type="module" src="/src/sketch.ts"></script>
35
+ </body>
36
+
37
+ </html>
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
10
+ "format": "prettier --write \"src/**/*.{js,ts}\"",
11
+ "format:check": "prettier --check \"src/**/*.{js,ts}\"",
12
+ "lint": "eslint src --ext .ts",
13
+ "lint:fix": "eslint src --ext .ts --fix",
14
+ "typecheck": "tsc --noEmit"
15
+ },
16
+ "dependencies": {
17
+ "textmode.js": "latest",
18
+ "tweakpane": "^4.0.5"
19
+ },
20
+ "devDependencies": {
21
+ "@eslint/js": "^9.39.1",
22
+ "@tweakpane/core": "^2.0.5",
23
+ "@types/node": "^24.10.2",
24
+ "eslint": "^9.39.1",
25
+ "eslint-config-prettier": "^10.1.8",
26
+ "globals": "^15.14.0",
27
+ "prettier": "^3.7.4",
28
+ "typescript": "^5.9.3",
29
+ "typescript-eslint": "^8.49.0",
30
+ "vite": "^7.2.7"
31
+ }
32
+ }
@@ -0,0 +1,72 @@
1
+ import { textmode } from 'textmode.js';
2
+ import { Pane } from 'tweakpane';
3
+
4
+ type RGB = { r: number; g: number; b: number };
5
+
6
+ type Params = {
7
+ speed: number;
8
+ frequency: number;
9
+ amplitude: number;
10
+ baseCharColor: RGB;
11
+ baseCellColor: RGB;
12
+ };
13
+
14
+ const tm = textmode.create({ width: window.innerWidth, height: window.innerHeight });
15
+
16
+ const params: Params = {
17
+ speed: 0.1,
18
+ frequency: 0.22,
19
+ amplitude: 1.1,
20
+ baseCharColor: { r: 0, g: 170, b: 255 },
21
+ baseCellColor: { r: 0, g: 0, b: 0 }
22
+ };
23
+
24
+ const paneContainer = document.querySelector<HTMLElement>('#pane') ?? undefined;
25
+ const pane = new Pane({ title: 'Controls', container: paneContainer });
26
+
27
+ pane.addBinding(params, 'speed', { min: 0, max: 0.4, step: 0.005, label: 'Speed' });
28
+ pane.addBinding(params, 'frequency', { min: 0.05, max: 0.8, step: 0.01, label: 'Frequency' });
29
+ pane.addBinding(params, 'amplitude', { min: 0.5, max: 2.0, step: 0.05, label: 'Amplitude' });
30
+ pane.addBinding(params, 'baseCharColor', { label: 'Base Char Color' });
31
+ pane.addBinding(params, 'baseCellColor', { label: 'Base Cell Color' });
32
+
33
+ const clamp = (value: number, min: number, max: number): number => Math.min(Math.max(value, min), max);
34
+
35
+ const getChar = (wave: number): string => {
36
+ if (wave > 0.6) return '▓';
37
+ if (wave > 0.2) return '▒';
38
+ return '░';
39
+ };
40
+
41
+ tm.draw(() => {
42
+ const halfCols = Math.round(tm.grid.cols / 2) + 1;
43
+ const halfRows = Math.round(tm.grid.rows / 2) + 1;
44
+
45
+ for (let y = -halfRows; y < halfRows; y++) {
46
+ for (let x = -halfCols; x < halfCols; x++) {
47
+ const dist = Math.hypot(x, y);
48
+ const wave = Math.sin(dist * params.frequency - tm.frameCount * params.speed) * params.amplitude;
49
+ const char = getChar(wave);
50
+
51
+ const lightness = 0.35 + 0.65 * ((wave + params.amplitude) / (2 * params.amplitude));
52
+ const charR = clamp(params.baseCharColor.r * lightness, 0, 255);
53
+ const charG = clamp(params.baseCharColor.g * lightness, 0, 255);
54
+ const charB = clamp(params.baseCharColor.b * lightness, 0, 255);
55
+ const cellR = clamp(params.baseCellColor.r * lightness, 0, 255);
56
+ const cellG = clamp(params.baseCellColor.g * lightness, 0, 255);
57
+ const cellB = clamp(params.baseCellColor.b * lightness, 0, 255);
58
+
59
+ tm.push();
60
+ tm.translate(x, y, 0);
61
+ tm.char(char);
62
+ tm.charColor(charR, charG, charB);
63
+ tm.cellColor(cellR, cellG, cellB);
64
+ tm.point();
65
+ tm.pop();
66
+ }
67
+ }
68
+ });
69
+
70
+ tm.windowResized(() => {
71
+ tm.resizeCanvas(window.innerWidth, window.innerHeight);
72
+ });
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Node",
7
+ "strict": true,
8
+ "jsx": "preserve",
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "types": ["vite/client"]
12
+ },
13
+ "include": ["src"],
14
+ "references": []
15
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ export default defineConfig({
4
+ server: {
5
+ open: true
6
+ }
7
+ });
@@ -1,13 +0,0 @@
1
- {
2
- "root": true,
3
- "env": {
4
- "browser": true,
5
- "es2021": true
6
- },
7
- "parserOptions": {
8
- "ecmaVersion": "latest",
9
- "sourceType": "module"
10
- },
11
- "extends": ["eslint:recommended", "prettier"],
12
- "ignorePatterns": ["dist/", "node_modules/"]
13
- }
@@ -1,19 +0,0 @@
1
- {
2
- "root": true,
3
- "env": {
4
- "browser": true,
5
- "es2021": true
6
- },
7
- "parser": "@typescript-eslint/parser",
8
- "parserOptions": {
9
- "ecmaVersion": "latest",
10
- "sourceType": "module"
11
- },
12
- "plugins": ["@typescript-eslint"],
13
- "extends": [
14
- "eslint:recommended",
15
- "plugin:@typescript-eslint/recommended",
16
- "prettier"
17
- ],
18
- "ignorePatterns": ["dist/", "node_modules/"]
19
- }