@vaadin/common-frontend 0.0.19 → 0.0.21

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 +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,EAA6B,MAAM,sBAAsB,CAAC;AAElF,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;IACjD;;;OAGG;IACH,MAAM,CAAC,MAAM;;QACX,MAAM,IAAI,GAAG,MAAa,CAAC;QAC3B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,mBAAmB,CAAA,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,KAAX,IAAI,CAAC,MAAM,GAAK,EAAE,EAAC;YACnB,IAAI,CAAC,MAAM,CAAC,mBAAmB,GAAG,QAAQ,CAAC,aAAa,CAAC,6BAA6B,CAAC,CAAC;YACxF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,mBAA0C,CAAC;IACjE,CAAC;IA4ED;QACE,KAAK,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,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAGhB;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,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,CAAC;IACpE,cAAc,CAAC,MAAM,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC;AAC5E,CAAC;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, 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\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 ||= {};\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 protected 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 * @returns 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 pointer-events: none;\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 pointer-events: auto;\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 pointer-events: auto;\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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,uBAAN,MAAM,8BAA4B,iBAsBvC,mBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAM1B,oBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAM1B,mBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAO1B,yBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAM1B,mBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAM1B,oBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAM1B,yBAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAG1B,gBAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC,IAG1C,qBAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC,IAG1C,iBAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC,IAG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AM,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
  /**
@@ -26,21 +26,17 @@ export declare enum ConnectionState {
26
26
  }
27
27
  export type ConnectionStateChangeListener = (previous: ConnectionState, current: ConnectionState) => void;
28
28
  export declare class ConnectionStateStore {
29
- private connectionState;
30
- private readonly 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;IAEvB;;;OAGG;IACH,OAAO,YAAY;IAEnB;;;;;;OAMG;IACH,YAAY,iBAAiB;IAE7B;;;;OAIG;IACH,eAAe,oBAAoB;CACpC;AAED,MAAM,MAAM,6BAA6B,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;AAE1G,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,eAAe,CAAkB;IAEzC,OAAO,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,OAAO,CAEpB;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;CAcF;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUrD"}
@@ -1,132 +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
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
36
- if (navigator.serviceWorker) {
37
- // Query service worker if the most recent fetch was served from cache
38
- // Add message listener for handling response
39
- // eslint-disable-next-line @typescript-eslint/unbound-method
40
- navigator.serviceWorker.addEventListener('message', this.serviceWorkerMessageListener);
41
- // Send JSON-RPC request to Vaadin service worker
42
- // eslint-disable-next-line no-void
43
- void navigator.serviceWorker.ready.then((registration) => {
44
- var _a;
45
- (_a = registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
46
- method: 'Vaadin.ServiceWorker.isConnectionLost',
47
- id: 'Vaadin.ServiceWorker.isConnectionLost',
48
- });
49
- });
50
- }
51
- }
52
- addStateChangeListener(listener) {
53
- this.stateChangeListeners.add(listener);
54
- }
55
- removeStateChangeListener(listener) {
56
- this.stateChangeListeners.delete(listener);
57
- }
58
- loadingStarted() {
59
- this.state = ConnectionState.LOADING;
60
- this.loadingCount += 1;
61
- }
62
- loadingFinished() {
63
- this.decreaseLoadingCount(ConnectionState.CONNECTED);
64
- }
65
- loadingFailed() {
66
- this.decreaseLoadingCount(ConnectionState.CONNECTION_LOST);
67
- }
68
- decreaseLoadingCount(finalState) {
69
- if (this.loadingCount > 0) {
70
- this.loadingCount -= 1;
71
- if (this.loadingCount === 0) {
72
- this.state = finalState;
73
- }
74
- }
75
- }
76
- get state() {
77
- return this.connectionState;
78
- }
79
- set state(newState) {
80
- if (newState !== this.connectionState) {
81
- const prevState = this.connectionState;
82
- this.connectionState = newState;
83
- this.loadingCount = 0;
84
- for (const listener of this.stateChangeListeners) {
85
- listener(prevState, this.connectionState);
86
- }
87
- }
88
- }
89
- get online() {
90
- return this.connectionState === ConnectionState.CONNECTED || this.connectionState === ConnectionState.LOADING;
91
- }
92
- get offline() {
93
- return !this.online;
94
- }
95
- serviceWorkerMessageListener(event) {
96
- // Handle JSON-RPC response from service worker
97
- if (typeof event.data === 'object' && event.data.id === 'Vaadin.ServiceWorker.isConnectionLost') {
98
- if (event.data.result === true) {
99
- this.state = ConnectionState.CONNECTION_LOST;
100
- }
101
- // Cleanup: remove event listener upon receiving response
102
- // eslint-disable-next-line @typescript-eslint/unbound-method
103
- navigator.serviceWorker.removeEventListener('message', this.serviceWorkerMessageListener);
104
- }
105
- }
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);
106
84
  }
107
- export const isLocalhost = (hostname) => {
108
- if (hostname === 'localhost') {
109
- return true;
110
- }
111
- if (hostname === '[::1]') {
112
- return true;
113
- }
114
- if (/^127\.\d+\.\d+\.\d+$/u.exec(hostname)) {
115
- return true;
116
- }
117
- return false;
118
- };
119
85
  const $wnd = window;
120
- if (!((_a = $wnd.Vaadin) === null || _a === void 0 ? void 0 : _a.connectionState)) {
121
- let online;
122
- if (isLocalhost(window.location.hostname)) {
123
- // 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
124
- online = true;
125
- }
126
- else {
127
- online = navigator.onLine;
128
- }
129
- $wnd.Vaadin || ($wnd.Vaadin = {});
130
- $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
+ );
131
97
  }
132
- //# 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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eAAe,CAAC,eAAe,CACrE,CAAC;AACJ,CAAC","sourcesContent":["export 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 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 readonly stateChangeListeners = new Set<ConnectionStateChangeListener>();\n\n private loadingCount = 0;\n\n constructor(initialState: ConnectionState) {\n this.connectionState = initialState;\n\n this.serviceWorkerMessageListener = this.serviceWorkerMessageListener.bind(this);\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 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 // eslint-disable-next-line @typescript-eslint/unbound-method\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 (/^127\\.\\d+\\.\\d+\\.\\d+$/u.exec(hostname)) {\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 ||= {};\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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BAA4B;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,12 +1,11 @@
1
- var _a;
2
- export * from './ConnectionState.js';
3
- export * from './ConnectionIndicator.js';
4
- const $wnd = window;
5
- $wnd.Vaadin || ($wnd.Vaadin = {});
6
- (_a = $wnd.Vaadin).registrations || (_a.registrations = []);
7
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
8
- $wnd.Vaadin.registrations.push({
9
- is: '@vaadin/common-frontend',
10
- version: /* updated-by-script */ '0.0.18',
11
- });
12
- //# 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.20"
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,KAAX,IAAI,CAAC,MAAM,GAAK,EAAE,EAAC;AACnB,MAAA,IAAI,CAAC,MAAM,EAAC,aAAa,QAAb,aAAa,GAAK,EAAE,EAAC;AACjC,6DAA6D;AAC7D,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 ||= {};\n$wnd.Vaadin.registrations ||= [];\n// eslint-disable-next-line @typescript-eslint/no-unsafe-call\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.19",
3
+ "version": "0.0.21",
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,22 +52,22 @@
48
52
  "publishConfig": {
49
53
  "access": "public"
50
54
  },
51
- "dependencies": {
52
- "tslib": "^2.3.1"
53
- },
54
55
  "peerDependencies": {
55
56
  "lit": "^3.0.0"
56
57
  },
57
58
  "devDependencies": {
58
- "@esm-bundle/chai": "^4.3.4-fix.0",
59
- "@open-wc/testing": "^4.0.0",
60
- "@types/chai": "^4.2.21",
61
- "@types/mocha": "^10.0.3",
62
- "@types/sinon": "^17.0.2",
63
- "@types/sinon-chai": "^3.2.5",
64
- "@web/test-runner": "^0.18.0",
65
- "mocha": "^10.2.0",
66
- "sinon": "^17.0.1"
59
+ "@types/chai": "4.3.20",
60
+ "@types/sinon": "21.0.0",
61
+ "@types/sinon-chai": "4.0.0",
62
+ "@vitest/browser": "4.0.18",
63
+ "@vitest/browser-playwright": "4.0.18",
64
+ "@vitest/coverage-v8": "4.0.18",
65
+ "@vitest/ui": "4.0.18",
66
+ "playwright-core": "1.58.2",
67
+ "sinon": "21.0.1",
68
+ "sinon-chai": "4.0.1",
69
+ "type-fest": "5.4.4",
70
+ "vitest": "4.0.18"
67
71
  },
68
- "gitHead": "8b61950646b8955ea20e7bbbd0c6c59f4aedcfd7"
72
+ "dependencies": {}
69
73
  }