sandcms 0.6.3 → 0.8.0

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 (175) hide show
  1. package/README.md +15 -11
  2. package/dist/admin/Account.svelte +2 -0
  3. package/dist/admin/Admin.svelte +21 -6
  4. package/dist/admin/AssetAttachment.svelte +9 -6
  5. package/dist/admin/AssetAttachment.svelte.d.ts +3 -1
  6. package/dist/admin/BlueprintFields.svelte +0 -3
  7. package/dist/admin/BlueprintFields.svelte.d.ts +0 -1
  8. package/dist/admin/Editor.svelte +5 -10
  9. package/dist/admin/Fields.svelte +2 -8
  10. package/dist/admin/Fields.svelte.d.ts +0 -1
  11. package/dist/admin/Gallery.svelte +221 -80
  12. package/dist/admin/Gallery.svelte.d.ts +0 -1
  13. package/dist/admin/Inbox.svelte +3 -2
  14. package/dist/admin/LinkField.svelte +0 -3
  15. package/dist/admin/LinkField.svelte.d.ts +0 -1
  16. package/dist/admin/MediaLibrary.svelte +10 -7
  17. package/dist/admin/MediaPicker.svelte +43 -35
  18. package/dist/admin/MediaPicker.svelte.d.ts +0 -1
  19. package/dist/admin/Navigation.svelte +13 -2
  20. package/dist/admin/Pages.svelte +195 -0
  21. package/dist/admin/Pages.svelte.d.ts +7 -0
  22. package/dist/admin/Shell.svelte +27 -5
  23. package/dist/admin/SortableList.svelte +82 -61
  24. package/dist/admin/SortableList.svelte.d.ts +3 -1
  25. package/dist/admin/ThemePicker.svelte +72 -0
  26. package/dist/admin/ThemePicker.svelte.d.ts +18 -0
  27. package/dist/admin/UploadButton.svelte +2 -1
  28. package/dist/admin/UploadProgress.svelte +24 -0
  29. package/dist/admin/UploadProgress.svelte.d.ts +7 -0
  30. package/dist/admin/Users.svelte +8 -3
  31. package/dist/admin/client.d.ts +3 -670
  32. package/dist/admin/client.js +2 -1
  33. package/dist/admin/components/ui/alert/alert.svelte.d.ts +3 -13
  34. package/dist/admin/components/ui/attachment/attachment-media.svelte.d.ts +3 -13
  35. package/dist/admin/components/ui/attachment/attachment.svelte.d.ts +6 -26
  36. package/dist/admin/components/ui/badge/badge.svelte.d.ts +7 -25
  37. package/dist/admin/components/ui/button/button.svelte.d.ts +15 -53
  38. package/dist/admin/components/ui/toggle/toggle.svelte.d.ts +6 -26
  39. package/dist/admin/generated/admin.css +823 -115
  40. package/dist/admin/navigation.d.ts +9 -0
  41. package/dist/admin/navigation.js +20 -1
  42. package/dist/admin/theme-context.d.ts +7 -0
  43. package/dist/admin/theme-context.js +3 -0
  44. package/dist/admin/theme.d.ts +7 -0
  45. package/dist/admin/theme.js +14 -0
  46. package/dist/admin/types.d.ts +3 -1
  47. package/dist/admin/uploads.d.ts +8 -1
  48. package/dist/admin/uploads.js +94 -16
  49. package/dist/blueprints/files.js +1 -0
  50. package/dist/blueprints/labels.d.ts +6 -0
  51. package/dist/blueprints/labels.js +14 -0
  52. package/dist/blueprints/load.js +16 -2
  53. package/dist/blueprints/types.d.ts +4 -1
  54. package/dist/cli/admin.d.ts +39 -0
  55. package/dist/cli/admin.js +95 -0
  56. package/dist/cli/backup.js +4 -4
  57. package/dist/cli/doctor.d.ts +10 -1
  58. package/dist/cli/doctor.js +98 -33
  59. package/dist/cli/email-test.d.ts +3 -0
  60. package/dist/cli/email-test.js +20 -0
  61. package/dist/cli/files.d.ts +2 -6
  62. package/dist/cli/files.js +12 -2
  63. package/dist/cli/index.js +401 -95
  64. package/dist/cli/rebaseline.d.ts +10 -0
  65. package/dist/cli/rebaseline.js +117 -0
  66. package/dist/cli/scaffold.js +8 -8
  67. package/dist/cli/setup.js +16 -26
  68. package/dist/cli/upgrade.js +34 -7
  69. package/dist/env.d.ts +26 -2
  70. package/dist/env.js +48 -6
  71. package/dist/notification-fields.js +2 -1
  72. package/dist/server/admin-load.d.ts +85 -5
  73. package/dist/server/admin-load.js +26 -1
  74. package/dist/server/api-access.d.ts +4 -0
  75. package/dist/server/api-access.js +15 -2
  76. package/dist/server/api-keys.d.ts +96 -0
  77. package/dist/server/api-keys.js +115 -0
  78. package/dist/server/api-pagination.d.ts +3 -0
  79. package/dist/server/api.js +21 -63
  80. package/dist/server/auth.d.ts +10 -9
  81. package/dist/server/cms.d.ts +63 -21
  82. package/dist/server/cms.js +64 -7
  83. package/dist/server/db/auto-migrate.d.ts +0 -4
  84. package/dist/server/db/auto-migrate.js +12 -3
  85. package/dist/server/db/legacy.d.ts +13 -0
  86. package/dist/server/db/legacy.js +60 -0
  87. package/dist/server/db/migration-data.js +2 -34
  88. package/dist/server/db/migrations/{0000_foundation.sql → 0000_baseline.sql} +120 -4
  89. package/dist/server/db/migrations/meta/0000_snapshot.json +578 -3
  90. package/dist/server/db/migrations/meta/_journal.json +2 -58
  91. package/dist/server/db/schema.d.ts +119 -2
  92. package/dist/server/db/schema.js +23 -9
  93. package/dist/server/db/store.d.ts +25 -2
  94. package/dist/server/db/store.js +90 -26
  95. package/dist/server/forms.js +2 -1
  96. package/dist/server/hooks.js +155 -81
  97. package/dist/server/media/contracts.d.ts +115 -0
  98. package/dist/server/media/contracts.js +12 -0
  99. package/dist/server/media/deletions.d.ts +2 -1
  100. package/dist/server/media/deletions.js +3 -3
  101. package/dist/server/media/delivery.js +7 -11
  102. package/dist/server/media/processor-child.d.ts +2 -0
  103. package/dist/server/media/processor-child.js +236 -0
  104. package/dist/server/media/processor.d.ts +51 -0
  105. package/dist/server/media/processor.js +135 -0
  106. package/dist/server/media/render-math.d.ts +24 -0
  107. package/dist/server/media/render-math.js +50 -0
  108. package/dist/server/media/runner.d.ts +30 -1
  109. package/dist/server/media/runner.js +418 -165
  110. package/dist/server/media/service.d.ts +53 -11
  111. package/dist/server/media/service.js +307 -98
  112. package/dist/server/media/storage.d.ts +5 -0
  113. package/dist/server/media/storage.js +279 -0
  114. package/dist/server/media/upload-ticket.d.ts +12 -0
  115. package/dist/server/media/upload-ticket.js +35 -0
  116. package/dist/server/media/verify.d.ts +64 -0
  117. package/dist/server/media/verify.js +201 -0
  118. package/dist/server/platform/http.d.ts +27 -0
  119. package/dist/server/platform/http.js +77 -0
  120. package/dist/server/platform/index.d.ts +52 -0
  121. package/dist/server/platform/index.js +98 -0
  122. package/dist/server/platform/snapshots.d.ts +18 -0
  123. package/dist/server/platform/snapshots.js +110 -0
  124. package/dist/server/platform/volume.d.ts +20 -0
  125. package/dist/server/platform/volume.js +60 -0
  126. package/docs/acceptance.md +7 -5
  127. package/docs/api.md +56 -4
  128. package/docs/cloudflare.md +26 -152
  129. package/docs/content.md +20 -5
  130. package/docs/deployment.md +222 -57
  131. package/docs/email.md +6 -0
  132. package/docs/forms.md +2 -2
  133. package/docs/media.md +94 -21
  134. package/docs/package.md +21 -18
  135. package/docs/plans/0.7-self-hosted.md +264 -0
  136. package/docs/releases.md +37 -1
  137. package/docs/upgrades.md +72 -9
  138. package/package.json +37 -44
  139. package/templates/Dockerfile +32 -0
  140. package/templates/integration.ts +26 -5
  141. package/templates/openship.json +9 -0
  142. package/templates/railpack.json +1 -1
  143. package/templates/sandcms/blueprints/files/image.yaml +1 -1
  144. package/templates/sandcms/config.yaml +1 -1
  145. package/dist/cli/cloudflare.d.ts +0 -8
  146. package/dist/cli/cloudflare.js +0 -135
  147. package/dist/server/db/migrations/0001_independent_password_resets.sql +0 -3
  148. package/dist/server/db/migrations/0002_email_failure_reason.sql +0 -1
  149. package/dist/server/db/migrations/0003_direct_r2_uploads.sql +0 -10
  150. package/dist/server/db/migrations/0004_agent_api_keys.sql +0 -38
  151. package/dist/server/db/migrations/0005_api_retention_and_pagination.sql +0 -3
  152. package/dist/server/db/migrations/0006_durable_media_deletion.sql +0 -7
  153. package/dist/server/db/migrations/0007_content_and_job_indexes.sql +0 -2
  154. package/dist/server/db/migrations/0008_search_text_cache.sql +0 -45
  155. package/dist/server/db/migrations/meta/0001_snapshot.json +0 -1197
  156. package/dist/server/db/migrations/meta/0002_snapshot.json +0 -1204
  157. package/dist/server/db/migrations/meta/0003_snapshot.json +0 -1281
  158. package/dist/server/db/migrations/meta/0004_snapshot.json +0 -1546
  159. package/dist/server/db/migrations/meta/0005_snapshot.json +0 -1572
  160. package/dist/server/db/migrations/meta/0006_snapshot.json +0 -1627
  161. package/dist/server/db/migrations/meta/0007_snapshot.json +0 -1643
  162. package/dist/server/db/migrations/meta/0008_snapshot.json +0 -1711
  163. package/dist/worker/index.d.ts +0 -10
  164. package/dist/worker/index.js +0 -460
  165. package/dist/worker/local.d.ts +0 -5
  166. package/dist/worker/local.js +0 -57
  167. package/dist/worker/source.d.ts +0 -2
  168. package/dist/worker/source.js +0 -31
  169. package/dist/worker/uploads.d.ts +0 -22
  170. package/dist/worker/uploads.js +0 -48
  171. package/templates/sandcms/worker/index.ts +0 -1
  172. package/templates/sandcms/worker/local.ts +0 -1
  173. package/templates/sandcms/worker/wrangler.jsonc +0 -6
  174. /package/dist/{worker → server/media}/svg.d.ts +0 -0
  175. /package/dist/{worker → server/media}/svg.js +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SandCMS
2
2
 
3
- **0.6.3** polishes the admin: tighter layouts, an account menu, link fields edited in a dialog, a calendar date picker, a step-by-step two-factor setup with a QR code, and removing users from the Users page. There is no new database migration or Worker change; stored data and project-owned YAML are preserved. See the [0.6.3 release notes](docs/releases.md#063), [upgrade workflow](docs/upgrades.md#063-upgrade-checklist) and [agent instructions](AGENTS.md).
3
+ **0.8.0** lets a SandCMS site deploy by overlap on OpenShip, Dokploy and Coolify: the new release migrates and passes its health check while the previous one still serves, and every later migration keeps the previous release working. The 0.7 migration history is replaced by one frozen baseline; existing 0.7.x databases are converted once with `sandcms rebaseline`. The release also adds operator commands for the server shell, a Pages screen and the site favicon or logo in the admin. See the [0.8.0 release notes](docs/releases.md#080), [upgrade checklist](docs/upgrades.md#080-upgrade-checklist) and [agent instructions](AGENTS.md).
4
4
 
5
5
  SandCMS embeds a content workspace into a SvelteKit website. Developers own YAML blueprints and public routes; editors manage drafts, publication, images, and form submissions at `/admin`.
6
6
 
@@ -8,7 +8,7 @@ This repository contains the `sandcms` package and a working example website. Th
8
8
 
9
9
  ## Run locally
10
10
 
11
- Requires Bun **1.4.0**. Node **26.8.1** is used by build tooling and Wrangler; the website runs on Bun.
11
+ Requires Bun **1.4.4**. Node is not needed: `bunfig.toml` runs every tool (Vite, SvelteKit, svelte-check, Playwright) on Bun.
12
12
 
13
13
  ```sh
14
14
  bun install --frozen-lockfile
@@ -22,7 +22,7 @@ Open **http://localhost:5410/admin**. `dev:init` creates an ignored local enviro
22
22
  bun run cli user reset-password --email admin@example.test
23
23
  ```
24
24
 
25
- For local image processing, follow [Cloudflare local setup](docs/cloudflare.md#local-development). The same guide covers staging, production, and website proxy caching.
25
+ Uploads and image processing work locally with no extra service. Media is stored in `./data/media` next to the database; see [media](docs/media.md).
26
26
 
27
27
  To open the preview from another device over ZeroTier, stop the ordinary dev/preview server and run:
28
28
 
@@ -31,7 +31,11 @@ bun run build
31
31
  bun run preview:network 10.123.59.34 # Use this machine's assigned ZeroTier IPv4 address.
32
32
  ```
33
33
 
34
- Open `https://10.123.59.34:5443/admin` and accept the local certificate prompt. HTTP port 5410 redirects to it. The helper keeps the configured origin, secure cookies, and media delivery on the same HTTPS address, with the website backend bound to loopback. For uploads from another device, set `SANDCMS_WORKER_URL` to a deployed staging Worker and allow the preview HTTPS origin in staging bucket CORS. The loopback local Worker is intended for localhost development. Certificates are generated under ignored `data/preview-tls`; production uses the host's trusted HTTPS certificate. The ordinary localhost environment remains unchanged.
34
+ Open `https://10.123.59.34:5443/admin` and accept the local certificate prompt. HTTP port 5410 redirects to it. The helper keeps the configured origin, secure cookies, and media delivery on the same HTTPS address, with the website backend bound to loopback. Certificates are generated under ignored `data/preview-tls`; production uses the host's trusted HTTPS certificate. The ordinary localhost environment remains unchanged.
35
+
36
+ ## Hosting
37
+
38
+ A site runs as one container built from its `Dockerfile`, with one persistent volume mounted at `/data`, behind any reverse proxy with default settings. Deploys overlap the old and new container with no downtime: the new one migrates on its first health check and takes traffic only once it is healthy. The volume should be backed up on a schedule. [OpenShip](https://openship.io), [Dokploy](https://dokploy.com) and [Coolify](https://coolify.io) are documented with the settings each needs; nothing in the package depends on any of them. See [deployment](docs/deployment.md) for the requirements, environment and backup workflow.
35
39
 
36
40
  ## Included
37
41
 
@@ -39,9 +43,9 @@ Open `https://10.123.59.34:5443/admin` and accept the local certificate prompt.
39
43
  - Validated YAML pages, site settings, collections, and form metadata. All planned field types, nested groups, ordered repeatable groups, stable relations, and focused Tiptap rich text.
40
44
  - Independent draft/published snapshots, conflict detection, authenticated draft preview, required-field validation, and media readiness gates.
41
45
  - Better Auth password sign-in, optional TOTP and recovery codes, temporary-password changes, two roles, and operator recovery. No public registration or email services.
42
- - Direct presigned R2 uploads with durable SQLite finalization and variant jobs, private originals, named versioned variants, sanitized SVG, global media selection, credits, usage warnings, and rebuilds.
46
+ - Chunked, resumable uploads up to 500 MB (JPEG, PNG, WebP, AVIF, GIF, TIFF, SVG), local processing with sharp, private originals, named versioned variants, sanitized SVG, global media selection, credits, usage warnings, and rebuilds.
43
47
  - Developer-owned form actions, honeypot/rate limiting, schema snapshots, read/unread inbox, deletion, and safe CSV exports.
44
- - Safe setup/upgrade manifests, a frozen SQL baseline and incremental migration runner, doctor, Worker deployment commands, verified live backups, and guarded offline restores.
48
+ - Safe setup/upgrade manifests, a frozen SQL baseline and incremental migration runner, doctor, a starter `Dockerfile` with a health check, volume and site-id checks, hourly verified snapshots, verified live backups, and guarded offline restores.
45
49
 
46
50
  ## Package use
47
51
 
@@ -52,27 +56,27 @@ bun pm pack --ignore-scripts --filename /tmp/sandcms.tgz
52
56
  bun dist/cli/index.js setup --cwd /path/to/site --package /tmp/sandcms.tgz
53
57
  ```
54
58
 
55
- For a reproducible local archive installation, use the explicit commands in the [package guide](docs/package.md). Setup previews changes, preserves existing hooks/configuration and customized generated files, and can optionally configure Cloudflare. Public project routes are written by the website developer.
59
+ For a reproducible local archive installation, use the explicit commands in the [package guide](docs/package.md). Setup previews changes and preserves existing hooks/configuration and customized generated files. Public project routes are written by the website developer.
56
60
 
57
61
  ## Verification
58
62
 
59
63
  ```sh
60
64
  bun run check
61
- bun test tests
65
+ bun run test
62
66
  bun run build
63
67
  bun x playwright install chromium
64
68
  bun run test:e2e
65
69
  bun run test:package
66
70
  ```
67
71
 
68
- Stop the dev server before building. Browser tests use the production Bun server, isolated SQLite, and a local Wrangler Worker. Package tests install the archive into both a blank directory and an existing site. Tests do not use production resources. See [acceptance evidence and remaining external checks](docs/acceptance.md).
72
+ Stop the dev server before building. Browser tests use the production Bun server with isolated SQLite and media directories. Package tests install the archive into both a blank directory and an existing site. Tests do not use production resources. See [acceptance evidence and remaining external checks](docs/acceptance.md).
69
73
 
70
74
  ## Guides
71
75
 
72
76
  - [Installation and private packaging](docs/package.md)
73
77
  - [Blueprints and runtime API](docs/content.md)
74
78
  - [Media, publication, and images](docs/media.md)
75
- - [Cloudflare Workers, R2, and proxy caching](docs/cloudflare.md)
79
+ - [Cloudflare: retired Worker and optional CDN](docs/cloudflare.md)
76
80
  - [Forms and submissions](docs/forms.md)
77
81
  - [Deployment, backups, and recovery](docs/deployment.md)
78
82
  - [Updates and file ownership](docs/upgrades.md)
@@ -81,6 +85,6 @@ Stop the dev server before building. Browser tests use the production Bun server
81
85
 
82
86
  SandCMS is licensed under the [PolyForm Strict License 1.0.0](LICENSE). See the license for permitted uses and terms.
83
87
 
84
- Source is organized into `src/lib/blueprints`, `server`, `admin`, `worker`, and `cli`. `src/routes/(site)` demonstrates developer-owned pages; `(sandcms)` is the thin integration layer. Never commit content databases, secrets, or bootstrap passwords.
88
+ Source is organized into `src/lib/blueprints`, `server`, `admin`, `cli`, and the deprecated `worker`. `src/routes/(site)` demonstrates developer-owned pages; `(sandcms)` is the thin integration layer. Never commit content databases, secrets, or bootstrap passwords.
85
89
 
86
90
  Agents can discover blueprints and map existing site content through the [authenticated content API](docs/api.md), with expiring Better Auth API keys and idempotent content writes.
@@ -3,6 +3,7 @@
3
3
  import * as Dialog from './components/ui/dialog/index.js';
4
4
  import Notice from './Notice.svelte';
5
5
  import ApiKeys from './ApiKeys.svelte';
6
+ import ThemePicker from './ThemePicker.svelte';
6
7
  import { untrack } from 'svelte';
7
8
  import type { AdminData } from './types.js';
8
9
  import { authClient, copyText, message } from './client.js';
@@ -235,6 +236,7 @@
235
236
  </div>
236
237
  {/if}
237
238
  </Card.Root>{/if}
239
+ {#if !data.user?.mustChangePassword}<ThemePicker />{/if}
238
240
  {#if data.user?.role === 'admin' && !data.user.mustChangePassword}<ApiKeys />{/if}
239
241
  </div>
240
242
 
@@ -6,21 +6,34 @@
6
6
  import Shell from './Shell.svelte';
7
7
  import Dashboard from './Dashboard.svelte';
8
8
  import Collection from './Collection.svelte';
9
+ import Pages from './Pages.svelte';
9
10
  import Editor from './Editor.svelte';
10
11
  import MediaLibrary from './MediaLibrary.svelte';
11
12
  import Inbox from './Inbox.svelte';
12
13
  import Users from './Users.svelte';
13
14
  import Account from './Account.svelte';
15
+ import { setContext, untrack } from 'svelte';
16
+ import { persistTheme, type Theme } from './theme.js';
17
+ import { themeContext, type ThemeState } from './theme-context.js';
14
18
  let { data }: { data: AdminData } = $props();
19
+ let theme = $state<Theme>(untrack(() => data.theme ?? 'system'));
20
+ setContext<ThemeState>(themeContext, {
21
+ get current() {
22
+ return theme;
23
+ },
24
+ set(next) {
25
+ theme = next;
26
+ persistTheme(next);
27
+ }
28
+ });
15
29
  </script>
16
30
 
17
31
  <svelte:head
18
- ><title>{data.blueprint?.label ?? 'Workspace'} · SandCMS</title><meta
19
- name="robots"
20
- content="noindex,nofollow"
21
- /></svelte:head
32
+ ><title
33
+ >{data.blueprint?.label ?? (data.screen === 'pages' ? 'Pages' : 'Workspace')} · SandCMS</title
34
+ ><meta name="robots" content="noindex,nofollow" /></svelte:head
22
35
  >
23
- <div class="sandcms-admin">
36
+ <div class="sandcms-admin" data-theme={theme}>
24
37
  <a class="cms-skip" href="#cms-main">Skip to content</a>{#if data.screen === 'login'}<Login
25
38
  emailEnabled={data.emailEnabled}
26
39
  next={data.next}
@@ -29,7 +42,9 @@
29
42
  />{:else}<Shell {data}
30
43
  >{#key data.screen + ':' + (data.blueprint?.id ?? '') + ':' + (data.entry?.id ?? '') + ':' + String(data.editing)}{#if data.screen === 'content'}{#if data.editing}<Editor
31
44
  {data}
32
- />{:else}<Collection {data} />{/if}{:else if data.screen === 'media'}<MediaLibrary
45
+ />{:else}<Collection {data} />{/if}{:else if data.screen === 'pages'}<Pages
46
+ {data}
47
+ />{:else if data.screen === 'media'}<MediaLibrary
33
48
  {data}
34
49
  />{:else if data.screen === 'forms'}<Inbox
35
50
  {data}
@@ -1,30 +1,32 @@
1
1
  <script lang="ts">
2
2
  import Image from '@lucide/svelte/icons/image';
3
3
  import X from '@lucide/svelte/icons/x';
4
+ import type { Snippet } from 'svelte';
4
5
  import { assetUrl } from './client.js';
5
6
  import type { Asset } from './types.js';
6
7
  import * as Attachment from './components/ui/attachment/index.js';
7
8
 
8
9
  let {
9
10
  asset,
10
- workerUrl,
11
11
  orientation = 'vertical',
12
12
  selected,
13
13
  visibility,
14
14
  onopen,
15
15
  onremove,
16
+ actions,
16
17
  class: className
17
18
  }: {
18
19
  asset: Asset;
19
- workerUrl: string;
20
20
  orientation?: Attachment.AttachmentOrientation;
21
21
  selected?: boolean;
22
22
  visibility?: 'Public' | 'Private';
23
23
  onopen?: () => void;
24
24
  onremove?: () => void;
25
+ /** Extra actions rendered before the remove button. */
26
+ actions?: Snippet;
25
27
  class?: string;
26
28
  } = $props();
27
- const src = $derived(assetUrl(asset, workerUrl));
29
+ const src = $derived(assetUrl(asset));
28
30
  </script>
29
31
 
30
32
  <Attachment.Root
@@ -62,11 +64,12 @@
62
64
  : 'Processing image'}
63
65
  </Attachment.Description>{/if}
64
66
  </Attachment.Content>
65
- {#if onremove}
67
+ {#if onremove || actions}
66
68
  <Attachment.Actions>
67
- <Attachment.Action aria-label={'Remove ' + asset.filename} onclick={onremove}
69
+ {@render actions?.()}
70
+ {#if onremove}<Attachment.Action aria-label={'Remove ' + asset.filename} onclick={onremove}
68
71
  ><X /></Attachment.Action
69
- >
72
+ >{/if}
70
73
  </Attachment.Actions>
71
74
  {/if}
72
75
  {#if onopen}
@@ -1,13 +1,15 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { Asset } from './types.js';
2
3
  import * as Attachment from './components/ui/attachment/index.js';
3
4
  type $$ComponentProps = {
4
5
  asset: Asset;
5
- workerUrl: string;
6
6
  orientation?: Attachment.AttachmentOrientation;
7
7
  selected?: boolean;
8
8
  visibility?: 'Public' | 'Private';
9
9
  onopen?: () => void;
10
10
  onremove?: () => void;
11
+ /** Extra actions rendered before the remove button. */
12
+ actions?: Snippet;
11
13
  class?: string;
12
14
  };
13
15
  declare const AssetAttachment: import("svelte").Component<$$ComponentProps, {}, "">;
@@ -12,7 +12,6 @@
12
12
  onchange,
13
13
  assets,
14
14
  relations,
15
- workerUrl,
16
15
  fileBlueprints,
17
16
  errors = {},
18
17
  autoSlug = false
@@ -22,7 +21,6 @@
22
21
  onchange: (value: Payload) => void;
23
22
  assets: Asset[];
24
23
  relations: Relations;
25
- workerUrl: string;
26
24
  fileBlueprints?: FileBlueprint[];
27
25
  errors?: Record<string, string>;
28
26
  /** Keep slugs derived from their source field until the editor changes them by hand. */
@@ -60,7 +58,6 @@
60
58
  onchange={change}
61
59
  {assets}
62
60
  {relations}
63
- {workerUrl}
64
61
  {fileBlueprints}
65
62
  {errors}
66
63
  />
@@ -6,7 +6,6 @@ type $$ComponentProps = {
6
6
  onchange: (value: Payload) => void;
7
7
  assets: Asset[];
8
8
  relations: Relations;
9
- workerUrl: string;
10
9
  fileBlueprints?: FileBlueprint[];
11
10
  errors?: Record<string, string>;
12
11
  /** Keep slugs derived from their source field until the editor changes them by hand. */
@@ -16,6 +16,7 @@
16
16
  import HoverHint from './HoverHint.svelte';
17
17
  import * as DropdownMenu from './components/ui/dropdown-menu/index.js';
18
18
  import RowMenu from './RowMenu.svelte';
19
+ import { previewPath } from './navigation.js';
19
20
  import ArrowUpRight from '@lucide/svelte/icons/arrow-up-right';
20
21
  import Copy from '@lucide/svelte/icons/copy';
21
22
  import EyeOff from '@lucide/svelte/icons/eye-off';
@@ -139,15 +140,10 @@
139
140
  busy = false;
140
141
  }
141
142
  }
142
- const preview = $derived(
143
- entry && data.blueprint?.preview
144
- ? data.blueprint.preview
145
- .replace('{slug}', encodeURIComponent(String(entry.draft.slug ?? entry.id)))
146
- .replace('{id}', entry.id) +
147
- '?cmsPreview=' +
148
- entry.id
149
- : null
150
- );
143
+ const preview = $derived.by(() => {
144
+ const path = previewPath(data.blueprint, entry);
145
+ return path && entry ? path + '?cmsPreview=' + entry.id : null;
146
+ });
151
147
  </script>
152
148
 
153
149
  <UnsavedChanges {dirty} />
@@ -217,7 +213,6 @@
217
213
  }}
218
214
  assets={data.assets ?? []}
219
215
  relations={data.relations ?? {}}
220
- workerUrl={data.workerUrl!}
221
216
  {errors}
222
217
  />
223
218
  </Card.Root>
@@ -2,6 +2,7 @@
2
2
  import type { Field, FileBlueprint, Json, Payload } from '../blueprints/types.js';
3
3
  import { fieldVisible } from '../blueprints/conditions.js';
4
4
  import { widthSpan } from '../blueprints/layout.js';
5
+ import { fieldLabel } from '../blueprints/labels.js';
5
6
  import type { Asset, Relations } from './types.js';
6
7
  import { Input } from './components/ui/input/index.js';
7
8
  import { Textarea } from './components/ui/textarea/index.js';
@@ -22,7 +23,6 @@
22
23
  onchange,
23
24
  assets,
24
25
  relations,
25
- workerUrl,
26
26
  imageUrl,
27
27
  prefix = 'field',
28
28
  fileBlueprints = [],
@@ -33,7 +33,6 @@
33
33
  onchange: (v: Payload) => void;
34
34
  assets: Asset[];
35
35
  relations: Relations;
36
- workerUrl: string;
37
36
  imageUrl?: string;
38
37
  prefix?: string;
39
38
  fileBlueprints?: FileBlueprint[];
@@ -59,7 +58,7 @@
59
58
  {#each Object.entries(fields) as [key, field]}
60
59
  {#if fieldVisible(field, value)}
61
60
  {@const id = prefix + '-' + key}{@const label =
62
- field.label ?? key.charAt(0).toUpperCase() + key.slice(1)}
61
+ fieldLabel(key, field)}
63
62
  {@const length = String(value[key] ?? '').length}
64
63
  {@const outsideLength =
65
64
  (field.minLength !== undefined && length < field.minLength) ||
@@ -159,7 +158,6 @@
159
158
  value={value[key]}
160
159
  {assets}
161
160
  {relations}
162
- {workerUrl}
163
161
  {fileBlueprints}
164
162
  invalid={!!errors[key]}
165
163
  onchange={(v) => set(key, v)}
@@ -173,7 +171,6 @@
173
171
  {id}
174
172
  value={(value[key] as string | string[]) ?? null}
175
173
  {assets}
176
- {workerUrl}
177
174
  fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
178
175
  multiple={field.type === 'media-list'}
179
176
  onchange={(v) => set(key, v)}
@@ -185,7 +182,6 @@
185
182
  value={(value[key] as Payload[]) ?? []}
186
183
  {assets}
187
184
  {relations}
188
- {workerUrl}
189
185
  errors={childErrors(key)}
190
186
  onchange={(v) => set(key, v)}
191
187
  />
@@ -196,7 +192,6 @@
196
192
  value={(value[key] as Payload) ?? {}}
197
193
  {assets}
198
194
  {relations}
199
- {workerUrl}
200
195
  prefix={id}
201
196
  errors={childErrors(key)}
202
197
  onchange={(v) => set(key, v)}
@@ -237,7 +232,6 @@
237
232
  value={row}
238
233
  {assets}
239
234
  {relations}
240
- {workerUrl}
241
235
  prefix={id + '-' + i}
242
236
  errors={childErrors(key + '.' + i)}
243
237
  onchange={(v) =>
@@ -7,7 +7,6 @@ type $$ComponentProps = {
7
7
  onchange: (v: Payload) => void;
8
8
  assets: Asset[];
9
9
  relations: Relations;
10
- workerUrl: string;
11
10
  imageUrl?: string;
12
11
  prefix?: string;
13
12
  fileBlueprints?: FileBlueprint[];