@roots/bud-client 6.13.1 → 6.14.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.
@@ -1,21 +1,14 @@
1
+ import * as Indicator from './indicator/index.js';
2
+ import * as Overlay from './overlay/index.js';
1
3
  export const make = async (options) => {
2
4
  if (options.indicator && !customElements.get(`bud-activity-indicator`)) {
3
- await import(`./indicator/index.js`)
4
- .then(makeController)
5
- .then(maybePushController);
5
+ maybePushController(Indicator.make());
6
6
  }
7
7
  if (options.overlay && !customElements.get(`bud-error`)) {
8
- await import(`./overlay/index.js`)
9
- .then(makeController)
10
- .then(maybePushController);
8
+ maybePushController(Overlay.make());
11
9
  }
12
10
  return window.bud.controllers;
13
11
  };
14
- const makeController = async (module) => {
15
- if (!module)
16
- return;
17
- return await module.make();
18
- };
19
12
  const maybePushController = (controller) => {
20
13
  if (!controller)
21
14
  return;
@@ -1,3 +1,2 @@
1
- export declare const make: () => Promise<{
2
- update: (data: Payload) => void;
3
- }>;
1
+ import { Controller } from './indicator.controller.js';
2
+ export declare const make: () => Controller;
@@ -1,6 +1,6 @@
1
1
  import { Component } from './indicator.component.js';
2
2
  import { Controller } from './indicator.controller.js';
3
- export const make = async () => {
3
+ export const make = () => {
4
4
  if (customElements.get(`bud-activity-indicator`))
5
5
  return;
6
6
  customElements.define(`bud-activity-indicator`, Component);
@@ -1,3 +1,3 @@
1
- export declare const make: () => Promise<{
1
+ export declare const make: () => {
2
2
  update: (data: Payload) => void;
3
- }>;
3
+ };
@@ -1,6 +1,6 @@
1
1
  import { Component } from './overlay.component.js';
2
2
  import { Controller } from './overlay.controller.js';
3
- export const make = async () => {
3
+ export const make = () => {
4
4
  if (customElements.get(`bud-error`))
5
5
  return;
6
6
  customElements.define(`bud-error`, Component);
@@ -1,22 +1,21 @@
1
- export declare const injectEvents: (eventSource: new (path: string) => EventSource) => {
1
+ interface EventSourceFactory {
2
+ new (path: string): EventSource;
3
+ }
4
+ export declare const injectEvents: (eventSource: EventSourceFactory) => {
2
5
  new (options: Partial<Options> & {
3
6
  name: string;
4
7
  path: string;
5
8
  }): {
6
9
  /**
7
10
  * Registered listeners
8
- *
9
- * @public
10
11
  */
11
12
  listeners: Set<Listener>;
12
13
  /**
13
14
  * EventSource `onmessage` handler
14
- * @public
15
15
  */
16
16
  onmessage: (payload: MessageEvent) => Promise<void>;
17
17
  /**
18
18
  * EventSource `onopen` handler
19
- * @public
20
19
  */
21
20
  onopen: () => void;
22
21
  options: Partial<Options> & {
@@ -25,7 +24,6 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
25
24
  };
26
25
  /**
27
26
  * EventSource `addMessageListener` handler
28
- * @public
29
27
  */
30
28
  addListener(listener: Listener): this;
31
29
  onerror: (this: EventSource, ev: Event) => any;
@@ -47,7 +45,6 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
47
45
  /**
48
46
  * Singleton constructor
49
47
  *
50
- * @public
51
48
  */
52
49
  make(options: Partial<Options> & {
53
50
  name: string;
@@ -55,18 +52,14 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
55
52
  }): {
56
53
  /**
57
54
  * Registered listeners
58
- *
59
- * @public
60
55
  */
61
56
  listeners: Set<Listener>;
62
57
  /**
63
58
  * EventSource `onmessage` handler
64
- * @public
65
59
  */
66
60
  onmessage: (payload: MessageEvent) => Promise<void>;
67
61
  /**
68
62
  * EventSource `onopen` handler
69
- * @public
70
63
  */
71
64
  onopen: () => void;
72
65
  options: Partial<Options> & {
@@ -75,7 +68,6 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
75
68
  };
76
69
  /**
77
70
  * EventSource `addMessageListener` handler
78
- * @public
79
71
  */
80
72
  addListener(listener: Listener): this;
81
73
  onerror: (this: EventSource, ev: Event) => any;
@@ -95,3 +87,4 @@ export declare const injectEvents: (eventSource: new (path: string) => EventSour
95
87
  dispatchEvent(event: Event): boolean;
96
88
  };
97
89
  };
90
+ export {};
package/lib/hot/events.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-console */
2
1
  export const injectEvents = (eventSource) => {
3
2
  /**
4
3
  * EventSource wrapper
@@ -14,20 +13,16 @@ export const injectEvents = (eventSource) => {
14
13
  * @remarks
15
14
  * Singleton interface, so this is private.
16
15
  *
17
- * @public
18
16
  */
19
17
  constructor(options) {
20
18
  super(options.path);
21
19
  this.options = options;
22
20
  /**
23
21
  * Registered listeners
24
- *
25
- * @public
26
22
  */
27
23
  this.listeners = new Set();
28
24
  /**
29
25
  * EventSource `onmessage` handler
30
- * @public
31
26
  */
32
27
  this.onmessage = async function (payload) {
33
28
  if (!payload?.data || payload.data == `\uD83D\uDC93`) {
@@ -45,7 +40,6 @@ export const injectEvents = (eventSource) => {
45
40
  };
46
41
  /**
47
42
  * EventSource `onopen` handler
48
- * @public
49
43
  */
50
44
  this.onopen = function () { };
51
45
  this.onopen = this.onopen.bind(this);
@@ -55,7 +49,6 @@ export const injectEvents = (eventSource) => {
55
49
  /**
56
50
  * Singleton constructor
57
51
  *
58
- * @public
59
52
  */
60
53
  static make(options) {
61
54
  if (typeof window.bud.hmr[options.name] === `undefined`)
@@ -66,7 +59,6 @@ export const injectEvents = (eventSource) => {
66
59
  }
67
60
  /**
68
61
  * EventSource `addMessageListener` handler
69
- * @public
70
62
  */
71
63
  addListener(listener) {
72
64
  this.listeners.add(listener);
package/lib/hot/index.js CHANGED
@@ -2,15 +2,11 @@
2
2
  /* global __resourceQuery */
3
3
  /* global module */
4
4
  import { client } from './client.js';
5
- try {
6
- client(__resourceQuery, import.meta.webpackHot);
7
- }
8
- catch (err) {
9
- console.error(err);
5
+ (async function () {
10
6
  try {
11
- client(__resourceQuery, module.hot);
7
+ await client(__resourceQuery, import.meta.webpackHot);
12
8
  }
13
- catch (error) {
14
- console.error(error);
9
+ catch (err) {
10
+ console.error(err);
15
11
  }
16
- }
12
+ })();
package/lib/hot/log.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export declare const makeLogger: (options: Options) => {
2
- error: (...args: any[]) => void;
3
- info: (...args: any[]) => void;
4
- log: (...args: any[]) => void;
5
- warn: (...args: any[]) => void;
2
+ error: (...args: Array<unknown>) => void;
3
+ info: (...args: Array<unknown>) => void;
4
+ log: (...args: Array<unknown>) => void;
5
+ warn: (...args: Array<unknown>) => void;
6
6
  };
7
- export declare const makeLog: (options: any) => (...args: any[]) => void;
8
- export declare const makeInfo: (options: any) => (...args: any[]) => void;
9
- export declare const makeError: (options: any) => (...args: any[]) => void;
10
- export declare const makeWarn: (options: any) => (...args: any[]) => void;
7
+ export declare const makeLog: (options: Options) => (...args: Array<unknown>) => void;
8
+ export declare const makeInfo: (options: Options) => (...args: Array<unknown>) => void;
9
+ export declare const makeError: (options: Options) => (...args: Array<unknown>) => void;
10
+ export declare const makeWarn: (options: Options) => (...args: Array<unknown>) => void;
package/lib/hot/log.js CHANGED
@@ -7,30 +7,26 @@ export const makeLogger = (options) => {
7
7
  warn: makeWarn(options),
8
8
  };
9
9
  };
10
- let lastLog = null;
11
- export const makeLog = options => {
10
+ export const makeLog = (options) => {
12
11
  return (...args) => {
13
12
  if (options.log) {
14
- if (lastLog === args.join(``))
15
- return;
16
- lastLog = args.join(``);
17
13
  console.log(`[${options.name}]`, ...args);
18
14
  }
19
15
  };
20
16
  };
21
- export const makeInfo = options => {
17
+ export const makeInfo = (options) => {
22
18
  return (...args) => {
23
19
  if (options.log) {
24
20
  console.info(`[${options.name}]`, ...args);
25
21
  }
26
22
  };
27
23
  };
28
- export const makeError = options => {
24
+ export const makeError = (options) => {
29
25
  return (...args) => {
30
26
  console.error(`[${options.name}]`, ...args);
31
27
  };
32
28
  };
33
- export const makeWarn = options => {
29
+ export const makeWarn = (options) => {
34
30
  return (...args) => {
35
31
  console.warn(`[${options.name}]`, ...args);
36
32
  };
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@roots/bud-client",
3
- "version": "6.13.1",
3
+ "version": "6.14.1",
4
4
  "description": "Client scripts for @roots/bud",
5
5
  "engines": {
6
6
  "node": ">=16"
7
7
  },
8
8
  "contributors": [
9
9
  {
10
- "name": "Kelly Mears",
11
10
  "email": "developers@tinypixel.dev",
11
+ "name": "Kelly Mears",
12
12
  "url": "https://github.com/kellymears"
13
13
  },
14
14
  {
15
- "name": "Ben Word",
16
15
  "email": "ben@benword.com",
16
+ "name": "Ben Word",
17
17
  "url": "https://github.com/retlehs"
18
18
  },
19
19
  {
20
- "name": "Brandon",
21
20
  "email": "brandon@tendency.me",
21
+ "name": "Brandon",
22
22
  "url": "https://github.com/Log1x"
23
23
  }
24
24
  ],
@@ -45,14 +45,8 @@
45
45
  ],
46
46
  "type": "module",
47
47
  "exports": {
48
- ".": {
49
- "import": "./lib/index.js",
50
- "default": "./lib/index.js"
51
- },
52
- "./lib/*": {
53
- "import": "./lib/*",
54
- "default": "./lib/*"
55
- }
48
+ ".": "./lib/index.js",
49
+ "./lib/*": "./lib/*"
56
50
  },
57
51
  "typesVersions": {
58
52
  "*": {
@@ -67,13 +61,13 @@
67
61
  "types": "./lib/index.d.ts",
68
62
  "module": "./lib/index.mjs",
69
63
  "devDependencies": {
70
- "@roots/bud": "6.13.1",
64
+ "@roots/bud": "6.14.1",
71
65
  "@skypack/package-check": "0.2.2",
72
- "@types/node": "18.16.16",
66
+ "@types/node": "18.16.18",
73
67
  "@types/webpack-env": "1.18.1"
74
68
  },
75
69
  "dependencies": {
76
- "tslib": "2.5.3"
70
+ "tslib": "2.6.0"
77
71
  },
78
72
  "volta": {
79
73
  "extends": "../../../package.json"
@@ -1,32 +1,20 @@
1
- interface ControllerModule {
2
- make: () => Promise<Controller>
3
- }
1
+ import * as Indicator from './indicator/index.js'
2
+ import * as Overlay from './overlay/index.js'
4
3
 
5
4
  export const make: (
6
5
  options: Options,
7
6
  ) => Promise<Array<Controller>> = async options => {
8
7
  if (options.indicator && !customElements.get(`bud-activity-indicator`)) {
9
- await import(`./indicator/index.js`)
10
- .then(makeController)
11
- .then(maybePushController)
8
+ maybePushController(Indicator.make())
12
9
  }
13
10
 
14
11
  if (options.overlay && !customElements.get(`bud-error`)) {
15
- await import(`./overlay/index.js`)
16
- .then(makeController)
17
- .then(maybePushController)
12
+ maybePushController(Overlay.make())
18
13
  }
19
14
 
20
15
  return window.bud.controllers
21
16
  }
22
17
 
23
- const makeController = async (
24
- module: ControllerModule,
25
- ): Promise<Controller | undefined> => {
26
- if (!module) return
27
- return await module.make()
28
- }
29
-
30
18
  const maybePushController = (controller: Controller | undefined) => {
31
19
  if (!controller) return
32
20
  window.bud.controllers.push(controller)
@@ -1,9 +1,7 @@
1
1
  import {Component} from './indicator.component.js'
2
2
  import {Controller} from './indicator.controller.js'
3
3
 
4
- export const make = async (): Promise<{
5
- update: (data: Payload) => void
6
- }> => {
4
+ export const make = () => {
7
5
  if (customElements.get(`bud-activity-indicator`)) return
8
6
  customElements.define(`bud-activity-indicator`, Component)
9
7
 
@@ -1,9 +1,9 @@
1
1
  import {Component} from './overlay.component.js'
2
2
  import {Controller} from './overlay.controller.js'
3
3
 
4
- export const make = async (): Promise<{
4
+ export const make = (): {
5
5
  update: (data: Payload) => void
6
- }> => {
6
+ } => {
7
7
  if (customElements.get(`bud-error`)) return
8
8
 
9
9
  customElements.define(`bud-error`, Component)
package/src/hot/events.ts CHANGED
@@ -1,8 +1,8 @@
1
- /* eslint-disable no-console */
1
+ interface EventSourceFactory {
2
+ new (path: string): EventSource
3
+ }
2
4
 
3
- export const injectEvents = (
4
- eventSource: new (path: string) => EventSource,
5
- ) => {
5
+ export const injectEvents = (eventSource: EventSourceFactory) => {
6
6
  /**
7
7
  * EventSource wrapper
8
8
  *
@@ -13,14 +13,11 @@ export const injectEvents = (
13
13
  return class Events extends eventSource {
14
14
  /**
15
15
  * Registered listeners
16
- *
17
- * @public
18
16
  */
19
17
  public listeners: Set<Listener> = new Set<Listener>()
20
18
 
21
19
  /**
22
20
  * EventSource `onmessage` handler
23
- * @public
24
21
  */
25
22
  public override onmessage = async function (payload: MessageEvent) {
26
23
  if (!payload?.data || payload.data == `\uD83D\uDC93`) {
@@ -41,7 +38,6 @@ export const injectEvents = (
41
38
 
42
39
  /**
43
40
  * EventSource `onopen` handler
44
- * @public
45
41
  */
46
42
  public override onopen = function () {}
47
43
 
@@ -51,7 +47,6 @@ export const injectEvents = (
51
47
  * @remarks
52
48
  * Singleton interface, so this is private.
53
49
  *
54
- * @public
55
50
  */
56
51
  private constructor(
57
52
  public options: Partial<Options> & {name: string; path: string},
@@ -66,7 +61,6 @@ export const injectEvents = (
66
61
  /**
67
62
  * Singleton constructor
68
63
  *
69
- * @public
70
64
  */
71
65
  public static make(
72
66
  options: Partial<Options> & {name: string; path: string},
@@ -81,7 +75,6 @@ export const injectEvents = (
81
75
 
82
76
  /**
83
77
  * EventSource `addMessageListener` handler
84
- * @public
85
78
  */
86
79
  public addListener(listener: Listener): this {
87
80
  this.listeners.add(listener)
package/src/hot/index.ts CHANGED
@@ -4,14 +4,13 @@
4
4
 
5
5
  import {client} from './client.js'
6
6
 
7
- try {
8
- client(__resourceQuery, import.meta.webpackHot)
9
- } catch (err) {
10
- console.error(err)
11
-
7
+ /**
8
+ * Client entrypoint
9
+ */
10
+ ;(async function () {
12
11
  try {
13
- client(__resourceQuery, module.hot)
14
- } catch (error) {
15
- console.error(error)
12
+ await client(__resourceQuery, import.meta.webpackHot)
13
+ } catch (err) {
14
+ console.error(err)
16
15
  }
17
- }
16
+ })()
package/src/hot/log.ts CHANGED
@@ -9,34 +9,30 @@ export const makeLogger = (options: Options) => {
9
9
  }
10
10
  }
11
11
 
12
- let lastLog: string = null
13
- export const makeLog = options => {
14
- return (...args) => {
12
+ export const makeLog = (options: Options) => {
13
+ return (...args: Array<unknown>) => {
15
14
  if (options.log) {
16
- if (lastLog === args.join(``)) return
17
- lastLog = args.join(``)
18
-
19
15
  console.log(`[${options.name}]`, ...args)
20
16
  }
21
17
  }
22
18
  }
23
19
 
24
- export const makeInfo = options => {
25
- return (...args) => {
20
+ export const makeInfo = (options: Options) => {
21
+ return (...args: Array<unknown>) => {
26
22
  if (options.log) {
27
23
  console.info(`[${options.name}]`, ...args)
28
24
  }
29
25
  }
30
26
  }
31
27
 
32
- export const makeError = options => {
33
- return (...args) => {
28
+ export const makeError = (options: Options) => {
29
+ return (...args: Array<unknown>) => {
34
30
  console.error(`[${options.name}]`, ...args)
35
31
  }
36
32
  }
37
33
 
38
- export const makeWarn = options => {
39
- return (...args) => {
34
+ export const makeWarn = (options: Options) => {
35
+ return (...args: Array<unknown>) => {
40
36
  console.warn(`[${options.name}]`, ...args)
41
37
  }
42
38
  }