@vaadin/common-frontend 0.0.18 → 0.0.20

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,4 +1,4 @@
1
- import { LitElement } from 'lit';
1
+ import { LitElement, type PropertyValues } from 'lit';
2
2
  /**
3
3
  * The loading indicator states
4
4
  */
@@ -8,11 +8,18 @@ export declare const enum LoadingBarState {
8
8
  SECOND = "second",
9
9
  THIRD = "third"
10
10
  }
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ 'vaadin-connection-indicator': ConnectionIndicator;
14
+ }
15
+ }
11
16
  /**
12
17
  * Component showing loading and connection indicator. When added to DOM,
13
18
  * listens for changes on `window.Vaadin.connectionState` ConnectionStateStore.
14
19
  */
15
20
  export declare class ConnectionIndicator extends LitElement {
21
+ #private;
22
+ static get instance(): ConnectionIndicator;
16
23
  /**
17
24
  * Initialize global connection indicator instance at
18
25
  * window.Vaadin.connectionIndicator and add instance to the document body.
@@ -21,66 +28,45 @@ export declare class ConnectionIndicator extends LitElement {
21
28
  /**
22
29
  * The delay before showing the loading indicator, in ms.
23
30
  */
24
- firstDelay: number;
31
+ accessor firstDelay: number;
25
32
  /**
26
33
  * The delay before the loading indicator goes into "second" state, in ms.
27
34
  */
28
- secondDelay: number;
35
+ accessor secondDelay: number;
29
36
  /**
30
37
  * The delay before the loading indicator goes into "third" state, in ms.
31
38
  */
32
- thirdDelay: number;
39
+ accessor thirdDelay: number;
33
40
  /**
34
41
  * The duration for which the connection state change message is visible,
35
42
  * in ms.
36
43
  */
37
- expandedDuration: number;
44
+ accessor expandedDuration: number;
38
45
  /**
39
46
  * The message shown when the connection goes to connected state.
40
47
  */
41
- onlineText: string;
48
+ accessor onlineText: string;
42
49
  /**
43
50
  * The message shown when the connection goes to lost state.
44
51
  */
45
- offlineText: string;
52
+ accessor offlineText: string;
46
53
  /**
47
54
  * The message shown when the connection goes to reconnecting state.
48
55
  */
49
- reconnectingText: string;
50
- private offline;
51
- private reconnecting;
52
- private expanded;
53
- private loading;
54
- private loadingBarState;
55
- private applyDefaultThemeState;
56
- private firstTimeout;
57
- private secondTimeout;
58
- private thirdTimeout;
59
- private expandedTimeout;
60
- private connectionStateStore?;
61
- private readonly connectionStateListener;
62
- private lastMessageState;
56
+ accessor reconnectingText: string;
57
+ accessor offline: boolean;
58
+ accessor reconnecting: boolean;
59
+ accessor expanded: boolean;
60
+ accessor loading: boolean;
61
+ readonly connectionStateListener: () => void;
63
62
  constructor();
64
- render(): import("lit").TemplateResult<1>;
63
+ protected render(): import("lit-html").TemplateResult<1>;
65
64
  connectedCallback(): void;
66
65
  disconnectedCallback(): void;
66
+ protected updated(props: PropertyValues): void;
67
67
  get applyDefaultTheme(): boolean;
68
68
  set applyDefaultTheme(applyDefaultTheme: boolean);
69
69
  protected createRenderRoot(): this;
70
- /**
71
- * Update state flags.
72
- *
73
- * @return true if the connection message changes, and therefore a new
74
- * message should be shown
75
- */
76
- private updateConnectionState;
77
- private updateLoading;
78
- private renderMessage;
79
- private updateTheme;
80
- private getDefaultStyle;
81
- private getLoadingBarStyle;
82
- private timeoutFor;
83
- static get instance(): ConnectionIndicator;
84
70
  }
85
71
  /**
86
72
  * The global connection indicator object. Its appearance and behavior can be
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionIndicator.d.ts","sourceRoot":"","sources":["src/ConnectionIndicator.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAOvC;;GAEG;AACH,0BAAkB,eAAe;IAC/B,IAAI,KAAK;IACT,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;IACjD;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,mBAAmB;IAUpC;;OAEG;IAEH,UAAU,SAAO;IAEjB;;OAEG;IAEH,WAAW,SAAQ;IAEnB;;OAEG;IAEH,UAAU,SAAQ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file except in compliance with the License. You may obtain a copy of
6
- * the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- * License for the specific language governing permissions and limitations under
14
- * the License.
15
- */
16
- import { __decorate } from "tslib";
17
- import { html, LitElement } from 'lit';
18
- import { property } from 'lit/decorators.js';
19
- import { classMap } from 'lit/directives/class-map.js';
20
- import { ConnectionState } from './ConnectionState.js';
21
- const DEFAULT_STYLE_ID = 'css-loading-indicator';
22
- /**
23
- * The loading indicator states
24
- */
25
- export var LoadingBarState;
26
- (function (LoadingBarState) {
27
- LoadingBarState["IDLE"] = "";
28
- LoadingBarState["FIRST"] = "first";
29
- LoadingBarState["SECOND"] = "second";
30
- LoadingBarState["THIRD"] = "third";
31
- })(LoadingBarState || (LoadingBarState = {}));
32
- /**
33
- * Component showing loading and connection indicator. When added to DOM,
34
- * listens for changes on `window.Vaadin.connectionState` ConnectionStateStore.
35
- */
36
- export class ConnectionIndicator extends LitElement {
37
- constructor() {
38
- super();
39
- /**
40
- * The delay before showing the loading indicator, in ms.
41
- */
42
- this.firstDelay = 450;
43
- /**
44
- * The delay before the loading indicator goes into "second" state, in ms.
45
- */
46
- this.secondDelay = 1500;
47
- /**
48
- * The delay before the loading indicator goes into "third" state, in ms.
49
- */
50
- this.thirdDelay = 5000;
51
- /**
52
- * The duration for which the connection state change message is visible,
53
- * in ms.
54
- */
55
- this.expandedDuration = 2000;
56
- /**
57
- * The message shown when the connection goes to connected state.
58
- */
59
- this.onlineText = 'Online';
60
- /**
61
- * The message shown when the connection goes to lost state.
62
- */
63
- this.offlineText = 'Connection lost';
64
- /**
65
- * The message shown when the connection goes to reconnecting state.
66
- */
67
- this.reconnectingText = 'Connection lost, trying to reconnect...';
68
- this.offline = false;
69
- this.reconnecting = false;
70
- this.expanded = false;
71
- this.loading = false;
72
- this.loadingBarState = LoadingBarState.IDLE;
73
- this.applyDefaultThemeState = true;
74
- this.firstTimeout = 0;
75
- this.secondTimeout = 0;
76
- this.thirdTimeout = 0;
77
- this.expandedTimeout = 0;
78
- this.lastMessageState = ConnectionState.CONNECTED;
79
- this.connectionStateListener = () => {
80
- this.expanded = this.updateConnectionState();
81
- this.expandedTimeout = this.timeoutFor(this.expandedTimeout, this.expanded, () => {
82
- this.expanded = false;
83
- }, this.expandedDuration);
84
- };
1
+ import { html, LitElement } from "lit";
2
+ import { property, state } from "lit/decorators.js";
3
+ import { classMap } from "lit/directives/class-map.js";
4
+ import { ConnectionState } from "./ConnectionState.js";
5
+ const DEFAULT_STYLE_ID = "css-loading-indicator";
6
+ var LoadingBarState = /* @__PURE__ */ ((LoadingBarState2) => {
7
+ LoadingBarState2["IDLE"] = "";
8
+ LoadingBarState2["FIRST"] = "first";
9
+ LoadingBarState2["SECOND"] = "second";
10
+ LoadingBarState2["THIRD"] = "third";
11
+ return LoadingBarState2;
12
+ })(LoadingBarState || {});
13
+ class ConnectionIndicator extends LitElement {
14
+ static get instance() {
15
+ return ConnectionIndicator.create();
16
+ }
17
+ /**
18
+ * Initialize global connection indicator instance at
19
+ * window.Vaadin.connectionIndicator and add instance to the document body.
20
+ */
21
+ static create() {
22
+ const $wnd = window;
23
+ if (!$wnd.Vaadin?.connectionIndicator) {
24
+ $wnd.Vaadin ??= {};
25
+ $wnd.Vaadin.connectionIndicator = document.createElement("vaadin-connection-indicator");
26
+ document.body.appendChild($wnd.Vaadin.connectionIndicator);
85
27
  }
86
- /**
87
- * Initialize global connection indicator instance at
88
- * window.Vaadin.connectionIndicator and add instance to the document body.
89
- */
90
- static create() {
91
- var _a, _b;
92
- const $wnd = window;
93
- if (!((_a = $wnd.Vaadin) === null || _a === void 0 ? void 0 : _a.connectionIndicator)) {
94
- $wnd.Vaadin = $wnd.Vaadin || {};
95
- $wnd.Vaadin.connectionIndicator = document.createElement('vaadin-connection-indicator');
96
- document.body.appendChild($wnd.Vaadin.connectionIndicator);
97
- }
98
- return (_b = $wnd.Vaadin) === null || _b === void 0 ? void 0 : _b.connectionIndicator;
99
- }
100
- render() {
101
- return html `
102
- <div class="v-loading-indicator ${this.loadingBarState}" style=${this.getLoadingBarStyle()}></div>
28
+ return $wnd.Vaadin?.connectionIndicator;
29
+ }
30
+ @property({ type: Number })
31
+ accessor firstDelay = 450;
32
+ @property({ type: Number })
33
+ accessor secondDelay = 1500;
34
+ @property({ type: Number })
35
+ accessor thirdDelay = 5e3;
36
+ @property({ type: Number })
37
+ accessor expandedDuration = 2e3;
38
+ @property({ type: String })
39
+ accessor onlineText = "Online";
40
+ @property({ type: String })
41
+ accessor offlineText = "Connection lost";
42
+ @property({ type: String })
43
+ accessor reconnectingText = "Connection lost, trying to reconnect...";
44
+ @property({ type: Boolean, reflect: true })
45
+ accessor offline = false;
46
+ @property({ type: Boolean, reflect: true })
47
+ accessor reconnecting = false;
48
+ @property({ type: Boolean, reflect: true })
49
+ accessor expanded = false;
50
+ @property({ type: Boolean, reflect: true })
51
+ accessor loading = false;
52
+ @state()
53
+ accessor #loadingBarState = "" /* IDLE */;
54
+ accessor #isPopover = false;
55
+ #applyDefaultThemeState = true;
56
+ #firstTimeout = 0;
57
+ #secondTimeout = 0;
58
+ #thirdTimeout = 0;
59
+ #expandedTimeout = 0;
60
+ #connectionStateStore;
61
+ connectionStateListener;
62
+ #lastMessageState = ConnectionState.CONNECTED;
63
+ constructor() {
64
+ super();
65
+ this.connectionStateListener = () => {
66
+ this.expanded = this.#updateConnectionState();
67
+ this.#expandedTimeout = this.#timeoutFor(
68
+ this.#expandedTimeout,
69
+ this.expanded,
70
+ () => {
71
+ this.expanded = false;
72
+ },
73
+ this.expandedDuration
74
+ );
75
+ };
76
+ }
77
+ render() {
78
+ return html`
79
+ <div class="v-loading-indicator ${this.#loadingBarState}" style=${this.#getLoadingBarStyle()}></div>
103
80
 
104
81
  <div
105
82
  class="v-status-message ${classMap({
106
- active: this.reconnecting,
107
- })}"
83
+ active: this.reconnecting
84
+ })}"
108
85
  >
109
- <span class="text"> ${this.renderMessage()} </span>
86
+ <span class="text"> ${this.#renderMessage()} </span>
110
87
  </div>
111
88
  `;
89
+ }
90
+ connectedCallback() {
91
+ super.connectedCallback();
92
+ this.#initPopover();
93
+ const $wnd = window;
94
+ if ($wnd.Vaadin?.connectionState) {
95
+ this.#connectionStateStore = $wnd.Vaadin.connectionState;
96
+ this.#connectionStateStore.addStateChangeListener(this.connectionStateListener);
97
+ this.#updateConnectionState();
112
98
  }
113
- connectedCallback() {
114
- var _a;
115
- super.connectedCallback();
116
- const $wnd = window;
117
- if ((_a = $wnd.Vaadin) === null || _a === void 0 ? void 0 : _a.connectionState) {
118
- this.connectionStateStore = $wnd.Vaadin.connectionState;
119
- this.connectionStateStore.addStateChangeListener(this.connectionStateListener);
120
- this.updateConnectionState();
121
- }
122
- this.updateTheme();
99
+ this.#updateTheme();
100
+ }
101
+ disconnectedCallback() {
102
+ super.disconnectedCallback();
103
+ if (this.#connectionStateStore) {
104
+ this.#connectionStateStore.removeStateChangeListener(this.connectionStateListener);
123
105
  }
124
- disconnectedCallback() {
125
- super.disconnectedCallback();
126
- if (this.connectionStateStore) {
127
- this.connectionStateStore.removeStateChangeListener(this.connectionStateListener);
128
- }
129
- this.updateTheme();
106
+ this.#updateTheme();
107
+ this.#isPopover = false;
108
+ }
109
+ updated(props) {
110
+ if (["loading", "offline", "reconnecting", "expanded"].some((p) => props.has(p))) {
111
+ this.#updatePopoverState();
130
112
  }
131
- get applyDefaultTheme() {
132
- return this.applyDefaultThemeState;
113
+ }
114
+ get applyDefaultTheme() {
115
+ return this.#applyDefaultThemeState;
116
+ }
117
+ @property({ type: Boolean, reflect: true })
118
+ set applyDefaultTheme(applyDefaultTheme) {
119
+ if (applyDefaultTheme !== this.#applyDefaultThemeState) {
120
+ this.#applyDefaultThemeState = applyDefaultTheme;
121
+ this.#updateTheme();
133
122
  }
134
- set applyDefaultTheme(applyDefaultTheme) {
135
- if (applyDefaultTheme !== this.applyDefaultThemeState) {
136
- this.applyDefaultThemeState = applyDefaultTheme;
137
- this.updateTheme();
138
- }
123
+ }
124
+ createRenderRoot() {
125
+ return this;
126
+ }
127
+ #initPopover() {
128
+ this.setAttribute("popover", "manual");
129
+ this.style.display = "contents";
130
+ }
131
+ /**
132
+ * Update state flags.
133
+ *
134
+ * @returns true if the connection message changes, and therefore a new
135
+ * message should be shown
136
+ */
137
+ #updateConnectionState() {
138
+ const connectionState = this.#connectionStateStore?.state;
139
+ this.offline = connectionState === ConnectionState.CONNECTION_LOST;
140
+ this.reconnecting = connectionState === ConnectionState.RECONNECTING;
141
+ this.#updateLoading(connectionState === ConnectionState.LOADING);
142
+ if (this.loading) {
143
+ return false;
139
144
  }
140
- createRenderRoot() {
141
- return this;
145
+ if (connectionState !== this.#lastMessageState) {
146
+ this.#lastMessageState = connectionState;
147
+ return true;
142
148
  }
143
- /**
144
- * Update state flags.
145
- *
146
- * @return true if the connection message changes, and therefore a new
147
- * message should be shown
148
- */
149
- updateConnectionState() {
150
- var _a;
151
- const state = (_a = this.connectionStateStore) === null || _a === void 0 ? void 0 : _a.state;
152
- this.offline = state === ConnectionState.CONNECTION_LOST;
153
- this.reconnecting = state === ConnectionState.RECONNECTING;
154
- this.updateLoading(state === ConnectionState.LOADING);
155
- if (this.loading) {
156
- // Entering loading state, do not show message
157
- return false;
158
- }
159
- if (state !== this.lastMessageState) {
160
- this.lastMessageState = state;
161
- // Message changes, show new message
162
- return true;
163
- }
164
- // Message did not change
165
- return false;
149
+ return false;
150
+ }
151
+ #updateLoading(loading) {
152
+ this.loading = loading;
153
+ this.#loadingBarState = "" /* IDLE */;
154
+ this.#firstTimeout = this.#timeoutFor(
155
+ this.#firstTimeout,
156
+ loading,
157
+ () => {
158
+ this.#loadingBarState = "first" /* FIRST */;
159
+ },
160
+ this.firstDelay
161
+ );
162
+ this.#secondTimeout = this.#timeoutFor(
163
+ this.#secondTimeout,
164
+ loading,
165
+ () => {
166
+ this.#loadingBarState = "second" /* SECOND */;
167
+ },
168
+ this.secondDelay
169
+ );
170
+ this.#thirdTimeout = this.#timeoutFor(
171
+ this.#thirdTimeout,
172
+ loading,
173
+ () => {
174
+ this.#loadingBarState = "third" /* THIRD */;
175
+ },
176
+ this.thirdDelay
177
+ );
178
+ }
179
+ #updatePopoverState() {
180
+ const showPopover = this.loading || this.offline || this.reconnecting || this.expanded;
181
+ if (this.#isPopover) {
182
+ this.hidePopover();
166
183
  }
167
- updateLoading(loading) {
168
- this.loading = loading;
169
- this.loadingBarState = LoadingBarState.IDLE;
170
- this.firstTimeout = this.timeoutFor(this.firstTimeout, loading, () => {
171
- this.loadingBarState = LoadingBarState.FIRST;
172
- }, this.firstDelay);
173
- this.secondTimeout = this.timeoutFor(this.secondTimeout, loading, () => {
174
- this.loadingBarState = LoadingBarState.SECOND;
175
- }, this.secondDelay);
176
- this.thirdTimeout = this.timeoutFor(this.thirdTimeout, loading, () => {
177
- this.loadingBarState = LoadingBarState.THIRD;
178
- }, this.thirdDelay);
184
+ if (showPopover) {
185
+ this.showPopover();
179
186
  }
180
- renderMessage() {
181
- if (this.reconnecting) {
182
- return this.reconnectingText;
183
- }
184
- if (this.offline) {
185
- return this.offlineText;
186
- }
187
- return this.onlineText;
187
+ this.#isPopover = showPopover;
188
+ }
189
+ #renderMessage() {
190
+ if (this.reconnecting) {
191
+ return this.reconnectingText;
188
192
  }
189
- updateTheme() {
190
- if (this.applyDefaultThemeState && this.isConnected) {
191
- if (!document.getElementById(DEFAULT_STYLE_ID)) {
192
- const style = document.createElement('style');
193
- style.id = DEFAULT_STYLE_ID;
194
- style.textContent = this.getDefaultStyle();
195
- document.head.appendChild(style);
196
- }
197
- }
198
- else {
199
- const style = document.getElementById(DEFAULT_STYLE_ID);
200
- if (style) {
201
- document.head.removeChild(style);
202
- }
203
- }
193
+ if (this.offline) {
194
+ return this.offlineText;
195
+ }
196
+ return this.onlineText;
197
+ }
198
+ #updateTheme() {
199
+ if (this.#applyDefaultThemeState && this.isConnected) {
200
+ if (!document.getElementById(DEFAULT_STYLE_ID)) {
201
+ const style = document.createElement("style");
202
+ style.id = DEFAULT_STYLE_ID;
203
+ style.textContent = this.#getDefaultStyle();
204
+ document.head.appendChild(style);
205
+ }
206
+ } else {
207
+ const style = document.getElementById(DEFAULT_STYLE_ID);
208
+ if (style) {
209
+ document.head.removeChild(style);
210
+ }
204
211
  }
205
- getDefaultStyle() {
206
- return `
212
+ }
213
+ #getDefaultStyle() {
214
+ return `
207
215
  @keyframes v-progress-start {
208
216
  0% {
209
217
  width: 0%;
@@ -248,7 +256,6 @@ export class ConnectionIndicator extends LitElement {
248
256
  .v-loading-indicator,
249
257
  .v-status-message {
250
258
  position: fixed;
251
- z-index: 251;
252
259
  left: 0;
253
260
  right: auto;
254
261
  top: 0;
@@ -360,80 +367,33 @@ export class ConnectionIndicator extends LitElement {
360
367
  }
361
368
  }
362
369
  `;
370
+ }
371
+ #getLoadingBarStyle() {
372
+ switch (this.#loadingBarState) {
373
+ case "" /* IDLE */:
374
+ return "display: none";
375
+ case "first" /* FIRST */:
376
+ case "second" /* SECOND */:
377
+ case "third" /* THIRD */:
378
+ return "display: block";
379
+ default:
380
+ return "";
363
381
  }
364
- getLoadingBarStyle() {
365
- switch (this.loadingBarState) {
366
- case LoadingBarState.IDLE:
367
- return 'display: none';
368
- case LoadingBarState.FIRST:
369
- case LoadingBarState.SECOND:
370
- case LoadingBarState.THIRD:
371
- return 'display: block';
372
- default:
373
- return '';
374
- }
375
- }
376
- timeoutFor(timeoutId, enabled, handler, delay) {
377
- if (timeoutId !== 0) {
378
- window.clearTimeout(timeoutId);
379
- }
380
- return enabled ? window.setTimeout(handler, delay) : 0;
381
- }
382
- static get instance() {
383
- return ConnectionIndicator.create();
382
+ }
383
+ #timeoutFor(timeoutId, enabled, handler, delay) {
384
+ if (timeoutId !== 0) {
385
+ window.clearTimeout(timeoutId);
384
386
  }
387
+ return enabled ? window.setTimeout(handler, delay) : 0;
388
+ }
385
389
  }
386
- __decorate([
387
- property({ type: Number })
388
- ], ConnectionIndicator.prototype, "firstDelay", void 0);
389
- __decorate([
390
- property({ type: Number })
391
- ], ConnectionIndicator.prototype, "secondDelay", void 0);
392
- __decorate([
393
- property({ type: Number })
394
- ], ConnectionIndicator.prototype, "thirdDelay", void 0);
395
- __decorate([
396
- property({ type: Number })
397
- ], ConnectionIndicator.prototype, "expandedDuration", void 0);
398
- __decorate([
399
- property({ type: String })
400
- ], ConnectionIndicator.prototype, "onlineText", void 0);
401
- __decorate([
402
- property({ type: String })
403
- ], ConnectionIndicator.prototype, "offlineText", void 0);
404
- __decorate([
405
- property({ type: String })
406
- ], ConnectionIndicator.prototype, "reconnectingText", void 0);
407
- __decorate([
408
- property({ type: Boolean, reflect: true })
409
- ], ConnectionIndicator.prototype, "offline", void 0);
410
- __decorate([
411
- property({ type: Boolean, reflect: true })
412
- ], ConnectionIndicator.prototype, "reconnecting", void 0);
413
- __decorate([
414
- property({ type: Boolean, reflect: true })
415
- ], ConnectionIndicator.prototype, "expanded", void 0);
416
- __decorate([
417
- property({ type: Boolean, reflect: true })
418
- ], ConnectionIndicator.prototype, "loading", void 0);
419
- __decorate([
420
- property({ type: String })
421
- ], ConnectionIndicator.prototype, "loadingBarState", void 0);
422
- __decorate([
423
- property({ type: Boolean })
424
- ], ConnectionIndicator.prototype, "applyDefaultTheme", null);
425
- if (customElements.get('vaadin-connection-indicator') === undefined) {
426
- customElements.define('vaadin-connection-indicator', ConnectionIndicator);
390
+ if (customElements.get("vaadin-connection-indicator") === void 0) {
391
+ customElements.define("vaadin-connection-indicator", ConnectionIndicator);
427
392
  }
428
- /**
429
- * The global connection indicator object. Its appearance and behavior can be
430
- * configured via properties:
431
- *
432
- * connectionIndicator.firstDelay = 0;
433
- * connectionIndicator.onlineText = 'The application is online';
434
- *
435
- * To avoid altering the appearance while the indicator is active, apply the
436
- * configuration in your application 'frontend/index.ts' file.
437
- */
438
- export const connectionIndicator = ConnectionIndicator.instance;
439
- //# sourceMappingURL=ConnectionIndicator.js.map
393
+ const connectionIndicator = ConnectionIndicator.instance;
394
+ export {
395
+ ConnectionIndicator,
396
+ LoadingBarState,
397
+ connectionIndicator
398
+ };
399
+ //# sourceMappingURL=ConnectionIndicator.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"ConnectionIndicator.js","sourceRoot":"","sources":["src/ConnectionIndicator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAwB,MAAM,sBAAsB,CAAC;AAE7E,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAN,IAAkB,eAKjB;AALD,WAAkB,eAAe;IAC/B,4BAAS,CAAA;IACT,kCAAe,CAAA;IACf,oCAAiB,CAAA;IACjB,kCAAe,CAAA;AACjB,CAAC,EALiB,eAAe,KAAf,eAAe,QAKhC;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAyFjD;QACE,KAAK,EAAE,CAAC;QA3EV;;WAEG;QAEH,eAAU,GAAG,GAAG,CAAC;QAEjB;;WAEG;QAEH,gBAAW,GAAG,IAAI,CAAC;QAEnB;;WAEG;QAEH,eAAU,GAAG,IAAI,CAAC;QAElB;;;WAGG;QAEH,qBAAgB,GAAG,IAAI,CAAC;QAExB;;WAEG;QAEH,eAAU,GAAG,QAAQ,CAAC;QAEtB;;WAEG;QAEH,gBAAW,GAAG,iBAAiB,CAAC;QAEhC;;WAEG;QAEH,qBAAgB,GAAG,yCAAyC,CAAC;QAGrD,YAAO,GAAG,KAAK,CAAC;QAGhB,iBAAY,GAAG,KAAK,CAAC;QAGrB,aA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M,EAAE,CAAC;4DACqC;AAwEhE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4DAG3B;AA6RH,IAAI,cAAc,CAAC,GAAG,CAAC,6BAA6B,CAAC,KAAK,SAAS,EAAE;IACnE,cAAc,CAAC,MAAM,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC;CAC3E;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,QAAQ,CAAC","sourcesContent":["/*\n * Copyright 2000-2020 Vaadin Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n * use this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ConnectionState, ConnectionStateStore } from './ConnectionState.js';\n\nconst DEFAULT_STYLE_ID = 'css-loading-indicator';\n\n/**\n * The loading indicator states\n */\nexport const enum LoadingBarState {\n IDLE = '',\n FIRST = 'first',\n SECOND = 'second',\n THIRD = 'third',\n}\n\n/**\n * Component showing loading and connection indicator. When added to DOM,\n * listens for changes on `window.Vaadin.connectionState` ConnectionStateStore.\n */\nexport class ConnectionIndicator extends LitElement {\n /**\n * Initialize global connection indicator instance at\n * window.Vaadin.connectionIndicator and add instance to the document body.\n */\n static create(): ConnectionIndicator {\n const $wnd = window as any;\n if (!$wnd.Vaadin?.connectionIndicator) {\n $wnd.Vaadin = $wnd.Vaadin || {};\n $wnd.Vaadin.connectionIndicator = document.createElement('vaadin-connection-indicator');\n document.body.appendChild($wnd.Vaadin.connectionIndicator);\n }\n return $wnd.Vaadin?.connectionIndicator as ConnectionIndicator;\n }\n\n /**\n * The delay before showing the loading indicator, in ms.\n */\n @property({ type: Number })\n firstDelay = 450;\n\n /**\n * The delay before the loading indicator goes into \"second\" state, in ms.\n */\n @property({ type: Number })\n secondDelay = 1500;\n\n /**\n * The delay before the loading indicator goes into \"third\" state, in ms.\n */\n @property({ type: Number })\n thirdDelay = 5000;\n\n /**\n * The duration for which the connection state change message is visible,\n * in ms.\n */\n @property({ type: Number })\n expandedDuration = 2000;\n\n /**\n * The message shown when the connection goes to connected state.\n */\n @property({ type: String })\n onlineText = 'Online';\n\n /**\n * The message shown when the connection goes to lost state.\n */\n @property({ type: String })\n offlineText = 'Connection lost';\n\n /**\n * The message shown when the connection goes to reconnecting state.\n */\n @property({ type: String })\n reconnectingText = 'Connection lost, trying to reconnect...';\n\n @property({ type: Boolean, reflect: true })\n private offline = false;\n\n @property({ type: Boolean, reflect: true })\n private reconnecting = false;\n\n @property({ type: Boolean, reflect: true })\n private expanded = false;\n\n @property({ type: Boolean, reflect: true })\n private loading = false;\n\n @property({ type: String })\n private loadingBarState: LoadingBarState = LoadingBarState.IDLE;\n\n private applyDefaultThemeState = true;\n\n private firstTimeout = 0;\n\n private secondTimeout = 0;\n\n private thirdTimeout = 0;\n\n private expandedTimeout = 0;\n\n private connectionStateStore?: ConnectionStateStore;\n\n private readonly connectionStateListener: () => void;\n\n private lastMessageState: ConnectionState = ConnectionState.CONNECTED;\n\n constructor() {\n super();\n\n this.connectionStateListener = () => {\n this.expanded = this.updateConnectionState();\n this.expandedTimeout = this.timeoutFor(\n this.expandedTimeout,\n this.expanded,\n () => {\n this.expanded = false;\n },\n this.expandedDuration\n );\n };\n }\n\n render() {\n return html`\n <div class=\"v-loading-indicator ${this.loadingBarState}\" style=${this.getLoadingBarStyle()}></div>\n\n <div\n class=\"v-status-message ${classMap({\n active: this.reconnecting,\n })}\"\n >\n <span class=\"text\"> ${this.renderMessage()} </span>\n </div>\n `;\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n const $wnd = window as any;\n if ($wnd.Vaadin?.connectionState) {\n this.connectionStateStore = $wnd.Vaadin.connectionState as ConnectionStateStore;\n this.connectionStateStore.addStateChangeListener(this.connectionStateListener);\n this.updateConnectionState();\n }\n\n this.updateTheme();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.connectionStateStore) {\n this.connectionStateStore.removeStateChangeListener(this.connectionStateListener);\n }\n\n this.updateTheme();\n }\n\n @property({ type: Boolean })\n get applyDefaultTheme() {\n return this.applyDefaultThemeState;\n }\n\n set applyDefaultTheme(applyDefaultTheme: boolean) {\n if (applyDefaultTheme !== this.applyDefaultThemeState) {\n this.applyDefaultThemeState = applyDefaultTheme;\n this.updateTheme();\n }\n }\n\n protected createRenderRoot() {\n return this;\n }\n\n /**\n * Update state flags.\n *\n * @return true if the connection message changes, and therefore a new\n * message should be shown\n */\n private updateConnectionState(): boolean {\n const state = this.connectionStateStore?.state;\n this.offline = state === ConnectionState.CONNECTION_LOST;\n this.reconnecting = state === ConnectionState.RECONNECTING;\n this.updateLoading(state === ConnectionState.LOADING);\n if (this.loading) {\n // Entering loading state, do not show message\n return false;\n }\n\n if (state !== this.lastMessageState) {\n this.lastMessageState = state!;\n // Message changes, show new message\n return true;\n }\n\n // Message did not change\n return false;\n }\n\n private updateLoading(loading: boolean) {\n this.loading = loading;\n this.loadingBarState = LoadingBarState.IDLE;\n\n this.firstTimeout = this.timeoutFor(\n this.firstTimeout,\n loading,\n () => {\n this.loadingBarState = LoadingBarState.FIRST;\n },\n this.firstDelay\n );\n\n this.secondTimeout = this.timeoutFor(\n this.secondTimeout,\n loading,\n () => {\n this.loadingBarState = LoadingBarState.SECOND;\n },\n this.secondDelay\n );\n\n this.thirdTimeout = this.timeoutFor(\n this.thirdTimeout,\n loading,\n () => {\n this.loadingBarState = LoadingBarState.THIRD;\n },\n this.thirdDelay\n );\n }\n\n private renderMessage() {\n if (this.reconnecting) {\n return this.reconnectingText;\n }\n\n if (this.offline) {\n return this.offlineText;\n }\n\n return this.onlineText;\n }\n\n private updateTheme() {\n if (this.applyDefaultThemeState && this.isConnected) {\n if (!document.getElementById(DEFAULT_STYLE_ID)) {\n const style = document.createElement('style');\n style.id = DEFAULT_STYLE_ID;\n style.textContent = this.getDefaultStyle();\n document.head.appendChild(style);\n }\n } else {\n const style = document.getElementById(DEFAULT_STYLE_ID);\n if (style) {\n document.head.removeChild(style);\n }\n }\n }\n\n private getDefaultStyle(): string {\n return `\n @keyframes v-progress-start {\n 0% {\n width: 0%;\n }\n 100% {\n width: 50%;\n }\n }\n @keyframes v-progress-delay {\n 0% {\n width: 50%;\n }\n 100% {\n width: 90%;\n }\n }\n @keyframes v-progress-wait {\n 0% {\n width: 90%;\n height: 4px;\n }\n 3% {\n width: 91%;\n height: 7px;\n }\n 100% {\n width: 96%;\n height: 7px;\n }\n }\n @keyframes v-progress-wait-pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.1;\n }\n 100% {\n opacity: 1;\n }\n }\n .v-loading-indicator,\n .v-status-message {\n position: fixed;\n z-index: 251;\n left: 0;\n right: auto;\n top: 0;\n background-color: var(--lumo-primary-color, var(--material-primary-color, blue));\n transition: none;\n }\n .v-loading-indicator {\n width: 50%;\n height: 4px;\n opacity: 1;\n pointer-events: none;\n animation: v-progress-start 1000ms 200ms both;\n }\n .v-loading-indicator[style*='none'] {\n display: block !important;\n width: 100%;\n opacity: 0;\n animation: none;\n transition: opacity 500ms 300ms, width 300ms;\n }\n .v-loading-indicator.second {\n width: 90%;\n animation: v-progress-delay 3.8s forwards;\n }\n .v-loading-indicator.third {\n width: 96%;\n animation: v-progress-wait 5s forwards, v-progress-wait-pulse 1s 4s infinite backwards;\n }\n\n vaadin-connection-indicator[offline] .v-loading-indicator,\n vaadin-connection-indicator[reconnecting] .v-loading-indicator {\n display: none;\n }\n\n .v-status-message {\n opacity: 0;\n width: 100%;\n max-height: var(--status-height-collapsed, 8px);\n overflow: hidden;\n background-color: var(--status-bg-color-online, var(--lumo-primary-color, var(--material-primary-color, blue)));\n color: var(\n --status-text-color-online,\n var(--lumo-primary-contrast-color, var(--material-primary-contrast-color, #fff))\n );\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1;\n transition: all 0.5s;\n padding: 0 0.5em;\n }\n\n vaadin-connection-indicator[offline] .v-status-message,\n vaadin-connection-indicator[reconnecting] .v-status-message {\n opacity: 1;\n background-color: var(--status-bg-color-offline, var(--lumo-shade, #333));\n color: var(\n --status-text-color-offline,\n var(--lumo-primary-contrast-color, var(--material-primary-contrast-color, #fff))\n );\n background-image: repeating-linear-gradient(\n 45deg,\n rgba(255, 255, 255, 0),\n rgba(255, 255, 255, 0) 10px,\n rgba(255, 255, 255, 0.1) 10px,\n rgba(255, 255, 255, 0.1) 20px\n );\n }\n\n vaadin-connection-indicator[reconnecting] .v-status-message {\n animation: show-reconnecting-status 2s;\n }\n\n vaadin-connection-indicator[offline] .v-status-message:hover,\n vaadin-connection-indicator[reconnecting] .v-status-message:hover,\n vaadin-connection-indicator[expanded] .v-status-message {\n max-height: var(--status-height, 1.75rem);\n }\n\n vaadin-connection-indicator[expanded] .v-status-message {\n opacity: 1;\n }\n\n .v-status-message span {\n display: flex;\n align-items: center;\n justify-content: center;\n height: var(--status-height, 1.75rem);\n }\n\n vaadin-connection-indicator[reconnecting] .v-status-message span::before {\n content: '';\n width: 1em;\n height: 1em;\n border-top: 2px solid\n var(--status-spinner-color, var(--lumo-primary-color, var(--material-primary-color, blue)));\n border-left: 2px solid\n var(--status-spinner-color, var(--lumo-primary-color, var(--material-primary-color, blue)));\n border-right: 2px solid transparent;\n border-bottom: 2px solid transparent;\n border-radius: 50%;\n box-sizing: border-box;\n animation: v-spin 0.4s linear infinite;\n margin: 0 0.5em;\n }\n\n @keyframes v-spin {\n 100% {\n transform: rotate(360deg);\n }\n }\n `;\n }\n\n private getLoadingBarStyle(): string {\n switch (this.loadingBarState) {\n case LoadingBarState.IDLE:\n return 'display: none';\n case LoadingBarState.FIRST:\n case LoadingBarState.SECOND:\n case LoadingBarState.THIRD:\n return 'display: block';\n default:\n return '';\n }\n }\n\n private timeoutFor(timeoutId: number, enabled: boolean, handler: () => void, delay: number): number {\n if (timeoutId !== 0) {\n window.clearTimeout(timeoutId);\n }\n\n return enabled ? window.setTimeout(handler, delay) : 0;\n }\n\n static get instance(): ConnectionIndicator {\n return ConnectionIndicator.create();\n }\n}\n\nif (customElements.get('vaadin-connection-indicator') === undefined) {\n customElements.define('vaadin-connection-indicator', ConnectionIndicator);\n}\n\n/**\n * The global connection indicator object. Its appearance and behavior can be\n * configured via properties:\n *\n * connectionIndicator.firstDelay = 0;\n * connectionIndicator.onlineText = 'The application is online';\n *\n * To avoid altering the appearance while the indicator is active, apply the\n * configuration in your application 'frontend/index.ts' file.\n */\nexport const connectionIndicator = ConnectionIndicator.instance;\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["src/ConnectionIndicator.ts"],
4
+ "sourcesContent": ["/*\n * Copyright 2000-2025 Vaadin Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n * use this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ConnectionState, type ConnectionStateStore } from './ConnectionState.js';\n\nconst DEFAULT_STYLE_ID = 'css-loading-indicator';\n\n/**\n * The loading indicator states\n */\nexport const enum LoadingBarState {\n IDLE = '',\n FIRST = 'first',\n SECOND = 'second',\n THIRD = 'third',\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'vaadin-connection-indicator': ConnectionIndicator;\n }\n}\n\n/**\n * Component showing loading and connection indicator. When added to DOM,\n * listens for changes on `window.Vaadin.connectionState` ConnectionStateStore.\n */\nexport class ConnectionIndicator extends LitElement {\n static get instance(): ConnectionIndicator {\n return ConnectionIndicator.create();\n }\n\n /**\n * Initialize global connection indicator instance at\n * window.Vaadin.connectionIndicator and add instance to the document body.\n */\n static create(): ConnectionIndicator {\n const $wnd = window as any;\n if (!$wnd.Vaadin?.connectionIndicator) {\n $wnd.Vaadin ??= {};\n $wnd.Vaadin.connectionIndicator = document.createElement('vaadin-connection-indicator');\n document.body.appendChild($wnd.Vaadin.connectionIndicator);\n }\n return $wnd.Vaadin?.connectionIndicator as ConnectionIndicator;\n }\n\n /**\n * The delay before showing the loading indicator, in ms.\n */\n @property({ type: Number })\n accessor firstDelay = 450;\n\n /**\n * The delay before the loading indicator goes into \"second\" state, in ms.\n */\n @property({ type: Number })\n accessor secondDelay = 1500;\n\n /**\n * The delay before the loading indicator goes into \"third\" state, in ms.\n */\n @property({ type: Number })\n accessor thirdDelay = 5000;\n\n /**\n * The duration for which the connection state change message is visible,\n * in ms.\n */\n @property({ type: Number })\n accessor expandedDuration = 2000;\n\n /**\n * The message shown when the connection goes to connected state.\n */\n @property({ type: String })\n accessor onlineText = 'Online';\n\n /**\n * The message shown when the connection goes to lost state.\n */\n @property({ type: String })\n accessor offlineText = 'Connection lost';\n\n /**\n * The message shown when the connection goes to reconnecting state.\n */\n @property({ type: String })\n accessor reconnectingText = 'Connection lost, trying to reconnect...';\n\n @property({ type: Boolean, reflect: true })\n accessor offline = false;\n\n @property({ type: Boolean, reflect: true })\n accessor reconnecting = false;\n\n @property({ type: Boolean, reflect: true })\n accessor expanded = false;\n\n @property({ type: Boolean, reflect: true })\n accessor loading = false;\n\n @state()\n accessor #loadingBarState: LoadingBarState = LoadingBarState.IDLE;\n\n accessor #isPopover: boolean = false;\n\n #applyDefaultThemeState = true;\n\n #firstTimeout = 0;\n\n #secondTimeout = 0;\n\n #thirdTimeout = 0;\n\n #expandedTimeout = 0;\n\n #connectionStateStore?: ConnectionStateStore;\n\n readonly connectionStateListener: () => void;\n\n #lastMessageState: ConnectionState = ConnectionState.CONNECTED;\n\n constructor() {\n super();\n\n this.connectionStateListener = () => {\n this.expanded = this.#updateConnectionState();\n this.#expandedTimeout = this.#timeoutFor(\n this.#expandedTimeout,\n this.expanded,\n () => {\n this.expanded = false;\n },\n this.expandedDuration,\n );\n };\n }\n\n protected override render() {\n return html`\n <div class=\"v-loading-indicator ${this.#loadingBarState}\" style=${this.#getLoadingBarStyle()}></div>\n\n <div\n class=\"v-status-message ${classMap({\n active: this.reconnecting,\n })}\"\n >\n <span class=\"text\"> ${this.#renderMessage()} </span>\n </div>\n `;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n\n this.#initPopover();\n\n const $wnd = window as any;\n if ($wnd.Vaadin?.connectionState) {\n this.#connectionStateStore = $wnd.Vaadin.connectionState as ConnectionStateStore;\n this.#connectionStateStore.addStateChangeListener(this.connectionStateListener);\n this.#updateConnectionState();\n }\n\n this.#updateTheme();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.#connectionStateStore) {\n this.#connectionStateStore.removeStateChangeListener(this.connectionStateListener);\n }\n\n this.#updateTheme();\n this.#isPopover = false;\n }\n\n protected override updated(props: PropertyValues): void {\n if (['loading', 'offline', 'reconnecting', 'expanded'].some((p) => props.has(p))) {\n this.#updatePopoverState();\n }\n }\n\n get applyDefaultTheme() {\n return this.#applyDefaultThemeState;\n }\n\n @property({ type: Boolean, reflect: true })\n set applyDefaultTheme(applyDefaultTheme: boolean) {\n if (applyDefaultTheme !== this.#applyDefaultThemeState) {\n this.#applyDefaultThemeState = applyDefaultTheme;\n this.#updateTheme();\n }\n }\n\n protected override createRenderRoot() {\n return this;\n }\n\n #initPopover() {\n // Allow showing the indicator as popover\n this.setAttribute('popover', 'manual');\n // Override user agent styles for popover\n this.style.display = 'contents';\n }\n\n /**\n * Update state flags.\n *\n * @returns true if the connection message changes, and therefore a new\n * message should be shown\n */\n #updateConnectionState(): boolean {\n const connectionState = this.#connectionStateStore?.state;\n this.offline = connectionState === ConnectionState.CONNECTION_LOST;\n this.reconnecting = connectionState === ConnectionState.RECONNECTING;\n this.#updateLoading(connectionState === ConnectionState.LOADING);\n if (this.loading) {\n // Entering loading state, do not show message\n return false;\n }\n\n if (connectionState !== this.#lastMessageState) {\n this.#lastMessageState = connectionState!;\n // Message changes, show new message\n return true;\n }\n\n // Message did not change\n return false;\n }\n\n #updateLoading(loading: boolean) {\n this.loading = loading;\n this.#loadingBarState = LoadingBarState.IDLE;\n\n this.#firstTimeout = this.#timeoutFor(\n this.#firstTimeout,\n loading,\n () => {\n this.#loadingBarState = LoadingBarState.FIRST;\n },\n this.firstDelay,\n );\n\n this.#secondTimeout = this.#timeoutFor(\n this.#secondTimeout,\n loading,\n () => {\n this.#loadingBarState = LoadingBarState.SECOND;\n },\n this.secondDelay,\n );\n\n this.#thirdTimeout = this.#timeoutFor(\n this.#thirdTimeout,\n loading,\n () => {\n this.#loadingBarState = LoadingBarState.THIRD;\n },\n this.thirdDelay,\n );\n }\n\n #updatePopoverState() {\n const showPopover = this.loading || this.offline || this.reconnecting || this.expanded;\n\n // Always close the popover first on state changes. This way, on every state change,\n // showPopover is called again, resulting in the connection indicator being shown on\n // top of other popovers that might have been added, for example after a reconnect.\n if (this.#isPopover) {\n this.hidePopover();\n }\n if (showPopover) {\n this.showPopover();\n }\n this.#isPopover = showPopover;\n }\n\n #renderMessage() {\n if (this.reconnecting) {\n return this.reconnectingText;\n }\n\n if (this.offline) {\n return this.offlineText;\n }\n\n return this.onlineText;\n }\n\n #updateTheme() {\n if (this.#applyDefaultThemeState && this.isConnected) {\n if (!document.getElementById(DEFAULT_STYLE_ID)) {\n const style = document.createElement('style');\n style.id = DEFAULT_STYLE_ID;\n style.textContent = this.#getDefaultStyle();\n document.head.appendChild(style);\n }\n } else {\n const style = document.getElementById(DEFAULT_STYLE_ID);\n if (style) {\n document.head.removeChild(style);\n }\n }\n }\n\n #getDefaultStyle(): string {\n return `\n @keyframes v-progress-start {\n 0% {\n width: 0%;\n }\n 100% {\n width: 50%;\n }\n }\n @keyframes v-progress-delay {\n 0% {\n width: 50%;\n }\n 100% {\n width: 90%;\n }\n }\n @keyframes v-progress-wait {\n 0% {\n width: 90%;\n height: 4px;\n }\n 3% {\n width: 91%;\n height: 7px;\n }\n 100% {\n width: 96%;\n height: 7px;\n }\n }\n @keyframes v-progress-wait-pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.1;\n }\n 100% {\n opacity: 1;\n }\n }\n .v-loading-indicator,\n .v-status-message {\n position: fixed;\n left: 0;\n right: auto;\n top: 0;\n background-color: var(--lumo-primary-color, var(--material-primary-color, blue));\n transition: none;\n }\n .v-loading-indicator {\n width: 50%;\n height: 4px;\n opacity: 1;\n pointer-events: none;\n animation: v-progress-start 1000ms 200ms both;\n }\n .v-loading-indicator[style*='none'] {\n display: block !important;\n width: 100%;\n opacity: 0;\n animation: none;\n transition: opacity 500ms 300ms, width 300ms;\n }\n .v-loading-indicator.second {\n width: 90%;\n animation: v-progress-delay 3.8s forwards;\n }\n .v-loading-indicator.third {\n width: 96%;\n animation: v-progress-wait 5s forwards, v-progress-wait-pulse 1s 4s infinite backwards;\n }\n\n vaadin-connection-indicator[offline] .v-loading-indicator,\n vaadin-connection-indicator[reconnecting] .v-loading-indicator {\n display: none;\n }\n\n .v-status-message {\n opacity: 0;\n width: 100%;\n max-height: var(--status-height-collapsed, 8px);\n overflow: hidden;\n background-color: var(--status-bg-color-online, var(--lumo-primary-color, var(--material-primary-color, blue)));\n color: var(\n --status-text-color-online,\n var(--lumo-primary-contrast-color, var(--material-primary-contrast-color, #fff))\n );\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1;\n transition: all 0.5s;\n padding: 0 0.5em;\n }\n\n vaadin-connection-indicator[offline] .v-status-message,\n vaadin-connection-indicator[reconnecting] .v-status-message {\n opacity: 1;\n background-color: var(--status-bg-color-offline, var(--lumo-shade, #333));\n color: var(\n --status-text-color-offline,\n var(--lumo-primary-contrast-color, var(--material-primary-contrast-color, #fff))\n );\n background-image: repeating-linear-gradient(\n 45deg,\n rgba(255, 255, 255, 0),\n rgba(255, 255, 255, 0) 10px,\n rgba(255, 255, 255, 0.1) 10px,\n rgba(255, 255, 255, 0.1) 20px\n );\n }\n\n vaadin-connection-indicator[reconnecting] .v-status-message {\n animation: show-reconnecting-status 2s;\n }\n\n vaadin-connection-indicator[offline] .v-status-message:hover,\n vaadin-connection-indicator[reconnecting] .v-status-message:hover,\n vaadin-connection-indicator[expanded] .v-status-message {\n max-height: var(--status-height, 1.75rem);\n }\n\n vaadin-connection-indicator[expanded] .v-status-message {\n opacity: 1;\n }\n\n .v-status-message span {\n display: flex;\n align-items: center;\n justify-content: center;\n height: var(--status-height, 1.75rem);\n }\n\n vaadin-connection-indicator[reconnecting] .v-status-message span::before {\n content: '';\n width: 1em;\n height: 1em;\n border-top: 2px solid\n var(--status-spinner-color, var(--lumo-primary-color, var(--material-primary-color, blue)));\n border-left: 2px solid\n var(--status-spinner-color, var(--lumo-primary-color, var(--material-primary-color, blue)));\n border-right: 2px solid transparent;\n border-bottom: 2px solid transparent;\n border-radius: 50%;\n box-sizing: border-box;\n animation: v-spin 0.4s linear infinite;\n margin: 0 0.5em;\n }\n\n @keyframes v-spin {\n 100% {\n transform: rotate(360deg);\n }\n }\n `;\n }\n\n #getLoadingBarStyle(): string {\n switch (this.#loadingBarState) {\n case LoadingBarState.IDLE:\n return 'display: none';\n case LoadingBarState.FIRST:\n case LoadingBarState.SECOND:\n case LoadingBarState.THIRD:\n return 'display: block';\n default:\n return '';\n }\n }\n\n #timeoutFor(timeoutId: number, enabled: boolean, handler: () => void, delay: number): number {\n if (timeoutId !== 0) {\n window.clearTimeout(timeoutId);\n }\n\n return enabled ? window.setTimeout(handler, delay) : 0;\n }\n}\n\nif (customElements.get('vaadin-connection-indicator') === undefined) {\n customElements.define('vaadin-connection-indicator', ConnectionIndicator);\n}\n\n/**\n * The global connection indicator object. Its appearance and behavior can be\n * configured via properties:\n *\n * connectionIndicator.firstDelay = 0;\n * connectionIndicator.onlineText = 'The application is online';\n *\n * To avoid altering the appearance while the indicator is active, apply the\n * configuration in your application 'frontend/index.ts' file.\n */\nexport const connectionIndicator = ConnectionIndicator.instance;\n"],
5
+ "mappings": "AAgBA,SAAS,MAAM,kBAAuC;AACtD,SAAS,UAAU,aAAa;AAChC,SAAS,gBAAgB;AACzB,SAAS,uBAAkD;AAE3D,MAAM,mBAAmB;AAKlB,IAAW,kBAAX,kBAAWA,qBAAX;AACL,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AACT,EAAAA,iBAAA,WAAQ;AAJQ,SAAAA;AAAA,GAAA;AAiBX,MAAM,4BAA4B,WAAW;AAAA,EAClD,WAAW,WAAgC;AACzC,WAAO,oBAAoB,OAAO;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,SAA8B;AACnC,UAAM,OAAO;AACb,QAAI,CAAC,KAAK,QAAQ,qBAAqB;AACrC,WAAK,WAAW,CAAC;AACjB,WAAK,OAAO,sBAAsB,SAAS,cAAc,6BAA6B;AACtF,eAAS,KAAK,YAAY,KAAK,OAAO,mBAAmB;AAAA,IAC3D;AACA,WAAO,KAAK,QAAQ;AAAA,EACtB;AAKA,GAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,EAC1B,SAAS,aAAa;AAKtB,GAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,EAC1B,SAAS,cAAc;AAKvB,GAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,EAC1B,SAAS,aAAa;AAMtB,GAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,EAC1B,SAAS,mBAAmB;AAK5B,GAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,EAC1B,SAAS,aAAa;AAKtB,GAAC,SAAS,EA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AAO,aAAa,SAAS;AAAA,IAC/B;AAEA,WAAO,UAAU,OAAO,WAAW,SAAS,KAAK,IAAI;AAAA,EACvD;AACF;AAEA,IAAI,eAAe,IAAI,6BAA6B,MAAM,QAAW;AACnE,iBAAe,OAAO,+BAA+B,mBAAmB;AAC1E;AAYO,MAAM,sBAAsB,oBAAoB;",
6
+ "names": ["LoadingBarState"]
7
+ }
@@ -6,7 +6,7 @@ export declare enum ConnectionState {
6
6
  CONNECTED = "connected",
7
7
  /**
8
8
  * Application is connected and Flow is loading application state from the
9
- * server, or Fusion is waiting for an endpoint call to return.
9
+ * server, or Hilla is waiting for an endpoint call to return.
10
10
  */
11
11
  LOADING = "loading",
12
12
  /**
@@ -24,23 +24,19 @@ export declare enum ConnectionState {
24
24
  */
25
25
  CONNECTION_LOST = "connection-lost"
26
26
  }
27
- export declare type ConnectionStateChangeListener = (previous: ConnectionState, current: ConnectionState) => void;
27
+ export type ConnectionStateChangeListener = (previous: ConnectionState, current: ConnectionState) => void;
28
28
  export declare class ConnectionStateStore {
29
- private connectionState;
30
- private stateChangeListeners;
31
- private loadingCount;
29
+ #private;
32
30
  constructor(initialState: ConnectionState);
33
31
  addStateChangeListener(listener: ConnectionStateChangeListener): void;
34
32
  removeStateChangeListener(listener: ConnectionStateChangeListener): void;
35
33
  loadingStarted(): void;
36
34
  loadingFinished(): void;
37
35
  loadingFailed(): void;
38
- private decreaseLoadingCount;
39
36
  get state(): ConnectionState;
40
37
  set state(newState: ConnectionState);
41
38
  get online(): boolean;
42
39
  get offline(): boolean;
43
- private serviceWorkerMessageListener;
44
40
  }
45
- export declare const isLocalhost: (hostname: string) => boolean;
41
+ export declare function isLocalhost(hostname: string): boolean;
46
42
  //# sourceMappingURL=ConnectionState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionState.d.ts","sourceRoot":"","sources":["src/ConnectionState.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB;;;OAGG;IACH,SAAS,cAAc;IAE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6BAA6B,GAAG,IAAI;IAIrE,yBAAyB,CAAC,QAAQ,EAAE,6BAA6B,GAAG,IAAI;IAIxE,cAAc,IAAI,IAAI;IAKtB,eAAe,IAAI,IAAI;IAIvB,aAAa,IAAI,IAAI;IAarB,IAAI,KAAK,IAAI,eAAe,CAE3B;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,eAAe,EASlC;IAED,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;CAcF;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUrD"}
@@ -1,128 +1,103 @@
1
- var _a;
2
- export var ConnectionState;
3
- (function (ConnectionState) {
4
- /**
5
- * Application is connected to server: last transaction over the wire (XHR /
6
- * heartbeat / endpoint call) was successful.
7
- */
8
- ConnectionState["CONNECTED"] = "connected";
9
- /**
10
- * Application is connected and Flow is loading application state from the
11
- * server, or Fusion is waiting for an endpoint call to return.
12
- */
13
- ConnectionState["LOADING"] = "loading";
14
- /**
15
- * Application has been temporarily disconnected from the server because the
16
- * last transaction over the wire (XHR / heartbeat / endpoint call) resulted
17
- * in a network error, or the browser has received the 'online' event and needs
18
- * to verify reconnection with the server. Flow is attempting to reconnect
19
- * a configurable number of times before giving up.
20
- */
21
- ConnectionState["RECONNECTING"] = "reconnecting";
22
- /**
23
- * Application has been permanently disconnected due to browser receiving the
24
- * 'offline' event, or the server not being reached after a number of reconnect
25
- * attempts.
26
- */
27
- ConnectionState["CONNECTION_LOST"] = "connection-lost";
28
- })(ConnectionState || (ConnectionState = {}));
29
- export class ConnectionStateStore {
30
- constructor(initialState) {
31
- this.stateChangeListeners = new Set();
32
- this.loadingCount = 0;
33
- this.connectionState = initialState;
34
- this.serviceWorkerMessageListener = this.serviceWorkerMessageListener.bind(this);
35
- if (navigator.serviceWorker) {
36
- // Query service worker if the most recent fetch was served from cache
37
- // Add message listener for handling response
38
- navigator.serviceWorker.addEventListener('message', this.serviceWorkerMessageListener);
39
- // Send JSON-RPC request to Vaadin service worker
40
- navigator.serviceWorker.ready.then((registration) => {
41
- var _a;
42
- (_a = registration === null || registration === void 0 ? void 0 : registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
43
- method: 'Vaadin.ServiceWorker.isConnectionLost',
44
- id: 'Vaadin.ServiceWorker.isConnectionLost',
45
- });
46
- });
47
- }
48
- }
49
- addStateChangeListener(listener) {
50
- this.stateChangeListeners.add(listener);
51
- }
52
- removeStateChangeListener(listener) {
53
- this.stateChangeListeners.delete(listener);
54
- }
55
- loadingStarted() {
56
- this.state = ConnectionState.LOADING;
57
- this.loadingCount += 1;
58
- }
59
- loadingFinished() {
60
- this.decreaseLoadingCount(ConnectionState.CONNECTED);
61
- }
62
- loadingFailed() {
63
- this.decreaseLoadingCount(ConnectionState.CONNECTION_LOST);
64
- }
65
- decreaseLoadingCount(finalState) {
66
- if (this.loadingCount > 0) {
67
- this.loadingCount -= 1;
68
- if (this.loadingCount === 0) {
69
- this.state = finalState;
70
- }
71
- }
72
- }
73
- get state() {
74
- return this.connectionState;
75
- }
76
- set state(newState) {
77
- if (newState !== this.connectionState) {
78
- const prevState = this.connectionState;
79
- this.connectionState = newState;
80
- this.loadingCount = 0;
81
- for (const listener of this.stateChangeListeners) {
82
- listener(prevState, this.connectionState);
83
- }
84
- }
85
- }
86
- get online() {
87
- return this.connectionState === ConnectionState.CONNECTED || this.connectionState === ConnectionState.LOADING;
88
- }
89
- get offline() {
90
- return !this.online;
91
- }
92
- serviceWorkerMessageListener(event) {
93
- // Handle JSON-RPC response from service worker
94
- if (typeof event.data === 'object' && event.data.id === 'Vaadin.ServiceWorker.isConnectionLost') {
95
- if (event.data.result === true) {
96
- this.state = ConnectionState.CONNECTION_LOST;
97
- }
98
- // Cleanup: remove event listener upon receiving response
99
- navigator.serviceWorker.removeEventListener('message', this.serviceWorkerMessageListener);
100
- }
101
- }
1
+ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
2
+ ConnectionState2["CONNECTED"] = "connected";
3
+ ConnectionState2["LOADING"] = "loading";
4
+ ConnectionState2["RECONNECTING"] = "reconnecting";
5
+ ConnectionState2["CONNECTION_LOST"] = "connection-lost";
6
+ return ConnectionState2;
7
+ })(ConnectionState || {});
8
+ class ConnectionStateStore {
9
+ #stateChangeListeners = /* @__PURE__ */ new Set();
10
+ #connectionState;
11
+ #loadingCount = 0;
12
+ constructor(initialState) {
13
+ this.#connectionState = initialState;
14
+ if (navigator.serviceWorker) {
15
+ navigator.serviceWorker.addEventListener("message", this.#serviceWorkerMessageListener);
16
+ void navigator.serviceWorker.ready.then((registration) => {
17
+ registration.active?.postMessage({
18
+ method: "Vaadin.ServiceWorker.isConnectionLost",
19
+ id: "Vaadin.ServiceWorker.isConnectionLost"
20
+ });
21
+ });
22
+ }
23
+ }
24
+ addStateChangeListener(listener) {
25
+ this.#stateChangeListeners.add(listener);
26
+ }
27
+ removeStateChangeListener(listener) {
28
+ this.#stateChangeListeners.delete(listener);
29
+ }
30
+ loadingStarted() {
31
+ this.state = "loading" /* LOADING */;
32
+ this.#loadingCount += 1;
33
+ }
34
+ loadingFinished() {
35
+ this.#decreaseLoadingCount("connected" /* CONNECTED */);
36
+ }
37
+ loadingFailed() {
38
+ this.#decreaseLoadingCount("connection-lost" /* CONNECTION_LOST */);
39
+ }
40
+ #decreaseLoadingCount(finalState) {
41
+ if (this.#loadingCount > 0) {
42
+ this.#loadingCount -= 1;
43
+ if (this.#loadingCount === 0) {
44
+ this.state = finalState;
45
+ }
46
+ }
47
+ }
48
+ get state() {
49
+ return this.#connectionState;
50
+ }
51
+ set state(newState) {
52
+ if (newState !== this.#connectionState) {
53
+ const prevState = this.#connectionState;
54
+ this.#connectionState = newState;
55
+ this.#loadingCount = 0;
56
+ for (const listener of this.#stateChangeListeners) {
57
+ listener(prevState, this.#connectionState);
58
+ }
59
+ }
60
+ }
61
+ get online() {
62
+ return this.#connectionState === "connected" /* CONNECTED */ || this.#connectionState === "loading" /* LOADING */;
63
+ }
64
+ get offline() {
65
+ return !this.online;
66
+ }
67
+ #serviceWorkerMessageListener = (event) => {
68
+ if (typeof event.data === "object" && event.data.id === "Vaadin.ServiceWorker.isConnectionLost") {
69
+ if (event.data.result === true) {
70
+ this.state = "connection-lost" /* CONNECTION_LOST */;
71
+ }
72
+ navigator.serviceWorker.removeEventListener("message", this.#serviceWorkerMessageListener);
73
+ }
74
+ };
75
+ }
76
+ function isLocalhost(hostname) {
77
+ if (hostname === "localhost") {
78
+ return true;
79
+ }
80
+ if (hostname === "[::1]") {
81
+ return true;
82
+ }
83
+ return /^127\.\d+\.\d+\.\d+$/u.test(hostname);
102
84
  }
103
- export const isLocalhost = (hostname) => {
104
- if (hostname === 'localhost') {
105
- return true;
106
- }
107
- if (hostname === '[::1]') {
108
- return true;
109
- }
110
- if (hostname.match(/^127\.\d+\.\d+\.\d+$/)) {
111
- return true;
112
- }
113
- return false;
114
- };
115
85
  const $wnd = window;
116
- if (!((_a = $wnd.Vaadin) === null || _a === void 0 ? void 0 : _a.connectionState)) {
117
- let online;
118
- if (isLocalhost(window.location.hostname)) {
119
- // We do not know if we are online or not as we cannot trust navigator.onLine which checks availability of a network connection. Better to assume online so localhost apps can work
120
- online = true;
121
- }
122
- else {
123
- online = navigator.onLine;
124
- }
125
- $wnd.Vaadin = $wnd.Vaadin || {};
126
- $wnd.Vaadin.connectionState = new ConnectionStateStore(online ? ConnectionState.CONNECTED : ConnectionState.CONNECTION_LOST);
86
+ if (!$wnd.Vaadin?.connectionState) {
87
+ let online;
88
+ if (isLocalhost(window.location.hostname)) {
89
+ online = true;
90
+ } else {
91
+ online = navigator.onLine;
92
+ }
93
+ $wnd.Vaadin ??= {};
94
+ $wnd.Vaadin.connectionState = new ConnectionStateStore(
95
+ online ? "connected" /* CONNECTED */ : "connection-lost" /* CONNECTION_LOST */
96
+ );
127
97
  }
128
- //# sourceMappingURL=ConnectionState.js.map
98
+ export {
99
+ ConnectionState,
100
+ ConnectionStateStore,
101
+ isLocalhost
102
+ };
103
+ //# sourceMappingURL=ConnectionState.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"ConnectionState.js","sourceRoot":"","sources":["src/ConnectionState.ts"],"names":[],"mappings":";AAAA,MAAM,CAAN,IAAY,eA4BX;AA5BD,WAAY,eAAe;IACzB;;;OAGG;IACH,0CAAuB,CAAA;IAEvB;;;OAGG;IACH,sCAAmB,CAAA;IAEnB;;;;;;OAMG;IACH,gDAA6B,CAAA;IAE7B;;;;OAIG;IACH,sDAAmC,CAAA;AACrC,CAAC,EA5BW,eAAe,KAAf,eAAe,QA4B1B;AAID,MAAM,OAAO,oBAAoB;IAO/B,YAAY,YAA6B;QAJjC,yBAAoB,GAAuC,IAAI,GAAG,EAAE,CAAC;QAErE,iBAAY,GAAG,CAAC,CAAC;QAGvB,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QAEpC,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjF,IAAI,SAAS,CAAC,aAAa,EAAE;YAC3B,sEAAsE;YACtE,6CAA6C;YAC7C,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC;YACvF,iDAAiD;YACjD,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;;gBAClD,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,0CAAE,WAAW,CAAC;oBAChC,MAAM,EAAE,uCAAuC;oBAC/C,EAAE,EAAE,uCAAuC;iBAC5C,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,sBAAsB,CAAC,QAAuC;QAC5D,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,yBAAyB,CAAC,QAAuC;QAC/D,IAAI,CAAC,oBAA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ConnectionState {\n /**\n * Application is connected to server: last transaction over the wire (XHR /\n * heartbeat / endpoint call) was successful.\n */\n CONNECTED = 'connected',\n\n /**\n * Application is connected and Flow is loading application state from the\n * server, or Fusion is waiting for an endpoint call to return.\n */\n LOADING = 'loading',\n\n /**\n * Application has been temporarily disconnected from the server because the\n * last transaction over the wire (XHR / heartbeat / endpoint call) resulted\n * in a network error, or the browser has received the 'online' event and needs\n * to verify reconnection with the server. Flow is attempting to reconnect\n * a configurable number of times before giving up.\n */\n RECONNECTING = 'reconnecting',\n\n /**\n * Application has been permanently disconnected due to browser receiving the\n * 'offline' event, or the server not being reached after a number of reconnect\n * attempts.\n */\n CONNECTION_LOST = 'connection-lost',\n}\n\nexport type ConnectionStateChangeListener = (previous: ConnectionState, current: ConnectionState) => void;\n\nexport class ConnectionStateStore {\n private connectionState: ConnectionState;\n\n private stateChangeListeners: Set<ConnectionStateChangeListener> = new Set();\n\n private loadingCount = 0;\n\n constructor(initialState: ConnectionState) {\n this.connectionState = initialState;\n\n this.serviceWorkerMessageListener = this.serviceWorkerMessageListener.bind(this);\n\n if (navigator.serviceWorker) {\n // Query service worker if the most recent fetch was served from cache\n // Add message listener for handling response\n navigator.serviceWorker.addEventListener('message', this.serviceWorkerMessageListener);\n // Send JSON-RPC request to Vaadin service worker\n navigator.serviceWorker.ready.then((registration) => {\n registration?.active?.postMessage({\n method: 'Vaadin.ServiceWorker.isConnectionLost',\n id: 'Vaadin.ServiceWorker.isConnectionLost',\n });\n });\n }\n }\n\n addStateChangeListener(listener: ConnectionStateChangeListener): void {\n this.stateChangeListeners.add(listener);\n }\n\n removeStateChangeListener(listener: ConnectionStateChangeListener): void {\n this.stateChangeListeners.delete(listener);\n }\n\n loadingStarted(): void {\n this.state = ConnectionState.LOADING;\n this.loadingCount += 1;\n }\n\n loadingFinished(): void {\n this.decreaseLoadingCount(ConnectionState.CONNECTED);\n }\n\n loadingFailed(): void {\n this.decreaseLoadingCount(ConnectionState.CONNECTION_LOST);\n }\n\n private decreaseLoadingCount(finalState: ConnectionState) {\n if (this.loadingCount > 0) {\n this.loadingCount -= 1;\n if (this.loadingCount === 0) {\n this.state = finalState;\n }\n }\n }\n\n get state(): ConnectionState {\n return this.connectionState;\n }\n\n set state(newState: ConnectionState) {\n if (newState !== this.connectionState) {\n const prevState = this.connectionState;\n this.connectionState = newState;\n this.loadingCount = 0;\n for (const listener of this.stateChangeListeners) {\n listener(prevState, this.connectionState);\n }\n }\n }\n\n get online(): boolean {\n return this.connectionState === ConnectionState.CONNECTED || this.connectionState === ConnectionState.LOADING;\n }\n\n get offline(): boolean {\n return !this.online;\n }\n\n private serviceWorkerMessageListener(event: MessageEvent) {\n // Handle JSON-RPC response from service worker\n if (typeof event.data === 'object' && event.data.id === 'Vaadin.ServiceWorker.isConnectionLost') {\n if (event.data.result === true) {\n this.state = ConnectionState.CONNECTION_LOST;\n }\n\n // Cleanup: remove event listener upon receiving response\n navigator.serviceWorker.removeEventListener('message', this.serviceWorkerMessageListener);\n }\n }\n}\n\nexport const isLocalhost = (hostname: string) => {\n if (hostname === 'localhost') {\n return true;\n }\n if (hostname === '[::1]') {\n return true;\n }\n if (hostname.match(/^127\\.\\d+\\.\\d+\\.\\d+$/)) {\n return true;\n }\n\n return false;\n};\n\nconst $wnd = window as any;\nif (!$wnd.Vaadin?.connectionState) {\n let online;\n if (isLocalhost(window.location.hostname)) {\n // We do not know if we are online or not as we cannot trust navigator.onLine which checks availability of a network connection. Better to assume online so localhost apps can work\n online = true;\n } else {\n online = navigator.onLine;\n }\n\n $wnd.Vaadin = $wnd.Vaadin || {};\n $wnd.Vaadin.connectionState = new ConnectionStateStore(\n online ? ConnectionState.CONNECTED : ConnectionState.CONNECTION_LOST\n );\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["src/ConnectionState.ts"],
4
+ "sourcesContent": ["/*\n * Copyright 2000-2025 Vaadin Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n * use this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nexport enum ConnectionState {\n /**\n * Application is connected to server: last transaction over the wire (XHR /\n * heartbeat / endpoint call) was successful.\n */\n CONNECTED = 'connected',\n\n /**\n * Application is connected and Flow is loading application state from the\n * server, or Hilla is waiting for an endpoint call to return.\n */\n LOADING = 'loading',\n\n /**\n * Application has been temporarily disconnected from the server because the\n * last transaction over the wire (XHR / heartbeat / endpoint call) resulted\n * in a network error, or the browser has received the 'online' event and needs\n * to verify reconnection with the server. Flow is attempting to reconnect\n * a configurable number of times before giving up.\n */\n RECONNECTING = 'reconnecting',\n\n /**\n * Application has been permanently disconnected due to browser receiving the\n * 'offline' event, or the server not being reached after a number of reconnect\n * attempts.\n */\n CONNECTION_LOST = 'connection-lost',\n}\n\nexport type ConnectionStateChangeListener = (previous: ConnectionState, current: ConnectionState) => void;\n\nexport class ConnectionStateStore {\n readonly #stateChangeListeners = new Set<ConnectionStateChangeListener>();\n\n #connectionState: ConnectionState;\n #loadingCount = 0;\n\n constructor(initialState: ConnectionState) {\n this.#connectionState = initialState;\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (navigator.serviceWorker) {\n // Query service worker if the most recent fetch was served from cache\n // Add message listener for handling response\n // eslint-disable-next-line @typescript-eslint/unbound-method\n navigator.serviceWorker.addEventListener('message', this.#serviceWorkerMessageListener);\n // Send JSON-RPC request to Vaadin service worker\n // eslint-disable-next-line no-void\n void navigator.serviceWorker.ready.then((registration) => {\n registration.active?.postMessage({\n method: 'Vaadin.ServiceWorker.isConnectionLost',\n id: 'Vaadin.ServiceWorker.isConnectionLost',\n });\n });\n }\n }\n\n addStateChangeListener(listener: ConnectionStateChangeListener): void {\n this.#stateChangeListeners.add(listener);\n }\n\n removeStateChangeListener(listener: ConnectionStateChangeListener): void {\n this.#stateChangeListeners.delete(listener);\n }\n\n loadingStarted(): void {\n this.state = ConnectionState.LOADING;\n this.#loadingCount += 1;\n }\n\n loadingFinished(): void {\n this.#decreaseLoadingCount(ConnectionState.CONNECTED);\n }\n\n loadingFailed(): void {\n this.#decreaseLoadingCount(ConnectionState.CONNECTION_LOST);\n }\n\n #decreaseLoadingCount(finalState: ConnectionState) {\n if (this.#loadingCount > 0) {\n this.#loadingCount -= 1;\n if (this.#loadingCount === 0) {\n this.state = finalState;\n }\n }\n }\n\n get state(): ConnectionState {\n return this.#connectionState;\n }\n\n set state(newState: ConnectionState) {\n if (newState !== this.#connectionState) {\n const prevState = this.#connectionState;\n this.#connectionState = newState;\n this.#loadingCount = 0;\n for (const listener of this.#stateChangeListeners) {\n listener(prevState, this.#connectionState);\n }\n }\n }\n\n get online(): boolean {\n return this.#connectionState === ConnectionState.CONNECTED || this.#connectionState === ConnectionState.LOADING;\n }\n\n get offline(): boolean {\n return !this.online;\n }\n\n readonly #serviceWorkerMessageListener = (event: MessageEvent) => {\n // Handle JSON-RPC response from service worker\n if (typeof event.data === 'object' && event.data.id === 'Vaadin.ServiceWorker.isConnectionLost') {\n if (event.data.result === true) {\n this.state = ConnectionState.CONNECTION_LOST;\n }\n\n // Cleanup: remove event listener upon receiving response\n // eslint-disable-next-line @typescript-eslint/unbound-method\n navigator.serviceWorker.removeEventListener('message', this.#serviceWorkerMessageListener);\n }\n };\n}\n\nexport function isLocalhost(hostname: string): boolean {\n if (hostname === 'localhost') {\n return true;\n }\n\n if (hostname === '[::1]') {\n return true;\n }\n\n return /^127\\.\\d+\\.\\d+\\.\\d+$/u.test(hostname);\n}\n\nconst $wnd = window as any;\nif (!$wnd.Vaadin?.connectionState) {\n let online;\n if (isLocalhost(window.location.hostname)) {\n // We do not know if we are online or not as we cannot trust navigator.onLine which checks availability of a network connection. Better to assume online so localhost apps can work\n online = true;\n } else {\n online = navigator.onLine;\n }\n\n $wnd.Vaadin ??= {};\n $wnd.Vaadin.connectionState = new ConnectionStateStore(\n online ? ConnectionState.CONNECTED : ConnectionState.CONNECTION_LOST,\n );\n}\n"],
5
+ "mappings": "AAgBO,IAAK,kBAAL,kBAAKA,qBAAL;AAKL,EAAAA,iBAAA,eAAY;AAMZ,EAAAA,iBAAA,aAAU;AASV,EAAAA,iBAAA,kBAAe;AAOf,EAAAA,iBAAA,qBAAkB;AA3BR,SAAAA;AAAA,GAAA;AAgCL,MAAM,qBAAqB;AAAA,EACvB,wBAAwB,oBAAI,IAAmC;AAAA,EAExE;AAAA,EACA,gBAAgB;AAAA,EAEhB,YAAY,cAA+B;AACzC,SAAK,mBAAmB;AAGxB,QAAI,UAAU,eAAe;AAI3B,gBAAU,cAAc,iBAAiB,WAAW,KAAK,6BAA6B;AAGtF,WAAK,UAAU,cAAc,MAAM,KAAK,CAAC,iBAAiB;AACxD,qBAAa,QAAQ,YAAY;AAAA,UAC/B,QAAQ;AAAA,UACR,IAAI;AAAA,QACN,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,uBAAuB,UAA+C;AACpE,SAAK,sBAAsB,IAAI,QAAQ;AAAA,EACzC;AAAA,EAEA,0BAA0B,UAA+C;AACvE,SAAK,sBAAsB,OAAO,QAAQ;AAAA,EAC5C;AAAA,EAEA,iBAAuB;AACrB,SAAK,QAAQ;AACb,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,kBAAwB;AACtB,SAAK,sBAAsB,2BAAyB;AAAA,EACtD;AAAA,EAEA,gBAAsB;AACpB,SAAK,sBAAsB,uCAA+B;AAAA,EAC5D;AAAA,EAEA,sBAAsB,YAA6B;AACjD,QAAI,KAAK,gBAAgB,GAAG;AAC1B,WAAK,iBAAiB;AACtB,UAAI,KAAK,kBAAkB,GAAG;AAC5B,aAAK,QAAQ;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,QAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,MAAM,UAA2B;AACnC,QAAI,aAAa,KAAK,kBAAkB;AACtC,YAAM,YAAY,KAAK;AACvB,WAAK,mBAAmB;AACxB,WAAK,gBAAgB;AACrB,iBAAW,YAAY,KAAK,uBAAuB;AACjD,iBAAS,WAAW,KAAK,gBAAgB;AAAA,MAC3C;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,SAAkB;AACpB,WAAO,KAAK,qBAAqB,+BAA6B,KAAK,qBAAqB;AAAA,EAC1F;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,CAAC,KAAK;AAAA,EACf;AAAA,EAES,gCAAgC,CAAC,UAAwB;AAEhE,QAAI,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,OAAO,yCAAyC;AAC/F,UAAI,MAAM,KAAK,WAAW,MAAM;AAC9B,aAAK,QAAQ;AAAA,MACf;AAIA,gBAAU,cAAc,oBAAoB,WAAW,KAAK,6BAA6B;AAAA,IAC3F;AAAA,EACF;AACF;AAEO,SAAS,YAAY,UAA2B;AACrD,MAAI,aAAa,aAAa;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,SAAS;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,wBAAwB,KAAK,QAAQ;AAC9C;AAEA,MAAM,OAAO;AACb,IAAI,CAAC,KAAK,QAAQ,iBAAiB;AACjC,MAAI;AACJ,MAAI,YAAY,OAAO,SAAS,QAAQ,GAAG;AAEzC,aAAS;AAAA,EACX,OAAO;AACL,aAAS,UAAU;AAAA,EACrB;AAEA,OAAK,WAAW,CAAC;AACjB,OAAK,OAAO,kBAAkB,IAAI;AAAA,IAChC,SAAS,8BAA4B;AAAA,EACvC;AACF;",
6
+ "names": ["ConnectionState"]
7
+ }
package/README.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  [![Latest Stable Version](https://img.shields.io/npm/v/@vaadin/common-frontend.svg)](https://www.npmjs.com/package/@vaadin/common-frontend)
4
4
 
5
- A set of utilities used by Vaadin [Flow](https://vaadin.com/docs/latest/flow/overview) and [Fusion](https://vaadin.com/docs/latest/fusion/overview) frameworks.
5
+ A set of utilities used by Vaadin [Flow](https://vaadin.com/docs/latest/flow/what-is-flow) and [Hilla](https://vaadin.com/docs/latest/hilla/faq) frameworks.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  **NOTE**: This package is internal.
10
- If you want to use Flow or Fusion frameworks in your project, visit https://start.vaadin.com.
10
+ If you want to use Flow or Hilla frameworks in your project, visit https://start.vaadin.com.
11
11
 
12
12
  ```bash
13
13
  $ npm install @vaadin/common-frontend
package/index.js CHANGED
@@ -1,10 +1,11 @@
1
- export * from './ConnectionState.js';
2
- export * from './ConnectionIndicator.js';
3
- const $wnd = window;
4
- $wnd.Vaadin = $wnd.Vaadin || {};
5
- $wnd.Vaadin.registrations = $wnd.Vaadin.registrations || [];
6
- $wnd.Vaadin.registrations.push({
7
- is: '@vaadin/common-frontend',
8
- version: /* updated-by-script */ '0.0.18',
9
- });
10
- //# sourceMappingURL=index.js.map
1
+ function __REGISTER__(feature, vaadinObj = window.Vaadin ??= {}) {
2
+ vaadinObj.registrations ??= [];
3
+ vaadinObj.registrations.push({
4
+ is: feature ? `${"@vaadin/common-frontend"}/${feature}` : "@vaadin/common-frontend",
5
+ version: "0.0.19"
6
+ });
7
+ }
8
+ export * from "./ConnectionState.js";
9
+ export * from "./ConnectionIndicator.js";
10
+ __REGISTER__();
11
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AAEzC,MAAM,IAAI,GAAG,MAAa,CAAC;AAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;AAChC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;AAC5D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;IAC7B,EAAE,EAAE,yBAAyB;IAC7B,OAAO,EAAE,uBAAuB,CAAC,QAAQ;CAC1C,CAAC,CAAC","sourcesContent":["export * from './ConnectionState.js';\nexport * from './ConnectionIndicator.js';\n\nconst $wnd = window as any;\n$wnd.Vaadin = $wnd.Vaadin || {};\n$wnd.Vaadin.registrations = $wnd.Vaadin.registrations || [];\n$wnd.Vaadin.registrations.push({\n is: '@vaadin/common-frontend',\n version: /* updated-by-script */ '0.0.18',\n});\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../scripts/register.js", "src/index.ts"],
4
+ "sourcesContent": ["export function __REGISTER__(feature, vaadinObj = (window.Vaadin ??= {})) {\n vaadinObj.registrations ??= [];\n vaadinObj.registrations.push({\n is: feature ? `${__NAME__}/${feature}` : __NAME__,\n version: __VERSION__,\n });\n}\n", "export * from './ConnectionState.js';\nexport * from './ConnectionIndicator.js';\n\n// @ts-expect-error: esbuild injection\n// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n__REGISTER__();\n"],
5
+ "mappings": "AAAO,SAAS,aAAa,SAAS,YAAa,OAAO,WAAW,CAAC,GAAI;AACxE,YAAU,kBAAkB,CAAC;AAC7B,YAAU,cAAc,KAAK;AAAA,IAC3B,IAAI,UAAU,GAAG,yBAAQ,IAAI,OAAO,KAAK;AAAA,IACzC,SAAS;AAAA,EACX,CAAC;AACH;ACNA,cAAc;AACd,cAAc;AAId,aAAa;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/common-frontend",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Vaadin frontend utils used by Flow and Hilla",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -8,18 +8,22 @@
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/vaadin/flow-hilla-common.git",
11
- "directory": "frontend/packages/common-frontend"
11
+ "directory": "packages/ts/common-frontend"
12
12
  },
13
13
  "keywords": [
14
14
  "Vaadin",
15
15
  "Hilla"
16
16
  ],
17
17
  "scripts": {
18
- "build": "tsc --isolatedModules",
19
- "lint": "eslint --fix src/**/*.ts",
20
- "test": "web-test-runner \"test/**/*.test.ts\" --config ../../web-test-runner.config.js",
21
- "test:coverage": "npm run test -- --coverage",
22
- "test:watch": "npm run test -- --watch",
18
+ "clean:build": "git clean -fx -e .vite -e node_modules",
19
+ "build": "concurrently npm:build:*",
20
+ "build:esbuild": "tsx ../../../scripts/build.ts",
21
+ "build:dts": "tsc --isolatedModules -p tsconfig.build.json",
22
+ "lint": "eslint src test",
23
+ "lint:fix": "eslint src test --fix",
24
+ "test": "vitest --run",
25
+ "test:watch": "vitest --inspect --no-file-parallelism",
26
+ "test:coverage": "npm test -- --coverage",
23
27
  "typecheck": "tsc --noEmit"
24
28
  },
25
29
  "exports": {
@@ -48,20 +52,22 @@
48
52
  "publishConfig": {
49
53
  "access": "public"
50
54
  },
51
- "dependencies": {
52
- "tslib": "^2.3.1"
53
- },
54
55
  "peerDependencies": {
55
- "lit": "^2.0.0"
56
+ "lit": "^3.0.0"
56
57
  },
57
58
  "devDependencies": {
58
- "@open-wc/testing": "^2.5.33",
59
59
  "@types/chai": "^4.2.21",
60
- "@types/mocha": "^9.0.0",
61
- "@types/sinon": "^10.0.2",
62
- "@types/sinon-chai": "^3.2.5",
63
- "@web/test-runner": "^0.13.16",
64
- "sinon": "^11.1.2"
60
+ "@types/sinon": "^17.0.2",
61
+ "@types/sinon-chai": "^3.2.12",
62
+ "@vitest/browser": "^3.0.2",
63
+ "@vitest/coverage-v8": "^3.0.2",
64
+ "@vitest/ui": "^3.0.2",
65
+ "playwright-core": "^1.49.1",
66
+ "sinon": "^17.0.1",
67
+ "sinon-chai": "^4.0.0",
68
+ "vitest": "^3.0.2"
65
69
  },
66
- "gitHead": "8e2a447f2793a6f786fac572a50a11e41197a23a"
70
+ "dependencies": {
71
+ "type-fest": "^4.32.0"
72
+ }
67
73
  }