@naturaldesign/dev 0.0.0-stage → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ export interface Node {
2
+ type: string;
3
+ start?: number | null;
4
+ end?: number | null;
5
+ loc?: {
6
+ start: {
7
+ line: number;
8
+ column: number;
9
+ };
10
+ } | null;
11
+ [key: string]: unknown;
12
+ }
13
+ /** Parses JS/TS with JSX; null when the file does not parse at all (errorRecovery keeps most broken files). */
14
+ export declare function parseModule(code: string): Node | null;
15
+ /** The Program node of a parsed File. */
16
+ export declare function programOf(file: Node): Node;
17
+ /** Depth-first walk over every child node. `enter` returning false skips the node's children. */
18
+ export declare function walk(node: Node | null | undefined, enter: (node: Node, parent: Node | null) => boolean | void, parent?: Node | null): void;
19
+ /** `Foo`, `Foo.Bar`, `ns:tag` for a JSX element name node. */
20
+ export declare function jsxName(name: Node): string;
21
+ /** Whether a file's directive prologue says 'use client'. */
22
+ export declare function hasUseClient(file: Node): boolean;
23
+ /** A literal's static value (string, number, boolean, null, negative numbers, plain template strings); undefined when not static. */
24
+ export declare function staticValue(node: Node | null | undefined): string | number | boolean | null | undefined;
@@ -0,0 +1,50 @@
1
+ import { type ComponentDecl } from './owners';
2
+ import { type Node } from './ast';
3
+ interface BabelApi {
4
+ types: {
5
+ jsxAttribute: (name: unknown, value: unknown) => unknown;
6
+ jsxIdentifier: (name: string) => unknown;
7
+ stringLiteral: (value: string) => unknown;
8
+ };
9
+ }
10
+ interface PluginOptions {
11
+ root?: string;
12
+ always?: boolean;
13
+ calls?: boolean;
14
+ owners?: boolean;
15
+ exclude?: string[];
16
+ }
17
+ interface Attribute {
18
+ type: string;
19
+ name?: {
20
+ type: string;
21
+ name?: string;
22
+ };
23
+ }
24
+ interface OpeningPath {
25
+ node: {
26
+ start?: number | null;
27
+ name: Node;
28
+ attributes: Attribute[];
29
+ loc?: {
30
+ start: {
31
+ line: number;
32
+ column: number;
33
+ };
34
+ } | null;
35
+ };
36
+ }
37
+ interface PluginState {
38
+ filename?: string;
39
+ ndComponents?: ComponentDecl[];
40
+ }
41
+ export default function naturalDesignBabel(api: BabelApi, options?: PluginOptions): {
42
+ name: string;
43
+ visitor: {
44
+ Program(path: {
45
+ node: Node;
46
+ }, state: PluginState): void;
47
+ JSXOpeningElement(path: OpeningPath, state: PluginState): void;
48
+ };
49
+ };
50
+ export {};
@@ -0,0 +1,35 @@
1
+ import { type Node } from '../ast';
2
+ import type { PropDefault, PropEntry, PropKind } from './types';
3
+ export type TypeScope = Map<string, Node>;
4
+ /**
5
+ * Top-level interfaces and type aliases of a script, exported or not; and (keyed `value:<name>`)
6
+ * the cva / tailwind-variants calls `VariantProps<typeof name>` reads its props from.
7
+ */
8
+ export declare function typeScope(program: Node): TypeScope;
9
+ /** Type arguments of a call or type reference (Babel 7 says typeParameters, Babel 8 typeArguments). */
10
+ export declare function typeArguments(node: Node | null | undefined): Node[];
11
+ interface Kind {
12
+ type: PropKind;
13
+ options?: string[];
14
+ }
15
+ /** Classifies one prop's type node. */
16
+ export declare function classifyType(type: Node | null | undefined, scope: TypeScope, depth?: number): Kind;
17
+ /** One kind for a union: all string literals → enum, all booleans → boolean, strings and literals → text, a slot anywhere → slot. */
18
+ export declare function mergeKinds(kinds: Kind[]): Kind;
19
+ /** Props of a type node (literal, local interface/alias, intersection, `PropsWithChildren<…>`); null when nothing about it resolves locally. */
20
+ export declare function propsFromType(type: Node | null | undefined, scope: TypeScope, depth?: number): PropEntry[] | null;
21
+ /** Later lists win on a name clash, as an interface's own members override what it extends. */
22
+ export declare function mergeProps(lists: PropEntry[][]): PropEntry[];
23
+ /** `{ size = 'md', title, ...rest }`: names and static defaults, in order. */
24
+ export declare function patternDefaults(pattern: Node | null | undefined): {
25
+ name: string;
26
+ default?: PropDefault;
27
+ }[];
28
+ /** A prop's kind guessed from its default, for untyped code. */
29
+ export declare function kindOfValue(value: PropDefault | undefined): PropKind;
30
+ /** Typed props with destructuring defaults laid over them; untyped names become props of their default's kind. */
31
+ export declare function withDefaults(typed: PropEntry[] | null, defaults: {
32
+ name: string;
33
+ default?: PropDefault;
34
+ }[]): PropEntry[];
35
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ComponentDecl } from '../owners';
2
+ import { type TypeScope } from './babel-props';
3
+ import type { ComponentEntry, PropEntry } from './types';
4
+ export declare function reactPropsFromBabel(component: ComponentDecl, scope: TypeScope): PropEntry[];
5
+ /** Exported React components of one module, from its source text. */
6
+ export declare function indexReactWithBabel(code: string, file: string, rel: string): ComponentEntry[];
@@ -0,0 +1,8 @@
1
+ import type { ComponentEntry } from './types';
2
+ export interface TsIndexer {
3
+ index(files: string[]): Map<string, ComponentEntry[]>;
4
+ /** The React components an installed package exports, from its type declarations. */
5
+ indexPackage(name: string): ComponentEntry[];
6
+ }
7
+ /** The project's TypeScript, wrapped; null when the project has no `typescript` package. */
8
+ export declare function tsIndexerFor(root: string): TsIndexer | null;
@@ -0,0 +1,19 @@
1
+ import type { ComponentEntry } from './types';
2
+ export declare const COMPONENT_FOLDERS: string[];
3
+ export interface IndexOptions {
4
+ /** Folders to scan, relative to the root (default COMPONENT_FOLDERS). */
5
+ folders?: string[];
6
+ /** Use the project's `typescript` for React props (default true). */
7
+ typescript?: boolean;
8
+ /** Installed npm packages whose exported React components join the index (read from their type declarations). */
9
+ packages?: string[];
10
+ }
11
+ export declare function isComponentSource(file: string): boolean;
12
+ /** Whether a file is inside one of the component folders (and so belongs in the index). */
13
+ export declare function inComponentFolder(root: string, file: string, folders?: string[]): boolean;
14
+ /** Every component file under the root's component folders, absolute and sorted. */
15
+ export declare function componentFiles(root: string, folders?: string[]): string[];
16
+ /** Indexes the given files (absolute). React files share one TypeScript program. */
17
+ export declare function indexFiles(root: string, files: string[], options?: IndexOptions): Map<string, ComponentEntry[]>;
18
+ /** The project's components: one entry per exported component in the component folders, then the listed packages'. */
19
+ export declare function indexComponents(projectRoot: string, options?: IndexOptions): ComponentEntry[];
@@ -0,0 +1,4 @@
1
+ import type { ComponentEntry } from './types';
2
+ export declare function indexSvelte(source: string, file: string, rel: string): ComponentEntry[];
3
+ export declare function indexVue(source: string, file: string, rel: string): ComponentEntry[];
4
+ export declare function indexAstro(source: string, file: string, rel: string): ComponentEntry[];
@@ -0,0 +1,24 @@
1
+ export type Framework = 'react' | 'svelte' | 'vue' | 'astro';
2
+ /** How the inspector edits a prop: enum (a menu of options), text, number, boolean, slot (children-like content), other (read-only "from code"). */
3
+ export type PropKind = 'enum' | 'text' | 'number' | 'boolean' | 'slot' | 'other';
4
+ export type PropDefault = string | number | boolean | null;
5
+ export interface PropEntry {
6
+ name: string;
7
+ type: PropKind;
8
+ /** The string literals of an enum prop, in declaration order. */
9
+ options?: string[];
10
+ optional: boolean;
11
+ /** A static default from the source (destructuring default, withDefaults, `export let x = …`). */
12
+ default?: PropDefault;
13
+ }
14
+ export interface ComponentEntry {
15
+ name: string;
16
+ /** Path relative to the project root, `/`-separated. */
17
+ file: string;
18
+ /** `default` or the exported name. Svelte, Vue and Astro components are always `default`. */
19
+ exportName: string;
20
+ framework: Framework;
21
+ props: PropEntry[];
22
+ /** Set for a component an installed npm package exports: `file` is then the package name (read-only). */
23
+ package?: string;
24
+ }
@@ -0,0 +1,19 @@
1
+ import type { Framework } from '../component-index/types';
2
+ export interface EntryOptions {
3
+ /** Absolute path of the component file. */
4
+ file: string;
5
+ exportName: string;
6
+ framework: Framework;
7
+ /** Absolute paths (or bare specifiers) of global stylesheets to bundle. */
8
+ stylesheets: string[];
9
+ /** Absolute path of natural.config.*, whose `decorator` wraps the component (React only). */
10
+ configFile: string | null;
11
+ /** Props merged under the ones `mount` receives. */
12
+ props: Record<string, unknown>;
13
+ /** Meta exported as-is, for the app's bookkeeping. */
14
+ meta: Record<string, unknown>;
15
+ }
16
+ /** The entry module for one component; null for frameworks that cannot mount in a browser (Astro). */
17
+ export declare function entryModule(options: EntryOptions): string | null;
18
+ /** The framework runtime packages an entry imports: if one of these is stubbed, nothing can render. */
19
+ export declare const RUNTIME_PACKAGES: Record<Framework, string[]>;
@@ -0,0 +1,23 @@
1
+ import type { BundleOutput } from './vite';
2
+ export interface Esbuild {
3
+ build: (options: Record<string, unknown>) => Promise<{
4
+ outputFiles?: {
5
+ path: string;
6
+ contents: Uint8Array;
7
+ }[];
8
+ warnings: {
9
+ text: string;
10
+ }[];
11
+ }>;
12
+ version?: string;
13
+ }
14
+ export interface EsbuildDeriveInput {
15
+ root: string;
16
+ out: string;
17
+ entryCode: string;
18
+ /** Extra folders to resolve bare imports from (the app's bundled react/react-dom at the partial rung). */
19
+ nodePaths: string[];
20
+ }
21
+ export declare function bundleWithEsbuild(esbuild: Esbuild, input: EsbuildDeriveInput): Promise<BundleOutput & {
22
+ stubs: string[];
23
+ }>;
@@ -0,0 +1,34 @@
1
+ import type { Framework } from '../component-index/types';
2
+ export interface DeriveOptions {
3
+ /** Project root (the folder with package.json). */
4
+ root: string;
5
+ /** Component file, absolute or relative to the root. */
6
+ file: string;
7
+ /** `default` or the exported name. */
8
+ exportName: string;
9
+ /** Output folder; receives component.js and component.css. */
10
+ out: string;
11
+ /** Props baked in as `defaultProps` (mount's props are laid over them). */
12
+ props?: Record<string, unknown>;
13
+ /** An esbuild package folder (or a folder whose node_modules has one): the app's sidecar. */
14
+ esbuild?: string;
15
+ /** Extra folders to resolve bare imports from in the esbuild path (the app's bundled react and react-dom). */
16
+ nodePaths?: string[];
17
+ /** Force a bundler (default: Vite when the project has it, esbuild otherwise). */
18
+ bundler?: 'auto' | 'vite' | 'esbuild';
19
+ /** Global stylesheets to bundle, root-relative (default: found from the app's entry). */
20
+ styles?: string[];
21
+ }
22
+ export interface DeriveResult {
23
+ ok: boolean;
24
+ /** Built without the project's dependencies, or with imports stubbed: the `partial` rung. */
25
+ partial: boolean;
26
+ js: string | null;
27
+ css: string | null;
28
+ warnings: string[];
29
+ bundler: 'vite' | 'esbuild' | null;
30
+ framework: Framework | null;
31
+ /** Specifiers replaced by stubs. */
32
+ stubs: string[];
33
+ }
34
+ export declare function derive(options: DeriveOptions): Promise<DeriveResult>;
@@ -0,0 +1,4 @@
1
+ type Process = (css: string, from: string) => Promise<string>;
2
+ /** A function running the project's PostCSS config over a stylesheet, or null when the project has none. */
3
+ export declare function projectPostcss(root: string, warnings: string[]): Promise<Process | null>;
4
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare const NEXT_SHIMS: string[];
2
+ export declare function isShimmed(specifier: string): boolean;
3
+ /** Every specifier a module imports or re-exports from, with the names it takes: `import { A, B as C } from 'x'` → A, B; `import D from 'x'` → default. */
4
+ export declare function importsOf(code: string): Map<string, Set<string>>;
5
+ /** The names a module file takes from a specifier (cached by mtime). */
6
+ export declare function importedNames(importer: string, specifier: string): string[];
7
+ /** An ES module whose default and named exports are all the same forgiving stub. */
8
+ export declare function stubModule(names: string[], label: string): string;
9
+ /** Module code for a shimmed `next/*` (or `server-only`) specifier; `names` are what the importer takes from it (for next/font). */
10
+ export declare function nextShim(specifier: string, names: string[]): string;
@@ -0,0 +1,15 @@
1
+ export interface ViteDeriveInput {
2
+ root: string;
3
+ out: string;
4
+ entryCode: string;
5
+ }
6
+ export interface BundleOutput {
7
+ js: string;
8
+ css: string;
9
+ warnings: string[];
10
+ }
11
+ interface ViteModule {
12
+ build: (config: Record<string, unknown>) => Promise<unknown>;
13
+ }
14
+ export declare function bundleWithVite(vite: ViteModule, input: ViteDeriveInput): Promise<BundleOutput>;
15
+ export {};
@@ -0,0 +1,12 @@
1
+ export { stampJsx, stampable, parseStamp, parseOwner, relativeTo, registrationCode, callExcluded, STAMP_ATTRIBUTE, CALL_ATTRIBUTE, OWNER_ATTRIBUTE } from './stamp';
2
+ export type { StampOptions, StampResult } from './stamp';
3
+ export { exportedComponents, ownerAt, componentNameFromFile } from './owners';
4
+ export type { ComponentDecl } from './owners';
5
+ export { indexComponents, indexFiles, componentFiles, COMPONENT_FOLDERS } from './component-index/scan';
6
+ export type { IndexOptions } from './component-index/scan';
7
+ export type { ComponentEntry, PropEntry, PropKind, PropDefault, Framework } from './component-index/types';
8
+ export { writeDescriptors, descriptorName, NEXT_INDEX_DIR } from './next-index';
9
+ export type { NextDescriptor } from './next-index';
10
+ export { REGISTRY_ID, HOST_ID, HOST_PATH, INDEX_PATH } from './registry';
11
+ export { derive } from './derive/index';
12
+ export type { DeriveOptions, DeriveResult } from './derive/index';
@@ -0,0 +1,24 @@
1
+ export interface NaturalDesignLoaderOptions {
2
+ root?: string;
3
+ /** Component names that must not receive data-nd-call. */
4
+ exclude?: string[];
5
+ /** Call-site stamps on component elements (default true). */
6
+ calls?: boolean;
7
+ /** Owner stamps on host elements (default true). */
8
+ owners?: boolean;
9
+ /** Register exported components of 'use client' files with `window.__nd` (default true). */
10
+ register?: boolean;
11
+ /** Write component descriptors to `.next/natural/index/` (default true). */
12
+ index?: boolean;
13
+ /** Folders the index covers, relative to the root (default: the usual component folders). */
14
+ indexFolders?: string[];
15
+ }
16
+ interface LoaderContext {
17
+ resourcePath: string;
18
+ rootContext?: string;
19
+ mode?: string;
20
+ getOptions?: () => NaturalDesignLoaderOptions;
21
+ callback: (error: Error | null, code?: string, map?: unknown) => void;
22
+ }
23
+ export default function naturalDesignLoader(this: LoaderContext, source: string, map?: unknown): void;
24
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { ComponentEntry } from './component-index/types';
2
+ export declare const NEXT_INDEX_DIR = ".next/natural/index";
3
+ export interface NextDescriptor {
4
+ file: string;
5
+ framework: 'react';
6
+ components: ComponentEntry[];
7
+ }
8
+ /** The descriptor's file name for a project-relative source path: the path, URI-encoded, plus `.json`. */
9
+ export declare function descriptorName(rel: string): string;
10
+ /** Writes (or removes) the descriptors for these files now. */
11
+ export declare function writeDescriptors(root: string, files: string[]): void;
12
+ /** Queues a file the loader just compiled; component files in the component folders get a descriptor shortly after. */
13
+ export declare function scheduleDescriptor(root: string, file: string, folders?: string[]): void;
@@ -0,0 +1,26 @@
1
+ import { type Node } from './ast';
2
+ export interface ComponentDecl {
3
+ /** Display name: the binding's name, or one made from the file name for an anonymous default export. */
4
+ name: string;
5
+ /** `default` or the exported name; what the index calls `exportName` and the owner stamp carries. */
6
+ exportName: string;
7
+ /** A binding that names the component at the end of the module; null for anonymous default exports. */
8
+ localName: string | null;
9
+ /** Source range of the declaration whose body JSX belongs to this component. */
10
+ start: number;
11
+ end: number;
12
+ /** The component function, when there is one (props are its first parameter). */
13
+ fn: Node | null;
14
+ /** The declaring node: a FunctionDeclaration, a VariableDeclarator (for `FC<Props>` annotations) or the default export's expression. */
15
+ node: Node;
16
+ kind: 'function' | 'class';
17
+ }
18
+ export declare function isComponentName(name: string): boolean;
19
+ /** `button-group.tsx` → ButtonGroup; `index.tsx` and `page.tsx` take their folder's name when it says more. */
20
+ export declare function componentNameFromFile(file: string): string;
21
+ /** Exported components of a module, in source order. `file` names anonymous default exports. */
22
+ export declare function exportedComponents(ast: Node, file: string): ComponentDecl[];
23
+ /** The component whose declaration contains a source offset. */
24
+ export declare function ownerAt(components: ComponentDecl[], offset: number): ComponentDecl | null;
25
+ /** One entry per exported component (the owner list can hold a wrapped implementation's range twice). */
26
+ export declare function uniqueComponents(components: ComponentDecl[]): ComponentDecl[];
@@ -0,0 +1,12 @@
1
+ export declare function projectRequire(root: string): NodeRequire;
2
+ /** Resolves a package's entry from the project, or null. `esm` prefers the `import` condition
3
+ * (vite's CJS entry is deprecated and hides its named exports from `import()`). */
4
+ export declare function resolveFromProject(root: string, name: string, esm?: boolean): string | null;
5
+ /** `require` for CommonJS packages (typescript), null when the project does not have it. */
6
+ export declare function requireFromProject<T = unknown>(root: string, name: string): T | null;
7
+ /** `import()` for packages that may be ESM-only (vite), null when the project does not have it. */
8
+ export declare function importFromProject<T = unknown>(root: string, name: string): Promise<T | null>;
9
+ export declare function hasPackage(root: string, name: string): boolean;
10
+ export declare function readJson<T>(file: string): T | null;
11
+ /** The project's version of a package (`18.3.1`), or null. */
12
+ export declare function packageVersion(root: string, name: string): string | null;
@@ -0,0 +1,15 @@
1
+ import type { ComponentEntry, Framework } from './component-index/types';
2
+ export declare const REGISTRY_ID = "virtual:natural-design/registry";
3
+ export declare const HOST_ID = "virtual:natural-design/host";
4
+ export declare const HOST_PATH = "/__natural/host";
5
+ export declare const INDEX_PATH = "/__natural/components.json";
6
+ /** A URL Vite serves for a project file: root-relative inside the root, `/@fs/` outside it. */
7
+ export declare function serveUrl(root: string, file: string): string;
8
+ /** The project's `natural.config.*`, whose `decorator` wraps every rendered component in the app's providers. */
9
+ export declare function naturalConfigFile(root: string): string | null;
10
+ /** The registry module's code. `frameworks` lists those whose runtime the project can resolve. */
11
+ export declare function registryModule(root: string, components: ComponentEntry[], frameworks: Set<Framework>, packages?: string[]): string;
12
+ /** The host page's module: global styles, the registry, the decorator, and `?component=Name&props={…}` for a direct render. */
13
+ export declare function hostModule(root: string, stylesheets: string[], configFile: string | null): string;
14
+ /** The bare host document, before Vite's transformIndexHtml adds its client and the React refresh preamble. */
15
+ export declare function hostHtml(root: string, base: string): string;
@@ -0,0 +1,56 @@
1
+ import MagicString from 'magic-string';
2
+ import { type Node } from './ast';
3
+ export declare const STAMP_ATTRIBUTE = "data-nd-source";
4
+ export declare const CALL_ATTRIBUTE = "data-nd-call";
5
+ export declare const OWNER_ATTRIBUTE = "data-nd-owner";
6
+ export interface StampOptions {
7
+ /** Absolute path of the file being compiled. */
8
+ file: string;
9
+ /** Project root the stamp's path is relative to (the webframe's `root`). */
10
+ root: string;
11
+ /** Give component elements a data-nd-call stamp (default true). */
12
+ calls?: boolean;
13
+ /** Give host elements a data-nd-owner stamp (default true). */
14
+ owners?: boolean;
15
+ /** Components that must not receive the call stamp (they iterate their props, or use exact prop-types). `Foo.Bar` or a bare name, which also matches the last segment. */
16
+ exclude?: string[];
17
+ /** Append a render-registry registration for each exported component, in 'use client' files only (Next, plan 7.1). */
18
+ register?: boolean;
19
+ }
20
+ export interface StampResult {
21
+ code: string;
22
+ map: ReturnType<MagicString['generateMap']>;
23
+ /** How many host elements got a source stamp. */
24
+ count: number;
25
+ /** How many component elements got a call stamp. */
26
+ calls: number;
27
+ /** Names registered with the render registry. */
28
+ registered: string[];
29
+ }
30
+ export declare function relativeTo(root: string, file: string): string;
31
+ /** Whether this is a production build: read at run time (a bundler would otherwise bake its own build-time value in). */
32
+ export declare function productionBuild(): boolean;
33
+ /** Files the plugin may stamp: project JSX/TSX outside node_modules. */
34
+ export declare function stampable(file: string): boolean;
35
+ /** Whether a component element is excluded from call stamps: fragments always, then the user's list. */
36
+ export declare function callExcluded(name: string, exclude?: readonly string[]): boolean;
37
+ /** Component element names: a capitalised identifier or any member expression (`ui.Card`, `motion.div`). */
38
+ export declare function isComponentElement(name: Node): boolean;
39
+ /** The registration statement the Next loader appends to a 'use client' module (plan 7.1, render registry). */
40
+ export declare function registrationCode(entries: {
41
+ name: string;
42
+ local: string;
43
+ exportName: string;
44
+ }[], file: string): string;
45
+ export declare function stampJsx(code: string, options: StampOptions): StampResult | null;
46
+ /** Parses a source or call stamp back into its parts (the agent and the mirror share this shape). */
47
+ export declare function parseStamp(value: string | null | undefined): {
48
+ file: string;
49
+ line: number;
50
+ column: number;
51
+ } | null;
52
+ /** Parses an owner stamp (`file:ExportName`). */
53
+ export declare function parseOwner(value: string | null | undefined): {
54
+ file: string;
55
+ exportName: string;
56
+ } | null;
@@ -0,0 +1,7 @@
1
+ /** Absolute paths of the global stylesheets, in import order. `explicit` (root-relative) wins when given. */
2
+ export declare function globalStylesheets(root: string, explicit?: string[]): string[];
3
+ /** `<html …>` and `<body …>` attributes of the project's index.html (theme classes, fonts), for the host page. */
4
+ export declare function documentAttributes(root: string): {
5
+ html: string;
6
+ body: string;
7
+ };
@@ -0,0 +1,58 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export interface NaturalDesignViteOptions {
3
+ root?: string;
4
+ /** Component names that must not receive data-nd-call. */
5
+ exclude?: string[];
6
+ /** Call-site stamps on component elements (default true). */
7
+ calls?: boolean;
8
+ /** Owner stamps on host elements (default true). */
9
+ owners?: boolean;
10
+ /** Serve the component index at /__natural/components.json (default true). */
11
+ index?: boolean;
12
+ /** Folders the index covers, relative to the root (default: src/components, components, src/lib/components, app/components, src/ui). */
13
+ indexFolders?: string[];
14
+ /** The render registry: virtual module, `window.__nd` in the app's pages, and /__natural/host (default true). */
15
+ registry?: boolean;
16
+ /** Global stylesheets for the host page, root-relative (default: found from index.html and the entry's CSS imports). */
17
+ styles?: string[];
18
+ /** Installed npm packages (`@acme/ui`) whose React components join the index and the registry, read-only. */
19
+ packages?: string[];
20
+ }
21
+ interface ViteServer {
22
+ middlewares: {
23
+ use: (handler: (req: IncomingMessage, res: ServerResponse, next: () => void) => void) => void;
24
+ };
25
+ watcher: {
26
+ on: (event: 'all', listener: (event: string, file: string) => void) => void;
27
+ };
28
+ moduleGraph: {
29
+ getModuleById: (id: string) => unknown;
30
+ invalidateModule: (module: never) => void;
31
+ };
32
+ transformIndexHtml: (url: string, html: string, originalUrl?: string) => Promise<string>;
33
+ }
34
+ export default function naturalDesign(options?: NaturalDesignViteOptions): {
35
+ name: string;
36
+ apply: "serve";
37
+ enforce: "pre";
38
+ configResolved(config: {
39
+ root: string;
40
+ base?: string;
41
+ }): void;
42
+ transform(code: string, id: string): {
43
+ code: string;
44
+ map: import("magic-string").SourceMap;
45
+ };
46
+ resolveId(id: string): string;
47
+ load(id: string): string;
48
+ transformIndexHtml(): {
49
+ tag: string;
50
+ attrs: {
51
+ type: string;
52
+ src: string;
53
+ };
54
+ injectTo: "head";
55
+ }[];
56
+ configureServer(server: ViteServer): void;
57
+ };
58
+ export {};