diff --git a/packages/ts/frontend/src/Connect.ts b/packages/ts/frontend/src/Connect.ts index 4b1ae3b282..7369ec04b8 100644 --- a/packages/ts/frontend/src/Connect.ts +++ b/packages/ts/frontend/src/Connect.ts @@ -16,7 +16,7 @@ import { } from './FluxConnection.js'; import type { VaadinWindow } from './types.js'; -const $wnd = window as VaadinWindow; +const $wnd = self as VaadinWindow; $wnd.Vaadin ??= {}; $wnd.Vaadin.registrations ??= []; @@ -300,7 +300,8 @@ export class ConnectClient { throw new TypeError(`2 arguments required, but got only ${arguments.length}`); } - const csrfHeaders = getCsrfTokenHeadersForEndpointRequest(document); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + const csrfHeaders = self.document ? getCsrfTokenHeadersForEndpointRequest(self.document) : {}; const headers: Record = { Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/packages/ts/frontend/src/CookieManager.ts b/packages/ts/frontend/src/CookieManager.ts index de4e11cb53..90999e6b69 100644 --- a/packages/ts/frontend/src/CookieManager.ts +++ b/packages/ts/frontend/src/CookieManager.ts @@ -5,7 +5,8 @@ export function calculatePath({ pathname }: URL): string { } const CookieManager: Cookies.CookiesStatic = Cookies.withAttributes({ - path: calculatePath(new URL(document.baseURI)), + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + path: calculatePath(new URL(self.document?.baseURI ?? '/')), }); export default CookieManager; diff --git a/packages/ts/frontend/src/FluxConnection.ts b/packages/ts/frontend/src/FluxConnection.ts index 4fef3a3019..562f5594a0 100644 --- a/packages/ts/frontend/src/FluxConnection.ts +++ b/packages/ts/frontend/src/FluxConnection.ts @@ -182,7 +182,8 @@ export class FluxConnection extends EventTarget { } #connectWebsocket(prefix: string, atmosphereOptions: Partial) { - const extraHeaders = getCsrfTokenHeadersForEndpointRequest(document); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + const extraHeaders = self.document ? getCsrfTokenHeadersForEndpointRequest(self.document) : {}; const pushUrl = 'HILLA/push'; const url = prefix.length === 0 ? pushUrl : (prefix.endsWith('/') ? prefix : `${prefix}/`) + pushUrl; this.#socket = atmosphere.subscribe?.({ diff --git a/packages/ts/react-i18n/src/index.ts b/packages/ts/react-i18n/src/index.ts index 5ef8f73227..a46f7e12e0 100644 --- a/packages/ts/react-i18n/src/index.ts +++ b/packages/ts/react-i18n/src/index.ts @@ -31,7 +31,7 @@ export class I18n { constructor() { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (!(window as any).Vaadin?.featureFlags?.hillaI18n) { + if (!(self as any).Vaadin?.featureFlags?.hillaI18n) { // Remove when removing feature flag throw new Error( `The Hilla I18n API is currently considered experimental and may change in the future. To use it you need to explicitly enable it in Copilot or by adding com.vaadin.experimental.hillaI18n=true to vaadin-featureflags.properties`, diff --git a/packages/ts/react-signals/src/FullStackSignal.ts b/packages/ts/react-signals/src/FullStackSignal.ts index 1b96087c8d..58926c971d 100644 --- a/packages/ts/react-signals/src/FullStackSignal.ts +++ b/packages/ts/react-signals/src/FullStackSignal.ts @@ -28,7 +28,7 @@ export abstract class DependencyTrackingSignal extends Signal { protected constructor(value: T | undefined, onFirstSubscribe: () => void, onLastUnsubscribe: () => void) { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (!(window as any).Vaadin?.featureFlags?.fullstackSignals) { + if (!(self as any).Vaadin?.featureFlags?.fullstackSignals) { // Remove when removing feature flag throw new Error( `The Hilla Fullstack Signals API is currently considered experimental and may change in the future. To use it you need to explicitly enable it in Copilot or by adding com.vaadin.experimental.fullstackSignals=true to vaadin-featureflags.properties`,