sandcms 0.6.3 → 0.7.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.
- package/README.md +14 -10
- package/dist/admin/Account.svelte +2 -0
- package/dist/admin/Admin.svelte +14 -1
- package/dist/admin/AssetAttachment.svelte +1 -3
- package/dist/admin/AssetAttachment.svelte.d.ts +0 -1
- package/dist/admin/BlueprintFields.svelte +0 -3
- package/dist/admin/BlueprintFields.svelte.d.ts +0 -1
- package/dist/admin/Editor.svelte +0 -1
- package/dist/admin/Fields.svelte +0 -7
- package/dist/admin/Fields.svelte.d.ts +0 -1
- package/dist/admin/Gallery.svelte +2 -6
- package/dist/admin/Gallery.svelte.d.ts +0 -1
- package/dist/admin/LinkField.svelte +0 -3
- package/dist/admin/LinkField.svelte.d.ts +0 -1
- package/dist/admin/MediaLibrary.svelte +10 -7
- package/dist/admin/MediaPicker.svelte +7 -15
- package/dist/admin/MediaPicker.svelte.d.ts +0 -1
- package/dist/admin/ThemePicker.svelte +72 -0
- package/dist/admin/ThemePicker.svelte.d.ts +18 -0
- package/dist/admin/UploadButton.svelte +2 -1
- package/dist/admin/UploadProgress.svelte +24 -0
- package/dist/admin/UploadProgress.svelte.d.ts +7 -0
- package/dist/admin/client.d.ts +3 -670
- package/dist/admin/client.js +2 -1
- package/dist/admin/components/ui/alert/alert.svelte.d.ts +3 -13
- package/dist/admin/components/ui/attachment/attachment-media.svelte.d.ts +3 -13
- package/dist/admin/components/ui/attachment/attachment.svelte.d.ts +6 -26
- package/dist/admin/components/ui/badge/badge.svelte.d.ts +7 -25
- package/dist/admin/components/ui/button/button.svelte.d.ts +15 -53
- package/dist/admin/components/ui/toggle/toggle.svelte.d.ts +6 -26
- package/dist/admin/generated/admin.css +529 -101
- package/dist/admin/theme-context.d.ts +7 -0
- package/dist/admin/theme-context.js +3 -0
- package/dist/admin/theme.d.ts +7 -0
- package/dist/admin/theme.js +14 -0
- package/dist/admin/types.d.ts +2 -1
- package/dist/admin/uploads.d.ts +8 -1
- package/dist/admin/uploads.js +94 -16
- package/dist/blueprints/files.js +1 -0
- package/dist/blueprints/load.js +7 -2
- package/dist/blueprints/types.d.ts +4 -1
- package/dist/cli/doctor.d.ts +3 -1
- package/dist/cli/doctor.js +85 -30
- package/dist/cli/files.d.ts +2 -6
- package/dist/cli/files.js +11 -2
- package/dist/cli/index.js +99 -31
- package/dist/cli/scaffold.js +8 -8
- package/dist/cli/setup.js +16 -26
- package/dist/cli/upgrade.js +21 -2
- package/dist/env.d.ts +32 -0
- package/dist/env.js +53 -3
- package/dist/server/admin-load.d.ts +13 -5
- package/dist/server/admin-load.js +6 -1
- package/dist/server/api-access.d.ts +4 -0
- package/dist/server/api-access.js +15 -2
- package/dist/server/api-pagination.d.ts +3 -0
- package/dist/server/api.js +5 -2
- package/dist/server/auth.d.ts +10 -9
- package/dist/server/cms.d.ts +65 -18
- package/dist/server/cms.js +62 -6
- package/dist/server/db/migration-data.js +4 -0
- package/dist/server/db/migrations/0009_local_media.sql +9 -0
- package/dist/server/db/migrations/meta/0009_snapshot.json +1763 -0
- package/dist/server/db/migrations/meta/_journal.json +7 -0
- package/dist/server/db/schema.d.ts +119 -2
- package/dist/server/db/schema.js +15 -3
- package/dist/server/hooks.js +155 -81
- package/dist/server/media/contracts.d.ts +115 -0
- package/dist/server/media/contracts.js +12 -0
- package/dist/server/media/deletions.d.ts +2 -1
- package/dist/server/media/deletions.js +3 -3
- package/dist/server/media/delivery.js +7 -11
- package/dist/server/media/import-r2.d.ts +56 -0
- package/dist/server/media/import-r2.js +342 -0
- package/dist/server/media/processor-child.d.ts +2 -0
- package/dist/server/media/processor-child.js +236 -0
- package/dist/server/media/processor.d.ts +51 -0
- package/dist/server/media/processor.js +135 -0
- package/dist/server/media/render-math.d.ts +24 -0
- package/dist/server/media/render-math.js +50 -0
- package/dist/server/media/runner.d.ts +30 -1
- package/dist/server/media/runner.js +418 -165
- package/dist/server/media/service.d.ts +56 -10
- package/dist/server/media/service.js +309 -98
- package/dist/server/media/storage.d.ts +5 -0
- package/dist/server/media/storage.js +279 -0
- package/dist/server/media/svg.d.ts +5 -0
- package/dist/server/media/svg.js +142 -0
- package/dist/server/media/upload-ticket.d.ts +12 -0
- package/dist/server/media/upload-ticket.js +35 -0
- package/dist/server/media/verify.d.ts +36 -0
- package/dist/server/media/verify.js +109 -0
- package/dist/server/platform/http.d.ts +27 -0
- package/dist/server/platform/http.js +77 -0
- package/dist/server/platform/index.d.ts +52 -0
- package/dist/server/platform/index.js +98 -0
- package/dist/server/platform/snapshots.d.ts +18 -0
- package/dist/server/platform/snapshots.js +110 -0
- package/dist/server/platform/volume.d.ts +20 -0
- package/dist/server/platform/volume.js +60 -0
- package/dist/worker/svg.d.ts +1 -5
- package/dist/worker/svg.js +2 -142
- package/docs/acceptance.md +6 -4
- package/docs/api.md +41 -3
- package/docs/cloudflare.md +48 -142
- package/docs/content.md +2 -2
- package/docs/deployment.md +159 -57
- package/docs/forms.md +1 -1
- package/docs/media.md +85 -21
- package/docs/package.md +21 -18
- package/docs/plans/0.7-self-hosted.md +264 -0
- package/docs/releases.md +17 -1
- package/docs/upgrades.md +35 -6
- package/package.json +36 -37
- package/templates/Dockerfile +28 -0
- package/templates/integration.ts +18 -2
- package/templates/railpack.json +1 -1
- package/templates/sandcms/blueprints/files/image.yaml +1 -1
- package/templates/sandcms/config.yaml +0 -1
- package/dist/cli/cloudflare.d.ts +0 -8
- package/dist/cli/cloudflare.js +0 -135
- package/templates/sandcms/worker/index.ts +0 -1
- package/templates/sandcms/worker/local.ts +0 -1
- package/templates/sandcms/worker/wrangler.jsonc +0 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SandCMS
|
|
2
2
|
|
|
3
|
-
**0.
|
|
3
|
+
**0.7.0** makes a SandCMS site self-contained: one container and one persistent volume hold the database, image originals, variants and hourly database snapshots. Images are processed on the site with sharp, uploads are chunked and resumable, and Cloudflare is no longer required. Existing sites import their R2 media once with `sandcms media import-r2`. See the [0.7.0 release notes](docs/releases.md#070), [upgrade checklist](docs/upgrades.md#070-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.
|
|
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
|
-
|
|
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.
|
|
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. Zero-downtime deploys that briefly overlap the old and new container work, and the volume should be backed up on a schedule. We recommend [Dokploy](https://dokploy.com) or [Openship](https://openship.io), which provide all of this; nothing in the package depends on either. 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
|
-
-
|
|
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,
|
|
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,7 +56,7 @@ 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
|
|
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
|
|
|
@@ -65,14 +69,14 @@ 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
|
|
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
|
|
79
|
+
- [Cloudflare: legacy R2 import 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`, `
|
|
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
|
|
package/dist/admin/Admin.svelte
CHANGED
|
@@ -11,7 +11,20 @@
|
|
|
11
11
|
import Inbox from './Inbox.svelte';
|
|
12
12
|
import Users from './Users.svelte';
|
|
13
13
|
import Account from './Account.svelte';
|
|
14
|
+
import { setContext, untrack } from 'svelte';
|
|
15
|
+
import { persistTheme, type Theme } from './theme.js';
|
|
16
|
+
import { themeContext, type ThemeState } from './theme-context.js';
|
|
14
17
|
let { data }: { data: AdminData } = $props();
|
|
18
|
+
let theme = $state<Theme>(untrack(() => data.theme ?? 'system'));
|
|
19
|
+
setContext<ThemeState>(themeContext, {
|
|
20
|
+
get current() {
|
|
21
|
+
return theme;
|
|
22
|
+
},
|
|
23
|
+
set(next) {
|
|
24
|
+
theme = next;
|
|
25
|
+
persistTheme(next);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
15
28
|
</script>
|
|
16
29
|
|
|
17
30
|
<svelte:head
|
|
@@ -20,7 +33,7 @@
|
|
|
20
33
|
content="noindex,nofollow"
|
|
21
34
|
/></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}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
let {
|
|
9
9
|
asset,
|
|
10
|
-
workerUrl,
|
|
11
10
|
orientation = 'vertical',
|
|
12
11
|
selected,
|
|
13
12
|
visibility,
|
|
@@ -16,7 +15,6 @@
|
|
|
16
15
|
class: className
|
|
17
16
|
}: {
|
|
18
17
|
asset: Asset;
|
|
19
|
-
workerUrl: string;
|
|
20
18
|
orientation?: Attachment.AttachmentOrientation;
|
|
21
19
|
selected?: boolean;
|
|
22
20
|
visibility?: 'Public' | 'Private';
|
|
@@ -24,7 +22,7 @@
|
|
|
24
22
|
onremove?: () => void;
|
|
25
23
|
class?: string;
|
|
26
24
|
} = $props();
|
|
27
|
-
const src = $derived(assetUrl(asset
|
|
25
|
+
const src = $derived(assetUrl(asset));
|
|
28
26
|
</script>
|
|
29
27
|
|
|
30
28
|
<Attachment.Root
|
|
@@ -2,7 +2,6 @@ import type { Asset } from './types.js';
|
|
|
2
2
|
import * as Attachment from './components/ui/attachment/index.js';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
asset: Asset;
|
|
5
|
-
workerUrl: string;
|
|
6
5
|
orientation?: Attachment.AttachmentOrientation;
|
|
7
6
|
selected?: boolean;
|
|
8
7
|
visibility?: 'Public' | 'Private';
|
|
@@ -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. */
|
package/dist/admin/Editor.svelte
CHANGED
package/dist/admin/Fields.svelte
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
onchange,
|
|
23
23
|
assets,
|
|
24
24
|
relations,
|
|
25
|
-
workerUrl,
|
|
26
25
|
imageUrl,
|
|
27
26
|
prefix = 'field',
|
|
28
27
|
fileBlueprints = [],
|
|
@@ -33,7 +32,6 @@
|
|
|
33
32
|
onchange: (v: Payload) => void;
|
|
34
33
|
assets: Asset[];
|
|
35
34
|
relations: Relations;
|
|
36
|
-
workerUrl: string;
|
|
37
35
|
imageUrl?: string;
|
|
38
36
|
prefix?: string;
|
|
39
37
|
fileBlueprints?: FileBlueprint[];
|
|
@@ -159,7 +157,6 @@
|
|
|
159
157
|
value={value[key]}
|
|
160
158
|
{assets}
|
|
161
159
|
{relations}
|
|
162
|
-
{workerUrl}
|
|
163
160
|
{fileBlueprints}
|
|
164
161
|
invalid={!!errors[key]}
|
|
165
162
|
onchange={(v) => set(key, v)}
|
|
@@ -173,7 +170,6 @@
|
|
|
173
170
|
{id}
|
|
174
171
|
value={(value[key] as string | string[]) ?? null}
|
|
175
172
|
{assets}
|
|
176
|
-
{workerUrl}
|
|
177
173
|
fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
|
|
178
174
|
multiple={field.type === 'media-list'}
|
|
179
175
|
onchange={(v) => set(key, v)}
|
|
@@ -185,7 +181,6 @@
|
|
|
185
181
|
value={(value[key] as Payload[]) ?? []}
|
|
186
182
|
{assets}
|
|
187
183
|
{relations}
|
|
188
|
-
{workerUrl}
|
|
189
184
|
errors={childErrors(key)}
|
|
190
185
|
onchange={(v) => set(key, v)}
|
|
191
186
|
/>
|
|
@@ -196,7 +191,6 @@
|
|
|
196
191
|
value={(value[key] as Payload) ?? {}}
|
|
197
192
|
{assets}
|
|
198
193
|
{relations}
|
|
199
|
-
{workerUrl}
|
|
200
194
|
prefix={id}
|
|
201
195
|
errors={childErrors(key)}
|
|
202
196
|
onchange={(v) => set(key, v)}
|
|
@@ -237,7 +231,6 @@
|
|
|
237
231
|
value={row}
|
|
238
232
|
{assets}
|
|
239
233
|
{relations}
|
|
240
|
-
{workerUrl}
|
|
241
234
|
prefix={id + '-' + i}
|
|
242
235
|
errors={childErrors(key + '.' + i)}
|
|
243
236
|
onchange={(v) =>
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
onchange,
|
|
17
17
|
assets,
|
|
18
18
|
relations,
|
|
19
|
-
workerUrl,
|
|
20
19
|
field,
|
|
21
20
|
fileBlueprints,
|
|
22
21
|
id,
|
|
@@ -26,7 +25,6 @@
|
|
|
26
25
|
onchange: (rows: Payload[]) => void;
|
|
27
26
|
assets: Asset[];
|
|
28
27
|
relations: Relations;
|
|
29
|
-
workerUrl: string;
|
|
30
28
|
field: Field;
|
|
31
29
|
fileBlueprints: FileBlueprint[];
|
|
32
30
|
id: string;
|
|
@@ -64,8 +62,8 @@
|
|
|
64
62
|
{@const effective = effectiveMetadata(metadata, row, field.fields ?? {})}
|
|
65
63
|
<div class="cms-stack">
|
|
66
64
|
<div class="cms-selected-image">
|
|
67
|
-
{#if asset && assetUrl(asset
|
|
68
|
-
src={assetUrl(asset
|
|
65
|
+
{#if asset && assetUrl(asset)}<img
|
|
66
|
+
src={assetUrl(asset)}
|
|
69
67
|
alt={String(row.alt ?? metadata.alt ?? '')}
|
|
70
68
|
draggable="false"
|
|
71
69
|
/>{/if}
|
|
@@ -103,7 +101,6 @@
|
|
|
103
101
|
value={effective}
|
|
104
102
|
{assets}
|
|
105
103
|
{relations}
|
|
106
|
-
{workerUrl}
|
|
107
104
|
{fileBlueprints}
|
|
108
105
|
prefix={`${id}-${i}`}
|
|
109
106
|
errors={Object.fromEntries(
|
|
@@ -123,7 +120,6 @@
|
|
|
123
120
|
<MediaPicker
|
|
124
121
|
{id}
|
|
125
122
|
assets={all}
|
|
126
|
-
{workerUrl}
|
|
127
123
|
multiple
|
|
128
124
|
hideSelection
|
|
129
125
|
fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
value,
|
|
23
23
|
assets,
|
|
24
24
|
relations,
|
|
25
|
-
workerUrl,
|
|
26
25
|
fileBlueprints,
|
|
27
26
|
invalid = false,
|
|
28
27
|
onchange
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
value?: Json;
|
|
33
32
|
assets: Asset[];
|
|
34
33
|
relations: Relations;
|
|
35
|
-
workerUrl: string;
|
|
36
34
|
fileBlueprints: FileBlueprint[];
|
|
37
35
|
invalid?: boolean;
|
|
38
36
|
onchange: (value: LinkValue | null) => void;
|
|
@@ -135,7 +133,6 @@
|
|
|
135
133
|
id={id + '-value'}
|
|
136
134
|
value={draft.value || null}
|
|
137
135
|
{assets}
|
|
138
|
-
{workerUrl}
|
|
139
136
|
fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
|
|
140
137
|
onchange={(value) =>
|
|
141
138
|
(draft = { ...draft, value: typeof value === 'string' ? value : '' })}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { Payload } from '../blueprints/types.js';
|
|
7
7
|
import Fields from './Fields.svelte';
|
|
8
8
|
import type { AdminData, Asset } from './types.js';
|
|
9
|
-
import { api, assetUrl, message } from './client.js';
|
|
9
|
+
import { api, assetUrl, megabytes, message } from './client.js';
|
|
10
10
|
import { Button } from './components/ui/button/index.js';
|
|
11
11
|
import { Label } from './components/ui/label/index.js';
|
|
12
12
|
import { Badge } from './components/ui/badge/index.js';
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import SelectField from './SelectField.svelte';
|
|
16
16
|
import { uploadImages, type UploadItem, type UploadFailure } from './uploads.js';
|
|
17
17
|
import UploadQueue from './UploadQueue.svelte';
|
|
18
|
+
import UploadProgress from './UploadProgress.svelte';
|
|
18
19
|
import AssetAttachment from './AssetAttachment.svelte';
|
|
19
20
|
import UploadButton from './UploadButton.svelte';
|
|
20
21
|
import Notice from './Notice.svelte';
|
|
@@ -109,6 +110,9 @@
|
|
|
109
110
|
batchBlueprint,
|
|
110
111
|
(index, state, error) => {
|
|
111
112
|
uploads[index] = { ...uploads[index], state, error };
|
|
113
|
+
},
|
|
114
|
+
(index, sent) => {
|
|
115
|
+
uploads[index] = { ...uploads[index], sent };
|
|
112
116
|
}
|
|
113
117
|
);
|
|
114
118
|
error = failures.map((failure) => failure.message).join('\n');
|
|
@@ -153,6 +157,7 @@
|
|
|
153
157
|
</div>
|
|
154
158
|
</div>
|
|
155
159
|
<UploadQueue items={uploads} />
|
|
160
|
+
<UploadProgress items={uploads} />
|
|
156
161
|
{#if failures.length}
|
|
157
162
|
<Button
|
|
158
163
|
variant="outline"
|
|
@@ -164,7 +169,7 @@
|
|
|
164
169
|
{#if error}<Notice error>{error}</Notice>{/if}
|
|
165
170
|
<div class="cms-list-meta">
|
|
166
171
|
<span class="cms-muted">{data.assets?.length ?? 0} assets</span><span class="cms-muted"
|
|
167
|
-
>Up to {(data.uploadLimit ?? 0)
|
|
172
|
+
>Up to {megabytes(data.uploadLimit ?? 0)} MB per image, including TIFF · SVG up to 1 MB</span
|
|
168
173
|
>
|
|
169
174
|
</div>
|
|
170
175
|
<SearchList
|
|
@@ -178,7 +183,6 @@
|
|
|
178
183
|
{#each assets as asset (asset.id)}
|
|
179
184
|
<AssetAttachment
|
|
180
185
|
{asset}
|
|
181
|
-
workerUrl={data.workerUrl!}
|
|
182
186
|
class="cms-media-card"
|
|
183
187
|
visibility={isPublic(asset.id) ? 'Public' : 'Private'}
|
|
184
188
|
onopen={() => {
|
|
@@ -206,16 +210,16 @@
|
|
|
206
210
|
>{/if}</Dialog.Header
|
|
207
211
|
>{#if active}{@const blueprint = data.fileBlueprints?.find((b) => b.id === active!.blueprint)}
|
|
208
212
|
<div class="cms-stack">
|
|
209
|
-
{#if !Object.values(blueprint?.fields ?? {}).some((field) => field.type === 'focus') && assetUrl(active
|
|
213
|
+
{#if !Object.values(blueprint?.fields ?? {}).some((field) => field.type === 'focus') && assetUrl(active)}<img
|
|
210
214
|
class="cms-asset-preview"
|
|
211
|
-
src={assetUrl(active
|
|
215
|
+
src={assetUrl(active)}
|
|
212
216
|
alt={String(active.metadata.alt ?? '')}
|
|
213
217
|
/>{/if}
|
|
214
218
|
{#if blueprint}<Fields
|
|
215
219
|
imageUrl={active.variants.some(
|
|
216
220
|
(v) => v.preset === 'sandcms-preview' || v.format === 'svg'
|
|
217
221
|
)
|
|
218
|
-
? assetUrl(active
|
|
222
|
+
? assetUrl(active)
|
|
219
223
|
: undefined}
|
|
220
224
|
fields={blueprint.fields}
|
|
221
225
|
value={metadata}
|
|
@@ -224,7 +228,6 @@
|
|
|
224
228
|
}}
|
|
225
229
|
assets={data.assets ?? []}
|
|
226
230
|
relations={data.relations ?? {}}
|
|
227
|
-
workerUrl={data.workerUrl!}
|
|
228
231
|
fileBlueprints={data.fileBlueprints}
|
|
229
232
|
prefix="media"
|
|
230
233
|
/>{/if}
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
import Upload from '@lucide/svelte/icons/upload';
|
|
9
9
|
import { uploadImages, type UploadItem, type UploadFailure } from './uploads.js';
|
|
10
10
|
import UploadQueue from './UploadQueue.svelte';
|
|
11
|
+
import UploadProgress from './UploadProgress.svelte';
|
|
12
|
+
import { imageMimeTypes } from '../blueprints/files.js';
|
|
11
13
|
import AssetAttachment from './AssetAttachment.svelte';
|
|
12
14
|
import SortableList from './SortableList.svelte';
|
|
13
15
|
import UploadButton from './UploadButton.svelte';
|
|
14
16
|
let {
|
|
15
17
|
value,
|
|
16
18
|
assets,
|
|
17
|
-
workerUrl,
|
|
18
19
|
onchange,
|
|
19
20
|
multiple = false,
|
|
20
21
|
hideSelection = false,
|
|
@@ -24,7 +25,6 @@
|
|
|
24
25
|
}: {
|
|
25
26
|
value: string | string[] | null;
|
|
26
27
|
assets: Asset[];
|
|
27
|
-
workerUrl: string;
|
|
28
28
|
onchange: (v: string | string[] | null) => void;
|
|
29
29
|
multiple?: boolean;
|
|
30
30
|
hideSelection?: boolean;
|
|
@@ -35,16 +35,7 @@
|
|
|
35
35
|
let uploads = $state<UploadItem[]>([]);
|
|
36
36
|
let dropArea = $state<HTMLDivElement | null>(null);
|
|
37
37
|
let dragging = $state(false);
|
|
38
|
-
const accept = $derived(
|
|
39
|
-
fileBlueprint?.accept ?? [
|
|
40
|
-
'image/jpeg',
|
|
41
|
-
'image/png',
|
|
42
|
-
'image/webp',
|
|
43
|
-
'image/avif',
|
|
44
|
-
'image/gif',
|
|
45
|
-
'image/svg+xml'
|
|
46
|
-
]
|
|
47
|
-
);
|
|
38
|
+
const accept = $derived(fileBlueprint?.accept ?? imageMimeTypes);
|
|
48
39
|
// Listen across the window so the grid responds as soon as files enter the app.
|
|
49
40
|
// The depth counter avoids flicker when crossing descendants of the grid.
|
|
50
41
|
$effect(() => {
|
|
@@ -172,6 +163,9 @@
|
|
|
172
163
|
batchBlueprint,
|
|
173
164
|
(index, state, error) => {
|
|
174
165
|
uploads[index] = { ...uploads[index], state, error };
|
|
166
|
+
},
|
|
167
|
+
(index, sent) => {
|
|
168
|
+
uploads[index] = { ...uploads[index], sent };
|
|
175
169
|
}
|
|
176
170
|
);
|
|
177
171
|
error = failures.map((failure) => failure.message).join('\n');
|
|
@@ -184,7 +178,6 @@
|
|
|
184
178
|
{#snippet selectedImage(asset: Asset)}
|
|
185
179
|
<AssetAttachment
|
|
186
180
|
{asset}
|
|
187
|
-
{workerUrl}
|
|
188
181
|
orientation="horizontal"
|
|
189
182
|
class="w-full"
|
|
190
183
|
onremove={() => onchange(multiple ? (value as string[]).filter((id) => id !== asset.id) : null)}
|
|
@@ -223,7 +216,7 @@
|
|
|
223
216
|
><Dialog.Content portalProps={{ disabled: true }} class="cms-media-dialog"
|
|
224
217
|
><Dialog.Header><Dialog.Title>Media library</Dialog.Title></Dialog.Header><UploadQueue
|
|
225
218
|
items={uploads}
|
|
226
|
-
/>
|
|
219
|
+
/><UploadProgress items={uploads} />
|
|
227
220
|
{#if failures.length}
|
|
228
221
|
<Button
|
|
229
222
|
variant="outline"
|
|
@@ -260,7 +253,6 @@
|
|
|
260
253
|
{#each matches.filter((a) => a.status !== 'deleting') as asset (asset.id)}
|
|
261
254
|
<AssetAttachment
|
|
262
255
|
{asset}
|
|
263
|
-
{workerUrl}
|
|
264
256
|
class="cms-picker-item"
|
|
265
257
|
selected={selected.some((a) => a.id === asset.id)}
|
|
266
258
|
onopen={() => {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { MediaQuery } from 'svelte/reactivity';
|
|
3
|
+
import Monitor from '@lucide/svelte/icons/monitor';
|
|
4
|
+
import Sun from '@lucide/svelte/icons/sun';
|
|
5
|
+
import Moon from '@lucide/svelte/icons/moon';
|
|
6
|
+
import Check from '@lucide/svelte/icons/check';
|
|
7
|
+
import * as Card from './components/ui/card/index.js';
|
|
8
|
+
import { useTheme } from './theme-context.js';
|
|
9
|
+
import type { Theme } from './theme.js';
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const prefersDark = new MediaQuery('(prefers-color-scheme: dark)', false);
|
|
12
|
+
const options: { value: Theme; label: string; icon: typeof Sun }[] = [
|
|
13
|
+
{ value: 'system', label: 'System', icon: Monitor },
|
|
14
|
+
{ value: 'light', label: 'Light', icon: Sun },
|
|
15
|
+
{ value: 'dark', label: 'Dark', icon: Moon }
|
|
16
|
+
];
|
|
17
|
+
const hint = (value: Theme) =>
|
|
18
|
+
value === 'system'
|
|
19
|
+
? `Match your device · now ${prefersDark.current ? 'dark' : 'light'}`
|
|
20
|
+
: value === 'light'
|
|
21
|
+
? 'Always use light'
|
|
22
|
+
: 'Always use dark';
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
{#snippet mock(tone: 'light' | 'dark')}
|
|
26
|
+
<span class="cms-theme-mock" data-tone={tone}>
|
|
27
|
+
<span class="cms-theme-mock-side"><i class="is-active"></i><i></i><i></i><i></i></span>
|
|
28
|
+
<span class="cms-theme-mock-main">
|
|
29
|
+
<span class="cms-theme-mock-title"></span>
|
|
30
|
+
<span class="cms-theme-mock-card">
|
|
31
|
+
<i class="is-accent"></i><i></i><i class="is-short"></i>
|
|
32
|
+
</span>
|
|
33
|
+
</span>
|
|
34
|
+
</span>
|
|
35
|
+
{/snippet}
|
|
36
|
+
|
|
37
|
+
<Card.Root class="cms-detail-card cms-settings-card">
|
|
38
|
+
<div class="cms-settings-header">
|
|
39
|
+
<div>
|
|
40
|
+
<h2>Appearance</h2>
|
|
41
|
+
<p class="cms-muted">Choose how the workspace looks in this browser.</p>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<fieldset class="cms-theme-picker">
|
|
45
|
+
<legend class="cms-theme-legend">Theme</legend>
|
|
46
|
+
{#each options as option (option.value)}
|
|
47
|
+
<label class="cms-theme-option">
|
|
48
|
+
<input
|
|
49
|
+
type="radio"
|
|
50
|
+
name="sandcms-theme"
|
|
51
|
+
value={option.value}
|
|
52
|
+
checked={theme.current === option.value}
|
|
53
|
+
onchange={() => theme.set(option.value)}
|
|
54
|
+
/>
|
|
55
|
+
<span class="cms-theme-preview" aria-hidden="true">
|
|
56
|
+
{#if option.value === 'system'}
|
|
57
|
+
{@render mock('light')}
|
|
58
|
+
<span class="cms-theme-split">{@render mock('dark')}</span>
|
|
59
|
+
{:else}
|
|
60
|
+
{@render mock(option.value)}
|
|
61
|
+
{/if}
|
|
62
|
+
</span>
|
|
63
|
+
<span class="cms-theme-meta">
|
|
64
|
+
<span class="cms-theme-label"><option.icon size={14} />{option.label}</span>
|
|
65
|
+
<span class="cms-theme-check" aria-hidden="true"><Check size={12} strokeWidth={3} /></span
|
|
66
|
+
>
|
|
67
|
+
</span>
|
|
68
|
+
<span class="cms-theme-hint">{hint(option.value)}</span>
|
|
69
|
+
</label>
|
|
70
|
+
{/each}
|
|
71
|
+
</fieldset>
|
|
72
|
+
</Card.Root>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ThemePicker: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ThemePicker = InstanceType<typeof ThemePicker>;
|
|
18
|
+
export default ThemePicker;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { Button } from './components/ui/button/index.js';
|
|
3
3
|
import { Input } from './components/ui/input/index.js';
|
|
4
4
|
import Upload from '@lucide/svelte/icons/upload';
|
|
5
|
+
import { imageMimeTypes } from '../blueprints/files.js';
|
|
5
6
|
let {
|
|
6
7
|
onchange,
|
|
7
8
|
busy = false,
|
|
8
9
|
multiple = false,
|
|
9
10
|
tile = false,
|
|
10
|
-
accept = '
|
|
11
|
+
accept = imageMimeTypes.join(',')
|
|
11
12
|
}: {
|
|
12
13
|
onchange: (event: Event) => void;
|
|
13
14
|
busy?: boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { megabytes } from './client.js';
|
|
3
|
+
import type { UploadItem } from './uploads.js';
|
|
4
|
+
|
|
5
|
+
let { items }: { items: UploadItem[] } = $props();
|
|
6
|
+
// Byte progress is only worth showing for files that take a while to transfer.
|
|
7
|
+
const current = $derived(
|
|
8
|
+
items.find((item) => item.state === 'uploading' && item.bytes > 1_000_000)
|
|
9
|
+
);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if current}
|
|
13
|
+
<div class="grid gap-1 text-sm">
|
|
14
|
+
<span class="cms-muted"
|
|
15
|
+
>{current.name} · {megabytes(current.sent ?? 0)} of {megabytes(current.bytes)} MB</span
|
|
16
|
+
>
|
|
17
|
+
<progress
|
|
18
|
+
class="w-full"
|
|
19
|
+
max={current.bytes}
|
|
20
|
+
value={current.sent ?? 0}
|
|
21
|
+
aria-label={`Uploading ${current.name}`}
|
|
22
|
+
></progress>
|
|
23
|
+
</div>
|
|
24
|
+
{/if}
|