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
package/dist/scaffold/stream.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { patchPackage, put, sharedPackage } from './files.js';
|
|
4
|
-
import { writeEnvironmentFile } from './environment.js';
|
|
5
|
-
export function scaffoldStream({ root, options, runtimeApp }) {
|
|
6
|
-
sharedPackage(root, 'stream', '', {});
|
|
7
|
-
rmSync(path.join(root, 'packages/stream/src/index.ts'));
|
|
8
|
-
patchPackage(root, 'packages/stream/package.json', {
|
|
9
|
-
exports: { './server': './src/server.ts' },
|
|
10
|
-
});
|
|
11
|
-
put(root, 'packages/stream/src/server.ts', streamServer);
|
|
12
|
-
put(root, 'packages/stream/README.md', streamGuide);
|
|
13
|
-
const app = `apps/${runtimeApp}`;
|
|
14
|
-
const native = runtimeApp === 'web' && options.hosting === 'vercel';
|
|
15
|
-
writeEnvironmentFile(root, `${app}/${native ? '.env.example' : '.dev.vars.example'}`, {
|
|
16
|
-
STREAM_ACCOUNT_ID: '',
|
|
17
|
-
STREAM_API_TOKEN: '',
|
|
18
|
-
});
|
|
19
|
-
if (!native)
|
|
20
|
-
put(root, `${app}/${runtimeApp === 'api' ? 'src/' : ''}stream-secrets.d.ts`, runtimeApp === 'api'
|
|
21
|
-
? 'interface Env { STREAM_ACCOUNT_ID: string; STREAM_API_TOKEN: string }\n'
|
|
22
|
-
: 'declare namespace Cloudflare { interface Env { STREAM_ACCOUNT_ID: string; STREAM_API_TOKEN: string } }\n');
|
|
23
|
-
}
|
|
24
|
-
const streamServer = `// Server code only. Never serialize a live input directly to viewers: it contains a publish credential.
|
|
25
|
-
export interface StreamLiveInput {
|
|
26
|
-
uid: string;
|
|
27
|
-
webRTC: { url: string };
|
|
28
|
-
webRTCPlayback: { url: string };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function readString(value: unknown): string {
|
|
32
|
-
if (typeof value !== 'string') throw new Error('Stream did not return a WebRTC live input.');
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function readEndpoint(endpoint?: { url?: unknown } | null): { url: string } {
|
|
37
|
-
return { url: readString(endpoint?.url) };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function readLiveInput(body: { success?: boolean; result?: Partial<StreamLiveInput> } | null): StreamLiveInput {
|
|
41
|
-
if (body?.success !== true) throw new Error('Stream live input request was unsuccessful.');
|
|
42
|
-
const input = body.result ?? {};
|
|
43
|
-
return { uid: readString(input.uid), webRTC: readEndpoint(input.webRTC), webRTCPlayback: readEndpoint(input.webRTCPlayback) };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function createStream(options: { accountId: string; apiToken: string }) {
|
|
47
|
-
if (!/^[a-f0-9]{32}$/i.test(options.accountId) || !options.apiToken.trim()) {
|
|
48
|
-
throw new Error('Configure server-only STREAM_ACCOUNT_ID and STREAM_API_TOKEN.');
|
|
49
|
-
}
|
|
50
|
-
const base = 'https://api.cloudflare.com/client/v4/accounts/' + options.accountId + '/stream/live_inputs';
|
|
51
|
-
async function request(url: string, init: RequestInit): Promise<StreamLiveInput> {
|
|
52
|
-
const response = await fetch(url, {
|
|
53
|
-
...init,
|
|
54
|
-
headers: { Authorization: 'Bearer ' + options.apiToken, 'Content-Type': 'application/json' },
|
|
55
|
-
redirect: 'error',
|
|
56
|
-
signal: AbortSignal.timeout(30_000),
|
|
57
|
-
});
|
|
58
|
-
// Do not include provider bodies or URLs in errors: they can contain broadcast credentials.
|
|
59
|
-
if (!response.ok) throw new Error('Stream live input request failed (HTTP ' + response.status + ').');
|
|
60
|
-
const body = await response.json().catch(() => {
|
|
61
|
-
throw new Error('Stream returned an invalid JSON response.');
|
|
62
|
-
}) as { success?: boolean; result?: Partial<StreamLiveInput> } | null;
|
|
63
|
-
return readLiveInput(body);
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
// Call only after creator authorization and quota checks. Persist uid; do not create on every page load.
|
|
67
|
-
// Select playback privacy explicitly. Signed playback still needs application token issuance.
|
|
68
|
-
createLiveInput(input: { name: string; requireSignedURLs: boolean }) {
|
|
69
|
-
if (!input.name.trim() || typeof input.requireSignedURLs !== 'boolean') {
|
|
70
|
-
throw new Error('Supply a stream name and explicit signed-playback policy.');
|
|
71
|
-
}
|
|
72
|
-
return request(base, { method: 'POST', body: JSON.stringify({
|
|
73
|
-
meta: { name: input.name }, recording: { mode: 'off', requireSignedURLs: input.requireSignedURLs },
|
|
74
|
-
}) });
|
|
75
|
-
},
|
|
76
|
-
getLiveInput(uid: string) {
|
|
77
|
-
if (!/^[a-f0-9]{32}$/i.test(uid)) throw new Error('Invalid Stream live input ID.');
|
|
78
|
-
return request(base + '/' + uid, { method: 'GET' });
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
`;
|
|
83
|
-
const streamGuide = `# Cloudflare Stream Live WebRTC
|
|
84
|
-
|
|
85
|
-
Optional one-to-many live video using WHIP ingest and WHEP playback. GA since October 15, 2026. This is independent of --realtime Durable Object messaging and --neon-realtime live SQL. For many-to-many calls, review Cloudflare Realtime separately; this package does not scaffold conferencing.
|
|
86
|
-
|
|
87
|
-
## Server integration
|
|
88
|
-
|
|
89
|
-
Add @workspace/stream as a workspace:* dependency of the server app and import createStream from @workspace/stream/server. Pass { accountId: env.STREAM_ACCOUNT_ID, apiToken: env.STREAM_API_TOKEN }. The factory supports createLiveInput({ name, requireSignedURLs }) and getLiveInput(uid). It returns uid, webRTC.url (secret WHIP ingest) and webRTCPlayback.url (WHEP playback). No browser management client or public management route is generated.
|
|
90
|
-
|
|
91
|
-
Use a customer-owned account with Stream enabled and an account-scoped Stream Write API token. Configure the selected server app's ignored runtime file from its environment example (.env for Void, .dev.vars for Wrangler, .env.local for native Next.js). The root .env.example is an inventory. Configure production secrets explicitly with the selected host; anhedral ship does not activate Stream, create live inputs or install these runtime credentials automatically. There is no Wrangler resource binding for this integration. Never use a public environment prefix for the management token or publish URL.
|
|
92
|
-
|
|
93
|
-
Authorize creators and enforce quotas before creating/retrieving an input. Persist its uid with the owning user/tenant; authorize access before calling getLiveInput. Reuse the input on refresh; reconcile uncertain creates rather than blindly retrying. Return the WHIP URL only to its authorized broadcaster, with Cache-Control: no-store. Anyone possessing it can broadcast. Never return the full input to viewers or put it in logs, committed config, static assets or public build variables. Rotate compromised publish keys through Cloudflare's supported management workflow.
|
|
94
|
-
|
|
95
|
-
Select requireSignedURLs explicitly. For private viewing implement authenticated, short-lived Stream playback token issuance and verify WHEP rejects unsigned, expired and unauthorized access. Hosting protection alone does not protect Cloudflare's media endpoints. Origin restrictions are not user authorization. The helper does not issue playback tokens or establish private media acceptance.
|
|
96
|
-
|
|
97
|
-
## Browser integration
|
|
98
|
-
|
|
99
|
-
Use native RTCPeerConnection or a Cloudflare-supported WHIP/WHEP client. Follow the official browser tutorial below. Capture camera/microphone only after a user action over HTTPS or localhost; handle denied permissions, device selection and autoplay restrictions. Publish send-only tracks to the authorized WHIP URL; receive audio/video tracks through WHEP. Media flows directly between the browser and Stream, not through a Worker, Durable Object or database. Application routes handle identity, input ownership and authorized endpoint/token issuance.
|
|
100
|
-
|
|
101
|
-
Implement ICE negotiation (including gathering completion or Trickle ICE), failed-connection recovery and bounded retries. Retain the Location session resource from signaling, DELETE it on stop, close RTCPeerConnection and stop local camera/microphone tracks on failure, navigation and sign-out. Implement the player and creator UI for the product; this package is a management foundation, not a finished broadcast feature.
|
|
102
|
-
|
|
103
|
-
## Limits and acceptance
|
|
104
|
-
|
|
105
|
-
As reviewed October 16, 2026, WHIP ingest and WHEP playback must be paired. Recording, HLS/DASH playback of WHIP inputs, RTMP/SRT-to-WHEP bridging, restreaming and live viewer counts are unsupported. WebRTC usage appears in Stream analytics/billable usage; this does not promise broadcast or player-experience metrics. Delivery billing began October 15 at standard Stream rates; budget viewer-minutes (viewers multiplied by watch time), verify current pricing and account eligibility before activation.
|
|
106
|
-
|
|
107
|
-
Before claiming acceptance, exercise an authorized creator and viewer in separate browsers, denied creator/viewer access, cross-tenant input access, reconnect, camera denial, session teardown and usage visibility. Verify signed playback separately when selected. Scaffolding and local tests do not establish live video, latency or provider readiness.
|
|
108
|
-
|
|
109
|
-
- Release: https://developers.cloudflare.com/changelog/post/2026-10-15-stream-live-webrtc-ga/
|
|
110
|
-
- WebRTC and current limits: https://developers.cloudflare.com/stream/webrtc-beta/
|
|
111
|
-
- Browser tutorial: https://developers.cloudflare.com/stream/examples/browser-based-webrtc/
|
|
112
|
-
- Live input API: https://developers.cloudflare.com/api/resources/stream/subresources/live_inputs/methods/create/
|
|
113
|
-
- Pricing: https://developers.cloudflare.com/stream/pricing/
|
|
114
|
-
`;
|
package/dist/scaffold/void.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Fresh-workspace conversion only. Existing applications keep their delivery engine. */
|
|
2
|
-
export declare function configureVoidDelivery(root: string): boolean;
|
|
3
|
-
/** Extend server declarations after transactional additions without evaluating config. */
|
|
4
|
-
export declare function refreshVoidEnvironment(root: string): void;
|
package/dist/scaffold/void.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { VOID_NODE_ENGINE, VOID_VERSION } from '../void.js';
|
|
4
|
-
import { VINEXT_DEPENDENCIES, WORKER_DEV_PORTS } from '../dependencies.js';
|
|
5
|
-
import { VINEXT_SERVER_OUTPUT_PLUGIN } from '../vinext.js';
|
|
6
|
-
import { json, patchPackage, put, readJson } from './files.js';
|
|
7
|
-
/** Keep Void's adapter paired with the Wrangler version validated by this stack. */
|
|
8
|
-
function pinVoidCloudflareAdapter(root) {
|
|
9
|
-
const pkg = readJson(root, 'package.json');
|
|
10
|
-
const pnpm = (pkg.pnpm ?? {});
|
|
11
|
-
patchPackage(root, 'package.json', {
|
|
12
|
-
pnpm: {
|
|
13
|
-
...pnpm,
|
|
14
|
-
overrides: {
|
|
15
|
-
...(pnpm.overrides ?? {}),
|
|
16
|
-
[`void@${VOID_VERSION}>@cloudflare/vite-plugin`]: VINEXT_DEPENDENCIES.devDependencies['@cloudflare/vite-plugin'],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/** Fresh-workspace conversion only. Existing applications keep their delivery engine. */
|
|
22
|
-
export function configureVoidDelivery(root) {
|
|
23
|
-
if (existsSync(path.join(root, 'apps/web/open-next.config.ts')) ||
|
|
24
|
-
existsSync(path.join(root, 'apps/mobile/worker/index.ts')))
|
|
25
|
-
return false;
|
|
26
|
-
for (const app of readdirSync(path.join(root, 'apps'))) {
|
|
27
|
-
const file = path.join(root, 'apps', app, 'wrangler.jsonc');
|
|
28
|
-
if (!existsSync(file))
|
|
29
|
-
continue;
|
|
30
|
-
const config = readJson(root, `apps/${app}/wrangler.jsonc`);
|
|
31
|
-
if (config.queues || config.pipelines || config.images || config.analytics_engine_datasets)
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
let configured = false;
|
|
35
|
-
for (const app of readdirSync(path.join(root, 'apps'))) {
|
|
36
|
-
const directory = `apps/${app}`;
|
|
37
|
-
const source = path.join(root, directory, 'wrangler.jsonc');
|
|
38
|
-
// OpenNext remains an explicit legacy recipe until its adapter is supported.
|
|
39
|
-
if (!existsSync(source) || existsSync(path.join(root, directory, 'open-next.config.ts')))
|
|
40
|
-
continue;
|
|
41
|
-
const cloudflare = readJson(root, `${directory}/wrangler.jsonc`);
|
|
42
|
-
delete cloudflare.$schema;
|
|
43
|
-
if (app !== 'web') {
|
|
44
|
-
cloudflare.main = 'src/void-entry.ts';
|
|
45
|
-
cloudflare.version_metadata = { binding: '__VOID_VERSION_METADATA' };
|
|
46
|
-
}
|
|
47
|
-
json(root, `${directory}/anhedral.cloudflare.json`, cloudflare);
|
|
48
|
-
rmSync(source);
|
|
49
|
-
put(root, `${directory}/void.config.ts`, `// Platform tooling requires this per-app declaration; resource bindings remain app-specific.
|
|
50
|
-
// fallow-ignore-file code-duplication
|
|
51
|
-
import { defineConfig } from 'void/config';
|
|
52
|
-
import declared from './anhedral.cloudflare.json';
|
|
53
|
-
|
|
54
|
-
// Unassigned placeholders are not provider identities. Void records real IDs
|
|
55
|
-
// in its lock, while Anhedral retains the declarative resource names.
|
|
56
|
-
const cloudflare = JSON.parse(JSON.stringify(declared, (key, value) =>
|
|
57
|
-
key === 'anhedral_name' || (typeof value === 'string' && value.startsWith('REPLACE_WITH_')) ? undefined : value,
|
|
58
|
-
));
|
|
59
|
-
|
|
60
|
-
// Enable only registry-declared capabilities with their exact binding names.
|
|
61
|
-
// Capability additions update this declaration without scanning other packages.
|
|
62
|
-
// Shared packages receive bindings through factories.
|
|
63
|
-
export default defineConfig({
|
|
64
|
-
target: 'cloudflare',
|
|
65
|
-
inference: {
|
|
66
|
-
appType: '${app === 'web' ? 'framework' : 'void'}',
|
|
67
|
-
scanDirs: ['src', 'app', 'lib'],
|
|
68
|
-
bindings: {
|
|
69
|
-
db: cloudflare.d1_databases?.[0]?.binding ?? false,
|
|
70
|
-
kv: cloudflare.kv_namespaces?.[0]?.binding ?? false,
|
|
71
|
-
storage: cloudflare.r2_buckets?.[0]?.binding ?? false,
|
|
72
|
-
ai: cloudflare.ai?.binding ?? false,
|
|
73
|
-
email: false,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
cloudflare,
|
|
77
|
-
});
|
|
78
|
-
`);
|
|
79
|
-
const envKeys = new Map();
|
|
80
|
-
for (const filename of ['.dev.vars.example', '.env.example']) {
|
|
81
|
-
const file = path.join(root, directory, filename);
|
|
82
|
-
if (!existsSync(file))
|
|
83
|
-
continue;
|
|
84
|
-
for (const match of readFileSync(file, 'utf8').matchAll(/^([A-Z][A-Z0-9_]*)=(.*)$/gm))
|
|
85
|
-
envKeys.set(match[1], match[2]);
|
|
86
|
-
rmSync(file);
|
|
87
|
-
}
|
|
88
|
-
put(root, `${directory}/env.example`, '# Copy env.example to .env in this app directory. Void reads one local file per deployable app.\n# Production server values use void secret; VITE_* values must be supplied by the build environment.\n' +
|
|
89
|
-
[...envKeys].map(([key, value]) => `${key}=${value}`).join('\n') +
|
|
90
|
-
'\n');
|
|
91
|
-
const serverKeys = [...envKeys.keys()].filter((key) => !key.startsWith('NEXT_PUBLIC_') &&
|
|
92
|
-
!key.startsWith('VITE_') &&
|
|
93
|
-
!key.startsWith('EXPO_PUBLIC_'));
|
|
94
|
-
if (app !== 'web' && serverKeys.length) {
|
|
95
|
-
cloudflare.secrets = { required: serverKeys };
|
|
96
|
-
json(root, `${directory}/anhedral.cloudflare.json`, cloudflare);
|
|
97
|
-
}
|
|
98
|
-
put(root, `${directory}/env.ts`, `import { defineEnv${serverKeys.length ? ', string' : ''} } from 'void/env';\nexport default defineEnv({\n${serverKeys.map((key) => ` ${key}: string(),`).join('\n')}\n});\n`);
|
|
99
|
-
patchPackage(root, `${directory}/package.json`, {
|
|
100
|
-
devDependencies: { void: VOID_VERSION },
|
|
101
|
-
scripts: {
|
|
102
|
-
deploy: 'node ../../scripts/prepare-void-migrations.mjs && void deploy --platform cloudflare',
|
|
103
|
-
'env:check': 'void env check',
|
|
104
|
-
typecheck: `wrangler types --config anhedral.cloudflare.json${app === 'web' ? ' --env-interface CloudflareEnv cloudflare-env.d.ts' : ''} && tsc --noEmit`,
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
if (app === 'web') {
|
|
108
|
-
// Void owns the Cloudflare Vite adapter in this recipe; the legacy
|
|
109
|
-
// Vinext configuration's direct plugin dependency is no longer used.
|
|
110
|
-
const webPackage = readJson(root, `${directory}/package.json`);
|
|
111
|
-
const webDevDependencies = webPackage.devDependencies;
|
|
112
|
-
delete webDevDependencies['@cloudflare/vite-plugin'];
|
|
113
|
-
json(root, `${directory}/package.json`, webPackage);
|
|
114
|
-
if (existsSync(path.join(root, directory, 'tsconfig.json'))) {
|
|
115
|
-
const ts = readJson(root, `${directory}/tsconfig.json`);
|
|
116
|
-
ts.compilerOptions.resolveJsonModule = true;
|
|
117
|
-
json(root, `${directory}/tsconfig.json`, ts);
|
|
118
|
-
}
|
|
119
|
-
put(root, `${directory}/vite.config.ts`, `import { defineConfig } from 'vite';\nimport vinext from 'vinext';\nimport { voidPlugin } from 'void';\nexport default defineConfig({ plugins: [vinext(), voidPlugin(), ${VINEXT_SERVER_OUTPUT_PLUGIN}] });\n`);
|
|
120
|
-
patchPackage(root, `${directory}/package.json`, {
|
|
121
|
-
scripts: { preview: 'vite preview --host 127.0.0.1 --port 3000' },
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
const ports = WORKER_DEV_PORTS[app];
|
|
126
|
-
const schedules = cloudflare.triggers?.crons;
|
|
127
|
-
if (schedules?.length) {
|
|
128
|
-
put(root, `${directory}/crons/scheduled.ts`, `import application from '../src/index';
|
|
129
|
-
// Void validates authored cron triggers against source declarations. The
|
|
130
|
-
// standalone Worker entry retains the original scheduled event handler.
|
|
131
|
-
export const cron = ${JSON.stringify(schedules)};
|
|
132
|
-
export default application.scheduled;
|
|
133
|
-
`);
|
|
134
|
-
}
|
|
135
|
-
put(root, `${directory}/src/void-entry.ts`, `import application from './index';
|
|
136
|
-
export * from './index';
|
|
137
|
-
// Deployment readiness is distinct from product acceptance. Preserve original
|
|
138
|
-
// fetch, queue, scheduled and named Durable Object/Workflow exports.
|
|
139
|
-
type Worker = { fetch?: (request: Request, env: Env, ctx: ExecutionContext) => Response | Promise<Response> };
|
|
140
|
-
const original = application as unknown as Worker;
|
|
141
|
-
function readiness(env: Env): Response {
|
|
142
|
-
return Response.json({ ready: true, versionId: env.__VOID_VERSION_METADATA?.id }, { headers: { 'cache-control': 'no-store' } });
|
|
143
|
-
}
|
|
144
|
-
export default {
|
|
145
|
-
...application,
|
|
146
|
-
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
|
147
|
-
if (request.method === 'GET' && new URL(request.url).pathname === '/__void/ready') {
|
|
148
|
-
return readiness(env);
|
|
149
|
-
}
|
|
150
|
-
return original.fetch ? original.fetch.call(application, request, env, ctx) : new Response('Not found', { status: 404 });
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
`);
|
|
154
|
-
put(root, `${directory}/routes/README.md`, '# Standalone Worker delivery\n\nVoid 0.27 requires a backend convention directory to classify a Worker deployment. This reserved directory contains no Void handlers. The Cloudflare Vite plugin builds src/void-entry.ts, which adds deployment readiness and preserves the application handlers and exported classes from src/index.ts. Do not add a second router here without reviewing the application architecture.\n');
|
|
155
|
-
put(root, `${directory}/vite.config.ts`, `import { defineConfig } from 'vite';\nimport { cloudflare } from '@cloudflare/vite-plugin';\n// Void generates the deployment config before its fresh build. Local builds\n// use the same explicit declaration without provisioning remote resources.\nexport default defineConfig({ plugins: [cloudflare({ configPath: process.env.VOID_CLOUDFLARE_DEPLOY_BUILD ? '.void-wrangler.jsonc' : 'anhedral.cloudflare.json', inspectorPort: ${ports.inspector}, viteEnvironment: { name: 'ssr' } })], server: { host: '127.0.0.1', port: ${ports.http}, strictPort: true } });\n`);
|
|
156
|
-
patchPackage(root, `${directory}/package.json`, {
|
|
157
|
-
devDependencies: {
|
|
158
|
-
vite: VINEXT_DEPENDENCIES.devDependencies.vite,
|
|
159
|
-
'@cloudflare/vite-plugin': VINEXT_DEPENDENCIES.devDependencies['@cloudflare/vite-plugin'],
|
|
160
|
-
},
|
|
161
|
-
scripts: {
|
|
162
|
-
dev: 'vite dev',
|
|
163
|
-
build: 'vite build',
|
|
164
|
-
preview: `vite preview --host 127.0.0.1 --port ${ports.http}`,
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
const ts = readJson(root, `${directory}/tsconfig.json`);
|
|
168
|
-
const compiler = ts.compilerOptions;
|
|
169
|
-
compiler.resolveJsonModule = true;
|
|
170
|
-
ts.include = [
|
|
171
|
-
'src/**/*.ts',
|
|
172
|
-
'worker-configuration.d.ts',
|
|
173
|
-
'vite.config.ts',
|
|
174
|
-
'void.config.ts',
|
|
175
|
-
'env.ts',
|
|
176
|
-
];
|
|
177
|
-
json(root, `${directory}/tsconfig.json`, ts);
|
|
178
|
-
}
|
|
179
|
-
const migrateFile = path.join(root, 'packages/db/src/migrate.ts');
|
|
180
|
-
if (existsSync(migrateFile)) {
|
|
181
|
-
const migrateSource = readFileSync(migrateFile, 'utf8');
|
|
182
|
-
put(root, 'packages/db/src/migrate.ts', migrateSource.replaceAll(`apps/${app}/wrangler.jsonc`, `apps/${app}/anhedral.cloudflare.json`));
|
|
183
|
-
}
|
|
184
|
-
configured = true;
|
|
185
|
-
}
|
|
186
|
-
if (configured) {
|
|
187
|
-
pinVoidCloudflareAdapter(root);
|
|
188
|
-
patchPackage(root, 'package.json', { engines: { node: VOID_NODE_ENGINE } });
|
|
189
|
-
// The standalone generated preparation module uses only Node builtins and
|
|
190
|
-
// is byte-identical to the version exercised by Anhedral delivery tests.
|
|
191
|
-
put(root, 'scripts/void-migrations.mjs', readFileSync(new URL('../void-migrations.js', import.meta.url), 'utf8'));
|
|
192
|
-
put(root, 'scripts/prepare-void-migrations.mjs', `import { readFileSync } from 'node:fs';
|
|
193
|
-
import { fileURLToPath } from 'node:url';
|
|
194
|
-
import path from 'node:path';
|
|
195
|
-
import { prepareVoidMigrations } from './void-migrations.mjs';
|
|
196
|
-
const root = fileURLToPath(new URL('../', import.meta.url));
|
|
197
|
-
const directory = process.cwd();
|
|
198
|
-
const config = JSON.parse(readFileSync(path.join(directory, 'anhedral.cloudflare.json'), 'utf8'));
|
|
199
|
-
prepareVoidMigrations(root, directory, config);
|
|
200
|
-
`);
|
|
201
|
-
}
|
|
202
|
-
return configured;
|
|
203
|
-
}
|
|
204
|
-
/** Extend server declarations after transactional additions without evaluating config. */
|
|
205
|
-
export function refreshVoidEnvironment(root) {
|
|
206
|
-
let configured = false;
|
|
207
|
-
for (const app of readdirSync(path.join(root, 'apps'))) {
|
|
208
|
-
const directory = `apps/${app}`;
|
|
209
|
-
if (!existsSync(path.join(root, directory, 'void.config.ts')))
|
|
210
|
-
continue;
|
|
211
|
-
configured = true;
|
|
212
|
-
const schemaFile = path.join(root, directory, 'env.ts');
|
|
213
|
-
if (!existsSync(schemaFile))
|
|
214
|
-
continue;
|
|
215
|
-
let schema = readFileSync(schemaFile, 'utf8');
|
|
216
|
-
const local = path.join(root, directory, 'env.example');
|
|
217
|
-
let example = existsSync(local) ? readFileSync(local, 'utf8') : '';
|
|
218
|
-
// Recipe additions use legacy names before this fresh staged conversion.
|
|
219
|
-
for (const filename of ['.env.example', '.dev.vars.example']) {
|
|
220
|
-
const file = path.join(root, directory, filename);
|
|
221
|
-
if (!existsSync(file))
|
|
222
|
-
continue;
|
|
223
|
-
for (const line of readFileSync(file, 'utf8').split('\n')) {
|
|
224
|
-
const key = /^([A-Z][A-Z0-9_]*)=/.exec(line)?.[1];
|
|
225
|
-
if (key && !example.split('\n').some((entry) => entry.startsWith(`${key}=`))) {
|
|
226
|
-
example += (example.endsWith('\n') ? '' : '\n') + line + '\n';
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
rmSync(file);
|
|
230
|
-
}
|
|
231
|
-
put(root, `${directory}/env.example`, example);
|
|
232
|
-
const keys = [...example.matchAll(/^([A-Z][A-Z0-9_]*)=/gm)].map((match) => match[1]);
|
|
233
|
-
const missing = [...new Set(keys)].filter((key) => !key.startsWith('NEXT_PUBLIC_') &&
|
|
234
|
-
!key.startsWith('VITE_') &&
|
|
235
|
-
!key.startsWith('EXPO_PUBLIC_') &&
|
|
236
|
-
!new RegExp(String.raw `\b${key}\s*:`).test(schema));
|
|
237
|
-
if (app !== 'web' && existsSync(path.join(root, directory, 'anhedral.cloudflare.json'))) {
|
|
238
|
-
const configFile = `${directory}/anhedral.cloudflare.json`;
|
|
239
|
-
const config = readJson(root, configFile);
|
|
240
|
-
const serverKeys = [...new Set(keys)].filter((key) => !key.startsWith('NEXT_PUBLIC_') &&
|
|
241
|
-
!key.startsWith('VITE_') &&
|
|
242
|
-
!key.startsWith('EXPO_PUBLIC_'));
|
|
243
|
-
const secrets = (config.secrets ?? {});
|
|
244
|
-
config.secrets = {
|
|
245
|
-
...secrets,
|
|
246
|
-
required: [...new Set([...(secrets.required ?? []), ...serverKeys])],
|
|
247
|
-
};
|
|
248
|
-
json(root, configFile, config);
|
|
249
|
-
}
|
|
250
|
-
if (!missing.length)
|
|
251
|
-
continue;
|
|
252
|
-
if (!schema.includes('defineEnv({'))
|
|
253
|
-
throw new Error(`Review ${directory}/env.ts before adding server environment keys.`);
|
|
254
|
-
if (!/import\s*\{[^}]*\bstring\b[^}]*\}\s*from\s*['"]void\/env['"]/.test(schema)) {
|
|
255
|
-
schema = schema.replace(/import\s*\{([^}]*)\}\s*from\s*(['"]void\/env['"])/, 'import { $1, string } from $2');
|
|
256
|
-
}
|
|
257
|
-
schema = schema.replace('defineEnv({', `defineEnv({\n${missing.map((key) => ` ${key}: string(),`).join('\n')}`);
|
|
258
|
-
put(root, `${directory}/env.ts`, schema);
|
|
259
|
-
}
|
|
260
|
-
if (configured) {
|
|
261
|
-
pinVoidCloudflareAdapter(root);
|
|
262
|
-
patchPackage(root, 'package.json', { engines: { node: VOID_NODE_ENGINE } });
|
|
263
|
-
}
|
|
264
|
-
}
|
package/dist/scaffold/web.d.ts
DELETED
package/dist/scaffold/web.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { scaffoldWebBackend } from './backend.js';
|
|
2
|
-
import { resourceName } from '../render.js';
|
|
3
|
-
import { writeEnvironmentFile } from './environment.js';
|
|
4
|
-
import { STACK_DEPENDENCIES, NEXT_VERCEL_VERSION, NEXT_OPENNEXT_VERSION } from '../dependencies.js';
|
|
5
|
-
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { configureVinext } from '../vinext.js';
|
|
8
|
-
import { writeWebLint } from './lint.js';
|
|
9
|
-
import { json, put, readJson, patchPackage, workerConfig } from './files.js';
|
|
10
|
-
function cleanWorkspaceManifest(root, directory) {
|
|
11
|
-
const manifestPath = `${directory}/package.json`;
|
|
12
|
-
if (!existsSync(path.join(root, manifestPath)))
|
|
13
|
-
return;
|
|
14
|
-
const manifest = readJson(root, manifestPath);
|
|
15
|
-
const sources = [];
|
|
16
|
-
const collect = (folder) => {
|
|
17
|
-
for (const entry of readdirSync(folder, { withFileTypes: true })) {
|
|
18
|
-
if (['node_modules', '.next', '.open-next', '.git'].includes(entry.name))
|
|
19
|
-
continue;
|
|
20
|
-
const file = path.join(folder, entry.name);
|
|
21
|
-
if (entry.isDirectory())
|
|
22
|
-
collect(file);
|
|
23
|
-
else if (/\.(tsx?|m?js|css)$/.test(entry.name))
|
|
24
|
-
sources.push(readFileSync(file, 'utf8'));
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
collect(path.join(root, directory));
|
|
28
|
-
for (const name of ['lucide-react', 'zod', 'next-themes']) {
|
|
29
|
-
if (!sources.some((source) => source.includes(`"${name}`) || source.includes(`'${name}`)))
|
|
30
|
-
delete manifest.dependencies?.[name];
|
|
31
|
-
}
|
|
32
|
-
if (directory === 'packages/ui') {
|
|
33
|
-
if (!sources.some((source) => source.includes('@turbo/gen')) &&
|
|
34
|
-
!Object.values(manifest.scripts ?? {}).some((script) => String(script).includes('turbo gen')))
|
|
35
|
-
delete manifest.devDependencies?.['@turbo/gen'];
|
|
36
|
-
manifest.devDependencies = {
|
|
37
|
-
...manifest.devDependencies,
|
|
38
|
-
'postcss-load-config': STACK_DEPENDENCIES['postcss-load-config'],
|
|
39
|
-
};
|
|
40
|
-
if (manifest.dependencies?.shadcn) {
|
|
41
|
-
manifest.devDependencies.shadcn = manifest.dependencies.shadcn;
|
|
42
|
-
delete manifest.dependencies.shadcn;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
json(root, manifestPath, manifest);
|
|
46
|
-
}
|
|
47
|
-
function cleanShadcnStarter(root) {
|
|
48
|
-
for (const directory of ['apps/web', 'packages/ui'])
|
|
49
|
-
cleanWorkspaceManifest(root, directory);
|
|
50
|
-
const themePath = 'apps/web/components/theme-provider.tsx';
|
|
51
|
-
if (existsSync(path.join(root, themePath))) {
|
|
52
|
-
const source = readFileSync(path.join(root, themePath), 'utf8');
|
|
53
|
-
const updated = source
|
|
54
|
-
.replace(/target.tagName === "INPUT" \|\|\s*target.tagName === "TEXTAREA" \|\|\s*target.tagName === "SELECT"/, '["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName)')
|
|
55
|
-
.replace(/if \(event.defaultPrevented \|\| event.repeat\) \{\s*return\s*\}\s*if \(event.metaKey \|\| event.ctrlKey \|\| event.altKey\) \{\s*return\s*\}\s*if \(event.key.toLowerCase\(\) !== "d"\) \{\s*return\s*\}\s*if \(isTypingTarget\(event.target\)\) \{\s*return\s*\}/, 'if (!isThemeShortcut(event) || isTypingTarget(event.target)) return');
|
|
56
|
-
// Group modifier handling while preserving short-circuiting and avoiding guard arrays.
|
|
57
|
-
const modifierHelper = `function hasShortcutModifier(event: KeyboardEvent) {
|
|
58
|
-
return event.metaKey || event.ctrlKey || event.altKey
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function isThemeShortcut(event: KeyboardEvent) {
|
|
62
|
-
if (event.defaultPrevented || event.repeat) return false
|
|
63
|
-
return !hasShortcutModifier(event) && event.key.toLowerCase() === "d"
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
`;
|
|
67
|
-
const needsModifierHelper = updated.includes('isThemeShortcut(event)') &&
|
|
68
|
-
!updated.includes('function hasShortcutModifier(');
|
|
69
|
-
const content = needsModifierHelper
|
|
70
|
-
? updated.replace(/(?:export )?function ThemeProvider\b/, (declaration) => modifierHelper + declaration)
|
|
71
|
-
: updated;
|
|
72
|
-
if (needsModifierHelper && content === updated)
|
|
73
|
-
throw new Error('The upstream theme provider changed; review its shortcut integration.');
|
|
74
|
-
put(root, themePath, content);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
export function scaffoldWeb({ root, options, bindings, runtimeApp, has }) {
|
|
78
|
-
cleanShadcnStarter(root);
|
|
79
|
-
writeWebLint(root);
|
|
80
|
-
patchPackage(root, 'apps/web/package.json', {
|
|
81
|
-
scripts: { typecheck: 'tsc --noEmit', lint: 'eslint . --max-warnings 0' },
|
|
82
|
-
devDependencies: {
|
|
83
|
-
'@next/eslint-plugin-next': STACK_DEPENDENCIES['@next/eslint-plugin-next'],
|
|
84
|
-
'@typescript-eslint/parser': STACK_DEPENDENCIES['@typescript-eslint/parser'],
|
|
85
|
-
'@typescript-eslint/eslint-plugin': STACK_DEPENDENCIES['@typescript-eslint/eslint-plugin'],
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
if (has('vinext')) {
|
|
89
|
-
configureVinext(root, resourceName(options.name, 'web'), runtimeApp === 'web' ? bindings : {});
|
|
90
|
-
}
|
|
91
|
-
else if (options.hosting === 'cloudflare') {
|
|
92
|
-
patchPackage(root, 'apps/web/package.json', {
|
|
93
|
-
dependencies: {
|
|
94
|
-
'@opennextjs/cloudflare': STACK_DEPENDENCIES['@opennextjs/cloudflare'],
|
|
95
|
-
next: NEXT_OPENNEXT_VERSION,
|
|
96
|
-
},
|
|
97
|
-
devDependencies: { wrangler: STACK_DEPENDENCIES['wrangler'] },
|
|
98
|
-
scripts: {
|
|
99
|
-
preview: 'opennextjs-cloudflare build && opennextjs-cloudflare preview --port 3000',
|
|
100
|
-
deploy: 'opennextjs-cloudflare build && opennextjs-cloudflare deploy',
|
|
101
|
-
'build:worker': 'opennextjs-cloudflare build',
|
|
102
|
-
'cf:typegen': 'wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts',
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
json(root, 'apps/web/wrangler.jsonc', {
|
|
106
|
-
...workerConfig(resourceName(options.name, 'web')),
|
|
107
|
-
compatibility_flags: ['nodejs_compat', 'global_fetch_strictly_public'],
|
|
108
|
-
main: '.open-next/worker.js',
|
|
109
|
-
assets: { directory: '.open-next/assets', binding: 'ASSETS' },
|
|
110
|
-
services: [{ binding: 'WORKER_SELF_REFERENCE', service: resourceName(options.name, 'web') }],
|
|
111
|
-
...(runtimeApp === 'web' ? bindings : {}),
|
|
112
|
-
});
|
|
113
|
-
const nextConfig = ['next.config.ts', 'next.config.mjs', 'next.config.js'].find((file) => existsSync(path.join(root, 'apps/web', file)));
|
|
114
|
-
if (nextConfig) {
|
|
115
|
-
const source = readFileSync(path.join(root, 'apps/web', nextConfig), 'utf8');
|
|
116
|
-
put(root, `apps/web/${nextConfig}`, `import { initOpenNextCloudflareForDev } from '@opennextjs/cloudflare';\n${source}\ninitOpenNextCloudflareForDev();\n`);
|
|
117
|
-
}
|
|
118
|
-
put(root, 'apps/web/open-next.config.ts', 'import { defineCloudflareConfig } from "@opennextjs/cloudflare";\nexport default defineCloudflareConfig();\n');
|
|
119
|
-
put(root, 'apps/web/public/_headers', '/_next/static/*\n Cache-Control: public,max-age=31536000,immutable\n');
|
|
120
|
-
writeEnvironmentFile(root, 'apps/web/.dev.vars.example', { NEXTJS_ENV: 'development' });
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
patchPackage(root, 'apps/web/package.json', { dependencies: { next: NEXT_VERCEL_VERSION } });
|
|
124
|
-
put(root, 'apps/web/next.config.ts', 'import type { NextConfig } from "next";\nconst config: NextConfig = { transpilePackages: ["@workspace/ui"], cacheComponents: true, partialPrefetching: true };\nexport default config;\n');
|
|
125
|
-
for (const file of ['next.config.js', 'next.config.mjs'])
|
|
126
|
-
rmSync(path.join(root, 'apps/web', file), { force: true });
|
|
127
|
-
json(root, 'apps/web/vercel.json', { framework: 'nextjs' });
|
|
128
|
-
}
|
|
129
|
-
scaffoldWebBackend({ root, options, bindings, runtimeApp, has });
|
|
130
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CloudflareRequest } from './cloudflare.js';
|
|
2
|
-
export interface DeletionPlan {
|
|
3
|
-
token: string;
|
|
4
|
-
name: string;
|
|
5
|
-
accountId: string;
|
|
6
|
-
resourceId: string;
|
|
7
|
-
kind: string;
|
|
8
|
-
applications: string[];
|
|
9
|
-
expiresAt: string;
|
|
10
|
-
impact: string;
|
|
11
|
-
}
|
|
12
|
-
export declare class ServiceDeletionStore {
|
|
13
|
-
readonly directory: string;
|
|
14
|
-
constructor(directory: string);
|
|
15
|
-
plan(root: string, key: string, request: CloudflareRequest): Promise<DeletionPlan>;
|
|
16
|
-
execute(root: string, key: string, token: string, typedName: string, request: CloudflareRequest): Promise<{
|
|
17
|
-
state: "deleted";
|
|
18
|
-
resourceId: string;
|
|
19
|
-
message: string;
|
|
20
|
-
} | {
|
|
21
|
-
state: "uncertain";
|
|
22
|
-
resourceId: string;
|
|
23
|
-
message: string;
|
|
24
|
-
}>;
|
|
25
|
-
}
|
|
26
|
-
export declare function assertNoDeletedServices(root: string, resources: {
|
|
27
|
-
kind: string;
|
|
28
|
-
name: string;
|
|
29
|
-
}[]): void;
|