@useavalon/avalon 0.1.44 → 0.1.47

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.
@@ -140,6 +140,43 @@ export interface AvalonNitroConfig {
140
140
  brotli?: boolean;
141
141
  zstd?: boolean;
142
142
  };
143
+ /**
144
+ * Prerender configuration for static site generation (SSG).
145
+ *
146
+ * Nitro will fetch each listed route at build time using the SSR handler
147
+ * and write the resulting HTML to the public output directory. These pages
148
+ * are then served as static files from the CDN — zero function invocations.
149
+ *
150
+ * Islands on prerendered pages still hydrate normally on the client.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * prerender: {
155
+ * routes: ['/', '/docs', '/blog'],
156
+ * crawlLinks: true,
157
+ * }
158
+ * ```
159
+ */
160
+ prerender?: {
161
+ /** Explicit routes to prerender at build time */
162
+ routes?: string[];
163
+ /** Crawl `<a>` links in prerendered pages to discover more routes */
164
+ crawlLinks?: boolean;
165
+ /** Number of concurrent prerender requests */
166
+ concurrency?: number;
167
+ /** Delay in ms between prerender requests */
168
+ interval?: number;
169
+ /** Fail the build if a prerender route errors */
170
+ failOnError?: boolean;
171
+ /** Routes to ignore (strings, RegExps, or filter functions) */
172
+ ignore?: Array<string | RegExp | ((path: string) => undefined | null | boolean)>;
173
+ /** Number of retry attempts per route @default 3 */
174
+ retry?: number;
175
+ /** Delay between retries in ms @default 500 */
176
+ retryDelay?: number;
177
+ /** Write `/about` as `/about/index.html` @default true */
178
+ autoSubfolderIndex?: boolean;
179
+ };
143
180
  }
144
181
  /**
145
182
  * Nitro configuration output structure
@@ -191,6 +228,8 @@ export interface NitroConfigOutput {
191
228
  }>;
192
229
  /** Static assets configuration */
193
230
  staticAssets?: StaticAssetsConfig;
231
+ /** Prerender configuration for SSG */
232
+ prerender?: AvalonNitroConfig['prerender'];
194
233
  }
195
234
  /**
196
235
  * Avalon-specific runtime configuration stored in Nitro's runtimeConfig
@@ -1 +1 @@
1
- export const DEFAULT_STATIC_ASSETS_CONFIG={publicDir:`public`,buildDir:`dist`,compression:!0,cacheControl:`public, max-age=31536000, immutable`,mutableCacheControl:`public, max-age=0, must-revalidate`,headers:{}};export const VALID_V3_PRESETS=[`node_server`,`node_middleware`,`vercel`,`cloudflare_module`,`cloudflare_pages`,`deno_deploy`,`deno_server`,`netlify`,`netlify_functions`,`netlify_edge`,`aws_lambda`,`azure_swa`,`firebase_functions`,`render_com`,`static`,`browser`];export function resolvePresetName(e){if(VALID_V3_PRESETS.includes(e))return e;throw Error(`Unknown Nitro preset: "${e}". Valid presets: ${VALID_V3_PRESETS.join(`, `)}`)}export const DEFAULT_NITRO_CONFIG={preset:`node_server`,serverDir:`server`,streaming:!0};export function createNitroConfig(t,i){let a=t.pagesDir??i.pagesDir,o=i.layoutsDir,s={streaming:t.streaming??DEFAULT_NITRO_CONFIG.streaming,pagesDir:a,layoutsDir:o};if(t.runtimeConfig&&`nitro`in t.runtimeConfig)throw Error(`The "nitro" key in runtimeConfig is reserved by Nitro v3 and cannot be used.`);let c={avalon:s,...t.runtimeConfig},l={...DEFAULT_STATIC_ASSETS_CONFIG,...t.staticAssets},u=mergeRouteRules(createDefaultStaticAssetRouteRules(l),t.routeRules??{}),d=[{dir:l.publicDir??DEFAULT_STATIC_ASSETS_CONFIG.publicDir,baseURL:`/`,maxAge:0}],f=t.renderer===!1?!1:t.renderer?{...t.renderer}:void 0;return{preset:resolvePresetName(process.env.NITRO_PRESET??t.preset??DEFAULT_NITRO_CONFIG.preset),serverDir:t.serverDir??DEFAULT_NITRO_CONFIG.serverDir,routeRules:u,runtimeConfig:c,publicRuntimeConfig:t.publicRuntimeConfig,renderer:f,compatibilityDate:t.compatibilityDate,traceDeps:t.traceDeps,rolldownConfig:t.rolldownConfig,serverEntry:t.serverEntry,compressPublicAssets:t.compressPublicAssets,publicAssets:d,staticAssets:l}}export function createDefaultStaticAssetRouteRules(t){let n=t.cacheControl??DEFAULT_STATIC_ASSETS_CONFIG.cacheControl,r=t.mutableCacheControl??DEFAULT_STATIC_ASSETS_CONFIG.mutableCacheControl;return{"/assets/**":{headers:{"Cache-Control":n,...t.headers}},"/islands/**":{headers:{"Cache-Control":n,...t.headers}},"/chunks/**":{headers:{"Cache-Control":n,...t.headers}},"/_nuxt/**":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff2":{headers:{"Cache-Control":n,...t.headers}},"/**/*.html":{headers:{"Cache-Control":r,...t.headers}},"/favicon.ico":{headers:{"Cache-Control":`public, max-age=86400`,...t.headers}},"/**/*.css":{headers:{"Cache-Control":r,...t.headers}}}}export function isValidPreset(e){return VALID_V3_PRESETS.includes(e)}export function mergeRouteRules(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]?n[e]={...n[e],...r,headers:{...n[e].headers,...r.headers}}:n[e]=r;return n}
1
+ export const DEFAULT_STATIC_ASSETS_CONFIG={publicDir:`public`,buildDir:`dist`,compression:!0,cacheControl:`public, max-age=31536000, immutable`,mutableCacheControl:`public, max-age=0, must-revalidate`,headers:{}};export const VALID_V3_PRESETS=[`node_server`,`node_middleware`,`vercel`,`cloudflare_module`,`cloudflare_pages`,`deno_deploy`,`deno_server`,`netlify`,`netlify_functions`,`netlify_edge`,`aws_lambda`,`azure_swa`,`firebase_functions`,`render_com`,`static`,`browser`];export function resolvePresetName(e){if(VALID_V3_PRESETS.includes(e))return e;throw Error(`Unknown Nitro preset: "${e}". Valid presets: ${VALID_V3_PRESETS.join(`, `)}`)}export const DEFAULT_NITRO_CONFIG={preset:`node_server`,serverDir:`server`,streaming:!0};export function createNitroConfig(t,i){let a=t.pagesDir??i.pagesDir,o=i.layoutsDir,s={streaming:t.streaming??DEFAULT_NITRO_CONFIG.streaming,pagesDir:a,layoutsDir:o};if(t.runtimeConfig&&`nitro`in t.runtimeConfig)throw Error(`The "nitro" key in runtimeConfig is reserved by Nitro v3 and cannot be used.`);let c={avalon:s,...t.runtimeConfig},l={...DEFAULT_STATIC_ASSETS_CONFIG,...t.staticAssets},u=mergeRouteRules(createDefaultStaticAssetRouteRules(l),t.routeRules??{}),d=[{dir:l.publicDir??DEFAULT_STATIC_ASSETS_CONFIG.publicDir,baseURL:`/`,maxAge:0}],f=t.renderer===!1?!1:t.renderer?{...t.renderer}:void 0;return{preset:resolvePresetName(process.env.NITRO_PRESET??t.preset??DEFAULT_NITRO_CONFIG.preset),serverDir:t.serverDir??DEFAULT_NITRO_CONFIG.serverDir,routeRules:u,runtimeConfig:c,publicRuntimeConfig:t.publicRuntimeConfig,renderer:f,compatibilityDate:t.compatibilityDate,traceDeps:t.traceDeps,rolldownConfig:t.rolldownConfig,serverEntry:t.serverEntry,compressPublicAssets:t.compressPublicAssets,publicAssets:d,staticAssets:l,prerender:t.prerender}}export function createDefaultStaticAssetRouteRules(t){let n=t.cacheControl??DEFAULT_STATIC_ASSETS_CONFIG.cacheControl,r=t.mutableCacheControl??DEFAULT_STATIC_ASSETS_CONFIG.mutableCacheControl;return{"/assets/**":{headers:{"Cache-Control":n,...t.headers}},"/islands/**":{headers:{"Cache-Control":n,...t.headers}},"/chunks/**":{headers:{"Cache-Control":n,...t.headers}},"/_nuxt/**":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff2":{headers:{"Cache-Control":n,...t.headers}},"/**/*.html":{headers:{"Cache-Control":r,...t.headers}},"/favicon.ico":{headers:{"Cache-Control":`public, max-age=86400`,...t.headers}},"/**/*.css":{headers:{"Cache-Control":r,...t.headers}}}}export function isValidPreset(e){return VALID_V3_PRESETS.includes(e)}export function mergeRouteRules(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]?n[e]={...n[e],...r,headers:{...n[e].headers,...r.headers}}:n[e]=r;return n}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Avalon Prerender Module
3
+ *
4
+ * Post-build prerendering for static site generation (SSG).
5
+ *
6
+ * Nitro v3's Vite builder does not yet support the built-in prerender
7
+ * pipeline. This module provides an equivalent: after the Vite/Nitro build
8
+ * completes, it boots the built server locally, fetches each configured
9
+ * route, and writes the resulting HTML to the public output directory.
10
+ *
11
+ * Prerendered pages are served as static files from the CDN — zero
12
+ * function invocations. Islands on prerendered pages still hydrate
13
+ * normally on the client.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // In post-build.mjs or build.mjs:
18
+ * import { prerenderRoutes } from '@useavalon/avalon/prerender';
19
+ *
20
+ * await prerenderRoutes({
21
+ * serverEntryPath: '.output/server/index.mjs',
22
+ * outputDir: '.output/public',
23
+ * routes: ['/'],
24
+ * crawlLinks: true,
25
+ * ignore: ['/demo/data-fetching'],
26
+ * });
27
+ * ```
28
+ */
29
+ export interface PrerenderConfig {
30
+ /** Path to the built Nitro server entry (e.g. '.output/server/index.mjs') */
31
+ serverEntryPath: string;
32
+ /** Directory to write prerendered HTML files */
33
+ outputDir: string;
34
+ /** Explicit routes to prerender */
35
+ routes?: string[];
36
+ /** Crawl <a> links in prerendered pages to discover more routes */
37
+ crawlLinks?: boolean;
38
+ /** Routes to ignore (strings, RegExps, or filter functions) */
39
+ ignore?: Array<string | RegExp | ((path: string) => undefined | null | boolean)>;
40
+ /** Number of concurrent prerender requests @default 4 */
41
+ concurrency?: number;
42
+ /** Fail the build if a prerender route errors @default false */
43
+ failOnError?: boolean;
44
+ /** Write /about as /about/index.html @default true */
45
+ autoSubfolderIndex?: boolean;
46
+ /** Number of retry attempts per route @default 3 */
47
+ retry?: number;
48
+ /** Delay between retries in ms @default 500 */
49
+ retryDelay?: number;
50
+ /** Port to run the prerender server on @default 13172 */
51
+ port?: number;
52
+ }
53
+ export { prerenderRoutes } from './prerender.ts';
@@ -0,0 +1 @@
1
+ export{prerenderRoutes}from"./prerender.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Prerender implementation.
3
+ *
4
+ * Spawns the built Nitro server as a child process, fetches routes via HTTP,
5
+ * extracts links, and writes static HTML files to the output directory.
6
+ *
7
+ * This approach avoids dependency issues (e.g. undici, platform-specific
8
+ * modules) that occur when importing the server bundle directly.
9
+ */
10
+ import type { PrerenderConfig } from './index.ts';
11
+ /**
12
+ * Prerender routes by spawning the built server and fetching each route via HTTP.
13
+ */
14
+ export declare function prerenderRoutes(config: PrerenderConfig): Promise<{
15
+ prerenderedRoutes: string[];
16
+ errors: Array<{
17
+ route: string;
18
+ error: string;
19
+ }>;
20
+ }>;
@@ -0,0 +1 @@
1
+ import{resolve as e,join as t,dirname as n}from"node:path";import{existsSync as r,mkdirSync as i,writeFileSync as a}from"node:fs";import{spawn as o}from"node:child_process";function s(e){let t=[],n=/<a\s[^>]*href=["']([^"'#?]+)/gi,r;for(;(r=n.exec(e))!==null;){let e=r[1];if(e.startsWith(`/`)&&!e.startsWith(`//`)){if(e.startsWith(`/assets/`)||e.startsWith(`/islands/`)||e.startsWith(`/chunks/`)||e.startsWith(`/_`)||e.match(/\.\w{2,5}$/))continue;t.push(e)}}return[...new Set(t)]}function c(e,t){for(let n of t)if(typeof n==`string`){if(e===n||n.endsWith(`/**`)&&e.startsWith(n.slice(0,-2)))return!0}else if(n instanceof RegExp){if(n.test(e))return!0}else if(typeof n==`function`&&n(e))return!0;return!1}async function l(e,t=15e3){let n=Date.now();for(;Date.now()-n<t;){try{let t=await fetch(`${e}/`);if(t.ok||t.status<500)return}catch{}await new Promise(e=>setTimeout(e,200))}throw Error(`[prerender] Server did not become ready within ${t}ms`)}export async function prerenderRoutes(u){let{serverEntryPath:d,outputDir:f,routes:p=[`/`],crawlLinks:m=!1,ignore:h=[],concurrency:g=4,failOnError:_=!1,autoSubfolderIndex:v=!0,retry:y=3,retryDelay:b=500,port:x=13172}=u,S=e(d);if(!r(S))throw Error(`[prerender] Server entry not found: ${S}`);let C=e(f),w=`http://localhost:${x}`;console.log(`[prerender] Spawning server from ${d} on port ${x}...`);let T=null;try{T=o(`node`,[S],{env:{...process.env,PORT:String(x),NITRO_PORT:String(x),HOST:`127.0.0.1`,NITRO_HOST:`127.0.0.1`,NODE_ENV:`production`},stdio:[`ignore`,`pipe`,`pipe`]}),T.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.log(`[prerender:server] ${t}`)}),T.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(`[prerender:server:err] ${t}`)}),await l(w),console.log(`[prerender] Server ready at ${w}`)}catch(e){throw T?.kill(`SIGKILL`),Error(`[prerender] Failed to start server: ${e.message}`)}let E=[],D=[],O=new Set,k=[...p];console.log(`[prerender] Starting with ${k.length} route(s), crawlLinks=${m}`);async function A(e){for(let t=1;t<=y;t++)try{let t=await fetch(`${w}${e}`);return{html:await t.text(),status:t.status}}catch(n){let r=n instanceof Error?n.message:String(n);if(t<y)console.warn(`[prerender] Retry ${t}/${y} for ${e}: ${r}`),await new Promise(e=>setTimeout(e,b));else return console.error(`[prerender] All ${y} attempts failed for ${e}: ${r}`),null}return null}try{for(;k.length>0;){let e=k.splice(0,g);await Promise.all(e.map(async e=>{let r=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(O.has(r))return;if(O.add(r),c(r,h)){console.log(`[prerender] ⏭ ${r} (ignored)`);return}let o=await A(r);if(!o){let e=`Failed to fetch ${r} after ${y} attempts`;if(console.error(`[prerender] ❌ ${e}`),D.push({route:r,error:e}),_)throw Error(e);return}if(o.status>=400){let e=`${r} returned ${o.status}`;if(console.error(`[prerender] ❌ ${e}`),D.push({route:r,error:e}),_)throw Error(e);return}let l=v?t(r,`index.html`):r+`.html`,u=t(C,l);if(i(n(u),{recursive:!0}),a(u,o.html),E.push(r),console.log(`[prerender] ✅ ${r} → ${l}`),m){let e=s(o.html);for(let t of e){let e=t.endsWith(`/`)&&t!==`/`?t.slice(0,-1):t;!O.has(e)&&!c(e,h)&&k.push(e)}}}))}}finally{T&&(console.log(`[prerender] Shutting down server...`),T.kill(`SIGKILL`))}return console.log(`[prerender] Done: ${E.length} page(s) prerendered`+(D.length>0?`, ${D.length} error(s)`:``)),{prerenderedRoutes:E,errors:D}}
@@ -1,106 +1,106 @@
1
- /**
2
- * Type declarations for image imports with vite-imagetools
3
- *
4
- * These types enable TypeScript support for optimized image imports.
5
- * Include this in your tsconfig.json `types` array:
6
- *
7
- * ```json
8
- * {
9
- * "compilerOptions": {
10
- * "types": ["@useavalon/avalon/types"]
11
- * }
12
- * }
13
- * ```
14
- */
15
-
16
- declare module "*.jpg" {
17
- const src: string;
18
- export default src;
19
- }
20
-
21
- declare module "*.jpeg" {
22
- const src: string;
23
- export default src;
24
- }
25
-
26
- declare module "*.png" {
27
- const src: string;
28
- export default src;
29
- }
30
-
31
- declare module "*.webp" {
32
- const src: string;
33
- export default src;
34
- }
35
-
36
- declare module "*.avif" {
37
- const src: string;
38
- export default src;
39
- }
40
-
41
- declare module "*.gif" {
42
- const src: string;
43
- export default src;
44
- }
45
-
46
- declare module "*.tiff" {
47
- const src: string;
48
- export default src;
49
- }
50
-
51
- declare module "*.svg" {
52
- const src: string;
53
- export default src;
54
- }
55
-
56
- // vite-imagetools srcset output
57
- interface ImageToolsSrcset {
58
- src: string;
59
- srcset: string;
60
- width: number;
61
- height: number;
62
- }
63
-
64
- declare module "*&as=srcset" {
65
- const srcset: ImageToolsSrcset;
66
- export default srcset;
67
- }
68
-
69
- declare module "*?as=srcset" {
70
- const srcset: ImageToolsSrcset;
71
- export default srcset;
72
- }
73
-
74
- // vite-imagetools picture output (multiple formats)
75
- interface ImageToolsPicture {
76
- sources: Record<string, ImageToolsSrcset>;
77
- img: ImageToolsSrcset;
78
- }
79
-
80
- declare module "*&as=picture" {
81
- const picture: ImageToolsPicture;
82
- export default picture;
83
- }
84
-
85
- declare module "*?as=picture" {
86
- const picture: ImageToolsPicture;
87
- export default picture;
88
- }
89
-
90
- // vite-imagetools metadata output
91
- interface ImageToolsMetadata {
92
- src: string;
93
- width: number;
94
- height: number;
95
- format: string;
96
- }
97
-
98
- declare module "*&as=metadata" {
99
- const metadata: ImageToolsMetadata;
100
- export default metadata;
101
- }
102
-
103
- declare module "*?as=metadata" {
104
- const metadata: ImageToolsMetadata;
105
- export default metadata;
106
- }
1
+ /**
2
+ * Type declarations for image imports with vite-imagetools
3
+ *
4
+ * These types enable TypeScript support for optimized image imports.
5
+ * Include this in your tsconfig.json `types` array:
6
+ *
7
+ * ```json
8
+ * {
9
+ * "compilerOptions": {
10
+ * "types": ["@useavalon/avalon/types"]
11
+ * }
12
+ * }
13
+ * ```
14
+ */
15
+
16
+ declare module "*.jpg" {
17
+ const src: string;
18
+ export default src;
19
+ }
20
+
21
+ declare module "*.jpeg" {
22
+ const src: string;
23
+ export default src;
24
+ }
25
+
26
+ declare module "*.png" {
27
+ const src: string;
28
+ export default src;
29
+ }
30
+
31
+ declare module "*.webp" {
32
+ const src: string;
33
+ export default src;
34
+ }
35
+
36
+ declare module "*.avif" {
37
+ const src: string;
38
+ export default src;
39
+ }
40
+
41
+ declare module "*.gif" {
42
+ const src: string;
43
+ export default src;
44
+ }
45
+
46
+ declare module "*.tiff" {
47
+ const src: string;
48
+ export default src;
49
+ }
50
+
51
+ declare module "*.svg" {
52
+ const src: string;
53
+ export default src;
54
+ }
55
+
56
+ // vite-imagetools srcset output
57
+ interface ImageToolsSrcset {
58
+ src: string;
59
+ srcset: string;
60
+ width: number;
61
+ height: number;
62
+ }
63
+
64
+ declare module "*&as=srcset" {
65
+ const srcset: ImageToolsSrcset;
66
+ export default srcset;
67
+ }
68
+
69
+ declare module "*?as=srcset" {
70
+ const srcset: ImageToolsSrcset;
71
+ export default srcset;
72
+ }
73
+
74
+ // vite-imagetools picture output (multiple formats)
75
+ interface ImageToolsPicture {
76
+ sources: Record<string, ImageToolsSrcset>;
77
+ img: ImageToolsSrcset;
78
+ }
79
+
80
+ declare module "*&as=picture" {
81
+ const picture: ImageToolsPicture;
82
+ export default picture;
83
+ }
84
+
85
+ declare module "*?as=picture" {
86
+ const picture: ImageToolsPicture;
87
+ export default picture;
88
+ }
89
+
90
+ // vite-imagetools metadata output
91
+ interface ImageToolsMetadata {
92
+ src: string;
93
+ width: number;
94
+ height: number;
95
+ format: string;
96
+ }
97
+
98
+ declare module "*&as=metadata" {
99
+ const metadata: ImageToolsMetadata;
100
+ export default metadata;
101
+ }
102
+
103
+ declare module "*?as=metadata" {
104
+ const metadata: ImageToolsMetadata;
105
+ export default metadata;
106
+ }
@@ -1,22 +1,22 @@
1
- /**
2
- * Avalon type definitions.
3
- *
4
- * Include this in your tsconfig.json `types` array to get island prop support:
5
- *
6
- * ```json
7
- * {
8
- * "compilerOptions": {
9
- * "types": ["@useavalon/avalon/types"]
10
- * }
11
- * }
12
- * ```
13
- */
14
-
15
- // Re-export island prop types
16
- export * from './island-prop.d.ts';
17
-
18
- // Import JSX augmentations (side-effect import for type augmentation)
19
- import './island-jsx.d.ts';
20
-
21
- // Import image type declarations
22
- import './image.d.ts';
1
+ /**
2
+ * Avalon type definitions.
3
+ *
4
+ * Include this in your tsconfig.json `types` array to get island prop support:
5
+ *
6
+ * ```json
7
+ * {
8
+ * "compilerOptions": {
9
+ * "types": ["@useavalon/avalon/types"]
10
+ * }
11
+ * }
12
+ * ```
13
+ */
14
+
15
+ // Re-export island prop types
16
+ export * from './island-prop.d.ts';
17
+
18
+ // Import JSX augmentations (side-effect import for type augmentation)
19
+ import './island-jsx.d.ts';
20
+
21
+ // Import image type declarations
22
+ import './image.d.ts';
@@ -1,33 +1,33 @@
1
- /**
2
- * JSX augmentation for the `island` prop.
3
- *
4
- * Automatically included via tsconfig.json `compilerOptions.types`.
5
- */
6
-
7
- import type { IslandDirective } from './island-prop.d.ts';
8
-
9
- declare module 'preact' {
10
- namespace JSX {
11
- interface IntrinsicAttributes {
12
- island?: IslandDirective;
13
- }
14
- }
15
- }
16
-
17
- // Augment the global JSX namespace so the `island` prop is accepted on
18
- // non-Preact components (Svelte, Solid) when used in a Preact JSX context.
19
- declare global {
20
- namespace JSX {
21
- interface IntrinsicAttributes {
22
- island?: IslandDirective;
23
- }
24
- }
25
- }
26
-
27
- // Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
28
- declare module '@vue/runtime-core' {
29
- interface ComponentCustomProps {
30
- island?: IslandDirective;
31
- }
32
- }
33
-
1
+ /**
2
+ * JSX augmentation for the `island` prop.
3
+ *
4
+ * Automatically included via tsconfig.json `compilerOptions.types`.
5
+ */
6
+
7
+ import type { IslandDirective } from './island-prop.d.ts';
8
+
9
+ declare module 'preact' {
10
+ namespace JSX {
11
+ interface IntrinsicAttributes {
12
+ island?: IslandDirective;
13
+ }
14
+ }
15
+ }
16
+
17
+ // Augment the global JSX namespace so the `island` prop is accepted on
18
+ // non-Preact components (Svelte, Solid) when used in a Preact JSX context.
19
+ declare global {
20
+ namespace JSX {
21
+ interface IntrinsicAttributes {
22
+ island?: IslandDirective;
23
+ }
24
+ }
25
+ }
26
+
27
+ // Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
28
+ declare module '@vue/runtime-core' {
29
+ interface ComponentCustomProps {
30
+ island?: IslandDirective;
31
+ }
32
+ }
33
+
@@ -1,20 +1,20 @@
1
- /**
2
- * Type augmentation for the `island` prop on island components.
3
- *
4
- * When importing a component from the islands directory and using it in a page,
5
- * you can pass an `island` prop to control hydration behavior. The Vite transform
6
- * plugin intercepts this at build time and converts it to a renderIsland() call.
7
- *
8
- * Usage:
9
- * import Counter from '../islands/Counter.tsx';
10
- * <Counter island={{ condition: 'on:interaction' }} someProp={42} />
11
- */
12
-
13
- export interface IslandDirective {
14
- /** Hydration condition */
15
- condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
16
- /** Force SSR-only rendering without client hydration */
17
- ssrOnly?: boolean;
18
- /** Whether to render server-side (default: true) */
19
- ssr?: boolean;
20
- }
1
+ /**
2
+ * Type augmentation for the `island` prop on island components.
3
+ *
4
+ * When importing a component from the islands directory and using it in a page,
5
+ * you can pass an `island` prop to control hydration behavior. The Vite transform
6
+ * plugin intercepts this at build time and converts it to a renderIsland() call.
7
+ *
8
+ * Usage:
9
+ * import Counter from '../islands/Counter.tsx';
10
+ * <Counter island={{ condition: 'on:interaction' }} someProp={42} />
11
+ */
12
+
13
+ export interface IslandDirective {
14
+ /** Hydration condition */
15
+ condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
16
+ /** Force SSR-only rendering without client hydration */
17
+ ssrOnly?: boolean;
18
+ /** Whether to render server-side (default: true) */
19
+ ssr?: boolean;
20
+ }
@@ -1,6 +1,6 @@
1
- import type { ComponentType } from 'preact';
2
-
3
- declare module '*.mdx' {
4
- const MDXComponent: ComponentType<Record<string, unknown>>;
5
- export default MDXComponent;
6
- }
1
+ import type { ComponentType } from 'preact';
2
+
3
+ declare module '*.mdx' {
4
+ const MDXComponent: ComponentType<Record<string, unknown>>;
5
+ export default MDXComponent;
6
+ }
@@ -1,49 +1,49 @@
1
- /**
2
- * Global URLPattern type declaration.
3
- * URLPattern is available at runtime in Node 22+, Bun, and Deno,
4
- * but TypeScript's lib.dom.d.ts may not include it in all configurations.
5
- */
6
- declare class URLPattern {
7
- constructor(init?: URLPatternInit | string, baseURL?: string);
8
- readonly protocol: string;
9
- readonly username: string;
10
- readonly password: string;
11
- readonly hostname: string;
12
- readonly port: string;
13
- readonly pathname: string;
14
- readonly search: string;
15
- readonly hash: string;
16
- test(input?: URLPatternInput, baseURL?: string): boolean;
17
- exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null;
18
- }
19
-
20
- interface URLPatternInit {
21
- baseURL?: string;
22
- username?: string;
23
- password?: string;
24
- hostname?: string;
25
- port?: string;
26
- pathname?: string;
27
- search?: string;
28
- hash?: string;
29
- protocol?: string;
30
- }
31
-
32
- type URLPatternInput = URLPatternInit | string;
33
-
34
- interface URLPatternComponentResult {
35
- input: string;
36
- groups: Record<string, string | undefined>;
37
- }
38
-
39
- interface URLPatternResult {
40
- inputs: [URLPatternInput, string?];
41
- protocol: URLPatternComponentResult;
42
- username: URLPatternComponentResult;
43
- password: URLPatternComponentResult;
44
- hostname: URLPatternComponentResult;
45
- port: URLPatternComponentResult;
46
- pathname: URLPatternComponentResult;
47
- search: URLPatternComponentResult;
48
- hash: URLPatternComponentResult;
49
- }
1
+ /**
2
+ * Global URLPattern type declaration.
3
+ * URLPattern is available at runtime in Node 22+, Bun, and Deno,
4
+ * but TypeScript's lib.dom.d.ts may not include it in all configurations.
5
+ */
6
+ declare class URLPattern {
7
+ constructor(init?: URLPatternInit | string, baseURL?: string);
8
+ readonly protocol: string;
9
+ readonly username: string;
10
+ readonly password: string;
11
+ readonly hostname: string;
12
+ readonly port: string;
13
+ readonly pathname: string;
14
+ readonly search: string;
15
+ readonly hash: string;
16
+ test(input?: URLPatternInput, baseURL?: string): boolean;
17
+ exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null;
18
+ }
19
+
20
+ interface URLPatternInit {
21
+ baseURL?: string;
22
+ username?: string;
23
+ password?: string;
24
+ hostname?: string;
25
+ port?: string;
26
+ pathname?: string;
27
+ search?: string;
28
+ hash?: string;
29
+ protocol?: string;
30
+ }
31
+
32
+ type URLPatternInput = URLPatternInit | string;
33
+
34
+ interface URLPatternComponentResult {
35
+ input: string;
36
+ groups: Record<string, string | undefined>;
37
+ }
38
+
39
+ interface URLPatternResult {
40
+ inputs: [URLPatternInput, string?];
41
+ protocol: URLPatternComponentResult;
42
+ username: URLPatternComponentResult;
43
+ password: URLPatternComponentResult;
44
+ hostname: URLPatternComponentResult;
45
+ port: URLPatternComponentResult;
46
+ pathname: URLPatternComponentResult;
47
+ search: URLPatternComponentResult;
48
+ hash: URLPatternComponentResult;
49
+ }
@@ -1,11 +1,11 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_APP_TITLE: string;
5
- // more env variables...
6
- }
7
-
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv;
10
- readonly hot?: import('vite/types/hot').ViteHotContext;
11
- }
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_TITLE: string;
5
+ // more env variables...
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv;
10
+ readonly hot?: import('vite/types/hot').ViteHotContext;
11
+ }