Skip to content

Commit a7c6fdd

Browse files
committed
Moved to new fdc3 package names, added trading view
1 parent 9fc1737 commit a7c6fdd

19 files changed

+357
-223
lines changed

directory/sail.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"applications": [
3+
{
4+
"appId": "trading-view-chart",
5+
"name": "Trading View Chart",
6+
"title": "Trading View Chart",
7+
"description": "Displays a chart of a given stock, using the TradingView applications",
8+
"type": "web",
9+
"details": {
10+
"url": "/static/example-apps/tradingview/chart.html"
11+
},
12+
"screenshots": [
13+
{
14+
"src": "/static/example-apps/tradingview/chart.png",
15+
"label": "Demo Screenshot"
16+
}
17+
],
18+
"hostManifests": {},
19+
"version": "1.0.0",
20+
"publisher": "FINOS",
21+
"icons": [
22+
{
23+
"src": "/static/example-apps/tradingview/tradingview-icon.png"
24+
}
25+
]
26+
}
27+
],
28+
"message": "OK"
29+
}

package-lock.json

+220-202
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
"vite": "^5.0.2"
1919
},
2020
"dependencies": {
21-
"@kite9/client": "2.2.0-beta.6",
22-
"@kite9/da-server": "2.2.0-beta.6",
23-
"@kite9/fdc3": "2.2.0-beta.6",
24-
"@kite9/fdc3-common": "2.2.0-beta.6",
21+
"@kite9/fdc3": "2.2.0-beta.19",
22+
"@kite9/fdc3-web-impl": "2.2.0-beta.19",
2523
"@types/react-dom": "^18.2.25",
2624
"@types/uuid": "^9.0.8",
2725
"@types/ws": "^8.5.10",

src/app/util.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { InstanceID } from "@kite9/da-server"
1+
import { InstanceID } from "@kite9/fdc3-web-impl"
22
import { Socket } from "socket.io-client"
33
import { FDC3_APP_EVENT, FDC3_DA_EVENT } from "../server/da/message-types"
44

55

66
export function link(socket: Socket, channel: MessageChannel, source: InstanceID) {
77
socket.on(FDC3_DA_EVENT, (data: any, to: InstanceID) => {
8-
//console.log(`DA Sent ${JSON.stringify(data)} from socket`)
8+
console.log(`DA Sent ${JSON.stringify(data)} from socket`)
99
channel.port2.postMessage(data)
1010
})
1111

1212
channel.port2.onmessage = function (event) {
13-
//console.log(`App Sent ${JSON.stringify(event.data)} from message port`)
13+
console.log(`App Sent ${JSON.stringify(event.data)} from message port`)
1414
socket.emit(FDC3_APP_EVENT, event.data, source)
1515
}
1616
}

src/client/appd/appd.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Icon } from "../icon/icon";
33
import { getServerState } from "../state/ServerState";
44
import * as styles from "./styles.module.css";
55
import { Popup, PopupButton } from "../popups/popup";
6-
import { DirectoryApp } from "@kite9/da-server";
6+
import { DirectoryApp } from "@kite9/fdc3-web-impl";
77
import { getAppState } from "../state/AppState";
88

99
const DEFAULT_ICON = "/static/icons/control/choose-app.svg";

src/client/grid/grid.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class Grids extends Component<GridsProps> {
2020
return (
2121
<div className={styles.grids} id={this.props.id}>
2222
{this.props.cs.getPanels().map((p) => (
23-
<AppFrame panel={p} />
23+
<AppFrame key={p.panelId} panel={p} />
2424
))}
2525
</div>
2626
);

src/client/state/AppState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { WebConnectionProtocol1Hello } from "@kite9/fdc3-common";
22
import { getClientState } from "./clientState"
33
import { getServerState } from "./ServerState"
4-
import { DirectoryApp } from "@kite9/da-server";
4+
import { DirectoryApp } from "@kite9/fdc3-web-impl";
55
import { v4 as uuid } from 'uuid'
66

77
interface AppState {

src/client/state/ServerState.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DirectoryApp } from "@kite9/da-server";
1+
import { DirectoryApp } from "@kite9/fdc3-web-impl";
22
import { getClientState } from "./clientState";
33
import { DA_DIRECTORY_LISTING, DA_HELLO, DA_REGISTER_APP_LAUNCH, DesktopAgentDirectoryListingArgs, DesktopAgentHelloArgs, DesktopAgentRegisterAppLaunchArgs, SAIL_APP_OPEN, SAIL_CHANNEL_CHANGE, SAIL_INTENT_RESOLVE, SailAppOpenArgs, SailChannelChangeArgs, SailIntentResolveArgs } from "../../server/da/message-types";
44
import { io, Socket } from "socket.io-client"
@@ -59,9 +59,9 @@ class ServerStateImpl implements ServerState {
5959
this.socket.on("connect", () => {
6060
this.socket?.emit(DA_HELLO, props)
6161

62-
this.socket?.on(SAIL_APP_OPEN, (data: SailAppOpenArgs, callback) => {
62+
this.socket?.on(SAIL_APP_OPEN, async (data: SailAppOpenArgs, callback) => {
6363
// (`SAIL_APP_OPEN: ${JSON.stringify(data)}`)
64-
const instanceId = getAppState().open(data.appDRecord)
64+
const instanceId = await getAppState().open(data.appDRecord)
6565
callback(instanceId)
6666
})
6767

src/client/state/clientState.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ChannelState, DirectoryApp } from "@kite9/da-server"
1+
import { ChannelState, DirectoryApp } from "@kite9/fdc3-web-impl"
22
import { GridStackPosition } from "gridstack"
33
import { v4 as uuidv4 } from 'uuid';
44
import { DesktopAgentHelloArgs } from "../../server/da/message-types";
55
import { AppIntent, Context, DisplayMetadata } from "@kite9/fdc3";
6-
import { ChannelType } from "@kite9/da-server/dist/src/handlers/BroadcastHandler";
6+
import { ChannelType } from "@kite9/fdc3-web-impl/dist/src/handlers/BroadcastHandler";
77
import { getServerState } from "./ServerState";
88

99
const STORAGE_KEY = "sail-client-state"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// TradingViewWidget.jsx
2+
import { useEffect, useRef, memo } from "react";
3+
4+
export function TradingViewWidget() {
5+
const container: any = useRef();
6+
7+
useEffect(() => {
8+
const script = document.createElement("script");
9+
script.src =
10+
"https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js";
11+
script.type = "text/javascript";
12+
script.async = true;
13+
script.innerHTML = `
14+
{
15+
"autosize": true,
16+
"symbol": "NASDAQ:AAPL",
17+
"interval": "D",
18+
"timezone": "Etc/UTC",
19+
"theme": "light",
20+
"style": "1",
21+
"locale": "en",
22+
"allow_symbol_change": true,
23+
"calendar": false,
24+
"support_host": "https://www.tradingview.com"
25+
}`;
26+
container.current.appendChild(script);
27+
}, []);
28+
29+
return (
30+
<div
31+
className="tradingview-widget-container"
32+
ref={container}
33+
style={{ height: "100%", width: "100%" }}
34+
>
35+
<div
36+
className="tradingview-widget-container__widget"
37+
style={{ height: "calc(100% - 32px)", width: "100%" }}
38+
></div>
39+
<div className="tradingview-widget-copyright">
40+
<a
41+
href="https://www.tradingview.com/"
42+
rel="noopener nofollow"
43+
target="_blank"
44+
>
45+
<span className="blue-text"> Track all markets on TradingView </span>
46+
</a>
47+
</div>
48+
</div>
49+
);
50+
}
51+
52+
export default memo(TradingViewWidget);
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createRoot } from "react-dom/client";
2+
import { TradingViewWidget } from "./TradingViewWidget";
3+
import { getAgent } from "@kite9/fdc3";
4+
5+
const container = document.getElementById("app");
6+
const root = createRoot(container!);
7+
root.render(<TradingViewWidget />);
8+
9+
window.onload = async () => {
10+
const fdc3 = await getAgent();
11+
};

src/server/appd/SailDirectory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from 'node:fs/promises';
2-
import { BasicDirectory, DirectoryApp } from '@kite9/da-server';
2+
import { BasicDirectory, DirectoryApp } from '@kite9/fdc3-web-impl';
33

44
function loadRemotely(u: string): Promise<any> {
55
return fetch(u).then((response) => response.json());

src/server/da/SailFDC3Server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DesktopAgentHelloArgs } from "./message-types";
2-
import { DefaultFDC3Server } from "@kite9/da-server"
2+
import { DefaultFDC3Server } from "@kite9/fdc3-web-impl"
33
import { SailServerContext } from "./SailServerContext";
44

55

src/server/da/SailServerContext.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Socket } from "socket.io";
22
import { v4 as uuidv4 } from 'uuid'
33
import { FDC3_DA_EVENT, SAIL_APP_OPEN, SAIL_CHANNEL_CHANGE, SAIL_INTENT_RESOLVE, SailAppOpenArgs } from "./message-types";
4-
import { DirectoryApp, InstanceID, ServerContext } from "@kite9/da-server"
5-
import { AppIdentifier } from "@kite9/fdc3-common";
4+
import { DirectoryApp, InstanceID, ServerContext } from "@kite9/fdc3-web-impl"
5+
import { AppIdentifier } from "@kite9/fdc3";
66
import { SailDirectory } from "../appd/SailDirectory";
77
import { AppIntent, Context, OpenError } from "@kite9/fdc3";
88
import { OPEN } from "ws";

src/server/da/initSocketService.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
2020
var type: SocketType | undefined = undefined
2121

2222
socket.on(DA_HELLO, function (props: DesktopAgentHelloArgs) {
23+
console.log(JSON.stringify(props))
24+
2325
type = SocketType.DESKTOP_AGENT
2426
userSessionId = props.userSessionId
2527
console.log("Desktop Agent Connecting", userSessionId)
@@ -45,11 +47,14 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
4547
if (session) {
4648
callback(session?.getDirectory().allApps)
4749
} else {
50+
console.error("Session not found", userSessionId)
4851
callback(null, "Session not found")
4952
}
5053
})
5154

5255
socket.on(DA_REGISTER_APP_LAUNCH, async function (props: DesktopAgentRegisterAppLaunchArgs, callback: (success: any, err?: string) => void) {
56+
console.log(JSON.stringify(props))
57+
5358
const { appId, userSessionId } = props
5459
const session = sessions.get(userSessionId)
5560
if (session) {
@@ -62,11 +67,14 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
6267
console.log("Registered app", appId, instanceId)
6368
callback(instanceId)
6469
} else {
70+
console.error("Session not found", userSessionId)
6571
callback(null, "Session not found")
6672
}
6773
})
6874

6975
socket.on(APP_HELLO, function (props: AppHelloArgs) {
76+
console.log(JSON.stringify(props))
77+
7078
appInstanceId = props.instanceId
7179
userSessionId = props.userSessionId
7280
type = SocketType.APP
@@ -96,7 +104,7 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
96104
console.error("App tried to connect with invalid instance id")
97105
}
98106
} else {
99-
console.log("App Tried Connecting to non-existent DA Instance ", userSessionId, appInstanceId)
107+
console.error("App Tried Connecting to non-existent DA Instance ", userSessionId, appInstanceId)
100108
}
101109
})
102110

@@ -110,6 +118,8 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
110118
} catch (e) {
111119
console.error("Error processing message", e)
112120
}
121+
} else {
122+
console.error("No Server instance")
113123
}
114124
})
115125

@@ -123,6 +133,8 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
123133
sessions.delete(userSessionId!!)
124134
console.error("Desktop Agent Disconnected", userSessionId)
125135
}
136+
} else {
137+
console.error("No Server instance")
126138
}
127139
})
128140
})

src/server/da/message-types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChannelState, DirectoryApp } from "@kite9/da-server"
1+
import { ChannelState, DirectoryApp } from "@kite9/fdc3-web-impl"
22
import { AppIntent, Context } from "@kite9/fdc3"
33

44
export const DA_HELLO = 'da-hello'
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html lang="en">
2+
<head>
3+
<title>FDC3 TradingView CHart</title>
4+
<meta charset="UTF-8" />
5+
<script
6+
type="module"
7+
src="/src/example-apps/tradingview/chart.tsx"
8+
></script>
9+
</head>
10+
11+
<body>
12+
<div id="app">Content loads here</div>
13+
</body>
14+
</html>
120 KB
Loading
Loading

0 commit comments

Comments
 (0)