bun-types-no-globals 1.3.3-canary.20251110T140631 → 1.3.3-canary.20251112T140644
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/lib/index.d.ts +0 -1
- package/package.json +1 -1
- package/lib/experimental.d.ts +0 -278
package/lib/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
/// <reference path="./deprecated.d.ts" />
|
|
19
19
|
/// <reference path="./redis.d.ts" />
|
|
20
20
|
/// <reference path="./shell.d.ts" />
|
|
21
|
-
/// <reference path="./experimental.d.ts" />
|
|
22
21
|
/// <reference path="./serve.d.ts" />
|
|
23
22
|
/// <reference path="./sql.d.ts" />
|
|
24
23
|
/// <reference path="./security.d.ts" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-types-no-globals",
|
|
3
|
-
"version": "1.3.3-canary.
|
|
3
|
+
"version": "1.3.3-canary.20251112T140644",
|
|
4
4
|
"main": "./generator/index.ts",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"description": "TypeScript type definitions for Bun without global types pollution",
|
package/lib/experimental.d.ts
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
declare module "bun" {
|
|
2
|
-
export namespace __experimental {
|
|
3
|
-
/**
|
|
4
|
-
* Base interface for static site generation route parameters.
|
|
5
|
-
*
|
|
6
|
-
* Supports both single string values and arrays of strings for dynamic route segments.
|
|
7
|
-
* This is typically used for route parameters like `[slug]`, `[...rest]`, or `[id]`.
|
|
8
|
-
*
|
|
9
|
-
* @warning These APIs are experimental and might be moved/changed in future releases.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* // Simple slug parameter
|
|
14
|
-
* type BlogParams = { slug: string };
|
|
15
|
-
*
|
|
16
|
-
* // Multiple parameters
|
|
17
|
-
* type ProductParams = {
|
|
18
|
-
* category: string;
|
|
19
|
-
* id: string;
|
|
20
|
-
* };
|
|
21
|
-
*
|
|
22
|
-
* // Catch-all routes with string arrays
|
|
23
|
-
* type DocsParams = {
|
|
24
|
-
* path: string[];
|
|
25
|
-
* };
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export interface SSGParamsLike {
|
|
29
|
-
[key: string]: string | string[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Configuration object for a single static route to be generated.
|
|
34
|
-
*
|
|
35
|
-
* Each path object contains the parameters needed to render a specific
|
|
36
|
-
* instance of a dynamic route at build time.
|
|
37
|
-
*
|
|
38
|
-
* @warning These APIs are experimental and might be moved/changed in future releases.
|
|
39
|
-
*
|
|
40
|
-
* @template Params - The shape of route parameters for this path
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```tsx
|
|
44
|
-
* // Single blog post path
|
|
45
|
-
* const blogPath: SSGPath<{ slug: string }> = {
|
|
46
|
-
* params: { slug: "my-first-post" }
|
|
47
|
-
* };
|
|
48
|
-
*
|
|
49
|
-
* // Product page with multiple params
|
|
50
|
-
* const productPath: SSGPath<{ category: string; id: string }> = {
|
|
51
|
-
* params: {
|
|
52
|
-
* category: "electronics",
|
|
53
|
-
* id: "laptop-123"
|
|
54
|
-
* }
|
|
55
|
-
* };
|
|
56
|
-
*
|
|
57
|
-
* // Documentation with catch-all route
|
|
58
|
-
* const docsPath: SSGPath<{ path: string[] }> = {
|
|
59
|
-
* params: { path: ["getting-started", "installation"] }
|
|
60
|
-
* };
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export interface SSGPath<Params extends SSGParamsLike = SSGParamsLike> {
|
|
64
|
-
params: Params;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Array of static paths to be generated at build time.
|
|
69
|
-
*
|
|
70
|
-
* This type represents the collection of all route configurations
|
|
71
|
-
* that should be pre-rendered for a dynamic route.
|
|
72
|
-
*
|
|
73
|
-
* @warning These APIs are experimental and might be moved/changed in future releases.
|
|
74
|
-
*
|
|
75
|
-
* @template Params - The shape of route parameters for these paths
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```tsx
|
|
79
|
-
* // Array of blog post paths
|
|
80
|
-
* const blogPaths: SSGPaths<{ slug: string }> = [
|
|
81
|
-
* { params: { slug: "introduction-to-bun" } },
|
|
82
|
-
* { params: { slug: "performance-benchmarks" } },
|
|
83
|
-
* { params: { slug: "getting-started-guide" } }
|
|
84
|
-
* ];
|
|
85
|
-
*
|
|
86
|
-
* // Mixed parameter types
|
|
87
|
-
* const productPaths: SSGPaths<{ category: string; id: string }> = [
|
|
88
|
-
* { params: { category: "books", id: "javascript-guide" } },
|
|
89
|
-
* { params: { category: "electronics", id: "smartphone-x" } }
|
|
90
|
-
* ];
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export type SSGPaths<Params extends SSGParamsLike = SSGParamsLike> = SSGPath<Params>[];
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Props interface for SSG page components.
|
|
97
|
-
*
|
|
98
|
-
* This interface defines the shape of props that will be passed to your
|
|
99
|
-
* static page components during the build process. The `params` object
|
|
100
|
-
* contains the route parameters extracted from the URL pattern.
|
|
101
|
-
*
|
|
102
|
-
* @warning These APIs are experimental and might be moved/changed in future releases.
|
|
103
|
-
*
|
|
104
|
-
* @template Params - The shape of route parameters for this page
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```tsx
|
|
108
|
-
* // Blog post component props
|
|
109
|
-
* interface BlogPageProps extends SSGPageProps<{ slug: string }> {
|
|
110
|
-
* // params: { slug: string } is automatically included
|
|
111
|
-
* }
|
|
112
|
-
*
|
|
113
|
-
* // Product page component props
|
|
114
|
-
* interface ProductPageProps extends SSGPageProps<{
|
|
115
|
-
* category: string;
|
|
116
|
-
* id: string;
|
|
117
|
-
* }> {
|
|
118
|
-
* // params: { category: string; id: string } is automatically included
|
|
119
|
-
* }
|
|
120
|
-
*
|
|
121
|
-
* // Usage in component
|
|
122
|
-
* function BlogPost({ params }: BlogPageProps) {
|
|
123
|
-
* const { slug } = params; // TypeScript knows slug is a string
|
|
124
|
-
* return <h1>Blog post: {slug}</h1>;
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
export interface SSGPageProps<Params extends SSGParamsLike = SSGParamsLike> {
|
|
129
|
-
params: Params;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* React component type for SSG pages that can be statically generated.
|
|
134
|
-
*
|
|
135
|
-
* This type represents a React component that receives SSG page props
|
|
136
|
-
* and can be rendered at build time. The component can be either a regular
|
|
137
|
-
* React component or an async React Server Component for advanced use cases
|
|
138
|
-
* like data fetching during static generation.
|
|
139
|
-
*
|
|
140
|
-
* @warning These APIs are experimental and might be moved/changed in future releases.
|
|
141
|
-
*
|
|
142
|
-
* @template Params - The shape of route parameters for this page component
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```tsx
|
|
146
|
-
* // Regular synchronous SSG page component
|
|
147
|
-
* const BlogPost: SSGPage<{ slug: string }> = ({ params }) => {
|
|
148
|
-
* return (
|
|
149
|
-
* <article>
|
|
150
|
-
* <h1>Blog Post: {params.slug}</h1>
|
|
151
|
-
* <p>This content was generated at build time!</p>
|
|
152
|
-
* </article>
|
|
153
|
-
* );
|
|
154
|
-
* };
|
|
155
|
-
*
|
|
156
|
-
* // Async React Server Component for data fetching
|
|
157
|
-
* const AsyncBlogPost: SSGPage<{ slug: string }> = async ({ params }) => {
|
|
158
|
-
* // Fetch data during static generation
|
|
159
|
-
* const post = await fetchBlogPost(params.slug);
|
|
160
|
-
* const author = await fetchAuthor(post.authorId);
|
|
161
|
-
*
|
|
162
|
-
* return (
|
|
163
|
-
* <article>
|
|
164
|
-
* <h1>{post.title}</h1>
|
|
165
|
-
* <p>By {author.name}</p>
|
|
166
|
-
* <div dangerouslySetInnerHTML={{ __html: post.content }} />
|
|
167
|
-
* </article>
|
|
168
|
-
* );
|
|
169
|
-
* };
|
|
170
|
-
*
|
|
171
|
-
* // Product page with multiple params and async data fetching
|
|
172
|
-
* const ProductPage: SSGPage<{ category: string; id: string }> = async ({ params }) => {
|
|
173
|
-
* const [product, reviews] = await Promise.all([
|
|
174
|
-
* fetchProduct(params.category, params.id),
|
|
175
|
-
* fetchProductReviews(params.id)
|
|
176
|
-
* ]);
|
|
177
|
-
*
|
|
178
|
-
* return (
|
|
179
|
-
* <div>
|
|
180
|
-
* <h1>{product.name}</h1>
|
|
181
|
-
* <p>Category: {params.category}</p>
|
|
182
|
-
* <p>Price: ${product.price}</p>
|
|
183
|
-
* <div>
|
|
184
|
-
* <h2>Reviews ({reviews.length})</h2>
|
|
185
|
-
* {reviews.map(review => (
|
|
186
|
-
* <div key={review.id}>{review.comment}</div>
|
|
187
|
-
* ))}
|
|
188
|
-
* </div>
|
|
189
|
-
* </div>
|
|
190
|
-
* );
|
|
191
|
-
* };
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
export type SSGPage<Params extends SSGParamsLike = SSGParamsLike> = import("react").ComponentType<
|
|
195
|
-
SSGPageProps<Params>
|
|
196
|
-
>;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* getStaticPaths is Bun's implementation of SSG (Static Site Generation) path determination.
|
|
200
|
-
*
|
|
201
|
-
* This function is called at your app's build time to determine which
|
|
202
|
-
* dynamic routes should be pre-rendered as static pages. It returns an
|
|
203
|
-
* array of path parameters that will be used to generate static pages for
|
|
204
|
-
* dynamic routes (e.g., [slug].tsx, [category]/[id].tsx).
|
|
205
|
-
*
|
|
206
|
-
* The function can be either synchronous or asynchronous, allowing you to
|
|
207
|
-
* fetch data from APIs, databases, or file systems to determine which paths
|
|
208
|
-
* should be statically generated.
|
|
209
|
-
*
|
|
210
|
-
* @warning These APIs are experimental and might be moved/changed in future releases.
|
|
211
|
-
*
|
|
212
|
-
* @template Params - The shape of route parameters for the dynamic route
|
|
213
|
-
*
|
|
214
|
-
* @returns An object containing an array of paths to be statically generated
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```tsx
|
|
218
|
-
* // In pages/blog/[slug].tsx ———————————————————╮
|
|
219
|
-
* export const getStaticPaths: GetStaticPaths<{ slug: string }> = async () => {
|
|
220
|
-
* // Fetch all blog posts from your CMS or API at build time
|
|
221
|
-
* const posts = await fetchBlogPosts();
|
|
222
|
-
*
|
|
223
|
-
* return {
|
|
224
|
-
* paths: posts.map((post) => ({
|
|
225
|
-
* params: { slug: post.slug }
|
|
226
|
-
* }))
|
|
227
|
-
* };
|
|
228
|
-
* };
|
|
229
|
-
*
|
|
230
|
-
* // In pages/products/[category]/[id].tsx
|
|
231
|
-
* export const getStaticPaths: GetStaticPaths<{
|
|
232
|
-
* category: string;
|
|
233
|
-
* id: string;
|
|
234
|
-
* }> = async () => {
|
|
235
|
-
* // Fetch products from database
|
|
236
|
-
* const products = await db.products.findMany({
|
|
237
|
-
* select: { id: true, category: { slug: true } }
|
|
238
|
-
* });
|
|
239
|
-
*
|
|
240
|
-
* return {
|
|
241
|
-
* paths: products.map(product => ({
|
|
242
|
-
* params: {
|
|
243
|
-
* category: product.category.slug,
|
|
244
|
-
* id: product.id
|
|
245
|
-
* }
|
|
246
|
-
* }))
|
|
247
|
-
* };
|
|
248
|
-
* };
|
|
249
|
-
*
|
|
250
|
-
* // In pages/docs/[...path].tsx (catch-all route)
|
|
251
|
-
* export const getStaticPaths: GetStaticPaths<{ path: string[] }> = async () => {
|
|
252
|
-
* // Read documentation structure from file system
|
|
253
|
-
* const docPaths = await getDocumentationPaths('./content/docs');
|
|
254
|
-
*
|
|
255
|
-
* return {
|
|
256
|
-
* paths: docPaths.map(docPath => ({
|
|
257
|
-
* params: { path: docPath.split('/') }
|
|
258
|
-
* }))
|
|
259
|
-
* };
|
|
260
|
-
* };
|
|
261
|
-
*
|
|
262
|
-
* // Synchronous example with static data
|
|
263
|
-
* export const getStaticPaths: GetStaticPaths<{ id: string }> = () => {
|
|
264
|
-
* const staticIds = ['1', '2', '3', '4', '5'];
|
|
265
|
-
*
|
|
266
|
-
* return {
|
|
267
|
-
* paths: staticIds.map(id => ({
|
|
268
|
-
* params: { id }
|
|
269
|
-
* }))
|
|
270
|
-
* };
|
|
271
|
-
* };
|
|
272
|
-
* ```
|
|
273
|
-
*/
|
|
274
|
-
export type GetStaticPaths<Params extends SSGParamsLike = SSGParamsLike> = () => MaybePromise<{
|
|
275
|
-
paths: SSGPaths<Params>;
|
|
276
|
-
}>;
|
|
277
|
-
}
|
|
278
|
-
}
|