@kazzle/app 0.1.693

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 (103) hide show
  1. package/README.md +63 -0
  2. package/dist/client.d.ts +25 -0
  3. package/dist/client.js +83 -0
  4. package/dist/index.d.ts +86 -0
  5. package/dist/index.js +15 -0
  6. package/dist/migrations.d.ts +19 -0
  7. package/dist/migrations.js +74 -0
  8. package/dist/templates.d.ts +33 -0
  9. package/dist/templates.js +89 -0
  10. package/dist/tools.d.ts +36 -0
  11. package/dist/tools.js +22 -0
  12. package/dist/vite.d.ts +29 -0
  13. package/dist/vite.js +77 -0
  14. package/package.json +47 -0
  15. package/templates/ai-app/KAZZLE.md +21 -0
  16. package/templates/ai-app/bun.lock +290 -0
  17. package/templates/ai-app/components/server/index.ts +238 -0
  18. package/templates/ai-app/components/server/package.json +20 -0
  19. package/templates/ai-app/components/server/tsconfig.json +11 -0
  20. package/templates/ai-app/components/ui/index.html +12 -0
  21. package/templates/ai-app/components/ui/package.json +28 -0
  22. package/templates/ai-app/components/ui/public/favicon.svg +4 -0
  23. package/templates/ai-app/components/ui/src/App.tsx +52 -0
  24. package/templates/ai-app/components/ui/src/api.ts +85 -0
  25. package/templates/ai-app/components/ui/src/main.tsx +11 -0
  26. package/templates/ai-app/components/ui/src/styles/app.css +210 -0
  27. package/templates/ai-app/components/ui/src/styles/theme.css +181 -0
  28. package/templates/ai-app/components/ui/src/tabs/chat-tab.tsx +75 -0
  29. package/templates/ai-app/components/ui/src/tabs/extract-tab.tsx +92 -0
  30. package/templates/ai-app/components/ui/src/tabs/image-tab.tsx +51 -0
  31. package/templates/ai-app/components/ui/src/tabs/speech-tab.tsx +47 -0
  32. package/templates/ai-app/components/ui/src/tabs/transcribe-tab.tsx +42 -0
  33. package/templates/ai-app/components/ui/src/tabs/video-tab.tsx +76 -0
  34. package/templates/ai-app/components/ui/src/types.ts +53 -0
  35. package/templates/ai-app/components/ui/src/vite-env.d.ts +1 -0
  36. package/templates/ai-app/components/ui/tsconfig.json +21 -0
  37. package/templates/ai-app/components/ui/vite.config.ts +22 -0
  38. package/templates/ai-app/kazzle.config.ts +9 -0
  39. package/templates/ai-app/package.json +17 -0
  40. package/templates/empty-app/KAZZLE.md +10 -0
  41. package/templates/empty-app/kazzle.config.ts +8 -0
  42. package/templates/empty-app/package.json +15 -0
  43. package/templates/manifest.json +10 -0
  44. package/templates/process-app/KAZZLE.md +10 -0
  45. package/templates/process-app/components/process/index.ts +155 -0
  46. package/templates/process-app/components/process/package.json +20 -0
  47. package/templates/process-app/components/process/tsconfig.json +12 -0
  48. package/templates/process-app/kazzle.config.ts +32 -0
  49. package/templates/process-app/package.json +18 -0
  50. package/templates/process-app/skills/tools/SKILL.md +37 -0
  51. package/templates/process-app/skills/tools/tools.ts +19 -0
  52. package/templates/realtime-app/KAZZLE.md +11 -0
  53. package/templates/realtime-app/bun.lock +887 -0
  54. package/templates/realtime-app/components/server/deploy.ts +105 -0
  55. package/templates/realtime-app/components/server/index.ts +40 -0
  56. package/templates/realtime-app/components/server/migrations/001_items.sql +6 -0
  57. package/templates/realtime-app/components/server/package.json +20 -0
  58. package/templates/realtime-app/components/server/routes.ts +137 -0
  59. package/templates/realtime-app/components/server/tsconfig.json +15 -0
  60. package/templates/realtime-app/components/ui/index.html +13 -0
  61. package/templates/realtime-app/components/ui/package.json +36 -0
  62. package/templates/realtime-app/components/ui/public/favicon.svg +4 -0
  63. package/templates/realtime-app/components/ui/src/App.tsx +77 -0
  64. package/templates/realtime-app/components/ui/src/lib/connector.ts +80 -0
  65. package/templates/realtime-app/components/ui/src/lib/schema.ts +35 -0
  66. package/templates/realtime-app/components/ui/src/lib/sync.ts +24 -0
  67. package/templates/realtime-app/components/ui/src/main.tsx +49 -0
  68. package/templates/realtime-app/components/ui/src/styles/theme.css +181 -0
  69. package/templates/realtime-app/components/ui/src/vite-env.d.ts +2 -0
  70. package/templates/realtime-app/components/ui/tsconfig.json +14 -0
  71. package/templates/realtime-app/components/ui/vite.config.ts +86 -0
  72. package/templates/realtime-app/kazzle.config.ts +11 -0
  73. package/templates/realtime-app/package.json +17 -0
  74. package/templates/shared/icon.svg +4 -0
  75. package/templates/ui-app/KAZZLE.md +16 -0
  76. package/templates/ui-app/components/ui/bun.lock +894 -0
  77. package/templates/ui-app/components/ui/index.html +13 -0
  78. package/templates/ui-app/components/ui/package.json +30 -0
  79. package/templates/ui-app/components/ui/public/favicon.svg +4 -0
  80. package/templates/ui-app/components/ui/src/App.tsx +41 -0
  81. package/templates/ui-app/components/ui/src/main.tsx +24 -0
  82. package/templates/ui-app/components/ui/src/styles/theme.css +181 -0
  83. package/templates/ui-app/components/ui/tsconfig.json +21 -0
  84. package/templates/ui-app/components/ui/vite.config.ts +97 -0
  85. package/templates/ui-app/kazzle.config.ts +10 -0
  86. package/templates/ui-app/package.json +16 -0
  87. package/templates/ui-db-app/KAZZLE.md +12 -0
  88. package/templates/ui-db-app/components/server/index.ts +218 -0
  89. package/templates/ui-db-app/components/server/package.json +21 -0
  90. package/templates/ui-db-app/components/server/tsconfig.json +11 -0
  91. package/templates/ui-db-app/components/ui/index.html +12 -0
  92. package/templates/ui-db-app/components/ui/package.json +28 -0
  93. package/templates/ui-db-app/components/ui/public/favicon.svg +4 -0
  94. package/templates/ui-db-app/components/ui/src/App.tsx +221 -0
  95. package/templates/ui-db-app/components/ui/src/api.ts +79 -0
  96. package/templates/ui-db-app/components/ui/src/main.tsx +10 -0
  97. package/templates/ui-db-app/components/ui/src/styles/theme.css +181 -0
  98. package/templates/ui-db-app/components/ui/src/types.ts +17 -0
  99. package/templates/ui-db-app/components/ui/src/vite-env.d.ts +1 -0
  100. package/templates/ui-db-app/components/ui/tsconfig.json +21 -0
  101. package/templates/ui-db-app/components/ui/vite.config.ts +19 -0
  102. package/templates/ui-db-app/kazzle.config.ts +9 -0
  103. package/templates/ui-db-app/package.json +17 -0
@@ -0,0 +1,181 @@
1
+ /* ─────────────────────────────────────────────────────────────────────────
2
+ * Kazzle app theme — the ONE styling entry point for this app.
3
+ *
4
+ * This file is the design system. It is imported once (in `main.tsx`) and
5
+ * gives you three things, in order:
6
+ *
7
+ * 1. Tailwind v4 — every utility class (`flex`, `gap-4`,
8
+ * `rounded-xl`, `text-zinc-500`, …) works in
9
+ * your JSX. No config file, no PostCSS setup.
10
+ * 2. Design tokens (@theme) — colors, radius, fonts as CSS variables. Edit
11
+ * these to re-skin the whole app at once.
12
+ * 3. Primitives (@layer) — a few ready-made classes (`.btn`, `.card`,
13
+ * `.input`, `.field`, `.page`, `.stack`,
14
+ * `.row`) so common UI looks good with zero
15
+ * effort.
16
+ *
17
+ * HOW TO STYLE — pick whichever is easier, mix freely:
18
+ * • Tailwind utilities in `className` for one-off layout/spacing.
19
+ * • A primitive class (`.btn`, `.card`) for the common building blocks.
20
+ *
21
+ * WHY IT'S BUILT THIS WAY: styles live in the markup (utilities) or in named
22
+ * primitives here — never in a separate per-screen stylesheet keyed to class
23
+ * names you have to keep in sync. Rewriting a component can't silently strip
24
+ * its styling, because the styling travels with the elements.
25
+ *
26
+ * TO EXTEND: add new design tokens under `@theme`, and add new reusable
27
+ * building blocks under `@layer components`. Keep app-specific one-offs as
28
+ * inline Tailwind utilities in the component instead of adding a class here.
29
+ * ───────────────────────────────────────────────────────────────────────── */
30
+
31
+ @import "tailwindcss";
32
+
33
+ /* ── Design tokens ──────────────────────────────────────────────────────────
34
+ * Exposed to Tailwind as `bg-surface`, `text-fg`, `text-muted`,
35
+ * `bg-accent`, `rounded-app`, etc. Change a value here and every utility and
36
+ * primitive that references it updates at once. */
37
+ @theme {
38
+ --color-bg: #0b0f1a;
39
+ --color-surface: #131a2a;
40
+ --color-surface-raised: #1b2438;
41
+ --color-fg: #e8edf7;
42
+ --color-muted: #94a3b8;
43
+ --color-border: rgba(148, 163, 184, 0.18);
44
+ --color-accent: #6366f1;
45
+ --color-accent-hover: #4f46e5;
46
+ --color-accent-fg: #ffffff;
47
+ --color-danger: #f87171;
48
+
49
+ --radius-app: 0.875rem;
50
+
51
+ --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system,
52
+ BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
53
+ }
54
+
55
+ /* ── Base ────────────────────────────────────────────────────────────────────
56
+ * Sensible document defaults so even unstyled markup reads well. */
57
+ @layer base {
58
+ html,
59
+ body,
60
+ #root {
61
+ min-height: 100%;
62
+ }
63
+
64
+ body {
65
+ margin: 0;
66
+ background: var(--color-bg);
67
+ color: var(--color-fg);
68
+ font-family: var(--font-sans);
69
+ -webkit-font-smoothing: antialiased;
70
+ }
71
+
72
+ h1 {
73
+ font-size: 1.875rem;
74
+ font-weight: 700;
75
+ letter-spacing: -0.02em;
76
+ margin: 0;
77
+ }
78
+
79
+ h2 {
80
+ font-size: 1.25rem;
81
+ font-weight: 600;
82
+ margin: 0;
83
+ }
84
+ }
85
+
86
+ /* ── Primitives ──────────────────────────────────────────────────────────────
87
+ * Reusable building blocks. Use them directly (`<button class="btn btn-primary">`)
88
+ * or layer Tailwind utilities on top. Add new ones here when a pattern repeats. */
89
+ @layer components {
90
+ /* Page wrapper — centers content with comfortable gutters. */
91
+ .page {
92
+ width: min(100% - 2rem, 48rem);
93
+ margin-inline: auto;
94
+ padding-block: 3rem;
95
+ display: flex;
96
+ flex-direction: column;
97
+ gap: 1.5rem;
98
+ }
99
+
100
+ /* Vertical / horizontal stacks. */
101
+ .stack {
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: 0.75rem;
105
+ }
106
+ .row {
107
+ display: flex;
108
+ align-items: center;
109
+ gap: 0.75rem;
110
+ }
111
+
112
+ /* Card surface. */
113
+ .card {
114
+ background: var(--color-surface);
115
+ border: 1px solid var(--color-border);
116
+ border-radius: var(--radius-app);
117
+ padding: 1.25rem;
118
+ }
119
+
120
+ /* Buttons. `.btn` is the neutral base; add `.btn-primary` for the accent. */
121
+ .btn {
122
+ display: inline-flex;
123
+ align-items: center;
124
+ justify-content: center;
125
+ gap: 0.5rem;
126
+ padding: 0.625rem 1rem;
127
+ border-radius: var(--radius-app);
128
+ border: 1px solid var(--color-border);
129
+ background: var(--color-surface-raised);
130
+ color: var(--color-fg);
131
+ font: inherit;
132
+ font-weight: 500;
133
+ cursor: pointer;
134
+ transition: background 0.15s, border-color 0.15s, opacity 0.15s;
135
+ }
136
+ .btn:hover {
137
+ background: color-mix(in srgb, var(--color-surface-raised) 80%, white);
138
+ }
139
+ .btn:disabled {
140
+ opacity: 0.5;
141
+ cursor: not-allowed;
142
+ }
143
+ .btn-primary {
144
+ background: var(--color-accent);
145
+ border-color: transparent;
146
+ color: var(--color-accent-fg);
147
+ }
148
+ .btn-primary:hover {
149
+ background: var(--color-accent-hover);
150
+ }
151
+
152
+ /* Text input / select. */
153
+ .input {
154
+ width: 100%;
155
+ min-width: 0;
156
+ padding: 0.625rem 0.875rem;
157
+ border-radius: var(--radius-app);
158
+ border: 1px solid var(--color-border);
159
+ background: var(--color-surface-raised);
160
+ color: var(--color-fg);
161
+ font: inherit;
162
+ outline: none;
163
+ }
164
+ .input:focus {
165
+ border-color: var(--color-accent);
166
+ }
167
+
168
+ /* Labelled field: <label class="field"><span>Label</span><input class="input"/></label> */
169
+ .field {
170
+ display: flex;
171
+ flex-direction: column;
172
+ gap: 0.375rem;
173
+ font-size: 0.875rem;
174
+ color: var(--color-muted);
175
+ }
176
+
177
+ /* Muted helper / secondary text. */
178
+ .muted {
179
+ color: var(--color-muted);
180
+ }
181
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vite-plugin-pwa/client" />
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "jsx": "react-jsx",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "types": ["node"]
12
+ },
13
+ "include": ["src", "vite.config.ts"]
14
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Vite config for the UI component.
3
+ *
4
+ * Kazzle preview/runtime wiring (HOST/PORT binding, strictPort, allowedHosts,
5
+ * backend proxy) lives in @kazzle/app/vite — the ONE shared place that must
6
+ * never be reinvented. This template declares a backend `server` component
7
+ * (PowerSync sync endpoint); we proxy `/sync` to it via the helper. Add new
8
+ * backend routes to `proxyPaths`.
9
+ *
10
+ * PWA + worker config below is realtime-specific (offline-first PowerSync) and
11
+ * stays here on top of the shared port contract.
12
+ */
13
+ import { defineConfig, type Plugin } from 'vite';
14
+ import react from '@vitejs/plugin-react';
15
+ import tailwindcss from '@tailwindcss/vite';
16
+ import { VitePWA } from 'vite-plugin-pwa';
17
+ import { kazzleAppVite } from '@kazzle/app/vite';
18
+
19
+ /**
20
+ * Dev-only: any browser that previously visited a built/PWA-enabled version
21
+ * of this app at the same origin still has a service worker installed. With
22
+ * `devOptions.enabled: false` we don't serve a SW in dev, so the stale SW
23
+ * keeps intercepting requests with its old precache and the page renders
24
+ * without current CSS/JS. This plugin responds to /sw.js (and the PWA
25
+ * register helper) with a tiny script that unregisters every SW, clears all
26
+ * caches, and reloads the page once. Once cleaned, the SW is gone and Vite
27
+ * HMR works normally. Safe to keep enabled — production builds skip this
28
+ * plugin (the `serve` command guard).
29
+ */
30
+ function devUnregisterServiceWorker(): Plugin {
31
+ const body = [
32
+ "self.addEventListener('install', e => self.skipWaiting());",
33
+ "self.addEventListener('activate', e => e.waitUntil((async () => {",
34
+ " try { await self.registration.unregister(); } catch {}",
35
+ " try { const keys = await caches.keys(); await Promise.all(keys.map(k => caches.delete(k))); } catch {}",
36
+ " const clients = await self.clients.matchAll({ type: 'window' });",
37
+ " for (const c of clients) { try { c.navigate(c.url); } catch {} }",
38
+ "})());",
39
+ ].join('\n');
40
+ return {
41
+ name: 'kazzle:dev-unregister-sw',
42
+ apply: 'serve',
43
+ configureServer(server) {
44
+ server.middlewares.use((req, res, next) => {
45
+ if (req.method !== 'GET') return next();
46
+ const url = req.url?.split('?')[0];
47
+ if (url !== '/sw.js' && url !== '/registerSW.js') return next();
48
+ res.setHeader('content-type', 'application/javascript; charset=utf-8');
49
+ res.setHeader('cache-control', 'no-store');
50
+ res.end(body);
51
+ });
52
+ },
53
+ };
54
+ }
55
+
56
+ export default defineConfig(({ command }) => ({
57
+ plugins: [
58
+ react(),
59
+ tailwindcss(),
60
+ devUnregisterServiceWorker(),
61
+ // Service worker for offline-first behavior. `devOptions.enabled: false`
62
+ // is intentional — enabling the SW in dev breaks Vite HMR
63
+ // (templates.mdc note). The SW only ships in the production build, where
64
+ // it pre-caches the app shell + JS bundles so reload-while-offline keeps
65
+ // working. PowerSync's local SQLite stays readable in both modes.
66
+ VitePWA({
67
+ registerType: 'autoUpdate',
68
+ devOptions: { enabled: false },
69
+ workbox: { globPatterns: ['**/*.{js,css,html,svg,png,ico}'] },
70
+ manifest: {
71
+ name: 'Kazzle App',
72
+ short_name: 'Kazzle',
73
+ display: 'standalone',
74
+ start_url: '/',
75
+ },
76
+ }),
77
+ ],
78
+ // HOST/PORT/strictPort/allowedHosts + /sync proxy. See @kazzle/app/vite.
79
+ ...kazzleAppVite(command, { apiComponent: 'server', proxyPaths: ['/sync'] }),
80
+ optimizeDeps: {
81
+ exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
82
+ },
83
+ worker: {
84
+ format: 'es',
85
+ },
86
+ }));
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from '@kazzle/app';
2
+
3
+ export default defineConfig({
4
+ /** Path to the app icon relative to the repo root. Uploaded to CDN on publish. */
5
+ icon: 'components/ui/public/favicon.svg',
6
+ /** App components — each entry defines a deployable unit. Max 1 UI component. */
7
+ components: [
8
+ { name: 'ui', type: 'ui', path: './components/ui' },
9
+ { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: 'bun run dev', run: 'bun run start' } },
10
+ ],
11
+ });
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "{{APP_SLUG}}",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "workspaces": [
7
+ "components/*"
8
+ ],
9
+ "scripts": {
10
+ "dev": "bun run --cwd components/ui dev",
11
+ "start": "bun run --cwd components/server start",
12
+ "check": "bun run --filter='./components/*' check"
13
+ },
14
+ "dependencies": {
15
+ "@kazzle/app": "{{KAZZLE_APP_VERSION}}"
16
+ }
17
+ }
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <rect width="64" height="64" rx="14" fill="hsl(230,65%,88%)"/>
3
+ <text x="32" y="46" text-anchor="middle" font-family="system-ui,sans-serif" font-size="40" font-weight="600" fill="hsl(230,50%,25%)">K</text>
4
+ </svg>
@@ -0,0 +1,16 @@
1
+ # Kazzle template context
2
+
3
+ This app was created from the `ui` template. It is a frontend-only React and Vite app.
4
+
5
+ Template-owned setup:
6
+ - `kazzle.config.ts` declares one UI component.
7
+ - `components/ui/package.json` already contains the Vite dev, build, typecheck, and check scripts.
8
+ - `components/ui/src/main.tsx` and `components/ui/src/App.tsx` are the base UI entrypoint. `main.tsx` imports the design system once via `src/styles/theme.css`.
9
+
10
+ Styling — this is mandatory, not a suggestion:
11
+ - The design system is `src/styles/theme.css`. It already imports Tailwind v4 (`@import "tailwindcss"`) so EVERY Tailwind utility class works in `className`, plus ready-made primitives (`.page`, `.stack`, `.row`, `.card`, `.btn`, `.btn-primary`, `.input`, `.field`, `.muted`) and design tokens.
12
+ - Style ONLY two ways: Tailwind utility classes in `className` (e.g. `className="flex items-center gap-4 rounded-xl"`), and/or the primitives above. Mix freely.
13
+ - NEVER invent semantic class names (`app-shell`, `hero`, `stats-grid`, `listing-grid`, …) and NEVER add a separate per-screen stylesheet keyed to class names. Those classes have no CSS behind them, so the app renders with no layout. If a pattern repeats, add a primitive under `@layer components` in `theme.css` — do not create a new CSS file.
14
+ - To re-skin, edit the `@theme` tokens in `theme.css`. Do not create `App.css` or any other stylesheet.
15
+
16
+ Do not add a server component, database wiring, or secret env refs unless the user's requirements need backend behavior. For ordinary Postgres persistence, use the `ui-db` template instead of converting this app by hand.