@rspack/dev-server 2.0.0 → 2.0.2

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.
Files changed (43) hide show
  1. package/package.json +28 -29
  2. package/client/clients/WebSocketClient.d.ts +0 -17
  3. package/client/clients/WebSocketClient.js +0 -32
  4. package/client/index.d.ts +0 -17
  5. package/client/index.js +0 -356
  6. package/client/modules/logger/Logger.d.ts +0 -39
  7. package/client/modules/logger/Logger.js +0 -121
  8. package/client/modules/logger/createConsoleLogger.d.ts +0 -12
  9. package/client/modules/logger/createConsoleLogger.js +0 -119
  10. package/client/modules/logger/index.d.ts +0 -26
  11. package/client/modules/logger/index.js +0 -32
  12. package/client/modules/types.d.ts +0 -45
  13. package/client/modules/types.js +0 -17
  14. package/client/overlay.d.ts +0 -47
  15. package/client/overlay.js +0 -454
  16. package/client/progress.d.ts +0 -11
  17. package/client/progress.js +0 -197
  18. package/client/socket.d.ts +0 -15
  19. package/client/socket.js +0 -34
  20. package/client/type.d.ts +0 -15
  21. package/client/type.js +0 -1
  22. package/client/utils/ansiHTML.d.ts +0 -30
  23. package/client/utils/ansiHTML.js +0 -195
  24. package/client/utils/log.d.ts +0 -13
  25. package/client/utils/log.js +0 -11
  26. package/client/utils/sendMessage.d.ts +0 -11
  27. package/client/utils/sendMessage.js +0 -8
  28. package/dist/0~chokidar.js +0 -1477
  29. package/dist/0~chokidar.js.LICENSE.txt +0 -1
  30. package/dist/0~connect-history-api-fallback.js +0 -76
  31. package/dist/0~connect-next.js +0 -1245
  32. package/dist/0~connect-next.js.LICENSE.txt +0 -57
  33. package/dist/0~debug.js +0 -621
  34. package/dist/0~http-proxy-middleware.js +0 -3777
  35. package/dist/0~http-proxy-middleware.js.LICENSE.txt +0 -34
  36. package/dist/0~launch-editor.js +0 -601
  37. package/dist/0~open.js +0 -555
  38. package/dist/0~p-retry.js +0 -161
  39. package/dist/0~serve-static.js +0 -1595
  40. package/dist/0~serve-static.js.LICENSE.txt +0 -108
  41. package/dist/198.js +0 -5113
  42. package/dist/index.d.ts +0 -587
  43. package/dist/index.js +0 -1
@@ -1,121 +0,0 @@
1
- import { LogType } from "../types.js";
2
- function _define_property(obj, key, value) {
3
- if (key in obj) Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- else obj[key] = value;
10
- return obj;
11
- }
12
- const LOG_SYMBOL = Symbol('rspack logger raw log method');
13
- const TIMERS_SYMBOL = Symbol('rspack logger times');
14
- const TIMERS_AGGREGATES_SYMBOL = Symbol('rspack logger aggregated times');
15
- let _LOG_SYMBOL = LOG_SYMBOL, _TIMERS_SYMBOL = TIMERS_SYMBOL, _TIMERS_AGGREGATES_SYMBOL = TIMERS_AGGREGATES_SYMBOL;
16
- class RspackLogger {
17
- error(...args) {
18
- this[LOG_SYMBOL](LogType.error, args);
19
- }
20
- warn(...args) {
21
- this[LOG_SYMBOL](LogType.warn, args);
22
- }
23
- info(...args) {
24
- this[LOG_SYMBOL](LogType.info, args);
25
- }
26
- log(...args) {
27
- this[LOG_SYMBOL](LogType.log, args);
28
- }
29
- debug(...args) {
30
- this[LOG_SYMBOL](LogType.debug, args);
31
- }
32
- assert(assertion, ...args) {
33
- if (!assertion) this[LOG_SYMBOL](LogType.error, args);
34
- }
35
- trace() {
36
- this[LOG_SYMBOL](LogType.trace, [
37
- 'Trace'
38
- ]);
39
- }
40
- clear() {
41
- this[LOG_SYMBOL](LogType.clear);
42
- }
43
- status(...args) {
44
- this[LOG_SYMBOL](LogType.status, args);
45
- }
46
- group(...args) {
47
- this[LOG_SYMBOL](LogType.group, args);
48
- }
49
- groupCollapsed(...args) {
50
- this[LOG_SYMBOL](LogType.groupCollapsed, args);
51
- }
52
- groupEnd() {
53
- this[LOG_SYMBOL](LogType.groupEnd);
54
- }
55
- profile(label) {
56
- this[LOG_SYMBOL](LogType.profile, [
57
- label
58
- ]);
59
- }
60
- profileEnd(label) {
61
- this[LOG_SYMBOL](LogType.profileEnd, [
62
- label
63
- ]);
64
- }
65
- time(label) {
66
- this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
67
- this[TIMERS_SYMBOL].set(label, process.hrtime());
68
- }
69
- timeLog(label) {
70
- const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
71
- if (!prev) throw new Error(`No such label '${label}' for RspackLogger.timeLog()`);
72
- const time = process.hrtime(prev);
73
- this[LOG_SYMBOL](LogType.time, [
74
- label,
75
- ...time
76
- ]);
77
- }
78
- timeEnd(label) {
79
- const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
80
- if (!prev) throw new Error(`No such label '${label}' for RspackLogger.timeEnd()`);
81
- const time = process.hrtime(prev);
82
- this[TIMERS_SYMBOL].delete(label);
83
- this[LOG_SYMBOL](LogType.time, [
84
- label,
85
- ...time
86
- ]);
87
- }
88
- timeAggregate(label) {
89
- const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
90
- if (!prev) throw new Error(`No such label '${label}' for RspackLogger.timeAggregate()`);
91
- const time = process.hrtime(prev);
92
- this[TIMERS_SYMBOL].delete(label);
93
- this[TIMERS_AGGREGATES_SYMBOL] = this[TIMERS_AGGREGATES_SYMBOL] || new Map();
94
- const current = this[TIMERS_AGGREGATES_SYMBOL].get(label);
95
- if (void 0 !== current) if (time[1] + current[1] > 1e9) {
96
- time[0] += current[0] + 1;
97
- time[1] = time[1] - 1e9 + current[1];
98
- } else {
99
- time[0] += current[0];
100
- time[1] += current[1];
101
- }
102
- this[TIMERS_AGGREGATES_SYMBOL].set(label, time);
103
- }
104
- timeAggregateEnd(label) {
105
- if (void 0 === this[TIMERS_AGGREGATES_SYMBOL]) return;
106
- const time = this[TIMERS_AGGREGATES_SYMBOL].get(label);
107
- if (void 0 === time) return;
108
- this[TIMERS_AGGREGATES_SYMBOL].delete(label);
109
- this[LOG_SYMBOL](LogType.time, [
110
- label,
111
- ...time
112
- ]);
113
- }
114
- constructor(log){
115
- _define_property(this, _LOG_SYMBOL, void 0);
116
- _define_property(this, _TIMERS_SYMBOL, new Map());
117
- _define_property(this, _TIMERS_AGGREGATES_SYMBOL, new Map());
118
- this[LOG_SYMBOL] = log;
119
- }
120
- }
121
- export { RspackLogger as Logger };
@@ -1,12 +0,0 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack-dev-server
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
- */
10
- import { type LoggerOptions, type LoggingFunction } from '../types.js';
11
- declare const _default: ({ level, debug, console, }: LoggerOptions) => LoggingFunction;
12
- export default _default;
@@ -1,119 +0,0 @@
1
- import { LogType } from "../types.js";
2
- const filterToFunction = (item)=>{
3
- if ('string' == typeof item) {
4
- const regExp = new RegExp(`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, '\\$&')}([\\\\/]|$|!|\\?)`);
5
- return (ident)=>regExp.test(ident);
6
- }
7
- if (item && 'object' == typeof item && 'function' == typeof item.test) return (ident)=>item.test(ident);
8
- if ('function' == typeof item) return item;
9
- if ('boolean' == typeof item) return ()=>item;
10
- };
11
- const LogLevel = {
12
- none: 6,
13
- false: 6,
14
- error: 5,
15
- warn: 4,
16
- info: 3,
17
- log: 2,
18
- true: 2,
19
- verbose: 1
20
- };
21
- const createConsoleLogger = ({ level = 'info', debug = false, console })=>{
22
- const debugFilters = 'boolean' == typeof debug ? [
23
- ()=>debug
24
- ] : [
25
- ...Array.isArray(debug) ? debug : [
26
- debug
27
- ]
28
- ].map(filterToFunction);
29
- const loglevel = LogLevel[`${level}`] || 0;
30
- const logger = (name, type, args)=>{
31
- const labeledArgs = ()=>{
32
- if (Array.isArray(args)) {
33
- if (args.length > 0 && 'string' == typeof args[0]) return [
34
- `[${name}] ${args[0]}`,
35
- ...args.slice(1)
36
- ];
37
- return [
38
- `[${name}]`,
39
- ...args
40
- ];
41
- }
42
- return [];
43
- };
44
- const debug = debugFilters.some((f)=>f(name));
45
- switch(type){
46
- case LogType.debug:
47
- if (!debug) return;
48
- if ('function' == typeof console.debug) console.debug(...labeledArgs());
49
- else console.log(...labeledArgs());
50
- break;
51
- case LogType.log:
52
- if (!debug && loglevel > LogLevel.log) return;
53
- console.log(...labeledArgs());
54
- break;
55
- case LogType.info:
56
- if (!debug && loglevel > LogLevel.info) return;
57
- console.info(...labeledArgs());
58
- break;
59
- case LogType.warn:
60
- if (!debug && loglevel > LogLevel.warn) return;
61
- console.warn(...labeledArgs());
62
- break;
63
- case LogType.error:
64
- if (!debug && loglevel > LogLevel.error) return;
65
- console.error(...labeledArgs());
66
- break;
67
- case LogType.trace:
68
- if (!debug) return;
69
- console.trace();
70
- break;
71
- case LogType.groupCollapsed:
72
- if (!debug && loglevel > LogLevel.log) return;
73
- if (!debug && loglevel > LogLevel.verbose) {
74
- if ('function' == typeof console.groupCollapsed) console.groupCollapsed(...labeledArgs());
75
- else console.log(...labeledArgs());
76
- break;
77
- }
78
- case LogType.group:
79
- if (!debug && loglevel > LogLevel.log) return;
80
- if ('function' == typeof console.group) console.group(...labeledArgs());
81
- else console.log(...labeledArgs());
82
- break;
83
- case LogType.groupEnd:
84
- if (!debug && loglevel > LogLevel.log) return;
85
- if ('function' == typeof console.groupEnd) console.groupEnd();
86
- break;
87
- case LogType.time:
88
- {
89
- if (!debug && loglevel > LogLevel.log) return;
90
- const [label, start, end] = args;
91
- const ms = 1000 * start + end / 1000000;
92
- const msg = `[${name}] ${label}: ${ms} ms`;
93
- if ('function' == typeof console.logTime) console.logTime(msg);
94
- else console.log(msg);
95
- break;
96
- }
97
- case LogType.profile:
98
- if ('function' == typeof console.profile) console.profile(...labeledArgs());
99
- break;
100
- case LogType.profileEnd:
101
- if ('function' == typeof console.profileEnd) console.profileEnd(...labeledArgs());
102
- break;
103
- case LogType.clear:
104
- if (!debug && loglevel > LogLevel.log) return;
105
- if ('function' == typeof console.clear) console.clear();
106
- break;
107
- case LogType.status:
108
- if (!debug && loglevel > LogLevel.info) return;
109
- if ('function' == typeof console.status) if (args && 0 !== args.length) console.status(...labeledArgs());
110
- else console.status();
111
- else if (args && 0 !== args.length) console.info(...labeledArgs());
112
- break;
113
- default:
114
- throw new Error(`Unexpected LogType ${type}`);
115
- }
116
- };
117
- return logger;
118
- };
119
- export default createConsoleLogger;
@@ -1,26 +0,0 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack-dev-server
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
- */
10
- import { Logger } from './Logger.js';
11
- import type { LoggerOptions } from '../types.js';
12
- /**
13
- * Client stub for tapable SyncBailHook
14
- */
15
- declare class SyncBailHook {
16
- constructor(_args?: string[]);
17
- call(_origin?: string, _type?: string, _args?: unknown): undefined;
18
- }
19
- export declare const logger: {
20
- getLogger: (name: string) => Logger;
21
- configureDefaultLogger: (options: LoggerOptions) => void;
22
- hooks: {
23
- log: SyncBailHook;
24
- };
25
- };
26
- export {};
@@ -1,32 +0,0 @@
1
- import { Logger } from "./Logger.js";
2
- import createConsoleLogger from "./createConsoleLogger.js";
3
- class SyncBailHook {
4
- call(_origin, _type, _args) {}
5
- constructor(_args){}
6
- }
7
- const currentDefaultLoggerOptions = {
8
- level: 'info',
9
- debug: false,
10
- console
11
- };
12
- let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
13
- const configureDefaultLogger = (options)=>{
14
- Object.assign(currentDefaultLoggerOptions, options);
15
- currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
16
- };
17
- const getLogger = (name)=>new Logger((type, args)=>{
18
- if (void 0 === hooks.log.call(name, type, args)) currentDefaultLogger(name, type, args);
19
- });
20
- const hooks = {
21
- log: new SyncBailHook([
22
- 'origin',
23
- 'type',
24
- 'args'
25
- ])
26
- };
27
- const logger = {
28
- getLogger: getLogger,
29
- configureDefaultLogger: configureDefaultLogger,
30
- hooks: hooks
31
- };
32
- export { logger };
@@ -1,45 +0,0 @@
1
- import type { FilterTypes } from '@rspack/core';
2
- export type EXPECTED_ANY = any;
3
- export type FilterFunction = (item: string) => boolean;
4
- export type LoggingFunction = (value: string, type: LogTypeEnum, args?: Args) => void;
5
- export type LoggerConsole = {
6
- clear: () => void;
7
- trace: () => void;
8
- info: (...args: Args) => void;
9
- log: (...args: Args) => void;
10
- warn: (...args: Args) => void;
11
- error: (...args: Args) => void;
12
- debug?: (...args: Args) => void;
13
- group?: (...args: Args) => void;
14
- groupCollapsed?: (...args: Args) => void;
15
- groupEnd?: (...args: Args) => void;
16
- status?: (...args: Args) => void;
17
- profile?: (...args: Args) => void;
18
- profileEnd?: (...args: Args) => void;
19
- logTime?: (...args: Args) => void;
20
- };
21
- export type LoggerOptions = {
22
- level: false | true | 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
23
- debug: FilterTypes | boolean;
24
- console: LoggerConsole;
25
- };
26
- export declare const LogType: Readonly<{
27
- error: "error";
28
- warn: "warn";
29
- info: "info";
30
- log: "log";
31
- debug: "debug";
32
- trace: "trace";
33
- group: "group";
34
- groupCollapsed: "groupCollapsed";
35
- groupEnd: "groupEnd";
36
- profile: "profile";
37
- profileEnd: "profileEnd";
38
- time: "time";
39
- clear: "clear";
40
- status: "status";
41
- }>;
42
- export type LogTypeEnum = (typeof LogType)[keyof typeof LogType];
43
- export type TimersMap = Map<string | undefined, [number, number]>;
44
- export type Args = EXPECTED_ANY[];
45
- export type { FilterItemTypes } from '@rspack/core';
@@ -1,17 +0,0 @@
1
- const LogType = Object.freeze({
2
- error: 'error',
3
- warn: 'warn',
4
- info: 'info',
5
- log: 'log',
6
- debug: 'debug',
7
- trace: 'trace',
8
- group: 'group',
9
- groupCollapsed: 'groupCollapsed',
10
- groupEnd: 'groupEnd',
11
- profile: 'profile',
12
- profileEnd: 'profileEnd',
13
- time: 'time',
14
- clear: 'clear',
15
- status: 'status'
16
- });
17
- export { LogType };
@@ -1,47 +0,0 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack-dev-server
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
- */
10
- type Message = Error & {
11
- file?: string;
12
- moduleName?: string;
13
- moduleIdentifier?: string;
14
- loc?: string;
15
- message?: string;
16
- stack?: string | string[];
17
- };
18
- type Event = {
19
- type: string;
20
- } & Record<string, any>;
21
- type StateMachine = {
22
- send: (event: Event) => void;
23
- };
24
- declare const formatProblem: (type: "warning" | "error", item: string | Message) => {
25
- header: string;
26
- body: string;
27
- };
28
- type CreateOverlayOptions = {
29
- /** Trusted types policy name. If false, disables trusted types. */
30
- trustedTypesPolicyName?: false | string;
31
- /** Runtime error catcher. If boolean, enables/disables catching. If function, handles the error. */
32
- catchRuntimeError?: boolean | ((error: Error) => void);
33
- };
34
- type OverlayTrustedTypePolicy = {
35
- createHTML: (value: string) => string;
36
- };
37
- declare global {
38
- interface Window {
39
- trustedTypes?: {
40
- createPolicy: (name: string, policy: {
41
- createHTML: (value: string) => string;
42
- }) => OverlayTrustedTypePolicy;
43
- };
44
- }
45
- }
46
- declare const createOverlay: (options: CreateOverlayOptions) => StateMachine;
47
- export { createOverlay, formatProblem };