@hearthlog/runtime 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +235 -0
- package/package.json +51 -3
- package/src/access/session.ts +223 -0
- package/src/access/user-session.ts +61 -0
- package/src/ai/decisions.ts +89 -0
- package/src/calendar/draft.ts +84 -0
- package/src/calendar/feeds.ts +91 -0
- package/src/calendar/groups.ts +198 -0
- package/src/calendar/logic.ts +141 -0
- package/src/calendar/preferences.ts +40 -0
- package/src/calendar/weeks.ts +56 -0
- package/src/commands/index.ts +184 -0
- package/src/commands/local-commit.ts +214 -0
- package/src/commands/standard.ts +8 -0
- package/src/commands/validation.ts +206 -0
- package/src/db/bootstrap.ts +72 -0
- package/src/db/calendar.ts +638 -0
- package/src/db/dynamic-ddl.ts +127 -0
- package/src/db/entities.ts +208 -0
- package/src/db/history.ts +194 -0
- package/src/db/index.ts +1240 -0
- package/src/db/kv.ts +33 -0
- package/src/db/local-statistics.ts +106 -0
- package/src/db/module-projections.ts +46 -0
- package/src/db/raw-browser.ts +361 -0
- package/src/db/read-repositories.ts +29 -0
- package/src/db/read-session.ts +47 -0
- package/src/db/schema-version.ts +76 -0
- package/src/db/session-context.ts +33 -0
- package/src/event/code-export.ts +65 -0
- package/src/event/dynamic-entities.ts +503 -0
- package/src/event/dynamic-materializer.ts +288 -0
- package/src/event/handlers.ts +490 -0
- package/src/event/index.ts +53 -0
- package/src/event/meta-entity-types.ts +165 -0
- package/src/event/projection-builder.ts +384 -0
- package/src/event/queries.ts +126 -0
- package/src/event/rebuild.ts +176 -0
- package/src/event/reference-lookup.ts +93 -0
- package/src/event/registry.ts +158 -0
- package/src/event/schema-effects.ts +45 -0
- package/src/event/types.ts +20 -0
- package/src/history/action-boundary.ts +18 -0
- package/src/history/action-detail.ts +23 -0
- package/src/history/change-comparison.ts +29 -0
- package/src/history/change-display.ts +41 -0
- package/src/history/contracts.ts +63 -0
- package/src/history/history.ts +372 -0
- package/src/history/legacy-replay.ts +69 -0
- package/src/history/legacy-url.ts +9 -0
- package/src/history/lineage.ts +123 -0
- package/src/history/log-format.ts +17 -0
- package/src/history/log-map.ts +110 -0
- package/src/history/navigation.ts +14 -0
- package/src/history/point-snapshot.ts +229 -0
- package/src/history/timeline.ts +215 -0
- package/src/history/url.ts +18 -0
- package/src/ledger/README.md +118 -0
- package/src/ledger/admin-client.ts +616 -0
- package/src/ledger/client.ts +10 -0
- package/src/ledger/config.ts +117 -0
- package/src/ledger/entity-id.ts +115 -0
- package/src/ledger/errors.ts +144 -0
- package/src/ledger/http-client.ts +590 -0
- package/src/ledger/index.ts +67 -0
- package/src/ledger/socket.ts +400 -0
- package/src/ledger/types.ts +202 -0
- package/src/ledger/version-tracker-singleton.ts +12 -0
- package/src/ledger/version-tracker.ts +259 -0
- package/src/log-management.ts +123 -0
- package/src/log-validation.ts +19 -0
- package/src/native/reminders.ts +2 -0
- package/src/native/shell.svelte.ts +136 -0
- package/src/native/shell.ts +102 -0
- package/src/pwa/registration.ts +169 -0
- package/src/recovery/local-recovery.ts +59 -0
- package/src/recovery/reset-sequence.ts +13 -0
- package/src/runtime/clock.ts +43 -0
- package/src/runtime/kept-page-data.svelte.ts +42 -0
- package/src/runtime/page-data.svelte.ts +160 -0
- package/src/runtime/phone-header.svelte.ts +17 -0
- package/src/runtime/read-coordinator.ts +103 -0
- package/src/runtime/refresh.ts +15 -0
- package/src/runtime/start-page.ts +56 -0
- package/src/runtime/view.ts +83 -0
- package/src/runtime/workspace.ts +62 -0
- package/src/storage/indexeddb-statistics.ts +153 -0
- package/src/store/attention.svelte.ts +51 -0
- package/src/store/conflict-merge.ts +169 -0
- package/src/store/entity-sync-state.svelte.ts +36 -0
- package/src/store/event-log.svelte.ts +109 -0
- package/src/store/events.svelte.ts +14 -0
- package/src/store/local-context.ts +93 -0
- package/src/store/local-store.svelte.ts +58 -0
- package/src/store/log-version.svelte.ts +35 -0
- package/src/store/logs.svelte.ts +60 -0
- package/src/store/moved.svelte.ts +43 -0
- package/src/store/offline-readiness.svelte.ts +188 -0
- package/src/store/outbox-request.ts +61 -0
- package/src/store/outbox.ts +426 -0
- package/src/store/pending-work-transfer.ts +49 -0
- package/src/store/pending-work.ts +143 -0
- package/src/store/sync-coordinator.ts +170 -0
- package/src/store/sync-invalidation.ts +10 -0
- package/src/store/sync-issues.ts +406 -0
- package/src/store/sync-progress.ts +54 -0
- package/src/store/sync-state.ts +127 -0
- package/src/store/sync.svelte.ts +1010 -0
- package/src/store/tab-coordination.ts +164 -0
- package/src/testing/e2e-seed.ts +40 -0
- package/src/testing/local-database.ts +120 -0
- package/src/testing/projection-database.ts +105 -0
- package/src/testing/test-entities.ts +28 -0
- package/src/theme/appearance.svelte.ts +111 -0
- package/src/utils/address.ts +5 -0
- package/src/utils/async.ts +30 -0
- package/src/utils/long-press.ts +70 -0
- package/src/utils/perf-dataset.ts +405 -0
- package/src/utils/perf.ts +627 -0
- package/README.md +0 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { LocalStorePhase } from './local-store.svelte.js';
|
|
2
|
+
|
|
3
|
+
export type SyncPhase =
|
|
4
|
+
| 'offline'
|
|
5
|
+
| 'idle'
|
|
6
|
+
| 'syncing'
|
|
7
|
+
| 'pending'
|
|
8
|
+
| 'blocked'
|
|
9
|
+
| 'waiting'
|
|
10
|
+
| 'error'
|
|
11
|
+
| 'synced';
|
|
12
|
+
|
|
13
|
+
export interface SyncStateInput {
|
|
14
|
+
isOnline: boolean;
|
|
15
|
+
isSyncing: boolean;
|
|
16
|
+
hasCompletedSync: boolean;
|
|
17
|
+
hasError: boolean;
|
|
18
|
+
waitingForLedger?: boolean;
|
|
19
|
+
pendingUploads: number;
|
|
20
|
+
needsAttention: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SyncPresentation {
|
|
24
|
+
label: string;
|
|
25
|
+
description: string;
|
|
26
|
+
tone: 'neutral' | 'success' | 'warning' | 'danger';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function deriveSyncPhase(input: SyncStateInput): SyncPhase {
|
|
30
|
+
if (!input.isOnline) return 'offline';
|
|
31
|
+
if (input.needsAttention > 0) return 'blocked';
|
|
32
|
+
if (input.hasError && input.waitingForLedger) return 'waiting';
|
|
33
|
+
if (input.hasError) return 'error';
|
|
34
|
+
if (input.isSyncing) return 'syncing';
|
|
35
|
+
if (input.pendingUploads > 0) return 'pending';
|
|
36
|
+
if (input.hasCompletedSync) return 'synced';
|
|
37
|
+
return 'idle';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function describeAppDataState(input: {
|
|
41
|
+
localStorePhase: LocalStorePhase;
|
|
42
|
+
syncPhase: SyncPhase;
|
|
43
|
+
pendingUploads: number;
|
|
44
|
+
needsAttention: number;
|
|
45
|
+
lastSyncedAt: Date | null;
|
|
46
|
+
syncErrorMessage?: string | null;
|
|
47
|
+
localStoreErrorMessage?: string | null;
|
|
48
|
+
}): SyncPresentation {
|
|
49
|
+
if (input.localStorePhase === 'booting') {
|
|
50
|
+
return {
|
|
51
|
+
label: 'Preparing local data',
|
|
52
|
+
description: 'Checking the local database',
|
|
53
|
+
tone: 'neutral',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (input.localStorePhase === 'failed') {
|
|
57
|
+
return {
|
|
58
|
+
label: 'Local data unavailable',
|
|
59
|
+
description: input.localStoreErrorMessage || 'The local database could not be opened',
|
|
60
|
+
tone: 'danger',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (input.localStorePhase === 'degraded') {
|
|
64
|
+
return {
|
|
65
|
+
label: 'Local data limited',
|
|
66
|
+
description: input.localStoreErrorMessage || 'No event log is selected',
|
|
67
|
+
tone: 'warning',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
switch (input.syncPhase) {
|
|
72
|
+
case 'offline':
|
|
73
|
+
return {
|
|
74
|
+
label: 'Offline',
|
|
75
|
+
description: 'Changes stay on this device',
|
|
76
|
+
tone: 'warning',
|
|
77
|
+
};
|
|
78
|
+
case 'blocked':
|
|
79
|
+
return {
|
|
80
|
+
label: `${input.needsAttention} need attention`,
|
|
81
|
+
description: 'Some local changes could not sync',
|
|
82
|
+
tone: 'danger',
|
|
83
|
+
};
|
|
84
|
+
case 'waiting':
|
|
85
|
+
return {
|
|
86
|
+
label: input.pendingUploads > 0 ? 'Waiting to upload' : 'Ledger unreachable',
|
|
87
|
+
description: 'Changes stay on this device and sync when Ledger responds',
|
|
88
|
+
tone: 'warning',
|
|
89
|
+
};
|
|
90
|
+
case 'error':
|
|
91
|
+
return {
|
|
92
|
+
label: 'Sync error',
|
|
93
|
+
description: input.syncErrorMessage || 'Ledger could not be reached',
|
|
94
|
+
tone: 'danger',
|
|
95
|
+
};
|
|
96
|
+
case 'syncing':
|
|
97
|
+
return {
|
|
98
|
+
label: 'Syncing',
|
|
99
|
+
description: input.pendingUploads > 0
|
|
100
|
+
? `Uploading ${input.pendingUploads} local ${input.pendingUploads === 1 ? 'change' : 'changes'}`
|
|
101
|
+
: 'Checking Ledger for changes',
|
|
102
|
+
tone: 'neutral',
|
|
103
|
+
};
|
|
104
|
+
case 'pending':
|
|
105
|
+
return {
|
|
106
|
+
label: `${input.pendingUploads} pending`,
|
|
107
|
+
description: 'Local changes are waiting to upload',
|
|
108
|
+
tone: 'warning',
|
|
109
|
+
};
|
|
110
|
+
case 'synced':
|
|
111
|
+
return {
|
|
112
|
+
label: 'Synced',
|
|
113
|
+
description: input.lastSyncedAt
|
|
114
|
+
? `Updated ${input.lastSyncedAt.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`
|
|
115
|
+
: 'Ledger is up to date',
|
|
116
|
+
tone: 'success',
|
|
117
|
+
};
|
|
118
|
+
case 'idle':
|
|
119
|
+
default:
|
|
120
|
+
return {
|
|
121
|
+
label: 'Not synced yet',
|
|
122
|
+
description: 'Waiting for the first Ledger check',
|
|
123
|
+
tone: 'neutral',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|