@roots/bud-client 6.10.0 → 6.12.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 (63) hide show
  1. package/lib/hot/client.d.ts +6 -0
  2. package/lib/hot/client.d.ts.map +1 -0
  3. package/lib/hot/client.js +135 -0
  4. package/lib/hot/components/index.d.ts +2 -0
  5. package/lib/hot/components/index.d.ts.map +1 -0
  6. package/lib/hot/components/index.js +32 -0
  7. package/lib/hot/components/indicator/index.d.ts +4 -0
  8. package/lib/hot/components/indicator/index.d.ts.map +1 -0
  9. package/lib/hot/components/indicator/index.js +17 -0
  10. package/lib/hot/components/indicator/indicator.component.d.ts +69 -0
  11. package/lib/hot/components/indicator/indicator.component.d.ts.map +1 -0
  12. package/lib/hot/components/indicator/indicator.component.js +162 -0
  13. package/lib/hot/components/indicator/indicator.controller.d.ts +35 -0
  14. package/lib/hot/components/indicator/indicator.controller.d.ts.map +1 -0
  15. package/lib/hot/components/indicator/indicator.controller.js +46 -0
  16. package/lib/hot/components/indicator/indicator.pulse.d.ts +8 -0
  17. package/lib/hot/components/indicator/indicator.pulse.d.ts.map +1 -0
  18. package/lib/hot/components/indicator/indicator.pulse.js +35 -0
  19. package/lib/hot/components/overlay/index.d.ts +4 -0
  20. package/lib/hot/components/overlay/index.d.ts.map +1 -0
  21. package/lib/hot/components/overlay/index.js +17 -0
  22. package/lib/hot/components/overlay/overlay.component.d.ts +18 -0
  23. package/lib/hot/components/overlay/overlay.component.d.ts.map +1 -0
  24. package/lib/hot/components/overlay/overlay.component.js +146 -0
  25. package/lib/hot/components/overlay/overlay.controller.d.ts +34 -0
  26. package/lib/hot/components/overlay/overlay.controller.d.ts.map +1 -0
  27. package/lib/hot/components/overlay/overlay.controller.js +60 -0
  28. package/lib/hot/events.d.ts +98 -0
  29. package/lib/hot/events.d.ts.map +1 -0
  30. package/lib/hot/events.js +87 -0
  31. package/lib/hot/index.cjs +5 -0
  32. package/lib/hot/index.d.cts +2 -0
  33. package/lib/hot/index.d.cts.map +1 -0
  34. package/lib/hot/index.d.mts +2 -0
  35. package/lib/hot/index.d.mts.map +1 -0
  36. package/lib/hot/index.mjs +17 -0
  37. package/lib/hot/log.d.ts +11 -0
  38. package/lib/hot/log.d.ts.map +1 -0
  39. package/lib/hot/log.js +37 -0
  40. package/lib/hot/options.d.ts +14 -0
  41. package/lib/hot/options.d.ts.map +1 -0
  42. package/lib/hot/options.js +30 -0
  43. package/lib/index.cjs +3 -0
  44. package/lib/index.d.cts +13 -0
  45. package/lib/index.d.cts.map +1 -0
  46. package/lib/index.d.mts +13 -0
  47. package/lib/index.d.mts.map +1 -0
  48. package/lib/index.mjs +3 -0
  49. package/lib/intercept/index.d.ts +3 -0
  50. package/lib/intercept/index.d.ts.map +1 -0
  51. package/lib/intercept/index.js +18 -0
  52. package/lib/intercept/proxy-click-interceptor.d.ts +2 -0
  53. package/lib/intercept/proxy-click-interceptor.d.ts.map +1 -0
  54. package/lib/intercept/proxy-click-interceptor.js +26 -0
  55. package/package.json +28 -19
  56. package/src/hot/client.ts +0 -8
  57. package/src/hot/components/indicator/indicator.component.ts +0 -15
  58. package/src/hot/components/indicator/indicator.controller.ts +0 -10
  59. package/src/hot/components/indicator/indicator.pulse.ts +0 -1
  60. package/src/hot/components/overlay/overlay.component.ts +0 -2
  61. package/src/hot/components/overlay/overlay.controller.ts +0 -12
  62. package/src/hot/events.ts +0 -2
  63. package/src/hot/options.ts +0 -3
@@ -0,0 +1,6 @@
1
+ /// <reference types="webpack-env" />
2
+ /**
3
+ * Initializes bud.js HMR handling
4
+ */
5
+ export declare const client: (queryString: string, webpackHot: __WebpackModuleApi.Hot) => Promise<boolean>;
6
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hot/client.ts"],"names":[],"mappings":";AASA;;GAEG;AACH,eAAO,MAAM,MAAM,gBACJ,MAAM,cACP,mBAAmB,GAAG,qBAqInC,CAAA"}
@@ -0,0 +1,135 @@
1
+ /* eslint-disable no-console */
2
+ /* global __resourceQuery */
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
+ import * as components from './components/index.js';
14
+ import { injectEvents } from './events.js';
15
+ import { makeLogger } from './log.js';
16
+ import * as clientOptions from './options.js';
17
+ /**
18
+ * Initializes bud.js HMR handling
19
+ */
20
+ export const client = (queryString, webpackHot) => __awaiter(void 0, void 0, void 0, function* () {
21
+ /* Guard: EventSource browser support */
22
+ if (typeof (window === null || window === void 0 ? void 0 : window.EventSource) === `undefined`) {
23
+ console.error(`[bud] hot module reload requires EventSource to work. https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools`);
24
+ return false;
25
+ }
26
+ /* Guard: webpackHot api availability */
27
+ if (!webpackHot) {
28
+ console.error(`[bud] hot module reload requires the webpack hot api to be available`);
29
+ return false;
30
+ }
31
+ /* Set client options from URL params */
32
+ const options = clientOptions.setFromParameters(queryString);
33
+ /* Setup logger */
34
+ const logger = makeLogger(options);
35
+ if (typeof window.bud === `undefined`) {
36
+ window.bud = {
37
+ current: {},
38
+ hmr: {},
39
+ controllers: [],
40
+ listeners: {},
41
+ };
42
+ }
43
+ if (!window.bud.current[options.name]) {
44
+ window.bud.current[options.name] = null;
45
+ }
46
+ const isStale = (hash) => {
47
+ if (hash)
48
+ window.bud.current[options.name] = hash;
49
+ return __webpack_hash__ === window.bud.current[options.name];
50
+ };
51
+ /**
52
+ * Webpack HMR check handler
53
+ */
54
+ const check = () => __awaiter(void 0, void 0, void 0, function* () {
55
+ if (webpackHot.status() === `idle`) {
56
+ yield webpackHot.check(false);
57
+ requestAnimationFrame(function whenReady() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ if (webpackHot.status() === `ready`) {
60
+ yield update();
61
+ }
62
+ else {
63
+ requestAnimationFrame(whenReady);
64
+ }
65
+ });
66
+ });
67
+ }
68
+ });
69
+ /**
70
+ * Webpack HMR unaccepted module handler
71
+ */
72
+ const onUnacceptedOrDeclined = (info) => {
73
+ console.warn(`[${options.name}] ${info.type}`, info);
74
+ options.reload && window.location.reload();
75
+ };
76
+ /**
77
+ * Webpack HMR error handler
78
+ */
79
+ const onErrored = (error) => {
80
+ window.bud.controllers.map(controller => controller === null || controller === void 0 ? void 0 : controller.update({
81
+ errors: [error],
82
+ }));
83
+ };
84
+ /**
85
+ * Webpack HMR update handler
86
+ */
87
+ const update = () => __awaiter(void 0, void 0, void 0, function* () {
88
+ try {
89
+ yield webpackHot.apply({
90
+ ignoreUnaccepted: true,
91
+ ignoreDeclined: true,
92
+ ignoreErrored: true,
93
+ onErrored,
94
+ onUnaccepted: onUnacceptedOrDeclined,
95
+ onDeclined: onUnacceptedOrDeclined,
96
+ });
97
+ if (!isStale())
98
+ yield check();
99
+ }
100
+ catch (error) {
101
+ logger.error(error);
102
+ }
103
+ });
104
+ /* Instantiate indicator, overlay */
105
+ yield components.make(options);
106
+ /* Instantiate eventSource */
107
+ const events = injectEvents(EventSource).make(options);
108
+ if (!window.bud.listeners[options.name]) {
109
+ window.bud.listeners[options.name] = (payload) => __awaiter(void 0, void 0, void 0, function* () {
110
+ var _a;
111
+ if (!payload)
112
+ return;
113
+ if (options.reload && payload.action === `reload`)
114
+ return window.location.reload();
115
+ if (payload.name !== options.name)
116
+ return;
117
+ window.bud.controllers.map(controller => controller === null || controller === void 0 ? void 0 : controller.update(payload));
118
+ if (((_a = payload.errors) === null || _a === void 0 ? void 0 : _a.length) > 0)
119
+ return;
120
+ if (payload.action === `built` || payload.action === `sync`) {
121
+ if (isStale(payload.hash))
122
+ return;
123
+ if (payload.action === `built`) {
124
+ logger.log(`built in ${payload.time}ms`);
125
+ }
126
+ yield check();
127
+ }
128
+ });
129
+ /*
130
+ * Instantiate HMR event source
131
+ * and register client listeners
132
+ */
133
+ events.addListener(window.bud.listeners[options.name]);
134
+ }
135
+ });
@@ -0,0 +1,2 @@
1
+ export declare const make: (options: Options) => Promise<Array<Controller>>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hot/components/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,EAAE,CACjB,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAc7B,CAAA"}
@@ -0,0 +1,32 @@
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
+ export const make = (options) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (options.indicator && !customElements.get(`bud-activity-indicator`)) {
12
+ yield import(`./indicator/index.js`)
13
+ .then(makeController)
14
+ .then(maybePushController);
15
+ }
16
+ if (options.overlay && !customElements.get(`bud-error`)) {
17
+ yield import(`./overlay/index.js`)
18
+ .then(makeController)
19
+ .then(maybePushController);
20
+ }
21
+ return window.bud.controllers;
22
+ });
23
+ const makeController = (module) => __awaiter(void 0, void 0, void 0, function* () {
24
+ if (!module)
25
+ return;
26
+ return yield module.make();
27
+ });
28
+ const maybePushController = (controller) => {
29
+ if (!controller)
30
+ return;
31
+ window.bud.controllers.push(controller);
32
+ };
@@ -0,0 +1,4 @@
1
+ export declare const make: () => Promise<{
2
+ update: (data: Payload) => void;
3
+ }>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hot/components/indicator/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;mBACA,OAAO,KAAK,IAAI;EAMhC,CAAA"}
@@ -0,0 +1,17 @@
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
+ import { Component } from './indicator.component.js';
11
+ import { Controller } from './indicator.controller.js';
12
+ export const make = () => __awaiter(void 0, void 0, void 0, function* () {
13
+ if (customElements.get(`bud-activity-indicator`))
14
+ return;
15
+ customElements.define(`bud-activity-indicator`, Component);
16
+ return new Controller();
17
+ });
@@ -0,0 +1,69 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Indicator web component
4
+ */
5
+ export declare class Component extends HTMLElement {
6
+ /**
7
+ * Has component rendered
8
+ */
9
+ rendered: boolean;
10
+ /**
11
+ * Component name
12
+ */
13
+ name: string;
14
+ /**
15
+ * Root div querySelector selector
16
+ */
17
+ get selector(): string;
18
+ /**
19
+ * Timer
20
+ */
21
+ hideTimeout: NodeJS.Timer;
22
+ /**
23
+ * Get accessor: has errors
24
+ */
25
+ get hasErrors(): boolean;
26
+ /**
27
+ * Get accessor: has warnings
28
+ */
29
+ get hasWarnings(): boolean;
30
+ /**
31
+ * Status indicator colors
32
+ */
33
+ colors: Record<string, [number, number, number, number]>;
34
+ /**
35
+ * Class constructor
36
+ */
37
+ constructor();
38
+ /**
39
+ * Render status indicator
40
+ */
41
+ renderShadow(): void;
42
+ /**
43
+ * Show status indicator
44
+ */
45
+ show(): void;
46
+ /**
47
+ * Hide status indicator
48
+ */
49
+ hide(): void;
50
+ /**
51
+ * Status is pending
52
+ */
53
+ onPending(): void;
54
+ /**
55
+ * Status is success
56
+ */
57
+ onSuccess(): void;
58
+ /**
59
+ * Status is error
60
+ */
61
+ onError(): void;
62
+ /**
63
+ * Status is warning
64
+ */
65
+ onWarning(): void;
66
+ static get observedAttributes(): string[];
67
+ attributeChangedCallback(): void;
68
+ }
69
+ //# sourceMappingURL=indicator.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indicator.component.d.ts","sourceRoot":"","sources":["../../../../src/hot/components/indicator/indicator.component.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC;;OAEG;IACI,QAAQ,EAAE,OAAO,CAAA;IAExB;;OAEG;IACI,IAAI,EAAE,MAAM,CAA2B;IAE9C;;OAEG;IACH,IAAW,QAAQ,WAElB;IAED;;OAEG;IACI,WAAW,EAAE,MAAM,CAAC,KAAK,CAAA;IAEhC;;OAEG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED;;OAEG;IACI,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAK9D;IAED;;OAEG;;IAMH;;OAEG;IACI,YAAY;IA4CnB;;OAEG;IACI,IAAI;IAKX;;OAEG;IACI,IAAI;IAMX;;OAEG;IACI,SAAS;IAYhB;;OAEG;IACI,SAAS;IAYhB;;OAEG;IACI,OAAO;IASd;;OAEG;IACI,SAAS;IAUhB,WAAkB,kBAAkB,aAEnC;IAEM,wBAAwB;CAiBhC"}
@@ -0,0 +1,162 @@
1
+ import { pulse } from './indicator.pulse.js';
2
+ /**
3
+ * Indicator web component
4
+ */
5
+ export class Component extends HTMLElement {
6
+ /**
7
+ * Root div querySelector selector
8
+ */
9
+ get selector() {
10
+ return `.${this.name}`;
11
+ }
12
+ /**
13
+ * Get accessor: has errors
14
+ */
15
+ get hasErrors() {
16
+ return this.getAttribute(`has-errors`) == `true`;
17
+ }
18
+ /**
19
+ * Get accessor: has warnings
20
+ */
21
+ get hasWarnings() {
22
+ return this.getAttribute(`has-warnings`) == `true`;
23
+ }
24
+ /**
25
+ * Class constructor
26
+ */
27
+ constructor() {
28
+ super();
29
+ /**
30
+ * Component name
31
+ */
32
+ this.name = `bud-activity-indicator`;
33
+ /**
34
+ * Status indicator colors
35
+ */
36
+ this.colors = {
37
+ success: [4, 120, 87, 1],
38
+ error: [220, 38, 38, 1],
39
+ warn: [252, 211, 77, 1],
40
+ pending: [59, 130, 246, 1],
41
+ };
42
+ this.renderShadow();
43
+ }
44
+ /**
45
+ * Render status indicator
46
+ */
47
+ renderShadow() {
48
+ const container = document.createElement(`div`);
49
+ container.classList.add(this.name);
50
+ container.innerHTML = `
51
+ <style>
52
+ .bud-activity-indicator {
53
+ position: fixed;
54
+ width: 10px;
55
+ height: 10px;
56
+ left: 10px;
57
+ bottom: 10px;
58
+ z-index: 9999;
59
+ margin: 5px;
60
+ padding: 5px;
61
+ -webkit-transition:
62
+ all .6s ease-in-out,
63
+ transition:
64
+ all .6s ease-in-out;
65
+ animation-fill-mode: forwards;
66
+ pointer-events: none;
67
+ border-radius: 50%;
68
+ transform: scale(0);
69
+ opacity: 0;
70
+ }
71
+
72
+ .show {
73
+ opacity: 1;
74
+ background-color: rgba(255, 255, 255, 1);
75
+ transform: scale(1);
76
+ transition:
77
+ all .6s ease-in-out;
78
+ }
79
+
80
+ ${pulse(`success`, this.colors.success)}
81
+ ${pulse(`error`, this.colors.error)}
82
+ ${pulse(`warning`, this.colors.warn)}
83
+ ${pulse(`pending`, this.colors.pending)}
84
+
85
+ </style>
86
+ `;
87
+ this.attachShadow({ mode: `open` }).appendChild(container);
88
+ }
89
+ /**
90
+ * Show status indicator
91
+ */
92
+ show() {
93
+ this.hideTimeout && clearTimeout(this.hideTimeout);
94
+ this.shadowRoot.querySelector(this.selector).classList.add(`show`);
95
+ }
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
+ }
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Activity indicator controller
4
+ */
5
+ export declare class Controller {
6
+ /**
7
+ * DOM node
8
+ */
9
+ node: HTMLElement;
10
+ /**
11
+ * Active WHM payload
12
+ */
13
+ payload: any;
14
+ /**
15
+ * Timer handler
16
+ */
17
+ timer: NodeJS.Timeout;
18
+ /**
19
+ * Initialization
20
+ */
21
+ constructor();
22
+ /**
23
+ * Append `bud-error` element to the DOM
24
+ */
25
+ addNode(): void;
26
+ /**
27
+ * Remove `bud-error` element from the DOM (if present)
28
+ */
29
+ removeNode(): void;
30
+ /**
31
+ * Update activity indicator
32
+ */
33
+ update(payload: Payload): void;
34
+ }
35
+ //# sourceMappingURL=indicator.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indicator.controller.d.ts","sourceRoot":"","sources":["../../../../src/hot/components/indicator/indicator.controller.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,qBAAa,UAAU;IACrB;;OAEG;IACI,IAAI,EAAE,WAAW,CAAA;IAExB;;OAEG;IACI,OAAO,MAAO;IAErB;;OAEG;IACI,KAAK,EAAE,MAAM,CAAC,OAAO,CAAA;IAE5B;;OAEG;;IAMH;;OAEG;IACI,OAAO;IAUd;;OAEG;IACI,UAAU;IAIjB;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,OAAO;CAe/B"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Activity indicator controller
3
+ */
4
+ export class Controller {
5
+ /**
6
+ * Initialization
7
+ */
8
+ constructor() {
9
+ /**
10
+ * Active WHM payload
11
+ */
12
+ this.payload = null;
13
+ this.node = document.createElement(`bud-activity-indicator`);
14
+ this.update = this.update.bind(this);
15
+ }
16
+ /**
17
+ * Append `bud-error` element to the DOM
18
+ */
19
+ addNode() {
20
+ var _a;
21
+ if (document.body.querySelector(`bud-activity-indicator`)) {
22
+ if (typeof this.timer.unref === `function`)
23
+ this.timer.unref();
24
+ this.removeNode();
25
+ }
26
+ (_a = document.body) === null || _a === void 0 ? void 0 : _a.appendChild(this.node);
27
+ this.timer = setTimeout(this.removeNode, 3000);
28
+ }
29
+ /**
30
+ * Remove `bud-error` element from the DOM (if present)
31
+ */
32
+ removeNode() {
33
+ var _a;
34
+ (_a = document.body.querySelector(`bud-activity-indicator`)) === null || _a === void 0 ? void 0 : _a.remove();
35
+ }
36
+ /**
37
+ * Update activity indicator
38
+ */
39
+ update(payload) {
40
+ var _a, _b;
41
+ this.node.toggleAttribute(`has-errors`, ((_a = payload.errors) === null || _a === void 0 ? void 0 : _a.length) ? true : false);
42
+ this.node.toggleAttribute(`has-warnings`, ((_b = payload.warnings) === null || _b === void 0 ? void 0 : _b.length) ? true : false);
43
+ this.node.setAttribute(`action`, payload.action);
44
+ this.addNode();
45
+ }
46
+ }
@@ -0,0 +1,8 @@
1
+ export interface pulse {
2
+ (name: string, color: [number, number, number]): string;
3
+ }
4
+ /**
5
+ * CSS animation for reload indicator
6
+ */
7
+ export declare const pulse: (name: string, color: [number, number, number, number]) => string;
8
+ //# sourceMappingURL=indicator.pulse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indicator.pulse.d.ts","sourceRoot":"","sources":["../../../../src/hot/components/indicator/indicator.pulse.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;CACxD;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,SACV,MAAM,SACL,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,KACtC,MA+BF,CAAA"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * CSS animation for reload indicator
3
+ */
4
+ export const pulse = (name, color) => `
5
+ .${name} {
6
+ box-shadow: 0 0 0 0 rgba(${color[0]}, ${color[1]}, ${color[2]}, ${color[3]});
7
+ animation: ${name}__pulse 2s infinite;
8
+ transition: all 0.4s ease-in-out;
9
+ }
10
+
11
+ .${name}:not(.show) {
12
+ background-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0);
13
+ }
14
+
15
+ .${name}.show {
16
+ background-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, ${color[3]});
17
+ }
18
+
19
+ @keyframes ${name}__pulse {
20
+ 0% {
21
+ transform: scale(0.95);
22
+ box-shadow: 0 0 0 0 rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.7);
23
+ }
24
+
25
+ 70% {
26
+ transform: scale(1);
27
+ box-shadow: 0 0 0 10px rgba(${color[0]}, ${color[1]}, ${color[2]}, 0);
28
+ }
29
+
30
+ 100% {
31
+ transform: scale(0.95);
32
+ box-shadow: 0 0 0 0 rgba(${color[0]}, ${color[1]}, ${color[2]}, 0);
33
+ }
34
+ }
35
+ `;
@@ -0,0 +1,4 @@
1
+ export declare const make: () => Promise<{
2
+ update: (data: Payload) => void;
3
+ }>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hot/components/overlay/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;mBACA,OAAO,KAAK,IAAI;EAOhC,CAAA"}
@@ -0,0 +1,17 @@
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
+ import { Component } from './overlay.component.js';
11
+ import { Controller } from './overlay.controller.js';
12
+ export const make = () => __awaiter(void 0, void 0, void 0, function* () {
13
+ if (customElements.get(`bud-error`))
14
+ return;
15
+ customElements.define(`bud-error`, Component);
16
+ return new Controller();
17
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Component container
3
+ */
4
+ export declare class Component extends HTMLElement {
5
+ name: string;
6
+ /**
7
+ * WHM payload
8
+ */
9
+ payload: any;
10
+ documentBodyStyle: any;
11
+ get message(): string;
12
+ constructor();
13
+ renderShadow(): void;
14
+ static get observedAttributes(): string[];
15
+ attributeChangedCallback(): void;
16
+ connectedCallback(): void;
17
+ }
18
+ //# sourceMappingURL=overlay.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.component.d.ts","sourceRoot":"","sources":["../../../../src/hot/components/overlay/overlay.component.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACjC,IAAI,EAAE,MAAM,CAAgB;IAEnC;;OAEG;IACI,OAAO,EAAE,GAAG,CAAA;IAEZ,iBAAiB,EAAE,GAAG,CAAA;IAE7B,IAAW,OAAO,WAEjB;;IAOM,YAAY,IAAI,IAAI;IA+G3B,WAAkB,kBAAkB,aAEnC;IAEM,wBAAwB;IAsBxB,iBAAiB;CAGzB"}