@roots/bud-client 6.13.0 → 6.13.1
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 +3 -3
- package/lib/hot/components/indicator/indicator.component.d.ts +28 -28
- package/lib/hot/components/indicator/indicator.component.js +86 -86
- package/lib/hot/components/overlay/overlay.component.d.ts +3 -3
- package/lib/hot/components/overlay/overlay.component.js +25 -25
- package/lib/hot/components/overlay/overlay.controller.d.ts +4 -4
- package/lib/hot/components/overlay/overlay.controller.js +14 -14
- package/lib/hot/events.d.ts +16 -16
- package/lib/hot/events.js +5 -5
- package/lib/hot/log.d.ts +2 -2
- package/lib/hot/log.js +2 -2
- package/lib/hot/options.js +4 -4
- package/package.json +5 -5
- package/src/hot/client.ts +3 -3
- package/src/hot/components/indicator/indicator.component.ts +104 -104
- package/src/hot/components/overlay/overlay.component.ts +36 -36
- package/src/hot/components/overlay/overlay.controller.ts +14 -14
- package/src/hot/events.ts +27 -27
- package/src/hot/log.ts +2 -2
- package/src/hot/options.ts +4 -4
- package/src/intercept/index.ts +1 -1
package/lib/hot/client.js
CHANGED
|
@@ -25,9 +25,9 @@ export const client = async (queryString, webpackHot) => {
|
|
|
25
25
|
const logger = makeLogger(options);
|
|
26
26
|
if (typeof window.bud === `undefined`) {
|
|
27
27
|
window.bud = {
|
|
28
|
+
controllers: [],
|
|
28
29
|
current: {},
|
|
29
30
|
hmr: {},
|
|
30
|
-
controllers: [],
|
|
31
31
|
listeners: {},
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -76,12 +76,12 @@ export const client = async (queryString, webpackHot) => {
|
|
|
76
76
|
const update = async () => {
|
|
77
77
|
try {
|
|
78
78
|
await webpackHot.apply({
|
|
79
|
-
ignoreUnaccepted: true,
|
|
80
79
|
ignoreDeclined: true,
|
|
81
80
|
ignoreErrored: true,
|
|
81
|
+
ignoreUnaccepted: true,
|
|
82
|
+
onDeclined: onUnacceptedOrDeclined,
|
|
82
83
|
onErrored,
|
|
83
84
|
onUnaccepted: onUnacceptedOrDeclined,
|
|
84
|
-
onDeclined: onUnacceptedOrDeclined,
|
|
85
85
|
});
|
|
86
86
|
if (!isStale())
|
|
87
87
|
await check();
|
|
@@ -4,49 +4,43 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class Component extends HTMLElement {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
rendered: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Component name
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* Root div querySelector selector
|
|
7
|
+
* Status indicator colors
|
|
16
8
|
*/
|
|
17
|
-
|
|
9
|
+
colors: Record<string, [number, number, number, number]>;
|
|
18
10
|
/**
|
|
19
11
|
* Timer
|
|
20
12
|
*/
|
|
21
13
|
hideTimeout: NodeJS.Timer;
|
|
22
14
|
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
get hasErrors(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Get accessor: has warnings
|
|
15
|
+
* Component name
|
|
28
16
|
*/
|
|
29
|
-
|
|
17
|
+
name: string;
|
|
30
18
|
/**
|
|
31
|
-
*
|
|
19
|
+
* Has component rendered
|
|
32
20
|
*/
|
|
33
|
-
|
|
21
|
+
rendered: boolean;
|
|
34
22
|
/**
|
|
35
23
|
* Class constructor
|
|
36
24
|
*/
|
|
37
25
|
constructor();
|
|
26
|
+
static get observedAttributes(): string[];
|
|
27
|
+
attributeChangedCallback(): void;
|
|
38
28
|
/**
|
|
39
|
-
*
|
|
29
|
+
* Get accessor: has errors
|
|
40
30
|
*/
|
|
41
|
-
|
|
31
|
+
get hasErrors(): boolean;
|
|
42
32
|
/**
|
|
43
|
-
*
|
|
33
|
+
* Get accessor: has warnings
|
|
44
34
|
*/
|
|
45
|
-
|
|
35
|
+
get hasWarnings(): boolean;
|
|
46
36
|
/**
|
|
47
37
|
* Hide status indicator
|
|
48
38
|
*/
|
|
49
39
|
hide(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Status is error
|
|
42
|
+
*/
|
|
43
|
+
onError(): void;
|
|
50
44
|
/**
|
|
51
45
|
* Status is pending
|
|
52
46
|
*/
|
|
@@ -55,14 +49,20 @@ export declare class Component extends HTMLElement {
|
|
|
55
49
|
* Status is success
|
|
56
50
|
*/
|
|
57
51
|
onSuccess(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Status is error
|
|
60
|
-
*/
|
|
61
|
-
onError(): void;
|
|
62
52
|
/**
|
|
63
53
|
* Status is warning
|
|
64
54
|
*/
|
|
65
55
|
onWarning(): void;
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Render status indicator
|
|
58
|
+
*/
|
|
59
|
+
renderShadow(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Root div querySelector selector
|
|
62
|
+
*/
|
|
63
|
+
get selector(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Show status indicator
|
|
66
|
+
*/
|
|
67
|
+
show(): void;
|
|
68
68
|
}
|
|
@@ -4,10 +4,40 @@ import { pulse } from './indicator.pulse.js';
|
|
|
4
4
|
*/
|
|
5
5
|
export class Component extends HTMLElement {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Class constructor
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
/**
|
|
12
|
+
* Status indicator colors
|
|
13
|
+
*/
|
|
14
|
+
this.colors = {
|
|
15
|
+
error: [220, 38, 38, 1],
|
|
16
|
+
pending: [59, 130, 246, 1],
|
|
17
|
+
success: [4, 120, 87, 1],
|
|
18
|
+
warn: [252, 211, 77, 1],
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Component name
|
|
22
|
+
*/
|
|
23
|
+
this.name = `bud-activity-indicator`;
|
|
24
|
+
this.renderShadow();
|
|
25
|
+
}
|
|
26
|
+
static get observedAttributes() {
|
|
27
|
+
return [`has-errors`, `has-warnings`, `action`];
|
|
28
|
+
}
|
|
29
|
+
attributeChangedCallback() {
|
|
30
|
+
if (this.hasAttribute(`has-errors`))
|
|
31
|
+
return this.onError();
|
|
32
|
+
if (this.hasAttribute(`has-warnings`))
|
|
33
|
+
return this.onWarning();
|
|
34
|
+
if (!this.hasAttribute(`has-errors`) &&
|
|
35
|
+
!this.hasAttribute(`has-warnings`) &&
|
|
36
|
+
this.getAttribute(`action`) === `built`)
|
|
37
|
+
return this.onSuccess();
|
|
38
|
+
if (this.getAttribute(`action`) == `building` ||
|
|
39
|
+
this.getAttribute(`action`) == `sync`)
|
|
40
|
+
return this.onPending();
|
|
11
41
|
}
|
|
12
42
|
/**
|
|
13
43
|
* Get accessor: has errors
|
|
@@ -22,24 +52,54 @@ export class Component extends HTMLElement {
|
|
|
22
52
|
return this.getAttribute(`has-warnings`) == `true`;
|
|
23
53
|
}
|
|
24
54
|
/**
|
|
25
|
-
*
|
|
55
|
+
* Hide status indicator
|
|
26
56
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
hide() {
|
|
58
|
+
this.hideTimeout = setTimeout(() => {
|
|
59
|
+
this.shadowRoot.querySelector(this.selector).classList.remove(`show`);
|
|
60
|
+
}, 2000);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Status is error
|
|
64
|
+
*/
|
|
65
|
+
onError() {
|
|
66
|
+
this.show();
|
|
67
|
+
this.shadowRoot
|
|
68
|
+
.querySelector(this.selector)
|
|
69
|
+
.classList.remove(`warning`, `success`, `pending`);
|
|
70
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`error`);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Status is pending
|
|
74
|
+
*/
|
|
75
|
+
onPending() {
|
|
76
|
+
this.show();
|
|
77
|
+
this.shadowRoot
|
|
78
|
+
.querySelector(this.selector)
|
|
79
|
+
.classList.remove(`error`, `warning`, `success`);
|
|
80
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`pending`);
|
|
81
|
+
this.hide();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Status is success
|
|
85
|
+
*/
|
|
86
|
+
onSuccess() {
|
|
87
|
+
this.show();
|
|
88
|
+
this.shadowRoot
|
|
89
|
+
.querySelector(this.selector)
|
|
90
|
+
.classList.remove(`error`, `warning`, `pending`);
|
|
91
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`success`);
|
|
92
|
+
this.hide();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Status is warning
|
|
96
|
+
*/
|
|
97
|
+
onWarning() {
|
|
98
|
+
this.show();
|
|
99
|
+
this.shadowRoot
|
|
100
|
+
.querySelector(this.selector)
|
|
101
|
+
.classList.remove(`error`, `success`, `pending`);
|
|
102
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`warning`);
|
|
43
103
|
}
|
|
44
104
|
/**
|
|
45
105
|
* Render status indicator
|
|
@@ -86,6 +146,12 @@ export class Component extends HTMLElement {
|
|
|
86
146
|
`;
|
|
87
147
|
this.attachShadow({ mode: `open` }).appendChild(container);
|
|
88
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Root div querySelector selector
|
|
151
|
+
*/
|
|
152
|
+
get selector() {
|
|
153
|
+
return `.${this.name}`;
|
|
154
|
+
}
|
|
89
155
|
/**
|
|
90
156
|
* Show status indicator
|
|
91
157
|
*/
|
|
@@ -93,70 +159,4 @@ export class Component extends HTMLElement {
|
|
|
93
159
|
this.hideTimeout && clearTimeout(this.hideTimeout);
|
|
94
160
|
this.shadowRoot.querySelector(this.selector).classList.add(`show`);
|
|
95
161
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Hide status indicator
|
|
98
|
-
*/
|
|
99
|
-
hide() {
|
|
100
|
-
this.hideTimeout = setTimeout(() => {
|
|
101
|
-
this.shadowRoot.querySelector(this.selector).classList.remove(`show`);
|
|
102
|
-
}, 2000);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Status is pending
|
|
106
|
-
*/
|
|
107
|
-
onPending() {
|
|
108
|
-
this.show();
|
|
109
|
-
this.shadowRoot
|
|
110
|
-
.querySelector(this.selector)
|
|
111
|
-
.classList.remove(`error`, `warning`, `success`);
|
|
112
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`pending`);
|
|
113
|
-
this.hide();
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Status is success
|
|
117
|
-
*/
|
|
118
|
-
onSuccess() {
|
|
119
|
-
this.show();
|
|
120
|
-
this.shadowRoot
|
|
121
|
-
.querySelector(this.selector)
|
|
122
|
-
.classList.remove(`error`, `warning`, `pending`);
|
|
123
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`success`);
|
|
124
|
-
this.hide();
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Status is error
|
|
128
|
-
*/
|
|
129
|
-
onError() {
|
|
130
|
-
this.show();
|
|
131
|
-
this.shadowRoot
|
|
132
|
-
.querySelector(this.selector)
|
|
133
|
-
.classList.remove(`warning`, `success`, `pending`);
|
|
134
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`error`);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Status is warning
|
|
138
|
-
*/
|
|
139
|
-
onWarning() {
|
|
140
|
-
this.show();
|
|
141
|
-
this.shadowRoot
|
|
142
|
-
.querySelector(this.selector)
|
|
143
|
-
.classList.remove(`error`, `success`, `pending`);
|
|
144
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`warning`);
|
|
145
|
-
}
|
|
146
|
-
static get observedAttributes() {
|
|
147
|
-
return [`has-errors`, `has-warnings`, `action`];
|
|
148
|
-
}
|
|
149
|
-
attributeChangedCallback() {
|
|
150
|
-
if (this.hasAttribute(`has-errors`))
|
|
151
|
-
return this.onError();
|
|
152
|
-
if (this.hasAttribute(`has-warnings`))
|
|
153
|
-
return this.onWarning();
|
|
154
|
-
if (!this.hasAttribute(`has-errors`) &&
|
|
155
|
-
!this.hasAttribute(`has-warnings`) &&
|
|
156
|
-
this.getAttribute(`action`) === `built`)
|
|
157
|
-
return this.onSuccess();
|
|
158
|
-
if (this.getAttribute(`action`) == `building` ||
|
|
159
|
-
this.getAttribute(`action`) == `sync`)
|
|
160
|
-
return this.onPending();
|
|
161
|
-
}
|
|
162
162
|
}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Component container
|
|
3
3
|
*/
|
|
4
4
|
export declare class Component extends HTMLElement {
|
|
5
|
+
documentBodyStyle: any;
|
|
5
6
|
name: string;
|
|
6
7
|
/**
|
|
7
8
|
* WHM payload
|
|
8
9
|
*/
|
|
9
10
|
payload: any;
|
|
10
|
-
documentBodyStyle: any;
|
|
11
|
-
get message(): string;
|
|
12
11
|
constructor();
|
|
13
|
-
renderShadow(): void;
|
|
14
12
|
static get observedAttributes(): string[];
|
|
15
13
|
attributeChangedCallback(): void;
|
|
16
14
|
connectedCallback(): void;
|
|
15
|
+
get message(): string;
|
|
16
|
+
renderShadow(): void;
|
|
17
17
|
}
|
|
@@ -2,14 +2,36 @@
|
|
|
2
2
|
* Component container
|
|
3
3
|
*/
|
|
4
4
|
export class Component extends HTMLElement {
|
|
5
|
-
get message() {
|
|
6
|
-
return this.getAttribute(`message`);
|
|
7
|
-
}
|
|
8
5
|
constructor() {
|
|
9
6
|
super();
|
|
10
7
|
this.name = `bud-overlay`;
|
|
11
8
|
this.renderShadow();
|
|
12
9
|
}
|
|
10
|
+
static get observedAttributes() {
|
|
11
|
+
return [`message`];
|
|
12
|
+
}
|
|
13
|
+
attributeChangedCallback() {
|
|
14
|
+
if (!this.documentBodyStyle)
|
|
15
|
+
this.documentBodyStyle = document.body?.style;
|
|
16
|
+
if (this.getAttribute(`message`)) {
|
|
17
|
+
document.body.style.overflow = `hidden`;
|
|
18
|
+
this.shadowRoot.querySelector(`.overlay`).classList.add(`visible`);
|
|
19
|
+
this.shadowRoot.querySelector(`.messages`).innerHTML =
|
|
20
|
+
this.getAttribute(`message`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.documentBodyStyle?.overflow && document?.body?.style) {
|
|
24
|
+
document.body.style.overflow = this.documentBodyStyle.overflow;
|
|
25
|
+
}
|
|
26
|
+
this.shadowRoot.querySelector(`.overlay`).classList.remove(`visible`);
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
if (document.body?.style)
|
|
30
|
+
this.documentBodyStyle = document.body.style;
|
|
31
|
+
}
|
|
32
|
+
get message() {
|
|
33
|
+
return this.getAttribute(`message`);
|
|
34
|
+
}
|
|
13
35
|
renderShadow() {
|
|
14
36
|
const container = document.createElement(`div`);
|
|
15
37
|
container.classList.add(`overlay`);
|
|
@@ -119,26 +141,4 @@ export class Component extends HTMLElement {
|
|
|
119
141
|
`;
|
|
120
142
|
this.attachShadow({ mode: `open` }).appendChild(container);
|
|
121
143
|
}
|
|
122
|
-
static get observedAttributes() {
|
|
123
|
-
return [`message`];
|
|
124
|
-
}
|
|
125
|
-
attributeChangedCallback() {
|
|
126
|
-
if (!this.documentBodyStyle)
|
|
127
|
-
this.documentBodyStyle = document.body?.style;
|
|
128
|
-
if (this.getAttribute(`message`)) {
|
|
129
|
-
document.body.style.overflow = `hidden`;
|
|
130
|
-
this.shadowRoot.querySelector(`.overlay`).classList.add(`visible`);
|
|
131
|
-
this.shadowRoot.querySelector(`.messages`).innerHTML =
|
|
132
|
-
this.getAttribute(`message`);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (this.documentBodyStyle?.overflow && document?.body?.style) {
|
|
136
|
-
document.body.style.overflow = this.documentBodyStyle.overflow;
|
|
137
|
-
}
|
|
138
|
-
this.shadowRoot.querySelector(`.overlay`).classList.remove(`visible`);
|
|
139
|
-
}
|
|
140
|
-
connectedCallback() {
|
|
141
|
-
if (document.body?.style)
|
|
142
|
-
this.documentBodyStyle = document.body.style;
|
|
143
|
-
}
|
|
144
144
|
}
|
|
@@ -10,10 +10,6 @@ export declare class Controller {
|
|
|
10
10
|
* HMR update
|
|
11
11
|
*/
|
|
12
12
|
payload: Payload;
|
|
13
|
-
/**
|
|
14
|
-
* Formatted error message
|
|
15
|
-
*/
|
|
16
|
-
get message(): string;
|
|
17
13
|
/**
|
|
18
14
|
* Class constructor
|
|
19
15
|
*/
|
|
@@ -22,6 +18,10 @@ export declare class Controller {
|
|
|
22
18
|
* Append `bud-error` element to the DOM
|
|
23
19
|
*/
|
|
24
20
|
createError(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Formatted error message
|
|
23
|
+
*/
|
|
24
|
+
get message(): string;
|
|
25
25
|
/**
|
|
26
26
|
* Remove `bud-error` element from the DOM (if present)
|
|
27
27
|
*/
|
|
@@ -7,20 +7,6 @@ const stripAnsi = (body) => body?.replace?.(new RegExp(ansiPattern, `g`), ``) ??
|
|
|
7
7
|
* Overlay controller
|
|
8
8
|
*/
|
|
9
9
|
export class Controller {
|
|
10
|
-
/**
|
|
11
|
-
* Formatted error message
|
|
12
|
-
*/
|
|
13
|
-
get message() {
|
|
14
|
-
return this.payload.errors?.reduce((a, c) => {
|
|
15
|
-
const msg = c?.message ?? c?.error ?? c;
|
|
16
|
-
if (!msg)
|
|
17
|
-
return a;
|
|
18
|
-
return `${a}
|
|
19
|
-
<div>
|
|
20
|
-
<pre>${stripAnsi(msg)}</pre>
|
|
21
|
-
</div>`;
|
|
22
|
-
}, ``);
|
|
23
|
-
}
|
|
24
10
|
/**
|
|
25
11
|
* Class constructor
|
|
26
12
|
*/
|
|
@@ -35,6 +21,20 @@ export class Controller {
|
|
|
35
21
|
!document.body.querySelector(`bud-error`) &&
|
|
36
22
|
document.body?.appendChild(this.element);
|
|
37
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Formatted error message
|
|
26
|
+
*/
|
|
27
|
+
get message() {
|
|
28
|
+
return this.payload.errors?.reduce((a, c) => {
|
|
29
|
+
const msg = c?.message ?? c?.error ?? c;
|
|
30
|
+
if (!msg)
|
|
31
|
+
return a;
|
|
32
|
+
return `${a}
|
|
33
|
+
<div>
|
|
34
|
+
<pre>${stripAnsi(msg)}</pre>
|
|
35
|
+
</div>`;
|
|
36
|
+
}, ``);
|
|
37
|
+
}
|
|
38
38
|
/**
|
|
39
39
|
* Remove `bud-error` element from the DOM (if present)
|
|
40
40
|
*/
|
package/lib/hot/events.d.ts
CHANGED
|
@@ -9,20 +9,20 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
listeners: Set<Listener>;
|
|
12
|
-
options: Partial<Options> & {
|
|
13
|
-
name: string;
|
|
14
|
-
path: string;
|
|
15
|
-
};
|
|
16
12
|
/**
|
|
17
|
-
* EventSource `
|
|
13
|
+
* EventSource `onmessage` handler
|
|
18
14
|
* @public
|
|
19
15
|
*/
|
|
20
|
-
|
|
16
|
+
onmessage: (payload: MessageEvent) => Promise<void>;
|
|
21
17
|
/**
|
|
22
|
-
* EventSource `
|
|
18
|
+
* EventSource `onopen` handler
|
|
23
19
|
* @public
|
|
24
20
|
*/
|
|
25
|
-
|
|
21
|
+
onopen: () => void;
|
|
22
|
+
options: Partial<Options> & {
|
|
23
|
+
name: string;
|
|
24
|
+
path: string;
|
|
25
|
+
};
|
|
26
26
|
/**
|
|
27
27
|
* EventSource `addMessageListener` handler
|
|
28
28
|
* @public
|
|
@@ -59,20 +59,20 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
|
|
|
59
59
|
* @public
|
|
60
60
|
*/
|
|
61
61
|
listeners: Set<Listener>;
|
|
62
|
-
options: Partial<Options> & {
|
|
63
|
-
name: string;
|
|
64
|
-
path: string;
|
|
65
|
-
};
|
|
66
62
|
/**
|
|
67
|
-
* EventSource `
|
|
63
|
+
* EventSource `onmessage` handler
|
|
68
64
|
* @public
|
|
69
65
|
*/
|
|
70
|
-
|
|
66
|
+
onmessage: (payload: MessageEvent) => Promise<void>;
|
|
71
67
|
/**
|
|
72
|
-
* EventSource `
|
|
68
|
+
* EventSource `onopen` handler
|
|
73
69
|
* @public
|
|
74
70
|
*/
|
|
75
|
-
|
|
71
|
+
onopen: () => void;
|
|
72
|
+
options: Partial<Options> & {
|
|
73
|
+
name: string;
|
|
74
|
+
path: string;
|
|
75
|
+
};
|
|
76
76
|
/**
|
|
77
77
|
* EventSource `addMessageListener` handler
|
|
78
78
|
* @public
|
package/lib/hot/events.js
CHANGED
|
@@ -25,11 +25,6 @@ export const injectEvents = (eventSource) => {
|
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
27
|
this.listeners = new Set();
|
|
28
|
-
/**
|
|
29
|
-
* EventSource `onopen` handler
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
this.onopen = function () { };
|
|
33
28
|
/**
|
|
34
29
|
* EventSource `onmessage` handler
|
|
35
30
|
* @public
|
|
@@ -48,6 +43,11 @@ export const injectEvents = (eventSource) => {
|
|
|
48
43
|
}
|
|
49
44
|
catch (ex) { }
|
|
50
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* EventSource `onopen` handler
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
this.onopen = function () { };
|
|
51
51
|
this.onopen = this.onopen.bind(this);
|
|
52
52
|
this.onmessage = this.onmessage.bind(this);
|
|
53
53
|
this.addListener = this.addListener.bind(this);
|
package/lib/hot/log.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const makeLogger: (options: Options) => {
|
|
2
|
-
log: (...args: any[]) => void;
|
|
3
2
|
error: (...args: any[]) => void;
|
|
4
|
-
warn: (...args: any[]) => void;
|
|
5
3
|
info: (...args: any[]) => void;
|
|
4
|
+
log: (...args: any[]) => void;
|
|
5
|
+
warn: (...args: any[]) => void;
|
|
6
6
|
};
|
|
7
7
|
export declare const makeLog: (options: any) => (...args: any[]) => void;
|
|
8
8
|
export declare const makeInfo: (options: any) => (...args: any[]) => void;
|
package/lib/hot/log.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
export const makeLogger = (options) => {
|
|
3
3
|
return {
|
|
4
|
-
log: makeLog(options),
|
|
5
4
|
error: makeError(options),
|
|
6
|
-
warn: makeWarn(options),
|
|
7
5
|
info: makeInfo(options),
|
|
6
|
+
log: makeLog(options),
|
|
7
|
+
warn: makeWarn(options),
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
let lastLog = null;
|
package/lib/hot/options.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Client options
|
|
3
3
|
*/
|
|
4
4
|
let data = {
|
|
5
|
-
timeout: 2000,
|
|
6
|
-
reload: true,
|
|
7
|
-
name: `@roots/bud-client`,
|
|
8
5
|
debug: true,
|
|
9
|
-
log: true,
|
|
10
6
|
indicator: true,
|
|
7
|
+
log: true,
|
|
8
|
+
name: `@roots/bud-client`,
|
|
11
9
|
overlay: true,
|
|
12
10
|
path: `/bud/hot`,
|
|
11
|
+
reload: true,
|
|
12
|
+
timeout: 2000,
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Get client option
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-client",
|
|
3
|
-
"version": "6.13.
|
|
3
|
+
"version": "6.13.1",
|
|
4
4
|
"description": "Client scripts for @roots/bud",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"types": "./lib/index.d.ts",
|
|
68
68
|
"module": "./lib/index.mjs",
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@roots/bud": "6.13.
|
|
70
|
+
"@roots/bud": "6.13.1",
|
|
71
71
|
"@skypack/package-check": "0.2.2",
|
|
72
|
-
"@types/node": "18.16.
|
|
73
|
-
"@types/webpack-env": "1.18.
|
|
72
|
+
"@types/node": "18.16.16",
|
|
73
|
+
"@types/webpack-env": "1.18.1"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"tslib": "2.5.
|
|
76
|
+
"tslib": "2.5.3"
|
|
77
77
|
},
|
|
78
78
|
"volta": {
|
|
79
79
|
"extends": "../../../package.json"
|
package/src/hot/client.ts
CHANGED
|
@@ -36,9 +36,9 @@ export const client = async (
|
|
|
36
36
|
|
|
37
37
|
if (typeof window.bud === `undefined`) {
|
|
38
38
|
window.bud = {
|
|
39
|
+
controllers: [],
|
|
39
40
|
current: {},
|
|
40
41
|
hmr: {},
|
|
41
|
-
controllers: [],
|
|
42
42
|
listeners: {},
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -96,12 +96,12 @@ export const client = async (
|
|
|
96
96
|
const update = async () => {
|
|
97
97
|
try {
|
|
98
98
|
await webpackHot.apply({
|
|
99
|
-
ignoreUnaccepted: true,
|
|
100
99
|
ignoreDeclined: true,
|
|
101
100
|
ignoreErrored: true,
|
|
101
|
+
ignoreUnaccepted: true,
|
|
102
|
+
onDeclined: onUnacceptedOrDeclined,
|
|
102
103
|
onErrored,
|
|
103
104
|
onUnaccepted: onUnacceptedOrDeclined,
|
|
104
|
-
onDeclined: onUnacceptedOrDeclined,
|
|
105
105
|
})
|
|
106
106
|
|
|
107
107
|
if (!isStale()) await check()
|
|
@@ -5,9 +5,19 @@ import {pulse} from './indicator.pulse.js'
|
|
|
5
5
|
*/
|
|
6
6
|
export class Component extends HTMLElement {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Status indicator colors
|
|
9
9
|
*/
|
|
10
|
-
public
|
|
10
|
+
public colors: Record<string, [number, number, number, number]> = {
|
|
11
|
+
error: [220, 38, 38, 1],
|
|
12
|
+
pending: [59, 130, 246, 1],
|
|
13
|
+
success: [4, 120, 87, 1],
|
|
14
|
+
warn: [252, 211, 77, 1],
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Timer
|
|
19
|
+
*/
|
|
20
|
+
public hideTimeout: NodeJS.Timer
|
|
11
21
|
|
|
12
22
|
/**
|
|
13
23
|
* Component name
|
|
@@ -15,16 +25,39 @@ export class Component extends HTMLElement {
|
|
|
15
25
|
public name: string = `bud-activity-indicator`
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
|
-
*
|
|
28
|
+
* Has component rendered
|
|
19
29
|
*/
|
|
20
|
-
public
|
|
21
|
-
return `.${this.name}`
|
|
22
|
-
}
|
|
30
|
+
public rendered: boolean
|
|
23
31
|
|
|
24
32
|
/**
|
|
25
|
-
*
|
|
33
|
+
* Class constructor
|
|
26
34
|
*/
|
|
27
|
-
public
|
|
35
|
+
public constructor() {
|
|
36
|
+
super()
|
|
37
|
+
this.renderShadow()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static get observedAttributes() {
|
|
41
|
+
return [`has-errors`, `has-warnings`, `action`]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public attributeChangedCallback() {
|
|
45
|
+
if (this.hasAttribute(`has-errors`)) return this.onError()
|
|
46
|
+
if (this.hasAttribute(`has-warnings`)) return this.onWarning()
|
|
47
|
+
|
|
48
|
+
if (
|
|
49
|
+
!this.hasAttribute(`has-errors`) &&
|
|
50
|
+
!this.hasAttribute(`has-warnings`) &&
|
|
51
|
+
this.getAttribute(`action`) === `built`
|
|
52
|
+
)
|
|
53
|
+
return this.onSuccess()
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
this.getAttribute(`action`) == `building` ||
|
|
57
|
+
this.getAttribute(`action`) == `sync`
|
|
58
|
+
)
|
|
59
|
+
return this.onPending()
|
|
60
|
+
}
|
|
28
61
|
|
|
29
62
|
/**
|
|
30
63
|
* Get accessor: has errors
|
|
@@ -41,21 +74,67 @@ export class Component extends HTMLElement {
|
|
|
41
74
|
}
|
|
42
75
|
|
|
43
76
|
/**
|
|
44
|
-
*
|
|
77
|
+
* Hide status indicator
|
|
45
78
|
*/
|
|
46
|
-
public
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
pending: [59, 130, 246, 1],
|
|
79
|
+
public hide() {
|
|
80
|
+
this.hideTimeout = setTimeout(() => {
|
|
81
|
+
this.shadowRoot.querySelector(this.selector).classList.remove(`show`)
|
|
82
|
+
}, 2000)
|
|
51
83
|
}
|
|
52
84
|
|
|
53
85
|
/**
|
|
54
|
-
*
|
|
86
|
+
* Status is error
|
|
55
87
|
*/
|
|
56
|
-
public
|
|
57
|
-
|
|
58
|
-
|
|
88
|
+
public onError() {
|
|
89
|
+
this.show()
|
|
90
|
+
|
|
91
|
+
this.shadowRoot
|
|
92
|
+
.querySelector(this.selector)
|
|
93
|
+
.classList.remove(`warning`, `success`, `pending`)
|
|
94
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`error`)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Status is pending
|
|
99
|
+
*/
|
|
100
|
+
public onPending() {
|
|
101
|
+
this.show()
|
|
102
|
+
|
|
103
|
+
this.shadowRoot
|
|
104
|
+
.querySelector(this.selector)
|
|
105
|
+
.classList.remove(`error`, `warning`, `success`)
|
|
106
|
+
|
|
107
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`pending`)
|
|
108
|
+
|
|
109
|
+
this.hide()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Status is success
|
|
114
|
+
*/
|
|
115
|
+
public onSuccess() {
|
|
116
|
+
this.show()
|
|
117
|
+
|
|
118
|
+
this.shadowRoot
|
|
119
|
+
.querySelector(this.selector)
|
|
120
|
+
.classList.remove(`error`, `warning`, `pending`)
|
|
121
|
+
|
|
122
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`success`)
|
|
123
|
+
|
|
124
|
+
this.hide()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Status is warning
|
|
129
|
+
*/
|
|
130
|
+
public onWarning() {
|
|
131
|
+
this.show()
|
|
132
|
+
|
|
133
|
+
this.shadowRoot
|
|
134
|
+
.querySelector(this.selector)
|
|
135
|
+
.classList.remove(`error`, `success`, `pending`)
|
|
136
|
+
|
|
137
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`warning`)
|
|
59
138
|
}
|
|
60
139
|
|
|
61
140
|
/**
|
|
@@ -106,96 +185,17 @@ export class Component extends HTMLElement {
|
|
|
106
185
|
}
|
|
107
186
|
|
|
108
187
|
/**
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
public show() {
|
|
112
|
-
this.hideTimeout && clearTimeout(this.hideTimeout)
|
|
113
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`show`)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Hide status indicator
|
|
118
|
-
*/
|
|
119
|
-
public hide() {
|
|
120
|
-
this.hideTimeout = setTimeout(() => {
|
|
121
|
-
this.shadowRoot.querySelector(this.selector).classList.remove(`show`)
|
|
122
|
-
}, 2000)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Status is pending
|
|
127
|
-
*/
|
|
128
|
-
public onPending() {
|
|
129
|
-
this.show()
|
|
130
|
-
|
|
131
|
-
this.shadowRoot
|
|
132
|
-
.querySelector(this.selector)
|
|
133
|
-
.classList.remove(`error`, `warning`, `success`)
|
|
134
|
-
|
|
135
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`pending`)
|
|
136
|
-
|
|
137
|
-
this.hide()
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Status is success
|
|
142
|
-
*/
|
|
143
|
-
public onSuccess() {
|
|
144
|
-
this.show()
|
|
145
|
-
|
|
146
|
-
this.shadowRoot
|
|
147
|
-
.querySelector(this.selector)
|
|
148
|
-
.classList.remove(`error`, `warning`, `pending`)
|
|
149
|
-
|
|
150
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`success`)
|
|
151
|
-
|
|
152
|
-
this.hide()
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Status is error
|
|
188
|
+
* Root div querySelector selector
|
|
157
189
|
*/
|
|
158
|
-
public
|
|
159
|
-
this.
|
|
160
|
-
|
|
161
|
-
this.shadowRoot
|
|
162
|
-
.querySelector(this.selector)
|
|
163
|
-
.classList.remove(`warning`, `success`, `pending`)
|
|
164
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`error`)
|
|
190
|
+
public get selector() {
|
|
191
|
+
return `.${this.name}`
|
|
165
192
|
}
|
|
166
193
|
|
|
167
194
|
/**
|
|
168
|
-
*
|
|
195
|
+
* Show status indicator
|
|
169
196
|
*/
|
|
170
|
-
public
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
this.shadowRoot
|
|
174
|
-
.querySelector(this.selector)
|
|
175
|
-
.classList.remove(`error`, `success`, `pending`)
|
|
176
|
-
|
|
177
|
-
this.shadowRoot.querySelector(this.selector).classList.add(`warning`)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public static get observedAttributes() {
|
|
181
|
-
return [`has-errors`, `has-warnings`, `action`]
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public attributeChangedCallback() {
|
|
185
|
-
if (this.hasAttribute(`has-errors`)) return this.onError()
|
|
186
|
-
if (this.hasAttribute(`has-warnings`)) return this.onWarning()
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
!this.hasAttribute(`has-errors`) &&
|
|
190
|
-
!this.hasAttribute(`has-warnings`) &&
|
|
191
|
-
this.getAttribute(`action`) === `built`
|
|
192
|
-
)
|
|
193
|
-
return this.onSuccess()
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
this.getAttribute(`action`) == `building` ||
|
|
197
|
-
this.getAttribute(`action`) == `sync`
|
|
198
|
-
)
|
|
199
|
-
return this.onPending()
|
|
197
|
+
public show() {
|
|
198
|
+
this.hideTimeout && clearTimeout(this.hideTimeout)
|
|
199
|
+
this.shadowRoot.querySelector(this.selector).classList.add(`show`)
|
|
200
200
|
}
|
|
201
201
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Component container
|
|
3
3
|
*/
|
|
4
4
|
export class Component extends HTMLElement {
|
|
5
|
+
public documentBodyStyle: any
|
|
6
|
+
|
|
5
7
|
public name: string = `bud-overlay`
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -9,17 +11,45 @@ export class Component extends HTMLElement {
|
|
|
9
11
|
*/
|
|
10
12
|
public payload: any
|
|
11
13
|
|
|
12
|
-
public documentBodyStyle: any
|
|
13
|
-
|
|
14
|
-
public get message() {
|
|
15
|
-
return this.getAttribute(`message`)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
public constructor() {
|
|
19
15
|
super()
|
|
20
16
|
this.renderShadow()
|
|
21
17
|
}
|
|
22
18
|
|
|
19
|
+
public static get observedAttributes() {
|
|
20
|
+
return [`message`]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public attributeChangedCallback() {
|
|
24
|
+
if (!this.documentBodyStyle)
|
|
25
|
+
this.documentBodyStyle = document.body?.style
|
|
26
|
+
|
|
27
|
+
if (this.getAttribute(`message`)) {
|
|
28
|
+
document.body.style.overflow = `hidden`
|
|
29
|
+
|
|
30
|
+
this.shadowRoot.querySelector(`.overlay`).classList.add(`visible`)
|
|
31
|
+
|
|
32
|
+
this.shadowRoot.querySelector(`.messages`).innerHTML =
|
|
33
|
+
this.getAttribute(`message`)
|
|
34
|
+
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.documentBodyStyle?.overflow && document?.body?.style) {
|
|
39
|
+
document.body.style.overflow = this.documentBodyStyle.overflow
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.shadowRoot.querySelector(`.overlay`).classList.remove(`visible`)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public connectedCallback() {
|
|
46
|
+
if (document.body?.style) this.documentBodyStyle = document.body.style
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public get message() {
|
|
50
|
+
return this.getAttribute(`message`)
|
|
51
|
+
}
|
|
52
|
+
|
|
23
53
|
public renderShadow(): void {
|
|
24
54
|
const container = document.createElement(`div`)
|
|
25
55
|
container.classList.add(`overlay`)
|
|
@@ -130,34 +160,4 @@ export class Component extends HTMLElement {
|
|
|
130
160
|
|
|
131
161
|
this.attachShadow({mode: `open`}).appendChild(container)
|
|
132
162
|
}
|
|
133
|
-
|
|
134
|
-
public static get observedAttributes() {
|
|
135
|
-
return [`message`]
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public attributeChangedCallback() {
|
|
139
|
-
if (!this.documentBodyStyle)
|
|
140
|
-
this.documentBodyStyle = document.body?.style
|
|
141
|
-
|
|
142
|
-
if (this.getAttribute(`message`)) {
|
|
143
|
-
document.body.style.overflow = `hidden`
|
|
144
|
-
|
|
145
|
-
this.shadowRoot.querySelector(`.overlay`).classList.add(`visible`)
|
|
146
|
-
|
|
147
|
-
this.shadowRoot.querySelector(`.messages`).innerHTML =
|
|
148
|
-
this.getAttribute(`message`)
|
|
149
|
-
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (this.documentBodyStyle?.overflow && document?.body?.style) {
|
|
154
|
-
document.body.style.overflow = this.documentBodyStyle.overflow
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.shadowRoot.querySelector(`.overlay`).classList.remove(`visible`)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public connectedCallback() {
|
|
161
|
-
if (document.body?.style) this.documentBodyStyle = document.body.style
|
|
162
|
-
}
|
|
163
163
|
}
|
|
@@ -20,20 +20,6 @@ export class Controller {
|
|
|
20
20
|
*/
|
|
21
21
|
public payload: Payload
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Formatted error message
|
|
25
|
-
*/
|
|
26
|
-
public get message(): string {
|
|
27
|
-
return this.payload.errors?.reduce((a, c) => {
|
|
28
|
-
const msg = c?.message ?? c?.error ?? c
|
|
29
|
-
if (!msg) return a
|
|
30
|
-
return `${a}
|
|
31
|
-
<div>
|
|
32
|
-
<pre>${stripAnsi(msg)}</pre>
|
|
33
|
-
</div>`
|
|
34
|
-
}, ``)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
23
|
/**
|
|
38
24
|
* Class constructor
|
|
39
25
|
*/
|
|
@@ -50,6 +36,20 @@ export class Controller {
|
|
|
50
36
|
document.body?.appendChild(this.element)
|
|
51
37
|
}
|
|
52
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Formatted error message
|
|
41
|
+
*/
|
|
42
|
+
public get message(): string {
|
|
43
|
+
return this.payload.errors?.reduce((a, c) => {
|
|
44
|
+
const msg = c?.message ?? c?.error ?? c
|
|
45
|
+
if (!msg) return a
|
|
46
|
+
return `${a}
|
|
47
|
+
<div>
|
|
48
|
+
<pre>${stripAnsi(msg)}</pre>
|
|
49
|
+
</div>`
|
|
50
|
+
}, ``)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
53
|
/**
|
|
54
54
|
* Remove `bud-error` element from the DOM (if present)
|
|
55
55
|
*/
|
package/src/hot/events.ts
CHANGED
|
@@ -18,6 +18,33 @@ export const injectEvents = (
|
|
|
18
18
|
*/
|
|
19
19
|
public listeners: Set<Listener> = new Set<Listener>()
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* EventSource `onmessage` handler
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
public override onmessage = async function (payload: MessageEvent) {
|
|
26
|
+
if (!payload?.data || payload.data == `\uD83D\uDC93`) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const data = JSON.parse(payload.data)
|
|
32
|
+
if (!data) return
|
|
33
|
+
|
|
34
|
+
await Promise.all(
|
|
35
|
+
[...this.listeners].map(async listener => {
|
|
36
|
+
return await listener(data)
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
} catch (ex) {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* EventSource `onopen` handler
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
public override onopen = function () {}
|
|
47
|
+
|
|
21
48
|
/**
|
|
22
49
|
* Class constructor
|
|
23
50
|
*
|
|
@@ -52,33 +79,6 @@ export const injectEvents = (
|
|
|
52
79
|
return window.bud.hmr[options.name]
|
|
53
80
|
}
|
|
54
81
|
|
|
55
|
-
/**
|
|
56
|
-
* EventSource `onopen` handler
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
public override onopen = function () {}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* EventSource `onmessage` handler
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
|
-
public override onmessage = async function (payload: MessageEvent) {
|
|
66
|
-
if (!payload?.data || payload.data == `\uD83D\uDC93`) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const data = JSON.parse(payload.data)
|
|
72
|
-
if (!data) return
|
|
73
|
-
|
|
74
|
-
await Promise.all(
|
|
75
|
-
[...this.listeners].map(async listener => {
|
|
76
|
-
return await listener(data)
|
|
77
|
-
}),
|
|
78
|
-
)
|
|
79
|
-
} catch (ex) {}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
82
|
/**
|
|
83
83
|
* EventSource `addMessageListener` handler
|
|
84
84
|
* @public
|
package/src/hot/log.ts
CHANGED
package/src/hot/options.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Client options
|
|
3
3
|
*/
|
|
4
4
|
let data: Options = {
|
|
5
|
-
timeout: 2000,
|
|
6
|
-
reload: true,
|
|
7
|
-
name: `@roots/bud-client`,
|
|
8
5
|
debug: true,
|
|
9
|
-
log: true,
|
|
10
6
|
indicator: true,
|
|
7
|
+
log: true,
|
|
8
|
+
name: `@roots/bud-client`,
|
|
11
9
|
overlay: true,
|
|
12
10
|
path: `/bud/hot`,
|
|
11
|
+
reload: true,
|
|
12
|
+
timeout: 2000,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
package/src/intercept/index.ts
CHANGED