bearminion 1.15.0 → 1.16.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/CHANGELOG.md +8 -0
- package/dist/astro.d.ts +26 -4
- package/dist/astro.js +49 -11
- package/dist/collections-BbL4_4jt.js +735 -0
- package/dist/content.d.ts +1 -1
- package/dist/{draft-store-BaZYEe56.js → draft-store-DBEfw_Gq.js} +1 -36
- package/dist/{editor-context-CTfxXtny.d.ts → editor-context-BBsL5NFx.d.ts} +41 -3
- package/dist/{github-store-BT9uiq5W.d.ts → github-store-DLQazToO.d.ts} +2 -2
- package/dist/{github-store-D0bQOwdt.js → github-store-DUf07ODw.js} +102 -152
- package/dist/hosted-astro.d.ts +6 -0
- package/dist/hosted-astro.js +15 -0
- package/dist/hosted-middleware-DTnZoRsK.js +343 -0
- package/dist/hosted-overlay.d.ts +2 -0
- package/dist/hosted-overlay.js +2 -0
- package/dist/hosted.d.ts +151 -5
- package/dist/hosted.js +171 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{page-FipdIFb5.d.ts → page-D1pdneYm.d.ts} +223 -223
- package/dist/request-guards-BcSUj8Gc.js +90 -0
- package/dist/ui/mount.js +2 -1
- package/dist/upload-rules-Cao9uY5K.js +36 -0
- package/package.json +16 -3
- package/registry/default/registry.json +1 -1
- package/dist/preview-ImEm3T8k.js +0 -125
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# bearminion
|
|
2
2
|
|
|
3
|
+
## 1.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7b4b9df: Add Markdown collections to the editor API (experimental): `collections: { blog: collection({ schema, path: 'src/content/blog/{slug}.md' }) }` lets the editor API list, read, create, save, rename and delete the entries of an existing Astro content collection, validated with the site's own Zod schema. A save rewrites only the frontmatter keys and body blocks that changed, so an unchanged entry produces no diff. Rename and delete are off unless enabled. Store keys with a leading slash now address the project root (`/src/content/blog/en/post.md`), which the file store and `githubStore` both support.
|
|
8
|
+
- 3b789a4: Add `bearminionHostedEditor` to `bearminion/astro` (experimental): turns a second deployment of your site into the hosted editor. It switches to server output, signs people in, and draws each page from the repository's current content with the editor overlay on top, while the public site stays a static build with no editor code. The default template's pages read `Astro.locals.bearminion` when it is set. `bearminion/hosted` also gains `createStoreContent`, `createHostedMiddleware` and `HostedEditor.scope`.
|
|
9
|
+
- d555385: Add `createHostedEditor` to `bearminion/hosted` (experimental): GitHub App sign-in (OAuth with PKCE, encrypted session cookie) in front of the editor API. Each request runs on the signed-in person's own GitHub token, so commits are authored by them and the repository's branch rules apply; only people with push access to the repository may sign in. The editor overlay is also built as one browser script (`bearminion/hosted-overlay`), which `createHostedEditor` serves and injects into pages for signed-in people only.
|
|
10
|
+
|
|
3
11
|
## 1.15.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/astro.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { _ as CollectionOptions, b as StoreOperation, n as ImageConvertOptions, t as EditorContext, x as UploadStore, y as ContentStore } from "./editor-context-BBsL5NFx.js";
|
|
2
|
+
import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-DLQazToO.js";
|
|
3
|
+
import { _ as SectionRegistry, d as SectionOf, g as ContentModel, gt as SiteOf, ht as SiteDefinition, n as PageRules, t as Page, w as ContentMigrator } from "./page-D1pdneYm.js";
|
|
4
4
|
import { AstroIntegration } from "astro";
|
|
5
5
|
//#region src/store.d.ts
|
|
6
6
|
interface FileStoreOptions {
|
|
@@ -68,6 +68,11 @@ interface BearminionOptions extends ContentModel {
|
|
|
68
68
|
* Off by default. It never pushes, and it does nothing outside a git work tree.
|
|
69
69
|
*/
|
|
70
70
|
git?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Existing Astro content collections (Markdown with frontmatter) the editor can edit, by id:
|
|
73
|
+
* `{ blog: collection({ schema, path: 'src/content/blog/{slug}.md' }) }`. Pages and sections are independent of them.
|
|
74
|
+
*/
|
|
75
|
+
collections?: Record<string, CollectionOptions>;
|
|
71
76
|
/**
|
|
72
77
|
* Where content and uploads are read and written. Default: the local project, using `contentDir` and `uploadsDir`.
|
|
73
78
|
* A custom store replaces those two folders for the editor API; undo history, the live-reload watcher and
|
|
@@ -115,4 +120,21 @@ export declare function loadSite<TDefinition extends SiteDefinition>(contentDir:
|
|
|
115
120
|
*/
|
|
116
121
|
export declare function loadPages<TRegistry extends SectionRegistry>(contentDir: string, registry: TRegistry, { migrator, tolerateOrphans }?: LoadOptions): Page<SectionOf<TRegistry>>[];
|
|
117
122
|
//#endregion
|
|
118
|
-
|
|
123
|
+
//#region src/hosted-integration.d.ts
|
|
124
|
+
interface HostedEditorIntegrationOptions {
|
|
125
|
+
/**
|
|
126
|
+
* The site's editor module, relative to the project root. Its default export is a `HostedEditor` from
|
|
127
|
+
* `createHostedEditor`, or a function `(context) => HostedEditor` for hosts that hand over secrets per request.
|
|
128
|
+
*/
|
|
129
|
+
module: string;
|
|
130
|
+
/** `required` (default): the whole deployment is the editor, so visitors are sent to sign in. See `createHostedMiddleware`. */
|
|
131
|
+
signIn?: 'required' | 'optional';
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Turns an Astro project into the hosted editor: server rendering, the sign-in middleware, and pages that draw from the
|
|
135
|
+
* repository's current content (`Astro.locals.bearminion`). Add it to the editor deployment's build only: the public
|
|
136
|
+
* static site must not use it. Needs an adapter (`@astrojs/cloudflare`, `@astrojs/vercel`, …).
|
|
137
|
+
*/
|
|
138
|
+
export declare function bearminionHostedEditor(options: HostedEditorIntegrationOptions): AstroIntegration;
|
|
139
|
+
//#endregion
|
|
140
|
+
export { type BearminionIntegration, type BearminionOptions, type ContentStore, type EditorContext, type FileStoreOptions, type GithubStoreOptions, type HostedEditorIntegrationOptions, type LoadOptions, type LoadedContent, StoreError, StoreKeyError, type StoreOperation, type UploadStore, bearminion as default, githubStore };
|
package/dist/astro.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as ContentReadError, O as ContentValidationError, S as loadThemePreview, _ as parseKey, b as PreviewUnavailableError, c as resolveCollections, v as StoreError, y as StoreKeyError } from "./collections-BbL4_4jt.js";
|
|
2
2
|
import { t as defaultTheme } from "./theme-BvqJ8UnS.js";
|
|
3
3
|
import { a as resolvePageRules, n as createPageSchema, r as createTolerantPageSchema } from "./page-wlcQJAA-.js";
|
|
4
4
|
import { a as DEFAULT_UPLOADS_DIR, i as DEFAULT_CONTENT_DIR, n as createMigrator, o as DEFAULT_VIDEOS_DIR, t as SCHEMA_VERSION_KEY } from "./migrate-b408EaLp.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { i as resolveMaxImageBytes, n as formatBytes, r as resolveConvert } from "./upload-rules-Cao9uY5K.js";
|
|
6
|
+
import { n as isLocalRequest, t as JSON_BODY_LIMIT } from "./request-guards-BcSUj8Gc.js";
|
|
7
7
|
import { i as resolveInside, n as isInside, r as resolveDir, t as asDirectory } from "./security-CBiOYdVE.js";
|
|
8
8
|
import { a as resolveFormsConfig, n as formFile, r as formsAreLive, t as createFormsMiddleware } from "./forms-dev-CzUHR7oS.js";
|
|
9
|
+
import { a as COMMIT_MESSAGE_LIMIT, c as IMAGE_EXTENSION, f as videoBodyLimit, i as isHistoryId, l as uploadStem, n as handleEditorRequest, o as GitError, r as historyId, s as imageBodyLimit, t as githubStore, u as stableStringify } from "./github-store-DUf07ODw.js";
|
|
10
|
+
import { S as isAssetPath } from "./draft-store-DBEfw_Gq.js";
|
|
9
11
|
import { n as contentReloadPlugin, r as dropEarlyReloadAfterSave } from "./reload-BzVw721A.js";
|
|
10
12
|
import { i as syncSections, r as staleSectionsMessage } from "./sections-manifest-CO9QfJPG.js";
|
|
11
13
|
import fs from "node:fs";
|
|
@@ -16,8 +18,8 @@ import { randomBytes } from "node:crypto";
|
|
|
16
18
|
import { access, mkdir, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
17
19
|
import { execFile } from "node:child_process";
|
|
18
20
|
//#region src/editor-client.ts
|
|
19
|
-
const VIRTUAL_ID = "virtual:bearminion-editor";
|
|
20
|
-
const RESOLVED_ID = `\0${VIRTUAL_ID}`;
|
|
21
|
+
const VIRTUAL_ID$1 = "virtual:bearminion-editor";
|
|
22
|
+
const RESOLVED_ID$1 = `\0${VIRTUAL_ID$1}`;
|
|
21
23
|
/**
|
|
22
24
|
* Serves the editor overlay only while Vite is in serve mode.
|
|
23
25
|
* `astro build` never adds this plugin, so the client is absent from production.
|
|
@@ -29,10 +31,10 @@ function editorClientPlugin() {
|
|
|
29
31
|
name: "bearminion-editor-client",
|
|
30
32
|
apply: "serve",
|
|
31
33
|
resolveId(id) {
|
|
32
|
-
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
34
|
+
if (id === VIRTUAL_ID$1) return RESOLVED_ID$1;
|
|
33
35
|
},
|
|
34
36
|
load(id) {
|
|
35
|
-
if (id !== RESOLVED_ID) return void 0;
|
|
37
|
+
if (id !== RESOLVED_ID$1) return void 0;
|
|
36
38
|
return `import { mountEditor } from ${JSON.stringify(entry)};\nmountEditor();\n`;
|
|
37
39
|
}
|
|
38
40
|
};
|
|
@@ -225,9 +227,8 @@ function isErrno$2(error) {
|
|
|
225
227
|
/** The content store for a local project: content as JSON files, uploads in a folder. */
|
|
226
228
|
function createFileStore({ root, contentDir, uploadsDir, videosDir }) {
|
|
227
229
|
function resolve(key) {
|
|
228
|
-
const parts = key
|
|
229
|
-
|
|
230
|
-
const resolved = resolveInside(contentDir, ...parts);
|
|
230
|
+
const { base, parts } = parseKey(key);
|
|
231
|
+
const resolved = resolveInside(base === "root" ? root : contentDir, ...parts);
|
|
231
232
|
if (resolved === null) throw new StoreKeyError(key);
|
|
232
233
|
return resolved;
|
|
233
234
|
}
|
|
@@ -547,6 +548,7 @@ function resolveEditorContext(options, rootInput) {
|
|
|
547
548
|
git: options?.git === true,
|
|
548
549
|
formsDir: resolveFormsConfig(options?.forms, root)?.dir ?? null
|
|
549
550
|
};
|
|
551
|
+
if (options.collections) context.collections = resolveCollections(options.collections);
|
|
550
552
|
context.history = fileHistory(context);
|
|
551
553
|
context.commits = fileGit(context);
|
|
552
554
|
const formsDir = context.formsDir;
|
|
@@ -956,6 +958,42 @@ function isErrno(error) {
|
|
|
956
958
|
return error instanceof Error && "code" in error;
|
|
957
959
|
}
|
|
958
960
|
//#endregion
|
|
961
|
+
//#region src/hosted-integration.ts
|
|
962
|
+
const VIRTUAL_ID = "virtual:bearminion/editor";
|
|
963
|
+
const RESOLVED_ID = `\0${VIRTUAL_ID}`;
|
|
964
|
+
/**
|
|
965
|
+
* Turns an Astro project into the hosted editor: server rendering, the sign-in middleware, and pages that draw from the
|
|
966
|
+
* repository's current content (`Astro.locals.bearminion`). Add it to the editor deployment's build only: the public
|
|
967
|
+
* static site must not use it. Needs an adapter (`@astrojs/cloudflare`, `@astrojs/vercel`, …).
|
|
968
|
+
*/
|
|
969
|
+
function bearminionHostedEditor(options) {
|
|
970
|
+
const signIn = options.signIn ?? "required";
|
|
971
|
+
if (signIn !== "required" && signIn !== "optional") throw new Error(`signIn must be "required" or "optional", got ${String(signIn)}.`);
|
|
972
|
+
if (!options.module) throw new Error("bearminionHostedEditor needs `module`: the file that exports your hosted editor.");
|
|
973
|
+
return {
|
|
974
|
+
name: "bearminion:hosted-editor",
|
|
975
|
+
hooks: { "astro:config:setup"({ config, updateConfig, addMiddleware }) {
|
|
976
|
+
if (!config.adapter) throw new Error("bearminionHostedEditor renders on a server, so the project needs an adapter (for example @astrojs/cloudflare or @astrojs/vercel). Add it to the editor build only.");
|
|
977
|
+
const editorModule = path.resolve(fileURLToPath(config.root), options.module);
|
|
978
|
+
updateConfig({
|
|
979
|
+
...config.output === "static" ? { output: "server" } : {},
|
|
980
|
+
vite: {
|
|
981
|
+
ssr: { noExternal: ["bearminion", config.adapter.name] },
|
|
982
|
+
plugins: [{
|
|
983
|
+
name: "bearminion:hosted-editor-module",
|
|
984
|
+
resolveId: (id) => id === VIRTUAL_ID ? RESOLVED_ID : null,
|
|
985
|
+
load: (id) => id === RESOLVED_ID ? `export { default as editor } from ${JSON.stringify(editorModule)}\nexport const signIn = ${JSON.stringify(signIn)}\n` : null
|
|
986
|
+
}]
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
addMiddleware({
|
|
990
|
+
entrypoint: "bearminion/hosted-astro",
|
|
991
|
+
order: "pre"
|
|
992
|
+
});
|
|
993
|
+
} }
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
//#endregion
|
|
959
997
|
//#region src/astro.ts
|
|
960
998
|
/**
|
|
961
999
|
* `bearminion/astro`: the server side. The dev-only Astro integration, the content store it writes through, and the
|
|
@@ -967,4 +1005,4 @@ function isErrno(error) {
|
|
|
967
1005
|
*/
|
|
968
1006
|
var astro_default = bearminion;
|
|
969
1007
|
//#endregion
|
|
970
|
-
export { StoreError, StoreKeyError, bearminion, createFileStore, astro_default as default, githubStore, loadContent, loadPages, loadSite };
|
|
1008
|
+
export { StoreError, StoreKeyError, bearminion, bearminionHostedEditor, createFileStore, astro_default as default, githubStore, loadContent, loadPages, loadSite };
|