@roots/bud-client 2023.11.26-7 → 2023.11.28-1115
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 +5 -3
- package/lib/hot/components/indicator/indicator.component.js +4 -5
- package/lib/hot/components/indicator/indicator.controller.js +2 -2
- package/package.json +2 -2
- package/src/hot/client.ts +8 -4
- package/src/hot/components/indicator/indicator.component.ts +7 -8
- package/src/hot/components/indicator/indicator.controller.ts +2 -8
- package/src/types/index.d.ts +1 -1
package/lib/hot/client.js
CHANGED
|
@@ -65,13 +65,14 @@ export const client = async (queryString, webpackHot) => {
|
|
|
65
65
|
console.warn(`[${options.name}] ${info.type}`, info);
|
|
66
66
|
options.reload && window.location.reload();
|
|
67
67
|
};
|
|
68
|
+
const onAccepted = (info) => {
|
|
69
|
+
window.bud.controllers.map(controller => controller?.update({ action: `sync`, errors: [] }));
|
|
70
|
+
};
|
|
68
71
|
/**
|
|
69
72
|
* Webpack HMR error handler
|
|
70
73
|
*/
|
|
71
74
|
const onErrored = (error) => {
|
|
72
|
-
window.bud.controllers.map(controller => controller?.update({
|
|
73
|
-
errors: [error],
|
|
74
|
-
}));
|
|
75
|
+
window.bud.controllers.map(controller => controller?.update({ errors: [error] }));
|
|
75
76
|
};
|
|
76
77
|
/**
|
|
77
78
|
* Webpack HMR update handler
|
|
@@ -82,6 +83,7 @@ export const client = async (queryString, webpackHot) => {
|
|
|
82
83
|
ignoreDeclined: true,
|
|
83
84
|
ignoreErrored: true,
|
|
84
85
|
ignoreUnaccepted: true,
|
|
86
|
+
onAccepted,
|
|
85
87
|
onDeclined: onUnacceptedOrDeclined,
|
|
86
88
|
onErrored,
|
|
87
89
|
onUnaccepted: onUnacceptedOrDeclined,
|
|
@@ -35,6 +35,7 @@ export class Component extends HTMLElement {
|
|
|
35
35
|
.querySelector(this.selector)
|
|
36
36
|
.classList.remove(`warning`, `success`, `pending`);
|
|
37
37
|
this.shadowRoot.querySelector(this.selector).classList.add(`error`);
|
|
38
|
+
this.hide();
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Status is pending
|
|
@@ -67,19 +68,17 @@ export class Component extends HTMLElement {
|
|
|
67
68
|
.querySelector(this.selector)
|
|
68
69
|
.classList.remove(`error`, `success`, `pending`);
|
|
69
70
|
this.shadowRoot.querySelector(this.selector).classList.add(`warning`);
|
|
71
|
+
this.hide();
|
|
70
72
|
}
|
|
71
73
|
attributeChangedCallback() {
|
|
72
74
|
if (this.hasAttribute(`has-errors`))
|
|
73
75
|
return this.onError();
|
|
74
76
|
if (this.hasAttribute(`has-warnings`))
|
|
75
77
|
return this.onWarning();
|
|
76
|
-
if (!this.hasAttribute(`has-errors`) &&
|
|
77
|
-
!this.hasAttribute(`has-warnings`) &&
|
|
78
|
-
this.getAttribute(`action`) === `built`)
|
|
79
|
-
return this.onSuccess();
|
|
80
78
|
if (this.getAttribute(`action`) == `building` ||
|
|
81
79
|
this.getAttribute(`action`) == `sync`)
|
|
82
|
-
return this.
|
|
80
|
+
return this.onSuccess();
|
|
81
|
+
this.onPending();
|
|
83
82
|
}
|
|
84
83
|
/**
|
|
85
84
|
* Get accessor: has errors
|
|
@@ -35,8 +35,8 @@ export class Controller {
|
|
|
35
35
|
* Update activity indicator
|
|
36
36
|
*/
|
|
37
37
|
update(payload) {
|
|
38
|
-
this.node.toggleAttribute(`has-errors`, payload.errors?.length
|
|
39
|
-
this.node.toggleAttribute(`has-warnings`, payload.warnings?.length
|
|
38
|
+
this.node.toggleAttribute(`has-errors`, payload.errors?.length > 0);
|
|
39
|
+
this.node.toggleAttribute(`has-warnings`, payload.warnings?.length > 0);
|
|
40
40
|
this.node.setAttribute(`action`, payload.action);
|
|
41
41
|
this.addNode();
|
|
42
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-client",
|
|
3
|
-
"version": "2023.11.
|
|
3
|
+
"version": "2023.11.28-1115",
|
|
4
4
|
"description": "Client scripts for @roots/bud",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"types": "./lib/index.d.ts",
|
|
70
70
|
"module": "./lib/index.mjs",
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@roots/bud": "2023.11.
|
|
72
|
+
"@roots/bud": "2023.11.28-1115",
|
|
73
73
|
"@skypack/package-check": "0.2.2",
|
|
74
74
|
"@types/node": "20.9.0",
|
|
75
75
|
"@types/webpack-env": "1.18.4"
|
package/src/hot/client.ts
CHANGED
|
@@ -83,15 +83,18 @@ export const client = async (
|
|
|
83
83
|
options.reload && window.location.reload()
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
const onAccepted = (info: __WebpackModuleApi.HotNotifierInfo) => {
|
|
87
|
+
window.bud.controllers.map(
|
|
88
|
+
controller => controller?.update({action: `sync`, errors: []}),
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
/**
|
|
87
93
|
* Webpack HMR error handler
|
|
88
94
|
*/
|
|
89
95
|
const onErrored = (error: any) => {
|
|
90
96
|
window.bud.controllers.map(
|
|
91
|
-
controller =>
|
|
92
|
-
controller?.update({
|
|
93
|
-
errors: [error],
|
|
94
|
-
}),
|
|
97
|
+
controller => controller?.update({errors: [error]}),
|
|
95
98
|
)
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -104,6 +107,7 @@ export const client = async (
|
|
|
104
107
|
ignoreDeclined: true,
|
|
105
108
|
ignoreErrored: true,
|
|
106
109
|
ignoreUnaccepted: true,
|
|
110
|
+
onAccepted,
|
|
107
111
|
onDeclined: onUnacceptedOrDeclined,
|
|
108
112
|
onErrored,
|
|
109
113
|
onUnaccepted: onUnacceptedOrDeclined,
|
|
@@ -50,6 +50,8 @@ export class Component extends HTMLElement {
|
|
|
50
50
|
.querySelector(this.selector)
|
|
51
51
|
.classList.remove(`warning`, `success`, `pending`)
|
|
52
52
|
this.shadowRoot.querySelector(this.selector).classList.add(`error`)
|
|
53
|
+
|
|
54
|
+
this.hide()
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Status is pending
|
|
@@ -90,23 +92,20 @@ export class Component extends HTMLElement {
|
|
|
90
92
|
.classList.remove(`error`, `success`, `pending`)
|
|
91
93
|
|
|
92
94
|
this.shadowRoot.querySelector(this.selector).classList.add(`warning`)
|
|
95
|
+
|
|
96
|
+
this.hide()
|
|
93
97
|
}
|
|
94
98
|
public attributeChangedCallback() {
|
|
95
99
|
if (this.hasAttribute(`has-errors`)) return this.onError()
|
|
96
100
|
if (this.hasAttribute(`has-warnings`)) return this.onWarning()
|
|
97
101
|
|
|
98
|
-
if (
|
|
99
|
-
!this.hasAttribute(`has-errors`) &&
|
|
100
|
-
!this.hasAttribute(`has-warnings`) &&
|
|
101
|
-
this.getAttribute(`action`) === `built`
|
|
102
|
-
)
|
|
103
|
-
return this.onSuccess()
|
|
104
|
-
|
|
105
102
|
if (
|
|
106
103
|
this.getAttribute(`action`) == `building` ||
|
|
107
104
|
this.getAttribute(`action`) == `sync`
|
|
108
105
|
)
|
|
109
|
-
return this.
|
|
106
|
+
return this.onSuccess()
|
|
107
|
+
|
|
108
|
+
this.onPending()
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
/**
|
|
@@ -49,15 +49,9 @@ export class Controller {
|
|
|
49
49
|
* Update activity indicator
|
|
50
50
|
*/
|
|
51
51
|
public update(payload: Payload) {
|
|
52
|
-
this.node.toggleAttribute(
|
|
53
|
-
`has-errors`,
|
|
54
|
-
payload.errors?.length ? true : false,
|
|
55
|
-
)
|
|
52
|
+
this.node.toggleAttribute(`has-errors`, payload.errors?.length > 0)
|
|
56
53
|
|
|
57
|
-
this.node.toggleAttribute(
|
|
58
|
-
`has-warnings`,
|
|
59
|
-
payload.warnings?.length ? true : false,
|
|
60
|
-
)
|
|
54
|
+
this.node.toggleAttribute(`has-warnings`, payload.warnings?.length > 0)
|
|
61
55
|
|
|
62
56
|
this.node.setAttribute(`action`, payload.action)
|
|
63
57
|
|
package/src/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare interface Events {
|
|
|
16
16
|
declare interface Payload {
|
|
17
17
|
name: string
|
|
18
18
|
type: `middleware` | __WebpackModuleApi.HotNotifierInfo[`type`]
|
|
19
|
-
action
|
|
19
|
+
action?: 'reload' | 'sync' | 'building' | 'built'
|
|
20
20
|
hash?: string
|
|
21
21
|
time?: number
|
|
22
22
|
errors?: Array<Record<string, any>>
|