@stacksjs/defaults 0.75.712 → 0.75.716

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 (45) hide show
  1. package/ai/skills/stacks-dashboard/SKILL.md +20 -6
  2. package/ai/skills/stacks-dns/SKILL.md +17 -2
  3. package/ai/skills/stacks-native/CATALOG.md +5 -5
  4. package/app/Actions/Dashboard/Infrastructure/dns-overview.ts +2 -2
  5. package/app/Actions/Dashboard/Infrastructure/environment-file.ts +1 -12
  6. package/functions/dashboard-api.ts +5 -0
  7. package/ide/vscode/package.json +1 -1
  8. package/package.json +6 -5
  9. package/resources/components/Dashboard/Buddy/BuddyAssistant.stx +1 -1
  10. package/resources/components/Dashboard/DashboardSectionSidebar.stx +12 -3
  11. package/resources/components/Dashboard/Environment/EnvironmentDashboard.stx +88 -68
  12. package/resources/components/Dashboard/Infrastructure/DnsDashboard.stx +1 -0
  13. package/resources/components/Dashboard/Projects/GitHubIssuesDashboard.stx +165 -0
  14. package/resources/components/Dashboard/Settings/DashboardSettingsIntro.stx +10 -0
  15. package/resources/components/Dashboard/Settings/DashboardSettingsSearch.stx +32 -0
  16. package/resources/components/Dashboard/Settings/DnsRecordsSettings.stx +181 -0
  17. package/resources/components/Dashboard/Settings/MailSettingsDashboard.stx +7 -5
  18. package/resources/components/Dashboard/Settings/SettingsCodeEditor.stx +27 -0
  19. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +187 -270
  20. package/resources/components/Dashboard/Settings/SettingsPicker.stx +87 -0
  21. package/resources/functions/dashboard/environment-value.ts +11 -0
  22. package/resources/functions/dashboard/page-availability.ts +1 -1
  23. package/resources/functions/dashboard/project-config-sections.ts +105 -0
  24. package/resources/functions/dashboard/section-landing.ts +1 -1
  25. package/resources/functions/dashboard/settings-panes.ts +26 -0
  26. package/resources/functions/dashboard/sidebar.ts +7 -7
  27. package/styles/dashboard-theme.css +281 -25
  28. package/views/dashboard/composables/dashboard-theme-bootstrap.ts +7 -0
  29. package/views/dashboard/composables/settings-dialog.ts +22 -0
  30. package/views/dashboard/composables/settings-window.ts +10 -4
  31. package/views/dashboard/composables/useProjectConfigEditor.ts +244 -0
  32. package/views/dashboard/composables/useSettingsWindow.ts +23 -1
  33. package/views/dashboard/github-issues.stx +18 -0
  34. package/views/dashboard/layouts/default.stx +1 -1
  35. package/views/dashboard/layouts/settings.stx +147 -10
  36. package/views/dashboard/settings/appearance.stx +2 -3
  37. package/views/dashboard/settings/billing.stx +2 -3
  38. package/views/dashboard/settings/config/[section].stx +22 -0
  39. package/views/dashboard/{environment/index.stx → settings/environment.stx} +1 -1
  40. package/views/dashboard/settings/index.stx +1 -3
  41. package/views/dashboard/settings/mail.stx +2 -3
  42. package/views/dashboard/settings/software-update.stx +2 -3
  43. package/resources/components/Dashboard/CodeEditor.stx +0 -73
  44. package/resources/components/Dashboard/Settings/DashboardSettingsFrame.stx +0 -101
  45. package/resources/functions/dashboard/config-io.ts +0 -401
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: stacks-dashboard
3
- description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 452 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
3
+ description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 456 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
4
4
  license: MIT
5
5
  compatibility: Bun >= 1.3.0, TypeScript
6
6
  allowed-tools: Read Edit Write Bash Grep Glob
@@ -8,7 +8,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
8
8
 
9
9
  # Stacks Dashboard
10
10
 
11
- The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 452 components, and a multi-section layout.
11
+ The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 456 components, and a multi-section layout.
12
12
 
13
13
  ## Key Paths
14
14
  - Dashboard components: `storage/framework/defaults/resources/components/Dashboard/`
@@ -244,13 +244,14 @@ inject message HTML into the dashboard document.
244
244
  - `/packages`, `/dependencies` - package and dependency inspection
245
245
 
246
246
  ### Settings
247
- - `/settings` - typed `config/*.ts` browser and editor
247
+ - `/settings` - Command-Comma opens General in the Craft Settings window. Project settings have dedicated panes under `/settings/config/:section` for database, security, networking, and other concerns. The sidebar shows sections with files and searches for individual configs. Unknown project files appear in Custom Configuration. Field forms organize related literal values and use adjacent source comments as help. TypeScript mode edits bindings, named exports, and structure. The dev dashboard loads one selected file at a time and refuses to overwrite newer disk edits.
248
248
  - `/settings/appearance` - dashboard appearance
249
249
  - `/settings/billing` - account billing
250
250
  - `/settings/mail` - mail configuration
251
- - `/environment` - environment summary
251
+ - `/settings/environment` - edit the env files this project loads
252
252
  - `/access-tokens` - access-token management
253
- - `/cloud`, `/dns`, `/mailboxes` - infrastructure-specific settings
253
+ - `/settings/config/dns` - list and add app DNS declarations for the next deployment
254
+ - `/cloud`, `/dns`, `/mailboxes` - infrastructure views
254
255
 
255
256
  ### Deployments
256
257
  - `/deployments` - deployment history, deployment controls, the custom
@@ -578,6 +579,19 @@ At 1024px and wider, the desktop sidebar keeps its 250px width, fixed
578
579
  placement, persisted collapse state, and `--stx-sidebar-width` content-shell
579
580
  contract across themes.
580
581
 
582
+ The Settings layout keeps the Craft sidebar, search, and toolbar outside the
583
+ routed outlet. Settings links, search results, and history replace the detail
584
+ pane without a view transition. Keep individual Settings views inside that
585
+ outlet so opening a pane preserves the sidebar's focus and scroll position.
586
+ Use `SettingsPicker` for choices in Settings. It opens a Craft system menu
587
+ with the current choice checked and renders an ordinary select in the
588
+ browser. Use the shared Settings group, row, and switch for inline
589
+ preferences. When discarding changes needs confirmation, ask Craft for a
590
+ system dialog and use the shared confirm dialog on the web.
591
+ Use `SettingsCodeEditor` for Settings source. It wraps the shared STX editor
592
+ with incremental `ts-syntax-highlighter` tokenization and Settings keyboard
593
+ shortcuts.
594
+
581
595
  ### Reactive page components
582
596
 
583
597
  Keep route views thin. Place stateful page implementations under
@@ -854,7 +868,7 @@ or a fake success response.
854
868
  - Dashboard runs on port 3002 by default (separate from frontend on 3000)
855
869
  - Dashboard components use STX templating with ts-css utilities
856
870
  - Dashboard routes are registered from `storage/framework/defaults/routes/`, not from a generated type file
857
- - Settings panels read/write from the corresponding `config/*.ts` files
871
+ - Project Configuration reads and writes project TypeScript source under `config/`. Environment variables are edited in the Environment pane of the same Settings window.
858
872
  - Models with `useApi` get generated REST actions and routes, not bespoke dashboard views
859
873
  - `dashboard: { highlight: true }` makes models prominent in the dashboard
860
874
  - Dashboard layout uses a sidebar + navbar pattern
@@ -27,8 +27,8 @@ desiredDnsRecords(domain, config) converts native config to provider records.
27
27
  planDnsSync(desired, current, { zone? }) returns create/keep/skip with reasons.
28
28
  syncDnsConfig(domain, config, { dryRun?, provider?, resolver? }) reports created/kept/failed,
29
29
  failures/skipped/applied/provider. It only creates missing declared records;
30
- it never deletes or overwrites an existing value. Single-value A/AAAA/CNAME
31
- records are kept when present; TXT/MX can add distinct values. Editing config
30
+ it never deletes or overwrites an existing value. An identical A/AAAA/CNAME
31
+ record is kept and a conflicting value is skipped; TXT/MX can add distinct values. Editing config
32
32
  does not imply changing an already-present provider value.
33
33
 
34
34
  dryRun reads public DNS without provider credentials; that is not a complete
@@ -38,6 +38,21 @@ and credentials. A missing provider yields an unapplied plan, not fake success.
38
38
  The native sync interface supports Route53/Porkbun/GoDaddy/Cloudflare through
39
39
  the provider factory; retained request/planner tests are not live provider parity.
40
40
 
41
+ ## Settings and deployments
42
+
43
+ Command-Comma → DNS Records lists the project declarations and adds a
44
+ record to `config/dns.ts`. A record added here stores a fully qualified
45
+ name under the chosen application hostname, so a deploy for a different
46
+ hostname or environment does not copy it. The TypeScript view handles
47
+ computed arrays and other advanced configurations. The DNS overview links
48
+ to this same editor.
49
+
50
+ `buddy deploy --dry-run` lists the eligible declarations without calling a
51
+ provider. Normal deployments add missing records when DNS publication is
52
+ enabled and a provider serves the domain. Conflicts with existing record
53
+ values or deployment-owned routing are reported. The declaration sync
54
+ does not remove existing provider records.
55
+
41
56
  ## Native config record shapes
42
57
 
43
58
  config/dns.ts uses a/aaaa records with address, cname with target, txt with
@@ -11,7 +11,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
11
11
  | Package | Task guidance | Source entry | Retained tests |
12
12
  |---|---|---|---|
13
13
  | `@stacksjs/action-runner` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/action-runner/src/index.ts) | 1 |
14
- | `@stacksjs/actions` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/index.ts) | 133 |
14
+ | `@stacksjs/actions` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/index.ts) | 135 |
15
15
  | `@stacksjs/ai` | [`stacks-ai`](../stacks-ai/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/index.ts) | 28 |
16
16
  | `@stacksjs/alias` | [`stacks-alias`](../stacks-alias/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/alias/src/index.ts) | 3 |
17
17
  | `@stacksjs/analytics` | [`stacks-analytics`](../stacks-analytics/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/analytics/src/index.ts) | 7 |
@@ -80,7 +80,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
80
80
  | `@stacksjs/scheduler` | [`stacks-scheduler`](../stacks-scheduler/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/index.ts) | 24 |
81
81
  | `@stacksjs/search-engine` | [`stacks-search-engine`](../stacks-search-engine/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/search-engine/src/index.ts) | 11 |
82
82
  | `@stacksjs/security` | [`stacks-security`](../stacks-security/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/security/src/index.ts) | 12 |
83
- | `@stacksjs/server` | [`stacks-server`](../stacks-server/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/index.ts) | 32 |
83
+ | `@stacksjs/server` | [`stacks-server`](../stacks-server/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/index.ts) | 33 |
84
84
  | `@stacksjs/shell` | [`stacks-shell`](../stacks-shell/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/shell/src/index.ts) | 1 |
85
85
  | `@stacksjs/sites` | [`stacks-sites`](../stacks-sites/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/sites/src/index.ts) | 3 |
86
86
  | `@stacksjs/skills` | [`stacks-skills`](../stacks-skills/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/skills/src/index.ts) | 1 |
@@ -123,7 +123,7 @@ Declared runtime exports: `BlogAdminError`, `DEFAULT_IOS_DEPENDENCIES`, `DEFAULT
123
123
 
124
124
  Local source modules: [src/action.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/action.ts), [src/add.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/add.ts), [src/blog-admin.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/blog-admin.ts), [src/build/ios-toolchain.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/build/ios-toolchain.ts), [src/build/macos-native.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/build/macos-native.ts), [src/commit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/commit.ts), [src/dev/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/dev/index.ts), [src/discover-packages.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/discover-packages.ts), [src/generate/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/generate/index.ts), [src/github-release.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/github-release.ts), [src/helpers/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/helpers/index.ts), [src/library/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/library/index.ts), [src/lint/lint.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/lint/lint.ts), [src/lint/stx-gate.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/lint/stx-gate.ts), [src/make-command.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-command.ts), [src/make-job.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-job.ts), [src/make-policy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-policy.ts), [src/make-resource.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-resource.ts), [src/make.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make.ts), [src/publication-preflight.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/publication-preflight.ts), [src/release-evidence.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/release-evidence.ts), [src/reviewos-evidence.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/reviewos-evidence.ts), [src/reviewos-workflows.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/reviewos-workflows.ts), [src/scaffold-crud.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/scaffold-crud.ts), [src/setup/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/setup/index.ts), [src/stacks.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/stacks.ts), [src/stx-source.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/stx-source.ts), [src/upgrade/package-project.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/upgrade/package-project.ts), [src/upgrade/route-actions.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/upgrade/route-actions.ts).
125
125
 
126
- Evidence directory: [133 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
126
+ Evidence directory: [135 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
127
127
 
128
128
  ### @stacksjs/ai
129
129
 
@@ -789,9 +789,9 @@ Guidance: [`stacks-server`](../stacks-server/SKILL.md). Source: [storage/framewo
789
789
 
790
790
  Declared runtime exports: `server`.
791
791
 
792
- Local source modules: [src/config.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/config.ts), [src/controllers/base.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/controllers/base.ts), [src/imports.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/imports.ts), [src/maintenance.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/maintenance.ts), [src/proxy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/proxy.ts), [src/redirects.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/redirects.ts), [src/request-body.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/request-body.ts), [src/response-headers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/response-headers.ts), [src/rewrites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/rewrites.ts), [src/security-headers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/security-headers.ts), [src/shadowed-defaults.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/shadowed-defaults.ts).
792
+ Local source modules: [src/config.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/config.ts), [src/controllers/base.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/controllers/base.ts), [src/domain-route-scopes.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/domain-route-scopes.ts), [src/imports.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/imports.ts), [src/maintenance.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/maintenance.ts), [src/proxy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/proxy.ts), [src/redirects.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/redirects.ts), [src/request-body.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/request-body.ts), [src/response-headers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/response-headers.ts), [src/rewrites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/rewrites.ts), [src/security-headers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/security-headers.ts), [src/shadowed-defaults.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/shadowed-defaults.ts).
793
793
 
794
- Evidence directory: [32 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
794
+ Evidence directory: [33 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
795
795
 
796
796
  ### @stacksjs/shell
797
797
 
@@ -51,10 +51,10 @@ function recordValue(type: DnsRecordType, item: DataRecord): string {
51
51
  if (type === 'CNAME')
52
52
  return text(item.target) ?? text(item.value) ?? ''
53
53
  if (type === 'MX')
54
- return text(item.server) ?? text(item.value) ?? ''
54
+ return text(item.mailServer) ?? text(item.server) ?? text(item.value) ?? ''
55
55
  if (type === 'A' || type === 'AAAA')
56
56
  return text(item.address) ?? text(item.value) ?? ''
57
- return text(item.value) ?? ''
57
+ return text(item.content) ?? text(item.value) ?? ''
58
58
  }
59
59
 
60
60
  function configuredRecords(dnsConfig: DataRecord): DashboardDnsRecord[] {
@@ -10,6 +10,7 @@ import {
10
10
  } from 'node:fs/promises'
11
11
  import { basename, dirname, join } from 'node:path'
12
12
  import { frameworkRuntimePath, projectPath } from '@stacksjs/path'
13
+ import { serializeEnvironmentValue } from '../../../../resources/functions/dashboard/environment-value'
13
14
 
14
15
  const MAX_ENV_BYTES = 1024 * 1024
15
16
  const ENV_KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/
@@ -105,18 +106,6 @@ function parseEnvironmentValue(source: string): string {
105
106
  .replace(/\\\\/g, '\\')
106
107
  }
107
108
 
108
- function serializeEnvironmentValue(value: string): string {
109
- if (!value)
110
- return ''
111
- if (/^[A-Za-z0-9_./:@+-]+$/.test(value))
112
- return value
113
-
114
- return `"${value
115
- .replace(/\\/g, '\\\\')
116
- .replace(/"/g, '\\"')
117
- .replace(/\n/g, '\\n')}"`
118
- }
119
-
120
109
  /**
121
110
  * Write a file the way an env file has to be written: whole or not at all
122
111
  * (a same-directory rename), and readable by its owner only.
@@ -23,6 +23,8 @@ export interface ApiRequestOptions {
23
23
  /** Multipart request body. The browser supplies its boundary header. */
24
24
  formData?: FormData
25
25
  signal?: AbortSignal
26
+ /** Explicit access to the same-origin local project source API. */
27
+ projectConfig?: boolean
26
28
  }
27
29
 
28
30
  export class DashboardApiError extends Error {
@@ -47,6 +49,8 @@ async function dashboardResponse(path: string, options: ApiRequestOptions, accep
47
49
  const method = options.method ?? 'GET'
48
50
  const headers: Record<string, string> = { accept }
49
51
  const authToken = useAuth().getToken()
52
+ if (options.projectConfig)
53
+ headers['X-Stacks-Config'] = '1'
50
54
 
51
55
  if (options.body !== undefined && options.formData)
52
56
  throw new TypeError('dashboardApi accepts either body or formData, not both.')
@@ -66,6 +70,7 @@ async function dashboardResponse(path: string, options: ApiRequestOptions, accep
66
70
  headers: requestHeaders,
67
71
  credentials: 'same-origin',
68
72
  signal: options.signal,
73
+ ...(options.projectConfig && { cache: 'no-store' }),
69
74
  ...(options.body !== undefined && { body: JSON.stringify(options.body) }),
70
75
  ...(options.formData && { body: options.formData }),
71
76
  })
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.712",
5
+ "version": "0.75.716",
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.712",
5
+ "version": "0.75.716",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -46,14 +46,15 @@
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
48
  "@stacksjs/desktop": "^0.2.960",
49
- "@stacksjs/mobile": "0.75.712",
49
+ "@stacksjs/mobile": "0.75.716",
50
50
  "@stacksjs/sanitizer": "^0.2.960",
51
51
  "@stacksjs/stx": "^0.2.960",
52
- "@stacksjs/strings": "0.75.712",
52
+ "@stacksjs/strings": "0.75.716",
53
53
  "@xterm/addon-fit": "^0.11.0",
54
54
  "@xterm/xterm": "^6.0.0",
55
55
  "ts-qr-codes": "^0.1.8",
56
- "@stacksjs/support": "0.75.712",
57
- "@stacksjs/browser": "0.75.712"
56
+ "ts-syntax-highlighter": "^0.2.21",
57
+ "@stacksjs/support": "0.75.716",
58
+ "@stacksjs/browser": "0.75.716"
58
59
  }
59
60
  }
@@ -111,7 +111,7 @@ onMount(() => {
111
111
  <code :if="chatState()?.missingKey" class="inline-block mt-3 px-2 py-1 font-mono text-amber-900 text-xs dark:text-amber-200 bg-amber-100 dark:bg-amber-950 rounded">
112
112
  {{ chatState()?.missingKey }}
113
113
  </code>
114
- <StxLink to="/environment" class="inline-flex items-center ml-3 font-medium text-amber-800 text-sm dark:text-amber-300">
114
+ <StxLink to="/settings/environment" class="inline-flex items-center ml-3 font-medium text-amber-800 text-sm dark:text-amber-300">
115
115
  Open environment
116
116
  <span class="ml-1 h-4 w-4 i-hugeicons-arrow-right-02"></span>
117
117
  </StxLink>
@@ -1,8 +1,10 @@
1
1
  <script server>
2
2
  import type { DashboardNavigationHub } from '@stacksjs/defaults/resources/functions/dashboard/section-navigation'
3
+ import type { WebSidebarItem } from '@stacksjs/defaults/resources/functions/dashboard/sidebar'
3
4
 
4
- const { sectionHubs = [] } = defineProps<{ sectionHubs: DashboardNavigationHub[] }>()
5
- defineClientPayload({ sectionHubs })
5
+ const { sectionHubs = [], primaryItems = [] } = defineProps<{ sectionHubs: DashboardNavigationHub[], primaryItems?: WebSidebarItem[] }>()
6
+ const primaryLinks = primaryItems.filter(item => item.href && item.href !== '/')
7
+ defineClientPayload({ sectionHubs, primaryLinks })
6
8
  </script>
7
9
 
8
10
  <script client>
@@ -11,6 +13,7 @@ import { useAppearance } from '@stacksjs/defaults/views/dashboard/composables/us
11
13
  import { authStore } from '@stacksjs/defaults/views/dashboard/stores/auth'
12
14
 
13
15
  const hubs = {{ sectionHubs }}
16
+ const links = {{ primaryLinks }}
14
17
  const rail = useRef<HTMLElement>('dashboardSectionSidebar')
15
18
  const route = useRoute()
16
19
  const appearance = useAppearance()
@@ -28,7 +31,7 @@ function syncVisibility(): void {
28
31
  function syncSelection(path = route.path): void {
29
32
  const current = dashboardNavigationPath(path)
30
33
  const settings = current === '/settings' || current.startsWith('/settings/')
31
- const active = settings ? 'settings' : activeDashboardSection(hubs, current)
34
+ const active = settings ? 'settings' : links.find(link => link.href === current)?.id ?? activeDashboardSection(hubs, current)
32
35
  for (const link of rail.current?.querySelectorAll<HTMLElement>('[data-dashboard-section-entry]') ?? []) {
33
36
  if (link.dataset.sectionId === active)
34
37
  link.setAttribute('aria-current', link.getAttribute('href') === current ? 'page' : 'location')
@@ -62,6 +65,12 @@ onMount(() => {
62
65
  <span class="dashboard-section-icon" aria-hidden="true"><span class="i-f7-house"></span></span>
63
66
  <span>Home</span>
64
67
  </a>
68
+ @foreach(primaryLinks as link)
69
+ <a href="{{ link.href }}" data-stx-link data-dashboard-section-entry data-section-id="{{ link.id }}">
70
+ <span class="dashboard-section-icon" aria-hidden="true"><span class="{{ link.icon }}"></span></span>
71
+ <span>{{ link.label }}</span>
72
+ </a>
73
+ @endforeach
65
74
  @foreach(sectionHubs as hub)
66
75
  <a href="{{ hub.href }}" data-stx-link data-dashboard-section-entry data-section-id="{{ hub.id }}">
67
76
  <span class="dashboard-section-icon" aria-hidden="true"><span class="{{ hub.icon }}"></span></span>
@@ -1,5 +1,7 @@
1
1
  <script client>
2
2
  import { DashboardApiError, dashboardApi } from '@stacksjs/defaults/functions/dashboard-api'
3
+ import { serializeEnvironmentValue } from '@stacksjs/defaults/resources/functions/dashboard/environment-value'
4
+ import { confirmSettingsDiscard } from '@stacksjs/defaults/views/dashboard/composables/settings-dialog'
3
5
 
4
6
  interface EnvironmentFileIssue {
5
7
  line: number
@@ -55,6 +57,8 @@ const showAddModal = state(false)
55
57
  const showBackupModal = state(false)
56
58
  const isLoading = state(true)
57
59
  const isSaving = state(false)
60
+ const confirming = state(false)
61
+ const discardAction = state<(() => void) | null>(null)
58
62
  const loadError = state('')
59
63
  const saveError = state('')
60
64
  const successMessage = state('')
@@ -65,6 +69,10 @@ const newVarKey = state('')
65
69
  const newVarValue = state('')
66
70
  const newVarDescription = state('')
67
71
  const addError = state('')
72
+ const addFormId = useId('add-environment-variable')
73
+ const fileOptions = derived(() => files().map(name => ({ value: name, label: name })))
74
+ const discardTitle = 'Discard unsaved edits?'
75
+ const discardDescription = 'Your unsaved changes to this environment file will be lost.'
68
76
 
69
77
  const hasBackup = derived(() => backupContent().length > 0)
70
78
  const isBusy = derived(() => isLoading() || isSaving())
@@ -105,15 +113,53 @@ async function loadEnvironment(): Promise<void> {
105
113
  }
106
114
  }
107
115
 
108
- /** Open another env file. Unsaved edits keep the current one open until they are saved. */
109
116
  function openFile(name: string): void {
110
- if (isBusy() || dirty() || name === file())
117
+ if (!files().includes(name) || name === file())
111
118
  return
119
+ void replaceDraft(() => {
120
+ clearFeedback()
121
+ file.set(name)
122
+ void loadEnvironment()
123
+ })
124
+ }
125
+
126
+ function clearFeedback(): void {
112
127
  successMessage.set('')
113
128
  saveError.set('')
114
129
  validationIssues.set([])
115
- file.set(name)
116
- void loadEnvironment()
130
+ }
131
+
132
+ async function replaceDraft(action: () => void): Promise<void> {
133
+ if (isBusy() || confirming() || discardAction())
134
+ return
135
+ if (!dirty()) {
136
+ action()
137
+ return
138
+ }
139
+ confirming.set(true)
140
+ try {
141
+ const confirmed = await confirmSettingsDiscard(discardTitle, discardDescription, 'Discard Changes')
142
+ if (confirmed === null)
143
+ discardAction.set(action)
144
+ else if (confirmed)
145
+ action()
146
+ }
147
+ finally {
148
+ confirming.set(false)
149
+ }
150
+ }
151
+
152
+ function discardAndContinue(): void {
153
+ const action = discardAction()
154
+ discardAction.set(null)
155
+ action?.()
156
+ }
157
+
158
+ function revertChanges(): void {
159
+ void replaceDraft(() => {
160
+ clearFeedback()
161
+ envValues.set(loadedContent())
162
+ })
117
163
  }
118
164
 
119
165
  function openAddModal(): void {
@@ -154,27 +200,31 @@ function addVariable(): void {
154
200
  return
155
201
  }
156
202
 
157
- const duplicate = envValues().split('\n').some(line => line.trim().startsWith(`${key}=`))
203
+ const duplicate = envValues().split('\n').some(line => line.slice(0, line.indexOf('=')).trim() === key && line.includes('='))
158
204
  if (duplicate) {
159
205
  addError.set(`${key} is already defined.`)
160
206
  return
161
207
  }
162
208
 
163
209
  const description = newVarDescription().trim()
164
- const addition = `${description ? `# ${description}\n` : ''}${key}=${newVarValue()}`
210
+ const addition = `${description ? `# ${description}\n` : ''}${key}=${serializeEnvironmentValue(newVarValue())}`
165
211
  const current = envValues().trimEnd()
166
212
  envValues.set(`${current}${current ? '\n\n' : ''}${addition}\n`)
167
213
  closeAddModal()
168
214
  }
169
215
 
170
216
  function loadBackup(): void {
171
- envValues.set(backupContent())
217
+ const content = backupContent()
172
218
  showBackupModal.set(false)
173
- successMessage.set('Backup loaded into the editor. Review it, then save to apply it.')
219
+ void replaceDraft(() => {
220
+ clearFeedback()
221
+ envValues.set(content)
222
+ successMessage.set('Backup loaded into the editor. Review it, then save to apply it.')
223
+ })
174
224
  }
175
225
 
176
226
  async function handleSave(): Promise<void> {
177
- if (isBusy() || !revision())
227
+ if (isBusy() || confirming() || discardAction() || !dirty())
178
228
  return
179
229
 
180
230
  isSaving.set(true)
@@ -210,16 +260,17 @@ async function handleSave(): Promise<void> {
210
260
  }
211
261
 
212
262
  function handlePageKeydown(event: KeyboardEvent): void {
213
- if (event.key === 'Escape') {
214
- showAddModal.set(false)
215
- showBackupModal.set(false)
263
+ if (event.defaultPrevented || confirming() || discardAction() || showBackupModal() || showAddModal()
264
+ || !(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey)
216
265
  return
217
- }
218
-
219
- if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'n') {
266
+ if (event.key.toLowerCase() === 'n' && !isBusy()) {
220
267
  event.preventDefault()
221
268
  openAddModal()
222
269
  }
270
+ if (event.key.toLowerCase() === 's') {
271
+ event.preventDefault()
272
+ void handleSave()
273
+ }
223
274
  }
224
275
 
225
276
  useEventListener('keydown', handlePageKeydown)
@@ -227,53 +278,19 @@ onMount(() => void loadEnvironment())
227
278
  </script>
228
279
 
229
280
  <template>
230
- <div class="flex flex-col gap-6 mx-auto pb-12 pt-6 px-4 sm:px-6 lg:px-8 max-w-7xl">
231
- <PageHeader
232
- title="Environment Variables"
233
- description="Edit the env files the app loads, with validation, conflict protection, and an automatic backup."
234
- >
235
- <template #actions>
236
- <div class="flex gap-2 items-center">
237
- <Button :if="hasBackup()" variant="secondary" @click="showBackupModal.set(true)">
238
- <span class="h-4 w-4 i-hugeicons-clock-03"></span>
239
- Backup
240
- </Button>
241
- <Button @click="openAddModal">
242
- <span class="h-4 w-4 i-hugeicons-add-01"></span>
243
- Add variable
244
- </Button>
281
+ <div class="dashboard-settings-stack">
282
+ <SettingsGroup>
283
+ <SettingsRow :label="files().length > 1 ? 'Environment file' : file()" :description="dirty() ? 'Unsaved changes' : `${variableCount()} variables`">
284
+ <SettingsPicker :if="files().length > 1" :options="fileOptions()" :value="file()"
285
+ ariaLabel="Environment file" :disabled="isBusy() || confirming()" @change="openFile($event)" />
286
+ </SettingsRow>
287
+ <SettingsRow label="Variables">
288
+ <div class="flex flex-wrap gap-2 items-center justify-end">
289
+ <Button :if="hasBackup()" variant="secondary" size="sm" :disabled="isBusy()" @click="showBackupModal.set(true)">View Backup</Button>
290
+ <Button size="sm" :disabled="isBusy()" @click="openAddModal">Add Variable</Button>
245
291
  </div>
246
- </template>
247
- </PageHeader>
248
-
249
- <div class="grid gap-3 sm:grid-cols-3">
250
- <div class="p-4 bg-white dark:bg-neutral-900 border border-stone-200 rounded-xl dark:border-neutral-700">
251
- <p class="font-medium text-stone-500 text-xs tracking-wide uppercase dark:text-neutral-400">File</p>
252
- <p class="mt-1 font-mono text-sm text-stone-900 dark:text-white" :text="file()"></p>
253
- </div>
254
- <div class="p-4 bg-white dark:bg-neutral-900 border border-stone-200 rounded-xl dark:border-neutral-700">
255
- <p class="font-medium text-stone-500 text-xs tracking-wide uppercase dark:text-neutral-400">Variables</p>
256
- <p class="mt-1 font-semibold text-lg text-stone-900 dark:text-white" :text="variableCount()"></p>
257
- </div>
258
- <div class="p-4 bg-white dark:bg-neutral-900 border border-stone-200 rounded-xl dark:border-neutral-700">
259
- <p class="font-medium text-stone-500 text-xs tracking-wide uppercase dark:text-neutral-400">Status</p>
260
- <p class="mt-1 font-medium text-sm" :class="dirty() ? 'text-amber-600 dark:text-amber-400' : 'text-emerald-600 dark:text-emerald-400'" :text="dirty() ? 'Unsaved changes' : 'Saved on disk'"></p>
261
- </div>
262
- </div>
263
-
264
- <div :if="files().length > 1" class="flex flex-wrap gap-2 items-center" role="group" aria-label="Env file">
265
- <button
266
- :for="name in files"
267
- type="button"
268
- class="px-3 py-1.5 font-mono text-sm border rounded-lg disabled:opacity-60 transition-colors"
269
- :class="name === file() ? 'text-white bg-stone-900 border-stone-900 dark:text-neutral-900 dark:bg-white dark:border-white' : 'text-stone-700 bg-white border-stone-200 hover:bg-stone-50 dark:text-neutral-200 dark:bg-neutral-900 dark:border-neutral-700 dark:hover:bg-neutral-800'"
270
- :aria-pressed="String(name === file())"
271
- :disabled="isBusy() || (dirty() && name !== file())"
272
- @click="openFile(name)"
273
- :text="name"
274
- ></button>
275
- <span :if="dirty()" class="text-stone-500 text-xs dark:text-neutral-400">Save your edits before opening another file.</span>
276
- </div>
292
+ </SettingsRow>
293
+ </SettingsGroup>
277
294
 
278
295
  <div :if="readElsewhere().length" class="p-4 text-amber-800 text-sm dark:text-amber-200 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 rounded-xl dark:border-amber-900" role="note" data-env-read-elsewhere>
279
296
  <p class="font-medium">Some keys here are set again in a file the app loads later.</p>
@@ -296,10 +313,10 @@ onMount(() => void loadEnvironment())
296
313
  </div>
297
314
 
298
315
  <div :if="!loadError()">
299
- <CodeEditor
316
+ <SettingsCodeEditor
300
317
  v-model:value="envValues"
301
318
  :label="file()"
302
- language="env"
319
+ language="dotenv"
303
320
  :loading="isLoading()"
304
321
  @save="handleSave"
305
322
  @format="formatContent"
@@ -312,6 +329,7 @@ onMount(() => void loadEnvironment())
312
329
  <span><kbd class="px-1.5 py-0.5 font-semibold text-stone-700 dark:text-neutral-200 bg-stone-100 dark:bg-neutral-800 border border-stone-200 rounded dark:border-neutral-700">Cmd/Ctrl + Shift + F</kbd> format</span>
313
330
  </div>
314
331
  <div class="flex gap-2">
332
+ <Button :if="dirty()" variant="secondary" :disabled="isBusy()" @click="revertChanges">Revert</Button>
315
333
  <Button variant="secondary" :disabled="isBusy()" @click="formatContent">Format</Button>
316
334
  <Button :loading="isSaving()" :disabled="isBusy() || !dirty()" @click="handleSave">Save changes</Button>
317
335
  </div>
@@ -325,8 +343,8 @@ onMount(() => void loadEnvironment())
325
343
  size="sm"
326
344
  @close="closeAddModal"
327
345
  >
328
- <form class="flex flex-col gap-4" @submit.prevent="addVariable">
329
- <Input v-model:value="newVarKey" label="Key" placeholder="APP_NAME" required />
346
+ <form :id="addFormId" class="flex flex-col gap-4" @submit.prevent="addVariable">
347
+ <Input v-model:value="newVarKey" label="Name" placeholder="APP_NAME" :spellcheck="false" required />
330
348
  <Input v-model:value="newVarValue" label="Value" placeholder="My App" />
331
349
  <Input v-model:value="newVarDescription" label="Description" placeholder="Used in emails and the interface" hint="Optional comment placed above the variable." />
332
350
  <p :if="addError()" class="text-red-600 text-sm dark:text-red-400" role="alert" :text="addError()"></p>
@@ -334,10 +352,12 @@ onMount(() => void loadEnvironment())
334
352
  <template #footer>
335
353
  <div class="flex gap-2">
336
354
  <Button variant="ghost" @click="closeAddModal">Cancel</Button>
337
- <Button @click="addVariable">Add to editor</Button>
355
+ <Button type="submit" :form="addFormId">Add to Editor</Button>
338
356
  </div>
339
357
  </template>
340
358
  </Modal>
359
+ <ConfirmDialog :isOpen="Boolean(discardAction())" :title="discardTitle" :description="discardDescription"
360
+ confirmLabel="Discard Changes" variant="warning" @close="discardAction.set(null)" @confirm="discardAndContinue" />
341
361
 
342
362
  <Modal
343
363
  :isOpen="showBackupModal()"
@@ -346,9 +366,9 @@ onMount(() => void loadEnvironment())
346
366
  size="lg"
347
367
  @close="showBackupModal.set(false)"
348
368
  >
349
- <div class="space-y-3">
369
+ <div class="flex flex-col gap-3">
350
370
  <p :if="backupUpdatedAt()" class="text-stone-500 text-xs dark:text-neutral-400" :text="backupSavedLabel()"></p>
351
- <textarea readonly rows="18" class="block p-4 w-full font-mono leading-6 text-[#c9d1d9] text-xs bg-[#0d1117] border border-[#30363d] rounded-lg resize-y" :value="backupContent()"></textarea>
371
+ <SettingsCodeEditor readonly :value="backupContent()" label="Environment backup source" language="dotenv" />
352
372
  </div>
353
373
  <template #footer>
354
374
  <div class="flex gap-2">
@@ -158,6 +158,7 @@ onMount(() => {
158
158
  </div>
159
159
  <p class="mt-1 max-w-2xl text-neutral-500 text-sm dark:text-neutral-400">DNS declarations from config/dns.ts and the project domain from config/cloud.ts.</p>
160
160
  </div>
161
+ <Button tag="a" href="/settings/config/dns">Edit in Settings</Button>
161
162
  <Button variant="secondary" :loading="loading()" @click="loadDns">
162
163
  <span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>
163
164
  Refresh