import type { Bound } from 'utilium'; import type * as fs from '../node/index.js'; import type * as path from '../path.js'; import type { Handle } from '../vfs/file.js'; import type * as xattr from '../vfs/xattr.js'; import type { Credentials, CredentialsInit } from './credentials.js'; /** * Symbol used for context branding * @internal @hidden */ declare const kIsContext: unique symbol; /** * A context used for FS operations * @category Contexts */ export interface FSContext { /** The unique ID of the context */ readonly [kIsContext]: boolean; /** The unique ID of the context */ readonly id: number; /** * The absolute root path of the context * * Note the parent's root is not considered */ root: string; /** The current working directory of the context */ pwd: string; /** The credentials of the context, used for access checks */ readonly credentials: Credentials; /** A map of open file descriptors to their handles */ readonly descriptors: Map; /** The parent context, if any. */ readonly parent: FSContext | null; /** The child contexts */ readonly children: FSContext[]; } /** * maybe an FS context */ export type V_Context = unknown; /** * Allows you to restrict operations to a specific root path and set of credentials. * @category Contexts */ export interface BoundContext extends FSContext { fs: Bound & { promises: Bound; xattr: Bound; }; /** Path functions, bound to the context */ path: Bound; /** Creates a new child context with this context as the parent */ bind(init: ContextInit): BoundContext; /** The parent context, if any. */ parent: FSContext; } /** * @category Contexts */ export interface ContextInit { root?: string; pwd?: string; credentials?: CredentialsInit; } /** * The default/global context. * @internal @hidden * @category Contexts */ export declare const defaultContext: FSContext; export declare function contextOf($: unknown): FSContext; /** * Create a blank FS Context * @internal * @category Contexts * @todo Make sure parent root can't be escaped * * This exists so that `kIsContext` is not exported and to make sure the context is "secure". */ export declare function createChildContext(parent: FSContext, init?: ContextInit): FSContext & { parent: FSContext; }; export {};