driggsby 0.2.0 → 0.2.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.
@@ -18,8 +18,8 @@ export function indexHtml(slug) {
18
18
  <main>
19
19
  <header>
20
20
  <h1>${slug}</h1>
21
- <p class="sample-note" id="sample-note">Sample data — your real accounts
22
- appear when this app runs inside Driggsby.</p>
21
+ <p class="sample-note" id="sample-note" hidden>Sample data — your real
22
+ accounts appear when this app runs inside Driggsby.</p>
23
23
  </header>
24
24
  <section aria-label="Overview">
25
25
  <div class="stat-grid" id="overview"></div>
@@ -46,8 +46,8 @@ export const APP_JS = `// Your app's code. Edit anything — driggsby dev reload
46
46
  // real result shapes, so the render functions work unchanged either way.
47
47
 
48
48
  // ---------------------------------------------------------------------------
49
- // Sample data. Every name and number here is invented. It renders only
50
- // until real data arrives from Driggsby.
49
+ // Sample data. Every name and number here is invented. It paints only
50
+ // when this page is opened on its own, outside Driggsby.
51
51
  // ---------------------------------------------------------------------------
52
52
 
53
53
  const SAMPLE_OVERVIEW = {
@@ -147,31 +147,35 @@ function renderAccounts(result) {
147
147
 
148
148
  // ---------------------------------------------------------------------------
149
149
  // Live data. window.driggsby exists when the Driggsby SDK loaded — inside
150
- // Driggsby, or under driggsby dev. Standalone, the sample data stays and
151
- // the note above explains why.
150
+ // Driggsby, or under driggsby dev. Whether anything embeds this page is
151
+ // knowable synchronously: opened directly in a tab, no host will ever
152
+ // answer, so the sample data paints right away and the note explaining it
153
+ // is revealed (it ships hidden in the HTML, so an embedded page never
154
+ // shows it, not even for the moment before this script runs). Embedded,
155
+ // sample numbers never paint at all — a muted loading line holds the
156
+ // accounts area until real data arrives.
152
157
  // ---------------------------------------------------------------------------
153
158
 
154
- renderOverview(SAMPLE_OVERVIEW);
155
- renderAccounts(SAMPLE_ACCOUNTS);
159
+ const standalone = window.parent === window;
160
+ const note = document.getElementById("sample-note");
156
161
 
157
- let overviewIsLive = false;
158
- let accountsAreLive = false;
159
-
160
- function removeSampleNoteWhenAllLive() {
161
- if (!overviewIsLive || !accountsAreLive) return;
162
- const note = document.getElementById("sample-note");
162
+ if (standalone) {
163
+ renderOverview(SAMPLE_OVERVIEW);
164
+ renderAccounts(SAMPLE_ACCOUNTS);
165
+ if (note) note.hidden = false;
166
+ } else {
163
167
  if (note) note.remove();
168
+ const accounts = document.getElementById("accounts");
169
+ if (accounts) {
170
+ accounts.replaceChildren(element("div", "loading-note", "Loading your accounts…"));
171
+ }
164
172
  }
165
173
 
166
174
  if (window.driggsby) {
167
175
  driggsby.watch("get_overview", {}, (result) => {
168
- overviewIsLive = true;
169
- removeSampleNoteWhenAllLive();
170
176
  renderOverview(result);
171
177
  });
172
178
  driggsby.watch("list_accounts", {}, (result) => {
173
- accountsAreLive = true;
174
- removeSampleNoteWhenAllLive();
175
179
  renderAccounts(result);
176
180
  });
177
181
  }
@@ -226,6 +230,17 @@ h2 {
226
230
  font-size: 13px;
227
231
  }
228
232
 
233
+ /* The display rule above would defeat the hidden attribute without this. */
234
+ .sample-note[hidden] {
235
+ display: none;
236
+ }
237
+
238
+ .loading-note {
239
+ margin-top: 8px;
240
+ color: var(--text-muted);
241
+ font-size: 13px;
242
+ }
243
+
229
244
  .stat-grid {
230
245
  display: grid;
231
246
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "driggsby",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Set up and build on Driggsby, the MCP server for personal finance.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "node": ">=18"
29
29
  },
30
30
  "dependencies": {
31
- "@driggsby/deploy": "0.2.0",
32
- "@driggsby/sdk": "0.2.0"
31
+ "@driggsby/deploy": "0.2.1",
32
+ "@driggsby/sdk": "0.2.1"
33
33
  }
34
34
  }