anhedral 0.13.0 → 0.16.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.
- package/README.md +23 -229
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +39 -0
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +86 -0
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +44 -0
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +15 -0
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +28 -0
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -84
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +40 -374
- package/dist/dependencies.d.ts +34 -62
- package/dist/dependencies.js +112 -199
- package/dist/index.d.ts +1 -45
- package/dist/index.js +1 -30
- package/dist/platforms/mobile.js +29 -139
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +251 -0
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -83
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +6 -40
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +18 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +3 -9
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -189
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +19 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +82 -84
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +9 -101
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +74 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/workspace.js +63 -199
- package/dist/stack-registry.d.ts +2 -58
- package/dist/stack-registry.js +22 -446
- package/dist/standard.js +7 -24
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -119
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -577
- package/docs/stack-standard.md +11 -307
- package/docs/ui.md +33 -0
- package/docs/verification.md +511 -0
- package/package.json +26 -27
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -168
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -172
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -186
- package/dist/delivery.d.ts +0 -88
- package/dist/delivery.js +0 -570
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -13
- package/dist/integration-service-readers.js +0 -173
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -366
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -702
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -49
- package/dist/project-state.js +0 -563
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -215
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -104
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -278
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -182
- package/dist/providers/definitions.d.ts +0 -318
- package/dist/providers/definitions.js +0 -127
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -66
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -112
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -265
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -289
- package/dist/provision.d.ts +0 -55
- package/dist/provision.js +0 -284
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -122
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -270
- package/dist/registry/bootstrap.d.ts +0 -2
- package/dist/registry/bootstrap.js +0 -14
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -85
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -3
- package/dist/scaffold/auth.js +0 -151
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -216
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -192
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -292
- package/dist/scaffold/integrations.d.ts +0 -4
- package/dist/scaffold/integrations.js +0 -12
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -78
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -78
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -247
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -102
- package/dist/ship.d.ts +0 -348
- package/dist/ship.js +0 -239
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { writeReactLintConfig } from './lint.js';
|
|
3
|
-
import { writeFile } from '../util.js';
|
|
4
|
-
import { DESKTOP_DEPENDENCIES } from '../dependencies.js';
|
|
5
|
-
import { childPackageName, htmlText, identifierSegment, jsString } from '../render.js';
|
|
6
|
-
export async function scaffoldElectron({ root, options }) {
|
|
7
|
-
const projectName = options.name;
|
|
8
|
-
const displayName = options.name;
|
|
9
|
-
const dir = path.join(root, 'apps/desktop');
|
|
10
|
-
writePackageJson(dir, projectName);
|
|
11
|
-
writeReactLintConfig(dir);
|
|
12
|
-
writeTsConfig(dir);
|
|
13
|
-
writeViteConfig(dir);
|
|
14
|
-
writePostcssConfig(dir);
|
|
15
|
-
writeDevScript(dir);
|
|
16
|
-
writeShadcnConfig(dir);
|
|
17
|
-
writeEnvExample(dir);
|
|
18
|
-
writeSourceFiles(dir, displayName);
|
|
19
|
-
}
|
|
20
|
-
function writePackageJson(dir, projectName) {
|
|
21
|
-
writeFile(path.join(dir, 'package.json'), JSON.stringify({
|
|
22
|
-
name: childPackageName(projectName, 'desktop'),
|
|
23
|
-
version: '0.1.0',
|
|
24
|
-
private: true,
|
|
25
|
-
type: 'module',
|
|
26
|
-
main: 'dist/main/main.js',
|
|
27
|
-
scripts: {
|
|
28
|
-
dev: 'tsc -p tsconfig.main.json && node scripts/dev.mjs',
|
|
29
|
-
build: 'tsc --noEmit && tsc -p tsconfig.main.json && vite build',
|
|
30
|
-
typecheck: 'tsc --noEmit && tsc -p tsconfig.main.json --noEmit',
|
|
31
|
-
lint: 'eslint src --max-warnings 0',
|
|
32
|
-
'build:mac': 'pnpm build && electron-builder --mac',
|
|
33
|
-
'build:win': 'pnpm build && electron-builder --win',
|
|
34
|
-
'build:linux': 'pnpm build && electron-builder --linux',
|
|
35
|
-
package: 'pnpm build && electron-builder',
|
|
36
|
-
},
|
|
37
|
-
build: {
|
|
38
|
-
appId: `dev.anhedral.${identifierSegment(projectName)}`,
|
|
39
|
-
productName: projectName,
|
|
40
|
-
directories: {
|
|
41
|
-
output: 'release',
|
|
42
|
-
},
|
|
43
|
-
files: ['dist/**/*', 'package.json'],
|
|
44
|
-
mac: {
|
|
45
|
-
target: ['dmg', 'zip'],
|
|
46
|
-
},
|
|
47
|
-
win: {
|
|
48
|
-
target: ['nsis', 'zip'],
|
|
49
|
-
},
|
|
50
|
-
linux: {
|
|
51
|
-
executableName: identifierSegment(projectName),
|
|
52
|
-
target: ['AppImage', 'deb'],
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
dependencies: DESKTOP_DEPENDENCIES.dependencies,
|
|
56
|
-
devDependencies: {
|
|
57
|
-
...DESKTOP_DEPENDENCIES.devDependencies,
|
|
58
|
-
'@workspace/eslint-config': 'workspace:*',
|
|
59
|
-
},
|
|
60
|
-
}, null, 2) + '\n');
|
|
61
|
-
}
|
|
62
|
-
function writeTsConfig(dir) {
|
|
63
|
-
writeFile(path.join(dir, 'tsconfig.json'), JSON.stringify({
|
|
64
|
-
compilerOptions: {
|
|
65
|
-
target: 'ES2022',
|
|
66
|
-
lib: ['ES2022', 'DOM'],
|
|
67
|
-
module: 'ESNext',
|
|
68
|
-
moduleResolution: 'Bundler',
|
|
69
|
-
jsx: 'react-jsx',
|
|
70
|
-
strict: true,
|
|
71
|
-
skipLibCheck: true,
|
|
72
|
-
esModuleInterop: true,
|
|
73
|
-
noEmit: true,
|
|
74
|
-
types: ['node', 'vite/client'],
|
|
75
|
-
paths: { '@/*': ['./src/renderer/*'] },
|
|
76
|
-
},
|
|
77
|
-
include: ['src/renderer/**/*', 'vite.config.ts'],
|
|
78
|
-
}, null, 2) + '\n');
|
|
79
|
-
writeFile(path.join(dir, 'tsconfig.main.json'), JSON.stringify({
|
|
80
|
-
compilerOptions: {
|
|
81
|
-
target: 'ES2022',
|
|
82
|
-
module: 'NodeNext',
|
|
83
|
-
moduleResolution: 'NodeNext',
|
|
84
|
-
strict: true,
|
|
85
|
-
skipLibCheck: true,
|
|
86
|
-
esModuleInterop: true,
|
|
87
|
-
outDir: 'dist/main',
|
|
88
|
-
rootDir: 'src/main',
|
|
89
|
-
types: ['node'],
|
|
90
|
-
},
|
|
91
|
-
include: ['src/main/**/*'],
|
|
92
|
-
}, null, 2) + '\n');
|
|
93
|
-
}
|
|
94
|
-
function writeViteConfig(dir) {
|
|
95
|
-
writeFile(path.join(dir, 'vite.config.ts'), `import { defineConfig } from 'vite';
|
|
96
|
-
import react from '@vitejs/plugin-react';
|
|
97
|
-
import path from 'node:path';
|
|
98
|
-
|
|
99
|
-
export default defineConfig({
|
|
100
|
-
base: './',
|
|
101
|
-
plugins: [react()],
|
|
102
|
-
resolve: {
|
|
103
|
-
alias: {
|
|
104
|
-
'@': path.resolve(__dirname, 'src/renderer'),
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
build: {
|
|
108
|
-
outDir: 'dist/renderer',
|
|
109
|
-
emptyOutDir: true,
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
`);
|
|
113
|
-
}
|
|
114
|
-
function writePostcssConfig(dir) {
|
|
115
|
-
writeFile(path.join(dir, 'postcss.config.mjs'), `const config = {
|
|
116
|
-
plugins: {
|
|
117
|
-
'@tailwindcss/postcss': {},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export default config;
|
|
122
|
-
`);
|
|
123
|
-
}
|
|
124
|
-
function writeDevScript(dir) {
|
|
125
|
-
writeFile(path.join(dir, 'scripts/dev.mjs'), `import { spawn } from 'node:child_process';
|
|
126
|
-
import { once } from 'node:events';
|
|
127
|
-
|
|
128
|
-
const host = '127.0.0.1';
|
|
129
|
-
const port = '5173';
|
|
130
|
-
const devServerUrl = 'http://' + host + ':' + port;
|
|
131
|
-
const viteCommand = process.platform === 'win32' ? 'vite.cmd' : 'vite';
|
|
132
|
-
const electronCommand = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
|
133
|
-
|
|
134
|
-
function start(command, args, options = {}) {
|
|
135
|
-
const invocation = process.platform === 'win32'
|
|
136
|
-
? {
|
|
137
|
-
command: process.env.ComSpec || 'cmd.exe',
|
|
138
|
-
args: ['/d', '/s', '/c', 'call', command, ...args],
|
|
139
|
-
}
|
|
140
|
-
: { command, args };
|
|
141
|
-
return spawn(invocation.command, invocation.args, {
|
|
142
|
-
cwd: process.cwd(),
|
|
143
|
-
stdio: 'inherit',
|
|
144
|
-
...options,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function stop(child) {
|
|
149
|
-
if (child && child.exitCode === null && !child.killed) child.kill('SIGTERM');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async function isServerReady(url) {
|
|
153
|
-
try { return (await fetch(url)).ok; }
|
|
154
|
-
catch { return false; }
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async function waitForServer(server, url, timeoutMs = 30_000) {
|
|
158
|
-
const deadline = Date.now() + timeoutMs;
|
|
159
|
-
while (Date.now() < deadline) {
|
|
160
|
-
if (server.exitCode !== null) throw new Error('Vite exited before the dev server was ready.');
|
|
161
|
-
if (await isServerReady(url)) return;
|
|
162
|
-
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
163
|
-
}
|
|
164
|
-
throw new Error('Timed out waiting for Vite at ' + url + '.');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const vite = start(viteCommand, ['--host', host, '--port', port, '--strictPort']);
|
|
168
|
-
let electron;
|
|
169
|
-
let shuttingDown = false;
|
|
170
|
-
|
|
171
|
-
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
172
|
-
process.once(signal, () => {
|
|
173
|
-
shuttingDown = true;
|
|
174
|
-
stop(electron);
|
|
175
|
-
stop(vite);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
await waitForServer(vite, devServerUrl);
|
|
181
|
-
electron = start(electronCommand, ['.'], {
|
|
182
|
-
env: { ...process.env, VITE_DEV_SERVER_URL: devServerUrl },
|
|
183
|
-
});
|
|
184
|
-
vite.once('exit', (code) => {
|
|
185
|
-
if (!shuttingDown) {
|
|
186
|
-
console.error('Vite exited while Electron was running.');
|
|
187
|
-
process.exitCode = code ?? 1;
|
|
188
|
-
stop(electron);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
const [code] = await once(electron, 'exit');
|
|
192
|
-
if (process.exitCode === undefined) process.exitCode = typeof code === 'number' ? code : 1;
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.error(error instanceof Error ? error.message : error);
|
|
195
|
-
process.exitCode = 1;
|
|
196
|
-
} finally {
|
|
197
|
-
shuttingDown = true;
|
|
198
|
-
stop(electron);
|
|
199
|
-
stop(vite);
|
|
200
|
-
}
|
|
201
|
-
`);
|
|
202
|
-
}
|
|
203
|
-
function writeShadcnConfig(dir) {
|
|
204
|
-
writeFile(path.join(dir, 'components.json'), JSON.stringify({
|
|
205
|
-
$schema: 'https://ui.shadcn.com/schema.json',
|
|
206
|
-
style: 'new-york',
|
|
207
|
-
rsc: false,
|
|
208
|
-
tsx: true,
|
|
209
|
-
tailwind: {
|
|
210
|
-
config: '',
|
|
211
|
-
css: 'src/renderer/styles.css',
|
|
212
|
-
baseColor: 'neutral',
|
|
213
|
-
cssVariables: true,
|
|
214
|
-
prefix: '',
|
|
215
|
-
},
|
|
216
|
-
aliases: {
|
|
217
|
-
components: '@/components',
|
|
218
|
-
utils: '@/lib/utils',
|
|
219
|
-
ui: '@/components/ui',
|
|
220
|
-
lib: '@/lib',
|
|
221
|
-
hooks: '@/hooks',
|
|
222
|
-
},
|
|
223
|
-
iconLibrary: 'lucide',
|
|
224
|
-
}, null, 2) + '\n');
|
|
225
|
-
}
|
|
226
|
-
function writeEnvExample(dir) {
|
|
227
|
-
writeFile(path.join(dir, '.env.example'), '');
|
|
228
|
-
}
|
|
229
|
-
function writeSourceFiles(dir, displayName) {
|
|
230
|
-
const displayNameLiteral = jsString(displayName);
|
|
231
|
-
const displayNameHtml = htmlText(displayName);
|
|
232
|
-
writeFile(path.join(dir, 'src/main/app-window.ts'), `import { BrowserWindow, shell } from 'electron';
|
|
233
|
-
import path from 'node:path';
|
|
234
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
235
|
-
|
|
236
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
237
|
-
const rendererIndex = path.join(__dirname, '../renderer/index.html');
|
|
238
|
-
|
|
239
|
-
function isSafeExternalUrl(value: string): boolean {
|
|
240
|
-
try {
|
|
241
|
-
const url = new URL(value);
|
|
242
|
-
return url.protocol === 'https:' && !url.username && !url.password;
|
|
243
|
-
} catch {
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function isAllowedAppNavigation(value: string): boolean {
|
|
249
|
-
try {
|
|
250
|
-
const target = new URL(value);
|
|
251
|
-
if (process.env.VITE_DEV_SERVER_URL) {
|
|
252
|
-
return target.origin === new URL(process.env.VITE_DEV_SERVER_URL).origin;
|
|
253
|
-
}
|
|
254
|
-
return target.href === pathToFileURL(rendererIndex).href;
|
|
255
|
-
} catch {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Product-owned window options and navigation policy belong in this file.
|
|
261
|
-
// main.ts imports this seam and manages application lifecycle.
|
|
262
|
-
export function createAppWindow(): BrowserWindow {
|
|
263
|
-
const window = new BrowserWindow({
|
|
264
|
-
width: 1180,
|
|
265
|
-
height: 760,
|
|
266
|
-
minWidth: 860,
|
|
267
|
-
minHeight: 560,
|
|
268
|
-
title: ${displayNameLiteral},
|
|
269
|
-
webPreferences: {
|
|
270
|
-
preload: path.join(__dirname, 'preload.cjs'),
|
|
271
|
-
contextIsolation: true,
|
|
272
|
-
nodeIntegration: false,
|
|
273
|
-
sandbox: true,
|
|
274
|
-
webSecurity: true,
|
|
275
|
-
},
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
window.webContents.on('will-navigate', (event, url) => {
|
|
279
|
-
if (!isAllowedAppNavigation(url)) event.preventDefault();
|
|
280
|
-
});
|
|
281
|
-
window.webContents.setWindowOpenHandler(({ url }) => {
|
|
282
|
-
if (isSafeExternalUrl(url)) {
|
|
283
|
-
void shell.openExternal(url).catch((error) => {
|
|
284
|
-
console.error('Unable to open external URL:', error);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
return { action: 'deny' };
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
if (process.env.VITE_DEV_SERVER_URL) {
|
|
291
|
-
void window.loadURL(process.env.VITE_DEV_SERVER_URL).catch((error) => {
|
|
292
|
-
console.error('Unable to load the development renderer:', error);
|
|
293
|
-
});
|
|
294
|
-
} else {
|
|
295
|
-
void window.loadFile(rendererIndex).catch((error) => {
|
|
296
|
-
console.error('Unable to load the packaged renderer:', error);
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return window;
|
|
301
|
-
}
|
|
302
|
-
`);
|
|
303
|
-
writeFile(path.join(dir, 'src/main/main.ts'), `import { app, BrowserWindow, session } from 'electron';
|
|
304
|
-
import { createAppWindow } from './app-window.js';
|
|
305
|
-
|
|
306
|
-
app.whenReady().then(() => {
|
|
307
|
-
session.defaultSession.setPermissionCheckHandler(() => false);
|
|
308
|
-
session.defaultSession.setPermissionRequestHandler((_webContents, _permission, callback) => callback(false));
|
|
309
|
-
createAppWindow();
|
|
310
|
-
}).catch((error) => {
|
|
311
|
-
console.error('Unable to start the desktop app:', error);
|
|
312
|
-
app.quit();
|
|
313
|
-
});
|
|
314
|
-
app.on('window-all-closed', () => {
|
|
315
|
-
if (process.platform !== 'darwin') app.quit();
|
|
316
|
-
});
|
|
317
|
-
app.on('activate', () => {
|
|
318
|
-
if (BrowserWindow.getAllWindows().length === 0) createAppWindow();
|
|
319
|
-
});
|
|
320
|
-
`);
|
|
321
|
-
writeFile(path.join(dir, 'src/main/preload.cts'), `import { contextBridge } from 'electron';
|
|
322
|
-
|
|
323
|
-
contextBridge.exposeInMainWorld('anhedral', {
|
|
324
|
-
platform: process.platform,
|
|
325
|
-
});
|
|
326
|
-
`);
|
|
327
|
-
writeFile(path.join(dir, 'index.html'), `<!doctype html>
|
|
328
|
-
<html lang="en">
|
|
329
|
-
<head>
|
|
330
|
-
<meta charset="UTF-8" />
|
|
331
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
332
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; base-uri 'none'; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' https: ws://127.0.0.1:* wss:; img-src 'self' data: https:; font-src 'self' data: https:; frame-src https:; form-action 'self' https:" />
|
|
333
|
-
<title>${displayNameHtml}</title>
|
|
334
|
-
</head>
|
|
335
|
-
<body>
|
|
336
|
-
<div id="root"></div>
|
|
337
|
-
<script type="module" src="/src/renderer/main.tsx"></script>
|
|
338
|
-
</body>
|
|
339
|
-
</html>
|
|
340
|
-
`);
|
|
341
|
-
writeFile(path.join(dir, 'src/renderer/lib/utils.ts'), `import { clsx, type ClassValue } from 'clsx';
|
|
342
|
-
import { twMerge } from 'tailwind-merge';
|
|
343
|
-
|
|
344
|
-
export function cn(...inputs: ClassValue[]) {
|
|
345
|
-
return twMerge(clsx(inputs));
|
|
346
|
-
}
|
|
347
|
-
`);
|
|
348
|
-
writeFile(path.join(dir, 'src/renderer/components/ui/button.tsx'), `import * as React from 'react';
|
|
349
|
-
import { cn } from '@/lib/utils';
|
|
350
|
-
|
|
351
|
-
export function Button({ className, type = 'button', ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) {
|
|
352
|
-
return (
|
|
353
|
-
<button
|
|
354
|
-
type={type}
|
|
355
|
-
className={cn('inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50', className)}
|
|
356
|
-
{...props}
|
|
357
|
-
/>
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
`);
|
|
361
|
-
writeFile(path.join(dir, 'src/renderer/main.tsx'), `import React from 'react';
|
|
362
|
-
import ReactDOM from 'react-dom/client';
|
|
363
|
-
import { Button } from '@/components/ui/button';
|
|
364
|
-
import './styles.css';
|
|
365
|
-
|
|
366
|
-
function App() {
|
|
367
|
-
return (
|
|
368
|
-
<main className="flex min-h-screen flex-col gap-6 bg-background p-8 text-foreground">
|
|
369
|
-
<section className="flex flex-col gap-3">
|
|
370
|
-
<h1 className="text-3xl font-semibold">{${displayNameLiteral}}</h1>
|
|
371
|
-
<p className="max-w-2xl text-muted-foreground">
|
|
372
|
-
${'Electron + shadcn/ui desktop client ready for your application.'}
|
|
373
|
-
</p>
|
|
374
|
-
</section>
|
|
375
|
-
<Button className="self-start" onClick={() => window.location.reload()}>Reload</Button>
|
|
376
|
-
</main>
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
381
|
-
<React.StrictMode>
|
|
382
|
-
<App />
|
|
383
|
-
</React.StrictMode>,
|
|
384
|
-
);
|
|
385
|
-
`);
|
|
386
|
-
writeFile(path.join(dir, 'src/renderer/styles.css'), `@import "tailwindcss";
|
|
387
|
-
|
|
388
|
-
:root {
|
|
389
|
-
--background: oklch(1 0 0);
|
|
390
|
-
--foreground: oklch(0.145 0 0);
|
|
391
|
-
--primary: oklch(0.205 0 0);
|
|
392
|
-
--primary-foreground: oklch(0.985 0 0);
|
|
393
|
-
--muted-foreground: oklch(0.556 0 0);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
@theme inline {
|
|
397
|
-
--color-background: var(--background);
|
|
398
|
-
--color-foreground: var(--foreground);
|
|
399
|
-
--color-primary: var(--primary);
|
|
400
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
401
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
body {
|
|
405
|
-
margin: 0;
|
|
406
|
-
background: var(--background);
|
|
407
|
-
color: var(--foreground);
|
|
408
|
-
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
button {
|
|
412
|
-
border: 0;
|
|
413
|
-
}
|
|
414
|
-
`);
|
|
415
|
-
}
|