Skip to content

Commit

Permalink
Merge pull request #1 from finos-labs/rob-first-version
Browse files Browse the repository at this point in the history
Apps Working, Desktop Agent created
  • Loading branch information
robmoffat authored Jul 1, 2023
2 parents 56f6b3b + 0e0cc11 commit 5555a70
Show file tree
Hide file tree
Showing 14 changed files with 2,757 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist
/node_modules
2,490 changes: 2,490 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"private": true,
"scripts": {
"compile": "webpack build",
"serve": "npx http-server . -p 3001 -c-1",
"start": "npm run compile && npm run serve"
},
"dependencies": {
"@finos/fdc3": "^2.0.3",
"source-map-support": "^0.5.21",
"stream-browserify": "^3.0.0",
"util": "^0.12.4",
"window": "^1.0.0"
},
"devDependencies": {
"buffer": "^6.0.3",
"css-loader": "^6.7.2",
"http-server": "^14.1.1",
"prettier": "^2.5.1",
"shx": "^0.3.4",
"style-loader": "^3.3.1",
"ts-loader": "^9.2.7",
"typescript": "^4.6.2",
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
}
}
10 changes: 10 additions & 0 deletions src/WebC3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { DesktopAgent} from '@finos/fdc3'


export function load(options: any) : Promise<DesktopAgent> {

return new Promise<DesktopAgent>((resolve) => {

});

}
30 changes: 30 additions & 0 deletions src/app1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { load } from '../WebC3'

const options = {

};

function createContext(i: number) {
return {
type: "demo.counter",
count: i
}
}

/**
* Calling this function should get the fdc3 DesktopAgent and then
* broadcast 50 context elements to the default channel.
*
* Can be called any number of times.
*/
async function startBroadcasting() {
const fdc3 = await load(options);
for (let index = 0; index < 50; index++) {
setInterval(() => fdc3.broadcast(createContext(index)), index*1000);
}
}

window.addEventListener("load", () => {
const broadcast = document.getElementById("broadcast");
broadcast.addEventListener("click", () => startBroadcasting());
})
18 changes: 18 additions & 0 deletions src/app2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { load } from '../WebC3'

const options = {

};

load(options).then(fdc => {
const log = document.getElementById("log");
const msg = document.createElement("p");
msg.textContent = "FDC Loaded: "+JSON.stringify(fdc.getInfo());
log.appendChild(msg);

fdc.addContextListener(null, context => {
const msg = document.createElement("p");
msg.textContent = "Received: "+JSON.stringify(msg);
log.appendChild(msg);
})
});
Empty file.
6 changes: 6 additions & 0 deletions src/dummy-desktop-agent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

window.addEventListener("load", () => {

// set up desktop agent handler here.

})
13 changes: 13 additions & 0 deletions static/app1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html lang="en">

<head>
<meta charset="UTF-8" />
<script src="../../dist/app1.js"></script>
</head>

<body>
<p>FDC3 For the Web App1</p>
<button id="broadcast">Press Me To Broadcast</button>
</body>

</html>
13 changes: 13 additions & 0 deletions static/app2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html lang="en">

<head>
<meta charset="UTF-8" />
<script src="../../dist/app2.js"></script>
</head>

<body>
<p>FDC3 For the Web App2</p>
<div id="log"></div>
</body>

</html>
20 changes: 20 additions & 0 deletions static/da/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html lang="en">

<head>
<meta charset="UTF-8" />
<script src="../../dist/dummy-desktop-agent.js"></script>
</head>

<body>
<p>Dummy Desktop Agent</p>

<a id="app1" href="../app1/index.html" target="_blank">Open App 1</button>

<button id="app2" href="../app2/index.html" target="_blank">Open App 2</button>

<div id="log"></div>


</body>

</html>
14 changes: 14 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "esnext",
"lib": ["dom", "esnext"],
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"target": "es5",
"allowJs": true,
"moduleResolution":"Node",
"esModuleInterop": true,
"sourceMap": true
},
"include": ["src/**/*.ts"],
}
57 changes: 57 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const path = require("path");
const webpack = require("webpack");

const isProduction = process.env.NODE_ENV == "production";

const config = {
entry: {
"app1": "./src/app1/index.ts",
"app2": "./src/app2/index.ts",
"dummy-desktop-agent": "./src/dummy-desktop-agent/index.ts",
"dummy-implementation": "./src/dummy-desktop-agent/implementation.ts",
"WebC3": "./src/WebC3/index.ts"
},
devtool: "source-map",
output: {
filename: "[name].js",
//globalObject: 'this',
path: path.resolve(__dirname, "./dist"),
},
plugins: [
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
],
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
loader: "ts-loader",
exclude: [path.resolve(__dirname, "/node_modules/")],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
fallback: {
util: require.resolve("util/"),
stream: require.resolve("stream-browserify/"),
buffer: require.resolve("buffer/"),
window: false,
},
},
};

module.exports = () => {
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
}
return config;
};
57 changes: 57 additions & 0 deletions yarn-error.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Arguments:
/usr/local/bin/node /opt/homebrew/Cellar/yarn/1.22.19/libexec/bin/yarn.js start

PATH:
/Users/rob/miniconda3/bin:/Users/rob/miniconda3/condabin:/Users/rob/.rbenv/shims:/Users/rob/.rbenv/bin:/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin:/Users/rob/Documents/apache-maven-3.6.3/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/rob/.rbenv/shims:/Users/rob/.rbenv/bin:/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin:/Users/rob/Documents/apache-maven-3.6.3/bin:/opt/homebrew/bin:/Users/rob/Library/Python/3.8/bin:/opt/homebrew/bin:/Users/rob/Library/Python/3.8/bin

Yarn version:
1.22.19

Node version:
18.16.1

Platform:
darwin arm64

Trace:
SyntaxError: /Users/rob/Documents/finos/fdc3-general/fdc3-for-the-web/package.json: Unexpected token } in JSON at position 166
at JSON.parse (<anonymous>)
at /opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:1629:59
at Generator.next (<anonymous>)
at step (/opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:310:30)
at /opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:321:13

npm manifest:
{
"private": true,
"scripts": {
"compile": "webpack build",
"serve": "npx http-server . -p 3001 -c-1",
"start": "npm run compile && npm run serve",
},
"dependencies": {
"@finos/fdc3": "^2.0.3",
"source-map-support": "^0.5.21",
"stream-browserify": "^3.0.0",
"util": "^0.12.4",
"window": "^1.0.0"
},
"devDependencies": {
"buffer": "^6.0.3",
"css-loader": "^6.7.2",
"http-server": "^14.1.1",
"prettier": "^2.5.1",
"shx": "^0.3.4",
"style-loader": "^3.3.1",
"ts-loader": "^9.2.7",
"typescript": "^4.6.2",
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
}
}

yarn manifest:
No manifest

Lockfile:
No lockfile

0 comments on commit 5555a70

Please sign in to comment.