import type { Program } from "acorn"; /** * True when a FIRST-PARTY file is named like a client module. Callers that have * a logger use this to warn when such a file carries no `"use client"` * directive. Package files are excluded: a dependency's layout is its own * business, and `.client` there routinely means a build-CONDITION variant with * no relation to `"use client"`. */ export declare function looksLikeClientFilename(moduleId: string | undefined): boolean; export type ParseFn = (source: string, options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean; }) => Program; export type DetectClientModuleOpts = { /** Module source text. If absent or empty, only the filename pattern applies. */ source?: string; /** Module identifier / file path. If absent, only the source check applies. */ moduleId?: string; /** * Optional AST producer. When provided (the build's transformer plugin * passes Rollup's `this.parse`), the helper parses with JSX/TS awareness * and inspects directives via {@link analyzeDirectives}. When omitted * (dev-server file watcher, the worker react-loader, the configurable * `loader.*` defaults), the helper falls back to the parser-free * char-scanner from {@link sourceHasTopLevelClientDirective}. Both paths * agree on every well-authored case. */ parseFn?: ParseFn; }; /** * Decides whether a module is a React client component. * * A module is client if and ONLY IF its source declares a top-of-file * `"use client"` directive — leading whitespace, line/block comments, and a * `"use strict"` prologue tolerated above it (React's contract). * * The filename is deliberately NOT a signal. `Foo.client.tsx` with no directive * is a server module here, exactly as it is under every other React toolchain; * making the name load-bearing would produce files that only work under this * loader. Callers with a logger can use {@link looksLikeClientFilename} to warn * on that case rather than silently guessing. Substring matches against * "client" in identifiers, comments, import paths, or directory names are * likewise rejected. * * Every call site that needs a "is this client?" answer routes through this * helper (transformer, worker react-loader, dev-server file watcher, build * auto-discover, the configurable `loader.*` defaults in * `config/defaults.tsx`), so the answer is the same for the same input at * every layer. */ export declare function detectClientModule({ source, moduleId: _moduleId, parseFn, }: DetectClientModuleOpts): boolean; //# sourceMappingURL=detectClientModule.d.ts.map