UNPKG

2.1 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Server } from 'http';
3import { Connect } from '@ream/server';
4import { SetRequired } from './base';
5import { UserConfig, ViteDevServer } from 'vite';
6
7declare type State = {
8 constants: {
9 [k: string]: string;
10 };
11 pluginsFiles: {
12 'enhance-app': Set<string>;
13 'enhance-server': Set<string>;
14 };
15};
16declare class Store {
17 state: State;
18 defineConstant: (name: string, value: any) => void;
19 addPluginFile: (type: keyof State['pluginsFiles'], file: string) => void;
20}
21
22declare type ReamPlugin = {
23 name: string;
24 apply?: (api: Store) => void;
25};
26
27interface Options {
28 rootDir?: string;
29 srcDir?: string;
30 dev?: boolean;
31 server?: {
32 port?: number | string;
33 };
34}
35declare type ReamConfig = {
36 env?: {
37 [k: string]: string | boolean | number;
38 };
39 plugins?: Array<ReamPlugin>;
40 imports?: string[];
41 server?: {
42 port?: number;
43 };
44 vue?: {
45 runtimeTemplateCompiler?: boolean;
46 };
47 vite?: (viteConfig: UserConfig, opts: {
48 dev: boolean;
49 ssr?: boolean;
50 }) => void;
51};
52declare class Ream {
53 rootDir: string;
54 srcDir: string;
55 isDev: boolean;
56 config: SetRequired<ReamConfig, 'env' | 'plugins' | 'imports' | 'server'>;
57 configPath?: string;
58 store: Store;
59 viteDevServer?: ViteDevServer;
60 constructor(options?: Options, configOverride?: ReamConfig);
61 resolveRootDir(...args: string[]): string;
62 resolveSrcDir(...args: string[]): string;
63 resolveDotReam(...args: string[]): string;
64 resolveOwnDir(...args: string[]): string;
65 resolveInPackage(pkg: string, target: string): string;
66 prepare({ shouldCleanDir, shouldPrepreFiles, }: {
67 shouldCleanDir: boolean;
68 shouldPrepreFiles: boolean;
69 }): Promise<void>;
70 localResolve(name: string): string | undefined;
71 localRequire(name: string): any;
72 getRequestHandler(): Promise<Connect>;
73 serve(): Promise<Server>;
74 build(fullyExport?: boolean): Promise<void>;
75}
76
77export { Options, Ream, ReamConfig, ReamPlugin };