@roots/bud-client 2023.5.12 → 2023.5.22
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.
- package/lib/hot/client.js +8 -4
- package/lib/hot/events.d.ts +6 -6
- package/package.json +3 -3
- package/src/hot/client.ts +4 -2
package/lib/hot/client.js
CHANGED
|
@@ -18,6 +18,7 @@ import * as clientOptions from './options.js';
|
|
|
18
18
|
* Initializes bud.js HMR handling
|
|
19
19
|
*/
|
|
20
20
|
export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
var _a;
|
|
21
22
|
/* Guard: EventSource browser support */
|
|
22
23
|
if (typeof (window === null || window === void 0 ? void 0 : window.EventSource) === `undefined`) {
|
|
23
24
|
console.error(`[bud] hot module reload requires EventSource to work. https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools`);
|
|
@@ -102,12 +103,15 @@ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, voi
|
|
|
102
103
|
}
|
|
103
104
|
});
|
|
104
105
|
/* Instantiate indicator, overlay */
|
|
105
|
-
|
|
106
|
+
try {
|
|
107
|
+
yield components.make(options);
|
|
108
|
+
}
|
|
109
|
+
catch (error) { }
|
|
106
110
|
/* Instantiate eventSource */
|
|
107
111
|
const events = injectEvents(EventSource).make(options);
|
|
108
|
-
if (!window.bud.listeners[options.name]) {
|
|
112
|
+
if (!((_a = window.bud.listeners) === null || _a === void 0 ? void 0 : _a[options.name])) {
|
|
109
113
|
window.bud.listeners[options.name] = (payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
var
|
|
114
|
+
var _b;
|
|
111
115
|
if (!payload)
|
|
112
116
|
return;
|
|
113
117
|
if (options.reload && payload.action === `reload`)
|
|
@@ -115,7 +119,7 @@ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, voi
|
|
|
115
119
|
if (payload.name !== options.name)
|
|
116
120
|
return;
|
|
117
121
|
window.bud.controllers.map(controller => controller === null || controller === void 0 ? void 0 : controller.update(payload));
|
|
118
|
-
if (((
|
|
122
|
+
if (((_b = payload.errors) === null || _b === void 0 ? void 0 : _b.length) > 0)
|
|
119
123
|
return;
|
|
120
124
|
if (payload.action === `built` || payload.action === `sync`) {
|
|
121
125
|
if (isStale(payload.hash))
|
package/lib/hot/events.d.ts
CHANGED
|
@@ -33,9 +33,9 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
|
|
|
33
33
|
readonly url: string;
|
|
34
34
|
readonly withCredentials: boolean;
|
|
35
35
|
close(): void;
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
readonly
|
|
36
|
+
readonly CONNECTING: 0;
|
|
37
|
+
readonly OPEN: 1;
|
|
38
|
+
readonly CLOSED: 2;
|
|
39
39
|
addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
40
40
|
addEventListener(type: string, listener: (this: EventSource, event: MessageEvent<any>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
41
41
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -83,9 +83,9 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
|
|
|
83
83
|
readonly url: string;
|
|
84
84
|
readonly withCredentials: boolean;
|
|
85
85
|
close(): void;
|
|
86
|
-
readonly
|
|
87
|
-
readonly
|
|
88
|
-
readonly
|
|
86
|
+
readonly CONNECTING: 0;
|
|
87
|
+
readonly OPEN: 1;
|
|
88
|
+
readonly CLOSED: 2;
|
|
89
89
|
addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
90
90
|
addEventListener(type: string, listener: (this: EventSource, event: MessageEvent<any>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
91
91
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-client",
|
|
3
|
-
"version": "2023.5.
|
|
3
|
+
"version": "2023.5.22",
|
|
4
4
|
"description": "Client scripts for @roots/bud",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"main": "./lib/index.cjs",
|
|
68
68
|
"module": "./lib/index.mjs",
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@roots/bud": "2023.5.
|
|
70
|
+
"@roots/bud": "2023.5.22",
|
|
71
71
|
"@skypack/package-check": "0.2.2",
|
|
72
|
-
"@types/node": "18.16.
|
|
72
|
+
"@types/node": "18.16.12",
|
|
73
73
|
"@types/webpack-env": "1.18.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
package/src/hot/client.ts
CHANGED
|
@@ -111,12 +111,14 @@ export const client = async (
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/* Instantiate indicator, overlay */
|
|
114
|
-
|
|
114
|
+
try {
|
|
115
|
+
await components.make(options)
|
|
116
|
+
} catch (error) {}
|
|
115
117
|
|
|
116
118
|
/* Instantiate eventSource */
|
|
117
119
|
const events = injectEvents(EventSource).make(options)
|
|
118
120
|
|
|
119
|
-
if (!window.bud.listeners[options.name]) {
|
|
121
|
+
if (!window.bud.listeners?.[options.name]) {
|
|
120
122
|
window.bud.listeners[options.name] = async payload => {
|
|
121
123
|
if (!payload) return
|
|
122
124
|
|