@caretcms/core 0.1.2 → 0.3.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 +109 -13
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +1 -0
- package/dist/contracts.js.map +1 -1
- package/dist/index.d.ts +31 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +146 -30
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +17 -6
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +57 -14
- package/dist/loader.js.map +1 -1
- package/dist/markdown/block-context.d.ts +21 -0
- package/dist/markdown/block-context.d.ts.map +1 -0
- package/dist/markdown/block-context.js +27 -0
- package/dist/markdown/block-context.js.map +1 -0
- package/dist/markdown/canonical-body.d.ts +30 -0
- package/dist/markdown/canonical-body.d.ts.map +1 -0
- package/dist/markdown/canonical-body.js +54 -0
- package/dist/markdown/canonical-body.js.map +1 -0
- package/dist/markdown/contracts.d.ts +66 -0
- package/dist/markdown/contracts.d.ts.map +1 -0
- package/dist/markdown/contracts.js +102 -0
- package/dist/markdown/contracts.js.map +1 -0
- package/dist/markdown/html-to-snodes.d.ts +26 -0
- package/dist/markdown/html-to-snodes.d.ts.map +1 -0
- package/dist/markdown/html-to-snodes.js +118 -0
- package/dist/markdown/html-to-snodes.js.map +1 -0
- package/dist/markdown/remark.d.ts +35 -0
- package/dist/markdown/remark.d.ts.map +1 -0
- package/dist/markdown/remark.js +66 -0
- package/dist/markdown/remark.js.map +1 -0
- package/dist/markdown/satteri.d.ts +19 -0
- package/dist/markdown/satteri.d.ts.map +1 -0
- package/dist/markdown/satteri.js +144 -0
- package/dist/markdown/satteri.js.map +1 -0
- package/dist/markdown/serialize.d.ts +60 -0
- package/dist/markdown/serialize.d.ts.map +1 -0
- package/dist/markdown/serialize.js +264 -0
- package/dist/markdown/serialize.js.map +1 -0
- package/dist/markdown/splice.d.ts +32 -0
- package/dist/markdown/splice.d.ts.map +1 -0
- package/dist/markdown/splice.js +44 -0
- package/dist/markdown/splice.js.map +1 -0
- package/dist/markdown/stamp.d.ts +68 -0
- package/dist/markdown/stamp.d.ts.map +1 -0
- package/dist/markdown/stamp.js +131 -0
- package/dist/markdown/stamp.js.map +1 -0
- package/dist/runtime/auth/rate-limiter.d.ts.map +1 -1
- package/dist/runtime/auth/rate-limiter.js +5 -0
- package/dist/runtime/auth/rate-limiter.js.map +1 -1
- package/dist/runtime/auth/session.d.ts +3 -3
- package/dist/runtime/auth/session.d.ts.map +1 -1
- package/dist/runtime/auth/session.js +68 -21
- package/dist/runtime/auth/session.js.map +1 -1
- package/dist/runtime/config.d.ts +3 -0
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/config.js +4 -1
- package/dist/runtime/config.js.map +1 -1
- package/dist/runtime/content.d.ts.map +1 -1
- package/dist/runtime/content.js +4 -2
- package/dist/runtime/content.js.map +1 -1
- package/dist/runtime/i18n.d.ts +86 -0
- package/dist/runtime/i18n.d.ts.map +1 -0
- package/dist/runtime/i18n.js +168 -0
- package/dist/runtime/i18n.js.map +1 -0
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/middleware.js +61 -6
- package/dist/runtime/middleware.js.map +1 -1
- package/dist/runtime/mutations/contracts.d.ts +28 -1
- package/dist/runtime/mutations/contracts.d.ts.map +1 -1
- package/dist/runtime/mutations/contracts.js +76 -0
- package/dist/runtime/mutations/contracts.js.map +1 -1
- package/dist/runtime/mutations/engine.d.ts +6 -1
- package/dist/runtime/mutations/engine.d.ts.map +1 -1
- package/dist/runtime/mutations/engine.js +271 -51
- package/dist/runtime/mutations/engine.js.map +1 -1
- package/dist/runtime/providers.d.ts +2 -1
- package/dist/runtime/providers.d.ts.map +1 -1
- package/dist/runtime/providers.js +7 -1
- package/dist/runtime/providers.js.map +1 -1
- package/dist/runtime/publish.d.ts +13 -1
- package/dist/runtime/publish.d.ts.map +1 -1
- package/dist/runtime/publish.js +80 -4
- package/dist/runtime/publish.js.map +1 -1
- package/dist/runtime/request-context.d.ts +14 -2
- package/dist/runtime/request-context.d.ts.map +1 -1
- package/dist/runtime/request-context.js +7 -1
- package/dist/runtime/request-context.js.map +1 -1
- package/dist/runtime/rewrite.d.ts.map +1 -1
- package/dist/runtime/rewrite.js +109 -3
- package/dist/runtime/rewrite.js.map +1 -1
- package/dist/runtime/rich-allowlist.d.ts.map +1 -1
- package/dist/runtime/rich-allowlist.js +5 -1
- package/dist/runtime/rich-allowlist.js.map +1 -1
- package/dist/runtime/routes/admin-entry.d.ts.map +1 -1
- package/dist/runtime/routes/admin-entry.js +114 -18
- package/dist/runtime/routes/admin-entry.js.map +1 -1
- package/dist/runtime/routes/admin.d.ts.map +1 -1
- package/dist/runtime/routes/admin.js +33 -15
- package/dist/runtime/routes/admin.js.map +1 -1
- package/dist/runtime/routes/auth-login.d.ts.map +1 -1
- package/dist/runtime/routes/auth-login.js +4 -0
- package/dist/runtime/routes/auth-login.js.map +1 -1
- package/dist/runtime/routes/auth-logout.d.ts.map +1 -1
- package/dist/runtime/routes/auth-logout.js +7 -2
- package/dist/runtime/routes/auth-logout.js.map +1 -1
- package/dist/runtime/routes/auth-session.d.ts.map +1 -1
- package/dist/runtime/routes/auth-session.js +4 -2
- package/dist/runtime/routes/auth-session.js.map +1 -1
- package/dist/runtime/routes/collection-list.d.ts.map +1 -1
- package/dist/runtime/routes/collection-list.js +64 -41
- package/dist/runtime/routes/collection-list.js.map +1 -1
- package/dist/runtime/routes/entries.d.ts.map +1 -1
- package/dist/runtime/routes/entries.js +16 -6
- package/dist/runtime/routes/entries.js.map +1 -1
- package/dist/runtime/routes/history.d.ts.map +1 -1
- package/dist/runtime/routes/history.js +50 -22
- package/dist/runtime/routes/history.js.map +1 -1
- package/dist/runtime/routes/mutate.d.ts.map +1 -1
- package/dist/runtime/routes/mutate.js +40 -6
- package/dist/runtime/routes/mutate.js.map +1 -1
- package/dist/runtime/routes/publish.d.ts.map +1 -1
- package/dist/runtime/routes/publish.js +5 -2
- package/dist/runtime/routes/publish.js.map +1 -1
- package/dist/runtime/routes/schema.d.ts.map +1 -1
- package/dist/runtime/routes/schema.js +11 -3
- package/dist/runtime/routes/schema.js.map +1 -1
- package/dist/runtime/routes/studio-home.d.ts.map +1 -1
- package/dist/runtime/routes/studio-home.js +38 -19
- package/dist/runtime/routes/studio-home.js.map +1 -1
- package/dist/runtime/routes/theme-stylesheet.d.ts.map +1 -1
- package/dist/runtime/routes/theme-stylesheet.js +11 -1
- package/dist/runtime/routes/theme-stylesheet.js.map +1 -1
- package/dist/runtime/schema-registry.d.ts +8 -1
- package/dist/runtime/schema-registry.d.ts.map +1 -1
- package/dist/runtime/schema-registry.js +47 -3
- package/dist/runtime/schema-registry.js.map +1 -1
- package/dist/runtime/storage/atomic-write.d.ts.map +1 -1
- package/dist/runtime/storage/atomic-write.js +8 -3
- package/dist/runtime/storage/atomic-write.js.map +1 -1
- package/dist/runtime/storage/markdown-adapter.d.ts +19 -0
- package/dist/runtime/storage/markdown-adapter.d.ts.map +1 -1
- package/dist/runtime/storage/markdown-adapter.js +41 -0
- package/dist/runtime/storage/markdown-adapter.js.map +1 -1
- package/dist/runtime/storage/session-overlay-adapter.d.ts +8 -0
- package/dist/runtime/storage/session-overlay-adapter.d.ts.map +1 -1
- package/dist/runtime/storage/session-overlay-adapter.js +24 -2
- package/dist/runtime/storage/session-overlay-adapter.js.map +1 -1
- package/dist/runtime/themes/preset-tokens.js +4 -4
- package/dist/runtime/themes/preset-tokens.js.map +1 -1
- package/dist/runtime/utils.d.ts +10 -0
- package/dist/runtime/utils.d.ts.map +1 -1
- package/dist/runtime/utils.js +16 -0
- package/dist/runtime/utils.js.map +1 -1
- package/dist/runtime/views/studio-layout.d.ts +3 -0
- package/dist/runtime/views/studio-layout.d.ts.map +1 -1
- package/dist/runtime/views/studio-layout.js +36 -13
- package/dist/runtime/views/studio-layout.js.map +1 -1
- package/dist/schema-utils.d.ts +7 -0
- package/dist/schema-utils.d.ts.map +1 -1
- package/dist/schema-utils.js +143 -0
- package/dist/schema-utils.js.map +1 -1
- package/dist/types.d.ts +83 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/static/cms/admin-entry.css +135 -13
- package/static/cms/admin-entry.js +509 -86
- package/static/cms/editor/guards.js +1 -1
- package/static/cms/editor/image-edit.js +42 -11
- package/static/cms/editor/image.css +7 -1
- package/static/cms/editor/md-block-edit.js +176 -0
- package/static/cms/editor/md-serialize.js +301 -0
- package/static/cms/editor/panel.css +69 -25
- package/static/cms/editor/panel.js +58 -1
- package/static/cms/editor/rich-toolbar.js +4 -3
- package/static/cms/editor/sanitize.js +2 -1
- package/static/cms/editor/sync.js +277 -56
- package/static/cms/editor/text-edit.js +68 -17
- package/static/cms/editor/text-link-interactions.js +4 -4
- package/static/cms/editor/toast.css +114 -2
- package/static/cms/editor/toast.js +121 -22
- package/static/cms/editor/tokens-and-text.css +73 -3
- package/static/cms/editor/toolbar.css +19 -6
- package/static/cms/editor/toolbar.js +64 -23
- package/static/cms/editor.css +1 -1
- package/static/cms/editor.js +14 -3
- package/static/cms/studio-tokens.css +4 -4
- package/static/cms/studio.css +24 -0
package/README.md
CHANGED
|
@@ -10,12 +10,15 @@ Inline editing and live content collections for Astro. Add one HTML attribute to
|
|
|
10
10
|
npm install @caretcms/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**Static Astro site?** Use
|
|
13
|
+
**Static Astro site?** Use `caret()` — no SSR adapter:
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
|
-
integrations: [caret(
|
|
16
|
+
integrations: [caret()],
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
`caret()` auto-detects Astro output: static output gets build-time baking, server
|
|
20
|
+
output gets middleware rewriting.
|
|
21
|
+
|
|
19
22
|
**Server-rendered site?** Add an adapter and server output:
|
|
20
23
|
|
|
21
24
|
```bash
|
|
@@ -32,6 +35,14 @@ See [Static delivery](../../docs/static-delivery.md) and [Rendering & output](#r
|
|
|
32
35
|
|
|
33
36
|
## Setup
|
|
34
37
|
|
|
38
|
+
Fast path for an existing Astro site:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx @caretcms/caretize init
|
|
42
|
+
npx @caretcms/caretize
|
|
43
|
+
npm run dev
|
|
44
|
+
```
|
|
45
|
+
|
|
35
46
|
### Static delivery (default path for static Astro sites)
|
|
36
47
|
|
|
37
48
|
```js
|
|
@@ -40,10 +51,16 @@ import { defineConfig } from 'astro/config';
|
|
|
40
51
|
import caret from '@caretcms/core';
|
|
41
52
|
|
|
42
53
|
export default defineConfig({
|
|
43
|
-
|
|
54
|
+
// Astro defaults to output: 'static'; caret() auto-selects static delivery.
|
|
55
|
+
integrations: [caret()],
|
|
44
56
|
});
|
|
45
57
|
```
|
|
46
58
|
|
|
59
|
+
Enable public access for the R2 bucket and set `R2_PUBLIC_DOMAIN` to that
|
|
60
|
+
hostname, or pass `publicBaseUrl` to `r2Uploads()`. Uploads fail with an
|
|
61
|
+
actionable configuration error if no public URL is available; Caret core does
|
|
62
|
+
not mount an R2 image proxy.
|
|
63
|
+
|
|
47
64
|
- **`astro dev`** — full authoring: `/admin`, `/api/cms`, inline editor.
|
|
48
65
|
- **`astro build`** — bakes stored overrides into generated HTML; authoring routes stay out of production output.
|
|
49
66
|
- **Public updates** — after Publish, run CI/build/deploy (optionally via `delivery.publish.webhookUrl`).
|
|
@@ -68,9 +85,27 @@ Edits are visible to visitors immediately — middleware rewrites HTML on each r
|
|
|
68
85
|
**Already have Astro content collections?** If your project has collections under
|
|
69
86
|
`src/content/` and you haven't set `storage`, CaretCMS auto-selects
|
|
70
87
|
`markdownStorage()` so the Studio lists those collections immediately (instead of
|
|
71
|
-
"No collections yet") and edits write back to your `.md`
|
|
88
|
+
"No collections yet") and edits write back to your `.md` files. Pass an
|
|
72
89
|
explicit `storage` to override — `storage: filesystemStorage()` opts back out.
|
|
73
90
|
|
|
91
|
+
### Edit Markdown prose on the page
|
|
92
|
+
|
|
93
|
+
When Astro renders a `.md` entry through `markdownStorage()`, Caret marks safe
|
|
94
|
+
prose blocks automatically. Sign in, click a paragraph or heading, edit it on the
|
|
95
|
+
page, then publish the draft to write the change back to the source file.
|
|
96
|
+
|
|
97
|
+
Caret supports paragraphs, ATX headings, list items, and paragraphs inside
|
|
98
|
+
blockquotes. Bold, emphasis, links, inline code, and line breaks round-trip to
|
|
99
|
+
Markdown. Code blocks, tables, raw HTML blocks, and MDX stay read-only. Nested
|
|
100
|
+
blocks must fit on one source line.
|
|
101
|
+
|
|
102
|
+
Each draft records the source range and a hash of the original text. If the file
|
|
103
|
+
changes before publish, Caret returns a conflict and leaves both the file and the
|
|
104
|
+
draft untouched. Set `bodyEditing: false` in `caret()` to disable this feature.
|
|
105
|
+
|
|
106
|
+
See [Markdown body editing](https://caretcms.com/docs/markdown-body-editing/) for
|
|
107
|
+
the full setup, supported syntax, and publish workflow.
|
|
108
|
+
|
|
74
109
|
## Choose your path
|
|
75
110
|
|
|
76
111
|
CaretCMS gives you two ways to make content editable. They share one storage layer and one login — you can mix them on the same site — but they answer different questions. Start at the top; reach for the next row only when you need it.
|
|
@@ -109,7 +144,7 @@ With no password configured, a **temporary dev password is printed in the termin
|
|
|
109
144
|
production stays locked). To set a permanent one, add `CARET_EDIT_PASSWORD=<your-password>` to a
|
|
110
145
|
`.env` file.
|
|
111
146
|
|
|
112
|
-
Log in at `/admin`, then click any
|
|
147
|
+
Log in at `/admin`, then click any tagged element on the page to edit it. The content Studio
|
|
113
148
|
lives at `/admin/cms`.
|
|
114
149
|
|
|
115
150
|
The inline editor only bootstraps on pages that contain `data-caret` bindings and only after
|
|
@@ -267,21 +302,71 @@ caret({
|
|
|
267
302
|
apiBasePath: '/api/cms', // API route prefix (default: /api/cms)
|
|
268
303
|
enableAdmin: true, // Inject admin pages (default: true)
|
|
269
304
|
enableInlineEditor: true, // Inject inline editor (default: true)
|
|
270
|
-
delivery: '
|
|
305
|
+
delivery: 'auto', // 'auto' | 'static' | 'server' | { mode, bake, publish }
|
|
271
306
|
storage: filesystemStorage(), // Storage adapter (default: markdownStorage when
|
|
272
307
|
// src/content collections exist, else filesystem)
|
|
273
308
|
uploads: localUploads(), // Upload handler (default: local filesystem)
|
|
274
309
|
schemas: {}, // Optional JSON Schema map for Studio (default: inferred)
|
|
310
|
+
collections: {}, // Labels, ordering, capabilities, and singletons
|
|
311
|
+
locale: 'en', // 'en' | 'es'; dictionary overrides are also supported
|
|
312
|
+
bodyEditing: true, // Inline editing for rendered Markdown prose
|
|
275
313
|
})
|
|
276
314
|
```
|
|
277
315
|
|
|
316
|
+
### Optional named identity adapter
|
|
317
|
+
|
|
318
|
+
Shared-password mode remains the zero-dependency default. Server deployments can
|
|
319
|
+
instead configure an authoritative identity provider:
|
|
320
|
+
|
|
321
|
+
```js
|
|
322
|
+
import caret, { defineIdentityProvider } from '@caretcms/core';
|
|
323
|
+
|
|
324
|
+
caret({
|
|
325
|
+
identity: defineIdentityProvider({
|
|
326
|
+
entrypoint: './src/caret-identity.ts',
|
|
327
|
+
exportName: 'identityProvider',
|
|
328
|
+
options: { loginOrigin: 'https://login.example.com' },
|
|
329
|
+
}),
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
The provider module exports a factory returning an `IdentityAdapter`:
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
import type { IdentityAdapter } from '@caretcms/core';
|
|
337
|
+
|
|
338
|
+
export function identityProvider(options: { loginOrigin: string }): IdentityAdapter {
|
|
339
|
+
return {
|
|
340
|
+
async authenticate(request) {
|
|
341
|
+
// Verify a trusted session/header and enforce editor authorization here.
|
|
342
|
+
// Return null to deny access. IDs must match /^[A-Za-z0-9_-]{1,64}$/.
|
|
343
|
+
return { id: 'editor_01', name: 'Alex Rivera', roles: ['editor'] };
|
|
344
|
+
},
|
|
345
|
+
loginUrl({ redirectTo }) {
|
|
346
|
+
return `${options.loginOrigin}/login?returnTo=${encodeURIComponent(redirectTo)}`;
|
|
347
|
+
},
|
|
348
|
+
logoutUrl({ redirectTo }) {
|
|
349
|
+
return `${options.loginOrigin}/logout?returnTo=${encodeURIComponent(redirectTo)}`;
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
When `identity` is configured it is authoritative: Caret does not fall back to
|
|
356
|
+
the shared password. Authentication errors and unsafe IDs fail closed. Named
|
|
357
|
+
identity is exposed by `/api/cms/auth/session`, shown in Studio, used as the
|
|
358
|
+
private-preview overlay key, and attached to new history snapshots. Only trust
|
|
359
|
+
identity headers when a proxy strips client-supplied copies and writes its own.
|
|
360
|
+
|
|
278
361
|
## Rendering & output
|
|
279
362
|
|
|
280
|
-
CaretCMS
|
|
363
|
+
CaretCMS defaults to automatic delivery. With `caret()` or `delivery: 'auto'`, Astro
|
|
364
|
+
`output: 'static'` uses static delivery and Astro `output: 'server'` uses server
|
|
365
|
+
delivery.
|
|
281
366
|
|
|
282
|
-
| | **Static delivery** | **Server delivery**
|
|
367
|
+
| | **Static delivery** | **Server delivery** |
|
|
283
368
|
|---|---|---|
|
|
284
|
-
| Config | `caret(
|
|
369
|
+
| Config | `caret()` on default/static output | `caret()` on `output: 'server'` + adapter |
|
|
285
370
|
| Public HTML | Baked at `astro build` | Rewritten per request in middleware |
|
|
286
371
|
| Production CMS routes | Not shipped in static output | `/admin`, `/api/cms` live on the server |
|
|
287
372
|
| Visitor sees edits | After publish + rebuild | Immediately after save |
|
|
@@ -290,12 +375,13 @@ CaretCMS supports two delivery modes via `delivery`:
|
|
|
290
375
|
### Static delivery
|
|
291
376
|
|
|
292
377
|
Use when your site stays `output: 'static'`. Local authoring works in `astro dev`; production
|
|
293
|
-
is plain static files with content baked in.
|
|
378
|
+
is plain static files with content baked in. `caret()` is enough; pass `delivery`
|
|
379
|
+
only when you want to configure bake/publish behavior or explicitly pin the mode.
|
|
294
380
|
|
|
295
381
|
```js
|
|
296
382
|
caret({
|
|
297
383
|
delivery: {
|
|
298
|
-
mode
|
|
384
|
+
// mode defaults to 'auto', so static Astro output still uses static delivery
|
|
299
385
|
bake: true,
|
|
300
386
|
publish: {
|
|
301
387
|
webhookUrl: 'https://ci.example.com/hooks/rebuild',
|
|
@@ -304,6 +390,9 @@ caret({
|
|
|
304
390
|
})
|
|
305
391
|
```
|
|
306
392
|
|
|
393
|
+
Use `delivery: 'static'` when you want the integration to error if Astro output is
|
|
394
|
+
changed away from static.
|
|
395
|
+
|
|
307
396
|
Full guide: [docs/static-delivery.md](../../docs/static-delivery.md).
|
|
308
397
|
|
|
309
398
|
### Server delivery
|
|
@@ -325,7 +414,7 @@ The default (embedded) providers write inside your project:
|
|
|
325
414
|
| `.caret/data/` | entry JSON | `filesystemStorage()` (default) |
|
|
326
415
|
| `.caret/drafts/` | per-editor draft overlays | `filesystemStorage()` |
|
|
327
416
|
| `.caretcms/` | revisions + history sidecar | both filesystem and markdown storage |
|
|
328
|
-
| `src/content/**.md` | frontmatter edits | `markdownStorage()` (auto-selected when you have content collections) |
|
|
417
|
+
| `src/content/**.md` | frontmatter and published prose edits | `markdownStorage()` (auto-selected when you have content collections) |
|
|
329
418
|
| `public/uploads/` | uploaded images | `localUploads()` (default) |
|
|
330
419
|
|
|
331
420
|
Recommended `.gitignore` for the transient state (keep `.caret/data/` or your
|
|
@@ -344,6 +433,9 @@ public/uploads/
|
|
|
344
433
|
- `CARET_SESSION_SECRET` — **required in production** when a password is set; sessions are
|
|
345
434
|
HMAC-signed with it. Generate one with `openssl rand -base64 32`. If it's missing, logins
|
|
346
435
|
return a configuration error and existing sessions are treated as signed out.
|
|
436
|
+
- Rotate `CARET_EDIT_PASSWORD` and `CARET_SESSION_SECRET` together, then restart or redeploy
|
|
437
|
+
every instance. Changing the session secret immediately invalidates all existing editor
|
|
438
|
+
cookies; changing only the password does not revoke sessions that are already signed in.
|
|
347
439
|
- `markdownStorage()` edits `src/content/*.md` **at request time** — a dev/git workflow. In
|
|
348
440
|
production, pair it with commit-on-publish + a CI rebuild (fields rendered through
|
|
349
441
|
`getCollection()` are baked at build time and only refresh on rebuild), or use a server-side
|
|
@@ -355,9 +447,13 @@ public/uploads/
|
|
|
355
447
|
from your project root, or pass explicit paths (`filesystemStorage({ dataRoot })`,
|
|
356
448
|
`markdownStorage({ contentRoot })`, `localUploads({ uploadsDir })`).
|
|
357
449
|
|
|
450
|
+
Password mode is deliberately a single shared-editor workflow: it has no named users, roles,
|
|
451
|
+
or per-user attribution. Teams needing those controls should configure the authoritative
|
|
452
|
+
identity adapter described above.
|
|
453
|
+
|
|
358
454
|
## Requirements
|
|
359
455
|
|
|
360
|
-
- Astro
|
|
456
|
+
- Astro 6 or 7
|
|
361
457
|
- Node 20.19.1+ or 22.12.0+
|
|
362
458
|
- **Static delivery:** default Astro static output (no adapter)
|
|
363
459
|
- **Server delivery:** `output: 'server'` plus an SSR adapter
|
package/dist/contracts.d.ts
CHANGED
|
@@ -11,4 +11,5 @@
|
|
|
11
11
|
export { COLLECTION_NAME_RE, ENTRY_ID_RE, EDITOR_ID_RE, assertSafeEditorId, } from "./runtime/storage/id-contracts.js";
|
|
12
12
|
export { REWRITABLE_TEXT_TAGS } from "./runtime/rewrite.js";
|
|
13
13
|
export { RICH_ALLOWED_TAGS, RICH_ALLOWED_ATTRS, SAFE_HREF_RE, } from "./runtime/rich-allowlist.js";
|
|
14
|
+
export { CARET_MD_ATTR, CARET_MD_SRC_ATTR, BODY_OVERLAY_KEY, BODY_FIELD, BLOCK_PATH_RE, formatBlockPath, parseBlockPath, formatMdBinding, parseMdBinding, formatMdSrc, parseMdSrc, fnv1a32, type MdBinding, type MdSrc, } from "./markdown/contracts.js";
|
|
14
15
|
//# sourceMappingURL=contracts.d.ts.map
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,EACX,UAAU,EACV,OAAO,EACP,KAAK,SAAS,EACd,KAAK,KAAK,GACX,MAAM,yBAAyB,CAAC"}
|
package/dist/contracts.js
CHANGED
|
@@ -11,4 +11,5 @@
|
|
|
11
11
|
export { COLLECTION_NAME_RE, ENTRY_ID_RE, EDITOR_ID_RE, assertSafeEditorId, } from "./runtime/storage/id-contracts.js";
|
|
12
12
|
export { REWRITABLE_TEXT_TAGS } from "./runtime/rewrite.js";
|
|
13
13
|
export { RICH_ALLOWED_TAGS, RICH_ALLOWED_ATTRS, SAFE_HREF_RE, } from "./runtime/rich-allowlist.js";
|
|
14
|
+
export { CARET_MD_ATTR, CARET_MD_SRC_ATTR, BODY_OVERLAY_KEY, BODY_FIELD, BLOCK_PATH_RE, formatBlockPath, parseBlockPath, formatMdBinding, parseMdBinding, formatMdSrc, parseMdSrc, fnv1a32, } from "./markdown/contracts.js";
|
|
14
15
|
//# sourceMappingURL=contracts.js.map
|
package/dist/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,EACX,UAAU,EACV,OAAO,GAGR,MAAM,yBAAyB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AstroIntegration } from "astro";
|
|
2
|
-
import type { CaretStorageProvider, CaretUploadProvider } from "./types.js";
|
|
3
|
-
|
|
2
|
+
import type { CaretStorageProvider, CaretUploadProvider, CollectionStudioConfig, CaretIdentityProvider } from "./types.js";
|
|
3
|
+
import { type StudioDictionary, type StudioLocale } from "./runtime/i18n.js";
|
|
4
|
+
export type { StorageAdapter, UploadHandler, UploadContext, EntryData, HistoryEntry, CollectionMetadata, CollectionSchema, CollectionStudioConfig, CaretIdentityProvider, IdentityAdapter, EditorIdentity, CaretMode, CaretStorageProvider, CaretUploadProvider, RuntimeProviderReference, } from "./types.js";
|
|
5
|
+
export type { StudioDictionary, StudioLocale, StudioMessageKey } from "./runtime/i18n.js";
|
|
4
6
|
export { FilesystemAdapter } from "./runtime/storage/filesystem-adapter.js";
|
|
5
7
|
export { MarkdownAdapter } from "./runtime/storage/markdown-adapter.js";
|
|
6
8
|
export { InMemoryAdapter } from "./runtime/storage/in-memory-adapter.js";
|
|
@@ -9,6 +11,7 @@ export { bindEntry } from "./runtime/bind.js";
|
|
|
9
11
|
export { caretLoader, CaretLoaderError } from "./loader.js";
|
|
10
12
|
export type { CaretLiveLoader } from "./loader.js";
|
|
11
13
|
export { editable } from "./editable.js";
|
|
14
|
+
export { stegaClean } from "./runtime/stega.js";
|
|
12
15
|
type ProviderDefinitionOptions = {
|
|
13
16
|
entrypoint: string;
|
|
14
17
|
exportName?: string;
|
|
@@ -55,6 +58,12 @@ type BaseCaretOptions = {
|
|
|
55
58
|
* by z.toJSONSchema() from a Zod schema).
|
|
56
59
|
*/
|
|
57
60
|
schemas?: Record<string, JsonSchemaDefinition>;
|
|
61
|
+
/** Studio labels, ordering, and mutation capabilities by collection. */
|
|
62
|
+
collections?: Record<string, CollectionStudioConfig>;
|
|
63
|
+
/** Fixed Studio chrome language. Spanish and English ship with core. */
|
|
64
|
+
locale?: StudioLocale;
|
|
65
|
+
/** Per-message overrides applied after the selected first-party locale. */
|
|
66
|
+
dictionary?: StudioDictionary;
|
|
58
67
|
/**
|
|
59
68
|
* Per-tag class allowlist for rich-text (`data-caret-rich`) fields. By default
|
|
60
69
|
* the rich-text sanitizer strips every `class` (keeping only semantic inline
|
|
@@ -70,16 +79,26 @@ type BaseCaretOptions = {
|
|
|
70
79
|
*/
|
|
71
80
|
allowedClasses?: Record<string, string[]>;
|
|
72
81
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
82
|
+
* Inline editing of the markdown BODY (prose blocks) for entries served from
|
|
83
|
+
* markdown storage. When on (the default with markdown storage), rendered
|
|
84
|
+
* paragraphs, headings, and list items on the page are stamped with
|
|
85
|
+
* `data-caret-md` bindings so they can be edited in place and published back
|
|
86
|
+
* to the source `.md` file. Set `false` to disable the render-time stamping.
|
|
87
|
+
* No effect on non-markdown storage or cloud mode.
|
|
77
88
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
bodyEditing?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Delivery target for embedded CaretCMS content. The default is "auto":
|
|
92
|
+
* Astro static output bakes stored content into generated HTML during
|
|
93
|
+
* `astro build`, while Astro server output rewrites HTML per request with
|
|
94
|
+
* middleware. Explicit "static"/"server" remain available when you want the
|
|
95
|
+
* integration to validate that Astro's output matches your chosen delivery.
|
|
96
|
+
*/
|
|
97
|
+
delivery?: "auto" | "server" | "static" | {
|
|
98
|
+
mode?: "auto" | "server" | "static";
|
|
80
99
|
/**
|
|
81
100
|
* Whether `astro build` should rewrite generated HTML with stored
|
|
82
|
-
* CaretCMS values. Defaults to true for static delivery.
|
|
101
|
+
* CaretCMS values. Defaults to true for effective static delivery.
|
|
83
102
|
*/
|
|
84
103
|
bake?: boolean;
|
|
85
104
|
publish?: {
|
|
@@ -109,15 +128,18 @@ export type CaretOptions = (BaseCaretOptions & {
|
|
|
109
128
|
mode?: "embedded";
|
|
110
129
|
storage?: CaretStorageProvider;
|
|
111
130
|
uploads?: CaretUploadProvider;
|
|
131
|
+
identity?: CaretIdentityProvider;
|
|
112
132
|
cloud?: never;
|
|
113
133
|
}) | (BaseCaretOptions & {
|
|
114
134
|
mode: "cloud";
|
|
115
135
|
cloud: CaretCloudOptions;
|
|
116
136
|
storage?: never;
|
|
117
137
|
uploads?: never;
|
|
138
|
+
identity?: never;
|
|
118
139
|
});
|
|
119
140
|
export declare function defineStorageProvider(options: ProviderDefinitionOptions): CaretStorageProvider;
|
|
120
141
|
export declare function defineUploadProvider(options: ProviderDefinitionOptions): CaretUploadProvider;
|
|
142
|
+
export declare function defineIdentityProvider(options: ProviderDefinitionOptions): CaretIdentityProvider;
|
|
121
143
|
export declare function filesystemStorage(options?: {
|
|
122
144
|
dataRoot?: string;
|
|
123
145
|
metaRoot?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,EAGnB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAI3B,YAAY,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,E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