@rspack/plugin-react-refresh 1.6.1 → 2.0.0-beta.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.
Files changed (43) hide show
  1. package/README.md +19 -57
  2. package/client/reactRefresh.js +16 -28
  3. package/client/reactRefreshEntry.js +11 -12
  4. package/client/refreshUtils.js +116 -133
  5. package/dist/index.d.ts +1 -6
  6. package/dist/index.js +10 -176
  7. package/dist/options.d.ts +3 -20
  8. package/package.json +29 -46
  9. package/client/errorOverlayEntry.js +0 -101
  10. package/client/overlay/components/CompileErrorTrace.js +0 -63
  11. package/client/overlay/components/PageHeader.js +0 -60
  12. package/client/overlay/components/RuntimeErrorFooter.js +0 -93
  13. package/client/overlay/components/RuntimeErrorHeader.js +0 -38
  14. package/client/overlay/components/RuntimeErrorStack.js +0 -80
  15. package/client/overlay/components/Spacer.js +0 -19
  16. package/client/overlay/containers/CompileErrorContainer.js +0 -25
  17. package/client/overlay/containers/RuntimeErrorContainer.js +0 -29
  18. package/client/overlay/index.js +0 -351
  19. package/client/overlay/theme.js +0 -39
  20. package/client/overlay/utils.js +0 -74
  21. package/client/utils/ansi-html.js +0 -300
  22. package/client/utils/errorEventHandlers.js +0 -102
  23. package/client/utils/formatWebpackErrors.js +0 -106
  24. package/client/utils/retry.js +0 -23
  25. package/dist/sockets/WDSSocket.d.ts +0 -13
  26. package/dist/sockets/WDSSocket.js +0 -63
  27. package/dist/sockets/WHMEventSource.d.ts +0 -26
  28. package/dist/sockets/WHMEventSource.js +0 -52
  29. package/dist/sockets/utils/getCurrentScriptSource.d.ts +0 -1
  30. package/dist/sockets/utils/getCurrentScriptSource.js +0 -45
  31. package/dist/sockets/utils/getSocketUrlParts.d.ts +0 -9
  32. package/dist/sockets/utils/getSocketUrlParts.js +0 -87
  33. package/dist/sockets/utils/getUrlFromParts.d.ts +0 -9
  34. package/dist/sockets/utils/getUrlFromParts.js +0 -49
  35. package/dist/sockets/utils/getWDSMetadata.d.ts +0 -16
  36. package/dist/sockets/utils/getWDSMetadata.js +0 -45
  37. package/dist/utils/getAdditionalEntries.d.ts +0 -9
  38. package/dist/utils/getIntegrationEntry.d.ts +0 -7
  39. package/dist/utils/getSocketIntegration.d.ts +0 -2
  40. package/exports/index.cjs +0 -7
  41. package/exports/index.d.cts +0 -3
  42. package/exports/index.d.mts +0 -5
  43. package/exports/index.mjs +0 -11
@@ -1,26 +0,0 @@
1
- /**
2
- * The hard-coded singleton key for webpack-hot-middleware's client instance.
3
- * [Ref](https://github.com/webpack-contrib/webpack-hot-middleware/blob/cb29abb9dde435a1ac8e9b19f82d7d36b1093198/client.js#L152)
4
- */
5
- declare const singletonKey = "__webpack_hot_middleware_reporter__";
6
- interface WHMClient {
7
- cleanProblemsCache: () => void;
8
- problems: () => boolean;
9
- success: () => void;
10
- useCustomOverlay: (customOverlay: {
11
- showProblems: (type: string, data: string[]) => void;
12
- clear: () => void;
13
- }) => void;
14
- }
15
- declare global {
16
- interface Window {
17
- [singletonKey]: WHMClient;
18
- }
19
- }
20
- /**
21
- * Initializes a socket server for HMR for webpack-hot-middleware.
22
- * @param {function(*): void} messageHandler A handler to consume Webpack compilation messages.
23
- * @returns {void}
24
- */
25
- export declare function init(messageHandler: (...args: unknown[]) => void): void;
26
- export {};
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- init: ()=>init
28
- });
29
- const singletonKey = '__webpack_hot_middleware_reporter__';
30
- function init(messageHandler) {
31
- const client = window[singletonKey];
32
- client.useCustomOverlay({
33
- showProblems (type, data) {
34
- messageHandler({
35
- type,
36
- data
37
- });
38
- },
39
- clear () {
40
- messageHandler({
41
- type: 'ok'
42
- });
43
- }
44
- });
45
- }
46
- exports.init = __webpack_exports__.init;
47
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
48
- "init"
49
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
50
- Object.defineProperty(exports, '__esModule', {
51
- value: true
52
- });
@@ -1 +0,0 @@
1
- export default function getCurrentScriptSource(): string | null | undefined;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- default: ()=>getCurrentScriptSource
28
- });
29
- function getCurrentScriptSource() {
30
- if ('currentScript' in document) {
31
- if (null == document.currentScript) return;
32
- return document.currentScript.getAttribute('src');
33
- }
34
- const scriptElementsWithSrc = Array.prototype.filter.call(document.scripts || [], (elem)=>elem.getAttribute('src'));
35
- if (!scriptElementsWithSrc.length) return;
36
- const currentScript = scriptElementsWithSrc[scriptElementsWithSrc.length - 1];
37
- return currentScript.getAttribute('src');
38
- }
39
- exports["default"] = __webpack_exports__["default"];
40
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
41
- "default"
42
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
43
- Object.defineProperty(exports, '__esModule', {
44
- value: true
45
- });
@@ -1,9 +0,0 @@
1
- import type { WDSMetaObj } from './getWDSMetadata';
2
- export interface SocketUrlParts {
3
- auth?: string;
4
- hostname: string;
5
- protocol?: string;
6
- pathname: string;
7
- port?: string;
8
- }
9
- export default function getSocketUrlParts(resourceQuery?: string, metadata?: WDSMetaObj): SocketUrlParts;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- default: ()=>getSocketUrlParts
37
- });
38
- const external_getCurrentScriptSource_js_namespaceObject = require("./getCurrentScriptSource.js");
39
- var external_getCurrentScriptSource_js_default = /*#__PURE__*/ __webpack_require__.n(external_getCurrentScriptSource_js_namespaceObject);
40
- function getSocketUrlParts(resourceQuery, metadata = {}) {
41
- const urlParts = {};
42
- if (resourceQuery) {
43
- const parsedQuery = {};
44
- const searchParams = new URLSearchParams(resourceQuery.slice(1));
45
- searchParams.forEach((value, key)=>{
46
- parsedQuery[key] = value;
47
- });
48
- urlParts.hostname = parsedQuery.sockHost;
49
- urlParts.pathname = parsedQuery.sockPath;
50
- urlParts.port = parsedQuery.sockPort;
51
- if (parsedQuery.sockProtocol) urlParts.protocol = `${parsedQuery.sockProtocol}:`;
52
- } else {
53
- const scriptSource = external_getCurrentScriptSource_js_default()();
54
- let url = {};
55
- try {
56
- url = new URL(scriptSource, window.location.href);
57
- } catch (e) {}
58
- if (url.username) {
59
- urlParts.auth = url.username;
60
- if (url.password) urlParts.auth += `:${url.password}`;
61
- }
62
- if ('null' !== url.origin) urlParts.hostname = url.hostname;
63
- urlParts.protocol = url.protocol;
64
- urlParts.port = url.port;
65
- }
66
- if (!urlParts.pathname) if (4 === metadata.version) urlParts.pathname = '/ws';
67
- else urlParts.pathname = '/sockjs-node';
68
- const isEmptyHostname = '0.0.0.0' === urlParts.hostname || '[::]' === urlParts.hostname || !urlParts.hostname;
69
- if (isEmptyHostname && window.location.hostname && 0 === window.location.protocol.indexOf('http')) urlParts.hostname = window.location.hostname;
70
- if (!urlParts.protocol || urlParts.hostname && (isEmptyHostname || 'https:' === window.location.protocol)) urlParts.protocol = window.location.protocol;
71
- if (!urlParts.port) urlParts.port = window.location.port;
72
- if (!urlParts.hostname || !urlParts.pathname) throw new Error("[React Refresh] Failed to get an URL for the socket connection.\nThis usually means that the current executed script doesn't have a `src` attribute set.\nYou should either specify the socket path parameters under the `devServer` key in your Rspack config, or use the `overlay` option.\nhttps://rspack.rs/guide/tech/react#fast-refresh");
73
- return {
74
- auth: urlParts.auth,
75
- hostname: urlParts.hostname,
76
- pathname: urlParts.pathname,
77
- protocol: urlParts.protocol,
78
- port: urlParts.port || void 0
79
- };
80
- }
81
- exports["default"] = __webpack_exports__["default"];
82
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
83
- "default"
84
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
85
- Object.defineProperty(exports, '__esModule', {
86
- value: true
87
- });
@@ -1,9 +0,0 @@
1
- import type { SocketUrlParts } from './getSocketUrlParts';
2
- import type { WDSMetaObj } from './getWDSMetadata';
3
- /**
4
- * Create a valid URL from parsed URL parts.
5
- * @param urlParts The parsed URL parts.
6
- * @param metadata The parsed WDS metadata object.
7
- * @returns The generated URL.
8
- */
9
- export default function urlFromParts(urlParts: SocketUrlParts, metadata?: WDSMetaObj): string;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- default: ()=>urlFromParts
28
- });
29
- function urlFromParts(urlParts, metadata = {}) {
30
- let fullProtocol = 'http:';
31
- if (urlParts.protocol) fullProtocol = urlParts.protocol;
32
- if (metadata.enforceWs) fullProtocol = fullProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws');
33
- fullProtocol = `${fullProtocol}//`;
34
- let fullHost = urlParts.hostname;
35
- if (urlParts.auth) {
36
- const fullAuth = `${urlParts.auth.split(':').map(encodeURIComponent).join(':')}@`;
37
- fullHost = fullAuth + fullHost;
38
- }
39
- if (urlParts.port) fullHost = `${fullHost}:${urlParts.port}`;
40
- const url = new URL(urlParts.pathname, fullProtocol + fullHost);
41
- return url.href;
42
- }
43
- exports["default"] = __webpack_exports__["default"];
44
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
45
- "default"
46
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
47
- Object.defineProperty(exports, '__esModule', {
48
- value: true
49
- });
@@ -1,16 +0,0 @@
1
- export interface WDSMetaObj {
2
- enforceWs?: boolean;
3
- version?: number;
4
- }
5
- declare class WebSocketClient {
6
- client: WebSocket;
7
- constructor(url: string);
8
- onOpen(f: (...args: unknown[]) => void): void;
9
- onClose(f: (...args: unknown[]) => void): void;
10
- onMessage(f: (...args: unknown[]) => void): void;
11
- }
12
- export interface SocketClient {
13
- new (url: string): WebSocketClient;
14
- }
15
- export default function getWDSMetadata(SocketClient: SocketClient): WDSMetaObj;
16
- export {};
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- default: ()=>getWDSMetadata
28
- });
29
- function getWDSMetadata(SocketClient) {
30
- let enforceWs = false;
31
- if (void 0 !== SocketClient.name && null !== SocketClient.name && SocketClient.name.toLowerCase().includes('websocket')) enforceWs = true;
32
- let version;
33
- version = 'onMessage' in SocketClient.prototype ? 'getClientPath' in SocketClient || 'BaseClient' === Object.getPrototypeOf(SocketClient).name ? 3 : 4 : 3;
34
- return {
35
- enforceWs: enforceWs,
36
- version: version
37
- };
38
- }
39
- exports["default"] = __webpack_exports__["default"];
40
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
41
- "default"
42
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
43
- Object.defineProperty(exports, '__esModule', {
44
- value: true
45
- });
@@ -1,9 +0,0 @@
1
- import type { NormalizedPluginOptions } from '../options';
2
- export interface AdditionalEntries {
3
- prependEntries: string[];
4
- overlayEntries: string[];
5
- }
6
- export declare function getAdditionalEntries({ devServer, options, }: {
7
- devServer: any;
8
- options: NormalizedPluginOptions;
9
- }): AdditionalEntries;
@@ -1,7 +0,0 @@
1
- import type { IntegrationType } from './getSocketIntegration';
2
- /**
3
- * Gets entry point of a supported socket integration.
4
- * @param integrationType A valid socket integration type or a path to a module.
5
- * @returns Path to the resolved integration entry point.
6
- */
7
- export declare function getIntegrationEntry(integrationType: IntegrationType): string | undefined;
@@ -1,2 +0,0 @@
1
- export type IntegrationType = 'wds' | 'whm' | (string & {});
2
- export declare function getSocketIntegration(integrationType: IntegrationType): string;
package/exports/index.cjs DELETED
@@ -1,7 +0,0 @@
1
- // CommonJS wrapper
2
- const { ReactRefreshRspackPlugin } = require('../dist/index.js');
3
-
4
- // default export will be deprecated in next major version
5
- module.exports = ReactRefreshRspackPlugin;
6
-
7
- module.exports.ReactRefreshRspackPlugin = ReactRefreshRspackPlugin;
@@ -1,3 +0,0 @@
1
- import { ReactRefreshRspackPlugin } from '../dist/index.js';
2
-
3
- export = ReactRefreshRspackPlugin;
@@ -1,5 +0,0 @@
1
- import { type PluginOptions, ReactRefreshRspackPlugin } from '../dist/index.js';
2
-
3
- export type { PluginOptions };
4
- export { ReactRefreshRspackPlugin };
5
- export default ReactRefreshRspackPlugin;
package/exports/index.mjs DELETED
@@ -1,11 +0,0 @@
1
- // ES modules wrapper
2
- import pluginModule from '../dist/index.js';
3
-
4
- const ReactRefreshRspackPlugin =
5
- pluginModule?.ReactRefreshRspackPlugin ??
6
- pluginModule?.default ??
7
- pluginModule;
8
-
9
- // default export will be deprecated in next major version
10
- export default ReactRefreshRspackPlugin;
11
- export { ReactRefreshRspackPlugin };