@stacksjs/defaults 0.75.672 → 0.75.683

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.
Files changed (69) hide show
  1. package/ai/skills/stacks-ai/SKILL.md +7 -2
  2. package/ai/skills/stacks-api/SKILL.md +1 -1
  3. package/ai/skills/stacks-dashboard/SKILL.md +26 -5
  4. package/ai/skills/stacks-deploy/SKILL.md +8 -0
  5. package/ai/skills/stacks-desktop/SKILL.md +31 -0
  6. package/ai/skills/stacks-development/SKILL.md +5 -7
  7. package/ai/skills/stacks-health/SKILL.md +19 -9
  8. package/ai/skills/stacks-native/CATALOG.md +24 -24
  9. package/ai/skills/stacks-newsletter/SKILL.md +10 -4
  10. package/ai/skills/stacks-router/SKILL.md +2 -2
  11. package/ai/skills/stacks-routes/SKILL.md +2 -2
  12. package/ai/skills/stacks-scheduler/SKILL.md +16 -2
  13. package/ai/skills/stacks-security/SKILL.md +24 -0
  14. package/ai/skills/stacks-socials/SKILL.md +17 -1
  15. package/ai/skills/stacks-storage/SKILL.md +34 -15
  16. package/app/Actions/SubscriberEmailAction.ts +26 -10
  17. package/app/Jobs/Inspire.ts +33 -0
  18. package/functions/dashboard-sidebar-order.ts +3 -0
  19. package/ide/vscode/package.json +1 -1
  20. package/package.json +8 -7
  21. package/project/storage/framework/types/request-context.d.ts +3 -0
  22. package/resources/components/Dashboard/Billing/BillingPaymentMethodsPanel.stx +3 -10
  23. package/resources/components/Dashboard/Billing/BillingPlanSummary.stx +3 -10
  24. package/resources/components/Dashboard/Billing/BillingSettings.stx +13 -15
  25. package/resources/components/Dashboard/Billing/BillingTransactionHistory.stx +2 -9
  26. package/resources/components/Dashboard/DashboardSectionLanding.stx +72 -0
  27. package/resources/components/Dashboard/DashboardSectionSidebar.stx +78 -0
  28. package/resources/components/Dashboard/GlobalSearch.stx +3 -1
  29. package/resources/components/Dashboard/Home/DashboardHome.stx +22 -9
  30. package/resources/components/Dashboard/MobileSidebar.stx +1 -1
  31. package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +37 -92
  32. package/resources/components/Dashboard/Settings/DashboardSettingsFrame.stx +98 -0
  33. package/resources/components/Dashboard/Settings/DashboardThemePicker.stx +213 -0
  34. package/resources/components/Dashboard/Settings/MailSettingsDashboard.stx +162 -167
  35. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +34 -30
  36. package/resources/components/Dashboard/Settings/SoftwareUpdateDashboard.stx +229 -0
  37. package/resources/components/Dashboard/UI/ActivityTable.stx +7 -7
  38. package/resources/components/Dashboard/UI/Button.stx +6 -3
  39. package/resources/components/Dashboard/UI/Card.stx +1 -1
  40. package/resources/components/Dashboard/UI/DashboardNavigationCards.stx +44 -0
  41. package/resources/components/Dashboard/UI/Drawer.stx +1 -1
  42. package/resources/components/Dashboard/UI/Input.stx +1 -0
  43. package/resources/components/Dashboard/UI/Modal.stx +1 -0
  44. package/resources/components/Dashboard/UI/PageHeader.stx +1 -1
  45. package/resources/components/Dashboard/UI/QuickLinks.stx +7 -5
  46. package/resources/components/Dashboard/UI/Select.stx +1 -0
  47. package/resources/components/Dashboard/UI/ServiceHealth.stx +6 -6
  48. package/resources/components/Dashboard/UI/StatsCard.stx +5 -5
  49. package/resources/components/Dashboard/UI/Table.stx +2 -1
  50. package/resources/components/Dashboard/UI/Textarea.stx +1 -0
  51. package/resources/components/Marketing/SubscribeForm.stx +29 -8
  52. package/resources/functions/dashboard/section-landing.ts +201 -0
  53. package/resources/functions/dashboard/section-navigation.ts +95 -0
  54. package/styles/dashboard-theme.css +1017 -0
  55. package/views/dashboard/composables/dashboard-theme-bootstrap.ts +11 -0
  56. package/views/dashboard/composables/dashboard-themes.ts +180 -0
  57. package/views/dashboard/composables/settings-window.ts +116 -0
  58. package/views/dashboard/composables/useAppearance.ts +34 -13
  59. package/views/dashboard/composables/useDashboardThemes.ts +80 -0
  60. package/views/dashboard/composables/useSettingsWindow.ts +23 -0
  61. package/views/dashboard/layouts/default.stx +74 -59
  62. package/views/dashboard/layouts/guest.stx +11 -1
  63. package/views/dashboard/layouts/settings.stx +48 -0
  64. package/views/dashboard/sections/[section].stx +19 -0
  65. package/views/dashboard/settings/appearance.stx +4 -2
  66. package/views/dashboard/settings/billing.stx +3 -4
  67. package/views/dashboard/settings/index.stx +4 -2
  68. package/views/dashboard/settings/mail.stx +3 -3
  69. package/views/dashboard/settings/software-update.stx +9 -0
@@ -89,7 +89,7 @@ routes. Use `buddy route:list` to inspect this application's actual surface.
89
89
  - `/commerce/products/*`, `/commerce/orders/*`, `/commerce/customers/*`
90
90
 
91
91
  ### Health
92
- - `GET /health` — status, uptime, memory, PID, Bun version
92
+ - `GET /api/health`: `{ status: 'healthy' | 'degraded', checks: { database, cache }, timestamp }`, 503 when a check fails
93
93
 
94
94
  ## Versioned Routes (routes/v1.ts)
95
95
 
@@ -120,7 +120,7 @@ route.get('/ping', (req) => Response.json({ pong: true }))
120
120
  - String handlers (Actions/X) are dynamically imported at request time
121
121
  - Route order matters — first match wins
122
122
  - Use groups for shared middleware instead of repeating on each route
123
- - The `health()` helper registers `GET /health` automatically
123
+ - The `health()` helper registers `GET /api/health`, not `/health`, so it cannot collide with a page
124
124
  - For the router API (request helpers, middleware, responses), see the `stacks-router` skill
125
125
 
126
126
  Source: `core/router/src/route-loader.ts`, `appRouteRegistry`, and
@@ -51,8 +51,14 @@ schedule.job(name: JobName): UntimedSchedule // Runs a job by name via runJo
51
51
  schedule.action(name: string): UntimedSchedule // Runs an action by name via runAction()
52
52
  schedule.command(cmd: string): UntimedSchedule // Runs a shell command via runCommand()
53
53
 
54
- // Graceful shutdown - stops all tracked jobs
55
- schedule.gracefulShutdown(): Promise<void>
54
+ // Stops every schedule, then waits up to timeoutMs (30 s) for running jobs.
55
+ // Resolves with the tasks still running when it gave up.
56
+ schedule.gracefulShutdown(options?: { timeoutMs?: number }): Promise<{ unfinished: string[] }>
57
+ // SIGTERM/SIGINT -> gracefulShutdown, then exit 0. runScheduler() installs it.
58
+ schedule.stopOnSignals(options?: { timeoutMs?: number }): void
59
+ // Each task's last run: startedAt, finishedAt, durationMs, status
60
+ // ('running' | 'success' | 'failed'), error (500 chars), lastSuccessAt.
61
+ schedule.lastRuns(): Record<string, ScheduledRun>
56
62
  ```
57
63
 
58
64
  ### Constructor
@@ -107,6 +113,7 @@ withContext(context: any): this // passed to the task on each run: the
107
113
  withInterval(seconds: number): this // at least this many seconds between runs; sooner ticks are skipped
108
114
  between(startAt: string | Date, stopAt: string | Date): this // only run inside the window; stops for good once it closes
109
115
  withoutOverlapping(expiresAfterMinutes?: number): this
116
+ allowOverlapping(): this // let a tick start while the last run is still going (off by default)
110
117
  onOneServer(): this
111
118
  runInBackground(): this
112
119
  ```
@@ -135,6 +142,13 @@ The `Timezone` type is a string union of ~70 IANA timezone identifiers (e.g., `'
135
142
 
136
143
  ### Overlap Prevention and Locking
137
144
 
145
+ In one process, a tick never starts while the previous run of the same task is
146
+ still going: it is skipped and logged. `allowOverlapping()` opts a task out.
147
+ `runNow()` and background runs always run. Each run's start, end, status and
148
+ error are kept in `storage/framework/runtime/scheduler-history.json` (a shared
149
+ temp file in a test process); `schedule.lastRuns()` reads it, and
150
+ `buddy schedule:list` shows it as LAST RUN.
151
+
138
152
  `withoutOverlapping()` uses a local exclusive file lock, with a stale-lock
139
153
  expiry. `onOneServer()` also requests a dedicated PostgreSQL/MySQL advisory
140
154
  lock through `scheduler-lock.ts`, alongside the local file lock. DB locks
@@ -153,6 +153,30 @@ interface HashMakeOptions {
153
153
  }
154
154
  ```
155
155
 
156
+ ## Page security headers (`config.server.security`)
157
+
158
+ The views server stamps `X-Content-Type-Options`, `Referrer-Policy` and
159
+ `X-Frame-Options: SAMEORIGIN` (not on `embeddable` paths) on every page, plus:
160
+
161
+ - `Strict-Transport-Security: max-age=31536000; includeSubDomains` when `APP_URL`
162
+ is https on a real host. Never for localhost, `*.localhost`, `*.test` or a
163
+ loopback IP. `hsts: false` turns it off; a string replaces the value.
164
+ - `Cross-Origin-Opener-Policy: same-origin-allow-popups`, which keeps OAuth and
165
+ payment popups working (`crossOriginOpenerPolicy`).
166
+ - `Permissions-Policy` turning off `browsing-topics`, `usb`, `serial`, `hid`,
167
+ `bluetooth` and `midi`, the features no stx composable uses. `permissionsPolicy`
168
+ merges features over that; `false` drops the header.
169
+ - An opt-in page CSP (`csp: 'report-only'` to observe, then `csp: true`): a
170
+ fresh nonce on every `<script>`, `script-src 'self' 'nonce-...'`, inline
171
+ styles allowed, `object-src 'none'`. `csp.directives` merge over the defaults;
172
+ `false` drops one. Inline `on*=` attributes are blocked when enforced, so
173
+ start report-only.
174
+
175
+ A header the response already carries always wins, and
176
+ `STACKS_SECURITY_HEADERS_DISABLE=true` turns the set off behind a proxy that
177
+ adds its own. The API's `STACKS_CSP` never reaches a page. Source:
178
+ `core/server/src/security-headers.ts`.
179
+
156
180
  ## Personal data and GDPR
157
181
 
158
182
  Data-subject requests are driven by model declarations, not by code you write per
@@ -125,7 +125,23 @@ given by URL is downloaded through fetchPostImage (the outbound guard in
125
125
  @stacksjs/security) and a URL that gives no image throws PostImageError; tests
126
126
  replace a driver's fetchImage. Mastodon's publish takes a third argument
127
127
  (idempotencyKey, visibility, spoilerText, language) and reads the instance's
128
- limits. Bluesky uploads external.thumb for link cards. PublishedPost.warnings
128
+ limits. Bluesky uploads external.thumb for link cards, and its publish takes a
129
+ third argument too: { rkey } from blueskyRecordKey(), kept per post, so a retry
130
+ answers with the post that already went out instead of posting twice. Bluesky
131
+ hashtags take letters from any script (#café, #日本), and images leave a link
132
+ card out with a warning, since a post holds one attachment. A Bluesky account on
133
+ its own PDS signs in there: when no service is configured and bsky.social refuses
134
+ the password, createSession looks the account's PDS up from its DID document
135
+ (resolveBlueskyService), and the session's service is where its posts go.
136
+ Instagram waits for
137
+ each media container to be FINISHED before publishing it (containerTimeoutMs,
138
+ five minutes by default), sends alt text on images and carousel items, refuses an
139
+ image whose mimeType is not JPEG, and looks through every page of the user's
140
+ Facebook Pages for the linked account. Threads deletes with deletePost (the
141
+ threads_delete permission, 100 a day). LinkedIn posts as a company Page when the
142
+ identity's did (the memberUrn setting) is an urn:li:organization URN, with the
143
+ w_organization_social scope; listOrganizations(accessToken) lists the Pages the
144
+ member may post for (rw_organization_admin). PublishedPost.warnings
129
145
  lists what went out without failing the post. The LinkedIn version is
130
146
  LINKEDIN_API_VERSION unless a configured one is still supported.
131
147
 
@@ -427,21 +427,27 @@ const uploads = createUploadSessions({
427
427
  maxBytes: 2 * 1024 ** 3,
428
428
  })
429
429
 
430
- // POST /uploads -> begin
431
- const upload = await uploads.begin({ owner: String(user.id), name, size, type, meta })
432
- // GET /uploads/{id} -> which parts are in
433
- await uploads.status(id, owner)
434
- // PUT /uploads/{id}/parts/{n} -> the part's raw bytes (application/octet-stream)
435
- await uploads.receive(id, owner, index, new Uint8Array(await request.arrayBuffer()))
436
- // DELETE /uploads/{id}
437
- await uploads.abort(id, owner)
438
-
439
- // In the action that uses the file:
440
- const done = await uploads.complete(id, owner) // { path, name, size, type, meta, discard }
441
- await Storage.disk().putStream(key, Bun.file(done.path).stream(), { contentType })
442
- await done.discard()
430
+ // One action answers all four routes (POST /uploads, GET and DELETE /uploads/{id},
431
+ // PUT /uploads/{id}/parts/{index}), told apart by method and the captured params:
432
+ export default new Action({
433
+ name: 'UploadSessions',
434
+ handle: async request => handleUploadSessionRequest(request, uploads, {
435
+ owner: (await authUser(request))?.id,
436
+ accept: file => /\.(mp4|mov|webm)$/i.test(file.name) ? null : 'Choose a video.',
437
+ }),
438
+ })
439
+
440
+ // In the action that uses the file, whichever way it came (whole, or as a session):
441
+ const upload = await receiveUpload(request, { owner: user.id, sessions: uploads, field: 'video' })
442
+ if (!upload) return response.json({ error: 'Send a video' }, 422)
443
+ // upload.path for a session (on this machine), upload.blob either way
444
+ await Storage.disk().putStream(key, upload.blob.stream(), { contentType })
445
+ await upload.discard()
443
446
  ```
444
447
 
448
+ The lower-level calls (`begin`, `status`, `receive`, `complete`, `abort`) are
449
+ there for anything the handler does not cover.
450
+
445
451
  - Every call names the `owner` given at `begin`; anyone else gets `not-found`,
446
452
  the same as an id that never existed. `UploadSessionError` carries the HTTP
447
453
  `status` to answer with (404, 409 incomplete, 413, 422, 429).
@@ -454,8 +460,11 @@ await done.discard()
454
460
  - Run `uploads.prune()` from the scheduler; unfinished sessions go after
455
461
  `ttlSeconds` (a day by default). `maxOpenPerOwner` caps what one account can
456
462
  leave lying around.
457
- - Browser side: `uploadInParts(file, { endpoint, transport, onProgress, signal,
458
- resumeKey })` from `@stacksjs/browser` speaks exactly these routes, retries
463
+ - Browser side: `sendUpload(path, file, { field, fields, transport, onProgress,
464
+ signal })` from `@stacksjs/browser` sends a file of up to 8 MiB whole and a
465
+ larger one in parts, then posts the action `upload` (the session id) with
466
+ the same fields; `receiveUpload` reads either. Under it, `uploadInParts(file,
467
+ { endpoint, transport, onProgress, signal, resumeKey })` speaks exactly these routes, retries
459
468
  each part with a growing pause, honours `Retry-After`, and with
460
469
  `resumeKey: uploadResumeKey(file, purpose)` continues a file picked again.
461
470
  Route bodies are `{ upload: <session view> }`.
@@ -463,6 +472,16 @@ await done.discard()
463
472
  Source: core/storage/src/upload-sessions.ts, core/browser/src/utils/uploads.ts.
464
473
  Tests: core/storage/tests/upload-sessions.test.ts, core/browser/tests/uploads.test.ts.
465
474
 
475
+ ## Serving large files (`locateFile`)
476
+
477
+ Do not read a video or an archive into memory to answer a request: a player
478
+ asks for `Range: bytes=0-1` first. `locateFile(path, { disks, expiresIn })`
479
+ answers `{ kind: 'file', file }` (a lazy `Bun.file` on a local disk, which
480
+ `videoFileResponse` in `@stacksjs/video` slices) or `{ kind: 'url', url }` (a
481
+ temporary URL on an object store, to redirect to), trying each disk in order
482
+ and passing over one that throws. `localDiskRoot(disk)` is the root a local
483
+ disk keeps files under, or null for a store.
484
+
466
485
  ## Low-Level File Operations
467
486
 
468
487
  ### Read/Write Files
@@ -1,4 +1,5 @@
1
1
  import { Action } from '@stacksjs/actions/runtime'
2
+ import { config } from '@stacksjs/config'
2
3
  import { emailAddress, NewsletterListUnavailableError, subscribe } from '@stacksjs/newsletter'
3
4
  import { SubscriberEmail } from '@stacksjs/orm'
4
5
  import { rateLimit } from '@stacksjs/router'
@@ -17,7 +18,14 @@ import { formReturnLocation, wantsFormRedirect } from './form-return'
17
18
  *
18
19
  * Fields: `email`, `source` (where they signed up, stored on the row), `list`
19
20
  * (a public list's slug; private lists are refused), `return` (where a plain
20
- * form post comes back to).
21
+ * form post comes back to), `website` (a honeypot: hidden from people, so a
22
+ * value there means a bot, which is answered as if it worked and stored nowhere).
23
+ *
24
+ * The answer never says whether an address was already on the list. On a
25
+ * double opt-in list everyone is told to check their inbox (only a new or
26
+ * still-pending address is actually sent the email); on any other list
27
+ * everyone is told they are subscribed. Otherwise the form would tell anyone
28
+ * who typed an address whether that person had signed up.
21
29
  *
22
30
  * What a signup came to. A plain form gets it back as `?subscribe=<outcome>`;
23
31
  * a script gets the JSON beside it.
@@ -25,7 +33,8 @@ import { formReturnLocation, wantsFormRedirect } from './form-return'
25
33
  * - `subscribed`: a new address, or one that had unsubscribed and came back.
26
34
  * - `pending`: the list has double opt-in on; a confirmation email went out
27
35
  * and the address joins once its link is opened (ConfirmSubscriptionAction).
28
- * - `already`: the address is on the list.
36
+ * - `already`: kept for forms that still read it; this action no longer
37
+ * sends it (see above).
29
38
  * - `invalid`: not an email address.
30
39
  * - `busy`: too many attempts from this visitor in a minute.
31
40
  * - `error`: anything else. Logged here; the visitor is asked to try again.
@@ -71,14 +80,22 @@ export default new Action({
71
80
  const email = emailAddress(request.get('email'))
72
81
  const source = String(request.get('source') || 'homepage').slice(0, 100)
73
82
  const list = String(request.get('list') || '').trim() || undefined
83
+ const defaultListDoubleOptIn = config.email?.newsletter?.doubleOptIn === true
84
+ const pendingAnswer = () => answer('pending', { success: true, pending: true, message: 'Confirmation required' })
85
+ const subscribedAnswer = () => answer('subscribed', { success: true, message: 'Subscribed' })
74
86
 
75
87
  if (!email)
76
88
  return answer('invalid', { success: false, message: 'A valid email is required' })
77
89
 
90
+ // A bot filled the hidden field. Tell it what a person would be told and
91
+ // keep nothing, so it has no reason to try another way in.
92
+ if (String(request.get('website') || '').trim())
93
+ return (list === undefined && defaultListDoubleOptIn) ? pendingAnswer() : subscribedAnswer()
94
+
78
95
  try {
79
96
  // `confirmation: 'list'`: a list with double opt-in on holds the address
80
97
  // as pending until it confirms; any other list subscribes it at once.
81
- const result = await subscribe(email, { list, source, publicOnly: true, confirmation: 'list' })
98
+ const result = await subscribe(email, { list, source, publicOnly: true, confirmation: 'list', defaultListDoubleOptIn })
82
99
 
83
100
  if (result.pending) {
84
101
  // New, returning, or asking again while still pending: (re)send the
@@ -86,22 +103,21 @@ export default new Action({
86
103
  if (result.created || result.reactivated)
87
104
  await SubscriberEmail.create({ email, source, subscriber_id: result.subscriberId })
88
105
  confirmRequest(email, result.token)
89
- return answer('pending', { success: true, pending: true, message: 'Confirmation required' })
106
+ return pendingAnswer()
90
107
  }
91
108
 
109
+ // Already on the list: answered like a new signup on the same list,
110
+ // and nothing is sent, so the address's owner is not emailed by
111
+ // whoever typed it.
92
112
  if (!result.created && !result.reactivated)
93
- return answer('already', { success: true, message: 'Already subscribed' })
113
+ return result.confirms ? pendingAnswer() : subscribedAnswer()
94
114
 
95
115
  // The signup log, tied to the person it belongs to.
96
116
  await SubscriberEmail.create({ email, source, subscriber_id: result.subscriberId })
97
117
 
98
118
  welcome(email, result.token)
99
119
 
100
- return answer('subscribed', {
101
- success: true,
102
- message: result.reactivated ? 'Subscribed again' : 'Subscribed',
103
- subscriber: { email, listId: result.listId },
104
- })
120
+ return subscribedAnswer()
105
121
  }
106
122
  catch (err) {
107
123
  // A form naming a list that is missing or private: say so plainly, as
@@ -0,0 +1,33 @@
1
+ import { Job } from '@stacksjs/queue'
2
+ import { Every } from '@stacksjs/types'
3
+
4
+ // `as const` makes this a non-empty tuple, so `quotes[0]` is a known element
5
+ // rather than `string | undefined` - which is what lets it serve as the
6
+ // fallback for the computed index below.
7
+ const quotes = [
8
+ 'Simplicity is the ultimate sophistication. - Leonardo da Vinci',
9
+ 'The best way to predict the future is to invent it. - Alan Kay',
10
+ 'Code is like humor. When you have to explain it, it\'s bad. - Cory House',
11
+ 'First, solve the problem. Then, write the code. - John Johnson',
12
+ 'Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler',
13
+ 'The only way to do great work is to love what you do. - Steve Jobs',
14
+ 'Talk is cheap. Show me the code. - Linus Torvalds',
15
+ 'Make it work, make it right, make it fast. - Kent Beck',
16
+ ] as const
17
+
18
+ export default new Job({
19
+ name: 'Inspire',
20
+ description: 'A demo job that logs an inspirational quote',
21
+ queue: 'default',
22
+ tries: 3,
23
+ backoff: 3,
24
+ rate: Every.Hour,
25
+
26
+ handle: (): { quote: string } => {
27
+ // Indexing is `string | undefined` under `noUncheckedIndexedAccess`, and
28
+ // an out-of-range read would otherwise print the word "undefined".
29
+ const quote = quotes[Math.floor(Math.random() * quotes.length)] ?? quotes[0]
30
+ console.log(`\n ✨ ${quote}\n`)
31
+ return { quote }
32
+ },
33
+ })
@@ -37,6 +37,7 @@ export function createDashboardSidebarOrder(options: {
37
37
  const pane = options.pane()
38
38
  if (!pane) return
39
39
  const sectionNodes = new Map([...pane.querySelectorAll<HTMLElement>('[data-sidebar-section]')].map(node => [node.dataset.sectionId!, node]))
40
+ const sectionLinks = new Map([...pane.querySelectorAll<HTMLElement>('[data-dashboard-section-sidebar] [data-section-id]')].map(link => [link.dataset.sectionId, link]))
40
41
  const sorted = orderSidebarSections(options.sections, order)
41
42
  groups.set('sections', sorted.map(section => section.id))
42
43
  function visit(items: WebSidebarItem[], section: string, ancestors: string[] = []) {
@@ -51,6 +52,8 @@ export function createDashboardSidebarOrder(options: {
51
52
  for (const section of sorted) {
52
53
  const node = sectionNodes.get(section.id)
53
54
  if (node) node.parentElement!.append(node)
55
+ const link = sectionLinks.get(section.id)
56
+ link?.parentElement?.append(link)
54
57
  visit(section.items, section.id)
55
58
  }
56
59
  }
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.672",
5
+ "version": "0.75.683",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.672",
5
+ "version": "0.75.683",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,14 +45,15 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.672",
49
- "@stacksjs/sanitizer": "^0.2.930",
50
- "@stacksjs/stx": "^0.2.930",
51
- "@stacksjs/strings": "0.75.672",
48
+ "@stacksjs/desktop": "^0.2.934",
49
+ "@stacksjs/mobile": "0.75.683",
50
+ "@stacksjs/sanitizer": "^0.2.934",
51
+ "@stacksjs/stx": "^0.2.934",
52
+ "@stacksjs/strings": "0.75.683",
52
53
  "@xterm/addon-fit": "^0.11.0",
53
54
  "@xterm/xterm": "^6.0.0",
54
55
  "ts-qr-codes": "^0.1.8",
55
- "@stacksjs/support": "0.75.672",
56
- "@stacksjs/browser": "0.75.672"
56
+ "@stacksjs/support": "0.75.683",
57
+ "@stacksjs/browser": "0.75.683"
57
58
  }
58
59
  }
@@ -46,6 +46,9 @@ declare global {
46
46
  */
47
47
  const query: Record<string, string>
48
48
 
49
+ /** Path parameters for the current STX route, e.g. a file named [section].stx. */
50
+ const params: Record<string, string | undefined>
51
+
49
52
  /**
50
53
  * Cookies injected onto the render context by the serve path.
51
54
  *
@@ -16,16 +16,9 @@ function expiry(method: BillingPaymentMethod): string {
16
16
  }
17
17
  </script>
18
18
 
19
- <section class="overflow-hidden bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700">
20
- <header class="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-neutral-700">
21
- <div>
22
- <h2 class="font-semibold text-base text-gray-900 dark:text-white">Payment methods</h2>
23
- <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400">Methods returned by the configured payment provider.</p>
24
- </div>
25
- <span class="h-5 w-5 text-gray-400 i-hugeicons-credit-card"></span>
26
- </header>
19
+ <SettingsGroup header="Payment methods">
27
20
 
28
- <div :if="methods().length === 0" class="px-6 py-14 text-center">
21
+ <div :if="methods().length === 0" class="px-4 py-7 text-center">
29
22
  <span class="inline-block h-7 w-7 text-gray-400 i-hugeicons-credit-card-not-found"></span>
30
23
  <p class="mt-3 font-medium text-gray-900 text-sm dark:text-white">No payment methods</p>
31
24
  <p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">No provider-backed payment method is attached to this user.</p>
@@ -43,4 +36,4 @@ function expiry(method: BillingPaymentMethod): string {
43
36
  </div>
44
37
  </li>
45
38
  </ul>
46
- </section>
39
+ </SettingsGroup>
@@ -32,16 +32,9 @@ function date(value: string): string {
32
32
  }
33
33
  </script>
34
34
 
35
- <section class="overflow-hidden bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700">
36
- <header class="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-neutral-700">
37
- <div>
38
- <h2 class="font-semibold text-base text-gray-900 dark:text-white">Subscription</h2>
39
- <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400">The active local subscription joined with its payment provider state.</p>
40
- </div>
41
- <span class="h-5 w-5 text-gray-400 i-hugeicons-invoice-03"></span>
42
- </header>
35
+ <SettingsGroup header="Subscription">
43
36
 
44
- <div :if="!subscription()" class="px-6 py-14 text-center">
37
+ <div :if="!subscription()" class="px-4 py-7 text-center">
45
38
  <span class="inline-block h-7 w-7 text-gray-400 i-hugeicons-calendar-remove-02"></span>
46
39
  <p class="mt-3 font-medium text-gray-900 text-sm dark:text-white">No active subscription</p>
47
40
  <p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">An active persisted subscription will appear here after the payment provider confirms it.</p>
@@ -62,4 +55,4 @@ function date(value: string): string {
62
55
  <div class="p-3 bg-gray-50 dark:bg-neutral-900/60 rounded-md"><dt class="text-gray-500 text-xs dark:text-neutral-400">Renewal</dt><dd class="mt-1 font-semibold text-gray-900 text-sm dark:text-white">{{ subscription()?.cancelAtPeriodEnd ? 'Cancellation scheduled' : 'Provider managed' }}</dd></div>
63
56
  </dl>
64
57
  </div>
65
- </section>
58
+ </SettingsGroup>
@@ -40,25 +40,23 @@ async function loadBilling(): Promise<void> {
40
40
  onMount(() => { void loadBilling() })
41
41
  </script>
42
42
 
43
- <div class="space-y-6">
44
- <header class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
45
- <div>
46
- <p class="font-semibold text-blue-600 text-xs tracking-wide uppercase dark:text-blue-400">Settings</p>
47
- <h1 class="mt-1 font-bold text-2xl text-gray-900 dark:text-white">Billing</h1>
48
- <p class="mt-1 max-w-2xl text-gray-500 text-sm dark:text-neutral-400">Inspect the active subscription, provider-backed payment methods, and persisted transaction records for the signed-in user.</p>
49
- </div>
50
- <Button :if="authenticated()" variant="secondary" :loading="loading()" @click="loadBilling()">
51
- <span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>
52
- Refresh
53
- </Button>
54
- </header>
43
+ <div class="dashboard-settings-stack">
44
+ <div :if="authenticated()">
45
+ <SettingsGroup>
46
+ <SettingsRow label="Billing details" setting="refresh-billing">
47
+ <Button variant="secondary" size="sm" :loading="loading()" @click="loadBilling()">
48
+ Refresh
49
+ </Button>
50
+ </SettingsRow>
51
+ </SettingsGroup>
52
+ </div>
55
53
 
56
- <section :if="loading()" aria-live="polite" class="flex items-center justify-center py-20 text-gray-500 text-sm dark:text-neutral-400 bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700">
54
+ <section :if="loading()" aria-live="polite" class="flex items-center justify-center py-20 text-gray-500 text-sm dark:text-neutral-400" data-settings-panel>
57
55
  <span class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
58
56
  Loading billing details
59
57
  </section>
60
58
 
61
- <section :else-if="!authenticated()" class="p-8 text-center bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700">
59
+ <section :else-if="!authenticated()" class="p-8 text-center" data-settings-panel>
62
60
  <span class="inline-block h-8 w-8 text-gray-400 i-hugeicons-square-lock-02"></span>
63
61
  <h2 class="mt-3 font-semibold text-gray-900 text-lg dark:text-white">Sign in to view billing</h2>
64
62
  <p class="mt-2 mx-auto max-w-lg text-gray-500 text-sm dark:text-neutral-400">Billing APIs are scoped to the authenticated user. No account or payment data is exposed to an anonymous dashboard session.</p>
@@ -78,7 +76,7 @@ onMount(() => { void loadBilling() })
78
76
  </ul>
79
77
  </div>
80
78
 
81
- <div class="grid gap-6 xl:grid-cols-[minmax(0,1fr)_minmax(22rem,0.8fr)]">
79
+ <div class="grid gap-3 sm:grid-cols-2">
82
80
  <BillingPlanSummary :subscription="subscription()" />
83
81
  <BillingPaymentMethodsPanel :methods="paymentMethods()" />
84
82
  </div>
@@ -24,14 +24,7 @@ const rows = derived(() => transactions().map(transaction => ({
24
24
  })))
25
25
  </script>
26
26
 
27
- <section class="overflow-hidden bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700">
28
- <header class="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-neutral-700">
29
- <div>
30
- <h2 class="font-semibold text-base text-gray-900 dark:text-white">Transaction history</h2>
31
- <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400">Persisted PaymentTransaction model records for this user.</p>
32
- </div>
33
- <span class="h-5 w-5 text-gray-400 i-hugeicons-transaction-history"></span>
34
- </header>
27
+ <SettingsGroup header="Transaction history">
35
28
 
36
29
  <Table
37
30
  :columns="COLUMNS"
@@ -41,4 +34,4 @@ const rows = derived(() => transactions().map(transaction => ({
41
34
  empty-title="No transactions recorded"
42
35
  empty-description="Successful persisted billing transactions will appear here."
43
36
  />
44
- </section>
37
+ </SettingsGroup>
@@ -0,0 +1,72 @@
1
+ <script server>
2
+ import type { DashboardNavigationHub } from '@stacksjs/defaults/resources/functions/dashboard/section-navigation'
3
+
4
+ const { hub } = defineProps<{ hub: DashboardNavigationHub }>()
5
+ defineClientPayload({ hub })
6
+ </script>
7
+
8
+ <script client>
9
+ import { getDashboardSectionLanding } from '@stacksjs/defaults/resources/functions/dashboard/section-landing'
10
+ import { authStore } from '@stacksjs/defaults/views/dashboard/stores/auth'
11
+
12
+ const section = {{ hub }}
13
+ const landing = derived(() => getDashboardSectionLanding(section, authStore.roles(), authStore.unauthenticated()))
14
+ const primary = derived(() => landing().primary)
15
+ </script>
16
+
17
+ <div class="dashboard-section-landing" data-dashboard-section-page data-section-id="{{ hub.id }}">
18
+ <div class="dashboard-section-stage">
19
+ <header class="dashboard-section-intro">
20
+ <h1 data-dashboard-ink>{{ hub.label }}</h1>
21
+ <p :if="landing().introduction" data-dashboard-muted :text="landing().introduction"></p>
22
+ </header>
23
+
24
+ <div class="dashboard-section-art">
25
+ <div class="dashboard-section-orb" aria-hidden="true">
26
+ <span class="{{ hub.icon }}"></span>
27
+ </div>
28
+ <div :if="primary()" class="dashboard-section-primary">
29
+ <a :href="primary()?.href" data-stx-link data-dashboard-section-primary
30
+ :aria-label="'Open ' + primary()?.label">
31
+ <span class="i-f7-arrow-right" aria-hidden="true"></span>
32
+ Open
33
+ </a>
34
+ <span data-dashboard-muted :text="primary()?.label"></span>
35
+ </div>
36
+ </div>
37
+
38
+ <nav :if="landing().featured.length > 0" class="dashboard-section-features" aria-label="Featured pages">
39
+ <a :for="page in landing().featured" :href="page.href" data-stx-link class="dashboard-section-row" data-dashboard-destination>
40
+ <span class="dashboard-section-row-icon" aria-hidden="true"><span :class="page.icon"></span></span>
41
+ <span class="dashboard-section-row-copy">
42
+ <strong :text="page.label"></strong>
43
+ <span :if="page.description" data-dashboard-muted :text="page.description"></span>
44
+ </span>
45
+ <span class="dashboard-section-chevron i-f7-chevron-right" aria-hidden="true"></span>
46
+ </a>
47
+ </nav>
48
+ <p :if="!authStore.loading() && !primary()" class="dashboard-section-features" data-dashboard-muted>No pages are available in this section.</p>
49
+ </div>
50
+
51
+ <div :if="landing().groups.length > 0" class="dashboard-section-panels">
52
+ <section :for="group in landing().groups" class="dashboard-section-panel">
53
+ <h2 data-dashboard-ink :text="group.title"></h2>
54
+ <a :for="page in group.first" :href="page.href" data-stx-link class="dashboard-section-row" data-dashboard-destination>
55
+ <span class="dashboard-section-row-icon" aria-hidden="true"><span :class="page.icon"></span></span>
56
+ <span class="dashboard-section-row-copy">
57
+ <strong :text="page.label"></strong>
58
+ <span :if="page.description && group.title !== 'Model records'" data-dashboard-muted :text="page.description"></span>
59
+ </span>
60
+ <span class="dashboard-section-chevron i-f7-chevron-right" aria-hidden="true"></span>
61
+ </a>
62
+ <details :if="group.more.length > 0" class="dashboard-section-more">
63
+ <summary :text="'Show ' + group.more.length + ' more'"></summary>
64
+ <a :for="page in group.more" :href="page.href" data-stx-link class="dashboard-section-row" data-dashboard-destination>
65
+ <span class="dashboard-section-row-icon" aria-hidden="true"><span :class="page.icon"></span></span>
66
+ <span class="dashboard-section-row-copy"><strong :text="page.label"></strong></span>
67
+ <span class="dashboard-section-chevron i-f7-chevron-right" aria-hidden="true"></span>
68
+ </a>
69
+ </details>
70
+ </section>
71
+ </div>
72
+ </div>