From ab2f5e6ab494e1938f098cea5df2576595b34d01 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 19 Oct 2023 16:57:41 +0200 Subject: [PATCH 1/2] Chore: Moved UserInfo from foundation.ts to compas/foundation.ts, since it's compas specific --- src/compas/CompasUserInfo.ts | 2 +- src/compas/foundation.ts | 22 ++++++++++++++++++++++ src/foundation.ts | 18 ------------------ test/integration/compas/foundation.test.ts | 6 ++++-- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/compas/CompasUserInfo.ts b/src/compas/CompasUserInfo.ts index e8c953efaa..4a82b8f458 100644 --- a/src/compas/CompasUserInfo.ts +++ b/src/compas/CompasUserInfo.ts @@ -1,4 +1,4 @@ -import { newUserInfoEvent } from '../foundation.js'; +import { newUserInfoEvent } from './foundation.js'; import { CompasUserInfoService } from '../compas-services/CompasUserInfoService.js'; import { createLogEvent } from '../compas-services/foundation.js'; diff --git a/src/compas/foundation.ts b/src/compas/foundation.ts index f1d2f35718..0b55620ae2 100644 --- a/src/compas/foundation.ts +++ b/src/compas/foundation.ts @@ -106,3 +106,25 @@ export function compareVersions( } return result; } + +/** Represents user information from a backend. */ +export interface UserInfoDetail { + name: string; +} +export type UserInfoEvent = CustomEvent; +export function newUserInfoEvent( + name: string, + eventInitDict?: CustomEventInit> +): UserInfoEvent { + return new CustomEvent('userinfo', { + bubbles: true, + composed: true, + ...eventInitDict, + detail: { name, ...eventInitDict?.detail }, + }); +} +declare global { + interface ElementEventMap { + ['userinfo']: UserInfoEvent; + } +} diff --git a/src/foundation.ts b/src/foundation.ts index fa63bed471..4d2dbbedfd 100644 --- a/src/foundation.ts +++ b/src/foundation.ts @@ -479,23 +479,6 @@ export function newOpenDocEvent( }); } -/** Represents user information from a backend. */ -export interface UserInfoDetail { - name: string; -} -export type UserInfoEvent = CustomEvent; -export function newUserInfoEvent( - name: string, - eventInitDict?: CustomEventInit> -): UserInfoEvent { - return new CustomEvent('userinfo', { - bubbles: true, - composed: true, - ...eventInitDict, - detail: { name, ...eventInitDict?.detail }, - }); -} - /** @returns a reference to `element` with segments delimited by '/'. */ // TODO(c-dinkel): replace with identity (FIXME) export function referencePath(element: Element): string { @@ -2880,7 +2863,6 @@ declare global { ['pending-state']: PendingStateEvent; ['editor-action']: EditorActionEvent; ['open-doc']: OpenDocEvent; - ['userinfo']: UserInfoEvent; ['wizard']: WizardEvent; ['validate']: ValidateEvent; ['log']: LogEvent; diff --git a/test/integration/compas/foundation.test.ts b/test/integration/compas/foundation.test.ts index b1bc1cf979..a054a58cf0 100644 --- a/test/integration/compas/foundation.test.ts +++ b/test/integration/compas/foundation.test.ts @@ -1,10 +1,12 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { updateDocumentInOpenSCD } from '../../../src/compas/foundation.js'; +import { + updateDocumentInOpenSCD, + newUserInfoEvent, +} from '../../../src/compas/foundation.js'; import { OpenSCD } from '../../../src/open-scd.js'; import '../../../src/open-scd.js'; -import { newUserInfoEvent } from '../../../src/foundation.js'; describe('compas-foundation', () => { let element: OpenSCD; From 656dafdcc3295d7fe0dc0f830f91a270e1b49111 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 19 Oct 2023 17:11:38 +0200 Subject: [PATCH 2/2] Updated import in Hosting Mixin --- src/Hosting.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Hosting.ts b/src/Hosting.ts index 6bf19bb743..6a21f97b65 100644 --- a/src/Hosting.ts +++ b/src/Hosting.ts @@ -15,7 +15,8 @@ import { Drawer } from '@material/mwc-drawer'; import { ActionDetail, List } from '@material/mwc-list'; import { ListItem } from '@material/mwc-list/mwc-list-item'; -import { Mixin, newPendingStateEvent, UserInfoEvent } from './foundation.js'; +import { Mixin, newPendingStateEvent } from './foundation.js'; +import { UserInfoEvent } from './compas/foundation.js'; import { LoggingElement } from './Logging.js'; import { PluggingElement, Plugin, pluginIcons } from './Plugging.js'; import { SettingElement } from './Setting.js';