kodeui 0.0.0-stage → 0.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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/bin/kodeui.mjs +89 -0
  4. package/package.json +37 -4
  5. package/skill/kodeui/SKILL.md +105 -0
  6. package/skill/kodeui/assets/tokens.css +40 -0
  7. package/skill/kodeui/components/aurora-input/AuroraInput.tsx +153 -0
  8. package/skill/kodeui/components/aurora-input/aurora-input.css +218 -0
  9. package/skill/kodeui/components/aurora-input/index.ts +2 -0
  10. package/skill/kodeui/components/bloom-wall/BloomWall.tsx +90 -0
  11. package/skill/kodeui/components/bloom-wall/bloom-wall.css +10 -0
  12. package/skill/kodeui/components/bloom-wall/engine.ts +1022 -0
  13. package/skill/kodeui/components/bloom-wall/icons/icons-a.ts +818 -0
  14. package/skill/kodeui/components/bloom-wall/icons/icons-b.ts +827 -0
  15. package/skill/kodeui/components/bloom-wall/icons/index.ts +25 -0
  16. package/skill/kodeui/components/bloom-wall/icons/types.ts +8 -0
  17. package/skill/kodeui/components/bloom-wall/index.ts +12 -0
  18. package/skill/kodeui/components/bloom-wall/paint.ts +113 -0
  19. package/skill/kodeui/components/bloom-wall/palettes.ts +32 -0
  20. package/skill/kodeui/components/blur-in-text/BlurInText.tsx +53 -0
  21. package/skill/kodeui/components/blur-in-text/blur-in-text.css +14 -0
  22. package/skill/kodeui/components/blur-in-text/index.ts +2 -0
  23. package/skill/kodeui/components/glass-reveal/GlassReveal.tsx +108 -0
  24. package/skill/kodeui/components/glass-reveal/glass-reveal.css +126 -0
  25. package/skill/kodeui/components/glass-reveal/index.ts +2 -0
  26. package/skill/kodeui/components/glow-card/GlowCard.tsx +67 -0
  27. package/skill/kodeui/components/glow-card/glow-card.css +134 -0
  28. package/skill/kodeui/components/glow-card/index.ts +2 -0
  29. package/skill/kodeui/components/launch-chip/LaunchChip.tsx +180 -0
  30. package/skill/kodeui/components/launch-chip/icons.tsx +119 -0
  31. package/skill/kodeui/components/launch-chip/index.ts +3 -0
  32. package/skill/kodeui/components/launch-chip/launch-chip.css +345 -0
  33. package/skill/kodeui/components/ring-reveal/RingReveal.tsx +84 -0
  34. package/skill/kodeui/components/ring-reveal/index.ts +4 -0
  35. package/skill/kodeui/components/ring-reveal/ring-reveal.css +10 -0
  36. package/skill/kodeui/components/ring-reveal/ring.ts +298 -0
  37. package/skill/kodeui/components/rolling-text/RollingText.tsx +121 -0
  38. package/skill/kodeui/components/rolling-text/index.ts +4 -0
  39. package/skill/kodeui/components/rolling-text/roll.ts +94 -0
  40. package/skill/kodeui/components/rolling-text/rolling-text.css +43 -0
  41. package/skill/kodeui/components/use-live-transcript/index.ts +2 -0
  42. package/skill/kodeui/components/use-live-transcript/useLiveTranscript.ts +215 -0
  43. package/skill/kodeui/components/voice-input/VoiceInput.tsx +273 -0
  44. package/skill/kodeui/components/voice-input/icons.tsx +27 -0
  45. package/skill/kodeui/components/voice-input/index.ts +4 -0
  46. package/skill/kodeui/components/voice-input/useVoiceRecorder.ts +289 -0
  47. package/skill/kodeui/components/voice-input/voice-input.css +34 -0
  48. package/skill/kodeui/components/voice-note/VoiceNote.tsx +170 -0
  49. package/skill/kodeui/components/voice-note/index.ts +3 -0
  50. package/skill/kodeui/components/voice-note/noteFile.ts +25 -0
  51. package/skill/kodeui/components/voice-note/voice-note.css +45 -0
  52. package/skill/kodeui/references/aurora-input.md +44 -0
  53. package/skill/kodeui/references/bloom-wall.md +59 -0
  54. package/skill/kodeui/references/blur-in-text.md +17 -0
  55. package/skill/kodeui/references/frameworks.md +46 -0
  56. package/skill/kodeui/references/glass-reveal.md +40 -0
  57. package/skill/kodeui/references/glow-card.md +48 -0
  58. package/skill/kodeui/references/launch-chip.md +37 -0
  59. package/skill/kodeui/references/recipes.md +77 -0
  60. package/skill/kodeui/references/ring-reveal.md +35 -0
  61. package/skill/kodeui/references/rolling-text.md +19 -0
  62. package/skill/kodeui/references/theming.md +45 -0
  63. package/skill/kodeui/references/use-live-transcript.md +28 -0
  64. package/skill/kodeui/references/voice-input.md +60 -0
  65. package/skill/kodeui/references/voice-note.md +22 -0
  66. package/skill/kodeui/scripts/add.mjs +192 -0
  67. package/skill/kodeui/scripts/manifest.json +92 -0
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Copy KodeUI components into a React project.
4
+ *
5
+ * node add.mjs list
6
+ * node add.mjs <component...> [--root <project>] [--dir <folder>] [--tokens] [--force] [--dry-run] [--client | --no-client]
7
+ *
8
+ * <component> is a folder name (glow-card), an export (GlowCard), an alias (card) or "all".
9
+ * It copies each folder plus the folders it needs, never overwrites a file unless --force,
10
+ * marks the files that use React hooks with 'use client' in a Next.js project, and prints
11
+ * the npm packages to install and the import lines to use. No dependencies; Node 18+.
12
+ */
13
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
14
+ import { dirname, join, relative, resolve, sep } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+
17
+ const here = dirname(fileURLToPath(import.meta.url));
18
+ const SKILL = resolve(here, '..');
19
+ const SOURCE = join(SKILL, 'components');
20
+ const manifest = JSON.parse(readFileSync(join(here, 'manifest.json'), 'utf8')).components;
21
+
22
+ // ------------------------------------------------------------------ arguments
23
+ const argv = process.argv.slice(2);
24
+ const flags = new Set();
25
+ const opts = {};
26
+ const names = [];
27
+ for (let i = 0; i < argv.length; i++) {
28
+ const a = argv[i];
29
+ if (a === '--root' || a === '--dir') opts[a.slice(2)] = argv[++i];
30
+ else if (a.startsWith('--')) flags.add(a.slice(2));
31
+ else names.push(a);
32
+ }
33
+
34
+ if (!names.length || names[0] === 'list' || flags.has('help')) {
35
+ console.log('KodeUI components (node add.mjs <name...>):\n');
36
+ for (const [id, c] of Object.entries(manifest)) {
37
+ const extra = [c.requires.length ? `needs ${c.requires.join(', ')}` : '', c.npm.length ? `npm ${c.npm.join(', ')}` : ''].filter(Boolean).join('; ');
38
+ console.log(` ${id.padEnd(20)} ${c.name.padEnd(18)} ${c.summary}${extra ? ` [${extra}]` : ''}`);
39
+ }
40
+ process.exit(names.length || flags.has('help') ? 0 : 1);
41
+ }
42
+
43
+ // ------------------------------------------------------------------ resolve names
44
+ const norm = (s) => s.toLowerCase().replace(/[\s_]+/g, '-').replace(/[^a-z0-9-]/g, '');
45
+ const lookup = new Map();
46
+ for (const [id, c] of Object.entries(manifest)) {
47
+ [id, c.name, ...c.exports, ...(c.aliases || [])].forEach((n) => lookup.set(norm(n), id));
48
+ }
49
+ const wanted = new Set();
50
+ const unknown = [];
51
+ for (const n of names) {
52
+ if (norm(n) === 'all') { Object.keys(manifest).forEach((id) => wanted.add(id)); continue; }
53
+ const id = lookup.get(norm(n));
54
+ id ? wanted.add(id) : unknown.push(n);
55
+ }
56
+ if (unknown.length) {
57
+ console.error(`Unknown component: ${unknown.join(', ')}. Run "node add.mjs list" to see the names.`);
58
+ process.exit(1);
59
+ }
60
+ const order = [];
61
+ const visit = (id) => { if (order.includes(id)) return; manifest[id].requires.forEach(visit); order.push(id); };
62
+ [...wanted].forEach(visit);
63
+
64
+ // ------------------------------------------------------------------ the project
65
+ function findRoot(start) {
66
+ let d = resolve(start);
67
+ for (;;) {
68
+ if (existsSync(join(d, 'package.json'))) return d;
69
+ const up = dirname(d);
70
+ if (up === d) return null;
71
+ d = up;
72
+ }
73
+ }
74
+ const root = opts.root ? resolve(opts.root) : findRoot(process.cwd());
75
+ if (!root || !existsSync(join(root, 'package.json'))) {
76
+ console.error('No package.json found. Run this inside the React project, or pass --root <project folder>.');
77
+ process.exit(1);
78
+ }
79
+ const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
80
+ const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}), ...(pkg.peerDependencies || {}) };
81
+ const has = (p) => existsSync(join(root, p));
82
+ const isNext = 'next' in deps;
83
+ const usesTs = 'typescript' in deps || has('tsconfig.json');
84
+ const appRouter = has('app') || has('src/app');
85
+ const pagesRouter = !appRouter && (['pages/_app.tsx', 'pages/_app.jsx', 'pages/_app.js', 'src/pages/_app.tsx', 'src/pages/_app.jsx', 'src/pages/_app.js'].some(has) || has('pages') || has('src/pages'));
86
+ const markClient = flags.has('client') || (isNext && !flags.has('no-client'));
87
+
88
+ let dir = opts.dir;
89
+ if (!dir) {
90
+ if (has('src/components')) dir = 'src/components/kodeui';
91
+ else if (has('components')) dir = 'components/kodeui';
92
+ else if (has('src')) dir = 'src/components/kodeui';
93
+ else dir = 'components/kodeui';
94
+ }
95
+ const target = resolve(root, dir);
96
+ const dry = flags.has('dry-run');
97
+ const force = flags.has('force');
98
+
99
+ // ------------------------------------------------------------------ copy
100
+ const HOOKS = /\buse(State|Effect|LayoutEffect|Ref|Callback|Memo|Id|ImperativeHandle|Reducer|Context|SyncExternalStore|Transition|DeferredValue)\b|\buse[A-Z]\w*\(/;
101
+ const written = [], skipped = [], marked = [];
102
+ function copyDir(from, to) {
103
+ for (const f of readdirSync(from)) {
104
+ if (f === '.DS_Store') continue;
105
+ const a = join(from, f), b = join(to, f);
106
+ if (statSync(a).isDirectory()) { copyDir(a, b); continue; }
107
+ let text = readFileSync(a, 'utf8');
108
+ if (markClient && /\.(tsx|ts|jsx|js)$/.test(f) && !/^index\./.test(f) && /from ['"]react['"]/.test(text) && HOOKS.test(text) && !/^['"]use client['"]/.test(text)) {
109
+ text = `'use client';\n\n${text}`;
110
+ marked.push(relative(root, b));
111
+ }
112
+ if (existsSync(b) && !force) {
113
+ if (readFileSync(b, 'utf8') !== text) skipped.push(relative(root, b));
114
+ continue;
115
+ }
116
+ if (!dry) { mkdirSync(dirname(b), { recursive: true }); writeFileSync(b, text); }
117
+ written.push(relative(root, b));
118
+ }
119
+ }
120
+ for (const id of order) copyDir(join(SOURCE, id), join(target, id));
121
+ if (flags.has('tokens')) {
122
+ const b = join(target, 'tokens.css');
123
+ if (existsSync(b) && !force) skipped.push(relative(root, b));
124
+ else { if (!dry) { mkdirSync(target, { recursive: true }); writeFileSync(b, readFileSync(join(SKILL, 'assets', 'tokens.css'))); } written.push(relative(root, b)); }
125
+ }
126
+
127
+ // ------------------------------------------------------------------ report
128
+ const npm = [...new Set(order.flatMap((id) => manifest[id].npm))]
129
+ .filter((spec) => !(spec.replace(/@[^@/]*$/, '') in deps));
130
+ const pm = has('pnpm-lock.yaml') ? 'pnpm add' : has('yarn.lock') ? 'yarn add' : has('bun.lockb') || has('bun.lock') ? 'bun add' : 'npm install';
131
+ // the import path: through the project's alias (tsconfig / jsconfig "paths") when one covers
132
+ // the folder, else relative to the source folder
133
+ function readJsonc(p) {
134
+ // drop // and /* */ comments outside strings, then trailing commas
135
+ try {
136
+ const src = readFileSync(p, 'utf8');
137
+ let out = '', i = 0, str = false;
138
+ while (i < src.length) {
139
+ const c = src[i], n = src[i + 1];
140
+ if (str) { out += c; if (c === '\\') { out += n ?? ''; i += 2; continue; } if (c === '"') str = false; i++; continue; }
141
+ if (c === '"') { str = true; out += c; i++; continue; }
142
+ if (c === '/' && n === '/') { while (i < src.length && src[i] !== '\n') i++; continue; }
143
+ if (c === '/' && n === '*') { i = src.indexOf('*/', i + 2); i = i < 0 ? src.length : i + 2; continue; }
144
+ out += c; i++;
145
+ }
146
+ return JSON.parse(out.replace(/,(\s*[}\]])/g, '$1'));
147
+ } catch { return null; }
148
+ }
149
+ const toPosix = (p) => p.split(sep).join('/');
150
+ const alias = (() => {
151
+ for (const f of ['tsconfig.json', 'tsconfig.app.json', 'jsconfig.json']) {
152
+ const cfg = has(f) ? readJsonc(join(root, f)) : null;
153
+ const co = cfg && cfg.compilerOptions;
154
+ if (!co || !co.paths) continue;
155
+ for (const [key, vals] of Object.entries(co.paths)) {
156
+ if (!key.endsWith('/*') || !Array.isArray(vals) || !vals.length) continue;
157
+ const base = resolve(root, co.baseUrl || '.', String(vals[0]).replace(/\/?\*$/, ''));
158
+ const rel = relative(base, target);
159
+ if (!rel.startsWith('..') && !rel.startsWith(sep)) return { key: key.slice(0, -2), base, file: f };
160
+ }
161
+ }
162
+ return null;
163
+ })();
164
+ const srcDir = has('src') ? join(root, 'src') : root;
165
+ const importPath = (id) => {
166
+ const folder = join(target, id);
167
+ if (alias) return `${alias.key}/${toPosix(relative(alias.base, folder))}`;
168
+ const rel = toPosix(relative(srcDir, folder));
169
+ return rel.startsWith('.') ? rel : `./${rel}`;
170
+ };
171
+
172
+ const out = [];
173
+ out.push(`${dry ? '[dry run] ' : ''}KodeUI → ${relative(process.cwd(), target) || '.'}`);
174
+ out.push(`Project: ${pkg.name || root}${isNext ? `, Next.js (${appRouter ? 'app router' : pagesRouter ? 'pages router' : 'router unknown'})` : ''}${usesTs ? ', TypeScript' : ', JavaScript'}`);
175
+ out.push(`Components: ${order.map((id) => (wanted.has(id) ? id : `${id} (needed by another)`)).join(', ')}`);
176
+ out.push(`Files written: ${written.length}${skipped.length ? `, kept ${skipped.length} existing files that differ (use --force to replace): ${skipped.join(', ')}` : ''}`);
177
+ if (marked.length) out.push(`Marked 'use client': ${marked.length} files`);
178
+ out.push(npm.length ? `Install: ${pm} ${npm.join(' ')}` : 'No npm packages needed.');
179
+ out.push(alias
180
+ ? `Imports (through the "${alias.key}/*" alias in ${alias.file}):`
181
+ : `Imports (no import alias found, so relative to ${srcDir === root ? 'the project root' : 'src/'}; add ../ for files deeper down):`);
182
+ for (const id of order.filter((x) => wanted.has(x))) out.push(` import { ${manifest[id].exports.join(', ')} } from '${importPath(id)}';`);
183
+
184
+ const warn = [];
185
+ const reactMajor = parseInt(String(deps.react || '').replace(/[^\d.]/g, ''), 10);
186
+ if (!deps.react) warn.push('react is not in package.json: KodeUI needs React 18 or newer.');
187
+ else if (reactMajor && reactMajor < 18) warn.push(`React ${deps.react} found: KodeUI needs React 18 or newer.`);
188
+ if (isNext && pagesRouter) warn.push('Next.js pages router: global CSS may only be imported from pages/_app. Move each component\'s "import \'./x.css\'" line into pages/_app (see references/frameworks.md).');
189
+ if (isNext && !usesTs) warn.push('Next.js needs TypeScript installed to build .tsx files: add typescript, @types/react and @types/node as dev dependencies (see references/frameworks.md).');
190
+ if (order.includes('voice-input') || order.includes('use-live-transcript')) warn.push('Voice: the microphone works only on https or localhost. The live transcript uses the browser speech service (Chrome sends audio to Google, Edge to Microsoft); transcribe={false} keeps audio on the device.');
191
+ if (warn.length) { out.push('Notes:'); warn.forEach((w) => out.push(` - ${w}`)); }
192
+ console.log(out.join('\n'));
@@ -0,0 +1,92 @@
1
+ {
2
+ "components": {
3
+ "bloom-wall": {
4
+ "name": "Bloom Wall",
5
+ "exports": ["BloomWall", "NATURE_PALETTES"],
6
+ "requires": [],
7
+ "npm": [],
8
+ "summary": "A wall of glowing tiles grows out of a button on hover, breathes while you stay, and folds back when you leave. Canvas, fills its positioned parent.",
9
+ "aliases": ["wall", "bloom", "tile wall", "hover wall", "neon wall"]
10
+ },
11
+ "ring-reveal": {
12
+ "name": "Ring Reveal",
13
+ "exports": ["RingReveal"],
14
+ "requires": [],
15
+ "npm": [],
16
+ "summary": "A soft ring grows out of an element and darkens the page behind it, then folds back in. The Bloom Wall's reveal without the tiles.",
17
+ "aliases": ["ring", "reveal", "spotlight reveal"]
18
+ },
19
+ "glass-reveal": {
20
+ "name": "Glass Reveal",
21
+ "exports": ["GlassReveal", "Glass"],
22
+ "requires": [],
23
+ "npm": [],
24
+ "summary": "Panels, pills and buttons turn to frosted glass one after another (4 stagger steps) while something glows behind them.",
25
+ "aliases": ["glass", "frosted glass", "glassmorphism"]
26
+ },
27
+ "glow-card": {
28
+ "name": "Glow Card",
29
+ "exports": ["GlowCard", "GlowCardTitle", "GlowCardText"],
30
+ "requires": [],
31
+ "npm": [],
32
+ "summary": "A card with a slow spinning four-colour light around its border and a soft glow behind it; spins faster on hover.",
33
+ "aliases": ["card", "glowing card", "promo card", "border glow", "upgrade card"]
34
+ },
35
+ "aurora-input": {
36
+ "name": "Aurora Input",
37
+ "exports": ["AuroraInput", "AuroraInputAction"],
38
+ "requires": [],
39
+ "npm": [],
40
+ "summary": "A prompt box with an aurora light on its border that moves to a new spot every 3 seconds, plus an action row.",
41
+ "aliases": ["input", "prompt box", "chat input", "composer", "glowing input"]
42
+ },
43
+ "launch-chip": {
44
+ "name": "Launch Chip",
45
+ "exports": ["LaunchChip"],
46
+ "requires": [],
47
+ "npm": [],
48
+ "summary": "An announcement pill: a light wipes across it, tiny icons drift and fade, it settles into a badge, and its label rolls to a second line.",
49
+ "aliases": ["chip", "announcement", "badge", "new feature pill", "launch pill"]
50
+ },
51
+ "rolling-text": {
52
+ "name": "Rolling Text",
53
+ "exports": ["RollingText"],
54
+ "requires": [],
55
+ "npm": [],
56
+ "summary": "Text rolls up to the next line and back inside a masked window, and its container's width follows.",
57
+ "aliases": ["rolling", "text rotator", "rotating text", "ticker"]
58
+ },
59
+ "blur-in-text": {
60
+ "name": "Blur-in Text",
61
+ "exports": ["BlurInText"],
62
+ "requires": [],
63
+ "npm": [],
64
+ "summary": "Words arrive one by one out of a blur. For headlines.",
65
+ "aliases": ["blur", "blur in", "headline reveal", "text reveal"]
66
+ },
67
+ "voice-input": {
68
+ "name": "Voice Input",
69
+ "exports": ["VoiceInput", "useVoiceRecorder"],
70
+ "requires": ["aurora-input", "voice-note", "use-live-transcript"],
71
+ "npm": ["voice-glow@^0.5.0"],
72
+ "summary": "The Aurora Input with a mic: a voice-reactive glow rises while recording, sweeps while it finishes, then leaves a playable voice note. Optional live transcript.",
73
+ "aliases": ["voice", "mic", "voice recorder", "voice composer", "dictation input"]
74
+ },
75
+ "voice-note": {
76
+ "name": "Voice Note",
77
+ "exports": ["VoiceNote"],
78
+ "requires": [],
79
+ "npm": [],
80
+ "summary": "A playable voice-note pill with moving bars, its length, Save and remove.",
81
+ "aliases": ["note", "audio note", "audio pill"]
82
+ },
83
+ "use-live-transcript": {
84
+ "name": "useLiveTranscript",
85
+ "exports": ["useLiveTranscript"],
86
+ "requires": [],
87
+ "npm": [],
88
+ "summary": "A hook that turns speech into text while you talk (browser speech recognition).",
89
+ "aliases": ["transcript", "live-transcript", "speech to text", "dictation", "uselivetranscript"]
90
+ }
91
+ }
92
+ }