This commit is contained in:
Cat /dev/Nulo 2023-04-30 19:08:46 -03:00
parent 2132890875
commit 8fe21c8202
14 changed files with 451 additions and 500 deletions

View file

@ -21,12 +21,11 @@
"vite-plugin-wasm": "^3.2.2"
},
"dependencies": {
"@automerge/automerge": "^2.0.3",
"@automerge/automerge-wasm": "^0.1.26",
"automerge-repo": "https://gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo?dummy-release-0.0.51-2",
"automerge-repo-network-broadcastchannel": "^0.0.50",
"automerge-repo-network-localfirstrelay": "https://gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo-network-localfirstrelay?0.0.51-dummy-release",
"automerge-repo-network-messagechannel": "^0.0.50",
"automerge-repo-storage-localforage": "^0.0.50"
"date-fns": "^2.30.0",
"nanoid": "^4.0.2",
"svelt-yjs": "^1.1.0",
"y-indexeddb": "^9.0.10",
"y-webrtc": "^10.2.5",
"yjs": "^13.6.0"
}
}

View file

@ -1,27 +1,24 @@
lockfileVersion: '6.0'
dependencies:
'@automerge/automerge':
specifier: ^2.0.3
version: 2.0.3
'@automerge/automerge-wasm':
specifier: ^0.1.26
version: 0.1.26
automerge-repo:
specifier: https://gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo?dummy-release-0.0.51-2
version: '@gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo?dummy-release-0.0.51-2(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)'
automerge-repo-network-broadcastchannel:
specifier: ^0.0.50
version: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
automerge-repo-network-localfirstrelay:
specifier: https://gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo-network-localfirstrelay?0.0.51-dummy-release
version: '@gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo-network-localfirstrelay?0.0.51-dummy-release(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)'
automerge-repo-network-messagechannel:
specifier: ^0.0.50
version: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
automerge-repo-storage-localforage:
specifier: ^0.0.50
version: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
date-fns:
specifier: ^2.30.0
version: 2.30.0
nanoid:
specifier: ^4.0.2
version: 4.0.2
svelt-yjs:
specifier: ^1.1.0
version: 1.1.0
y-indexeddb:
specifier: ^9.0.10
version: 9.0.10(yjs@13.6.0)
y-webrtc:
specifier: ^10.2.5
version: 10.2.5
yjs:
specifier: ^13.6.0
version: 13.6.0
devDependencies:
'@sveltejs/vite-plugin-svelte':
@ -44,7 +41,7 @@ devDependencies:
version: 5.0.2
vite:
specifier: ^4.3.2
version: 4.3.2(@types/node@18.16.3)
version: 4.3.2
vite-plugin-top-level-await:
specifier: ^1.3.0
version: 1.3.0(vite@4.3.2)
@ -54,70 +51,11 @@ devDependencies:
packages:
/@automerge/automerge-wasm@0.1.26:
resolution: {integrity: sha512-NLH7KpErTuy2O1VIA0uE+48e0u69o0qL8/9RZYjLd2uEZeWBzIWbhyDJGfUPDMIYXtkcy8z2H7h6YcwusG0BXA==}
dev: false
/@automerge/automerge@2.0.3:
resolution: {integrity: sha512-ihfyW/pt+bmHNmPzf4nyH9OzfowAlOaK+1XD8wbtbsJeaGL/8Kap88xMO0lU3wgrddsrZtX5uTbrB/6kMl1PEA==}
/@babel/runtime@7.21.5:
resolution: {integrity: sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==}
engines: {node: '>=6.9.0'}
dependencies:
'@automerge/automerge-wasm': 0.1.26
uuid: 9.0.0
dev: false
/@cbor-extract/cbor-extract-darwin-arm64@2.1.1:
resolution: {integrity: sha512-blVBy5MXz6m36Vx0DfLd7PChOQKEs8lK2bD1WJn/vVgG4FXZiZmZb2GECHFvVPA5T7OnODd9xZiL3nMCv6QUhA==}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@cbor-extract/cbor-extract-darwin-x64@2.1.1:
resolution: {integrity: sha512-h6KFOzqk8jXTvkOftyRIWGrd7sKQzQv2jVdTL9nKSf3D2drCvQB/LHUxAOpPXo3pv2clDtKs3xnHalpEh3rDsw==}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@cbor-extract/cbor-extract-linux-arm64@2.1.1:
resolution: {integrity: sha512-SxAaRcYf8S0QHaMc7gvRSiTSr7nUYMqbUdErBEu+HYA4Q6UNydx1VwFE68hGcp1qvxcy9yT5U7gA+a5XikfwSQ==}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@cbor-extract/cbor-extract-linux-arm@2.1.1:
resolution: {integrity: sha512-ds0uikdcIGUjPyraV4oJqyVE5gl/qYBpa/Wnh6l6xLE2lj/hwnjT2XcZCChdXwW/YFZ1LUHs6waoYN8PmK0nKQ==}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@cbor-extract/cbor-extract-linux-x64@2.1.1:
resolution: {integrity: sha512-GVK+8fNIE9lJQHAlhOROYiI0Yd4bAZ4u++C2ZjlkS3YmO6hi+FUxe6Dqm+OKWTcMpL/l71N6CQAmaRcb4zyJuA==}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@cbor-extract/cbor-extract-win32-x64@2.1.1:
resolution: {integrity: sha512-2Niq1C41dCRIDeD8LddiH+mxGlO7HJ612Ll3D/E73ZWBmycued+8ghTr/Ho3CMOWPUEr08XtyBMVXAjqF+TcKw==}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@cspotcode/source-map-support@0.8.1:
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/trace-mapping': 0.3.9
regenerator-runtime: 0.13.11
dev: false
/@esbuild/android-arm64@0.17.18:
@ -321,6 +259,7 @@ packages:
/@jridgewell/resolve-uri@3.1.0:
resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==}
engines: {node: '>=6.0.0'}
dev: true
/@jridgewell/sourcemap-codec@1.4.14:
resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==}
@ -328,6 +267,7 @@ packages:
/@jridgewell/sourcemap-codec@1.4.15:
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
dev: true
/@jridgewell/trace-mapping@0.3.18:
resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==}
@ -336,23 +276,6 @@ packages:
'@jridgewell/sourcemap-codec': 1.4.14
dev: true
/@jridgewell/trace-mapping@0.3.9:
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
dependencies:
'@jridgewell/resolve-uri': 3.1.0
'@jridgewell/sourcemap-codec': 1.4.15
dev: false
/@localfirst/relay-client@3.6.2:
resolution: {integrity: sha512-8+/2WC9EoWnhaOpAMhM1zV2IIfaac7wpiOlabb98+i56TiuqTc4vG/x9EmAfqZ57TvAt5O3NDbfiVgLGqg+FQg==}
dependencies:
cuid: 2.1.8
debug: 4.3.4
eventemitter3: 4.0.7
transitivePeerDependencies:
- supports-color
dev: false
/@nodelib/fs.scandir@2.1.5:
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@ -397,7 +320,7 @@ packages:
magic-string: 0.29.0
svelte: 3.57.0
svelte-hmr: 0.15.1(svelte@3.57.0)
vite: 4.3.2(@types/node@18.16.3)
vite: 4.3.2
vitefu: 0.2.4(vite@4.3.2)
transitivePeerDependencies:
- supports-color
@ -515,29 +438,10 @@ packages:
'@swc/core-win32-x64-msvc': 1.3.56
dev: true
/@tsconfig/node10@1.0.9:
resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==}
dev: false
/@tsconfig/node12@1.0.11:
resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
dev: false
/@tsconfig/node14@1.0.3:
resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
dev: false
/@tsconfig/node16@1.0.3:
resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==}
dev: false
/@tsconfig/svelte@4.0.1:
resolution: {integrity: sha512-B+XlGpmuAQzJqDoBATNCvEPqQg0HkO7S8pM14QDI5NsmtymzRexQ1N+nX2H6RTtFbuFgaZD4I8AAi8voGg0GLg==}
dev: true
/@types/node@18.16.3:
resolution: {integrity: sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==}
/@types/pug@2.0.6:
resolution: {integrity: sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==}
dev: true
@ -549,17 +453,6 @@ packages:
sass: 1.62.1
dev: true
/acorn-walk@8.2.0:
resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==}
engines: {node: '>=0.4.0'}
dev: false
/acorn@8.8.2:
resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: false
/anymatch@3.1.3:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
@ -568,75 +461,14 @@ packages:
picomatch: 2.3.1
dev: true
/arg@4.1.3:
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
dev: false
/automerge-repo-network-broadcastchannel@0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2):
resolution: {integrity: sha512-Ykir3B9rpDej2JulI54PjSe++EQx6BlATYt5KP5M9Uvy2EIlgv5vrrP1ozv6C5rxpsx0mby8MjaBzrWogok6KQ==}
dependencies:
automerge-repo: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
transitivePeerDependencies:
- '@automerge/automerge'
- '@swc/core'
- '@swc/wasm'
- '@types/node'
- supports-color
- typescript
dev: false
/automerge-repo-network-messagechannel@0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2):
resolution: {integrity: sha512-USUV42W7ErR2EwT8wT0DHvZBTK4a1O/nGHjvyxi55JQV8ZMlp3tNWSdtOz0dTOPpWUZLT7R6/yX2jWB2G51o6A==}
dependencies:
automerge-repo: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
transitivePeerDependencies:
- '@automerge/automerge'
- '@swc/core'
- '@swc/wasm'
- '@types/node'
- supports-color
- typescript
dev: false
/automerge-repo-storage-localforage@0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2):
resolution: {integrity: sha512-Pbs+FnTtaXWkdDCMcLeqkerfq7IHVKmko6M5OVpDEw50unt2KBM7sQhrfpFIjWwX9mIM3ZQ3DGQt2UsSPCOL5A==}
dependencies:
automerge-repo: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
localforage: 1.10.0
transitivePeerDependencies:
- '@automerge/automerge'
- '@swc/core'
- '@swc/wasm'
- '@types/node'
- supports-color
- typescript
dev: false
/automerge-repo@0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2):
resolution: {integrity: sha512-eHlZ5j7mgxSJ9MsX4Qy8pIIAWZa5+O6lOv/DA4Md35Nt0rMkacTYi7mO/QN7BR/uab9fxlenyHyA8q4yIcTX+w==}
peerDependencies:
'@automerge/automerge': '>=2.0.2'
dependencies:
'@automerge/automerge': 2.0.3
cbor-x: 1.5.2
debug: 4.3.4
eventemitter3: 4.0.7
tiny-typed-emitter: 2.1.0
ts-node: 10.9.1(@types/node@18.16.3)(typescript@5.0.2)
uuid: 8.3.2
xstate: 4.37.2
transitivePeerDependencies:
- '@swc/core'
- '@swc/wasm'
- '@types/node'
- supports-color
- typescript
dev: false
/balanced-match@1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
dev: true
/base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
dev: false
/binary-extensions@2.2.0:
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
engines: {node: '>=8'}
@ -660,33 +492,18 @@ packages:
resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}
dev: true
/buffer@6.0.3:
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
dev: false
/callsites@3.1.0:
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
engines: {node: '>=6'}
dev: true
/cbor-extract@2.1.1:
resolution: {integrity: sha512-1UX977+L+zOJHsp0mWFG13GLwO6ucKgSmSW6JTl8B9GUvACvHeIVpFqhU92299Z6PfD09aTXDell5p+lp1rUFA==}
hasBin: true
requiresBuild: true
dependencies:
node-gyp-build-optional-packages: 5.0.3
optionalDependencies:
'@cbor-extract/cbor-extract-darwin-arm64': 2.1.1
'@cbor-extract/cbor-extract-darwin-x64': 2.1.1
'@cbor-extract/cbor-extract-linux-arm': 2.1.1
'@cbor-extract/cbor-extract-linux-arm64': 2.1.1
'@cbor-extract/cbor-extract-linux-x64': 2.1.1
'@cbor-extract/cbor-extract-win32-x64': 2.1.1
dev: false
optional: true
/cbor-x@1.5.2:
resolution: {integrity: sha512-JArE6xcgj3eo13fpnShO42QFBUuXP2uG12RLeF2Nb+dJcETFYxkUa27gXQrRYp67Ahtaxyfbg+ihc62XTyQqsQ==}
optionalDependencies:
cbor-extract: 2.1.1
dev: false
/chokidar@3.5.3:
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
engines: {node: '>= 8.10.0'}
@ -706,13 +523,11 @@ packages:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true
/create-require@1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
dev: false
/cuid@2.1.8:
resolution: {integrity: sha512-xiEMER6E7TlTPnDxrM4eRiC6TRgjNX9xzEZ5U/Se2YJKr7Mq4pJn/2XEHjl3STcSh96GmkHPcBXLES8M29wyyg==}
deprecated: Cuid and other k-sortable and non-cryptographic ids (Ulid, ObjectId, KSUID, all UUIDs) are all insecure. Use @paralleldrive/cuid2 instead.
/date-fns@2.30.0:
resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==}
engines: {node: '>=0.11'}
dependencies:
'@babel/runtime': 7.21.5
dev: false
/debug@4.3.4:
@ -736,9 +551,8 @@ packages:
engines: {node: '>=8'}
dev: true
/diff@4.0.2:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
/err-code@3.0.1:
resolution: {integrity: sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==}
dev: false
/es6-promise@3.3.1:
@ -775,10 +589,6 @@ packages:
'@esbuild/win32-x64': 0.17.18
dev: true
/eventemitter3@4.0.7:
resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
dev: false
/fast-glob@3.2.12:
resolution: {integrity: sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==}
engines: {node: '>=8.6.0'}
@ -815,6 +625,10 @@ packages:
dev: true
optional: true
/get-browser-rtc@1.1.0:
resolution: {integrity: sha512-MghbMJ61EJrRsDe7w1Bvqt3ZsBuqhce5nrn/XAwgwOXhcsz53/ltdxOse1h/8eKXj5slzxdsz56g5rzOFSGwfQ==}
dev: false
/glob-parent@5.1.2:
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
engines: {node: '>= 6'}
@ -837,8 +651,8 @@ packages:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
dev: true
/immediate@3.0.6:
resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==}
/ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
dev: false
/immutable@4.3.0:
@ -862,7 +676,6 @@ packages:
/inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
dev: true
/is-binary-path@2.1.0:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
@ -888,21 +701,21 @@ packages:
engines: {node: '>=0.12.0'}
dev: true
/isomorphic.js@0.2.5:
resolution: {integrity: sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==}
dev: false
/kleur@4.1.5:
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
engines: {node: '>=6'}
dev: true
/lie@3.1.1:
resolution: {integrity: sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==}
/lib0@0.2.74:
resolution: {integrity: sha512-roj9i46/JwG5ik5KNTkxP2IytlnrssAkD/OhlAVtE+GqectrdkfR+pttszVLrOzMDeXNs1MPt6yo66MUolWSiA==}
engines: {node: '>=14'}
hasBin: true
dependencies:
immediate: 3.0.6
dev: false
/localforage@1.10.0:
resolution: {integrity: sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==}
dependencies:
lie: 3.1.1
isomorphic.js: 0.2.5
dev: false
/magic-string@0.25.9:
@ -918,10 +731,6 @@ packages:
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
/make-error@1.3.6:
resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
dev: false
/merge2@1.4.1:
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
engines: {node: '>= 8'}
@ -971,11 +780,11 @@ packages:
hasBin: true
dev: true
/node-gyp-build-optional-packages@5.0.3:
resolution: {integrity: sha512-k75jcVzk5wnnc/FMxsf4udAoTEUv2jY3ycfdSd3yWu6Cnd1oee6/CfZJApyscA4FJOmdoixWwiwOyf16RzD5JA==}
/nanoid@4.0.2:
resolution: {integrity: sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==}
engines: {node: ^14 || ^16 || >=18}
hasBin: true
dev: false
optional: true
/normalize-path@3.0.0:
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
@ -1020,7 +829,21 @@ packages:
/queue-microtask@1.2.3:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
dev: true
/randombytes@2.1.0:
resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}
dependencies:
safe-buffer: 5.2.1
dev: false
/readable-stream@3.6.2:
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
engines: {node: '>= 6'}
dependencies:
inherits: 2.0.4
string_decoder: 1.3.0
util-deprecate: 1.0.2
dev: false
/readdirp@3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
@ -1029,6 +852,10 @@ packages:
picomatch: 2.3.1
dev: true
/regenerator-runtime@0.13.11:
resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==}
dev: false
/resolve-from@4.0.0:
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'}
@ -1067,6 +894,10 @@ packages:
mri: 1.2.0
dev: true
/safe-buffer@5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false
/sander@0.5.1:
resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==}
dependencies:
@ -1086,6 +917,20 @@ packages:
source-map-js: 1.0.2
dev: true
/simple-peer@9.11.1:
resolution: {integrity: sha512-D1SaWpOW8afq1CZGWB8xTfrT3FekjQmPValrqncJMX7QFl8YwhrPTZvMCANLtgBwwdS+7zURyqxDDEmY558tTw==}
dependencies:
buffer: 6.0.3
debug: 4.3.4
err-code: 3.0.1
get-browser-rtc: 1.1.0
queue-microtask: 1.2.3
randombytes: 2.1.0
readable-stream: 3.6.2
transitivePeerDependencies:
- supports-color
dev: false
/sorcery@0.10.0:
resolution: {integrity: sha512-R5ocFmKZQFfSTstfOtHjJuAwbpGyf9qjQa1egyhvXSbM7emjrtLXtGdZsDJDABC85YBfVvrOiGWKSYXPKdvP1g==}
hasBin: true
@ -1106,6 +951,12 @@ packages:
deprecated: Please use @jridgewell/sourcemap-codec instead
dev: true
/string_decoder@1.3.0:
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
dependencies:
safe-buffer: 5.2.1
dev: false
/strip-indent@3.0.0:
resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==}
engines: {node: '>=8'}
@ -1113,6 +964,14 @@ packages:
min-indent: 1.0.1
dev: true
/svelt-yjs@1.1.0:
resolution: {integrity: sha512-2cG19yT1/j3INP19TilDw8H3oyznCC1dyickRnfgs0Ecpdoa7y2yAQ21/7Qihy4m2OArxZRIaX1hmbMyYItFeA==}
engines: {node: '>= 10.0'}
dependencies:
tslib: 2.0.3
yjs: 13.6.0
dev: false
/svelte-check@2.10.3(svelte@3.57.0):
resolution: {integrity: sha512-Nt1aWHTOKFReBpmJ1vPug0aGysqPwJh2seM1OvICfM2oeyaA62mOiy5EvkXhltGfhCcIQcq2LoE0l1CwcWPjlw==}
hasBin: true
@ -1206,10 +1065,6 @@ packages:
engines: {node: '>= 8'}
dev: true
/tiny-typed-emitter@2.1.0:
resolution: {integrity: sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==}
dev: false
/to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@ -1217,35 +1072,8 @@ packages:
is-number: 7.0.0
dev: true
/ts-node@10.9.1(@types/node@18.16.3)(typescript@5.0.2):
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
hasBin: true
peerDependencies:
'@swc/core': '>=1.2.50'
'@swc/wasm': '>=1.2.50'
'@types/node': '*'
typescript: '>=2.7'
peerDependenciesMeta:
'@swc/core':
optional: true
'@swc/wasm':
optional: true
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.3
'@types/node': 18.16.3
acorn: 8.8.2
acorn-walk: 8.2.0
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.0.2
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
/tslib@2.0.3:
resolution: {integrity: sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==}
dev: false
/tslib@2.5.0:
@ -1256,19 +1084,16 @@ packages:
resolution: {integrity: sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==}
engines: {node: '>=12.20'}
hasBin: true
dev: true
/uuid@8.3.2:
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
hasBin: true
/util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
dev: false
/uuid@9.0.0:
resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
hasBin: true
/v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
dev: false
dev: true
/vite-plugin-top-level-await@1.3.0(vite@4.3.2):
resolution: {integrity: sha512-owIfsgWudMlQODWJSwp0sQB3AZZu3qsMygeBjZy8CyjEk6OB9AGd8lHqmgwrcEqgvy9N58lYxSBLVk3/4ejEiA==}
@ -1278,7 +1103,7 @@ packages:
'@rollup/plugin-virtual': 3.0.1
'@swc/core': 1.3.56
uuid: 9.0.0
vite: 4.3.2(@types/node@18.16.3)
vite: 4.3.2
transitivePeerDependencies:
- '@swc/helpers'
- rollup
@ -1289,10 +1114,10 @@ packages:
peerDependencies:
vite: ^2 || ^3 || ^4
dependencies:
vite: 4.3.2(@types/node@18.16.3)
vite: 4.3.2
dev: true
/vite@4.3.2(@types/node@18.16.3):
/vite@4.3.2:
resolution: {integrity: sha512-9R53Mf+TBoXCYejcL+qFbZde+eZveQLDYd9XgULILLC1a5ZwPaqgmdVpL8/uvw2BM/1TzetWjglwm+3RO+xTyw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
@ -1317,7 +1142,6 @@ packages:
terser:
optional: true
dependencies:
'@types/node': 18.16.3
esbuild: 0.17.18
postcss: 8.4.23
rollup: 3.21.1
@ -1333,59 +1157,62 @@ packages:
vite:
optional: true
dependencies:
vite: 4.3.2(@types/node@18.16.3)
vite: 4.3.2
dev: true
/wrappy@1.0.2:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
dev: true
/xstate@4.37.2:
resolution: {integrity: sha512-Qm337O49CRTZ3PRyRuK6b+kvI+D3JGxXIZCTul+xEsyFCVkTFDt5jixaL1nBWcUBcaTQ9um/5CRGVItPi7fveg==}
dev: false
/yn@3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}
dev: false
'@gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo-network-localfirstrelay?0.0.51-dummy-release(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)':
resolution: {tarball: https://gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo-network-localfirstrelay?0.0.51-dummy-release}
id: '@gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo-network-localfirstrelay?0.0.51-dummy-release'
name: automerge-repo-network-localfirstrelay
version: 0.0.50
dependencies:
'@localfirst/relay-client': 3.6.2
automerge-repo: 0.0.50(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)
transitivePeerDependencies:
- '@automerge/automerge'
- '@swc/core'
- '@swc/wasm'
- '@types/node'
- supports-color
- typescript
dev: false
'@gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo?dummy-release-0.0.51-2(@automerge/automerge@2.0.3)(@types/node@18.16.3)(typescript@5.0.2)':
resolution: {tarball: https://gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo?dummy-release-0.0.51-2}
id: '@gitpkg.now.sh/onsetsoftware/automerge-repo/packages/automerge-repo?dummy-release-0.0.51-2'
name: automerge-repo
version: 0.0.50
/ws@7.5.9:
resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==}
engines: {node: '>=8.3.0'}
requiresBuild: true
peerDependencies:
'@automerge/automerge': ^2.0.3
dependencies:
'@automerge/automerge': 2.0.3
cbor-x: 1.5.2
debug: 4.3.4
eventemitter3: 4.0.7
tiny-typed-emitter: 2.1.0
ts-node: 10.9.1(@types/node@18.16.3)(typescript@5.0.2)
uuid: 8.3.2
xstate: 4.37.2
transitivePeerDependencies:
- '@swc/core'
- '@swc/wasm'
- '@types/node'
- supports-color
- typescript
bufferutil: ^4.0.1
utf-8-validate: ^5.0.2
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
dev: false
optional: true
/y-indexeddb@9.0.10(yjs@13.6.0):
resolution: {integrity: sha512-Tz4IzLZ20Pe8LTjXU125k2+7caERsX4ANsrjskHMm3yXUX4v9kBga/kK7ctT05P0uAj+glQComkAglY1qey7zg==}
peerDependencies:
yjs: ^13.0.0
dependencies:
lib0: 0.2.74
yjs: 13.6.0
dev: false
/y-protocols@1.0.5:
resolution: {integrity: sha512-Wil92b7cGk712lRHDqS4T90IczF6RkcvCwAD0A2OPg+adKmOe+nOiT/N2hvpQIWS3zfjmtL4CPaH5sIW1Hkm/A==}
dependencies:
lib0: 0.2.74
dev: false
/y-webrtc@10.2.5:
resolution: {integrity: sha512-ZyBNvTI5L28sQ2PQI0T/JvyWgvuTq05L21vGkIlcvNLNSJqAaLCBJRe3FHEqXoaogqWmRcEAKGfII4ErNXMnNw==}
engines: {node: '>=12'}
hasBin: true
dependencies:
lib0: 0.2.74
simple-peer: 9.11.1
y-protocols: 1.0.5
optionalDependencies:
ws: 7.5.9
transitivePeerDependencies:
- bufferutil
- supports-color
- utf-8-validate
dev: false
/yjs@13.6.0:
resolution: {integrity: sha512-tFZtuQV6XamtDa9SfZhUsxchUcTBWe7fzpo1UWZDLXGejTZ5t9MCswGYzyvq7+BDzfEc9oX54QEbzI/4NyS6+g==}
engines: {node: '>=16.0.0', npm: '>=8.0.0'}
dependencies:
lib0: 0.2.74
dev: false

View file

@ -1,22 +1,33 @@
<script lang="ts">
import { setContextRepo } from "./automerge-repo-svelte";
import { repo } from "./repo";
import * as Y from "yjs";
import { createUser, getUserY, type UserIdentifier } from "./doc";
import Doing from "./lib/Doing.svelte";
import Others from "./lib/Others.svelte";
import Amigxs from "./lib/Amigxs.svelte";
setContextRepo(repo);
let rootDocId = localStorage.rootDocId;
if (!rootDocId) {
const handle = repo.create();
localStorage.rootDocId = rootDocId = handle.documentId;
let myUser =
localStorage.myUser && (JSON.parse(localStorage.myUser) as UserIdentifier);
if (!myUser) {
myUser = createUser();
localStorage.myUser = JSON.stringify(myUser);
}
</script>
<main>
<div class="card">
<Doing documentId={rootDocId} />
<Others />
</div>
<div class="card">
<Doing user={myUser} />
</div>
</main>
<h2>Amigxs</h2>
<Amigxs {myUser} />
<style>
main {
display: flex;
min-height: 100vh;
}
</style>

View file

@ -1,38 +0,0 @@
import type { Doc, ChangeFn } from "@automerge/automerge";
import { setContext, getContext } from "svelte";
import { writable, type Readable, readable } from "svelte/store";
import {
Repo,
type DocumentId,
type DocHandlePatchPayload,
} from "automerge-repo";
const ContextRepoKey = Symbol("svelte-context-automerge-repo");
export function getContextRepo(): Repo {
return getContext<Repo>(ContextRepoKey);
}
export function setContextRepo(repo: Repo) {
setContext(ContextRepoKey, repo);
}
export function document<T>(documentId: DocumentId) {
const repo = getContextRepo();
const handle = repo.find<T>(documentId);
const { subscribe } = readable<Doc<T>>(null, (set) => {
const onPatch = (h: DocHandlePatchPayload<T>) => {
set(h.after);
};
handle.addListener("patch", onPatch);
return () => handle.removeListener("patch", onPatch);
});
return {
subscribe,
change: (fn: ChangeFn<T>) => {
handle.change(fn);
},
};
}

84
src/doc.ts Normal file
View file

@ -0,0 +1,84 @@
import * as Y from "yjs";
import { WebrtcProvider } from "y-webrtc";
import { IndexeddbPersistence } from "y-indexeddb";
import { nanoid } from "nanoid";
export type UserIdentifier = {
room: string;
password: string;
};
export type UserY = {
ydoc: Y.Doc;
webrtcProvider: WebrtcProvider;
};
export function createUser(): UserIdentifier {
return {
room: nanoid(),
password: nanoid(),
};
}
export function parseUser(id: string): UserIdentifier {
const [room, password] = id.split(";");
return { room, password };
}
// when creating a webrtc provider for a second time in the same room, it freaks out.
// cache the previous doc and return that instead
let userYCache: { [key: string]: UserY } = {};
window.userYCache = userYCache;
const credsReq = fetch(
"https://nulo.metered.live/api/v1/turn/credentials?apiKey=205de2914a8564e2efa19a7d7f299a95e574"
).then((res) => res.json());
export function getUserY(world: UserIdentifier): UserY {
if (userYCache[world.room]) return userYCache[world.room];
const ydoc = new Y.Doc();
const provider = new WebrtcProvider(world.room, ydoc, {
password: world.password,
signaling: [
"wss://webrtc-signaling.schreiben.nulo.ar",
"wss://y-webrtc-eu.fly.dev",
// "wss://signaling.yjs.dev",
// "wss://y-webrtc-signaling-eu.herokuapp.com",
// "wss://y-webrtc-signaling-us.herokuapp.com",
],
});
credsReq.then((iceServers) => {
// change the default for future connections
provider.peerOpts.config = { iceServers };
if (!provider.room?.webrtcConns) return;
// change the configuration in current connections
for (const conn of provider.room?.webrtcConns?.values()) {
const pc: RTCPeerConnection = conn.peer._pc;
pc.setConfiguration({
iceServers,
});
}
});
const idbProvider = new IndexeddbPersistence(world.room, ydoc);
const worldY = { ydoc, webrtcProvider: provider };
userYCache[world.room] = worldY;
return worldY;
}
// export function getWorldPage(ydoc: Y.Doc, pageId: string): Y.XmlFragment {
// return ydoc.getXmlFragment(`page/${pageId}`);
// }
export type Doing = {
description: string;
started: number;
};
export type Done = {
description: string;
started: number;
took: number;
};
export function getData(userY: UserY) {
const ydoing: Y.Array<Doing> = userY.ydoc.getArray("doing");
const ydone: Y.Array<Done> = userY.ydoc.getArray("done");
return { ydoing, ydone };
}

33
src/lib/Amigxs.svelte Normal file
View file

@ -0,0 +1,33 @@
<script lang="ts">
import { parseUser, type UserIdentifier } from "../doc";
import friends from "./stores/friends";
export let myUser: UserIdentifier;
function add(
event: Event & { readonly submitter: HTMLElement } & {
currentTarget: EventTarget & HTMLFormElement;
}
) {
const idString: string = event.currentTarget.idd.value;
const id = parseUser(idString);
$friends = [...$friends, id];
event.currentTarget.idd.value = "";
}
$: id = `${myUser.room};${myUser.password}`;
const copiar = () => navigator.clipboard.writeText(id);
</script>
<button on:click={copiar}>copiar tu id</button>
<form on:submit|preventDefault={add}>
<input name="idd" type="text" placeholder="id" />
<button>añadir</button>
</form>
<ul>
{#each $friends as friend}
<li>{friend.room}</li>
{/each}
</ul>

View file

@ -1,10 +0,0 @@
<script lang="ts">
let count: number = 0
const increment = () => {
count += 1
}
</script>
<button on:click={increment}>
count is {count}
</button>

View file

@ -1,43 +1,47 @@
<script lang="ts">
import { type DocumentId } from "automerge-repo";
import { document } from "../automerge-repo-svelte";
import * as Y from "yjs";
import { getData, getUserY, type UserIdentifier } from "../doc";
import { readableArray } from "svelt-yjs/src/main";
import {
formatDuration,
intervalToDuration,
formatDistance,
formatDistanceStrict,
} from "date-fns";
import timer from "./timer";
export let documentId: DocumentId;
export let user: UserIdentifier;
$: userY = getUserY(user);
$: ({ ydoing, ydone } = getData(userY));
$: doing = readableArray(ydoing);
$: done = readableArray(ydone);
$: sortedDone = $done.sort((a, b) => b.started - a.started);
interface Person {
doing?: {
description: string;
started: number;
}[];
done?: {
description: string;
started: number;
finished: number;
}[];
}
const doc = document<Person>(documentId);
const start = (description: string) => {
doc.change((p) => {
if (!p.doing) (p as Person).doing = [];
p.doing.insertAt(0, { description, started: new Date().getTime() });
});
doing.y.insert(0, [{ description, started: new Date().getTime() }]);
};
const finish = (index: number) => {
doc.change((p) => {
const thing = p.doing[index];
p.doing.deleteAt(index);
if (!p.done) (p as Person).done = [];
p.done.push({ ...thing, finished: new Date().getTime() });
});
const thing = doing.y.get(index);
doing.y.delete(index);
done.y.push([{ ...thing, took: new Date().getTime() - thing.started }]);
};
$: console.debug($doc?.doing[0]);
const sTimer = timer(1000);
</script>
{#if $doc?.doing?.length > 0}
{#each $doc.doing as doing, index}
{#if $doing.length > 0}
{#each $doing as doing, index}
<div>
<span>{doing.description} </span>
<button on:click={() => finish(index)}>Terminar</button>
<div>
<span>{doing.description} </span>
<button on:click={() => finish(index)}>Terminar</button>
</div>
<div>
{formatDuration(
intervalToDuration({ start: $sTimer, end: new Date(doing.started) })
)}
</div>
</div>
{/each}
{:else}
@ -49,11 +53,18 @@
</form>
{/if}
{#if $doc?.done?.length > 0}
{#if $done.length > 0}
<h2>Ya hecho</h2>
<ul>
{#each $doc?.done as thing}
<li>{thing.description}</li>
{#each sortedDone as thing}
<li>
{thing.description}
({formatDistance(
new Date(thing.took + thing.started),
new Date(thing.started)
)})
</li>
{/each}
</ul>
{/if}

46
src/lib/Others.svelte Normal file
View file

@ -0,0 +1,46 @@
<script lang="ts">
import { readableArray } from "svelt-yjs/src/main";
import { getData, getUserY, type Doing } from "../doc";
import { derived } from "svelte/store";
import timer from "./timer";
import { intervalToDuration } from "date-fns";
import friends from "./stores/friends";
import formatDistanceShort from "./helpers/formatDistanceShort";
$: users = $friends
.map((id) => ({ id, ...getUserY(id) }))
.map((y) => ({ ...y, ...getData(y) }));
$: allDoing =
users &&
derived(
users.map((y) => readableArray(y.ydoing)),
(doings, set: (value: { name: string; $d: Doing[] }[]) => void) => {
set(doings.map(($d, i) => ({ name: users[i].id.room, $d })));
}
);
// $: done = readableArray(ydone);
// $: sortedDone = $done.sort((a, b) => b.started - a.started);
const sTimer = timer(1000);
</script>
{#if allDoing}
<ul>
{#each $allDoing as doing}
{#if doing.$d.length > 0}
<li>
<strong>{doing.name}</strong>
{#each doing.$d as d, i}
{#if i !== 0} y {/if}
{d.description}
hace
{formatDistanceShort(
intervalToDuration({ start: $sTimer, end: new Date(d.started) })
)}
{/each}
</li>
{/if}
{/each}
</ul>
{/if}

View file

@ -0,0 +1,21 @@
import { formatDuration } from "date-fns";
// https://github.com/date-fns/date-fns/issues/2134#issuecomment-788212525
const formatDistanceLocale = {
xSeconds: "{{count}}s",
xMinutes: "{{count}}m",
xHours: "{{count}}h",
};
const shortEnLocale = {
formatDistance: (
/** @type {string | number} */ token,
/** @type {any} */ count
) => formatDistanceLocale[token].replace("{{count}}", count),
};
export default (/** @type {Duration} */ duration) => {
return formatDuration(duration, {
format: ["hours", "minutes", "seconds"],
locale: shortEnLocale,
});
};

11
src/lib/stores/friends.ts Normal file
View file

@ -0,0 +1,11 @@
import { writable } from "svelte/store";
import type { UserIdentifier } from "../../doc";
type Type = UserIdentifier[];
const start: Type = JSON.parse(localStorage.friends || "[]");
const save = (v: Type) => (localStorage.friends = JSON.stringify(v));
const store = writable(start);
store.subscribe(save);
export default store;

13
src/lib/timer.ts Normal file
View file

@ -0,0 +1,13 @@
import { type Readable } from "svelte/store";
export default (every: number): Readable<Date> => {
return {
subscribe(run) {
const cb = () => {
run(new Date());
};
const interval = setInterval(cb, every);
cb();
return () => clearInterval(interval);
},
};
};

View file

@ -1,15 +0,0 @@
import { Repo } from "automerge-repo";
import { BroadcastChannelNetworkAdapter } from "automerge-repo-network-broadcastchannel";
import { LocalForageStorageAdapter } from "automerge-repo-storage-localforage";
import { LocalFirstRelayNetworkAdapter } from "automerge-repo-network-localfirstrelay/src/index";
// import { MessageChannelNetworkAdapter } from "automerge-repo-network-messagechannel";
export const repo = new Repo({
network: [
// new MessageChannelNetworkAdapter(),
new BroadcastChannelNetworkAdapter(),
new LocalFirstRelayNetworkAdapter("wss://localfirstrelay.nulo.ar"),
// new BrowserWebSocketClientAdapter("ws://localhost:3030"),
],
storage: new LocalForageStorageAdapter(),
});

View file

@ -1,42 +0,0 @@
import { syncedStore, getYjsDoc } from "@syncedstore/core";
import { WebrtcProvider } from "y-webrtc";
import { svelteSyncedStore } from "@syncedstore/svelte";
import { IndexeddbPersistence } from "y-indexeddb";
type DoingThing = { description: string; start: number };
export const synced = syncedStore<{
doing: { thing?: DoingThing };
}>({ doing: {} });
export const store = svelteSyncedStore(synced);
// Get the Yjs document and sync automatically using y-webrtc
const doc = getYjsDoc(synced);
// setup p2p
const credsReq = fetch(
"https://nulo.metered.live/api/v1/turn/credentials?apiKey=205de2914a8564e2efa19a7d7f299a95e574"
).then((res) => res.json());
const docId = "uwjwifsighsglks";
const webrtcProvider = new WebrtcProvider(docId, doc, {
signaling: [
"wss://webrtc-signaling.schreiben.nulo.ar",
"wss://y-webrtc-eu.fly.dev",
],
});
credsReq.then((iceServers) => {
// change the default for future connections
webrtcProvider.peerOpts.config = { iceServers };
if (!webrtcProvider.room?.webrtcConns) return;
// change the configuration in current connections
for (const conn of webrtcProvider.room?.webrtcConns?.values()) {
const pc: RTCPeerConnection = conn.peer._pc;
pc.setConfiguration({
iceServers,
});
}
});
const idbProvider = new IndexeddbPersistence(docId, doc);