Update environment type definitions and remove generated files. Added new environment variables to ambient.d.ts and dynamic private module. Deleted obsolete generated files including root.js, root.svelte, and client-related files. Updated route metadata and types for improved structure and clarity.

This commit is contained in:
2026-01-22 17:22:57 -06:00
parent f15f7b8e38
commit 4a7f3c192d
27 changed files with 689 additions and 170 deletions
+32 -6
View File
@@ -30,14 +30,19 @@ declare module '$env/static/private' {
export const GHOSTTY_RESOURCES_DIR: string; export const GHOSTTY_RESOURCES_DIR: string;
export const TERM_PROGRAM: string; export const TERM_PROGRAM: string;
export const NODE: string; export const NODE: string;
export const SHELL: string; export const INIT_CWD: string;
export const TERM: string; export const TERM: string;
export const HOMEBREW_REPOSITORY: string; export const SHELL: string;
export const TMPDIR: string; export const TMPDIR: string;
export const HOMEBREW_REPOSITORY: string;
export const npm_config_global_prefix: string;
export const TERM_PROGRAM_VERSION: string; export const TERM_PROGRAM_VERSION: string;
export const COLOR: string;
export const npm_config_noproxy: string;
export const npm_config_local_prefix: string; export const npm_config_local_prefix: string;
export const USER: string; export const USER: string;
export const COMMAND_MODE: string; export const COMMAND_MODE: string;
export const npm_config_globalconfig: string;
export const SSH_AUTH_SOCK: string; export const SSH_AUTH_SOCK: string;
export const __CF_USER_TEXT_ENCODING: string; export const __CF_USER_TEXT_ENCODING: string;
export const npm_execpath: string; export const npm_execpath: string;
@@ -46,19 +51,25 @@ declare module '$env/static/private' {
export const _: string; export const _: string;
export const LaunchInstanceID: string; export const LaunchInstanceID: string;
export const GHOSTTY_SHELL_FEATURES: string; export const GHOSTTY_SHELL_FEATURES: string;
export const npm_config_userconfig: string;
export const npm_config_init_module: string;
export const __CFBundleIdentifier: string; export const __CFBundleIdentifier: string;
export const npm_command: string; export const npm_command: string;
export const PWD: string; export const PWD: string;
export const npm_lifecycle_event: string; export const npm_lifecycle_event: string;
export const EDITOR: string;
export const npm_package_name: string; export const npm_package_name: string;
export const LANG: string; export const LANG: string;
export const npm_config_npm_version: string;
export const XPC_FLAGS: string; export const XPC_FLAGS: string;
export const npm_config_node_gyp: string;
export const npm_package_version: string; export const npm_package_version: string;
export const XPC_SERVICE_NAME: string; export const XPC_SERVICE_NAME: string;
export const HOME: string; export const HOME: string;
export const SHLVL: string; export const SHLVL: string;
export const TERMINFO: string; export const TERMINFO: string;
export const HOMEBREW_PREFIX: string; export const HOMEBREW_PREFIX: string;
export const npm_config_cache: string;
export const LOGNAME: string; export const LOGNAME: string;
export const npm_lifecycle_script: string; export const npm_lifecycle_script: string;
export const XDG_DATA_DIRS: string; export const XDG_DATA_DIRS: string;
@@ -67,10 +78,12 @@ declare module '$env/static/private' {
export const INFOPATH: string; export const INFOPATH: string;
export const HOMEBREW_CELLAR: string; export const HOMEBREW_CELLAR: string;
export const OSLogRateLimit: string; export const OSLogRateLimit: string;
export const AGENT: string;
export const SECURITYSESSIONID: string; export const SECURITYSESSIONID: string;
export const npm_node_execpath: string; export const npm_node_execpath: string;
export const npm_config_prefix: string;
export const OPENCODE: string;
export const COLORTERM: string; export const COLORTERM: string;
export const NODE_ENV: string;
} }
/** /**
@@ -104,14 +117,19 @@ declare module '$env/dynamic/private' {
GHOSTTY_RESOURCES_DIR: string; GHOSTTY_RESOURCES_DIR: string;
TERM_PROGRAM: string; TERM_PROGRAM: string;
NODE: string; NODE: string;
SHELL: string; INIT_CWD: string;
TERM: string; TERM: string;
HOMEBREW_REPOSITORY: string; SHELL: string;
TMPDIR: string; TMPDIR: string;
HOMEBREW_REPOSITORY: string;
npm_config_global_prefix: string;
TERM_PROGRAM_VERSION: string; TERM_PROGRAM_VERSION: string;
COLOR: string;
npm_config_noproxy: string;
npm_config_local_prefix: string; npm_config_local_prefix: string;
USER: string; USER: string;
COMMAND_MODE: string; COMMAND_MODE: string;
npm_config_globalconfig: string;
SSH_AUTH_SOCK: string; SSH_AUTH_SOCK: string;
__CF_USER_TEXT_ENCODING: string; __CF_USER_TEXT_ENCODING: string;
npm_execpath: string; npm_execpath: string;
@@ -120,19 +138,25 @@ declare module '$env/dynamic/private' {
_: string; _: string;
LaunchInstanceID: string; LaunchInstanceID: string;
GHOSTTY_SHELL_FEATURES: string; GHOSTTY_SHELL_FEATURES: string;
npm_config_userconfig: string;
npm_config_init_module: string;
__CFBundleIdentifier: string; __CFBundleIdentifier: string;
npm_command: string; npm_command: string;
PWD: string; PWD: string;
npm_lifecycle_event: string; npm_lifecycle_event: string;
EDITOR: string;
npm_package_name: string; npm_package_name: string;
LANG: string; LANG: string;
npm_config_npm_version: string;
XPC_FLAGS: string; XPC_FLAGS: string;
npm_config_node_gyp: string;
npm_package_version: string; npm_package_version: string;
XPC_SERVICE_NAME: string; XPC_SERVICE_NAME: string;
HOME: string; HOME: string;
SHLVL: string; SHLVL: string;
TERMINFO: string; TERMINFO: string;
HOMEBREW_PREFIX: string; HOMEBREW_PREFIX: string;
npm_config_cache: string;
LOGNAME: string; LOGNAME: string;
npm_lifecycle_script: string; npm_lifecycle_script: string;
XDG_DATA_DIRS: string; XDG_DATA_DIRS: string;
@@ -141,10 +165,12 @@ declare module '$env/dynamic/private' {
INFOPATH: string; INFOPATH: string;
HOMEBREW_CELLAR: string; HOMEBREW_CELLAR: string;
OSLogRateLimit: string; OSLogRateLimit: string;
AGENT: string;
SECURITYSESSIONID: string; SECURITYSESSIONID: string;
npm_node_execpath: string; npm_node_execpath: string;
npm_config_prefix: string;
OPENCODE: string;
COLORTERM: string; COLORTERM: string;
NODE_ENV: string;
[key: `PUBLIC_${string}`]: undefined; [key: `PUBLIC_${string}`]: undefined;
[key: `${string}`]: string | undefined; [key: `${string}`]: string | undefined;
} }
-29
View File
@@ -1,29 +0,0 @@
export { matchers } from './matchers.js';
export const nodes = [
() => import('./nodes/0'),
() => import('./nodes/1'),
() => import('./nodes/2')
];
export const server_loads = [];
export const dictionary = {
"/": [2]
};
export const hooks = {
handleError: (({ error }) => { console.error(error) }),
reroute: (() => {}),
transport: {}
};
export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode]));
export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode]));
export const hash = false;
export const decode = (type, value) => decoders[type](value);
export { default as root } from '../root.js';
-1
View File
@@ -1 +0,0 @@
export const matchers = {};
-1
View File
@@ -1 +0,0 @@
export { default as component } from "../../../../src/routes/+layout.svelte";
-1
View File
@@ -1 +0,0 @@
export { default as component } from "../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte";
-1
View File
@@ -1 +0,0 @@
export { default as component } from "../../../../src/routes/+page.svelte";
-3
View File
@@ -1,3 +0,0 @@
import { asClassComponent } from 'svelte/legacy';
import Root from './root.svelte';
export default asClassComponent(Root);
-68
View File
@@ -1,68 +0,0 @@
<!-- This file is generated by @sveltejs/kit — do not edit it! -->
<svelte:options runes={true} />
<script>
import { setContext, onMount, tick } from 'svelte';
import { browser } from '$app/environment';
// stores
let { stores, page, constructors, components = [], form, data_0 = null, data_1 = null } = $props();
if (!browser) {
// svelte-ignore state_referenced_locally
setContext('__svelte__', stores);
}
if (browser) {
$effect.pre(() => stores.page.set(page));
} else {
// svelte-ignore state_referenced_locally
stores.page.set(page);
}
$effect(() => {
stores;page;constructors;components;form;data_0;data_1;
stores.page.notify();
});
let mounted = $state(false);
let navigated = $state(false);
let title = $state(null);
onMount(() => {
const unsubscribe = stores.page.subscribe(() => {
if (mounted) {
navigated = true;
tick().then(() => {
title = document.title || 'untitled page';
});
}
});
mounted = true;
return unsubscribe;
});
const Pyramid_1=$derived(constructors[1])
</script>
{#if constructors[1]}
{@const Pyramid_0 = constructors[0]}
<!-- svelte-ignore binding_property_non_reactive -->
<Pyramid_0 bind:this={components[0]} data={data_0} {form} params={page.params}>
<!-- svelte-ignore binding_property_non_reactive -->
<Pyramid_1 bind:this={components[1]} data={data_1} {form} params={page.params} />
</Pyramid_0>
{:else}
{@const Pyramid_0 = constructors[0]}
<!-- svelte-ignore binding_property_non_reactive -->
<Pyramid_0 bind:this={components[0]} data={data_0} {form} params={page.params} />
{/if}
{#if mounted}
<div id="svelte-announcer" aria-live="assertive" aria-atomic="true" style="position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px">
{#if navigated}
{title}
{/if}
</div>
{/if}
-53
View File
@@ -1,53 +0,0 @@
import root from '../root.js';
import { set_building, set_prerendering } from '__sveltekit/environment';
import { set_assets } from '$app/paths/internal/server';
import { set_manifest, set_read_implementation } from '__sveltekit/server';
import { set_private_env, set_public_env } from '../../../node_modules/@sveltejs/kit/src/runtime/shared-server.js';
export const options = {
app_template_contains_nonce: false,
async: false,
csp: {"mode":"auto","directives":{"upgrade-insecure-requests":false,"block-all-mixed-content":false},"reportOnly":{"upgrade-insecure-requests":false,"block-all-mixed-content":false}},
csrf_check_origin: true,
csrf_trusted_origins: [],
embedded: false,
env_public_prefix: 'PUBLIC_',
env_private_prefix: '',
hash_routing: false,
hooks: null, // added lazily, via `get_hooks`
preload_strategy: "modulepreload",
root,
service_worker: false,
service_worker_options: undefined,
templates: {
app: ({ head, body, assets, nonce, env }) => "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t" + head + "\n\t</head>\n\t<body data-sveltekit-preload-data=\"hover\">\n\t\t<div style=\"display: contents\">" + body + "</div>\n\t</body>\n</html>\n",
error: ({ status, message }) => "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>" + message + "</title>\n\n\t\t<style>\n\t\t\tbody {\n\t\t\t\t--bg: white;\n\t\t\t\t--fg: #222;\n\t\t\t\t--divider: #ccc;\n\t\t\t\tbackground: var(--bg);\n\t\t\t\tcolor: var(--fg);\n\t\t\t\tfont-family:\n\t\t\t\t\tsystem-ui,\n\t\t\t\t\t-apple-system,\n\t\t\t\t\tBlinkMacSystemFont,\n\t\t\t\t\t'Segoe UI',\n\t\t\t\t\tRoboto,\n\t\t\t\t\tOxygen,\n\t\t\t\t\tUbuntu,\n\t\t\t\t\tCantarell,\n\t\t\t\t\t'Open Sans',\n\t\t\t\t\t'Helvetica Neue',\n\t\t\t\t\tsans-serif;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t.error {\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tmax-width: 32rem;\n\t\t\t\tmargin: 0 1rem;\n\t\t\t}\n\n\t\t\t.status {\n\t\t\t\tfont-weight: 200;\n\t\t\t\tfont-size: 3rem;\n\t\t\t\tline-height: 1;\n\t\t\t\tposition: relative;\n\t\t\t\ttop: -0.05rem;\n\t\t\t}\n\n\t\t\t.message {\n\t\t\t\tborder-left: 1px solid var(--divider);\n\t\t\t\tpadding: 0 0 0 1rem;\n\t\t\t\tmargin: 0 0 0 1rem;\n\t\t\t\tmin-height: 2.5rem;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t.message h1 {\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t@media (prefers-color-scheme: dark) {\n\t\t\t\tbody {\n\t\t\t\t\t--bg: #222;\n\t\t\t\t\t--fg: #ddd;\n\t\t\t\t\t--divider: #666;\n\t\t\t\t}\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div class=\"error\">\n\t\t\t<span class=\"status\">" + status + "</span>\n\t\t\t<div class=\"message\">\n\t\t\t\t<h1>" + message + "</h1>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>\n"
},
version_hash: "1rc0y0p"
};
export async function get_hooks() {
let handle;
let handleFetch;
let handleError;
let handleValidationError;
let init;
let reroute;
let transport;
return {
handle,
handleFetch,
handleError,
handleValidationError,
init,
reroute,
transport
};
}
export { set_assets, set_building, set_manifest, set_prerendering, set_private_env, set_public_env, set_read_implementation };
+8 -1
View File
@@ -1,3 +1,10 @@
{ {
"/": [] "/": [
"src/routes/+page.ts",
"src/routes/+page.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
]
} }
+20 -6
View File
@@ -11,14 +11,28 @@ type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Pa
type EnsureDefined<T> = T extends null | undefined ? {} : T; type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never; type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>; export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageServerParentData = EnsureDefined<LayoutServerData>;
type PageParentData = EnsureDefined<LayoutData>; type PageParentData = EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/" | null type LayoutRouteId = RouteId | "/" | null
type LayoutParams = RouteParams & { } type LayoutParams = RouteParams & { }
type LayoutServerParentData = EnsureDefined<{}>;
type LayoutParentData = EnsureDefined<{}>; type LayoutParentData = EnsureDefined<{}>;
export type PageServerData = null; export type PageServerLoad<OutputData extends Partial<App.PageData> & Record<string, any> | void = Partial<App.PageData> & Record<string, any> | void> = Kit.ServerLoad<RouteParams, PageServerParentData, OutputData, RouteId>;
export type PageData = Expand<PageParentData>; export type PageServerLoadEvent = Parameters<PageServerLoad>[0];
export type PageProps = { params: RouteParams; data: PageData } export type ActionData = unknown;
export type LayoutServerData = null; export type PageServerData = Expand<OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+page.server.js').load>>>>>>;
export type LayoutData = Expand<LayoutParentData>; export type PageLoad<OutputData extends OutputDataShape<PageParentData> = OutputDataShape<PageParentData>> = Kit.Load<RouteParams, PageServerData, PageParentData, OutputData, RouteId>;
export type LayoutProps = { params: LayoutParams; data: LayoutData; children: import("svelte").Snippet } export type PageLoadEvent = Parameters<PageLoad>[0];
export type PageData = Expand<Omit<PageParentData, keyof Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+page.js').load>>>> & OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+page.js').load>>>>>>;
export type Action<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Action<RouteParams, OutputData, RouteId>
export type Actions<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Actions<RouteParams, OutputData, RouteId>
export type PageProps = { params: RouteParams; data: PageData; form: ActionData }
export type LayoutServerLoad<OutputData extends Partial<App.PageData> & Record<string, any> | void = Partial<App.PageData> & Record<string, any> | void> = Kit.ServerLoad<LayoutParams, LayoutServerParentData, OutputData, LayoutRouteId>;
export type LayoutServerLoadEvent = Parameters<LayoutServerLoad>[0];
export type LayoutServerData = Expand<OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+layout.server.js').load>>>>>>;
export type LayoutLoad<OutputData extends Partial<App.PageData> & Record<string, any> | void = Partial<App.PageData> & Record<string, any> | void> = Kit.Load<LayoutParams, LayoutServerData, LayoutParentData, OutputData, LayoutRouteId>;
export type LayoutLoadEvent = Parameters<LayoutLoad>[0];
export type LayoutData = Expand<Omit<LayoutParentData, keyof Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+layout.js').load>>>> & OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+layout.js').load>>>>>>;
export type LayoutProps = { params: LayoutParams; data: LayoutData; children: import("svelte").Snippet }
export type RequestEvent = Kit.RequestEvent<RouteParams, RouteId>;
@@ -0,0 +1,12 @@
// @ts-nocheck
// Server-only load function for the root layout.
// Runs only on the server.
// Provides shared data that requires server access (auth, user info, etc.).
import type { LayoutServerLoad } from './$types';
export const load = async ({ locals }: Parameters<LayoutServerLoad>[0]) => {
// Example: Load user session or server-side data here
return {
// Add server-side shared data here
};
};
@@ -0,0 +1,12 @@
// @ts-nocheck
// Universal load function for the root layout.
// Runs on both server and client.
// Provides shared data to all child routes.
import type { LayoutLoad } from './$types';
export const load = async () => {
return {
appName: 'My SvelteKit App'
};
};
;null as any as LayoutLoad;
@@ -0,0 +1,17 @@
// @ts-nocheck
// Server-only load function for the home page.
// Runs only on the server with access to cookies, database, and server APIs.
import type { PageServerLoad } from './$types';
export const load = async ({ cookies }: Parameters<PageServerLoad>[0]) => {
// Example: Access cookies, database, or server APIs here
const visitCount = parseInt(cookies.get('visit-count') || '0', 10);
cookies.set('visit-count', String(visitCount + 1), {
path: '/',
httpOnly: true
});
return {
visitCount
};
};
@@ -0,0 +1,12 @@
// @ts-nocheck
// Universal load function for the home page.
// Runs on both server and client.
// Returns data to the page component.
import type { PageLoad } from './$types';
export const load = async () => {
return {
title: 'Welcome to SvelteKit'
};
};
;null as any as PageLoad;
+143
View File
@@ -0,0 +1,143 @@
# Agent Guidelines
## Development Commands
```bash
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Type checking
npm run check
# Type checking with watch mode
npm run check:watch
# Sync SvelteKit
npm run prepare
```
**Note:** No test framework is configured. Add Vitest or similar for testing.
## Code Style Guidelines
### File Structure
- `src/routes/` - Route pages and layouts
- `src/lib/` - Reusable components and utilities (importable via `$lib` alias)
- `src/app.d.ts` - Global TypeScript declarations for SvelteKit types
- `static/` - Static assets served at `/`
### Svelte Components
**Svelte 5 Runes Syntax:**
```svelte
<script lang="ts">
let { children } = $props();
</script>
```
Use Svelte 5 runes API for reactivity:
- `$props()` for component props
- `$state()` for reactive state
- `$derived()` for derived values
**Imports:**
```svelte
<script lang="ts">
import favicon from '$lib/assets/favicon.svg';
</script>
```
Use `$lib` alias for imports from `src/lib/`.
### TypeScript
**Configuration:**
- Strict mode enabled
- ES modules (`"type": "module"`)
- Module resolution: bundler
**Types:**
- Extend global `App` namespace in `app.d.ts` for custom interfaces:
- `App.Error`
- `App.Locals`
- `App.PageData`
- `App.PageState`
- `App.Platform`
### Styling
- Use tabs for indentation
- Single quotes for string literals
- Semicolons at end of statements
- No ESLint/Prettier configured - follow SvelteKit conventions
### File Naming
- Routes: `+page.svelte`, `+layout.svelte`, `+error.svelte`
- Server endpoints: `+page.server.ts`, `+layout.server.ts`, `+server.ts`
- Load functions: `+page.ts`, `+layout.ts`
### SvelteKit File Types
**Page Files:**
- `+page.svelte` - The component for a route page, renders HTML and handles UI
- `+page.ts` - Universal load function that runs on server and client, returns data for the page
- `+page.server.ts` - Server-only load function with access to cookies, database, and server APIs
**Layout Files:**
- `+layout.svelte` - Wraps child routes with shared UI (navbar, footer, etc.)
- `+layout.ts` - Universal load function that provides data to all child routes
- `+layout.server.ts` - Server-only layout load for shared data (auth session, user info, etc.)
**Special Files:**
- `+error.svelte` - Custom error page component, renders when `error()` is thrown or page fails to load
- `+loading.svelte` - Loading indicator shown during navigation while data is loading
- `+not-found.svelte` - Custom 404 page when a route doesn't exist
**Server Endpoints:**
- `+server.ts` - API endpoint (GET, POST, PUT, DELETE, etc.) that creates RESTful routes
- Supports named export functions like `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS`
**Root Files:**
- `src/app.html` - HTML template for the entire application, injected with rendered content
- `src/app.d.ts` - TypeScript declarations extending SvelteKit's global types
- `src/hooks.server.ts` - Server-side hooks (handle, handleError) for auth, cookies, middleware
- `src/hooks.client.ts` - Client-side hooks for browser-specific initialization
### Import Style
- Group imports: third-party, internal, relative
- Use absolute imports with `$lib` alias for library imports
- Use relative imports `./` and `../` for same-directory files
### Component Conventions
- Always specify `lang="ts"` in `<script>` tags
- Use `<svelte:head>` for document head elements
- Render slot content with `{@render children()}` for layouts
### Error Handling
Use SvelteKit's error handling:
- Throw `error(status, message)` from load functions
- Create `+error.svelte` pages for error UI
- Define `App.Error` interface for custom error types
### Development Workflow
1. Run `npm run dev` for hot-reload development
2. Run `npm run check` before committing to ensure type safety
3. Test with `npm run build` before deploying
### Adding Tests
No test framework is currently configured. To add testing:
1. Install Vitest: `npm install -D vitest @testing-library/svelte`
2. Create test files alongside source with `.test.ts` suffix
3. Update `package.json` with test scripts
+32
View File
@@ -0,0 +1,32 @@
declare namespace svelteNative.JSX {
// Every namespace eligible for use needs to implement the following two functions
function mapElementTag(
tag: string
): any;
function createElement<Elements extends IntrinsicElements, Key extends keyof Elements>(
element: Key | undefined | null, attrs: Elements[Key]
): any;
function createElement<Elements extends IntrinsicElements, Key extends keyof Elements, T>(
element: Key | undefined | null, attrEnhancers: T, attrs: Elements[Key] & T
): any;
/* svelte specific */
interface ElementClass {
$$prop_def: any;
}
interface ElementAttributesProperty {
$$prop_def: any; // specify the property name to use
}
// Add empty IntrinsicAttributes to prevent fallback to the one in the JSX namespace
interface IntrinsicAttributes {
}
interface IntrinsicElements {
[name: string]: { [name: string]: any };
}
}
+290
View File
@@ -0,0 +1,290 @@
// Whenever a ambient declaration changes, its number should be increased
// This way, we avoid the situation where multiple ambient versions of svelte2tsx
// are loaded and their declarations conflict each other
// See https://github.com/sveltejs/language-tools/issues/1059 for an example bug that stems from it
// If you change anything in this file, think about whether or not it should be backported to svelte-shims.d.ts
type AConstructorTypeOf<T, U extends any[] = any[]> = new (...args: U) => T;
/** @internal PRIVATE API, DO NOT USE */
type SvelteActionReturnType = {
update?: (args: any) => void,
destroy?: () => void
} | void
/** @internal PRIVATE API, DO NOT USE */
type SvelteTransitionConfig = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
/** @internal PRIVATE API, DO NOT USE */
type SvelteTransitionReturnType = SvelteTransitionConfig | (() => SvelteTransitionConfig)
/** @internal PRIVATE API, DO NOT USE */
type SvelteAnimationReturnType = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
/** @internal PRIVATE API, DO NOT USE */
type SvelteWithOptionalProps<Props, Keys extends keyof Props> = Omit<Props, Keys> & Partial<Pick<Props, Keys>>;
/** @internal PRIVATE API, DO NOT USE */
type SvelteAllProps = { [index: string]: any }
/** @internal PRIVATE API, DO NOT USE */
type SveltePropsAnyFallback<Props> = {[K in keyof Props]: Props[K] extends never ? never : Props[K] extends undefined ? any : Props[K]}
/** @internal PRIVATE API, DO NOT USE */
type SvelteSlotsAnyFallback<Slots> = {[K in keyof Slots]: {[S in keyof Slots[K]]: Slots[K][S] extends undefined ? any : Slots[K][S]}}
/** @internal PRIVATE API, DO NOT USE */
type SvelteRestProps = { [index: string]: any }
/** @internal PRIVATE API, DO NOT USE */
type SvelteSlots = { [index: string]: any }
/** @internal PRIVATE API, DO NOT USE */
type SvelteStore<T> = { subscribe: (run: (value: T) => any, invalidate?: any) => any }
// Forces TypeScript to look into the type which results in a better representation of it
// which helps for error messages and is necessary for d.ts file transformation so that
// no ambient type references are left in the output
/** @internal PRIVATE API, DO NOT USE */
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
/** @internal PRIVATE API, DO NOT USE */
type KeysMatching<Obj, V> = {[K in keyof Obj]-?: Obj[K] extends V ? K : never}[keyof Obj]
/** @internal PRIVATE API, DO NOT USE */
declare type __sveltets_2_CustomEvents<T> = {[K in KeysMatching<T, CustomEvent>]: T[K] extends CustomEvent ? T[K]['detail']: T[K]}
declare function __sveltets_2_ensureRightProps<Props>(props: Props): {};
declare function __sveltets_2_instanceOf<T = any>(type: AConstructorTypeOf<T>): T;
declare function __sveltets_2_allPropsType(): SvelteAllProps
declare function __sveltets_2_restPropsType(): SvelteRestProps
declare function __sveltets_2_slotsType<Slots, Key extends keyof Slots>(slots: Slots): Record<Key, boolean>;
// Overload of the following two functions is necessary.
// An empty array of optionalProps makes OptionalProps type any, which means we lose the prop typing.
// optionalProps need to be first or its type cannot be infered correctly.
declare function __sveltets_2_partial<Props = {}, Events = {}, Slots = {}, Exports = {}, Bindings = string>(
render: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
): {props: Expand<SveltePropsAnyFallback<Props>>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>>, exports?: Exports, bindings?: Bindings }
declare function __sveltets_2_partial<Props = {}, Events = {}, Slots = {}, Exports = {}, Bindings = string, OptionalProps extends keyof Props = any>(
optionalProps: OptionalProps[],
render: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
): {props: Expand<SvelteWithOptionalProps<SveltePropsAnyFallback<Props>, OptionalProps>>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>>, exports?: Exports, bindings?: Bindings }
declare function __sveltets_2_partial_with_any<Props = {}, Events = {}, Slots = {}, Exports = {}, Bindings = string>(
render: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
): {props: Expand<SveltePropsAnyFallback<Props> & SvelteAllProps>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>>, exports?: Exports, bindings?: Bindings }
declare function __sveltets_2_partial_with_any<Props = {}, Events = {}, Slots = {}, Exports = {}, Bindings = string, OptionalProps extends keyof Props = any>(
optionalProps: OptionalProps[],
render: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
): {props: Expand<SvelteWithOptionalProps<SveltePropsAnyFallback<Props>, OptionalProps> & SvelteAllProps>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>>, exports?: Exports, bindings?: Bindings }
declare function __sveltets_2_with_any<Props = {}, Events = {}, Slots = {}, Exports = {}, Bindings = string>(
render: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
): {props: Expand<Props & SvelteAllProps>, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
declare function __sveltets_2_with_any_event<Props = {}, Events = {}, Slots = {}, Exports = {}, Bindings = string>(
render: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }
): {props: Props, events: Events & {[evt: string]: CustomEvent<any>;}, slots: Slots, exports?: Exports, bindings?: Bindings }
declare function __sveltets_2_store_get<T = any>(store: SvelteStore<T>): T
declare function __sveltets_2_store_get<Store extends SvelteStore<any> | undefined | null>(store: Store): Store extends SvelteStore<infer T> ? T : Store;
declare function __sveltets_2_any(dummy: any): any;
declare function __sveltets_2_invalidate<T>(getValue: () => T): T
declare function __sveltets_2_mapWindowEvent<K extends keyof HTMLBodyElementEventMap>(
event: K
): HTMLBodyElementEventMap[K];
declare function __sveltets_2_mapBodyEvent<K extends keyof WindowEventMap>(
event: K
): WindowEventMap[K];
declare function __sveltets_2_mapElementEvent<K extends keyof HTMLElementEventMap>(
event: K
): HTMLElementEventMap[K];
declare function __sveltets_2_bubbleEventDef<Events, K extends keyof Events>(
events: Events, eventKey: K
): Events[K];
declare function __sveltets_2_bubbleEventDef(
events: any, eventKey: string
): any;
declare const __sveltets_2_customEvent: CustomEvent<any>;
declare function __sveltets_2_toEventTypings<Typings>(): {[Key in keyof Typings]: CustomEvent<Typings[Key]>};
declare function __sveltets_2_unionType<T1, T2>(t1: T1, t2: T2): T1 | T2;
declare function __sveltets_2_unionType<T1, T2, T3>(t1: T1, t2: T2, t3: T3): T1 | T2 | T3;
declare function __sveltets_2_unionType<T1, T2, T3, T4>(t1: T1, t2: T2, t3: T3, t4: T4): T1 | T2 | T3 | T4;
declare function __sveltets_2_unionType(...types: any[]): any;
declare function __sveltets_2_createSvelte2TsxComponent<Props extends {}, Events extends {}, Slots extends {}>(
render: {props: Props, events: Events, slots: Slots }
): typeof import("svelte").SvelteComponent<Props, Events, Slots>;
declare function __sveltets_2_unwrapArr<T>(arr: ArrayLike<T>): T
declare function __sveltets_2_unwrapPromiseLike<T>(promise: PromiseLike<T> | T): T
// v2
declare function __sveltets_2_createCreateSlot<Slots = Record<string, Record<string, any>>>(): <SlotName extends keyof Slots>(slotName: SlotName, attrs: Slots[SlotName]) => Record<string, any>;
declare function __sveltets_2_createComponentAny(props: Record<string, any>): import("svelte").SvelteComponent<any, any, any>;
declare function __sveltets_2_any(...dummy: any[]): any;
declare function __sveltets_2_empty(...dummy: any[]): {};
declare function __sveltets_2_union<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(t1:T1,t2?:T2,t3?:T3,t4?:T4,t5?:T5,t6?:T6,t7?:T7,t8?:T8,t9?:T9,t10?:T10): T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10;
declare function __sveltets_2_nonNullable<T>(type: T): NonNullable<T>;
declare function __sveltets_2_cssProp(prop: Record<string, any>): {};
// @ts-ignore Svelte v3/v4 don't have this
declare function __sveltets_2_ensureSnippet(val: ReturnType<import('svelte').Snippet> | undefined | null): any;
/** @internal PRIVATE API, DO NOT USE */
type __sveltets_2_SvelteAnimationReturnType = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
declare var __sveltets_2_AnimationMove: { from: DOMRect, to: DOMRect }
declare function __sveltets_2_ensureAnimation(animationCall: __sveltets_2_SvelteAnimationReturnType): {};
/** @internal PRIVATE API, DO NOT USE */
type __sveltets_2_SvelteActionReturnType = {
update?: (args: any) => void,
destroy?: () => void,
$$_attributes?: Record<string, any>,
} | void
declare function __sveltets_2_ensureAction<T extends __sveltets_2_SvelteActionReturnType>(actionCall: T): T extends {$$_attributes?: any} ? T['$$_attributes'] : {};
/** @internal PRIVATE API, DO NOT USE */
type __sveltets_2_SvelteTransitionConfig = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
/** @internal PRIVATE API, DO NOT USE */
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | (() => __sveltets_2_SvelteTransitionConfig)
declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_SvelteTransitionReturnType): {};
// Includes undefined and null for all types as all usages also allow these
declare function __sveltets_2_ensureType<T>(type: AConstructorTypeOf<T>, el: T | undefined | null): {};
declare function __sveltets_2_ensureType<T1, T2>(type1: AConstructorTypeOf<T1>, type2: AConstructorTypeOf<T2>, el: T1 | T2 | undefined | null): {};
// The following is necessary because there are two clashing errors that can't be solved at the same time
// when using Svelte2TsxComponent, more precisely the event typings in
// __sveltets_2_ensureComponent<T extends new (..) => _SvelteComponent<any,||any||<-this,any>>(type: T): T;
// If we type it as "any", we have an error when using sth like {a: CustomEvent<any>}
// If we type it as "{}", we have an error when using sth like {[evt: string]: CustomEvent<any>}
// If we type it as "unknown", we get all kinds of follow up errors which we want to avoid
// Therefore introduce two more base classes just for this case.
/**
* Ambient type only used for intellisense, DO NOT USE IN YOUR PROJECT
*/
declare type ATypedSvelteComponent = {
/**
* @internal This is for type checking capabilities only
* and does not exist at runtime. Don't use this property.
*/
$$prop_def: any;
/**
* @internal This is for type checking capabilities only
* and does not exist at runtime. Don't use this property.
*/
$$events_def: any;
/**
* @internal This is for type checking capabilities only
* and does not exist at runtime. Don't use this property.
*/
$$slot_def: any;
$on(event: string, handler: any): () => void;
}
/**
* Ambient type only used for intellisense, DO NOT USE IN YOUR PROJECT.
*
* If you're looking for the type of a Svelte Component, use `SvelteComponent` and `ComponentType` instead:
*
* ```ts
* import type { ComponentType, SvelteComponent } from "svelte";
* let myComponentConstructor: ComponentType<SvelteComponent> = ..;
* ```
*/
declare type ConstructorOfATypedSvelteComponent = new (args: {target: any, props?: any}) => ATypedSvelteComponent
// Usage note: Cannot properly transform generic function components to class components due to TypeScript limitations
declare function __sveltets_2_ensureComponent<
T extends
| ConstructorOfATypedSvelteComponent
| (typeof import('svelte') extends { mount: any }
? // @ts-ignore svelte.Component doesn't exist in Svelte 4
import('svelte').Component<any, any, any>
: never)
| null
| undefined
>(
type: T
): NonNullable<
T extends ConstructorOfATypedSvelteComponent
? T
: typeof import('svelte') extends { mount: any }
? // @ts-ignore svelte.Component doesn't exist in Svelte 4
T extends import('svelte').Component<
infer Props extends Record<string, any>,
infer Exports extends Record<string, any>,
infer Bindings extends string
>
? new (
options: import('svelte').ComponentConstructorOptions<Props>
) => import('svelte').SvelteComponent<Props, Props['$$events'], Props['$$slots']> &
Exports & { $$bindings: Bindings }
: never
: never
>;
declare function __sveltets_2_ensureArray<T extends ArrayLike<unknown> | Iterable<unknown>>(
// Svelte 5 allows undefined or null here, Svelte 4 doesn't
array: T | (typeof import('svelte') extends { mount: any } ? (undefined | null) : never)
): T extends ArrayLike<infer U> ? U[] : T extends Iterable<infer U> ? Iterable<U> : any[];
type __sveltets_2_PropsWithChildren<Props, Slots> = Props &
(Slots extends { default: any }
// This is unfortunate because it means "accepts no props" turns into "accepts any prop"
// but the alternative is non-fixable type errors because of the way TypeScript index
// signatures work (they will always take precedence and make an impossible-to-satisfy children type).
? Props extends Record<string, never>
? any
: { children?: any }
: {});
declare function __sveltets_2_runes_constructor<Props extends {}>(render: {props: Props }): import("svelte").ComponentConstructorOptions<Props>;
declare function __sveltets_2_get_set_binding<T>(get: (() => T) | null | undefined, set: (t: T) => void): T;
declare function __sveltets_$$bindings<Bindings extends string[]>(...bindings: Bindings): Bindings[number];
declare function __sveltets_2_fn_component<
Props extends Record<string, any>, Exports extends Record<string, any>, Bindings extends string
// @ts-ignore Svelte 5 only
>(klass: {props: Props, exports?: Exports, bindings?: Bindings }): import('svelte').Component<Props, Exports, Bindings>;
interface __sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & { $$bindings?: Bindings } & Exports;
(internal: unknown, props: Props extends Record<string, never> ? {$$events?: Events, $$slots?: Slots} : Props & {$$events?: Events, $$slots?: Slots}): Exports & { $set?: any, $on?: any };
z_$$bindings?: Bindings;
}
declare function __sveltets_2_isomorphic_component<
Props extends Record<string, any>, Events extends Record<string, any>, Slots extends Record<string, any>, Exports extends Record<string, any>, Bindings extends string
>(klass: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }): __sveltets_2_IsomorphicComponent<Props, Events, Slots, Exports, Bindings>;
declare function __sveltets_2_isomorphic_component_slots<
Props extends Record<string, any>, Events extends Record<string, any>, Slots extends Record<string, any>, Exports extends Record<string, any>, Bindings extends string
>(klass: {props: Props, events: Events, slots: Slots, exports?: Exports, bindings?: Bindings }): __sveltets_2_IsomorphicComponent<__sveltets_2_PropsWithChildren<Props, Slots>, Events, Slots, Exports, Bindings>;
+13
View File
@@ -0,0 +1,13 @@
/*
Client-side hooks.
Runs in the browser on page load and navigation.
Useful for client initialization and browser-specific logic.
*/
import { browser } from '$app/environment';
export function handleError({ error }: { error: Error & { appError?: any } }) {
if (browser) {
// Log client-side errors to error tracking service
console.error('Client error:', error);
}
}
+21
View File
@@ -0,0 +1,21 @@
// Server-side hooks.
// Runs on the server for every request.
// Useful for authentication, cookies, and middleware.
import type { Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
export const handle: Handle = async ({ event, resolve }) => {
// Example: Add user session to locals
// event.locals.user = await getUserFromSession(event.cookies);
return resolve(event);
};
export const handleError = async ({ error, event }: { error: Error; event: any }) => {
// Log errors to your error tracking service
console.error('Error:', error, 'Event:', event);
return {
message: 'An unexpected error occurred'
};
};
+22
View File
@@ -0,0 +1,22 @@
<!--
Error page component.
Displays when an error is thrown or a page fails to load.
-->
<script lang="ts">
import { page } from '$app/stores';
let { data } = $props();
</script>
<svelte:head>
<title>Error</title>
</svelte:head>
<h1>Error</h1>
<p>{$page.error?.message || 'Something went wrong'}</p>
{#if $page.status}
<p>Status: {$page.status}</p>
{/if}
<a href="/">Go back home</a>
+11
View File
@@ -0,0 +1,11 @@
// Server-only load function for the root layout.
// Runs only on the server.
// Provides shared data that requires server access (auth, user info, etc.).
import type { LayoutServerLoad } from './$types';
export const load: LayoutServerLoad = async ({ locals }) => {
// Example: Load user session or server-side data here
return {
// Add server-side shared data here
};
};
+4
View File
@@ -1,3 +1,7 @@
<!--
Root layout component that wraps all pages.
Sets the favicon and renders child page content.
-->
<script lang="ts"> <script lang="ts">
import favicon from '$lib/assets/favicon.svg'; import favicon from '$lib/assets/favicon.svg';
+10
View File
@@ -0,0 +1,10 @@
// Universal load function for the root layout.
// Runs on both server and client.
// Provides shared data to all child routes.
import type { LayoutLoad } from './$types';
export const load: LayoutLoad = async () => {
return {
appName: 'My SvelteKit App'
};
};
+16
View File
@@ -0,0 +1,16 @@
// Server-only load function for the home page.
// Runs only on the server with access to cookies, database, and server APIs.
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ cookies }) => {
// Example: Access cookies, database, or server APIs here
const visitCount = parseInt(cookies.get('visit-count') || '0', 10);
cookies.set('visit-count', String(visitCount + 1), {
path: '/',
httpOnly: true
});
return {
visitCount
};
};
+4
View File
@@ -1,2 +1,6 @@
<!--
Home page component.
Displays a welcome message with a link to SvelteKit documentation.
-->
<h1>Welcome to SvelteKit</h1> <h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p> <p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
+10
View File
@@ -0,0 +1,10 @@
// Universal load function for the home page.
// Runs on both server and client.
// Returns data to the page component.
import type { PageLoad } from './$types';
export const load: PageLoad = async () => {
return {
title: 'Welcome to SvelteKit'
};
};