rspack-plugin-mock 1.0.1 → 1.2.0

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.
@@ -1,76 +0,0 @@
1
- import { RspackPluginInstance, Compiler, RspackOptionsNormalized } from '@rspack/core';
2
- import { i as LogLevel, b as MockOptions, c as MockServerPluginOptions, S as ServerBuildOption } from './types-Aw0AciTG.js';
3
- import { Server as Server$1 } from 'node:http';
4
- import { Http2SecureServer } from 'node:http2';
5
- import { FSWatcher } from 'node:fs';
6
- import EventEmitter from 'node:events';
7
-
8
- interface Logger {
9
- debug: (msg: string, level?: boolean | LogLevel) => void;
10
- info: (msg: string, level?: boolean | LogLevel) => void;
11
- warn: (msg: string, level?: boolean | LogLevel) => void;
12
- error: (msg: string, level?: boolean | LogLevel) => void;
13
- }
14
- declare const logLevels: Record<LogLevel, number>;
15
- declare function createLogger(prefix: string, defaultLevel?: LogLevel): Logger;
16
-
17
- interface MockCompilerOptions {
18
- alias?: Record<string, false | string | (string | false)[]>;
19
- plugins: RspackPluginInstance[];
20
- cwd?: string;
21
- include: string | string[];
22
- exclude: string | string[];
23
- logger: Logger;
24
- }
25
- declare function createMockCompiler(options: MockCompilerOptions): MockCompiler;
26
- declare class MockCompiler extends EventEmitter {
27
- options: MockCompilerOptions;
28
- cwd: string;
29
- mockWatcher: FSWatcher;
30
- moduleType: 'cjs' | 'esm';
31
- entryFile: string;
32
- private _mockData;
33
- private fileFilter;
34
- private watchInfo?;
35
- compiler?: Compiler | null;
36
- constructor(options: MockCompilerOptions);
37
- get mockData(): Record<string, MockOptions>;
38
- run(): Promise<void>;
39
- close(): void;
40
- updateAlias(alias: Record<string, false | string | (string | false)[]>): void;
41
- updateMockEntry(): Promise<void>;
42
- getMockFiles(): Promise<string[]>;
43
- watchMockFiles(): void;
44
- }
45
-
46
- interface ResolvedCompilerOptions {
47
- alias: Record<string, false | string | (string | false)[]>;
48
- proxies: (string | ((pathname: string, req: any) => boolean))[];
49
- wsProxies: (string | ((pathname: string, req: any) => boolean))[];
50
- plugins: RspackPluginInstance[];
51
- context?: string;
52
- }
53
- type ResolvePluginOptions = Required<Omit<MockServerPluginOptions, 'build'>> & ResolvedCompilerOptions & {
54
- logger: Logger;
55
- build: false | ServerBuildOption;
56
- };
57
-
58
- interface MiddlewareOptions {
59
- alias: Record<string, false | string | (string | false)[]>;
60
- proxies: (string | ((pathname: string, req: any) => boolean))[];
61
- context?: string;
62
- plugins: RspackPluginInstance[];
63
- }
64
- declare function createMockMiddleware(compiler: MockCompiler, options: ResolvePluginOptions): (middlewares: Middleware[], reload?: () => void) => Middleware[];
65
- type SetupMiddlewaresFn = NonNullable<NonNullable<RspackOptionsNormalized['devServer']>['setupMiddlewares']>;
66
- type Middleware = SetupMiddlewaresFn extends (middlewares: (infer T)[], devServer: any) => void ? T : never;
67
- type Server = SetupMiddlewaresFn extends (middlewares: any, devServer: infer T) => void ? T : never;
68
-
69
- interface MockSocketOptions {
70
- wsProxies: (string | ((pathname: string, req: any) => boolean))[];
71
- cookiesOptions: MockServerPluginOptions['cookiesOptions'];
72
- logger: Logger;
73
- }
74
- declare function mockWebSocket(compiler: MockCompiler, httpServer: Server$1 | Http2SecureServer, { wsProxies: proxies, cookiesOptions, logger, }: MockSocketOptions): void;
75
-
76
- export { type Logger as L, type MockCompilerOptions as M, type ResolvePluginOptions as R, type Server as S, MockCompiler as a, type MiddlewareOptions as b, createMockCompiler as c, createMockMiddleware as d, type Middleware as e, type MockSocketOptions as f, createLogger as g, logLevels as l, mockWebSocket as m };
@@ -1,76 +0,0 @@
1
- import { RspackPluginInstance, Compiler, RspackOptionsNormalized } from '@rspack/core';
2
- import { i as LogLevel, b as MockOptions, c as MockServerPluginOptions, S as ServerBuildOption } from './types-Aw0AciTG.cjs';
3
- import { Server as Server$1 } from 'node:http';
4
- import { Http2SecureServer } from 'node:http2';
5
- import { FSWatcher } from 'node:fs';
6
- import EventEmitter from 'node:events';
7
-
8
- interface Logger {
9
- debug: (msg: string, level?: boolean | LogLevel) => void;
10
- info: (msg: string, level?: boolean | LogLevel) => void;
11
- warn: (msg: string, level?: boolean | LogLevel) => void;
12
- error: (msg: string, level?: boolean | LogLevel) => void;
13
- }
14
- declare const logLevels: Record<LogLevel, number>;
15
- declare function createLogger(prefix: string, defaultLevel?: LogLevel): Logger;
16
-
17
- interface MockCompilerOptions {
18
- alias?: Record<string, false | string | (string | false)[]>;
19
- plugins: RspackPluginInstance[];
20
- cwd?: string;
21
- include: string | string[];
22
- exclude: string | string[];
23
- logger: Logger;
24
- }
25
- declare function createMockCompiler(options: MockCompilerOptions): MockCompiler;
26
- declare class MockCompiler extends EventEmitter {
27
- options: MockCompilerOptions;
28
- cwd: string;
29
- mockWatcher: FSWatcher;
30
- moduleType: 'cjs' | 'esm';
31
- entryFile: string;
32
- private _mockData;
33
- private fileFilter;
34
- private watchInfo?;
35
- compiler?: Compiler | null;
36
- constructor(options: MockCompilerOptions);
37
- get mockData(): Record<string, MockOptions>;
38
- run(): Promise<void>;
39
- close(): void;
40
- updateAlias(alias: Record<string, false | string | (string | false)[]>): void;
41
- updateMockEntry(): Promise<void>;
42
- getMockFiles(): Promise<string[]>;
43
- watchMockFiles(): void;
44
- }
45
-
46
- interface ResolvedCompilerOptions {
47
- alias: Record<string, false | string | (string | false)[]>;
48
- proxies: (string | ((pathname: string, req: any) => boolean))[];
49
- wsProxies: (string | ((pathname: string, req: any) => boolean))[];
50
- plugins: RspackPluginInstance[];
51
- context?: string;
52
- }
53
- type ResolvePluginOptions = Required<Omit<MockServerPluginOptions, 'build'>> & ResolvedCompilerOptions & {
54
- logger: Logger;
55
- build: false | ServerBuildOption;
56
- };
57
-
58
- interface MiddlewareOptions {
59
- alias: Record<string, false | string | (string | false)[]>;
60
- proxies: (string | ((pathname: string, req: any) => boolean))[];
61
- context?: string;
62
- plugins: RspackPluginInstance[];
63
- }
64
- declare function createMockMiddleware(compiler: MockCompiler, options: ResolvePluginOptions): (middlewares: Middleware[], reload?: () => void) => Middleware[];
65
- type SetupMiddlewaresFn = NonNullable<NonNullable<RspackOptionsNormalized['devServer']>['setupMiddlewares']>;
66
- type Middleware = SetupMiddlewaresFn extends (middlewares: (infer T)[], devServer: any) => void ? T : never;
67
- type Server = SetupMiddlewaresFn extends (middlewares: any, devServer: infer T) => void ? T : never;
68
-
69
- interface MockSocketOptions {
70
- wsProxies: (string | ((pathname: string, req: any) => boolean))[];
71
- cookiesOptions: MockServerPluginOptions['cookiesOptions'];
72
- logger: Logger;
73
- }
74
- declare function mockWebSocket(compiler: MockCompiler, httpServer: Server$1 | Http2SecureServer, { wsProxies: proxies, cookiesOptions, logger, }: MockSocketOptions): void;
75
-
76
- export { type Logger as L, type MockCompilerOptions as M, type ResolvePluginOptions as R, type Server as S, MockCompiler as a, type MiddlewareOptions as b, createMockCompiler as c, createMockMiddleware as d, type Middleware as e, type MockSocketOptions as f, createLogger as g, logLevels as l, mockWebSocket as m };