From b47fa96e58f9763b69190993d58295fd64d3f0fa Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Thu, 29 Aug 2024 20:45:35 +0100 Subject: [PATCH 1/2] Fixed window race condition issue --- .../packages/client/package.json | 8 +++---- .../packages/client/src/index.ts | 18 ++++++++-------- .../client/src/ui/AbstractUIComponent.ts | 13 ++++++------ .../packages/da-proxy/package.json | 6 +++--- .../src/channels/DefaultChannelSupport.ts | 21 +------------------ .../src/intents/DefaultIntentSupport.ts | 10 +++------ .../src/messaging/AbstractMessaging.ts | 13 +++--------- .../packages/da-server/package.json | 6 +++--- .../packages/demo/package.json | 8 +++---- .../packages/fdc3-common/package.json | 2 +- .../packages/testing/package.json | 4 ++-- 11 files changed, 39 insertions(+), 70 deletions(-) diff --git a/fdc3-for-web-implementation/packages/client/package.json b/fdc3-for-web-implementation/packages/client/package.json index bd69e467f..b62d988dd 100644 --- a/fdc3-for-web-implementation/packages/client/package.json +++ b/fdc3-for-web-implementation/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@kite9/client", - "version": "0.0.54", + "version": "0.0.56", "files": [ "dist" ], @@ -13,14 +13,14 @@ }, "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/da-proxy": "0.0.54", - "@kite9/fdc3-common": "0.0.54", + "@kite9/da-proxy": "0.0.56", + "@kite9/fdc3-common": "0.0.56", "@types/uuid": "^10.0.0", "uuid": "^9.0.1" }, "devDependencies": { "@cucumber/cucumber": "10.3.1", - "@kite9/da-server": "0.0.54", + "@kite9/da-server": "0.0.56", "@types/node": "^20.14.11", "@types/wtfnode": "^0.7.3", "expect": "^29.7.0", diff --git a/fdc3-for-web-implementation/packages/client/src/index.ts b/fdc3-for-web-implementation/packages/client/src/index.ts index 28581f49a..c2d9acaa6 100644 --- a/fdc3-for-web-implementation/packages/client/src/index.ts +++ b/fdc3-for-web-implementation/packages/client/src/index.ts @@ -70,15 +70,15 @@ export const getAgent: getAgentType = (optionsOverride?: GetAgentParams) => { /** * Replaces the original fdc3Ready function from FDC3 2.0 with a new one that uses the new getClientAPI function. - * + * * @param waitForMs Amount of time to wait before failing the promise (20 seconds is the default). * @returns A DesktopAgent promise. */ -// export function fdc3Ready(waitForMs = DEFAULT_WAIT_FOR_MS): Promise { -// return getAgent({ -// timeout: waitForMs, -// dontSetWindowFdc3: false, -// channelSelector: true, -// intentResolver: true -// }) -// } \ No newline at end of file +export function fdc3Ready(waitForMs = DEFAULT_WAIT_FOR_MS): Promise { + return getAgent({ + timeout: waitForMs, + dontSetWindowFdc3: false, + channelSelector: true, + intentResolver: true + }) +} \ No newline at end of file diff --git a/fdc3-for-web-implementation/packages/client/src/ui/AbstractUIComponent.ts b/fdc3-for-web-implementation/packages/client/src/ui/AbstractUIComponent.ts index 9e58ae84e..1a2686a93 100644 --- a/fdc3-for-web-implementation/packages/client/src/ui/AbstractUIComponent.ts +++ b/fdc3-for-web-implementation/packages/client/src/ui/AbstractUIComponent.ts @@ -29,7 +29,7 @@ export const ALLOWED_CSS_ELEMENTS = [ export abstract class AbstractUIComponent implements Connectable { private container: HTMLDivElement | undefined = undefined - private iframe: Window | undefined = undefined + private iframe: HTMLIFrameElement | undefined = undefined private url: string private name: string port: MessagePort | null = null @@ -75,7 +75,7 @@ export abstract class AbstractUIComponent implements Connectable { return new Promise((resolve, _reject) => { const ml = (e: MessageEvent) => { console.log("Received UI Message: " + JSON.stringify(e.data)) - if ((e.source == this.iframe) && (e.data.type == 'iframeHello')) { + if ((e.source == this.iframe?.contentWindow) && (e.data.type == 'iframeHello')) { const port = e.ports[0] port.start() globalThis.window.removeEventListener("message", ml) @@ -90,14 +90,13 @@ export abstract class AbstractUIComponent implements Connectable { private openFrame(): void { this.container = globalThis.document.createElement("div") - const ifrm = globalThis.document.createElement("iframe") + this.iframe = globalThis.document.createElement("iframe") this.themeContainer(INITIAL_CONTAINER_CSS) - this.themeFrame(ifrm) - this.iframe = ifrm.contentWindow!! + this.themeFrame(this.iframe) - ifrm.setAttribute("src", this.url) - this.container.appendChild(ifrm) + this.iframe.setAttribute("src", this.url) + this.container.appendChild(this.iframe) document.body.appendChild(this.container) } diff --git a/fdc3-for-web-implementation/packages/da-proxy/package.json b/fdc3-for-web-implementation/packages/da-proxy/package.json index 3c74f8446..470aff76d 100644 --- a/fdc3-for-web-implementation/packages/da-proxy/package.json +++ b/fdc3-for-web-implementation/packages/da-proxy/package.json @@ -1,6 +1,6 @@ { "name": "@kite9/da-proxy", - "version": "0.0.54", + "version": "0.0.56", "files": [ "dist" ], @@ -13,7 +13,7 @@ }, "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/fdc3-common": "0.0.54" + "@kite9/fdc3-common": "0.0.56" }, "devDependencies": { "@cucumber/cucumber": "10.3.1", @@ -34,7 +34,7 @@ "is-ci": "2.0.0", "jsonpath-plus": "^9.0.0", "nyc": "15.1.0", - "@kite9/testing": "0.0.54", + "@kite9/testing": "0.0.56", "prettier": "2.2.1", "rimraf": "^6.0.1", "ts-node": "^10.9.2", diff --git a/fdc3-for-web-implementation/packages/da-proxy/src/channels/DefaultChannelSupport.ts b/fdc3-for-web-implementation/packages/da-proxy/src/channels/DefaultChannelSupport.ts index c0b6dbccd..1aca34af9 100644 --- a/fdc3-for-web-implementation/packages/da-proxy/src/channels/DefaultChannelSupport.ts +++ b/fdc3-for-web-implementation/packages/da-proxy/src/channels/DefaultChannelSupport.ts @@ -16,25 +16,6 @@ import { } from "@kite9/fdc3-common"; import { FollowingContextListener } from "../listeners/FollowingContextListener"; -const NO_OP_CHANNEL_SELECTOR: ChannelSelector = { - - updateChannel(_channelId: string | null): void { - // does nothing - }, - - setChannelChangeCallback(_callback: (channelId: string) => void): void { - // also does nothing - }, - - connect: function (): Promise { - return Promise.resolve() - }, - - disconnect: function (): Promise { - return Promise.resolve() - } - -} export class DefaultChannelSupport implements ChannelSupport { @@ -43,7 +24,7 @@ export class DefaultChannelSupport implements ChannelSupport { protected userChannels: Channel[] | null = null private followingListeners: FollowingContextListener[] = [] - constructor(messaging: Messaging, channelSelector: ChannelSelector = NO_OP_CHANNEL_SELECTOR) { + constructor(messaging: Messaging, channelSelector: ChannelSelector) { this.messaging = messaging; this.channelSelector = channelSelector this.channelSelector.setChannelChangeCallback((channelId: string) => { diff --git a/fdc3-for-web-implementation/packages/da-proxy/src/intents/DefaultIntentSupport.ts b/fdc3-for-web-implementation/packages/da-proxy/src/intents/DefaultIntentSupport.ts index 151ac4528..77d901703 100644 --- a/fdc3-for-web-implementation/packages/da-proxy/src/intents/DefaultIntentSupport.ts +++ b/fdc3-for-web-implementation/packages/da-proxy/src/intents/DefaultIntentSupport.ts @@ -86,13 +86,9 @@ export class DefaultIntentSupport implements IntentSupport { (m.type == 'raiseIntentResultResponse') && (m.meta.requestUuid == messageOut.meta.requestUuid))) - if (!rp) { - // probably a timeout - return; - } else { - const ir = await convertIntentResult(rp, this.messaging) - return ir - } + + const ir = await convertIntentResult(rp, this.messaging) + return ir } async raiseIntent(intent: string, context: Context, app: AppIdentifier): Promise { diff --git a/fdc3-for-web-implementation/packages/da-proxy/src/messaging/AbstractMessaging.ts b/fdc3-for-web-implementation/packages/da-proxy/src/messaging/AbstractMessaging.ts index 2c27089b7..e04912879 100644 --- a/fdc3-for-web-implementation/packages/da-proxy/src/messaging/AbstractMessaging.ts +++ b/fdc3-for-web-implementation/packages/da-proxy/src/messaging/AbstractMessaging.ts @@ -26,11 +26,7 @@ export abstract class AbstractMessaging implements Messaging { } getSource(): AppIdentifier { - if (this.appId == null) { - throw new Error("AppId not set") - } else { - return this.appId; - } + return this.appId!! } waitFor(filter: (m: any) => boolean, timeoutErrorMessage?: string): Promise { @@ -44,8 +40,7 @@ export abstract class AbstractMessaging implements Messaging { done = true this.unregister(id) resolve(m) - }, - register: () => Promise.resolve() + } } as RegisterableListener @@ -104,9 +99,7 @@ export abstract class AbstractMessaging implements Messaging { } getImplementationMetadata(): Promise { - return this.implementationMetadata == null ? - Promise.reject("Not connected") : - Promise.resolve(this.implementationMetadata) + return Promise.resolve(this.implementationMetadata!!) } private async exchangeValidationWithId(message: any, connectionAttemptUuid: string): Promise { diff --git a/fdc3-for-web-implementation/packages/da-server/package.json b/fdc3-for-web-implementation/packages/da-server/package.json index 9a80ab5e3..a2a0a40b7 100644 --- a/fdc3-for-web-implementation/packages/da-server/package.json +++ b/fdc3-for-web-implementation/packages/da-server/package.json @@ -1,6 +1,6 @@ { "name": "@kite9/da-server", - "version": "0.0.54", + "version": "0.0.56", "files": [ "dist" ], @@ -21,8 +21,8 @@ "@cucumber/cucumber": "10.3.1", "@cucumber/html-formatter": "11.0.4", "@cucumber/pretty-formatter": "1.0.1", - "@kite9/fdc3-common": "0.0.54", - "@kite9/testing": "0.0.54", + "@kite9/fdc3-common": "0.0.56", + "@kite9/testing": "0.0.56", "@types/expect": "24.3.0", "@types/lodash": "4.14.167", "@types/node": "^20.14.11", diff --git a/fdc3-for-web-implementation/packages/demo/package.json b/fdc3-for-web-implementation/packages/demo/package.json index a65cfa5e9..9d6ed2924 100644 --- a/fdc3-for-web-implementation/packages/demo/package.json +++ b/fdc3-for-web-implementation/packages/demo/package.json @@ -1,7 +1,7 @@ { "name": "@kite9/demo", "private": true, - "version": "0.0.54", + "version": "0.0.56", "scripts": { "dev": "nodemon -w src/server src/server/main.ts" }, @@ -14,9 +14,9 @@ }, "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/client": "0.0.54", - "@kite9/da-server": "0.0.54", - "@kite9/fdc3-common": "0.0.54", + "@kite9/client": "0.0.56", + "@kite9/da-server": "0.0.56", + "@kite9/fdc3-common": "0.0.56", "@types/uuid": "^10.0.0", "@types/ws": "^8.5.10", "express": "^4.18.3", diff --git a/fdc3-for-web-implementation/packages/fdc3-common/package.json b/fdc3-for-web-implementation/packages/fdc3-common/package.json index ab9a6aa8d..80e62edb7 100644 --- a/fdc3-for-web-implementation/packages/fdc3-common/package.json +++ b/fdc3-for-web-implementation/packages/fdc3-common/package.json @@ -1,6 +1,6 @@ { "name": "@kite9/fdc3-common", - "version": "0.0.54", + "version": "0.0.56", "files": [ "dist" ], diff --git a/fdc3-for-web-implementation/packages/testing/package.json b/fdc3-for-web-implementation/packages/testing/package.json index a1e928d4d..1efbe72ce 100644 --- a/fdc3-for-web-implementation/packages/testing/package.json +++ b/fdc3-for-web-implementation/packages/testing/package.json @@ -1,6 +1,6 @@ { "name": "@kite9/testing", - "version": "0.0.54", + "version": "0.0.56", "files": [ "dist" ], @@ -16,7 +16,7 @@ "@cucumber/html-formatter": "11.0.4", "@cucumber/pretty-formatter": "1.0.1", "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/fdc3-common": "0.0.54", + "@kite9/fdc3-common": "0.0.56", "@types/expect": "24.3.0", "@types/lodash": "4.14.167", "@types/node": "^20.14.11", From 04a94acb49ef88c9ee055a15acf41d05adc2ab24 Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Fri, 30 Aug 2024 14:38:00 +0100 Subject: [PATCH 2/2] Minor dead code removal --- fdc3-for-web-implementation/package-lock.json | 88 +++++++++---------- fdc3-for-web-implementation/package.json | 2 +- 2 files changed, 42 insertions(+), 48 deletions(-) diff --git a/fdc3-for-web-implementation/package-lock.json b/fdc3-for-web-implementation/package-lock.json index a6b54e4a6..e24339dc5 100644 --- a/fdc3-for-web-implementation/package-lock.json +++ b/fdc3-for-web-implementation/package-lock.json @@ -1,12 +1,12 @@ { "name": "@kite9/web-fdc3", - "version": "0.0.54", + "version": "0.0.56", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@kite9/web-fdc3", - "version": "0.0.54", + "version": "0.0.56", "workspaces": [ "packages/fdc3-common", "packages/testing", @@ -94,10 +94,10 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.5", - "integrity": "sha512-abd43wyLfbWoxC6ahM8xTkqLpGB2iWBVyuKC9/srhFunCd1SDNrV1s72bBpK4hLj8KLzHBBcOblvLQZBNw9r3w==", + "version": "7.25.6", + "integrity": "sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==", "dependencies": { - "@babel/types": "^7.25.4", + "@babel/types": "^7.25.6", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -187,11 +187,11 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.0", - "integrity": "sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==", + "version": "7.25.6", + "integrity": "sha512-Xg0tn4HcfTijTwfDwYlvVCl43V6h4KyVVX2aEm4qdO/PC6L2YvzLHFdmxhoeSA3eslcE6+ZVXHgWwopXYLNq4Q==", "dependencies": { "@babel/template": "^7.25.0", - "@babel/types": "^7.25.0" + "@babel/types": "^7.25.6" }, "engines": { "node": ">=6.9.0" @@ -261,10 +261,10 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.4", - "integrity": "sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==", + "version": "7.25.6", + "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", "dependencies": { - "@babel/types": "^7.25.4" + "@babel/types": "^7.25.6" }, "bin": { "parser": "bin/babel-parser.js" @@ -274,8 +274,8 @@ } }, "node_modules/@babel/runtime": { - "version": "7.25.4", - "integrity": "sha512-DSgLeL/FNcpXuzav5wfYvHCGvynXkJbn3Zvc3823AEe9nPwW9IK4UoCSS5yGymmQzN0pCPvivtgS6/8U2kkm1w==", + "version": "7.25.6", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" @@ -297,14 +297,14 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.4", - "integrity": "sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==", + "version": "7.25.6", + "integrity": "sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==", "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.4", - "@babel/parser": "^7.25.4", + "@babel/generator": "^7.25.6", + "@babel/parser": "^7.25.6", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.4", + "@babel/types": "^7.25.6", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -320,8 +320,8 @@ } }, "node_modules/@babel/types": { - "version": "7.25.4", - "integrity": "sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==", + "version": "7.25.6", + "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", "dependencies": { "@babel/helper-string-parser": "^7.24.8", "@babel/helper-validator-identifier": "^7.24.7", @@ -4314,8 +4314,8 @@ } }, "node_modules/get-tsconfig": { - "version": "4.7.6", - "integrity": "sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA==", + "version": "4.8.0", + "integrity": "sha512-Pgba6TExTZ0FJAn1qkJAjIeKoDJ3CsI2ChuLohJnZl/tTU8MVrq3b+2t5UOPfRa4RMsorClBjJALkJUMjG1PAw==", "dependencies": { "resolve-pkg-maps": "^1.0.0" }, @@ -8346,8 +8346,8 @@ } }, "node_modules/type-fest": { - "version": "4.25.0", - "integrity": "sha512-bRkIGlXsnGBRBQRAY56UXBm//9qH4bmJfFvq83gSz41N282df+fjy8ofcEgc1sM8geNt5cl6mC2g9Fht1cs8Aw==", + "version": "4.26.0", + "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", "engines": { "node": ">=16" }, @@ -9459,18 +9459,17 @@ } }, "packages/client": { - "name": "@kite9/client", - "version": "0.0.54", + "version": "0.0.56", "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/da-proxy": "0.0.54", - "@kite9/fdc3-common": "0.0.54", + "@kite9/da-proxy": "0.0.56", + "@kite9/fdc3-common": "0.0.56", "@types/uuid": "^10.0.0", "uuid": "^9.0.1" }, "devDependencies": { "@cucumber/cucumber": "10.3.1", - "@kite9/da-server": "0.0.54", + "@kite9/da-server": "0.0.56", "@types/node": "^20.14.11", "@types/wtfnode": "^0.7.3", "expect": "^29.7.0", @@ -9483,17 +9482,16 @@ } }, "packages/da-proxy": { - "name": "@kite9/da-proxy", - "version": "0.0.54", + "version": "0.0.56", "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/fdc3-common": "0.0.54" + "@kite9/fdc3-common": "0.0.56" }, "devDependencies": { "@cucumber/cucumber": "10.3.1", "@cucumber/html-formatter": "11.0.4", "@cucumber/pretty-formatter": "1.0.1", - "@kite9/testing": "0.0.54", + "@kite9/testing": "0.0.56", "@types/expect": "24.3.0", "@types/lodash": "4.14.167", "@types/node": "^20.14.11", @@ -9518,8 +9516,7 @@ } }, "packages/da-server": { - "name": "@kite9/da-server", - "version": "0.0.54", + "version": "0.0.56", "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", "@types/uuid": "^10.0.0", @@ -9529,8 +9526,8 @@ "@cucumber/cucumber": "10.3.1", "@cucumber/html-formatter": "11.0.4", "@cucumber/pretty-formatter": "1.0.1", - "@kite9/fdc3-common": "0.0.54", - "@kite9/testing": "0.0.54", + "@kite9/fdc3-common": "0.0.56", + "@kite9/testing": "0.0.56", "@types/expect": "24.3.0", "@types/lodash": "4.14.167", "@types/node": "^20.14.11", @@ -9555,13 +9552,12 @@ } }, "packages/demo": { - "name": "@kite9/demo", - "version": "0.0.54", + "version": "0.0.56", "dependencies": { "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/client": "0.0.54", - "@kite9/da-server": "0.0.54", - "@kite9/fdc3-common": "0.0.54", + "@kite9/client": "0.0.56", + "@kite9/da-server": "0.0.56", + "@kite9/fdc3-common": "0.0.56", "@types/uuid": "^10.0.0", "@types/ws": "^8.5.10", "express": "^4.18.3", @@ -9581,8 +9577,7 @@ } }, "packages/fdc3-common": { - "name": "@kite9/fdc3-common", - "version": "0.0.54", + "version": "0.0.56", "dependencies": { "@finos/fdc3": "^2.1.0-beta.6" }, @@ -9592,14 +9587,13 @@ } }, "packages/testing": { - "name": "@kite9/testing", - "version": "0.0.54", + "version": "0.0.56", "dependencies": { "@cucumber/cucumber": "10.3.1", "@cucumber/html-formatter": "11.0.4", "@cucumber/pretty-formatter": "1.0.1", "@finos/fdc3": "^2.1.0-beta.6", - "@kite9/fdc3-common": "0.0.54", + "@kite9/fdc3-common": "0.0.56", "@types/expect": "24.3.0", "@types/lodash": "4.14.167", "@types/node": "^20.14.11", diff --git a/fdc3-for-web-implementation/package.json b/fdc3-for-web-implementation/package.json index aa058833c..9889e9dc0 100644 --- a/fdc3-for-web-implementation/package.json +++ b/fdc3-for-web-implementation/package.json @@ -1,7 +1,7 @@ { "name": "@kite9/web-fdc3", "private": true, - "version": "0.0.54", + "version": "0.0.56", "workspaces": [ "packages/fdc3-common", "packages/testing",