Skip to content

Commit

Permalink
FIxing linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Mar 11, 2025
1 parent 860555f commit 1b924fe
Show file tree
Hide file tree
Showing 28 changed files with 562 additions and 144 deletions.
32 changes: 0 additions & 32 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"rimraf": "^6.0.1"
},
"dependencies": {
"@finos/fdc3-agent-proxy": "2.2.0-beta.2",
"@finos/fdc3-schema": "2.2.0-beta.2",
"@finos/fdc3-agent-proxy": "2.2.0-beta.3",
"@finos/fdc3-schema": "2.2.0-beta.3",
"@finos/fdc3-web-impl": "file:../../FDC3/toolbox/fdc3-for-web/fdc3-web-impl",
"socket.io-client": "^4.7.5",
"typescript": "^5.7.3",
Expand Down
2 changes: 1 addition & 1 deletion common/src/AbstractClientState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export abstract class AbstractClientState implements ClientState {

/** Tabs */
getActiveTab(): TabDetail {
return this.tabs.find(t => t.id == this.activeTabId)!!
return this.tabs.find(t => t.id == this.activeTabId)!
}

async setActiveTabId(id: string): Promise<void> {
Expand Down
18 changes: 9 additions & 9 deletions common/src/DefaultAppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class DefaultAppState implements AppState {

async getDirectoryAppForUrl(identityUrl: string): Promise<DirectoryApp | undefined> {
const strippedIdentityUrl = identityUrl.replace(/\/$/, "")
const applications: DirectoryApp[] = this.cs!!.getKnownApps()
const applications: DirectoryApp[] = this.cs!.getKnownApps()
const firstMatchingApp = applications.find(x => {
const d = x.details as WebAppDetails
return (d.url == strippedIdentityUrl) ||
Expand All @@ -45,9 +45,9 @@ export class DefaultAppState implements AppState {
this.cs = cs;
this.ss = ss;
// sets up postMessage listener for new applications joining

// eslint-disable-next-line insufficient-postmessage-origin-validation
window.addEventListener("message", async (e) => {
const event = e as MessageEvent
const event = e
const data = event.data;
const source = event.source as Window
const origin = event.origin;
Expand Down Expand Up @@ -115,7 +115,7 @@ export class DefaultAppState implements AppState {
*/
createTitle(detail: DirectoryApp): string {
// Get all existing panels
const existingPanels = this.cs!!.getPanels()
const existingPanels = this.cs!.getPanels()

// Get all numbers currently in use for this app title
const usedNumbers = new Set(
Expand Down Expand Up @@ -145,14 +145,14 @@ export class DefaultAppState implements AppState {
const hosting: AppHosting = destination ?? (detail.hostManifests as any)?.sail?.forceNewWindow ? AppHosting.Tab : AppHosting.Frame
const instanceTitle = this.createTitle(detail)
if (hosting == AppHosting.Tab) {
const instanceId = await this.ss!!.registerAppLaunch(detail.appId, hosting, null, instanceTitle)
const w = window.open((detail.details as WebAppDetails).url, "_blank")!!;
const instanceId = await this.ss!.registerAppLaunch(detail.appId, hosting, null, instanceTitle)
const w = window.open((detail.details as WebAppDetails).url, "_blank")!;
this.registerAppWindow(w, instanceId)
return resolve({ instanceId, channel: null, instanceTitle })
} else {
const channel = this.cs!!.getActiveTab().id
const instanceId = await this.ss!!.registerAppLaunch(detail.appId, hosting, channel, instanceTitle)
this.cs!!.newPanel(detail, instanceId, instanceTitle)
const channel = this.cs!.getActiveTab().id
const instanceId = await this.ss!.registerAppLaunch(detail.appId, hosting, channel, instanceTitle)
this.cs!.newPanel(detail, instanceId, instanceTitle)
return resolve({ instanceId, channel, instanceTitle })
}
})
Expand Down
2 changes: 1 addition & 1 deletion common/src/LocalStorageClientState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class LocalStorageClientState extends AbstractClientState {
localStorage.setItem(STORAGE_KEY, data)
console.log(`SAIL saved state: ${data}`)
this.callbacks.forEach(cb => cb())
await this.ss!!.sendClientState(this.tabs, this.directories)
await this.ss!.sendClientState(this.tabs, this.directories)
}
}

Expand Down
22 changes: 11 additions & 11 deletions common/src/ServerStateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export class ServerStateImpl implements ServerState {
throw new Error("Desktop Agent not registered")
}

const userSessionId = this.cs!!.getUserSessionID()
const userSessionId = this.cs!.getUserSessionID()
const response = await this.socket.emitWithAck(DA_DIRECTORY_LISTING, { userSessionId } as DesktopAgentDirectoryListingArgs)
const out = response as DirectoryApp[]
this.cs!!.setKnownApps(out)
this.cs!.setKnownApps(out)
return out
}

Expand All @@ -38,7 +38,7 @@ export class ServerStateImpl implements ServerState {
throw new Error("Desktop Agent not registered")
}

const userSessionId = this.cs!!.getUserSessionID()
const userSessionId = this.cs!.getUserSessionID()
const instanceId: string = await this.socket.emitWithAck(DA_REGISTER_APP_LAUNCH, { userSessionId, appId, hosting, channel, instanceTitle } as DesktopAgentRegisterAppLaunchArgs)
return instanceId
}
Expand All @@ -47,7 +47,7 @@ export class ServerStateImpl implements ServerState {
if (!this.socket) {
return
}
const userSessionId = this.cs!!.getUserSessionID()
const userSessionId = this.cs!.getUserSessionID()


await this.socket.emitWithAck(SAIL_CLIENT_STATE, { userSessionId, tabs, directories } as SailClientStateArgs)
Expand All @@ -60,7 +60,7 @@ export class ServerStateImpl implements ServerState {
this.socket = io()
this.socket.on("connect", () => {
this.socket?.emit(DA_HELLO, props, () => {
this.sendClientState(this.cs!!.getTabs(), this.cs!!.getDirectories()).then(() => {
this.sendClientState(this.cs!.getTabs(), this.cs!.getDirectories()).then(() => {
this.getApplications()
})
})
Expand All @@ -70,31 +70,31 @@ export class ServerStateImpl implements ServerState {
if (data.channel) {
// opening in a panel inside sail
this.cs?.setActiveTabId(data.channel)
const openDetails = await this.as!!.open(data.appDRecord, AppHosting.Frame)
const openDetails = await this.as!.open(data.appDRecord, AppHosting.Frame)
callback(openDetails)
} else {
// opening in a new tab
const openDetails = await this.as!!.open(data.appDRecord, AppHosting.Tab)
const openDetails = await this.as!.open(data.appDRecord, AppHosting.Tab)
callback(openDetails)
}
})

this.socket?.on(SAIL_APP_STATE, (data: SailAppStateArgs) => {
//console.log(`SAIL_APP_STATE: ${JSON.stringify(data)}`)
this.as!!.setAppState(data)
this.as!.setAppState(data)
})

this.socket?.on(SAIL_CHANNEL_SETUP, (instanceId: string) => {
//console.log(`SAIL_CHANNEL_SETUP: ${instanceId}`)
const panel = this.cs!!.getPanels().find(p => p.panelId === instanceId)
const panel = this.cs!.getPanels().find(p => p.panelId === instanceId)
if (panel) {
this.setUserChannel(instanceId, panel.tabId)
}
})

this.socket?.on(SAIL_INTENT_RESOLVE, (data: SailIntentResolveArgs, callback) => {
console.log(`SAIL_INTENT_RESOLVE: ${JSON.stringify(data)}`)
this.cs!!.setIntentResolution({
this.cs!.setIntentResolution({
appIntents: data.appIntents,
context: data.context,
requestId: data.requestId
Expand All @@ -109,7 +109,7 @@ export class ServerStateImpl implements ServerState {
await this.socket?.emitWithAck(SAIL_CHANNEL_CHANGE, {
instanceId,
channel: channelId,
userSessionId: this.cs!!.getUserSessionID()
userSessionId: this.cs!.getUserSessionID()
} as SailChannelChangeArgs)
}

Expand Down
12 changes: 6 additions & 6 deletions common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export * from "./message-types"
export * from "./AppState"
export * from "./ServerState"

var theServerState: ServerState | null = null
var theClientState: ClientState | null = null
var theAppState: DefaultAppState | null = null
let theServerState: ServerState | null = null
let theClientState: ClientState | null = null
let theAppState: DefaultAppState | null = null

function ensureSetup() {

Expand All @@ -29,15 +29,15 @@ function ensureSetup() {

export function getServerState(): ServerState {
ensureSetup()
return theServerState!!
return theServerState!
}

export function getAppState(): AppState {
ensureSetup()
return theAppState!!
return theAppState!
}

export function getClientState(): ClientState {
ensureSetup()
return theClientState!!
return theClientState!
}
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: ['./**/tsconfig.json'],
tsconfigRootDir: import.meta.dirname,
},
},
},
);
Loading

0 comments on commit 1b924fe

Please sign in to comment.