Skip to content

Commit

Permalink
🔨🐛 improve code; fix example bugs (guest-shareds)
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 408cc3ff8e9c6db847ffd62fc6ccded5e9c81cb5
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 14:57:35 2022 -0500

    fix example stickies

commit 68ce49f94905b4cae9027daa0be2fca2344716d4
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 14:53:24 2022 -0500

    fix e4_sound_board

commit 12d9f0eac8dca4bc858804eb51ba1eb379d9bde2
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 14:47:46 2022 -0500

    update todo

commit 08d53d5236fff4125d01dabae6deb905c4e11bf2
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 14:46:24 2022 -0500

    improve drag and tanks examples

commit a43c9db4610be399ee688d125170b31ec0e8d7e9
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 11:14:46 2022 -0500

    change #debug to #info
    avoid conflict with notes regex

commit 466466adac0e65583b8fc344b16e5936351d0eff
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 11:13:03 2022 -0500

    update todos

commit 4435d7098431f82d9e573c43cb6335aaf9ec27ca
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 11:12:53 2022 -0500

    suppress warn logs on tests

commit 20058a33fb33c842f3b339a78c4b56cfc13cd280
Author: Justin Bakse <justin@tsfim.com>
Date:   Thu Aug 4 11:12:23 2022 -0500

    fix tank example markup

commit e8b9069812417699c549a01ddaae2aa80733f568
Author: Justin Bakse <justin@tsfim.com>
Date:   Tue Jun 28 14:54:36 2022 -0500

    clean up room

commit 245333b7bed67ae7142f67c64e267dc716dba1d3
Author: Justin Bakse <justin@tsfim.com>
Date:   Tue Jun 28 13:50:04 2022 -0500

    cleaning up comment notes

commit c0b75a237673b033eb17886099c4b186b1eb9b0f
Author: Justin Bakse <justin@tsfim.com>
Date:   Tue Jun 28 13:29:49 2022 -0500

    improve room connect flow

commit 248d60f8b00fe10ed6ae3f49497c320a675ffd3e
Author: Justin Bakse <justin@tsfim.com>
Date:   Sun Jun 12 21:54:04 2022 -0500

    code cleanup

commit 521a987931239d30584d0cd83edde85a1680e700
Author: Justin Bakse <justin@tsfim.com>
Date:   Sat Jun 11 21:27:37 2022 -0500

    new when*
  • Loading branch information
jbakse committed Aug 4, 2022
1 parent cdc5232 commit 236b2ef
Show file tree
Hide file tree
Showing 46 changed files with 477 additions and 1,037 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -17,10 +17,10 @@

Test Coverage:

![Statements](https://img.shields.io/badge/statements-99.62%25-brightgreen.svg?style=flat)
![Branches](https://img.shields.io/badge/branches-94.21%25-brightgreen.svg?style=flat)
![Functions](https://img.shields.io/badge/functions-97.91%25-brightgreen.svg?style=flat)
![Lines](https://img.shields.io/badge/lines-99.59%25-brightgreen.svg?style=flat)
![Statements](https://img.shields.io/badge/statements-98.26%25-brightgreen.svg?style=flat)
![Branches](https://img.shields.io/badge/branches-92.03%25-brightgreen.svg?style=flat)
![Functions](https://img.shields.io/badge/functions-96.55%25-brightgreen.svg?style=flat)
![Lines](https://img.shields.io/badge/lines-98.12%25-brightgreen.svg?style=flat)

</div>

Expand Down
16 changes: 15 additions & 1 deletion notes/how_to.md
@@ -1,8 +1,22 @@
# How to run local dev

1. `npm run start` to build/watch/rebuild
2. use VS Code / Live Server to open examples in browser

# How to run tests

1. `npm run serve` to start local version of the server (leave running)
2. `npm run test` to run the test suite
-or-
3. `npm run serve` to start local version of the server (leave running)
4. run tests from VS Code interface with `Jest` extension

# How To Release a new Version of p5.Party

Releases are automated using `np`.

1. Make sure the code is working.
1. Make sure local ds server is running so tests can run.
1. Make sure your working directory is clean.
1. Make sure your commits are pushed.
1. Make sure you are up to date with origin.
Expand All @@ -11,7 +25,7 @@ Releases are automated using `np`.
1. Enter one-time password from Duo Mobile
1. Browser should open github release page
1. Enter name for release (or leave blank to use release number)
1. Attach p5.party.zip (generated by build in your working directory)
1. ~~Attach p5.party.zip (generated by build in your working directory)~~
1. Check pre-release checkbox
1. Click "publish"

Expand Down
77 changes: 50 additions & 27 deletions notes/newTodo.todo
@@ -1,6 +1,12 @@
□ something to consider:
✓ does resolved promise resolve again immediately if waited on again? (a: yes) @done(22-06-27 11:14)
✓ if so, we could cache the load() promise on the object and use that for a better when ready/loaded. @done(22-06-27 11:14)
✓ though that might mean some wrapping code in the method @done(22-06-27 11:14)
✓ move the load call into the constructor? @done(22-08-04 12:33)

Docs:
make note about empty {} not being in guests[]
if you want everyone to be in there as soon as they connect, add a placehold prop `partyGetMyShared({placeholder: true})`
make note about empty {} not being in guests[] @done(22-06-27 11:38)
if you want everyone to be in there as soon as they connect, add a placehold prop `partyGetMyShared({placeholder: true})` @done(22-06-27 11:38)

Restore Features:
✓ test p5.party loading callbacks @done(22-06-01 21:04)
Expand All @@ -10,55 +16,72 @@ Docs:
✓ partyLoadGuestShareds(); @done(22-06-03 11:18)
✓ partyWatchShared() @done(22-06-06 14:50)
✓ partyEmit() partySubscribe() @done(22-06-06 14:59)
□ ? partyToggleInfo() - panel


✓ pong example doesn't work because guests[] doesn't contain the same object as me. (it has a different copy of the record/shared object) @done(22-06-07 21:55)
✓ D12 is breaking for same reason! @done(22-06-07 21:55)

✓ ghosts does not work because guests[].length can't be used to determine join order any more. (can be fixed by putting a property on getMyShared()) @done(22-06-07 21:55)

Code Review:
□ check what is public/private
□ order class members (is there an extension for this)
□ hacky #updateGuestShareds
instead of current hacky #updateGuestShareds, maybe try keeping
two arrays: `#guestShareds` and `#nonemptyGuestShareds`
✓ check what is public/private @done(22-08-04 12:44)


Intermission:
□ check test coverage
□ compare SLOC
□ compare export size (try more modern es version target?)
□ extension is "better comments" better than "highlight"
□ extensions: is "better comments" better than "highlight"?

Deploy:
□ create a branch for 0.7
□ add student credit to readme
□ bump tsc version, remove ts suffix in code
□ squash tsc to main
□ push to github, verify netlify
□ release
✓ add student credit to readme @done(22-06-08 12:42)
✓ bump tsc version, remove ts suffix in code @done(22-06-08 12:42)
✓ squash tsc to main @done(22-06-08 12:42)
✓ push to github, verify netlify @done(22-06-08 12:42)
✓ release @done(22-06-08 12:42)


Examples:
move multifile examples to modules
remove bad examples (tanks 1, drag 1)
move multifile examples to modules @done(22-08-04 14:46)
remove bad examples (tanks 1, drag 1) @done(22-08-04 14:46)
✓ remove ! examples @done(22-06-07 13:05)
✓ fix live server injecting into html displayed on example pages? @done(22-06-07 21:59)

□ e3_sign_up example puts input field at bottom of page
□ callbacks example puts button at bottom of page

Clean up:
✓ remove .js files @done(22-06-06 23:37)
✓ remove old dev deps @done(22-06-06 23:37)
✓ update npm scripts now that js dev deps are gone @done(22-06-07 11:14)

□ clean up branches (merge + remove feature branches)

Add Features:

Priority Features:
□ overwrite on reopening room
partyLoadShared takes an initobject which is only used if the record doesn't exist yet. Might be better to set default to overwriting record contents if connector is host?
partyLoadShared takes an initobject which is only used if the record doesn't exist yet. Might be better to set default to overwriting record contents if connector is host? Or some way to signal you want this? a `resetEmptyRoom` flag or call.
Currently i find i'm more likely to use setup()->partyIsHost->partySetShared thanthe initobject. the init object just isn't more convient (which was the point!)


Possible Features:
□ allow early calls to Record initData, setData, watchShared, delete
these currently expect the dsRecord to be ready and fail if not
they could wait for whenLoaded() instead with a little refactoring
wait until need is demonstrated

□ show warning or error on writes to "owned" records
it is generally a good practice to only read from `guests` array
and write to only `my`
though sometimes, with careful planning, it is alright to violate this general practice
□ consider allowing but warning when this practice is violated
□ consider erroring when this practice is violated (locked `guests`)
□ consider allowing user to mark owner of shared objects and enforce with warnings or errors

□ "owned" record warnings/errors
□ actually, it might be best to just make guests[] locked
□ record tracking, garbage collect, room reset
□ room.deleteRecord
□ tsc javadocs?
currently all server records for named shared objects are leaked
p5.party does not maintan list of records created
user records and guest records are not deleted automatically (unless the server restarts)
there is no way to manually delete a record
□ create room.deleteRecord

□ tsc javadocs

□ restore partyToggleInfo() - panel
the earlier version of p5.party had an info panel that showed who was connected and who was host, maybe restore it?
15 changes: 5 additions & 10 deletions notes/todo.todo
Expand Up @@ -34,12 +34,9 @@ Shared objects:


Records:
☐ records leak
currently all server records are leaked.
there are no lists of records created
user records and guest records are not deleted (unless the server restarts)

☐ clear room/app records

☐ api to clear room/app records
Would be useful in normal, emergency, and dev situations.
Having stale data stick around can be confusing reloading a js program usually restarts it from 0, but not when you have data hanging out on the back end.
pattern: `setup->if host->reset room->init room`
Expand Down Expand Up @@ -103,12 +100,10 @@ Emit Subscribe:


Release Package:
☐ provide min and unmin versions?
compare to other p5 libraries
https://stackoverflow.com/questions/25956937/how-to-build-minified-and-uncompressed-bundle-with-webpack
☐ Should the examples be distributed in the zip?
☐ Should the zip even be distributed?
☐ provide min and unmin versions, include them in the release resources



Examples:

☐ Div Cursors Example
Expand Down
4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -38,10 +38,8 @@
"prebuild": "npm run genversion",
"build": "npm run esbuild -- --outfile=dist/p5.party.js",
"prerelease": "npm run build",
"prepublishOnly": "npm run build && npm run zip",
"prepublishOnly": "npm run build",
"postpublish": "curl https://purge.jsdelivr.net/npm/p5.party@latest/dist/p5.party.js",
"prezip": "rm -f p5.party.zip",
"zip": "npm run build && ln -s public/examples && zip p5.party.zip -r dist -r examples && rm -r examples && unzip -l p5.party.zip",
"genversion": "genversion --es6 --semi version.js",
"esbuild": "esbuild src/p5.party.ts --bundle --sourcemap --minify --target=es6 --define:global=window --inject:esbuild.inject.js"
},
Expand Down
1 change: 1 addition & 0 deletions public/examples/d12/index.js
Expand Up @@ -333,6 +333,7 @@ function keyPressed() {
if (inputMode === "move") {
if (key === " " || keyCode === RETURN) {
startMessageOnRelease = true;
return false;
}
if (key === "q") {
me.avatarId = ++me.avatarId % 16;
Expand Down
File renamed without changes.
@@ -1,4 +1,4 @@
# drag2
# drag

Some little squres to drag around.

Expand Down
File renamed without changes.
Expand Up @@ -29,6 +29,7 @@ window.draw = () => {

window.mousePressed = () => {
// abort if any sprites are already in drag
// this requires players to take turns with dragging
if (shared.sprites.find((s) => s.inDrag)) return;

for (const s of shared.sprites.slice().reverse()) {
Expand Down
File renamed without changes.
11 changes: 0 additions & 11 deletions public/examples/drag_1/README.md

This file was deleted.

90 changes: 0 additions & 90 deletions public/examples/drag_1/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions public/examples/drag_2/.eslintrc.js

This file was deleted.

23 changes: 0 additions & 23 deletions public/examples/drag_2/index.html

This file was deleted.

1 change: 1 addition & 0 deletions public/examples/e4_sound_board/index.html
Expand Up @@ -13,6 +13,7 @@ <h2>index.html</h2>
<div id="source-html"></div>

<script src="https://cdn.jsdelivr.net/npm/p5@1.4.1/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@1.4.2/lib/addons/p5.sound.js"></script>
<script src="/dist/p5.party.js"></script>
<script src="index.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion public/examples/e4_sound_board/index.js
Expand Up @@ -59,7 +59,7 @@ function mousePressed() {

// ?
function onPlaySound(name) {
console.log("onPlaySound", name);
console.log("onPlaySound", name, sounds);

// ?
sounds[name].play();
Expand Down

0 comments on commit 236b2ef

Please sign in to comment.