@astropub/vite-plugin-file
Version:
A Vite plugin for seamless access to file metadata and data streams, supporting modern Web API interfaces like Blob, File, and ArrayBuffer
47 lines (40 loc) • 932 B
TypeScript
global {
declare module "*?file" {
// properties
export const name: string
export const type: string
export const size: number
export const lastModified: number
// computed properties
export const headers: Headers
// methods
export const arrayBuffer: () => Promise<ArrayBuffer>
export const blob: () => Promise<Blob>
export const file: () => Promise<File>
export const json: <T>() => Promise<T>
export const response: () => Response
export const stream: () => ReadableStream
export const text: () => Promise<string>
export default {
name,
type,
size,
lastModified,
headers,
arrayBuffer,
blob,
file,
json,
response,
stream,
text,
}
}
}
declare const plugin: () => {
name: "vite-plugin-file"
enforce: "pre"
resolveId(source: string, importer?: string): Promise<string | undefined>
load(id: string): { code: string } | undefined
}
export default plugin