UNPKG

@sqliteai/sqlite-js

Version:

SQLite JS extension for Node.js - Custom SQLite functions in JavaScript

85 lines (82 loc) 2.65 kB
/** * Supported platform identifiers */ type Platform = 'darwin-arm64' | 'darwin-x86_64' | 'linux-arm64' | 'linux-arm64-musl' | 'linux-x86_64' | 'linux-x86_64-musl' | 'win32-x86_64'; /** * Detects if the system uses musl libc (Alpine Linux, etc.) * Uses multiple detection strategies for reliability */ declare function isMusl(): boolean; /** * Gets the current platform identifier * @throws {Error} If the platform is unsupported */ declare function getCurrentPlatform(): Platform; /** * Gets the package name for the current platform */ declare function getPlatformPackageName(): string; /** * Gets the binary filename for the current platform */ declare function getBinaryName(): string; /** * Error thrown when the SQLite JS extension cannot be found */ declare class ExtensionNotFoundError extends Error { constructor(message: string); } /** * Gets the absolute path to the SQLite JS extension binary for the current platform * * @returns Absolute path to the extension binary (.so, .dylib, or .dll) * @throws {ExtensionNotFoundError} If the extension binary cannot be found * * @example * ```typescript * import { getExtensionPath } from '@sqliteai/sqlite-js'; * * const extensionPath = getExtensionPath(); * // On macOS ARM64: /path/to/node_modules/@sqliteai/sqlite-js-darwin-arm64/js.dylib * ``` */ declare function getExtensionPath(): string; /** * Information about the current platform and extension */ interface ExtensionInfo { /** Current platform identifier (e.g., 'darwin-arm64') */ platform: Platform; /** Name of the platform-specific npm package */ packageName: string; /** Filename of the binary (e.g., 'js.dylib') */ binaryName: string; /** Full path to the extension binary */ path: string; } /** * Gets detailed information about the SQLite JS extension * * @returns Extension information object * * @example * ```typescript * import { getExtensionInfo } from '@sqliteai/sqlite-js'; * * const info = getExtensionInfo(); * console.log(info); * // { * // platform: 'darwin-arm64', * // packageName: '@sqliteai/sqlite-js-darwin-arm64', * // binaryName: 'js.dylib', * // path: '/path/to/js.dylib' * // } * ``` */ declare function getExtensionInfo(): ExtensionInfo; declare const _default: { getExtensionPath: typeof getExtensionPath; getExtensionInfo: typeof getExtensionInfo; ExtensionNotFoundError: typeof ExtensionNotFoundError; }; export { type ExtensionInfo, ExtensionNotFoundError, type Platform, _default as default, getBinaryName, getCurrentPlatform, getExtensionInfo, getExtensionPath, getPlatformPackageName, isMusl };