mirror of
https://github.com/fluencelabs/dashboard
synced 2024-12-04 23:30:20 +00:00
Merge pull request #7 from fluencelabs/update-sdk
This commit is contained in:
commit
bec83f0a98
@ -4,5 +4,6 @@ module.exports = {
|
||||
singleQuote: true,
|
||||
printWidth: 120,
|
||||
tabWidth: 4,
|
||||
useTabs: false
|
||||
useTabs: false,
|
||||
endOfLine: "auto"
|
||||
};
|
||||
|
161
package-lock.json
generated
161
package-lock.json
generated
@ -1223,14 +1223,35 @@
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aquamarine-stepper": {
|
||||
"version": "0.0.30",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aquamarine-stepper/-/aquamarine-stepper-0.0.30.tgz",
|
||||
"integrity": "sha512-XIgRgyVgPJXvXB3NuYHpSdJ0EFcFZ+K4uduGFf8PfnFii/bFs4F1n3MBB+b4D0y59HR4F9ZQUC4fXxcf6UCYWA=="
|
||||
"version": "0.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aquamarine-stepper/-/aquamarine-stepper-0.3.4.tgz",
|
||||
"integrity": "sha512-0NPg9dWvANtc3If8C8O8XjKwzMCq2492lA73faKJdCwUv7m+xHX9G3l6UJULTfV1T4mWVtMQZIKopNOlRYSrKA=="
|
||||
},
|
||||
"@fluencelabs/fluence": {
|
||||
"version": "0.9.7",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.9.7.tgz",
|
||||
"integrity": "sha512-z9l9+nzJASnNfJpOE9iAX/iRbKrFMgZHIFqC0qYTHm0GFEMQe1YApnWNYXCS49f9tJlJte9TclaJ/f5FFwOrjg==",
|
||||
"requires": {
|
||||
"@fluencelabs/aquamarine-stepper": "0.3.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.3.1",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
"libp2p": "0.28.3",
|
||||
"libp2p-mplex": "0.9.5",
|
||||
"libp2p-secio": "0.12.5",
|
||||
"libp2p-websockets": "0.13.6",
|
||||
"loglevel": "1.7.0",
|
||||
"peer-id": "0.13.12",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence-network-environment": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence-network-environment/-/fluence-network-environment-1.0.5.tgz",
|
||||
"integrity": "sha512-N6ndXhlAuokwhE0in2Mg67nU+jH1H4JlgFvXQP0iFJjWT95nYfjnGEboxxavBnijd6IJe7hi68m+XvlNEV+7yw=="
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence-network-environment/-/fluence-network-environment-1.0.8.tgz",
|
||||
"integrity": "sha512-k1E48+r7tc5jWsnAeLrua7yRKN9lRISdJ1czkcOzUF6dZ9fI5+6ZfKKfUozJyC6n4hSjtCIcUV0G65vBvQfxBw=="
|
||||
},
|
||||
"@hapi/address": {
|
||||
"version": "2.1.4",
|
||||
@ -1350,9 +1371,9 @@
|
||||
}
|
||||
},
|
||||
"@sinonjs/commons": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.1.tgz",
|
||||
"integrity": "sha512-892K+kWUUi3cl+LlqEWIDrhvLgdL79tECi8JZUyq6IviKy/DNhuzCRlbHUjxK89f4ypPMMaFnFuR9Ie6DoIMsw==",
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.2.tgz",
|
||||
"integrity": "sha512-sruwd86RJHdsVf/AtBoijDmUqJp3B6hF/DGC23C+JaegnDHaZyewCjoVGTdg3J0uz3Zs7NnIT05OBOmML72lQw==",
|
||||
"requires": {
|
||||
"type-detect": "4.0.8"
|
||||
}
|
||||
@ -1365,19 +1386,10 @@
|
||||
"@sinonjs/commons": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"@sinonjs/formatio": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-5.0.1.tgz",
|
||||
"integrity": "sha512-KaiQ5pBf1MpS09MuA0kp6KBQt2JUOQycqVG1NZXvzeaXe5LGFqAKueIS0bw4w0P9r7KuBSVdUk5QjXsUdu2CxQ==",
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1",
|
||||
"@sinonjs/samsam": "^5.0.2"
|
||||
}
|
||||
},
|
||||
"@sinonjs/samsam": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.3.0.tgz",
|
||||
"integrity": "sha512-hXpcfx3aq+ETVBwPlRFICld5EnrkexXuXDwqUNhDdr5L8VjvMeSRwyOa0qL7XFmR+jVWR4rUZtnxlG7RX72sBg==",
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.3.1.tgz",
|
||||
"integrity": "sha512-1Hc0b1TtyfBu8ixF/tpfSHTVWKwCBLY4QJbkgnE7HcwyvT2xArDxb4K7dMgqRm3szI+LJbzmW/s4xxEhv6hwDg==",
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.6.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
@ -4823,9 +4835,9 @@
|
||||
}
|
||||
},
|
||||
"delay": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/delay/-/delay-4.4.0.tgz",
|
||||
"integrity": "sha512-txgOrJu3OdtOfTiEOT2e76dJVfG/1dz2NZ4F0Pyt4UGZJryssMRp5vdM5wQoLwSOBNdrJv3F9PAhp/heqd7vrA=="
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/delay/-/delay-4.4.1.tgz",
|
||||
"integrity": "sha512-aL3AhqtfhOlT/3ai6sWXeqwnw63ATNpnUiN4HL7x9q+My5QtHlO3OIkasmug9LKzpheLdmUKGRKnYXYAS7FQkQ=="
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
@ -6833,27 +6845,6 @@
|
||||
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
|
||||
"dev": true
|
||||
},
|
||||
"fluence": {
|
||||
"version": "0.7.108",
|
||||
"resolved": "https://registry.npmjs.org/fluence/-/fluence-0.7.108.tgz",
|
||||
"integrity": "sha512-Pwk3QkX2AX5vWv791yfIy37xMFAoB+iIZFOAaRCHES2nkBXVJgqBQWH42xXcGJeiBCfecPpI9yl9kPSp3f6nCA==",
|
||||
"requires": {
|
||||
"@fluencelabs/aquamarine-stepper": "0.0.30",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.3.1",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
"libp2p": "0.28.3",
|
||||
"libp2p-mplex": "0.9.5",
|
||||
"libp2p-secio": "0.12.5",
|
||||
"libp2p-websockets": "0.13.6",
|
||||
"loglevel": "1.7.0",
|
||||
"peer-id": "0.13.12",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
},
|
||||
"flush-write-stream": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
|
||||
@ -7001,14 +6992,14 @@
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz",
|
||||
"integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==",
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
|
||||
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
|
||||
"requires": {
|
||||
"at-least-node": "^1.0.0",
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^1.0.0"
|
||||
"universalify": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"fs-minipass": {
|
||||
@ -8019,9 +8010,9 @@
|
||||
}
|
||||
},
|
||||
"ip-regex": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.2.0.tgz",
|
||||
"integrity": "sha512-n5cDDeTWWRwK1EBoWwRti+8nP4NbytBBY0pldmnIkq6Z55KNFmWofh4rl9dPZpj+U/nVq7gweR3ylrvMt4YZ5A=="
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz",
|
||||
"integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q=="
|
||||
},
|
||||
"ipaddr.js": {
|
||||
"version": "1.9.1",
|
||||
@ -8574,9 +8565,9 @@
|
||||
}
|
||||
},
|
||||
"it-pushable": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/it-pushable/-/it-pushable-1.4.0.tgz",
|
||||
"integrity": "sha512-W7251Tj88YBqUIEDWCwd3F8JettSbze+bBp5B3ASzz5tYWaLUI1VDNGbjllH1T6RJ71a5jUSTSt5vHjvuzwoFw==",
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/it-pushable/-/it-pushable-1.4.1.tgz",
|
||||
"integrity": "sha512-XOnbDxD5YoiVtL/vobQW/ZGkzQzJv9Fs9TJlO2McfkIbolBBO2IGY6XjE1ooLfw8gQeH8XbgpoLajtPUVO8Qew==",
|
||||
"requires": {
|
||||
"fast-fifo": "^1.0.0"
|
||||
}
|
||||
@ -8723,13 +8714,6 @@
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"jsonify": {
|
||||
@ -8765,9 +8749,9 @@
|
||||
}
|
||||
},
|
||||
"keypair": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/keypair/-/keypair-1.0.1.tgz",
|
||||
"integrity": "sha1-dgNxknCvtlZO04oiCHoG/Jqk6hs="
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/keypair/-/keypair-1.0.2.tgz",
|
||||
"integrity": "sha512-7zRr8fKOWp/N8xfZyZV6WG1CUvKNiNahSDI4vjJnPJD60lHtIg62dpv60yCgcM2PP8QKv4S2UkZl+8MsYmQRpw=="
|
||||
},
|
||||
"killable": {
|
||||
"version": "1.0.1",
|
||||
@ -9159,9 +9143,9 @@
|
||||
}
|
||||
},
|
||||
"streaming-iterables": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/streaming-iterables/-/streaming-iterables-5.0.3.tgz",
|
||||
"integrity": "sha512-1AgrKjHTvaaK+iA+N3BuTXQWVb7Adyb6+v8yIW3SCTwlBVYEbm76mF8Mf0/IVo+DOk7hoeELOURBKTCMhe/qow=="
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/streaming-iterables/-/streaming-iterables-5.0.4.tgz",
|
||||
"integrity": "sha512-nEs6hBGIPsVz6uq6pscGGKfoPDQWrDQW0b0UHurtSDysekfKLmkPg7FQVRE2sj3Rad6yUo9E1sGTxOWyYsHQ/g=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -10684,9 +10668,9 @@
|
||||
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ=="
|
||||
},
|
||||
"p-wait-for": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-wait-for/-/p-wait-for-3.1.0.tgz",
|
||||
"integrity": "sha512-0Uy19uhxbssHelu9ynDMcON6BmMk6pH8551CvxROhiz3Vx+yC4RqxjyIDk2V4ll0g9177RKT++PK4zcV58uJ7A==",
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/p-wait-for/-/p-wait-for-3.2.0.tgz",
|
||||
"integrity": "sha512-wpgERjNkLrBiFmkMEjuZJEWKKDrNfHCKA1OhyN1wg1FrLkULbviEy6py1AyJUgZ72YWFbZ38FIpnqvVqAlDUwA==",
|
||||
"requires": {
|
||||
"p-timeout": "^3.0.0"
|
||||
}
|
||||
@ -10881,9 +10865,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz",
|
||||
"integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA="
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
||||
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ=="
|
||||
},
|
||||
"pbkdf2": {
|
||||
"version": "3.1.1",
|
||||
@ -11901,9 +11885,9 @@
|
||||
}
|
||||
},
|
||||
"protocol-buffers-schema": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.4.0.tgz",
|
||||
"integrity": "sha512-G/2kcamPF2S49W5yaMGdIpkG6+5wZF0fzBteLKgEHjbNzqjZQ85aAs1iJGto31EJaSTkNvHs5IXuHSaTLWBAiA=="
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.5.1.tgz",
|
||||
"integrity": "sha512-YVCvdhxWNDP8/nJDyXLuM+UFsuPk4+1PB7WGPVDzm3HTHbzFLxQYeW2iZpS4mmnXrQJGBzt230t/BbEb7PrQaw=="
|
||||
},
|
||||
"protons": {
|
||||
"version": "1.2.1",
|
||||
@ -13435,14 +13419,13 @@
|
||||
}
|
||||
},
|
||||
"sinon": {
|
||||
"version": "9.2.2",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.2.tgz",
|
||||
"integrity": "sha512-9Owi+RisvCZpB0bdOVFfL314I6I4YoRlz6Isi4+fr8q8YQsDPoCe5UnmNtKHRThX3negz2bXHWIuiPa42vM8EQ==",
|
||||
"version": "9.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz",
|
||||
"integrity": "sha512-zljcULZQsJxVra28qIAL6ow1Z9tpattkCTEJR4RBP3TGc00FcttsP5pK284Nas5WjMZU5Yzy3kAIp3B3KRf5Yg==",
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.8.1",
|
||||
"@sinonjs/fake-timers": "^6.0.1",
|
||||
"@sinonjs/formatio": "^5.0.1",
|
||||
"@sinonjs/samsam": "^5.3.0",
|
||||
"@sinonjs/samsam": "^5.3.1",
|
||||
"diff": "^4.0.2",
|
||||
"nise": "^4.0.4",
|
||||
"supports-color": "^7.1.0"
|
||||
@ -15210,12 +15193,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"multibase": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/multibase/-/multibase-3.1.0.tgz",
|
||||
"integrity": "sha512-Z+pThrpbS7ckQ2DwW5mPiwCGe1a94f8DWi/OxmbyeRednVOyUKmLSE+60kL/WHFYwWnaD1OakXGk3PYI1NkMFw==",
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/multibase/-/multibase-3.1.1.tgz",
|
||||
"integrity": "sha512-kkSd8jWGznDNEC2eDwtnvSGlZeTeEt0+oHieNWUhv8rIi8JU3voIUo02HpJBNOtgmtxT2CPwkElub7Y9kz3nrw==",
|
||||
"requires": {
|
||||
"@multiformats/base-x": "^4.0.1",
|
||||
"web-encoding": "^1.0.4"
|
||||
"web-encoding": "^1.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15305,9 +15288,9 @@
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",
|
||||
"integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug=="
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
|
@ -20,8 +20,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/fluencelabs/fluence-admin#readme",
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence-network-environment": "1.0.5",
|
||||
"fluence": "0.7.108",
|
||||
"@fluencelabs/fluence": "0.9.7",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.8",
|
||||
"tachyons": "^4.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
65
src/index.ts
65
src/index.ts
@ -16,17 +16,17 @@
|
||||
|
||||
import 'tachyons/css/tachyons.min.css';
|
||||
import './main.css';
|
||||
import Fluence from 'fluence';
|
||||
import { build } from 'fluence/dist/particle';
|
||||
import { registerService } from 'fluence/dist/globalState';
|
||||
import { ServiceOne } from 'fluence/dist/service';
|
||||
import { faasNetHttps, dev, Node } from '@fluencelabs/fluence-network-environment';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import log from 'loglevel';
|
||||
import { Node, dev, testNet } from '@fluencelabs/fluence-network-environment';
|
||||
import { createClient, generatePeerId, Particle, sendParticle, subscribeToEvent } from '@fluencelabs/fluence';
|
||||
import { Elm } from './Main.elm';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
|
||||
const relayIdx = 2;
|
||||
const relayIdx = 3;
|
||||
|
||||
export const relays: Node[] = faasNetHttps;
|
||||
// const relays: Node[] = testNet;
|
||||
const relays: Node[] = dev;
|
||||
|
||||
function genFlags(peerId: string): any {
|
||||
return {
|
||||
@ -67,53 +67,36 @@ function event(
|
||||
/* eslint-enable */
|
||||
|
||||
(async () => {
|
||||
Fluence.setLogLevel('silent');
|
||||
const pid = await Fluence.generatePeerId();
|
||||
const pid = await generatePeerId();
|
||||
const flags = genFlags(pid.toB58String());
|
||||
|
||||
// If the relay is ever changed, an event shall be sent to elm
|
||||
const client = await Fluence.connect(relays[relayIdx].multiaddr, pid);
|
||||
const client = await createClient(relays[relayIdx].multiaddr, pid);
|
||||
|
||||
const app = Elm.Main.init({
|
||||
node: document.getElementById('root'),
|
||||
flags,
|
||||
});
|
||||
|
||||
const eventService = new ServiceOne('event', (fnName, args: any[], _tetraplets) => {
|
||||
// console.log('event service called: ', fnName);
|
||||
// console.log('from: ', args[0]);
|
||||
console.log(`event from ${args[0]} received:`, args);
|
||||
|
||||
subscribeToEvent(client, 'event', 'peers_discovered', (args, _tetraplets) => {
|
||||
try {
|
||||
if (fnName === 'peers_discovered') {
|
||||
app.ports.eventReceiver.send(event(fnName, args[0], args[1]));
|
||||
} else if (fnName === 'all_info') {
|
||||
app.ports.eventReceiver.send(event(fnName, args[0], undefined, args[1], args[2], args[3], args[4]));
|
||||
} else {
|
||||
console.error('UNHANDLED');
|
||||
}
|
||||
app.ports.eventReceiver.send(event('peers_discovered', args[0], args[1]));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
log.error('Elm eventreceiver failed: ', err);
|
||||
}
|
||||
|
||||
return {};
|
||||
});
|
||||
registerService(eventService);
|
||||
|
||||
app.ports.sendParticle.subscribe(async (part: any) => {
|
||||
console.log('Going to build particle', part);
|
||||
const jsonData = part.data;
|
||||
|
||||
const map = new Map<string, string>();
|
||||
for (const v in jsonData) {
|
||||
if (jsonData.hasOwnProperty(v)) {
|
||||
map.set(v, jsonData[v]);
|
||||
}
|
||||
subscribeToEvent(client, 'event', 'all_info', (args, _tetraplets) => {
|
||||
try {
|
||||
app.ports.eventReceiver.send(event('all_info', args[0], undefined, args[1], args[2], args[3], args[4]));
|
||||
} catch (err) {
|
||||
log.error('Elm eventreceiver failed: ', err);
|
||||
}
|
||||
});
|
||||
|
||||
const particle = await build(client.selfPeerId, part.script, map, 45000);
|
||||
console.log('Building a particle with AIR script: ', particle);
|
||||
await client.sendParticle(particle);
|
||||
app.ports.sendParticle.subscribe(async (part: { script: string; data: any }) => {
|
||||
const particle = new Particle(part.script, part.data, 45000);
|
||||
await sendParticle(client, particle);
|
||||
});
|
||||
})();
|
||||
|
||||
@ -122,12 +105,8 @@ function event(
|
||||
// Learn more about service workers: https://bit.ly/CRA-PWA
|
||||
serviceWorker.unregister();
|
||||
|
||||
async function test() {}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
test: any;
|
||||
}
|
||||
}
|
||||
|
||||
window.test = test;
|
||||
|
Loading…
Reference in New Issue
Block a user