@roots/bud-client 6.12.3 → 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 +31 -40
- package/lib/hot/components/index.js +7 -16
- package/lib/hot/components/indicator/index.js +2 -11
- package/lib/hot/components/indicator/indicator.component.d.ts +29 -29
- package/lib/hot/components/indicator/indicator.component.js +86 -86
- package/lib/hot/components/indicator/indicator.controller.d.ts +1 -1
- package/lib/hot/components/indicator/indicator.controller.js +4 -7
- package/lib/hot/components/overlay/index.js +2 -11
- package/lib/hot/components/overlay/overlay.component.d.ts +3 -3
- package/lib/hot/components/overlay/overlay.component.js +25 -27
- package/lib/hot/components/overlay/overlay.controller.d.ts +4 -4
- package/lib/hot/components/overlay/overlay.controller.js +19 -24
- package/lib/hot/events.d.ts +22 -22
- package/lib/hot/events.js +17 -28
- package/lib/hot/index.js +16 -0
- package/lib/hot/log.d.ts +2 -2
- package/lib/hot/log.js +2 -2
- package/lib/hot/options.js +5 -5
- package/{src/index.mts → lib/index.js} +1 -3
- package/lib/intercept/proxy-click-interceptor.js +11 -22
- package/package.json +9 -9
- package/src/hot/client.ts +7 -5
- 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/index.ts +17 -0
- package/src/hot/log.ts +2 -2
- package/src/hot/options.ts +4 -4
- package/src/intercept/index.ts +1 -1
- package/lib/hot/index.cjs +0 -5
- package/lib/hot/index.d.mts +0 -1
- package/lib/hot/index.mjs +0 -17
- package/lib/index.cjs +0 -3
- package/lib/index.d.mts +0 -12
- package/lib/index.mjs +0 -3
- package/src/hot/client.test.ts +0 -78
- package/src/hot/index.cts +0 -7
- package/src/hot/index.mts +0 -9
- /package/lib/hot/{index.d.cts → index.d.ts} +0 -0
- /package/lib/{index.d.cts → index.d.ts} +0 -0
- /package/src/{index.cts → index.ts} +0 -0
package/lib/hot/client.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
/* global __resourceQuery */
|
|
3
3
|
/* global __webpack_hash__ */
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
4
|
import * as components from './components/index.js';
|
|
14
5
|
import { injectEvents } from './events.js';
|
|
15
6
|
import { makeLogger } from './log.js';
|
|
@@ -17,9 +8,9 @@ import * as clientOptions from './options.js';
|
|
|
17
8
|
/**
|
|
18
9
|
* Initializes bud.js HMR handling
|
|
19
10
|
*/
|
|
20
|
-
export const client = (queryString, webpackHot) =>
|
|
11
|
+
export const client = async (queryString, webpackHot) => {
|
|
21
12
|
/* Guard: EventSource browser support */
|
|
22
|
-
if (typeof
|
|
13
|
+
if (typeof window?.EventSource === `undefined`) {
|
|
23
14
|
console.error(`[bud] hot module reload requires EventSource to work. https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools`);
|
|
24
15
|
return false;
|
|
25
16
|
}
|
|
@@ -34,9 +25,9 @@ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, voi
|
|
|
34
25
|
const logger = makeLogger(options);
|
|
35
26
|
if (typeof window.bud === `undefined`) {
|
|
36
27
|
window.bud = {
|
|
28
|
+
controllers: [],
|
|
37
29
|
current: {},
|
|
38
30
|
hmr: {},
|
|
39
|
-
controllers: [],
|
|
40
31
|
listeners: {},
|
|
41
32
|
};
|
|
42
33
|
}
|
|
@@ -51,21 +42,19 @@ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, voi
|
|
|
51
42
|
/**
|
|
52
43
|
* Webpack HMR check handler
|
|
53
44
|
*/
|
|
54
|
-
const check = () =>
|
|
45
|
+
const check = async () => {
|
|
55
46
|
if (webpackHot.status() === `idle`) {
|
|
56
|
-
|
|
57
|
-
requestAnimationFrame(function whenReady() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
});
|
|
47
|
+
await webpackHot.check(false);
|
|
48
|
+
requestAnimationFrame(async function whenReady() {
|
|
49
|
+
if (webpackHot.status() === `ready`) {
|
|
50
|
+
await update();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
requestAnimationFrame(whenReady);
|
|
54
|
+
}
|
|
66
55
|
});
|
|
67
56
|
}
|
|
68
|
-
}
|
|
57
|
+
};
|
|
69
58
|
/**
|
|
70
59
|
* Webpack HMR unaccepted module handler
|
|
71
60
|
*/
|
|
@@ -77,45 +66,47 @@ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, voi
|
|
|
77
66
|
* Webpack HMR error handler
|
|
78
67
|
*/
|
|
79
68
|
const onErrored = (error) => {
|
|
80
|
-
window.bud.controllers.map(controller => controller
|
|
69
|
+
window.bud.controllers.map(controller => controller?.update({
|
|
81
70
|
errors: [error],
|
|
82
71
|
}));
|
|
83
72
|
};
|
|
84
73
|
/**
|
|
85
74
|
* Webpack HMR update handler
|
|
86
75
|
*/
|
|
87
|
-
const update = () =>
|
|
76
|
+
const update = async () => {
|
|
88
77
|
try {
|
|
89
|
-
|
|
90
|
-
ignoreUnaccepted: true,
|
|
78
|
+
await webpackHot.apply({
|
|
91
79
|
ignoreDeclined: true,
|
|
92
80
|
ignoreErrored: true,
|
|
81
|
+
ignoreUnaccepted: true,
|
|
82
|
+
onDeclined: onUnacceptedOrDeclined,
|
|
93
83
|
onErrored,
|
|
94
84
|
onUnaccepted: onUnacceptedOrDeclined,
|
|
95
|
-
onDeclined: onUnacceptedOrDeclined,
|
|
96
85
|
});
|
|
97
86
|
if (!isStale())
|
|
98
|
-
|
|
87
|
+
await check();
|
|
99
88
|
}
|
|
100
89
|
catch (error) {
|
|
101
90
|
logger.error(error);
|
|
102
91
|
}
|
|
103
|
-
}
|
|
92
|
+
};
|
|
104
93
|
/* Instantiate indicator, overlay */
|
|
105
|
-
|
|
94
|
+
try {
|
|
95
|
+
await components.make(options);
|
|
96
|
+
}
|
|
97
|
+
catch (error) { }
|
|
106
98
|
/* Instantiate eventSource */
|
|
107
99
|
const events = injectEvents(EventSource).make(options);
|
|
108
|
-
if (!window.bud.listeners[options.name]) {
|
|
109
|
-
window.bud.listeners[options.name] = (payload) =>
|
|
110
|
-
var _a;
|
|
100
|
+
if (!window.bud.listeners?.[options.name]) {
|
|
101
|
+
window.bud.listeners[options.name] = async (payload) => {
|
|
111
102
|
if (!payload)
|
|
112
103
|
return;
|
|
113
104
|
if (options.reload && payload.action === `reload`)
|
|
114
105
|
return window.location.reload();
|
|
115
106
|
if (payload.name !== options.name)
|
|
116
107
|
return;
|
|
117
|
-
window.bud.controllers.map(controller => controller
|
|
118
|
-
if (
|
|
108
|
+
window.bud.controllers.map(controller => controller?.update(payload));
|
|
109
|
+
if (payload.errors?.length > 0)
|
|
119
110
|
return;
|
|
120
111
|
if (payload.action === `built` || payload.action === `sync`) {
|
|
121
112
|
if (isStale(payload.hash))
|
|
@@ -123,13 +114,13 @@ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, voi
|
|
|
123
114
|
if (payload.action === `built`) {
|
|
124
115
|
logger.log(`built in ${payload.time}ms`);
|
|
125
116
|
}
|
|
126
|
-
|
|
117
|
+
await check();
|
|
127
118
|
}
|
|
128
|
-
}
|
|
119
|
+
};
|
|
129
120
|
/*
|
|
130
121
|
* Instantiate HMR event source
|
|
131
122
|
* and register client listeners
|
|
132
123
|
*/
|
|
133
124
|
events.addListener(window.bud.listeners[options.name]);
|
|
134
125
|
}
|
|
135
|
-
}
|
|
126
|
+
};
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export const make = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1
|
+
export const make = async (options) => {
|
|
11
2
|
if (options.indicator && !customElements.get(`bud-activity-indicator`)) {
|
|
12
|
-
|
|
3
|
+
await import(`./indicator/index.js`)
|
|
13
4
|
.then(makeController)
|
|
14
5
|
.then(maybePushController);
|
|
15
6
|
}
|
|
16
7
|
if (options.overlay && !customElements.get(`bud-error`)) {
|
|
17
|
-
|
|
8
|
+
await import(`./overlay/index.js`)
|
|
18
9
|
.then(makeController)
|
|
19
10
|
.then(maybePushController);
|
|
20
11
|
}
|
|
21
12
|
return window.bud.controllers;
|
|
22
|
-
}
|
|
23
|
-
const makeController = (module) =>
|
|
13
|
+
};
|
|
14
|
+
const makeController = async (module) => {
|
|
24
15
|
if (!module)
|
|
25
16
|
return;
|
|
26
|
-
return
|
|
27
|
-
}
|
|
17
|
+
return await module.make();
|
|
18
|
+
};
|
|
28
19
|
const maybePushController = (controller) => {
|
|
29
20
|
if (!controller)
|
|
30
21
|
return;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { Component } from './indicator.component.js';
|
|
11
2
|
import { Controller } from './indicator.controller.js';
|
|
12
|
-
export const make = () =>
|
|
3
|
+
export const make = async () => {
|
|
13
4
|
if (customElements.get(`bud-activity-indicator`))
|
|
14
5
|
return;
|
|
15
6
|
customElements.define(`bud-activity-indicator`, Component);
|
|
16
7
|
return new Controller();
|
|
17
|
-
}
|
|
8
|
+
};
|
|
@@ -1,52 +1,46 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/**
|
|
3
3
|
* Indicator web component
|
|
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
|
}
|
|
@@ -17,29 +17,26 @@ export class Controller {
|
|
|
17
17
|
* Append `bud-error` element to the DOM
|
|
18
18
|
*/
|
|
19
19
|
addNode() {
|
|
20
|
-
var _a;
|
|
21
20
|
if (document.body.querySelector(`bud-activity-indicator`)) {
|
|
22
21
|
if (typeof this.timer.unref === `function`)
|
|
23
22
|
this.timer.unref();
|
|
24
23
|
this.removeNode();
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
document.body?.appendChild(this.node);
|
|
27
26
|
this.timer = setTimeout(this.removeNode, 3000);
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* Remove `bud-error` element from the DOM (if present)
|
|
31
30
|
*/
|
|
32
31
|
removeNode() {
|
|
33
|
-
|
|
34
|
-
(_a = document.body.querySelector(`bud-activity-indicator`)) === null || _a === void 0 ? void 0 : _a.remove();
|
|
32
|
+
document.body.querySelector(`bud-activity-indicator`)?.remove();
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
35
|
* Update activity indicator
|
|
38
36
|
*/
|
|
39
37
|
update(payload) {
|
|
40
|
-
|
|
41
|
-
this.node.toggleAttribute(`has-
|
|
42
|
-
this.node.toggleAttribute(`has-warnings`, ((_b = payload.warnings) === null || _b === void 0 ? void 0 : _b.length) ? true : false);
|
|
38
|
+
this.node.toggleAttribute(`has-errors`, payload.errors?.length ? true : false);
|
|
39
|
+
this.node.toggleAttribute(`has-warnings`, payload.warnings?.length ? true : false);
|
|
43
40
|
this.node.setAttribute(`action`, payload.action);
|
|
44
41
|
this.addNode();
|
|
45
42
|
}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { Component } from './overlay.component.js';
|
|
11
2
|
import { Controller } from './overlay.controller.js';
|
|
12
|
-
export const make = () =>
|
|
3
|
+
export const make = async () => {
|
|
13
4
|
if (customElements.get(`bud-error`))
|
|
14
5
|
return;
|
|
15
6
|
customElements.define(`bud-error`, Component);
|
|
16
7
|
return new Controller();
|
|
17
|
-
}
|
|
8
|
+
};
|
|
@@ -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,28 +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
|
-
var _a, _b, _c;
|
|
127
|
-
if (!this.documentBodyStyle)
|
|
128
|
-
this.documentBodyStyle = (_a = document.body) === null || _a === void 0 ? void 0 : _a.style;
|
|
129
|
-
if (this.getAttribute(`message`)) {
|
|
130
|
-
document.body.style.overflow = `hidden`;
|
|
131
|
-
this.shadowRoot.querySelector(`.overlay`).classList.add(`visible`);
|
|
132
|
-
this.shadowRoot.querySelector(`.messages`).innerHTML =
|
|
133
|
-
this.getAttribute(`message`);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (((_b = this.documentBodyStyle) === null || _b === void 0 ? void 0 : _b.overflow) && ((_c = document === null || document === void 0 ? void 0 : document.body) === null || _c === void 0 ? void 0 : _c.style)) {
|
|
137
|
-
document.body.style.overflow = this.documentBodyStyle.overflow;
|
|
138
|
-
}
|
|
139
|
-
this.shadowRoot.querySelector(`.overlay`).classList.remove(`visible`);
|
|
140
|
-
}
|
|
141
|
-
connectedCallback() {
|
|
142
|
-
var _a;
|
|
143
|
-
if ((_a = document.body) === null || _a === void 0 ? void 0 : _a.style)
|
|
144
|
-
this.documentBodyStyle = document.body.style;
|
|
145
|
-
}
|
|
146
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
|
*/
|