Skip to content

Commit d9bf21e

Browse files
authored
Updated olaf problem to the last version. (#20)
* Updated olaf problem to the last version. * added .env.example * fixed readme example
1 parent aca4458 commit d9bf21e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1976
-1108
lines changed

.babelrc

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
{
22
"presets": [
3-
[
4-
"@babel/env",
5-
{
6-
"targets": {
7-
chrome: "58",
8-
node: "6"
9-
}
10-
}
11-
]
3+
"@babel/preset-env"
124
],
135
"plugins": [
14-
"@babel/proposal-class-properties"
6+
"@babel/plugin-proposal-class-properties"
157
]
168
}

package-lock.json

+1,467-972
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6+
"browserslist": [
7+
"> 5%"
8+
],
69
"dependencies": {
710
"@geut/discovery-swarm-webrtc": "^1.0.1",
811
"anchorme": "^1.1.2",
912
"balloon-css": "^0.5.0",
1013
"choo": "^6.13.0",
1114
"choo-devtools": "^2.5.1",
15+
"choo-service-worker": "^2.4.0",
16+
"color-contrast": "0.0.1",
1217
"copy-to-clipboard": "^3.0.8",
1318
"file-type": "^9.0.0",
1419
"flush-write-stream": "^1.0.3",
@@ -17,12 +22,13 @@
1722
"hyperid": "^1.4.1",
1823
"pump": "^3.0.0",
1924
"qrcode": "^1.3.0",
25+
"random-access-idb": "^1.2.0",
2026
"random-access-memory": "^3.0.0",
2127
"random-color": "^1.0.1",
2228
"signalhub": "^4.9.0",
29+
"signalhubws": "^1.0.4",
2330
"tachyons": "^4.11.1",
24-
"tinydate": "^1.0.0",
25-
"webrtc-swarm": "^2.9.0"
31+
"tinydate": "^1.0.0"
2632
},
2733
"devDependencies": {
2834
"@babel/core": "^7.0.0",
@@ -40,13 +46,15 @@
4046
"eslint-plugin-promise": "^4.0.1",
4147
"eslint-plugin-standard": "^4.0.0",
4248
"jest": "^23.6.0",
43-
"parcel-bundler": "^1.10.3"
49+
"parcel-bundler": "^1.10.3",
50+
"parcel-plugin-sw-precache": "^1.0.1"
4451
},
4552
"scripts": {
4653
"test": "jest",
4754
"start": "docsify serve --port 5000",
4855
"lint": "eslint problems",
49-
"olaf": "parcel problems/10/chat/olaf/index.html -p 3000"
56+
"olaf": "parcel problems/10/olaf/index.html -p 3000",
57+
"signal": "signalhubws listen -p 4000"
5058
},
5159
"repository": {
5260
"type": "git",

problems/05/README.es.md

+2-1

problems/05/README.md

+5-4

problems/05/solution.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = class Saga {
55
this.messages = new Map()
66
this.users = new Map()
77
this.username = username
8+
this.timestamp = Date.now()
89
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
910
}
1011
}

problems/05/test.js

+4
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ describe('problem 05', () => {
2424
test('username prop', () => {
2525
expect(saga.username).toBe('peti')
2626
})
27+
28+
test('timestamp prop', () => {
29+
expect(typeof saga.timestamp).toBe('number')
30+
})
2731
})

problems/06/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = class Saga {
66
this.messages = new Map()
77
this.users = new Map()
88
this.username = username
9+
this.timestamp = Date.now()
910
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1011
}
1112

problems/06/solution.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = class Saga {
77
this.messages = new Map()
88
this.users = new Map()
99
this.username = username
10+
this.timestamp = Date.now()
1011
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1112
}
1213

problems/07/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = class Saga extends EventEmitter {
2222
this.messages = new Map()
2323
this.users = new Map()
2424
this.username = username
25+
this.timestamp = Date.now()
2526
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
2627
}
2728

problems/07/solution.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = class Saga extends EventEmitter {
1313
this.messages = new Map()
1414
this.users = new Map()
1515
this.username = username
16+
this.timestamp = Date.now()
1617
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1718
}
1819

problems/08/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = class Saga extends EventEmitter {
1313
this.messages = new Map()
1414
this.users = new Map()
1515
this.username = username
16+
this.timestamp = Date.now()
1617
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1718
}
1819

problems/08/solution.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = class Saga extends EventEmitter {
1313
this.messages = new Map()
1414
this.users = new Map()
1515
this.username = username
16+
this.timestamp = Date.now()
1617
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1718
}
1819

problems/09/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = class Saga extends EventEmitter {
1313
this.messages = new Map()
1414
this.users = new Map()
1515
this.username = username
16+
this.timestamp = Date.now()
1617
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1718
}
1819

@@ -29,7 +30,7 @@ module.exports = class Saga extends EventEmitter {
2930
userData: JSON.stringify({
3031
key: this.db.local.key,
3132
username: this.username,
32-
timestamp: Date.now()
33+
timestamp: this.timestamp
3334
})
3435
})
3536
}

problems/09/solution.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = class Saga extends EventEmitter {
1313
this.messages = new Map()
1414
this.users = new Map()
1515
this.username = username
16+
this.timestamp = Date.now()
1617
this.db = hyperdb(storage, key, { valueEncoding: 'json' })
1718
}
1819

@@ -29,7 +30,7 @@ module.exports = class Saga extends EventEmitter {
2930
userData: JSON.stringify({
3031
key: this.db.local.key,
3132
username: this.username,
32-
timestamp: Date.now()
33+
timestamp: this.timestamp
3334
})
3435
})
3536
}

problems/09/test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Emitter = require('events')
22
const ram = require('random-access-memory')
33
const crypto = require('hypercore-crypto')
4-
const Saga = require('./solution')
4+
const Saga = require('.')
55

66
class MockedPeer extends Emitter {
77
constructor (data) {
@@ -17,7 +17,8 @@ describe('problem 09', () => {
1717
const peerKey = keyPair.publicKey
1818
const peer = new MockedPeer({
1919
username: 'test',
20-
key: peerKey
20+
key: peerKey,
21+
timestamp: Date.now()
2122
})
2223

2324
beforeAll(() => saga.initialize())

problems/10/chat/olaf/.env.example

-2
This file was deleted.

problems/10/chat/olaf/.gitignore

-8
This file was deleted.

problems/10/chat/olaf/index.html

-12
This file was deleted.

problems/10/chat/olaf/src/lib/for-each-chunk.js

-19
This file was deleted.

problems/10/chat/olaf/src/lib/saga.js

-17
This file was deleted.

problems/10/index.js

Whitespace-only changes.

problems/10/olaf/.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#ICE_URLS=stun:localhost:3478
2+
#SIGNAL_URLS=wss://localhost:4000
66.6 KB
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
1.12 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "App",
3+
"icons": [
4+
{
5+
"src": "\/android-icon-36x36.png",
6+
"sizes": "36x36",
7+
"type": "image\/png",
8+
"density": "0.75"
9+
},
10+
{
11+
"src": "\/android-icon-48x48.png",
12+
"sizes": "48x48",
13+
"type": "image\/png",
14+
"density": "1.0"
15+
},
16+
{
17+
"src": "\/android-icon-72x72.png",
18+
"sizes": "72x72",
19+
"type": "image\/png",
20+
"density": "1.5"
21+
},
22+
{
23+
"src": "\/android-icon-96x96.png",
24+
"sizes": "96x96",
25+
"type": "image\/png",
26+
"density": "2.0"
27+
},
28+
{
29+
"src": "\/android-icon-144x144.png",
30+
"sizes": "144x144",
31+
"type": "image\/png",
32+
"density": "3.0"
33+
},
34+
{
35+
"src": "\/android-icon-192x192.png",
36+
"sizes": "192x192",
37+
"type": "image\/png",
38+
"density": "4.0"
39+
}
40+
]
41+
}

problems/10/olaf/index.html

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>Olaf chat</title>
7+
<link rel="apple-touch-icon" sizes="57x57" href="/assets/favicon/apple-icon-57x57.png">
8+
<link rel="apple-touch-icon" sizes="60x60" href="/assets/favicon/apple-icon-60x60.png">
9+
<link rel="apple-touch-icon" sizes="72x72" href="/assets/favicon/apple-icon-72x72.png">
10+
<link rel="apple-touch-icon" sizes="76x76" href="/assets/favicon/apple-icon-76x76.png">
11+
<link rel="apple-touch-icon" sizes="114x114" href="/assets/favicon/apple-icon-114x114.png">
12+
<link rel="apple-touch-icon" sizes="120x120" href="/assets/favicon/apple-icon-120x120.png">
13+
<link rel="apple-touch-icon" sizes="144x144" href="/assets/favicon/apple-icon-144x144.png">
14+
<link rel="apple-touch-icon" sizes="152x152" href="/assets/favicon/apple-icon-152x152.png">
15+
<link rel="apple-touch-icon" sizes="180x180" href="/assets/favicon/apple-icon-180x180.png">
16+
<link rel="icon" type="image/png" sizes="192x192" href="/assets/favicon/android-icon-192x192.png">
17+
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png">
18+
<link rel="icon" type="image/png" sizes="96x96" href="/assets/favicon/favicon-96x96.png">
19+
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png">
20+
<link rel="manifest" href="/manifest.webmanifest">
21+
<meta name="msapplication-TileColor" content="#ffffff">
22+
<meta name="msapplication-TileImage" content="/assets/favicon/ms-icon-144x144.png">
23+
<meta name="theme-color" content="#ffffff">
24+
<link rel="stylesheet" href="./src/index.css"/>
25+
</head>
26+
<body>
27+
<script src="./src/index.js"></script>
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)