@roots/bud-client 6.3.5 → 6.4.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.
Files changed (87) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +0 -3
  3. package/lib/components/index.d.ts +4 -0
  4. package/lib/components/index.d.ts.map +1 -0
  5. package/lib/components/index.js +49 -0
  6. package/lib/components/{overlay/index.d.cts → indicator/index.d.ts} +1 -1
  7. package/lib/components/indicator/index.d.ts.map +1 -0
  8. package/lib/components/indicator/index.js +21 -0
  9. package/lib/components/indicator/{indicator.component.d.cts → indicator.component.d.ts} +6 -7
  10. package/lib/components/indicator/indicator.component.d.ts.map +1 -0
  11. package/lib/components/indicator/{indicator.component.cjs → indicator.component.js} +26 -29
  12. package/lib/components/indicator/indicator.controller.d.ts +45 -0
  13. package/lib/components/indicator/indicator.controller.d.ts.map +1 -0
  14. package/lib/components/indicator/indicator.controller.js +58 -0
  15. package/lib/components/indicator/{indicator.pulse.d.cts → indicator.pulse.d.ts} +1 -1
  16. package/lib/components/indicator/indicator.pulse.d.ts.map +1 -0
  17. package/lib/components/indicator/{indicator.pulse.cjs → indicator.pulse.js} +0 -1
  18. package/lib/components/{indicator/index.d.cts → overlay/index.d.ts} +1 -1
  19. package/lib/components/overlay/index.d.ts.map +1 -0
  20. package/lib/components/overlay/index.js +21 -0
  21. package/lib/components/overlay/{overlay.component.d.cts → overlay.component.d.ts} +1 -1
  22. package/lib/components/overlay/overlay.component.d.ts.map +1 -0
  23. package/lib/components/overlay/{overlay.component.cjs → overlay.component.js} +16 -21
  24. package/lib/components/overlay/{overlay.controller.d.cts → overlay.controller.d.ts} +1 -7
  25. package/lib/components/overlay/overlay.controller.d.ts.map +1 -0
  26. package/lib/components/overlay/{overlay.controller.cjs → overlay.controller.js} +11 -10
  27. package/lib/hmr/events.d.ts +52 -0
  28. package/lib/hmr/events.d.ts.map +1 -0
  29. package/lib/hmr/events.js +100 -0
  30. package/lib/index.d.mts +1 -5
  31. package/lib/index.d.mts.map +1 -1
  32. package/lib/index.d.ts +2 -0
  33. package/lib/index.d.ts.map +1 -0
  34. package/lib/index.js +117 -0
  35. package/lib/index.mjs +1 -5
  36. package/lib/intercept.d.ts +3 -0
  37. package/lib/intercept.d.ts.map +1 -0
  38. package/lib/intercept.js +20 -0
  39. package/lib/interface.d.ts +53 -0
  40. package/lib/interface.d.ts.map +1 -0
  41. package/lib/interface.js +4 -0
  42. package/lib/options.d.ts +16 -0
  43. package/lib/options.d.ts.map +1 -0
  44. package/lib/options.js +39 -0
  45. package/lib/proxy-click-interceptor.d.ts +2 -0
  46. package/lib/proxy-click-interceptor.d.ts.map +1 -0
  47. package/lib/proxy-click-interceptor.js +31 -0
  48. package/package.json +10 -14
  49. package/lib/components/indicator/index.cjs +0 -14
  50. package/lib/components/indicator/index.cjs.map +0 -1
  51. package/lib/components/indicator/index.d.cts.map +0 -1
  52. package/lib/components/indicator/indicator.component.cjs.map +0 -1
  53. package/lib/components/indicator/indicator.component.d.cts.map +0 -1
  54. package/lib/components/indicator/indicator.controller.cjs +0 -40
  55. package/lib/components/indicator/indicator.controller.cjs.map +0 -1
  56. package/lib/components/indicator/indicator.controller.d.cts +0 -27
  57. package/lib/components/indicator/indicator.controller.d.cts.map +0 -1
  58. package/lib/components/indicator/indicator.pulse.cjs.map +0 -1
  59. package/lib/components/indicator/indicator.pulse.d.cts.map +0 -1
  60. package/lib/components/overlay/index.cjs +0 -14
  61. package/lib/components/overlay/index.cjs.map +0 -1
  62. package/lib/components/overlay/index.d.cts.map +0 -1
  63. package/lib/components/overlay/overlay.component.cjs.map +0 -1
  64. package/lib/components/overlay/overlay.component.d.cts.map +0 -1
  65. package/lib/components/overlay/overlay.controller.cjs.map +0 -1
  66. package/lib/components/overlay/overlay.controller.d.cts.map +0 -1
  67. package/lib/hmr/bridge.cjs +0 -290
  68. package/lib/hmr/bridge.cjs.map +0 -1
  69. package/lib/hmr/bridge.d.cts +0 -5
  70. package/lib/hmr/bridge.d.cts.map +0 -1
  71. package/lib/hmr/index.cjs +0 -81
  72. package/lib/hmr/index.cjs.map +0 -1
  73. package/lib/hmr/index.d.cts +0 -19
  74. package/lib/hmr/index.d.cts.map +0 -1
  75. package/lib/hmr/update.cjs +0 -154
  76. package/lib/hmr/update.cjs.map +0 -1
  77. package/lib/hmr/update.d.cts +0 -8
  78. package/lib/hmr/update.d.cts.map +0 -1
  79. package/lib/index.cjs +0 -5
  80. package/lib/index.cjs.map +0 -1
  81. package/lib/index.d.cts +0 -4
  82. package/lib/index.d.cts.map +0 -1
  83. package/lib/index.mjs.map +0 -1
  84. package/lib/proxy-click-interceptor.cjs +0 -49
  85. package/lib/proxy-click-interceptor.cjs.map +0 -1
  86. package/lib/proxy-click-interceptor.d.cts +0 -4
  87. package/lib/proxy-click-interceptor.d.cts.map +0 -1
@@ -0,0 +1,52 @@
1
+ declare type Listener = ((ev: MessageEvent) => any) | null;
2
+ /**
3
+ * HMR EventSource
4
+ *
5
+ * @public
6
+ */
7
+ export declare class Events extends EventSource {
8
+ options: Options;
9
+ /**
10
+ * Current hash
11
+ * @public
12
+ */
13
+ currentHash: string;
14
+ /**
15
+ * Messages
16
+ */
17
+ messages: Set<string>;
18
+ /**
19
+ * Registered listeners
20
+ * @public
21
+ */
22
+ listeners: Set<Listener>;
23
+ /**
24
+ * Class constructor
25
+ *
26
+ * @remarks
27
+ * Singleton interface, so this is private.
28
+ */
29
+ private constructor();
30
+ /**
31
+ * Singleton constructor
32
+ * @public
33
+ */
34
+ static make(options: Options): Events;
35
+ /**
36
+ * EventSource `onopen` handler
37
+ * @public
38
+ */
39
+ onopen: (ev?: Event) => Promise<void>;
40
+ /**
41
+ * EventSource `onmessage` handler
42
+ * @public
43
+ */
44
+ onmessage: (payload: MessageEvent) => Promise<void>;
45
+ /**
46
+ * EventSource `addMessageListener` handler
47
+ * @public
48
+ */
49
+ addMessageListener(callback: (ev: MessageEvent) => unknown): this;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/hmr/events.ts"],"names":[],"mappings":"AAEA,aAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAE,YAAY,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;AAElD;;;;GAIG;AACH,qBAAa,MAAO,SAAQ,WAAW;IAwBV,OAAO,EAAE,OAAO;IAvB3C;;;OAGG;IACI,WAAW,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACI,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAY;IAExC;;;OAGG;IACI,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAsB;IAErD;;;;;OAKG;IACH,OAAO;IAQP;;;OAGG;WACW,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAU5C;;;OAGG;IACI,MAAM,QAAwB,KAAK,mBAEzC;IAED;;;OAGG;IACI,SAAS,YAA4B,YAAY,mBAuBvD;IAED;;;OAGG;IACI,kBAAkB,CACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,GACtC,IAAI;CAIR"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /* eslint-disable no-console */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Events = void 0;
14
+ /**
15
+ * HMR EventSource
16
+ *
17
+ * @public
18
+ */
19
+ class Events extends EventSource {
20
+ /**
21
+ * Class constructor
22
+ *
23
+ * @remarks
24
+ * Singleton interface, so this is private.
25
+ */
26
+ constructor(options) {
27
+ super(options.path);
28
+ this.options = options;
29
+ /**
30
+ * Messages
31
+ */
32
+ this.messages = new Set();
33
+ /**
34
+ * Registered listeners
35
+ * @public
36
+ */
37
+ this.listeners = new Set();
38
+ /**
39
+ * EventSource `onopen` handler
40
+ * @public
41
+ */
42
+ this.onopen = function (ev) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ console.log(`[bud] connected`);
45
+ });
46
+ };
47
+ /**
48
+ * EventSource `onmessage` handler
49
+ * @public
50
+ */
51
+ this.onmessage = function (payload) {
52
+ var _a, _b, _c, _d;
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ // @ts-ignore
55
+ if (!payload)
56
+ return;
57
+ try {
58
+ this.payload = JSON.parse(payload.data);
59
+ ((_a = this.payload) === null || _a === void 0 ? void 0 : _a.action) === `reload` &&
60
+ this.options.reload &&
61
+ window.location.reload();
62
+ if ((_b = this.payload) === null || _b === void 0 ? void 0 : _b.hash) {
63
+ if (this.messages.has((_c = this.payload) === null || _c === void 0 ? void 0 : _c.hash))
64
+ return;
65
+ this.currentHash = (_d = this.payload) === null || _d === void 0 ? void 0 : _d.hash;
66
+ this.messages.add(this.currentHash);
67
+ }
68
+ if (this.messages.size <= 1)
69
+ return;
70
+ yield Promise.all([...this.listeners].map((listener) => __awaiter(this, void 0, void 0, function* () { return yield listener(payload); })));
71
+ }
72
+ catch (error) { }
73
+ });
74
+ };
75
+ this.onopen = this.onopen.bind(this);
76
+ this.onmessage = this.onmessage.bind(this);
77
+ this.addMessageListener = this.addMessageListener.bind(this);
78
+ }
79
+ /**
80
+ * Singleton constructor
81
+ * @public
82
+ */
83
+ static make(options) {
84
+ if (!window.bud)
85
+ window.bud = { hmr: {} };
86
+ if (!window.bud.hmr[options.path]) {
87
+ window.bud.hmr[options.path] = new Events(options);
88
+ }
89
+ return window.bud.hmr[options.path];
90
+ }
91
+ /**
92
+ * EventSource `addMessageListener` handler
93
+ * @public
94
+ */
95
+ addMessageListener(callback) {
96
+ this.listeners.add(callback);
97
+ return this;
98
+ }
99
+ }
100
+ exports.Events = Events;
package/lib/index.d.mts CHANGED
@@ -1,6 +1,2 @@
1
- /**
2
- * Default export
3
- */
4
- declare const _default: {};
5
- export default _default;
1
+ import './index.js';
6
2
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,wBAAiB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import './interface';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,aAAa,CAAA"}
package/lib/index.js ADDED
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ /* eslint-disable no-console */
3
+ /* global __resourceQuery */
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ require("./interface");
38
+ const components = __importStar(require("./components/index.js"));
39
+ const events_js_1 = require("./hmr/events.js");
40
+ const clientOptions = __importStar(require("./options"));
41
+ ((queryString) => __awaiter(void 0, void 0, void 0, function* () {
42
+ /**
43
+ * Webpack hot interface
44
+ */
45
+ const webpackHot = module.hot;
46
+ /* Set client options from URL params */
47
+ const options = clientOptions.setFromParameters(queryString);
48
+ /**
49
+ * Returns true if environment supports HMR
50
+ */
51
+ if (typeof (window === null || window === void 0 ? void 0 : window.EventSource) === `undefined`) {
52
+ console.error(`[bud] hot module reload requires EventSource to work. https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools`);
53
+ return false;
54
+ }
55
+ /**
56
+ * Webpack HMR check handler
57
+ */
58
+ const check = () => __awaiter(void 0, void 0, void 0, function* () {
59
+ return webpackHot.status() === `idle` &&
60
+ (yield webpackHot.check(false).then((modules) => __awaiter(void 0, void 0, void 0, function* () {
61
+ modules && (yield update());
62
+ })));
63
+ });
64
+ /**
65
+ * Webpack HMR unaccepted module handler
66
+ */
67
+ const onUnacceptedOrDeclined = (info) => {
68
+ console.warn(`[${options.name}] ${info.type}`, info);
69
+ options.reload && window.location.reload();
70
+ };
71
+ /**
72
+ * Webpack HMR error handler
73
+ */
74
+ const onErrored = error => {
75
+ var _a, _b;
76
+ const message = `[${(_a = error === null || error === void 0 ? void 0 : error.moduleId) !== null && _a !== void 0 ? _a : options.name}] ${(_b = error === null || error === void 0 ? void 0 : error.error) !== null && _b !== void 0 ? _b : `error`}`;
77
+ console.error(message);
78
+ components.controllers.map(controller => controller.update({
79
+ type: `accept-errored`,
80
+ action: `built`,
81
+ errors: [{ message }],
82
+ }));
83
+ };
84
+ /**
85
+ * Webpack HMR update handler
86
+ */
87
+ const update = () => __awaiter(void 0, void 0, void 0, function* () {
88
+ webpackHot.status() === `ready` &&
89
+ (yield webpackHot.apply({
90
+ autoApply: false,
91
+ ignoreUnaccepted: true,
92
+ ignoreDeclined: true,
93
+ ignoreErrored: true,
94
+ onErrored,
95
+ onUnaccepted: onUnacceptedOrDeclined,
96
+ onDeclined: onUnacceptedOrDeclined,
97
+ }));
98
+ });
99
+ /* Instantiate eventSource */
100
+ const eventSource = events_js_1.Events.make(options);
101
+ /* Instantiate indicator, overlay */
102
+ yield components.make(options);
103
+ /* Instantiate HMR event source and register client listeners */
104
+ eventSource.addMessageListener((event) => __awaiter(void 0, void 0, void 0, function* () {
105
+ try {
106
+ const data = JSON.parse(event.data);
107
+ if (!data)
108
+ return;
109
+ if (data.action === `reload`)
110
+ window.location.reload();
111
+ components.controllers.map(controller => controller.update(data));
112
+ if (__webpack_hash__ !== eventSource.currentHash)
113
+ yield check();
114
+ }
115
+ catch (error) { }
116
+ }));
117
+ }))(__resourceQuery);
package/lib/index.mjs CHANGED
@@ -1,7 +1,3 @@
1
1
  "use strict";
2
- /**
3
- * Default export
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = {};
7
- //# sourceMappingURL=index.mjs.map
3
+ require("./index.js");
@@ -0,0 +1,3 @@
1
+ declare const intercept: (args_0: string, args_1: string) => void;
2
+ export default intercept;
3
+ //# sourceMappingURL=intercept.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intercept.d.ts","sourceRoot":"","sources":["../src/intercept.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,0CA2Bd,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const intercept = (...args) => {
4
+ args.every(arg => typeof arg === `string`) &&
5
+ setInterval(() => [
6
+ [document.getElementsByTagName(`a`), `href`],
7
+ [document.getElementsByTagName(`link`), `href`],
8
+ ]
9
+ .map(([elements, attribute]) => [Array.from(elements), attribute])
10
+ .forEach(([elements, attribute]) => elements
11
+ .filter(el => el.hasAttribute(attribute))
12
+ .filter(el => !el.hasAttribute(`__bud_processed`))
13
+ .filter(el => el.getAttribute(attribute).startsWith(args[0]))
14
+ .map(el => {
15
+ const value = el.getAttribute(attribute).replace(...args);
16
+ el.setAttribute(attribute, value);
17
+ el.toggleAttribute(`__bud_processed`);
18
+ })), 1000);
19
+ };
20
+ exports.default = intercept;
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="webpack-env" />
3
+ declare var __resourceQuery: string;
4
+ declare var __webpack_hash__: string;
5
+ declare var bud: {
6
+ hmr?: Record<string, Events>;
7
+ };
8
+ declare var module: NodeJS.Module & {
9
+ hot?: {
10
+ check?: CallableFunction;
11
+ accept?: CallableFunction;
12
+ apply?: CallableFunction;
13
+ status?: CallableFunction;
14
+ };
15
+ };
16
+ declare module global {
17
+ interface Window {
18
+ bud: typeof bud;
19
+ }
20
+ }
21
+ declare interface Events extends EventSource {
22
+ messages: Set<string>;
23
+ options: Options;
24
+ currentHash: string;
25
+ listeners: Set<((ev: MessageEvent) => any) | null>;
26
+ addMessageListener(fn: (ev: MessageEvent) => unknown): this;
27
+ }
28
+ declare interface Payload {
29
+ type: `middleware` | __WebpackModuleApi.HotNotifierInfo[`type`];
30
+ action: 'reload' | 'sync' | 'building' | 'built';
31
+ hash?: string;
32
+ time?: number;
33
+ errors?: Array<{
34
+ title?: string;
35
+ message: string;
36
+ }>;
37
+ warnings?: Array<string>;
38
+ message?: string;
39
+ }
40
+ declare interface Controller {
41
+ update: (payload: Payload) => void;
42
+ }
43
+ declare interface Options {
44
+ timeout: number;
45
+ reload: boolean;
46
+ debug: boolean;
47
+ log: boolean;
48
+ name: string;
49
+ path: string;
50
+ indicator: boolean;
51
+ overlay: boolean;
52
+ }
53
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;AAAA,QAAA,IAAI,eAAe,EAAE,MAAM,CAAA;AAE3B,QAAA,IAAI,gBAAgB,EAAE,MAAM,CAAA;AAE5B,QAAA,IAAI,GAAG,EAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC7B,CAAA;AAED,QAAA,IAAI,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG;IAC1B,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,gBAAgB,CAAA;QACxB,MAAM,CAAC,EAAE,gBAAgB,CAAA;QACzB,KAAK,CAAC,EAAE,gBAAgB,CAAA;QACxB,MAAM,CAAC,EAAE,gBAAgB,CAAA;KAC1B,CAAA;CACF,CAAA;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,MAAM;QACd,GAAG,EAAE,OAAO,GAAG,CAAA;KAChB;CACF;AAED,OAAO,WAAW,MAAO,SAAQ,WAAW;IAC1C,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,YAAY,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAClD,kBAAkB,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,GAAG,IAAI,CAAA;CAC5D;AAED,OAAO,WAAW,OAAO;IACvB,IAAI,EAAE,YAAY,GAAG,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;IAC/D,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAA;IAChD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,KAAK,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,OAAO,WAAW,UAAU;IAC1B,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CACnC;AAED,OAAO,WAAW,OAAO;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,OAAO,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB"}
@@ -0,0 +1,4 @@
1
+ var __resourceQuery;
2
+ var __webpack_hash__;
3
+ var bud;
4
+ var module;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Client options
3
+ * @public
4
+ */
5
+ declare let data: Record<string, Options>;
6
+ /**
7
+ * Get client option
8
+ * @public
9
+ */
10
+ declare const get: (name?: string, key?: string) => any;
11
+ /**
12
+ * Set client data based on URL parameters
13
+ */
14
+ declare const setFromParameters: (query: string) => Options;
15
+ export { data, get, setFromParameters };
16
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,QAAA,IAAI,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAW/B,CAAA;AAED;;;GAGG;AACH,QAAA,MAAM,GAAG,UAAW,MAAM,QAAQ,MAAM,QACJ,CAAA;AAEpC;;GAEG;AACH,QAAA,MAAM,iBAAiB,UAAW,MAAM,KAAG,OAW1C,CAAA;AAED,OAAO,EAAC,IAAI,EAAE,GAAG,EAAE,iBAAiB,EAAC,CAAA"}
package/lib/options.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setFromParameters = exports.get = exports.data = void 0;
4
+ /**
5
+ * Client options
6
+ * @public
7
+ */
8
+ let data = {
9
+ [`default`]: {
10
+ timeout: 20 * 1000,
11
+ reload: true,
12
+ name: `default`,
13
+ debug: true,
14
+ log: true,
15
+ path: `/__bud/hmr`,
16
+ indicator: true,
17
+ overlay: true,
18
+ },
19
+ };
20
+ exports.data = data;
21
+ /**
22
+ * Get client option
23
+ * @public
24
+ */
25
+ const get = (name, key) => key ? data[name][key] : data[name];
26
+ exports.get = get;
27
+ /**
28
+ * Set client data based on URL parameters
29
+ */
30
+ const setFromParameters = (query) => {
31
+ let parsedParams = {};
32
+ new window.URLSearchParams(query).forEach((value, key) => {
33
+ parsedParams[key] =
34
+ value === `true` ? true : value === `false` ? false : value;
35
+ });
36
+ data[parsedParams.name] = Object.assign(Object.assign({}, data.default), parsedParams);
37
+ return data[parsedParams.name];
38
+ };
39
+ exports.setFromParameters = setFromParameters;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=proxy-click-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-click-interceptor.d.ts","sourceRoot":"","sources":["../src/proxy-click-interceptor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /* eslint-disable no-console */
3
+ /* global __resourceQuery */
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const intercept_1 = __importDefault(require("./intercept"));
18
+ window.requestAnimationFrame(function ready() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ if (!__resourceQuery)
21
+ return;
22
+ const params = new URLSearchParams(__resourceQuery);
23
+ if (!params || !params.has(`search`) || !params.has(`replace`))
24
+ return;
25
+ const search = decodeURI(params.get(`search`));
26
+ const replace = decodeURI(params.get(`replace`));
27
+ return document.body
28
+ ? (0, intercept_1.default)(search, replace)
29
+ : window.requestAnimationFrame(ready);
30
+ });
31
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@roots/bud-client",
3
3
  "description": "Client scripts for @roots/bud",
4
- "version": "6.3.5",
4
+ "version": "6.4.1",
5
5
  "homepage": "https://roots.io/bud",
6
6
  "repository": {
7
7
  "type": "git",
@@ -36,37 +36,33 @@
36
36
  "files": [
37
37
  "lib/"
38
38
  ],
39
- "type": "commonjs",
40
- "main": "./lib/index.cjs",
41
- "module": "./lib/index.mjs",
42
- "types": "./lib/hmr.d.cts",
39
+ "main": "./lib/index.js",
40
+ "types": "./lib/index.d.ts",
43
41
  "exports": {
44
42
  ".": {
45
43
  "import": "./lib/index.mjs",
46
- "require": "./lib/index.cjs"
44
+ "require": "./lib/index.js"
47
45
  },
48
46
  "./lib/*": "./lib/*"
49
47
  },
50
48
  "typesVersions": {
51
49
  "*": {
52
50
  ".": [
53
- "./lib/index.d.cts"
51
+ "./lib/index.d.ts"
54
52
  ],
55
- "hmr": [
56
- "./lib/hmr/index.d.cts"
57
- ],
58
- "proxy-click-interceptor": [
59
- "./lib/proxy-click-interceptor.d.cts"
53
+ "./lib/*": [
54
+ "./lib/*.d.ts"
60
55
  ]
61
56
  }
62
57
  },
63
58
  "devDependencies": {
59
+ "@jest/globals": "29.0.1",
64
60
  "@skypack/package-check": "0.2.2",
65
- "@types/node": "16.11.45",
61
+ "@types/node": "16.11.48",
62
+ "@types/webpack-env": "1.18.0",
66
63
  "webpack": "5.73.0"
67
64
  },
68
65
  "dependencies": {
69
- "querystring": "^0.2.1",
70
66
  "strip-ansi": "7.0.1",
71
67
  "tslib": "2.4.0"
72
68
  },
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.make = void 0;
4
- const tslib_1 = require("tslib");
5
- const indicator_component_cjs_1 = require("./indicator.component.cjs");
6
- const indicator_controller_cjs_1 = require("./indicator.controller.cjs");
7
- const make = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
8
- if (customElements.get('bud-activity-indicator'))
9
- return;
10
- customElements.define('bud-activity-indicator', indicator_component_cjs_1.Component);
11
- return new indicator_controller_cjs_1.Controller();
12
- });
13
- exports.make = make;
14
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/indicator/index.cts"],"names":[],"mappings":";;;;AAAA,uEAAmD;AACnD,yEAAqD;AAE9C,MAAM,IAAI,GAAG,GAA4C,EAAE;IAChE,IAAI,cAAc,CAAC,GAAG,CAAC,wBAAwB,CAAC;QAAE,OAAM;IAExD,cAAc,CAAC,MAAM,CAAC,wBAAwB,EAAE,mCAAS,CAAC,CAAA;IAE1D,OAAO,IAAI,qCAAU,EAAE,CAAA;AACzB,CAAC,CAAA,CAAA;AANY,QAAA,IAAI,QAMhB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/indicator/index.cts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;2BAAwC,IAAI;EAM5D,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"indicator.component.cjs","sourceRoot":"","sources":["../../../src/components/indicator/indicator.component.cts"],"names":[],"mappings":";;;AAAA,+DAA2C;AAE3C;;;GAGG;AACH,MAAa,SAAU,SAAQ,WAAW;IAA1C;;QAOE;;;WAGG;QACI,SAAI,GAAW,wBAAwB,CAAA;QAsC9C;;;WAGG;QACI,WAAM,GAAqD;YAChE,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;YACxB,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACvB,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;YACvB,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;SAC3B,CAAA;IAyJH,CAAC;IAtMC;;;OAGG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;IAcD;;;OAGG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,MAAM,CAAA;IAClD,CAAC;IAED;;;OAGG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,MAAM,CAAA;IACpD,CAAC;IAaD;;;OAGG;IACI,YAAY;QACjB,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA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AAc,EAAE,QAAQ,CAAC,CAAA;IACjD,CAAC;IAEM,wBAAwB;;QAC7B,IAAI,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,0CAAE,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAA;QACvD,IAAI,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,0CAAE,MAAM;YAAE,OAAO,IAAI,CAAC,SAAS,EAAE,CAAA;QAC3D,IACE,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,0CAAE,MAAM,CAAA;YAC7B,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,0CAAE,MAAM,CAAA;YAC/B,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO;YAE9B,OAAO,IAAI,CAAC,SAAS,EAAE,CAAA;QACzB,IACE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,KAAI,UAAU;YAClC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,KAAI,MAAM;YAE9B,OAAO,IAAI,CAAC,SAAS,EAAE,CAAA;IAC3B,CAAC;IAEM,iBAAiB;QACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,YAAY,EAAE,CAAA;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;SACrB;IACH,CAAC;CACF;AAnND,8BAmNC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"indicator.component.d.cts","sourceRoot":"","sources":["../../../src/components/indicator/indicator.component.cts"],"names":[],"mappings":";AAEA;;;GAGG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC;;;OAGG;IACI,QAAQ,EAAE,OAAO,CAAA;IAExB;;;OAGG;IACI,IAAI,EAAE,MAAM,CAA2B;IAE9C;;;OAGG;IACH,IAAW,QAAQ,WAElB;IAED;;;OAGG;IACI,WAAW,EAAE,MAAM,CAAC,KAAK,CAAA;IAEhC;;;OAGG;IACI,OAAO,EAAE,GAAG,CAAA;IAEnB;;;OAGG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;OAGG;IACH,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED;;;OAGG;IACI,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAK9D;IAED;;;OAGG;IACI,YAAY;IA4CnB;;;OAGG;IACI,IAAI;IAKX;;OAEG;IACI,IAAI;IAMX;;;OAGG;IACI,SAAS;IAYhB;;;OAGG;IACI,SAAS;IAYhB;;;OAGG;IACI,OAAO;IASd;;;OAGG;IACI,SAAS;IAUhB,WAAkB,kBAAkB,aAEnC;IAEM,wBAAwB;IAgBxB,iBAAiB;CAMzB"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Controller = void 0;
4
- /**
5
- * Activity indicator controller
6
- * @public
7
- */
8
- class Controller {
9
- /**
10
- * Initialization
11
- * @public
12
- */
13
- constructor() {
14
- /**
15
- * DOM node
16
- * @public
17
- */
18
- this.node = null;
19
- /**
20
- * Active WHM payload
21
- * @public
22
- */
23
- this.payload = null;
24
- this.node = document.createElement('bud-activity-indicator');
25
- document.body && document.body.appendChild(this.node);
26
- this.update = this.update.bind(this);
27
- }
28
- /**
29
- * Update activity indicator
30
- * @public
31
- */
32
- update(payload) {
33
- var _a, _b;
34
- this.node.payload = payload;
35
- this.node.setAttribute('has-warnings', (_a = payload.errors) === null || _a === void 0 ? void 0 : _a.length);
36
- this.node.setAttribute('has-errors', (_b = payload.warnings) === null || _b === void 0 ? void 0 : _b.length);
37
- }
38
- }
39
- exports.Controller = Controller;
40
- //# sourceMappingURL=indicator.controller.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"indicator.controller.cjs","sourceRoot":"","sources":["../../../src/components/indicator/indicator.controller.cts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,UAAU;IAarB;;;OAGG;IACH;QAhBA;;;WAGG;QACI,SAAI,GAAG,IAAI,CAAA;QAElB;;;WAGG;QACI,YAAO,GAAG,IAAI,CAAA;QAOnB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAA;QAC5D,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,OAAO;;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,MAAA,OAAO,CAAC,MAAM,0CAAE,MAAM,CAAC,CAAA;QAC9D,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,MAAA,OAAO,CAAC,QAAQ,0CAAE,MAAM,CAAC,CAAA;IAChE,CAAC;CACF;AAhCD,gCAgCC"}