import { C as SuggestionAction, D as SymbolTable, E as UnreadFile, S as Suggestion, T as TypeImports, _ as RuleName, a as BaselineResult, b as Severity, c as Finding, d as LayerscopeConfig, f as PresetName, g as ResolutionSource, h as ReferenceKind, i as BaselineEntry, l as Layer, m as Reference, n as AllowEntry, o as Context, p as PresetOptions, r as AnalyzeResult, s as Edge, t as defineConfig, u as LayerRule, v as ScannedDirs, w as SuggestionImpact, x as SourceOption, y as ScopedAllow } from "./define-O7kUyPCq.mjs"; import { t as ProjectConfig } from "./effective-BpkmlFZK.mjs"; import { styleText } from "node:util"; /** The ignore rules of Nuxt, as the module or the CLI reads them from `@nuxt/kit`. */ interface NuxtIgnore { /** `nuxt.options.rootDir`. */ rootDir: string; /** * The root of each layer, with a trailing slash. The module takes them from * `getLayerDirectories()`. The CLI uses the real path of each layer. */ roots: string[]; /** The result of `resolveIgnorePatterns()`: `ignore`, `ignorePrefix` and the root `.nuxtignore`. */ patterns: string[]; /** `nuxt.options.ignoreOptions`, or `null` when it is not set. */ options: Record | null; } /** Bumped on breaking changes to `registry.json`; readers fall back to the `.d.ts` files. */ export declare const REGISTRY_VERSION = 1; /** Relative to the Nuxt build dir. */ export declare const REGISTRY_FILE = "layerscope/registry.json"; type ComponentMode = 'all' | 'client' | 'server'; interface RegistryComponent { /** PascalCase name, without the `Lazy` prefix. */ name: string; /** Absolute path, or a bare module specifier for virtual components. */ file: string; mode: ComponentMode; island: boolean; /** Registered with `app.component()`, so Vue can render it by a name chosen at runtime. */ global: boolean; priority: number; } /** A component that lost to a higher-priority one with the same name. */ interface ShadowedComponent extends RegistryComponent { /** File of the component Nuxt registered instead. */ shadowedBy: string; } /** * A layout, a route middleware, a server route or an auto-import that lost to a file of the same * name in another layer (an auto-import: to any auto-import of the same name). A page adds * `routes`. */ interface ShadowedFile { /** * The name that Nuxt gives the layout, the middleware or the auto-import. For a server route, the * route, with the method and the env when the name of the file sets them: `GET /api/hello (dev)`. */ name: string; /** Absolute path of the file that Nuxt does not use. */ file: string; /** The file that Nuxt uses instead. For an auto-import it can also be a package or an import path. */ shadowedBy: string; } /** A layout or a named route middleware that Nuxt uses, with its name. */ interface NamedFile { name: string; /** Absolute path once aliases are resolved, or a bare module specifier. */ file: string; } /** A page that lost to a page with the same path in the pages dir of another layer. */ interface ShadowedPage extends ShadowedFile { /** The path of the file relative to the pages dir, without the extension. */ name: string; /** The full paths of the routes that Nuxt makes from the file that it uses. */ routes: string[]; } interface RegistryComponentDir { path: string; /** Glob Nuxt scans the dir with, relative to `path`. */ pattern: string | string[]; ignore: string[]; /** Files matched when the registry was written, for the stale check. */ files: string[]; } interface RegistryImportDir { /** The dir that Nuxt or Nitro scans for auto-imports, or the glob when the user gave one. */ dir: string; /** The absolute globs that the scan used for the dir. */ globs: string[]; /** * The scan of the dir: `nuxt` for the app, `nitro` for the auto-import scan of Nitro. Only the * scan of the app uses the ignore rules of Nuxt. */ scanner: 'nuxt' | 'nitro'; /** Files that the globs matched when the registry was written, before Nuxt's ignore rules. */ files: string[]; } interface RegistryImport { /** Name the symbol is auto-imported as. */ name: string; /** Absolute path once aliases are resolved, or a bare module specifier. */ from: string; } interface Registry { version: typeof REGISTRY_VERSION; generator: { name: string; version: string; nuxt: string; }; /** Highest priority first, as Nuxt orders `_layers`. Older releases wrote no `modulesDir` or `publicDir`. */ layers: Layer[]; components: RegistryComponent[]; shadowedComponents: ShadowedComponent[]; shadowedLayouts: ShadowedFile[]; shadowedMiddleware: ShadowedFile[]; shadowedPages: ShadowedPage[]; /** The auto-imports of the app that Nuxt does not use. */ shadowedImports: ShadowedFile[]; /** The route files that Nitro does not use, because the same path in another layer wins. */ shadowedServerRoutes: ShadowedFile[]; /** The auto-imports of Nitro from a file in a server dir that Nitro does not use. */ shadowedServerImports: ShadowedFile[]; componentDirs: RegistryComponentDir[]; /** * Every dir that Nuxt or Nitro scans for auto-imports, for the stale check. `null` when the * module could not read them (it printed the reason): the check is off for this file. */ importDirs: RegistryImportDir[] | null; /** The ignore rules of Nuxt. The stale check skips the new files that they match. */ nuxtIgnore: NuxtIgnore; /** The project uses Nuxt Content, which can render any component by its name from a content file. */ nuxtContent: boolean; imports: Record; /** The layouts that Nuxt uses. Code uses a layout by its name. */ layouts: NamedFile[]; /** The named route middleware that Nuxt uses. A page cannot use global middleware by its name. */ middleware: NamedFile[]; /** The `layerscope` key of `nuxt.config`, when it sets layers or rules. Added in 0.1.0. */ config?: ProjectConfig; } type OwnerLookup = (file: string) => Layer | null; /** References found in one source file. Offsets point into the original file. */ interface FileScan { /** Identifiers without a local binding. */ free: Named[]; /** The names in `typeof x` in a type that have no local binding: uses in a type position. */ typeFree: Named[]; /** Identifiers a template reads from the component instance (`_ctx.x`). */ templateIdents: Named[]; components: Named[]; /** * The identifiers that are the first argument of `h()`, as in `h(CartSummary)`. In a `.vue`, * `.jsx` or `.tsx` file, Nuxt changes such a name to its component by its text, whatever binds it. */ renderArgs: Named[]; /** * Component tags in JSX, such as `` or ``, with the name in * PascalCase: not an HTML or SVG element, not `Fragment`, not a local binding and not a JavaScript * global such as `Map`. Vue's JSX plugin compiles each to `resolveComponent()`, and outside the * `server/` dir Nuxt changes it to an import. */ jsxTags: Named[]; /** * The names in ``. A name that is not in the symbol table gives no finding: * the generated .d.ts files do not list island components. */ islands: Named[]; /** * The layout names that are fixed strings: `layout` in `definePageMeta()`, also in its object * form `{ name }`, and the first argument of `setPageLayout()`. */ layouts: Named[]; /** The route middleware names in `middleware` of `definePageMeta()` that are fixed strings. */ middleware: Named[]; /** Offsets of `` bound to a runtime value. */ dynamicComponents: number[]; /** * Offsets of runtime component choices that give no finding: `` bound to a * `string` prop with an element default (a parent can still pass a global component name), * `` and `resolveDynamicComponent(x)`. The file still counts as a user. */ quietDynamicComponents: number[]; imports: ImportRef[]; /** Parts of the file that layerscope cannot read. Everything else in the file is still scanned. */ unread: Unread[]; /** Set when the file could not be parsed; nothing else in it was analyzed. */ error: { message: string; offset: number; } | null; } interface Unread { /** Short name of the part, for the finding: `