@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
112 lines (109 loc) • 5.45 kB
TypeScript
import fs, { PathOrFileDescriptor } from 'node:fs';
import { Context } from '../../types/index.js';
import { VirtualFileSystemInterface } from '../../types/vfs.js';
import '@babel/core';
import '@babel/types';
import '@storm-stack/types/shared/error';
import '@stryke/types/base';
import 'magic-string';
import '@storm-software/config-tools/types';
import '@stryke/types/configuration';
import 'hookable';
import '@storm-software/build-tools/types';
import '@storm-software/config/types';
import '@storm-software/esbuild/types';
import '@storm-software/unbuild/types';
import 'c12';
import 'esbuild';
import 'unbuild';
import '@deepkit/type';
import '../../reflection-DTM1oT21.js';
import '@stryke/capnp';
import '@storm-stack/types/shared/log';
import '@stryke/env/get-env-paths';
import '@stryke/types/package-json';
import 'jest-worker';
import 'jiti';
import 'memfs';
import 'unimport';
import '../../types/tsconfig.js';
import '@stryke/types/tsconfig';
import 'typescript';
import 'memfs/lib/volume';
import 'unionfs';
declare const FILE_PREFIX = "file://";
declare function toFilePath(pathOrUrl: PathOrFileDescriptor): string;
declare function cloneFS(originalFS: typeof fs): typeof fs;
/**
* Patches the original file system module to use the virtual file system (VFS) methods.
*
* @param originalFS - The original file system module to patch.
* @param vfs - The virtual file system interface to use for file operations.
* @returns A function to restore the original file system methods.
*/
declare function patchFS(originalFS: typeof fs, vfs: VirtualFileSystemInterface): () => void;
/**
* Case insensitive file systems have discrepancies in how they handle some characters (eg. turkish Upper case I with dot on top - \\u0130)
* This function is used in places where we want to make file name as a key on these systems
* It is possible on mac to be able to refer to file name with I with dot on top as a fileName with its lower case form
* But on windows we cannot. Windows can have fileName with I with dot on top next to its lower case and they can not each be referred with the lowercase forms
* Technically we would want this function to be platform specific as well but
* our api has till now only taken caseSensitive as the only input and just for some characters we don't want to update API and ensure all customers use those api
* We could use upper case and we would still need to deal with the discrepancies but
* we want to continue using lower case since in most cases filenames are lower case and wont need any case changes and avoid having to store another string for the key
* So for this function purpose, we go ahead and assume character I with dot on top it as case sensitive since its very unlikely to use lower case form of that special character
*
* @internal
*/
declare function toFileNameLowerCase(x: string): string;
interface CheckAbsoluteOptions {
type?: "file" | "directory";
}
/**
* Check if the request is an absolute path and if it exists in the file system.
*
* @param request - The request path to check.
* @param vfs - The file system module to use for checking file existence.
* @returns The file path if it exists, otherwise false.
*/
declare function checkAbsolute(request: string, vfs: VirtualFileSystemInterface): string | false;
interface CheckRelativeOptions extends CheckAbsoluteOptions {
parentPath?: string;
}
/**
* Check if the request is a relative path and if it exists in the given paths.
*
* @param context - The context of the virtual file system.
* @param request - The request path to check.
* @param vfs - The file system module to use for checking file existence.
* @param options - Options to specify the type of path to check (file or directory) and the parent path.
* @returns The file path if it exists, otherwise false.
*/
declare function checkRelative(context: Context, request: string, vfs: VirtualFileSystemInterface, options?: CheckRelativeOptions): string | false;
/**
* Check if the file exists with different variants (index, extensions).
*
* @param request - The request path to check.
* @param vfs - The file system module to use for checking file existence.
* @returns The file path if it exists, otherwise false.
*/
declare function checkVariants(request: string, vfs: VirtualFileSystemInterface, parentPath?: string): string | false;
/**
* Check if the index file exists in the given request path.
*
* @param request - The request path to check.
* @param vfs - The file system module to use for checking file existence.
* @returns The index file path if it exists, otherwise false.
*/
declare function checkIndex(request: string, vfs: VirtualFileSystemInterface): string | false;
/**
* Check if the file exists with different extensions.
*
* @param request - The request path to check.
* @param vfs - The file system module to use for checking file existence.
* @returns The file path if it exists with any of the checked extensions, otherwise false.
*/
declare function checkExtensions(request: string, vfs: VirtualFileSystemInterface): string | false;
declare type __ΩCheckAbsoluteOptions = any[];
declare type __ΩCheckRelativeOptions = any[];
export { type CheckAbsoluteOptions, type CheckRelativeOptions, FILE_PREFIX, type __ΩCheckAbsoluteOptions, type __ΩCheckRelativeOptions, checkAbsolute, checkExtensions, checkIndex, checkRelative, checkVariants, cloneFS, patchFS, toFileNameLowerCase, toFilePath };