bearminion 1.14.0 → 1.15.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # bearminion
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e8285c6: Add `bearminion/hosted` (experimental): the editor API without Node, for a Worker or a serverless function, with `createHostedContext`, `handleHostedRequest` and `githubStore`. The editor API itself no longer imports Node modules: undo history, Commit changes and the form-handler lookup are now optional capabilities of the editor context, which the local dev editor fills in as before.
8
+
3
9
  ## 1.14.0
4
10
 
5
11
  ### Minor Changes
package/dist/astro.d.ts CHANGED
@@ -1,20 +1,79 @@
1
- import { A as ContentModel, X as SiteOf, Xt as ContentMigrator, Y as SiteDefinition, d as SectionOf, j as SectionRegistry, t as Page } from "./page-CwbIDegI.js";
2
- import { a as StoreOperation, i as FileStoreOptions, n as EditorContext, o as UploadStore, r as ContentStore, s as createFileStore, t as BearminionOptions } from "./options-CosfIOMs.js";
1
+ import { A as ContentModel, X as SiteOf, Y as SiteDefinition, d as SectionOf, j as SectionRegistry, n as PageRules, t as Page, wt as ContentMigrator } from "./page-FipdIFb5.js";
2
+ import { _ as ContentStore, n as ImageConvertOptions, t as EditorContext, v as StoreOperation, y as UploadStore } from "./editor-context-CTfxXtny.js";
3
+ import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-BT9uiq5W.js";
3
4
  import { AstroIntegration } from "astro";
4
- //#region src/store-error.d.ts
5
- /** A key that is empty, absolute or leaves the content directory. */
6
- export declare class StoreKeyError extends Error {
7
- constructor(key: string);
5
+ //#region src/store.d.ts
6
+ interface FileStoreOptions {
7
+ /** Project root. Upload paths are relative to it. */
8
+ root: string;
9
+ contentDir: string;
10
+ uploadsDir: string;
11
+ /** Where uploaded videos go. Without it the store takes no video uploads. */
12
+ videosDir?: string;
8
13
  }
9
- /**
10
- * A store that could not do what was asked, for a reason the person editing can act on (a refused token, a protected
11
- * branch, a branch that moved). The editor API answers it with `status` and `code`, so the message reaches the page
12
- * instead of becoming a bare 500.
13
- */
14
- export declare class StoreError extends Error {
15
- readonly status: number;
16
- readonly code: string;
17
- constructor(status: number, code: string, message: string);
14
+ /** The content store for a local project: content as JSON files, uploads in a folder. */
15
+ export declare function createFileStore({ root, contentDir, uploadsDir, videosDir }: FileStoreOptions): ContentStore;
16
+ //#endregion
17
+ //#region src/options.d.ts
18
+ interface BearminionOptions extends ContentModel {
19
+ /** Directory that contains `site.json` and `pages/`. Default `content`. */
20
+ contentDir?: string;
21
+ /** Directory for uploaded images. Default `src/assets/uploads`. */
22
+ uploadsDir?: string;
23
+ /** Directory for uploaded videos. It must be inside `public/`, which serves them as they are. Default `public/videos`. */
24
+ videosDir?: string;
25
+ /** Largest video the editor accepts, in bytes. Default 50 MB. */
26
+ maxVideoBytes?: number;
27
+ /**
28
+ * Largest image the editor accepts, in bytes. Default 5 MB. The editor checks it in the browser before it uploads,
29
+ * and the server checks it again.
30
+ */
31
+ maxImageBytes?: number;
32
+ /**
33
+ * Re-encode images in the browser before they are uploaded, so phone photos stay out of the repository:
34
+ * `{ to: 'webp', maxWidth: 2400, quality: 0.82 }`. Animated GIFs are never converted, and an image that would come
35
+ * out larger is kept as it is. Default: off, images are uploaded as they are.
36
+ */
37
+ imageConvert?: false | ImageConvertOptions;
38
+ /**
39
+ * Which page operations the editor allows: `{ rename: false, delete: false }` for a site whose addresses must not
40
+ * change (they carry search ranking or are the target of redirects). Both default to true. A locked operation is
41
+ * refused by the API as well as hidden in the editor. `rename: false` also blocks making another page the home page,
42
+ * because that moves the old home page to a new address.
43
+ */
44
+ pages?: Partial<PageRules>;
45
+ /**
46
+ * Vite module id loaded by the dev server to render a draft page.
47
+ * Default `/src/lib/render-preview.ts`. Preview never writes to disk.
48
+ */
49
+ previewModule?: string;
50
+ /**
51
+ * The folder that holds the section directories and the files `bearminion sync` generates from them, relative to the
52
+ * project root. When set, `astro build`, `astro check` and `astro sync` stop if those files are stale, and
53
+ * `astro dev` warns. Default: not checked.
54
+ */
55
+ sectionsDir?: string;
56
+ /**
57
+ * The dev route for the forms in your site. A file `src/forms/contact.ts` that default-exports `defineForm(...)`
58
+ * answers at `/api/contact` during `astro dev`, as a dry run unless `BEARMINION_FORMS_LIVE=on`. `dir` is the folder
59
+ * (default `src/forms`) and `prefix` the path (default `/api`). `false` turns the route off, for a site whose
60
+ * Astro adapter serves the endpoint itself.
61
+ */
62
+ forms?: false | {
63
+ dir?: string;
64
+ prefix?: string;
65
+ };
66
+ /**
67
+ * Show Commit changes in the editor, which commits the changed content and uploads to the local git repository.
68
+ * Off by default. It never pushes, and it does nothing outside a git work tree.
69
+ */
70
+ git?: boolean;
71
+ /**
72
+ * Where content and uploads are read and written. Default: the local project, using `contentDir` and `uploadsDir`.
73
+ * A custom store replaces those two folders for the editor API; undo history, the live-reload watcher and
74
+ * `git` still work on the local project.
75
+ */
76
+ store?: ContentStore;
18
77
  }
19
78
  //#endregion
20
79
  //#region src/integration.d.ts
@@ -28,52 +87,6 @@ interface BearminionIntegration extends AstroIntegration {
28
87
  */
29
88
  export declare function bearminion(options: BearminionOptions): BearminionIntegration;
30
89
  //#endregion
31
- //#region src/github-store.d.ts
32
- interface GithubStoreOptions {
33
- /** `owner/name`. */
34
- repo: string;
35
- /**
36
- * A token that may write to the repository: a fine-grained personal access token with "Contents: Read and write" on
37
- * this one repository. Keep it in the environment, never in a file the repository tracks.
38
- */
39
- token: string;
40
- /** The branch edits are committed to. Default: the repository's default branch. */
41
- branch?: string;
42
- /** The folder of the site inside the repository. Default: the repository root. */
43
- rootDir?: string;
44
- /** The content folder, relative to `rootDir`. Default `content`. */
45
- contentDir?: string;
46
- /** The folder uploaded images go to, relative to `rootDir`. Default `src/assets/uploads`. */
47
- uploadsDir?: string;
48
- /** The commit message for a change. Default: `Update pages/about.json`, `Update 3 files`, `Upload photo-1a2b3c4d.jpg`. */
49
- message?: (change: {
50
- written: readonly string[];
51
- removed: readonly string[];
52
- }) => string;
53
- /**
54
- * `direct` (default): a save is a commit on `branch`. `pr`: a save is a commit on a branch of its own for the entry
55
- * being edited, with a pull request opened on the first save. Nothing here ever merges. Needs "Pull requests: Read
56
- * and write" besides "Contents: Read and write".
57
- */
58
- mode?: 'direct' | 'pr';
59
- /** `pr` mode: the title and body of the pull request opened for an entry. */
60
- pullRequest?: (change: {
61
- scope: string;
62
- written: readonly string[];
63
- removed: readonly string[];
64
- }) => {
65
- title: string;
66
- body: string;
67
- };
68
- /** `pr` mode: the label put on the pull requests. Default `bearminion`; `false` for none. */
69
- label?: string | false;
70
- /** The GitHub API. Default `https://api.github.com`. Set it for GitHub Enterprise. */
71
- apiUrl?: string;
72
- /** Default: the global `fetch`. */
73
- fetch?: typeof fetch;
74
- }
75
- export declare function githubStore(options: GithubStoreOptions): ContentStore;
76
- //#endregion
77
90
  //#region src/load.d.ts
78
91
  interface LoadOptions {
79
92
  /** Upgrades files written under an older `schemaVersion`. `loadContent` builds it from the model. */
@@ -102,4 +115,4 @@ export declare function loadSite<TDefinition extends SiteDefinition>(contentDir:
102
115
  */
103
116
  export declare function loadPages<TRegistry extends SectionRegistry>(contentDir: string, registry: TRegistry, { migrator, tolerateOrphans }?: LoadOptions): Page<SectionOf<TRegistry>>[];
104
117
  //#endregion
105
- export { type BearminionIntegration, type BearminionOptions, type ContentStore, type EditorContext, type FileStoreOptions, type GithubStoreOptions, type LoadOptions, type LoadedContent, type StoreOperation, type UploadStore, bearminion as default, createFileStore };
118
+ export { type BearminionIntegration, type BearminionOptions, type ContentStore, type EditorContext, type FileStoreOptions, type GithubStoreOptions, type LoadOptions, type LoadedContent, StoreError, StoreKeyError, type StoreOperation, type UploadStore, bearminion as default, githubStore };