@freeappstore/cli 0.4.59 → 0.4.61

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,1065 @@
1
+ /** Canonical worker-safe editable starter foundation. */
2
+ import { planCapabilityChanges } from './capability-definitions.js';
3
+ import { resolveStarterPreset } from './starter-presets.js';
4
+ export const APP_STARTER_CONFIG = {
5
+ store: 'apps',
6
+ r2Bucket: 'fas-apps',
7
+ nounPlural: 'apps',
8
+ };
9
+ export const APP_ARCHETYPES = [
10
+ 'dashboard',
11
+ 'tracker',
12
+ 'calculator',
13
+ 'generic',
14
+ ];
15
+ // ── Shared template files (identical for apps and games) ──
16
+ const SHARED_FILES = {
17
+ 'pnpm-workspace.yaml': `packages:\n - web\n`,
18
+ 'package.json': `{
19
+ "name": "APPNAME",
20
+ "private": true,
21
+ "packageManager": "pnpm@10.30.3",
22
+ "engines": { "node": ">=22" },
23
+ "pnpm": { "onlyBuiltDependencies": ["esbuild"] },
24
+ "scripts": {
25
+ "dev": "pnpm --filter @APPNAME/web dev",
26
+ "build": "pnpm --filter @APPNAME/web build",
27
+ "preview": "pnpm --filter @APPNAME/web preview",
28
+ "typecheck": "pnpm --filter @APPNAME/web exec tsc -b",
29
+ "test": "pnpm build"
30
+ }
31
+ }`,
32
+ 'web/package.json': `{
33
+ "name": "@APPNAME/web",
34
+ "private": true,
35
+ "type": "module",
36
+ "scripts": {
37
+ "dev": "vite",
38
+ "build": "vite build",
39
+ "preview": "vite preview",
40
+ "test": "vitest run"
41
+ },
42
+ "dependencies": {
43
+ "react": "^19",
44
+ "react-dom": "^19",
45
+ "@freeappstore/sdk": "^0.16.32"
46
+ },
47
+ "devDependencies": {
48
+ "@tailwindcss/vite": "^4.1",
49
+ "@types/react": "^19",
50
+ "@types/react-dom": "^19",
51
+ "@vitejs/plugin-react": "^4.3",
52
+ "tailwindcss": "^4.1",
53
+ "typescript": "^5.7",
54
+ "@types/node": "^22.20.2",
55
+ "happy-dom": "^20.14.5",
56
+ "vitest": "^4.1.11",
57
+ "vite": "^6"
58
+ }
59
+ }`,
60
+ 'web/vite.config.ts': `
61
+ import { defineConfig } from "vite";
62
+ import react from "@vitejs/plugin-react";
63
+ import tailwindcss from "@tailwindcss/vite";
64
+
65
+ export default defineConfig({
66
+ plugins: [react(), tailwindcss()],
67
+ });`,
68
+ 'web/tsconfig.json': `{
69
+ "files": [],
70
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
71
+ }`,
72
+ 'web/tsconfig.app.json': `{
73
+ "compilerOptions": {
74
+ "target": "ES2020",
75
+ "useDefineForClassFields": true,
76
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
77
+ "module": "ESNext",
78
+ "skipLibCheck": true,
79
+ "moduleResolution": "bundler",
80
+ "allowImportingTsExtensions": true,
81
+ "isolatedModules": true,
82
+ "moduleDetection": "force",
83
+ "noEmit": true,
84
+ "jsx": "react-jsx",
85
+ "strict": true,
86
+ "noUnusedLocals": false,
87
+ "noUnusedParameters": true,
88
+ "noFallthroughCasesInSwitch": true,
89
+ "noUncheckedSideEffectImports": true
90
+ },
91
+ "include": ["src"]
92
+ }`,
93
+ 'web/tsconfig.node.json': `{
94
+ "compilerOptions": {
95
+ "target": "ES2022",
96
+ "lib": ["ES2023"],
97
+ "module": "ESNext",
98
+ "skipLibCheck": true,
99
+ "moduleResolution": "bundler",
100
+ "allowImportingTsExtensions": true,
101
+ "isolatedModules": true,
102
+ "moduleDetection": "force",
103
+ "noEmit": true,
104
+ "strict": true,
105
+ "noUnusedLocals": true,
106
+ "noUnusedParameters": true,
107
+ "noFallthroughCasesInSwitch": true,
108
+ "noUncheckedSideEffectImports": true
109
+ },
110
+ "include": ["vite.config.ts"]
111
+ }`,
112
+ 'web/src/main.tsx': `import { StrictMode } from "react";
113
+ import { createRoot } from "react-dom/client";
114
+ import "./index.css";
115
+ import App from "./App";
116
+
117
+ createRoot(document.getElementById("root")!).render(
118
+ <StrictMode>
119
+ <App />
120
+ </StrictMode>,
121
+ );`,
122
+ '.gitignore': `node_modules\ndist\n.DS_Store\n*.local\n`,
123
+ };
124
+ // ── Apps-specific template files ──
125
+ const APP_FILES = {
126
+ 'web/src/starter.test.ts': `// @vitest-environment happy-dom
127
+ import { afterEach, expect, it, vi } from 'vitest';
128
+
129
+ afterEach(() => { localStorage.clear(); vi.unstubAllGlobals(); });
130
+
131
+ it('uses this scaffold id for synthetic authenticated SDK requests', async () => {
132
+ localStorage.setItem('fas:session', JSON.stringify({ token: 'synthetic-token', user: { id: 'synthetic-user', login: 'synthetic' } }));
133
+ const requests: string[] = [];
134
+ vi.stubGlobal('fetch', async (input: RequestInfo | URL) => {
135
+ requests.push(String(input));
136
+ return new Response('null', { status: 200 });
137
+ });
138
+ const { fas } = await import('./App');
139
+ await fas.kv.get('identity-probe');
140
+ expect(requests).toContain('https://api.freeappstore.online/v1/apps/APPID/roles/ensure-member');
141
+ expect(requests).toContain('https://api.freeappstore.online/v1/apps/APPID/kv/identity-probe');
142
+ });
143
+ `,
144
+ 'CLAUDE.md': `# Editable FreeAppStore starter
145
+
146
+ This source is app-owned after scaffolding. Keep existing screens, layouts and data.
147
+ The SDK Shell is the supported default; a custom accessible frame is supported.
148
+ Keep a reachable Profile in both auth states, shared theme/text preferences,
149
+ keyboard navigation, visible focus, loading/error feedback and page zoom.
150
+ Public screens stay public; gate private features at their data boundary.
151
+ Share the existing SDK/Auth instance with Shell, Profile and connected features.
152
+
153
+ Choose device-local, private-account, public-shared or room storage for the feature.
154
+ Never treat collections or room broadcasts as private storage. Do not ask end users
155
+ for developer API keys: the SDK proxy supports server-side key injection.
156
+ No payments, ads or direct trackers. Preserve SDK Tailwind @source and @theme wiring.
157
+
158
+ Use fas add <capability> --dry-run for infrastructure changes. Resolve reported
159
+ package prerequisites before applying; root recipe imports need a root SDK dependency.
160
+ Keep edited capability files and review conflicts rather than overwriting them.
161
+ Keep one PWA controller and register busy guards for unsaved work and capture.
162
+
163
+ Canonical source and guidance:
164
+ https://github.com/freeappstore-online/platform/blob/main/docs/composable-starter-contract.md
165
+ https://github.com/freeappstore-online/platform/blob/main/CONTRIBUTING.md#updating-the-external-app-starter-repositories
166
+ `,
167
+ 'web/src/vite-env.d.ts': `/// <reference types="vite/client" />\n`,
168
+ 'web/index.html': `<!DOCTYPE html>
169
+ <html lang="en">
170
+ <head>
171
+ <meta charset="UTF-8" />
172
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
173
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
174
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
175
+ <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,700;9..144,800&display=swap" rel="stylesheet" />
176
+ <link rel="manifest" href="/manifest.json" />
177
+ <meta name="theme-color" content="#2563eb" />
178
+ <meta name="apple-mobile-web-app-capable" content="yes" />
179
+ <meta name="mobile-web-app-capable" content="yes" />
180
+ <title>APPNAME — FreeAppStore</title>
181
+ <link rel="canonical" href="https://APPID.freeappstore.online/" />
182
+ <meta property="og:title" content="APPNAME — FreeAppStore" />
183
+ <meta property="og:url" content="https://APPID.freeappstore.online/" />
184
+ <meta name="twitter:card" content="summary" />
185
+ </head>
186
+ <body>
187
+ <div id="root"></div>
188
+ <script type="module" src="/src/main.tsx"></script>
189
+ </body>
190
+ </html>`,
191
+ 'web/public/manifest.json': `{
192
+ "name": "APPNAME",
193
+ "short_name": "APPNAME",
194
+ "start_url": "/",
195
+ "display": "standalone",
196
+ "background_color": "#ffffff",
197
+ "theme_color": "#2563eb",
198
+ "orientation": "any"
199
+ }`,
200
+ 'web/src/index.css': `@import "tailwindcss";
201
+ @source "../node_modules/@freeappstore/sdk/dist";
202
+ @source "../../node_modules/@freeappstore/sdk/dist";
203
+
204
+ @theme inline {
205
+ --color-paper: var(--paper);
206
+ --color-paper-deep: var(--paper-deep, var(--paper));
207
+ --color-ink: var(--ink);
208
+ --color-ink-strong: var(--ink-strong, var(--ink));
209
+ --color-muted: var(--muted);
210
+ --color-line: var(--line);
211
+ --color-line-strong: var(--line-strong, var(--line));
212
+ --color-panel: var(--panel);
213
+ --color-panel-glass: var(--panel-glass, var(--panel));
214
+ --color-popover: var(--popover, var(--paper));
215
+ --color-accent: var(--accent);
216
+ --color-accent-soft: var(--accent-soft, var(--accent));
217
+ --color-accent-deep: var(--accent-deep, var(--accent));
218
+ --color-accent-hover: var(--accent-hover, var(--accent));
219
+ --color-sky: var(--sky, #0ea5e9);
220
+ --color-sky-soft: var(--sky-soft, #e0f2fe);
221
+ --color-sky-deep: var(--sky-deep, #0369a1);
222
+ --color-mint: var(--mint, #10b981);
223
+ --color-mint-soft: var(--mint-soft, #d1fae5);
224
+ --color-mint-deep: var(--mint-deep, #047857);
225
+ --color-success: var(--success);
226
+ --color-success-soft: var(--success-soft, var(--success));
227
+ --color-warning: var(--warning);
228
+ --color-warning-soft: var(--warning-soft, var(--warning));
229
+ --color-danger: var(--danger);
230
+ --color-danger-soft: var(--danger-soft, var(--danger));
231
+ --color-scrim: var(--scrim, rgb(0 0 0 / 45%));
232
+ --radius: var(--radius, 12px);
233
+ --radius-sm: var(--radius-sm, 8px);
234
+ --radius-lg: var(--radius-lg, var(--radius));
235
+ --shadow-sm: var(--shadow, 0 1px 2px rgb(0 0 0 / 8%));
236
+ --shadow-lg: var(--shadow-lg, 0 12px 32px rgb(0 0 0 / 18%));
237
+ }
238
+
239
+ @theme {
240
+ --animate-sdk-fade-in: sdk-fade-in 150ms ease-out;
241
+ --animate-sdk-slide-up: sdk-slide-up 200ms ease-out;
242
+ --animate-sdk-drawer: sdk-drawer 200ms ease-out;
243
+ @keyframes sdk-fade-in { from { opacity: 0; } to { opacity: 1; } }
244
+ @keyframes sdk-slide-up {
245
+ from { opacity: 0; transform: translateY(8px); }
246
+ to { opacity: 1; transform: translateY(0); }
247
+ }
248
+ @keyframes sdk-drawer {
249
+ from { transform: translateX(100%); }
250
+ to { transform: translateX(0); }
251
+ }
252
+ }
253
+
254
+ :root {
255
+ --paper: #ffffff;
256
+ --ink: #1a1a1a;
257
+ --muted: #6b7280;
258
+ --line: #e5e7eb;
259
+ --line-strong: #d1d5db;
260
+ --panel: #f9fafb;
261
+ --success: #16a34a;
262
+ --warning: #d97706;
263
+ --danger: #dc2626;
264
+ --accent: #2563eb;
265
+ --paper-deep: #f3f4f6;
266
+ --ink-strong: var(--ink);
267
+ --panel-glass: rgba(255, 255, 255, 0.72);
268
+ --popover: var(--paper);
269
+ --scrim: rgba(0, 0, 0, 0.5);
270
+ --accent-soft: #dbeafe;
271
+ --accent-deep: #1e40af;
272
+ --accent-hover: var(--accent-deep);
273
+ --sky: #0284c7;
274
+ --sky-soft: #e0f2fe;
275
+ --sky-deep: #075985;
276
+ --mint: #059669;
277
+ --mint-soft: #d1fae5;
278
+ --mint-deep: #065f46;
279
+ --success-soft: color-mix(in srgb, var(--success) 15%, var(--paper));
280
+ --warning-soft: color-mix(in srgb, var(--warning) 15%, var(--paper));
281
+ --danger-soft: color-mix(in srgb, var(--danger) 15%, var(--paper));
282
+ --radius: 0.75rem;
283
+ --radius-sm: 0.5rem;
284
+ --radius-lg: 1rem;
285
+ --shadow: 0 12px 28px rgba(26, 41, 81, 0.08);
286
+ --shadow-lg: var(--shadow);
287
+ --font-display: "Fraunces", Georgia, serif;
288
+ font-family: "Manrope", system-ui, sans-serif;
289
+ }
290
+
291
+ /* Dark mode: the SDK sets data-theme="dark" on <html> when the system is dark
292
+ or the user picks dark in the Shell's theme toggle. */
293
+ :root[data-theme="dark"] {
294
+ color-scheme: dark;
295
+ --paper: #0f0f0f;
296
+ --ink: #f5f5f5;
297
+ --muted: #9ca3af;
298
+ --line: #2d2d2d;
299
+ --line-strong: #404040;
300
+ --panel: #1a1a1a;
301
+ --success: #22c55e;
302
+ --warning: #fbbf24;
303
+ --danger: #ef4444;
304
+ --paper-deep: #0a0a0a;
305
+ --panel-glass: rgba(26, 26, 26, 0.8);
306
+ --accent: #60a5fa;
307
+ --accent-soft: #172554;
308
+ --accent-deep: #bfdbfe;
309
+ --sky: #38bdf8;
310
+ --sky-soft: #082f49;
311
+ --sky-deep: #bae6fd;
312
+ --mint: #34d399;
313
+ --mint-soft: #022c22;
314
+ --mint-deep: #a7f3d0;
315
+ --shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
316
+ }
317
+
318
+ /* Shell text preferences scale rem-based typography without blocking zoom. */
319
+ :root[data-text="lg"] { font-size: 112.5%; }
320
+ :root[data-text="sm"] { font-size: 87.5%; }
321
+
322
+ body {
323
+ margin: 0;
324
+ background: var(--paper);
325
+ color: var(--ink);
326
+ }
327
+
328
+ h1,
329
+ h2,
330
+ h3 {
331
+ font-family: var(--font-display);
332
+ }`,
333
+ 'web/src/App.tsx': `import { useEffect, useState } from "react";
334
+ import { initApp } from "@freeappstore/sdk";
335
+ import { type NavItem, PageHeader, Shell } from "@freeappstore/sdk/ui";
336
+
337
+ // "APPID" is replaced by the CLI scaffold or deployment flow with this app's id.
338
+ export const fas = initApp({ appId: "APPID" });
339
+
340
+ // The app's screens. Shell renders them as the navbar: a <nav> in its topbar
341
+ // with the current screen highlighted, collapsing to a menu on phones.
342
+ // Add one entry per primary screen; \`title\` becomes the browser tab title.
343
+ const NAV: NavItem[] = [
344
+ { label: "Home", href: "/", title: "APPNAME_JS" },
345
+ { label: "About", href: "/about", title: "About — APPNAME_JS" },
346
+ ];
347
+
348
+ export default function App() {
349
+ const [path, setPath] = useState(() => window.location.pathname);
350
+
351
+ // Keep the screen in step with the browser's back and forward buttons.
352
+ useEffect(() => {
353
+ const sync = () => setPath(window.location.pathname);
354
+ window.addEventListener("popstate", sync);
355
+ return () => window.removeEventListener("popstate", sync);
356
+ }, []);
357
+
358
+ // Nav clicks switch screens without a page load. Shell scrolls to the top
359
+ // and moves focus to the new screen's PageHeader.
360
+ const navigate = (href: string) => {
361
+ window.history.pushState(null, "", href);
362
+ setPath(href);
363
+ };
364
+
365
+ return (
366
+ <Shell app={fas} appName={"APPNAME_JS"} nav={NAV} onNavigate={navigate}>
367
+ <div className="mx-auto w-full max-w-3xl p-4 sm:p-8">
368
+ {path === "/about" ? <About /> : <Home />}
369
+ </div>
370
+ </Shell>
371
+ );
372
+ }
373
+
374
+ function Home() {
375
+ return <PageHeader title={"Welcome to APPNAME_JS"} description="Edit web/src/App.tsx to get started." />;
376
+ }
377
+
378
+ function About() {
379
+ return (
380
+ <>
381
+ <PageHeader title="About" />
382
+ <p style={{ color: "var(--muted)" }}>
383
+ APPNAME_TEXT is a free app on <a href="https://freeappstore.online">FreeAppStore</a>.
384
+ </p>
385
+ </>
386
+ );
387
+ }`,
388
+ LICENSE: `MIT License
389
+
390
+ Copyright (c) 2025 FreeAppStore
391
+
392
+ Permission is hereby granted, free of charge, to any person obtaining a copy
393
+ of this software and associated documentation files (the "Software"), to deal
394
+ in the Software without restriction, including without limitation the rights
395
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
396
+ copies of the Software, and to permit persons to whom the Software is
397
+ furnished to do so, subject to the following conditions:
398
+
399
+ The above copyright notice and this permission notice shall be included in all
400
+ copies or substantial portions of the Software.
401
+
402
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
403
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
404
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
405
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
406
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
407
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
408
+ SOFTWARE.`,
409
+ };
410
+ const DASHBOARD_FILES = {
411
+ 'web/src/components/Dashboard.tsx': `const stats = [
412
+ { label: "Revenue", value: "$24.8k", delta: "+12%" },
413
+ { label: "Active users", value: "1,284", delta: "+8%" },
414
+ { label: "Conversion", value: "6.2%", delta: "+1.4%" },
415
+ { label: "Open tasks", value: "17", delta: "-3" },
416
+ ];
417
+
418
+ export function Dashboard() {
419
+ return (
420
+ <section className="space-y-6">
421
+ <div>
422
+ <h2 className="text-2xl font-bold" style={{ fontFamily: "Fraunces, serif" }}>
423
+ Dashboard
424
+ </h2>
425
+ <p className="mt-1 text-sm" style={{ color: "var(--muted)" }}>
426
+ Track the signals that matter most.
427
+ </p>
428
+ </div>
429
+ <div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
430
+ {stats.map((stat) => (
431
+ <article
432
+ key={stat.label}
433
+ className="rounded-2xl border p-4"
434
+ style={{ borderColor: "var(--line)", background: "var(--panel)" }}
435
+ >
436
+ <p className="text-sm font-medium" style={{ color: "var(--muted)" }}>
437
+ {stat.label}
438
+ </p>
439
+ <div className="mt-3 flex items-end justify-between gap-3">
440
+ <strong className="text-2xl">{stat.value}</strong>
441
+ <span className="rounded-full px-2 py-1 text-xs font-semibold" style={{ color: "var(--success)", background: "var(--paper)" }}>
442
+ {stat.delta}
443
+ </span>
444
+ </div>
445
+ </article>
446
+ ))}
447
+ </div>
448
+ <div className="grid gap-4 lg:grid-cols-[2fr_1fr]">
449
+ <article className="min-h-72 rounded-2xl border p-5" style={{ borderColor: "var(--line)", background: "var(--panel)" }}>
450
+ <div className="flex items-center justify-between">
451
+ <h3 className="font-semibold">Trend overview</h3>
452
+ <span className="text-sm" style={{ color: "var(--muted)" }}>Last 30 days</span>
453
+ </div>
454
+ <div className="mt-8 flex h-44 items-end gap-3">
455
+ {[42, 68, 52, 76, 64, 86, 72, 94].map((height, index) => (
456
+ <div key={index} className="flex-1 rounded-t-xl" style={{ height: height + "%", background: "var(--accent)" }} />
457
+ ))}
458
+ </div>
459
+ </article>
460
+ <article className="rounded-2xl border p-5" style={{ borderColor: "var(--line)", background: "var(--panel)" }}>
461
+ <h3 className="font-semibold">Next actions</h3>
462
+ <ul className="mt-4 space-y-3 text-sm">
463
+ {["Review weekly progress", "Prioritize stalled work", "Share update"].map((item) => (
464
+ <li key={item} className="rounded-xl border px-3 py-2" style={{ borderColor: "var(--line)", background: "var(--paper)" }}>
465
+ {item}
466
+ </li>
467
+ ))}
468
+ </ul>
469
+ </article>
470
+ </div>
471
+ </section>
472
+ );
473
+ }
474
+ `,
475
+ };
476
+ const TRACKER_FILES = {
477
+ 'web/src/components/Tracker.tsx': `import { useMemo, useState } from "react";
478
+
479
+ interface Item {
480
+ id: string;
481
+ title: string;
482
+ done: boolean;
483
+ }
484
+
485
+ const initialItems: Item[] = [
486
+ { id: "welcome", title: "Define the first thing to track", done: false },
487
+ { id: "sample", title: "Mark an item complete", done: true },
488
+ ];
489
+
490
+ export function Tracker() {
491
+ const [items, setItems] = useState<Item[]>(initialItems);
492
+ const [draft, setDraft] = useState("");
493
+ const [editingId, setEditingId] = useState<string | null>(null);
494
+
495
+ const remaining = useMemo(() => items.filter((item) => !item.done).length, [items]);
496
+ const editingItem = items.find((item) => item.id === editingId);
497
+
498
+ function saveItem() {
499
+ const title = draft.trim();
500
+ if (!title) return;
501
+ if (editingId) {
502
+ setItems((current) => current.map((item) => (item.id === editingId ? { ...item, title } : item)));
503
+ setEditingId(null);
504
+ } else {
505
+ setItems((current) => [{ id: crypto.randomUUID(), title, done: false }, ...current]);
506
+ }
507
+ setDraft("");
508
+ }
509
+
510
+ function startEdit(item: Item) {
511
+ setEditingId(item.id);
512
+ setDraft(item.title);
513
+ }
514
+
515
+ function cancelEdit() {
516
+ setEditingId(null);
517
+ setDraft("");
518
+ }
519
+
520
+ return (
521
+ <section className="space-y-5">
522
+ <div className="flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between">
523
+ <div>
524
+ <h2 className="text-2xl font-bold" style={{ fontFamily: "Fraunces, serif" }}>
525
+ Tracker
526
+ </h2>
527
+ <p className="text-sm" style={{ color: "var(--muted)" }}>
528
+ {remaining} open item{remaining === 1 ? "" : "s"}
529
+ </p>
530
+ </div>
531
+ </div>
532
+ <div className="rounded-2xl border p-4" style={{ borderColor: "var(--line)", background: "var(--panel)" }}>
533
+ <label className="text-sm font-semibold" htmlFor="tracker-item">
534
+ {editingItem ? "Edit item" : "Add item"}
535
+ </label>
536
+ <div className="mt-3 flex flex-col gap-2 sm:flex-row">
537
+ <input
538
+ id="tracker-item"
539
+ value={draft}
540
+ onChange={(event) => setDraft(event.target.value)}
541
+ onKeyDown={(event) => {
542
+ if (event.key === "Enter") saveItem();
543
+ if (event.key === "Escape") cancelEdit();
544
+ }}
545
+ placeholder="What needs tracking?"
546
+ className="min-h-11 flex-1 rounded-xl border px-3 outline-none"
547
+ style={{ borderColor: "var(--line)", background: "var(--paper)", color: "var(--ink)" }}
548
+ />
549
+ <button type="button" onClick={saveItem} className="min-h-11 rounded-xl px-4 font-semibold text-white" style={{ background: "var(--accent)" }}>
550
+ {editingItem ? "Save" : "Add"}
551
+ </button>
552
+ {editingItem && (
553
+ <button type="button" onClick={cancelEdit} className="min-h-11 rounded-xl border px-4 font-semibold" style={{ borderColor: "var(--line)" }}>
554
+ Cancel
555
+ </button>
556
+ )}
557
+ </div>
558
+ </div>
559
+ <ul className="space-y-3">
560
+ {items.map((item) => (
561
+ <li key={item.id} className="rounded-2xl border p-4" style={{ borderColor: "var(--line)", background: "var(--panel)" }}>
562
+ <div className="flex flex-col gap-3 sm:flex-row sm:items-center">
563
+ <label className="flex flex-1 items-center gap-3">
564
+ <input
565
+ type="checkbox"
566
+ checked={item.done}
567
+ onChange={() => setItems((current) => current.map((entry) => (entry.id === item.id ? { ...entry, done: !entry.done } : entry)))}
568
+ className="size-5"
569
+ />
570
+ <span className={item.done ? "line-through" : ""} style={{ color: item.done ? "var(--muted)" : "var(--ink)" }}>
571
+ {item.title}
572
+ </span>
573
+ </label>
574
+ <div className="flex gap-2">
575
+ <button type="button" onClick={() => startEdit(item)} className="rounded-xl border px-3 py-2 text-sm font-semibold" style={{ borderColor: "var(--line)" }}>
576
+ Edit
577
+ </button>
578
+ <button
579
+ type="button"
580
+ onClick={() => setItems((current) => current.filter((entry) => entry.id !== item.id))}
581
+ className="rounded-xl border px-3 py-2 text-sm font-semibold"
582
+ style={{ borderColor: "var(--line)", color: "var(--danger)" }}
583
+ >
584
+ Delete
585
+ </button>
586
+ </div>
587
+ </div>
588
+ </li>
589
+ ))}
590
+ </ul>
591
+ </section>
592
+ );
593
+ }
594
+ `,
595
+ };
596
+ const CALCULATOR_FILES = {
597
+ 'web/src/components/Calculator.tsx': `import { useMemo, useState } from "react";
598
+
599
+ const buttons = ["7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", ".", "=", "+"];
600
+
601
+ function evaluateExpression(expression: string): string {
602
+ if (!/^[0-9+\\-*/. ()]+$/.test(expression)) return "Error";
603
+ try {
604
+ const value = Function('"use strict"; return (' + expression + ')')();
605
+ return Number.isFinite(value) ? String(Number(value.toFixed(8))) : "Error";
606
+ } catch {
607
+ return "Error";
608
+ }
609
+ }
610
+
611
+ export function Calculator() {
612
+ const [display, setDisplay] = useState("0");
613
+ const isError = display === "Error";
614
+ const preview = useMemo(() => {
615
+ if (isError || display === "0" || /[+\\-*/.]$/.test(display)) return "";
616
+ const result = evaluateExpression(display);
617
+ return result !== "Error" && result !== display ? result : "";
618
+ }, [display, isError]);
619
+
620
+ function press(key: string) {
621
+ if (key === "=") {
622
+ setDisplay((current) => evaluateExpression(current));
623
+ return;
624
+ }
625
+ setDisplay((current) => (current === "0" || current === "Error" ? key : current + key));
626
+ }
627
+
628
+ return (
629
+ <section className="mx-auto max-w-sm space-y-4">
630
+ <div>
631
+ <h2 className="text-2xl font-bold" style={{ fontFamily: "Fraunces, serif" }}>
632
+ Calculator
633
+ </h2>
634
+ <p className="text-sm" style={{ color: "var(--muted)" }}>
635
+ A compact expression calculator.
636
+ </p>
637
+ </div>
638
+ <div className="rounded-2xl border p-4 shadow-sm" style={{ borderColor: "var(--line)", background: "var(--panel)" }}>
639
+ <div className="min-h-28 rounded-2xl border p-4 text-right" style={{ borderColor: "var(--line)", background: "var(--paper)" }}>
640
+ <div className="break-all text-3xl font-bold">{display}</div>
641
+ <div className="mt-2 min-h-5 text-sm" style={{ color: "var(--muted)" }}>
642
+ {preview}
643
+ </div>
644
+ </div>
645
+ <div className="mt-4 grid grid-cols-4 gap-2">
646
+ <button
647
+ type="button"
648
+ onClick={() => setDisplay("0")}
649
+ className="col-span-2 min-h-12 rounded-xl border font-semibold"
650
+ style={{ borderColor: "var(--line)" }}
651
+ >
652
+ Clear
653
+ </button>
654
+ <button
655
+ type="button"
656
+ onClick={() => setDisplay((current) => (current.length > 1 && current !== "Error" ? current.slice(0, -1) : "0"))}
657
+ className="col-span-2 min-h-12 rounded-xl border font-semibold"
658
+ style={{ borderColor: "var(--line)" }}
659
+ >
660
+ Back
661
+ </button>
662
+ {buttons.map((button) => (
663
+ <button
664
+ key={button}
665
+ type="button"
666
+ onClick={() => press(button)}
667
+ className="min-h-12 rounded-xl border text-lg font-semibold"
668
+ style={{
669
+ borderColor: "var(--line)",
670
+ background: button === "=" ? "var(--accent)" : "var(--paper)",
671
+ color: button === "=" ? "#fff" : "var(--ink)",
672
+ }}
673
+ >
674
+ {button}
675
+ </button>
676
+ ))}
677
+ </div>
678
+ </div>
679
+ </section>
680
+ );
681
+ }
682
+ `,
683
+ };
684
+ const APP_ARCHETYPE_FILES = {
685
+ dashboard: DASHBOARD_FILES,
686
+ tracker: TRACKER_FILES,
687
+ calculator: CALCULATOR_FILES,
688
+ generic: {},
689
+ };
690
+ // ── Games-specific template files ──
691
+ const GAME_FILES = {
692
+ 'web/index.html': `<!DOCTYPE html>
693
+ <html lang="en">
694
+ <head>
695
+ <meta charset="UTF-8" />
696
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
697
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
698
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
699
+ <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,700;9..144,800&display=swap" rel="stylesheet" />
700
+ <link rel="manifest" href="/manifest.json" />
701
+ <meta name="theme-color" content="#10b981" />
702
+ <meta name="apple-mobile-web-app-capable" content="yes" />
703
+ <meta name="mobile-web-app-capable" content="yes" />
704
+ <title>APPNAME — FreeGameStore</title>
705
+ </head>
706
+ <body>
707
+ <div id="root"></div>
708
+ <script type="module" src="/src/main.tsx"></script>
709
+ </body>
710
+ </html>`,
711
+ 'web/public/manifest.json': `{
712
+ "name": "APPNAME",
713
+ "short_name": "APPNAME",
714
+ "start_url": "/",
715
+ "display": "standalone",
716
+ "background_color": "#0f0f0f",
717
+ "theme_color": "#10b981",
718
+ "orientation": "any"
719
+ }`,
720
+ 'web/src/index.css': `@import "tailwindcss";
721
+
722
+ :root {
723
+ /* Games use the same canonical token names as apps (DESIGN-SYSTEM.md bans
724
+ the old background alias everywhere); only the values are game-dark. */
725
+ --paper: #0f0f0f;
726
+ --panel: #1a1a1a;
727
+ --ink: #f0f0f0;
728
+ --muted: #999;
729
+ --accent: #10b981;
730
+ --line: #2a2a2a;
731
+ --success: #22c55e;
732
+ --warning: #fbbf24;
733
+ --danger: #ef4444;
734
+ font-family: "Manrope", system-ui, sans-serif;
735
+ }
736
+
737
+ body {
738
+ margin: 0;
739
+ background: var(--paper);
740
+ color: var(--ink);
741
+ overflow: hidden;
742
+ }
743
+
744
+ #root {
745
+ width: 100vw;
746
+ height: 100dvh;
747
+ overflow: hidden;
748
+ }`,
749
+ 'web/src/components/GameShell.tsx': `import type { ReactNode } from "react";
750
+
751
+ interface GameShellProps {
752
+ title: string;
753
+ children: ReactNode;
754
+ }
755
+
756
+ /** GameShell: full-viewport wrapper with a 44px top bar and game canvas area.
757
+ * The topbar shows the game name and a link to FreeGameStore.
758
+ * The children fill the remaining viewport height. */
759
+ export function GameShell({ title, children }: GameShellProps) {
760
+ return (
761
+ <div style={{ width: "100vw", height: "100dvh", display: "flex", flexDirection: "column", overflow: "hidden", background: "var(--paper)" }}>
762
+ <header style={{ height: 44, minHeight: 44, display: "flex", alignItems: "center", justifyContent: "space-between", padding: "0 1rem", background: "var(--panel)", borderBottom: "1px solid var(--line)", fontSize: "0.85rem" }}>
763
+ <span style={{ fontWeight: 700, fontFamily: "Fraunces, serif" }}>{title}</span>
764
+ <a href="https://freegamestore.online" target="_blank" rel="noopener noreferrer" style={{ color: "var(--muted)", fontSize: "0.75rem", textDecoration: "none" }}>
765
+ FreeGameStore
766
+ </a>
767
+ </header>
768
+ <main style={{ flex: 1, overflow: "hidden", position: "relative" }}>
769
+ {children}
770
+ </main>
771
+ </div>
772
+ );
773
+ }`,
774
+ 'web/src/App.tsx': `import { GameShell } from "./components/GameShell";
775
+
776
+ export default function App() {
777
+ return (
778
+ <GameShell title={"APPNAME_JS"}>
779
+ <div style={{ display: "flex", alignItems: "center", justifyContent: "center", height: "100%", flexDirection: "column", gap: "1rem" }}>
780
+ <h1 style={{ fontFamily: "Fraunces, serif", fontSize: "2rem", margin: 0 }}>
781
+ APPNAME_TEXT
782
+ </h1>
783
+ <p style={{ color: "var(--muted)" }}>
784
+ Edit <code>src/App.tsx</code> to build your game.
785
+ </p>
786
+ </div>
787
+ </GameShell>
788
+ );
789
+ }`,
790
+ LICENSE: `MIT License
791
+
792
+ Copyright (c) 2025 FreeGameStore
793
+
794
+ Permission is hereby granted, free of charge, to any person obtaining a copy
795
+ of this software and associated documentation files (the "Software"), to deal
796
+ in the Software without restriction, including without limitation the rights
797
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
798
+ copies of the Software, and to permit persons to whom the Software is
799
+ furnished to do so, subject to the following conditions:
800
+
801
+ The above copyright notice and this permission notice shall be included in all
802
+ copies or substantial portions of the Software.
803
+
804
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
805
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
806
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
807
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
808
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
809
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
810
+ SOFTWARE.`,
811
+ };
812
+ // ── Deploy workflow (R2) ──
813
+ //
814
+ // Every agent-pushed repo carries this so GitHub Actions builds web/dist and
815
+ // syncs it to r2://<bucket>/<nounPlural>/<repo>/ — the prefix the host Worker
816
+ // (freeappstore-host / freegamestore-host) serves once the publish step writes
817
+ // the D1 routes row. Mirrors the proven template-standalone deploy.yml.
818
+ //
819
+ // Uses plain `pnpm install` (NOT --frozen-lockfile): the agent scaffold ships
820
+ // no lockfile. Org-level R2_* secrets (R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY /
821
+ // R2_ACCOUNT_ID) are inherited from the store org — public repos get them
822
+ // (console/notes already deploy this way). Contains no APPNAME placeholder.
823
+ function deployWorkflow(config) {
824
+ return `name: Deploy to R2
825
+
826
+ on:
827
+ push:
828
+ branches: [main]
829
+ workflow_dispatch:
830
+
831
+ concurrency:
832
+ group: deploy-\${{ github.repository }}
833
+ cancel-in-progress: true
834
+
835
+ jobs:
836
+ deploy:
837
+ if: \${{ !startsWith(github.event.repository.name, 'template-') }}
838
+ runs-on: ubuntu-latest
839
+ permissions:
840
+ contents: read
841
+ steps:
842
+ - uses: actions/checkout@v4
843
+ - uses: pnpm/action-setup@v4
844
+ - uses: actions/setup-node@v4
845
+ with:
846
+ node-version: 22
847
+ - name: Install
848
+ run: pnpm install --no-frozen-lockfile
849
+ ${config.store === 'apps'
850
+ ? ` - name: Resolve build target
851
+ id: target
852
+ run: npx @freeappstore/cli build-target --app-id "\${GITHUB_REPOSITORY##*/}" --github-output
853
+ - name: Build
854
+ env:
855
+ BUILD_COMMAND: \${{ steps.target.outputs.build-command }}
856
+ run: bash -e -c "$BUILD_COMMAND"
857
+ - name: Verify build output
858
+ run: npx @freeappstore/cli build-target --artifact --app-id "\${GITHUB_REPOSITORY##*/}"
859
+ `
860
+ : `\
861
+ - name: Build
862
+ run: pnpm build
863
+ - name: Verify build output
864
+ run: |
865
+ test -d ./web/dist || { echo "::error::No build output at web/dist"; exit 1; }
866
+ test -n "$(ls -A ./web/dist)" || { echo "::error::web/dist is empty"; exit 1; }
867
+ `}\
868
+ - name: Upload to R2
869
+ env:
870
+ ${config.store === 'apps' ? ` OUTPUT_PATH: \${{ steps.target.outputs.output-path }}\n` : ''}\
871
+ AWS_ACCESS_KEY_ID: \${{ secrets.R2_ACCESS_KEY_ID }}
872
+ AWS_SECRET_ACCESS_KEY: \${{ secrets.R2_SECRET_ACCESS_KEY }}
873
+ AWS_DEFAULT_REGION: auto
874
+ R2_ACCOUNT_ID: \${{ secrets.R2_ACCOUNT_ID }}
875
+ run: |
876
+ aws s3 sync ${config.store === 'apps' ? '"$OUTPUT_PATH"' : './web/dist'} "s3://${config.r2Bucket}/${config.nounPlural}/\${GITHUB_REPOSITORY##*/}/" \\
877
+ --endpoint-url "https://$R2_ACCOUNT_ID.r2.cloudflarestorage.com" \\
878
+ --delete \\
879
+ --no-progress
880
+ echo "Deployed ${config.nounPlural}/\${GITHUB_REPOSITORY##*/} from \${GITHUB_SHA::7} to R2"
881
+ `;
882
+ }
883
+ // ── Public API ──
884
+ const CONNECTED_DRAFT = `import { useEffect, useRef } from 'react';
885
+ import { useConnectedKvDraft } from '@freeappstore/sdk/hooks';
886
+ import { SignInButton } from '@freeappstore/sdk/ui';
887
+ import type { FreeAppStore } from '@freeappstore/sdk';
888
+ import { pwa } from '../fas-capabilities/pwa';
889
+
890
+ /** Keep the sign-in gate on this private-data feature, not on public app screens. */
891
+ export function ConnectedDraft({ app: fas }: { app: FreeAppStore }) {
892
+ const draft = useConnectedKvDraft(fas, 'private-draft', '');
893
+ const busy = useRef(false);
894
+ busy.current = draft.dirty || draft.saving;
895
+ useEffect(() => pwa.addBusyGuard(() => busy.current), []);
896
+
897
+ if (!draft.user) {
898
+ return (
899
+ <section aria-labelledby="draft-title">
900
+ <h2 id="draft-title">Private draft</h2>
901
+ <p>Sign in to load or save your private draft. Public parts of the app remain available.</p>
902
+ <SignInButton app={fas} />
903
+ </section>
904
+ );
905
+ }
906
+
907
+ return (
908
+ <section aria-labelledby="draft-title">
909
+ <h2 id="draft-title">Private draft</h2>
910
+ {draft.loading ? <p role="status">Loading your draft…</p> : null}
911
+ {draft.error ? (
912
+ <p role="alert">
913
+ {draft.error}{' '}
914
+ <button type="button" onClick={draft.retry}>
915
+ Retry
916
+ </button>
917
+ </p>
918
+ ) : null}
919
+ <label htmlFor="private-draft">Your notes</label>
920
+ <textarea
921
+ id="private-draft"
922
+ style={{ display: 'block', boxSizing: 'border-box', width: '100%', minWidth: 0, maxWidth: '100%', resize: 'vertical' }}
923
+ value={draft.draft}
924
+ onChange={(event) => draft.setDraft(event.currentTarget.value)}
925
+ />
926
+ <button
927
+ type="button"
928
+ disabled={!draft.dirty || draft.saving}
929
+ onClick={() => void draft.save()}
930
+ >
931
+ {draft.saving ? 'Saving…' : 'Save'}
932
+ </button>
933
+ {draft.dirty ? <span>Unsaved changes</span> : null}
934
+ </section>
935
+ );
936
+ }
937
+ `;
938
+ export function getArchetypeFiles(archetype) {
939
+ return APP_ARCHETYPE_FILES[archetype];
940
+ }
941
+ export function getTemplateFiles(config, archetype, preset = 'standalone') {
942
+ const appArchetypeFiles = config.store === 'games' ? {} : getArchetypeFiles(archetype ?? 'generic');
943
+ const capabilities = config.store === 'apps' ? resolveStarterPreset(preset) : [];
944
+ const foundationFiles = { ...SHARED_FILES, ...APP_FILES };
945
+ const capabilityPlan = planCapabilityChanges(capabilities, foundationFiles, {}, () => false);
946
+ const capabilityFiles = capabilityPlan.writes;
947
+ const files = {
948
+ ...SHARED_FILES,
949
+ ...(config.store === 'games' ? GAME_FILES : APP_FILES),
950
+ ...(config.store === 'apps'
951
+ ? {
952
+ 'web/package.json': SHARED_FILES['web/package.json'].replace('"vite": "^6"', '"vite": "^6",\n "vite-plugin-pwa": "^1.0"'),
953
+ 'web/vite.config.ts': `import { defineConfig } from 'vite';
954
+ import react from '@vitejs/plugin-react';
955
+ import tailwindcss from '@tailwindcss/vite';
956
+ import { VitePWA } from 'vite-plugin-pwa';
957
+ import { pwaOptions } from '@freeappstore/sdk/pwa-config';
958
+ export default defineConfig({ plugins: [react(), tailwindcss(), VitePWA(pwaOptions())] });`,
959
+ 'web/src/pwa.ts': `// Compatibility path: the canonical app-owned controller lives in fas-capabilities/pwa.ts.
960
+ export { pwa } from './fas-capabilities/pwa';
961
+ `,
962
+ 'web/src/main.tsx': `import './fas-capabilities/pwa';\n${SHARED_FILES['web/src/main.tsx']}`,
963
+ 'web/public/icon.svg': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><rect width="512" height="512" rx="64" fill="#2563eb"/><path d="M160 160h192v48H208v48h120v48H208v48h-48z" fill="white"/></svg>`,
964
+ 'web/public/manifest.json': JSON.stringify({
965
+ ...JSON.parse(APP_FILES['web/public/manifest.json']),
966
+ id: '/',
967
+ scope: '/',
968
+ min_viewport_width: 320,
969
+ icons: [
970
+ { src: '/icon.svg', sizes: 'any', type: 'image/svg+xml', purpose: 'any maskable' },
971
+ ],
972
+ }, null, 2),
973
+ 'web/index.html': APP_FILES['web/index.html'].replace('initial-scale=1.0', 'initial-scale=1.0, viewport-fit=cover'),
974
+ 'web/src/index.css': `${APP_FILES['web/src/index.css']}
975
+ html { overflow-wrap: anywhere; }
976
+ body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
977
+ img, video, canvas { max-width: 100%; }
978
+ `,
979
+ 'fas.json': JSON.stringify({
980
+ appId: 'APPID',
981
+ applicationRoot: 'web',
982
+ outputPath: 'web/dist',
983
+ buildCommand: 'pnpm build',
984
+ }, null, 2),
985
+ ...capabilityFiles,
986
+ }
987
+ : {}),
988
+ ...appArchetypeFiles,
989
+ '.github/workflows/deploy.yml': deployWorkflow(config),
990
+ };
991
+ if (config.store === 'apps') {
992
+ const appPackage = JSON.parse(files['package.json']);
993
+ appPackage.scripts.test = 'pnpm --filter @APPNAME/web test';
994
+ files['package.json'] = JSON.stringify(appPackage, null, 2);
995
+ }
996
+ if (config.store === 'apps' && preset === 'connected') {
997
+ files['web/src/App.tsx'] = files['web/src/App.tsx'].replace('import { initApp }', 'import { ConnectedDraft } from "./components/ConnectedDraft";\nimport { initApp }').replace(' return <PageHeader title={"Welcome to APPNAME_JS"} description="Edit web/src/App.tsx to get started." />;', ' return <><PageHeader title={"Welcome to APPNAME_JS"} description="Editable app-owned starter screen." /><ConnectedDraft app={fas} /></>;');
998
+ files['web/src/components/ConnectedDraft.tsx'] = CONNECTED_DRAFT;
999
+ }
1000
+ return files;
1001
+ }
1002
+ export function substituteAppName(files, appId, displayName) {
1003
+ const out = {};
1004
+ for (const [path, content] of Object.entries(files)) {
1005
+ const packagePath = path === 'package.json' || path === 'web/package.json';
1006
+ const replacementForPath = path.endsWith('.json')
1007
+ ? escapeJsonString(displayName)
1008
+ : path.endsWith('.html')
1009
+ ? escapeHtml(displayName)
1010
+ : displayName;
1011
+ out[path] = content.replace(/APPNAME_JS|APPNAME_TEXT|APPNAME|APPID/g, (token) => {
1012
+ if (token === 'APPID')
1013
+ return appId;
1014
+ if (token === 'APPNAME_JS')
1015
+ return escapeJavaScriptString(displayName);
1016
+ if (token === 'APPNAME_TEXT')
1017
+ return escapeJsxText(displayName);
1018
+ if (packagePath || path === 'pnpm-workspace.yaml')
1019
+ return appId;
1020
+ return replacementForPath;
1021
+ });
1022
+ }
1023
+ return out;
1024
+ }
1025
+ function escapeJavaScriptString(value) {
1026
+ return [...value]
1027
+ .map((char) => {
1028
+ const escapes = {
1029
+ '\\': '\\\\',
1030
+ '"': '\\"',
1031
+ '\n': '\\n',
1032
+ '\r': '\\r',
1033
+ '\t': '\\t',
1034
+ '\b': '\\b',
1035
+ '\f': '\\f',
1036
+ };
1037
+ if (escapes[char])
1038
+ return escapes[char];
1039
+ const codePoint = char.codePointAt(0);
1040
+ if (codePoint < 0x20 || codePoint === 0x2028 || codePoint === 0x2029) {
1041
+ return `\\u${codePoint.toString(16).padStart(4, '0')}`;
1042
+ }
1043
+ return char;
1044
+ })
1045
+ .join('');
1046
+ }
1047
+ function escapeJsonString(value) {
1048
+ return JSON.stringify(value).slice(1, -1);
1049
+ }
1050
+ function escapeHtml(value) {
1051
+ return value.replace(/[&<>"']/g, (char) => {
1052
+ const entities = {
1053
+ '&': '&amp;',
1054
+ '<': '&lt;',
1055
+ '>': '&gt;',
1056
+ '"': '&quot;',
1057
+ "'": '&#39;',
1058
+ };
1059
+ return entities[char];
1060
+ });
1061
+ }
1062
+ function escapeJsxText(value) {
1063
+ return escapeHtml(value).replace(/\{/g, '&#123;').replace(/\}/g, '&#125;');
1064
+ }
1065
+ //# sourceMappingURL=starter-foundation.js.map