fuzzyworld

north-star / commit

folder refactoring

f32f5e954424f1f7cbf4b5983619b1fb37ecaac7 · Pavel Safronov · 2026-03-16 12:23:52 -0700 · parents 39ddb24e6733

folder refactoring
 src/app.ts                                         | 24 +++++++++-------------
 src/{ => core}/crypto.ts                           |  0
 src/{ => core}/public-settings.ts                  |  0
 src/{ => core}/room.ts                             |  0
 src/{ => core}/toast.ts                            |  0
 src/{ => core}/utils.ts                            |  2 +-
 src/{ => features/compass}/compass.ts              |  6 +++---
 src/features/compass/index.ts                      |  1 +
 src/features/friends/index.ts                      |  3 +++
 .../friends/panel.ts}                              |  6 +++---
 src/{ => features/friends}/renderer.ts             |  4 ++--
 src/{friends-sync.ts => features/friends/sync.ts}  |  2 +-
 src/features/participants/index.ts                 |  2 ++
 .../participants/panel.ts}                         |  0
 .../participants/sync.ts}                          |  2 +-
 src/features/session/index.ts                      |  3 +++
 src/{ => features/session}/qr.ts                   |  0
 src/{ => features/session}/self-profile.ts         |  2 +-
 src/{ => features/session}/session.ts              |  6 +++---
 src/features/ui/index.ts                           |  1 +
 src/{ => features/ui}/wake-lock-controller.ts      |  4 ++--
 src/{ => platform}/darkmode.ts                     |  0
 src/{ => platform}/firebase.ts                     |  0
 src/{ => platform}/wakelock.ts                     |  0
 24 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/src/app.ts b/src/app.ts
index d802cc3..539c4de 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -1,18 +1,14 @@
 import { get, ref, remove, set, serverTimestamp } from 'firebase/database';
-import { getReadableTextColor, getArrowDisplayColor } from './utils';
-import { encryptJson } from './crypto';
-import { initDarkMode } from './darkmode';
-import { initWakeLockController } from './wake-lock-controller';
-import { initFirebaseSession } from './firebase';
-import { initSession } from './session';
-import { parseRoomFromHash } from './room';
-import { initSelfProfile } from './self-profile';
-import { subscribeToFriends } from './friends-sync';
-import { initCompassController } from './compass';
-import { createFriendsPanelController } from './friends-panel';
-import { renderArrows } from './renderer';
-import { bumpQrAutoCollapseCountdown } from './qr';
-import { PUBLIC_SETTINGS } from './public-settings';
+import { getReadableTextColor, getArrowDisplayColor } from './core/utils';
+import { encryptJson } from './core/crypto';
+import { initDarkMode } from './platform/darkmode';
+import { initWakeLockController } from './features/ui';
+import { initFirebaseSession } from './platform/firebase';
+import { initSession, initSelfProfile, bumpQrAutoCollapseCountdown } from './features/session';
+import { parseRoomFromHash } from './core/room';
+import { subscribeToFriends, createFriendsPanelController, renderArrows } from './features/friends';
+import { initCompassController } from './features/compass';
+import { PUBLIC_SETTINGS } from './core/public-settings';
 
 const debugCommit = document.getElementById('debug-commit');
 const nameForm = document.getElementById('name-form');
diff --git a/src/crypto.ts b/src/core/crypto.ts
similarity index 100%
rename from src/crypto.ts
rename to src/core/crypto.ts
diff --git a/src/public-settings.ts b/src/core/public-settings.ts
similarity index 100%
rename from src/public-settings.ts
rename to src/core/public-settings.ts
diff --git a/src/room.ts b/src/core/room.ts
similarity index 100%
rename from src/room.ts
rename to src/core/room.ts
diff --git a/src/toast.ts b/src/core/toast.ts
similarity index 100%
rename from src/toast.ts
rename to src/core/toast.ts
diff --git a/src/utils.ts b/src/core/utils.ts
similarity index 99%
rename from src/utils.ts
rename to src/core/utils.ts
index 0d60b93..a9cf0d8 100644
--- a/src/utils.ts
+++ b/src/core/utils.ts
@@ -64,7 +64,7 @@ export const getFriendPresenceState = (friend: FriendLike, now: number, threshol
 export const PRESENCE_EMOJI: Record<string, string> = {
     online: '🟢',
     'recent-offline': '🟡',
-    'stale-offline': '👻'
+    'stale-offline': '⚪'
 };
 
 export const getDeviceHint = async () => {
diff --git a/src/compass.ts b/src/features/compass/compass.ts
similarity index 98%
rename from src/compass.ts
rename to src/features/compass/compass.ts
index db2fe32..c515047 100644
--- a/src/compass.ts
+++ b/src/features/compass/compass.ts
@@ -1,6 +1,6 @@
-import { normalizeAngle, normalizeSignedAngle } from './utils';
-import { PUBLIC_SETTINGS } from './public-settings';
-import { createToast } from './toast';
+import { normalizeAngle, normalizeSignedAngle } from '../../core/utils';
+import { PUBLIC_SETTINGS } from '../../core/public-settings';
+import { createToast } from '../../core/toast';
 
 type CompassControllerOptions = {
     calibrateHeadingLink: HTMLElement | null;
diff --git a/src/features/compass/index.ts b/src/features/compass/index.ts
new file mode 100644
index 0000000..060fef9
--- /dev/null
+++ b/src/features/compass/index.ts
@@ -0,0 +1 @@
+export { initCompassController } from './compass';
diff --git a/src/features/friends/index.ts b/src/features/friends/index.ts
new file mode 100644
index 0000000..48b3644
--- /dev/null
+++ b/src/features/friends/index.ts
@@ -0,0 +1,3 @@
+export { createFriendsPanelController } from './panel';
+export { subscribeToFriends } from './sync';
+export { renderArrows } from './renderer';
diff --git a/src/friends-panel.ts b/src/features/friends/panel.ts
similarity index 98%
rename from src/friends-panel.ts
rename to src/features/friends/panel.ts
index 0a13644..aed84b1 100644
--- a/src/friends-panel.ts
+++ b/src/features/friends/panel.ts
@@ -1,6 +1,6 @@
-import { getFriendPresenceState, PRESENCE_EMOJI } from './utils';
-import type { PresenceThresholds } from './utils';
-import { PUBLIC_SETTINGS } from './public-settings';
+import { getFriendPresenceState, PRESENCE_EMOJI } from '../../core/utils';
+import type { PresenceThresholds } from '../../core/utils';
+import { PUBLIC_SETTINGS } from '../../core/public-settings';
 
 type FriendModel = {
     id: string;
diff --git a/src/renderer.ts b/src/features/friends/renderer.ts
similarity index 97%
rename from src/renderer.ts
rename to src/features/friends/renderer.ts
index fe06f6c..afc7c35 100644
--- a/src/renderer.ts
+++ b/src/features/friends/renderer.ts
@@ -1,5 +1,5 @@
-import { getShortestDelta, normalizeAngle, getFriendPresenceState } from './utils';
-import type { PresenceThresholds } from './utils';
+import { getShortestDelta, normalizeAngle, getFriendPresenceState } from '../../core/utils';
+import type { PresenceThresholds } from '../../core/utils';
 
 type ArrowElement = HTMLElement & { currentAngle: number | null };
 
diff --git a/src/friends-sync.ts b/src/features/friends/sync.ts
similarity index 98%
rename from src/friends-sync.ts
rename to src/features/friends/sync.ts
index 0a69bd2..4ae2c8d 100644
--- a/src/friends-sync.ts
+++ b/src/features/friends/sync.ts
@@ -1,6 +1,6 @@
 import { ref, onValue } from 'firebase/database';
 import type { Database } from 'firebase/database';
-import { decryptJson } from './crypto';
+import { decryptJson } from '../../core/crypto';
 
 type FriendRecord = {
     id?: string;
diff --git a/src/features/participants/index.ts b/src/features/participants/index.ts
new file mode 100644
index 0000000..f3e8453
--- /dev/null
+++ b/src/features/participants/index.ts
@@ -0,0 +1,2 @@
+export { createParticipantsPanelController } from './panel';
+export { subscribeToParticipants } from './sync';
diff --git a/src/participants-panel.ts b/src/features/participants/panel.ts
similarity index 100%
rename from src/participants-panel.ts
rename to src/features/participants/panel.ts
diff --git a/src/participants-sync.ts b/src/features/participants/sync.ts
similarity index 98%
rename from src/participants-sync.ts
rename to src/features/participants/sync.ts
index 7cdc7e6..b1a6f00 100644
--- a/src/participants-sync.ts
+++ b/src/features/participants/sync.ts
@@ -1,5 +1,5 @@
 import { ref, onValue, type Database } from 'firebase/database';
-import { decryptJson } from './crypto';
+import { decryptJson } from '../../core/crypto';
 
 type ParticipantRecord = {
     id?: string;
diff --git a/src/features/session/index.ts b/src/features/session/index.ts
new file mode 100644
index 0000000..3514e26
--- /dev/null
+++ b/src/features/session/index.ts
@@ -0,0 +1,3 @@
+export { initSession } from './session';
+export { initSelfProfile } from './self-profile';
+export { bumpQrAutoCollapseCountdown, renderInviteQrCard } from './qr';
diff --git a/src/qr.ts b/src/features/session/qr.ts
similarity index 100%
rename from src/qr.ts
rename to src/features/session/qr.ts
diff --git a/src/self-profile.ts b/src/features/session/self-profile.ts
similarity index 98%
rename from src/self-profile.ts
rename to src/features/session/self-profile.ts
index 0a4c868..937316c 100644
--- a/src/self-profile.ts
+++ b/src/features/session/self-profile.ts
@@ -1,4 +1,4 @@
-import { normalizeName, normalizeColor, createRandomUserName, createRandomColor } from './utils';
+import { normalizeName, normalizeColor, createRandomUserName, createRandomColor } from '../../core/utils';
 
 const NAME_STORAGE_KEY = 'north-star-self-name-v2';
 const COLOR_STORAGE_KEY = 'north-star-self-color';
diff --git a/src/session.ts b/src/features/session/session.ts
similarity index 94%
rename from src/session.ts
rename to src/features/session/session.ts
index 55640c0..cb00297 100644
--- a/src/session.ts
+++ b/src/features/session/session.ts
@@ -1,7 +1,7 @@
-import { generateRoomKey, exportRoomKey, importRoomKey } from './crypto';
-import { buildRoomHash, parseRoomFromHash } from './room';
+import { generateRoomKey, exportRoomKey, importRoomKey } from '../../core/crypto';
+import { buildRoomHash, parseRoomFromHash } from '../../core/room';
 import { renderInviteQrCard } from './qr';
-import { PUBLIC_SETTINGS } from './public-settings';
+import { PUBLIC_SETTINGS } from '../../core/public-settings';
 
 /**
  * Parses an existing room from the URL hash, or generates a new one.
diff --git a/src/features/ui/index.ts b/src/features/ui/index.ts
new file mode 100644
index 0000000..29204d7
--- /dev/null
+++ b/src/features/ui/index.ts
@@ -0,0 +1 @@
+export { initWakeLockController } from './wake-lock-controller';
diff --git a/src/wake-lock-controller.ts b/src/features/ui/wake-lock-controller.ts
similarity index 97%
rename from src/wake-lock-controller.ts
rename to src/features/ui/wake-lock-controller.ts
index aa4a0b6..4348fb5 100644
--- a/src/wake-lock-controller.ts
+++ b/src/features/ui/wake-lock-controller.ts
@@ -1,5 +1,5 @@
-import { createWakeLockManager } from './wakelock';
-import { createToast } from './toast';
+import { createWakeLockManager } from '../../platform/wakelock';
+import { createToast } from '../../core/toast';
 
 type WakeLockControllerOptions = {
     wakeLockToggle: HTMLElement | null;
diff --git a/src/darkmode.ts b/src/platform/darkmode.ts
similarity index 100%
rename from src/darkmode.ts
rename to src/platform/darkmode.ts
diff --git a/src/firebase.ts b/src/platform/firebase.ts
similarity index 100%
rename from src/firebase.ts
rename to src/platform/firebase.ts
diff --git a/src/wakelock.ts b/src/platform/wakelock.ts
similarity index 100%
rename from src/wakelock.ts
rename to src/platform/wakelock.ts