From b26031228ac36247406d2ca0cf92ccf70441fe57 Mon Sep 17 00:00:00 2001 From: Stephanie Yu Date: Thu, 21 Nov 2024 14:38:29 -0500 Subject: [PATCH] CR --- packages/widget.client.unstable/src/host.test.ts | 6 +++--- packages/widget.client.unstable/src/host.ts | 10 +++++----- packages/widget.client.unstable/src/request.ts | 15 +++------------ 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/packages/widget.client.unstable/src/host.test.ts b/packages/widget.client.unstable/src/host.test.ts index 94d002593..3174f6db5 100644 --- a/packages/widget.client.unstable/src/host.test.ts +++ b/packages/widget.client.unstable/src/host.test.ts @@ -43,7 +43,7 @@ describe("FoundryHostEventTarget", () => { events: { myEvent: { displayName: "My Event", - parameterIds: ["test"], + parameterUpdateIds: ["test"], }, }, }); @@ -87,7 +87,7 @@ describe("FoundryHostEventTarget", () => { events: { myEvent: { displayName: "My Event", - parameterIds: ["test"], + parameterUpdateIds: ["test"], }, }, }); @@ -117,7 +117,7 @@ describe("FoundryHostEventTarget", () => { events: { myEvent: { displayName: "My Event", - parameterIds: ["test"], + parameterUpdateIds: ["test"], }, }, }); diff --git a/packages/widget.client.unstable/src/host.ts b/packages/widget.client.unstable/src/host.ts index 2fa8ca98f..5bb1837c0 100644 --- a/packages/widget.client.unstable/src/host.ts +++ b/packages/widget.client.unstable/src/host.ts @@ -31,10 +31,10 @@ export class FoundryHostEventTarget< type: T, callback: | HostMessageEventListener< - Extract, { type: T }>["payload"] + (HostMessage & { type: T })["payload"] > | HostMessageEventListenerObject< - Extract, { type: T }>["payload"] + (HostMessage & { type: T })["payload"] > | null, options?: AddEventListenerOptions | boolean, @@ -46,10 +46,10 @@ export class FoundryHostEventTarget< type: T, callback: | HostMessageEventListener< - Extract, { type: T }>["payload"] + (HostMessage & { type: T })["payload"] > | HostMessageEventListenerObject< - Extract, { type: T }>["payload"] + (HostMessage & { type: T })["payload"] > | null, options?: EventListenerOptions | boolean, @@ -59,7 +59,7 @@ export class FoundryHostEventTarget< public dispatchEventMessage["type"]>( type: T, - payload: Extract, { type: T }>["payload"], + payload: (HostMessage & { type: T })["payload"], ) { this.dispatchEvent( new CustomEvent(type, { diff --git a/packages/widget.client.unstable/src/request.ts b/packages/widget.client.unstable/src/request.ts index 1e3459401..02e15b808 100644 --- a/packages/widget.client.unstable/src/request.ts +++ b/packages/widget.client.unstable/src/request.ts @@ -32,22 +32,13 @@ export function serializeRequest( id, url: input, method: init?.method ?? "GET", - headers: serializeHeaders(init?.headers), + headers: Object.fromEntries([ + ...new Headers(init?.headers ?? {}).entries(), + ]), body: body as any, }; } -function serializeHeaders(headers: HeadersInit | undefined) { - if (headers === undefined || !(headers instanceof Headers)) { - throw new Error("Header object not found"); - } - const serialized: Record = {}; - for (const key of headers.keys()) { - serialized[key] = headers.get(key)!; - } - return serialized; -} - export function deserializeResponse( response: HostMessage.Payload._unstable_FetchResponseSuccess, ): Response {