bearminion 1.13.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 +12 -0
- package/dist/astro.d.ts +75 -45
- package/dist/astro.js +106 -1553
- package/dist/cli.js +1 -1
- package/dist/content.d.ts +1 -1
- package/dist/content.js +1 -1
- package/dist/{draft-store-1Y4-sn45.js → draft-store-BaZYEe56.js} +45 -1
- package/dist/editor-context-CTfxXtny.d.ts +272 -0
- package/dist/{forms-dev-CEab55ss.js → forms-dev-CzUHR7oS.js} +1 -1
- package/dist/github-store-BT9uiq5W.d.ts +64 -0
- package/dist/github-store-D0bQOwdt.js +1755 -0
- package/dist/hosted.d.ts +45 -0
- package/dist/hosted.js +37 -0
- package/dist/index.d.ts +2 -103
- package/dist/{page-CwbIDegI.d.ts → page-FipdIFb5.d.ts} +37 -37
- package/dist/{reload-BIIa7pej.js → reload-BzVw721A.js} +1 -1
- package/dist/security-CBiOYdVE.js +24 -0
- package/dist/ui/mount.js +1 -2
- package/package.json +5 -1
- package/registry/default/registry.json +1 -1
- package/dist/options-DP6mTauQ.d.ts +0 -205
- package/dist/security-FLvgc2jD.js +0 -93
- package/dist/upload-rules-Cao9uY5K.js +0 -36
package/dist/hosted.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { A as ContentModel, n as PageRules } from "./page-FipdIFb5.js";
|
|
2
|
+
import { _ as ContentStore, n as ImageConvertOptions, t as EditorContext } from "./editor-context-CTfxXtny.js";
|
|
3
|
+
import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-BT9uiq5W.js";
|
|
4
|
+
//#region src/api.d.ts
|
|
5
|
+
interface HandleMeta {
|
|
6
|
+
/**
|
|
7
|
+
* Hosted editor only. The caller has already signed the person in and checked that they may edit, so the localhost
|
|
8
|
+
* check is replaced by a same-origin check. Never set it on a route that has no sign-in in front of it: with it,
|
|
9
|
+
* anyone who can reach the handler can write the content.
|
|
10
|
+
*/
|
|
11
|
+
authenticated?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* TCP peer address. Pass it from the dev server.
|
|
14
|
+
* When it is omitted, only Host and Origin are checked.
|
|
15
|
+
*/
|
|
16
|
+
remoteAddress?: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Dev-only. Renders draft JSON to HTML without writing it.
|
|
19
|
+
* Omit it outside `astro dev`.
|
|
20
|
+
*/
|
|
21
|
+
renderPreview?: (page: unknown, motion: boolean) => Promise<string>;
|
|
22
|
+
/** Dev-only. Renders the header and footer of a draft site. Optional: a project without it keeps reload-to-see. */
|
|
23
|
+
renderSitePreview?: (site: unknown, pathname: string) => Promise<{
|
|
24
|
+
header: string;
|
|
25
|
+
footer: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/hosted.d.ts
|
|
30
|
+
export interface HostedEditorOptions extends ContentModel {
|
|
31
|
+
/** Where content lives, such as `githubStore({ ... })`. */
|
|
32
|
+
store: ContentStore;
|
|
33
|
+
/** Largest image accepted, in bytes. Default 5 MB. */
|
|
34
|
+
maxImageBytes?: number;
|
|
35
|
+
/** Re-encode images in the browser before upload. Default: off. */
|
|
36
|
+
imageConvert?: false | ImageConvertOptions;
|
|
37
|
+
/** Which page operations are allowed. */
|
|
38
|
+
pages?: Partial<PageRules>;
|
|
39
|
+
}
|
|
40
|
+
/** The context for `handleEditorRequest`. */
|
|
41
|
+
export declare function createHostedContext(options: HostedEditorOptions): EditorContext;
|
|
42
|
+
/** Handle one editor API request. Returns `null` for a path that is not the editor API. Sign the person in first. */
|
|
43
|
+
export declare function handleHostedRequest(request: Request, context: EditorContext, meta?: Omit<HandleMeta, 'authenticated'>): Promise<Response | null>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { type ContentStore, type EditorContext, type GithubStoreOptions, StoreError, StoreKeyError, githubStore };
|
package/dist/hosted.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { t as defaultTheme } from "./theme-BvqJ8UnS.js";
|
|
2
|
+
import { a as resolvePageRules } from "./page-wlcQJAA-.js";
|
|
3
|
+
import { n as createMigrator } from "./migrate-b408EaLp.js";
|
|
4
|
+
import { D as resolveMaxImageBytes, E as resolveConvert } from "./draft-store-BaZYEe56.js";
|
|
5
|
+
import { c as StoreKeyError, n as handleEditorRequest, p as DEFAULT_VIDEO_BYTE_LIMIT, s as StoreError, t as githubStore } from "./github-store-D0bQOwdt.js";
|
|
6
|
+
//#region src/hosted.ts
|
|
7
|
+
/** The context for `handleEditorRequest`. */
|
|
8
|
+
function createHostedContext(options) {
|
|
9
|
+
if (!options.sections) throw new Error("createHostedContext() needs the `sections` option: the site's section definitions.");
|
|
10
|
+
if (!options.site) throw new Error("createHostedContext() needs the `site` option: the site definition from defineSite().");
|
|
11
|
+
if (!options.store) throw new Error("createHostedContext() needs the `store` option, such as githubStore({ ... }).");
|
|
12
|
+
return {
|
|
13
|
+
root: "",
|
|
14
|
+
contentDir: "",
|
|
15
|
+
uploadsDir: "",
|
|
16
|
+
videosDir: "",
|
|
17
|
+
maxVideoBytes: DEFAULT_VIDEO_BYTE_LIMIT,
|
|
18
|
+
maxImageBytes: resolveMaxImageBytes(options.maxImageBytes),
|
|
19
|
+
pageRules: resolvePageRules(options.pages),
|
|
20
|
+
imageConvert: resolveConvert(options.imageConvert),
|
|
21
|
+
sections: options.sections,
|
|
22
|
+
site: options.site,
|
|
23
|
+
theme: options.theme ?? defaultTheme,
|
|
24
|
+
store: options.store,
|
|
25
|
+
migrator: createMigrator(options),
|
|
26
|
+
git: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Handle one editor API request. Returns `null` for a path that is not the editor API. Sign the person in first. */
|
|
30
|
+
function handleHostedRequest(request, context, meta = {}) {
|
|
31
|
+
return handleEditorRequest(request, context, {
|
|
32
|
+
...meta,
|
|
33
|
+
authenticated: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { StoreError, StoreKeyError, createHostedContext, githubStore, handleHostedRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as Theme, $t as
|
|
1
|
+
import { $ as Theme, $t as ShowCondition, A as ContentModel, At as SectionDefinition, B as Footer, Bt as CountRule, C as jsonLdSchema, Ct as ContentMigration, D as siteJsonLdIds, Dt as SCHEMA_VERSION_KEY, E as parseJsonLdInput, Et as DocumentKind, F as defaultTheme, Ft as defineWireframe, G as Site, Gt as buttonStyles, H as FooterConfig, Ht as NumberOption, I as defineTheme, It as wireKinds, J as SiteConsent, Jt as toneOption, K as SiteAnalytics, Kt as motionOption, L as BRAND_LOGO_HEIGHT, Lt as wireframeIssues, M as ThemeConfig, Mt as WireKind, N as ThemeDefinition, Nt as WireRect, O as upsertJsonLd, Ot as createMigrator, P as ThemeFont, Pt as Wireframe, Q as SiteWith, Qt as FieldIcons, R as DEFAULT_MAX_FOOTER_COLUMNS, Rt as OptionalContent, S as isPlaceholderSiteUrl, St as withEmphasis, T as mergeJsonLd, Tt as ContentVersioning, U as Header, Ut as Option, V as FooterColumn, Vt as EnumOption, W as HeaderConfig, Wt as StringOption, X as SiteOf, Xt as variantOption, Y as SiteDefinition, Yt as tones, Z as SiteSeo, Zt as FieldChoices, _ as SiteJsonLdIds, _t as richTextSchema, a as createPageSchema, at as themeColorsSchema, b as generateSiteJsonLd, bt as toneSchema, c as withoutOrphanSections, ct as Image, d as SectionOf, dt as RichText, en as ShowWhen, et as brandLogoSchema, f as anchorSchema, ft as Text, g as JsonLdResult, gt as linkSchema, h as JsonLdBlock, ht as imageSchema, i as Seo, it as siteSeoSchema, j as SectionRegistry, jt as defineSection, k as API_PREFIX, kt as SectionConfig, l as BaseSection, lt as Link, m as sectionIdSchema, mt as htmlIdSchema, nt as siteAnalyticsSchema, o as isSystemPage, ot as themeSchema, p as createSectionSchema, pt as Tone, q as SiteConfig, qt as themeModes, r as SYSTEM_PAGES, rt as siteConsentSchema, s as seoSchema, st as ButtonStyle, t as Page, tt as defineSite, u as PropsOf, ut as MAX_NAV_DEPTH, v as SiteJsonLdSource, vt as textMarkSchema, w as jsonLdWarnings, wt as ContentMigrator, x as hasJsonLdId, xt as trackingIdSchema, y as formatJsonLd, yt as textSchema, z as DEFAULT_MAX_HEADER_ACTIONS, zt as BooleanOption } from "./page-FipdIFb5.js";
|
|
2
2
|
import { _ as renderMarkedHtml, a as WeightMark, f as markClass, g as reconcileMarks, i as TextRun, l as fontMarks, m as marksFromEmphasis, o as applyTextMark, r as TextMark, t as FontMark, v as splitMarkedText, y as weightMarks } from "./marks-BzLa48Y9.js";
|
|
3
|
-
import "./
|
|
3
|
+
import { a as CommitRequest, c as HistoryEntry, d as SaveResponse, f as SitePreview, g as GitInfo, h as ChangedFile, i as ApiProblem, l as PageListItem, m as UploadedVideo, o as CommitResult, p as UploadedImage, r as ApiIssue, s as CreatePageRequest, u as SaveRequest } from "./editor-context-CTfxXtny.js";
|
|
4
4
|
import { a as TURNSTILE_FIELD, i as HONEYPOT_FIELD, n as FormResult, r as FormSubmission, t as FormFieldErrors } from "./form-contract-BURSJP3Y.js";
|
|
5
5
|
//#region src/errors.d.ts
|
|
6
6
|
/** One schema problem, addressed by a dot path such as `sections.0.props.heading`. */
|
|
@@ -94,107 +94,6 @@ type MediaSource = {
|
|
|
94
94
|
export declare const VIDEO_FILE: RegExp;
|
|
95
95
|
export declare function parseMediaSource(value: string): MediaSource | null;
|
|
96
96
|
//#endregion
|
|
97
|
-
//#region src/git.d.ts
|
|
98
|
-
type ChangeStatus = 'added' | 'modified' | 'deleted' | 'renamed' | 'untracked';
|
|
99
|
-
interface ChangedFile {
|
|
100
|
-
/** Path relative to the project root, with `/` separators. */
|
|
101
|
-
path: string;
|
|
102
|
-
status: ChangeStatus;
|
|
103
|
-
}
|
|
104
|
-
interface GitInfo {
|
|
105
|
-
/** The `git` option is on. */
|
|
106
|
-
enabled: boolean;
|
|
107
|
-
/** The project is inside a git work tree. */
|
|
108
|
-
repo: boolean;
|
|
109
|
-
branch?: string;
|
|
110
|
-
files: ChangedFile[];
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/api-types.d.ts
|
|
114
|
-
/**
|
|
115
|
-
* Request and response bodies of the dev editor API (`/__bearminion/api`). The server handlers and the
|
|
116
|
-
* overlay's client both use these, so a changed shape is a type error on both sides.
|
|
117
|
-
*/
|
|
118
|
-
/** Every error response. `issues` is present on schema validation failures. */
|
|
119
|
-
interface ApiProblem {
|
|
120
|
-
error: string;
|
|
121
|
-
message: string;
|
|
122
|
-
issues?: ApiIssue[];
|
|
123
|
-
}
|
|
124
|
-
/** One validation failure: a dotted path into the document and a message. */
|
|
125
|
-
interface ApiIssue {
|
|
126
|
-
path: string;
|
|
127
|
-
message: string;
|
|
128
|
-
/** Present on `POST /save`, which validates the page and the site together. */
|
|
129
|
-
file?: 'page' | 'site';
|
|
130
|
-
}
|
|
131
|
-
/** `GET /pages`. */
|
|
132
|
-
interface PageListItem {
|
|
133
|
-
slug: string;
|
|
134
|
-
title: string;
|
|
135
|
-
/** File name inside the pages directory. */
|
|
136
|
-
file: string;
|
|
137
|
-
system?: boolean;
|
|
138
|
-
anchors?: string[];
|
|
139
|
-
}
|
|
140
|
-
/** `GET /images` entries and the body of a successful `POST /images`. */
|
|
141
|
-
interface UploadedImage {
|
|
142
|
-
filename: string;
|
|
143
|
-
/** Project-relative path, the value image fields store. */
|
|
144
|
-
path: string;
|
|
145
|
-
bytes?: number;
|
|
146
|
-
}
|
|
147
|
-
/** `GET /videos` entries and the body of a successful `POST /videos`. */
|
|
148
|
-
interface UploadedVideo {
|
|
149
|
-
filename: string;
|
|
150
|
-
/** Project-relative path of the file. */
|
|
151
|
-
path: string;
|
|
152
|
-
/** What a Media section's `video` field holds, such as `/videos/demo-1a2b3c4d.mp4`. */
|
|
153
|
-
url: string;
|
|
154
|
-
bytes?: number;
|
|
155
|
-
}
|
|
156
|
-
/** `GET /history/site` and `GET /history/pages/:slug` entries. */
|
|
157
|
-
interface HistoryEntry {
|
|
158
|
-
id: string;
|
|
159
|
-
at: string;
|
|
160
|
-
}
|
|
161
|
-
/** `POST /save`. At least one of `page` and `site`. */
|
|
162
|
-
interface SaveRequest<TPage = unknown, TSite = unknown> {
|
|
163
|
-
page?: {
|
|
164
|
-
/** Slug the page is stored under now. When `document.slug` differs, the page is renamed (or made home). */
|
|
165
|
-
from: string;
|
|
166
|
-
document: TPage;
|
|
167
|
-
/** Where the current home page moves when this page becomes `index`. Required when a home page exists. */
|
|
168
|
-
previousHomeSlug?: string;
|
|
169
|
-
};
|
|
170
|
-
site?: TSite;
|
|
171
|
-
}
|
|
172
|
-
/** `POST /save` response: the documents as stored. */
|
|
173
|
-
interface SaveResponse<TPage = unknown, TSite = unknown> {
|
|
174
|
-
page?: TPage;
|
|
175
|
-
site?: TSite;
|
|
176
|
-
}
|
|
177
|
-
/** `POST /pages`. `template` is a section type or the slug of a page to copy. */
|
|
178
|
-
interface CreatePageRequest {
|
|
179
|
-
slug: string;
|
|
180
|
-
title: string;
|
|
181
|
-
template?: string;
|
|
182
|
-
}
|
|
183
|
-
/** `POST /git/commit`. */
|
|
184
|
-
interface CommitRequest {
|
|
185
|
-
message: string;
|
|
186
|
-
paths?: string[];
|
|
187
|
-
}
|
|
188
|
-
interface CommitResult {
|
|
189
|
-
commit: string;
|
|
190
|
-
files: number;
|
|
191
|
-
}
|
|
192
|
-
/** `POST /preview/site`. */
|
|
193
|
-
interface SitePreview {
|
|
194
|
-
header: string;
|
|
195
|
-
footer: string;
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
97
|
//#region src/consent.d.ts
|
|
199
98
|
/** Longest copy the consent banner takes, in characters. The editor shows the same limits. */
|
|
200
99
|
export declare const CONSENT_LIMITS: {
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
import { r as TextMark, t as FontMark } from "./marks-BzLa48Y9.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
//#region src/migrate.d.ts
|
|
4
|
-
/** Which kind of document a migration is upgrading. */
|
|
5
|
-
type DocumentKind = 'page' | 'site';
|
|
6
|
-
/** Upgrades one document from version N to N + 1. Return the new document; do not mutate the input. */
|
|
7
|
-
type ContentMigration = (document: Record<string, unknown>, kind: DocumentKind) => Record<string, unknown>;
|
|
8
|
-
/** How a site versions its content files. */
|
|
9
|
-
interface ContentVersioning {
|
|
10
|
-
/**
|
|
11
|
-
* The content format version this site's schemas describe. Default 1. Raise it when a schema change
|
|
12
|
-
* would reject files written before it, and add the migration that upgrades them.
|
|
13
|
-
*/
|
|
14
|
-
schemaVersion?: number;
|
|
15
|
-
/** `migrations[n]` upgrades a document from version `n` to `n + 1`. Needed for every `n` below `schemaVersion`. */
|
|
16
|
-
migrations?: Readonly<Record<number, ContentMigration>>;
|
|
17
|
-
}
|
|
18
|
-
/** The key that stores a document's version. It is stripped on read and stamped on write; schemas never see it. */
|
|
19
|
-
declare const SCHEMA_VERSION_KEY = "schemaVersion";
|
|
20
|
-
type UpgradeResult = {
|
|
21
|
-
ok: true;
|
|
22
|
-
value: unknown;
|
|
23
|
-
} | {
|
|
24
|
-
ok: false;
|
|
25
|
-
message: string;
|
|
26
|
-
};
|
|
27
|
-
interface ContentMigrator {
|
|
28
|
-
/** The version this site writes. */
|
|
29
|
-
readonly version: number;
|
|
30
|
-
/** Upgrade a parsed file to the current version and remove its version key. Non-objects pass through for the schema to reject. */
|
|
31
|
-
upgrade(raw: unknown, kind: DocumentKind): UpgradeResult;
|
|
32
|
-
/** The document as written to disk: its version key plus the content. */
|
|
33
|
-
stamp<T extends object>(document: T): T & {
|
|
34
|
-
schemaVersion: number;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
declare function createMigrator(versioning?: ContentVersioning): ContentMigrator;
|
|
38
|
-
//#endregion
|
|
39
3
|
//#region src/field-rules.d.ts
|
|
40
4
|
/**
|
|
41
5
|
* Field rules a section declares beside its schema, in a form the editor overlay can read without zod.
|
|
@@ -231,6 +195,42 @@ interface SectionConfig<TType extends string, TSchema extends z.ZodType, TVarian
|
|
|
231
195
|
}
|
|
232
196
|
declare function defineSection<const TType extends string, TSchema extends z.ZodType, const TVariants extends readonly [string, ...string[]]>(config: SectionConfig<TType, TSchema, TVariants>): SectionDefinition<TType, TSchema, TVariants[number]>;
|
|
233
197
|
//#endregion
|
|
198
|
+
//#region src/migrate.d.ts
|
|
199
|
+
/** Which kind of document a migration is upgrading. */
|
|
200
|
+
type DocumentKind = 'page' | 'site';
|
|
201
|
+
/** Upgrades one document from version N to N + 1. Return the new document; do not mutate the input. */
|
|
202
|
+
type ContentMigration = (document: Record<string, unknown>, kind: DocumentKind) => Record<string, unknown>;
|
|
203
|
+
/** How a site versions its content files. */
|
|
204
|
+
interface ContentVersioning {
|
|
205
|
+
/**
|
|
206
|
+
* The content format version this site's schemas describe. Default 1. Raise it when a schema change
|
|
207
|
+
* would reject files written before it, and add the migration that upgrades them.
|
|
208
|
+
*/
|
|
209
|
+
schemaVersion?: number;
|
|
210
|
+
/** `migrations[n]` upgrades a document from version `n` to `n + 1`. Needed for every `n` below `schemaVersion`. */
|
|
211
|
+
migrations?: Readonly<Record<number, ContentMigration>>;
|
|
212
|
+
}
|
|
213
|
+
/** The key that stores a document's version. It is stripped on read and stamped on write; schemas never see it. */
|
|
214
|
+
declare const SCHEMA_VERSION_KEY = "schemaVersion";
|
|
215
|
+
type UpgradeResult = {
|
|
216
|
+
ok: true;
|
|
217
|
+
value: unknown;
|
|
218
|
+
} | {
|
|
219
|
+
ok: false;
|
|
220
|
+
message: string;
|
|
221
|
+
};
|
|
222
|
+
interface ContentMigrator {
|
|
223
|
+
/** The version this site writes. */
|
|
224
|
+
readonly version: number;
|
|
225
|
+
/** Upgrade a parsed file to the current version and remove its version key. Non-objects pass through for the schema to reject. */
|
|
226
|
+
upgrade(raw: unknown, kind: DocumentKind): UpgradeResult;
|
|
227
|
+
/** The document as written to disk: its version key plus the content. */
|
|
228
|
+
stamp<T extends object>(document: T): T & {
|
|
229
|
+
schemaVersion: number;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
declare function createMigrator(versioning?: ContentVersioning): ContentMigrator;
|
|
233
|
+
//#endregion
|
|
234
234
|
//#region src/fields.d.ts
|
|
235
235
|
/** Non-empty plain text. */
|
|
236
236
|
declare const textSchema: z.ZodString;
|
|
@@ -1402,4 +1402,4 @@ declare function withoutOrphanSections<TPage extends {
|
|
|
1402
1402
|
sections: readonly unknown[];
|
|
1403
1403
|
}>(page: TPage, registry: SectionRegistry): TPage;
|
|
1404
1404
|
//#endregion
|
|
1405
|
-
export { Theme as $,
|
|
1405
|
+
export { Theme as $, ShowCondition as $t, ContentModel as A, SectionDefinition as At, Footer as B, CountRule as Bt, jsonLdSchema as C, ContentMigration as Ct, siteJsonLdIds as D, SCHEMA_VERSION_KEY as Dt, parseJsonLdInput as E, DocumentKind as Et, defaultTheme as F, defineWireframe as Ft, Site as G, buttonStyles as Gt, FooterConfig as H, NumberOption as Ht, defineTheme as I, wireKinds as It, SiteConsent as J, toneOption as Jt, SiteAnalytics as K, motionOption as Kt, BRAND_LOGO_HEIGHT as L, wireframeIssues as Lt, ThemeConfig as M, WireKind as Mt, ThemeDefinition as N, WireRect as Nt, upsertJsonLd as O, createMigrator as Ot, ThemeFont as P, Wireframe as Pt, SiteWith as Q, FieldIcons as Qt, DEFAULT_MAX_FOOTER_COLUMNS as R, OptionalContent as Rt, isPlaceholderSiteUrl as S, withEmphasis as St, mergeJsonLd as T, ContentVersioning as Tt, Header as U, Option as Ut, FooterColumn as V, EnumOption as Vt, HeaderConfig as W, StringOption as Wt, SiteOf as X, variantOption as Xt, SiteDefinition as Y, tones as Yt, SiteSeo as Z, FieldChoices as Zt, SiteJsonLdIds as _, richTextSchema as _t, createPageSchema as a, themeColorsSchema as at, generateSiteJsonLd as b, toneSchema as bt, withoutOrphanSections as c, Image as ct, SectionOf as d, RichText as dt, ShowWhen as en, brandLogoSchema as et, anchorSchema as f, Text as ft, JsonLdResult as g, linkSchema as gt, JsonLdBlock as h, imageSchema as ht, Seo as i, siteSeoSchema as it, SectionRegistry as j, defineSection as jt, API_PREFIX as k, SectionConfig as kt, BaseSection as l, Link as lt, sectionIdSchema as m, htmlIdSchema as mt, PageRules as n, siteAnalyticsSchema as nt, isSystemPage as o, themeSchema as ot, createSectionSchema as p, Tone as pt, SiteConfig as q, themeModes as qt, SYSTEM_PAGES as r, siteConsentSchema as rt, seoSchema as s, ButtonStyle as st, Page as t, defineSite as tt, PropsOf as u, MAX_NAV_DEPTH as ut, SiteJsonLdSource as v, textMarkSchema as vt, jsonLdWarnings as w, ContentMigrator as wt, hasJsonLdId as x, trackingIdSchema as xt, formatJsonLd as y, textSchema as yt, DEFAULT_MAX_HEADER_ACTIONS as z, BooleanOption as zt };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
//#region src/security.ts
|
|
4
|
+
function asDirectory(root) {
|
|
5
|
+
if (root instanceof URL) return fileURLToPath(root);
|
|
6
|
+
if (root.startsWith("file:")) return fileURLToPath(root);
|
|
7
|
+
return path.resolve(root);
|
|
8
|
+
}
|
|
9
|
+
function resolveDir(root, value, fallback) {
|
|
10
|
+
const chosen = value ?? fallback;
|
|
11
|
+
return path.isAbsolute(chosen) ? path.resolve(chosen) : path.resolve(root, chosen);
|
|
12
|
+
}
|
|
13
|
+
/** True when `candidate` is `root` or a path inside it. */
|
|
14
|
+
function isInside(root, candidate) {
|
|
15
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
|
16
|
+
return relative === "" || !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative);
|
|
17
|
+
}
|
|
18
|
+
/** Resolve `parts` under `root`, or return null when the result escapes `root`. */
|
|
19
|
+
function resolveInside(root, ...parts) {
|
|
20
|
+
const target = path.resolve(root, ...parts);
|
|
21
|
+
return isInside(root, target) ? target : null;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { resolveInside as i, isInside as n, resolveDir as r, asDirectory as t };
|
package/dist/ui/mount.js
CHANGED
|
@@ -2,8 +2,7 @@ import { a as sectionFieldKey, i as isPropShown, t as defaultTheme } from "../th
|
|
|
2
2
|
import { B as isImagePosition, C as upsertJsonLd, F as DEFAULT_IMAGE_FIT, I as DEFAULT_IMAGE_POSITION, L as IMAGE_FITS, R as IMAGE_POSITIONS, V as withImageLayout, _ as isPlaceholderSiteUrl, h as generateSiteJsonLd, i as isSystemPage, m as formatJsonLd, x as parseJsonLdInput, y as jsonLdWarnings, z as isImageFit } from "../page-wlcQJAA-.js";
|
|
3
3
|
import { d as reconcileMarks, f as renderMarkedHtml, i as fontMarks, l as marksFromEmphasis, t as applyTextMark } from "../marks-DPBilumg.js";
|
|
4
4
|
import { _ as consentCopy, b as parseMediaSource, c as hasThemeColors, d as tokenToHex, f as CONSENT_COPY, h as CONSENT_LIMITS, i as contrastChecks, n as HEX_COLOR, o as derivePalette, r as OVERRIDE_TOKENS, s as hasOverrides, t as DEFAULT_BRAND, u as themeCss, v as consentTextIssues } from "../theme-colors-CHROGZkI.js";
|
|
5
|
-
import {
|
|
6
|
-
import { _ as writeSaveNotice, a as localDraftStorage, d as removeDraft, f as savedNoticeFor, g as writeDraftRecord, h as sweepExpiredDrafts, i as isForeignSave, l as readDraftRecord, m as siteSavedKey, n as draftBannerText, o as pageDraftKey, p as siteDraftKey, r as hashText, s as pageSavedKey, t as assessStoredDraft, u as reloadDecision, x as draftImageUsages } from "../draft-store-1Y4-sn45.js";
|
|
5
|
+
import { T as formatBytes, _ as writeSaveNotice, a as localDraftStorage, d as removeDraft, f as savedNoticeFor, g as writeDraftRecord, h as sweepExpiredDrafts, i as isForeignSave, l as readDraftRecord, m as siteSavedKey, n as draftBannerText, o as pageDraftKey, p as siteDraftKey, r as hashText, s as pageSavedKey, t as assessStoredDraft, u as reloadDecision, w as DEFAULT_IMAGE_BYTE_LIMIT, x as draftImageUsages } from "../draft-store-BaZYEe56.js";
|
|
7
6
|
import { a as richLinkAt, c as updateRichLink, i as renderRichText, n as isSafeHref, o as sanitizeRichHtml, r as markdownFromHtml, s as stripPlainRich } from "../rich-text-70hddxMC.js";
|
|
8
7
|
import { Component, Fragment, createContext, isValidElement, options, render } from "preact";
|
|
9
8
|
import { useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bearminion",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "A git-based CMS for Astro with no database and no server: JSON content in your repo, edited by clicking on the page during astro dev.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jakub Lange",
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
"types": "./dist/forms.d.ts",
|
|
56
56
|
"import": "./dist/forms.js"
|
|
57
57
|
},
|
|
58
|
+
"./hosted": {
|
|
59
|
+
"types": "./dist/hosted.d.ts",
|
|
60
|
+
"import": "./dist/hosted.js"
|
|
61
|
+
},
|
|
58
62
|
"./package.json": "./package.json"
|
|
59
63
|
},
|
|
60
64
|
"files": [
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { A as ContentModel, N as ThemeDefinition, Xt as ContentMigrator, Y as SiteDefinition, j as SectionRegistry, n as PageRules } from "./page-CwbIDegI.js";
|
|
2
|
-
//#region src/upload-names.d.ts
|
|
3
|
-
type ImageKind = 'png' | 'jpeg' | 'webp' | 'gif' | 'avif';
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region src/images.d.ts
|
|
6
|
-
interface SavedImage {
|
|
7
|
-
filename: string;
|
|
8
|
-
path: string;
|
|
9
|
-
bytes: number;
|
|
10
|
-
}
|
|
11
|
-
interface ListedImage {
|
|
12
|
-
filename: string;
|
|
13
|
-
path: string;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/videos.d.ts
|
|
17
|
-
type VideoKind = 'mp4' | 'mov' | 'webm' | 'ogv';
|
|
18
|
-
interface SavedVideo {
|
|
19
|
-
filename: string;
|
|
20
|
-
/** Project-relative path of the file. */
|
|
21
|
-
path: string;
|
|
22
|
-
/** What a Media section's `video` field holds: the file's address on the site, such as `/videos/demo-1a2b.mp4`. */
|
|
23
|
-
url: string;
|
|
24
|
-
bytes: number;
|
|
25
|
-
}
|
|
26
|
-
type ListedVideo = Omit<SavedVideo, 'bytes'> & {
|
|
27
|
-
bytes?: number;
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/store.d.ts
|
|
31
|
-
/**
|
|
32
|
-
* Where the editor reads and writes content. The editor API talks only to this interface, so the
|
|
33
|
-
* place the files live is a choice: {@link createFileStore} uses the local project, and another
|
|
34
|
-
* implementation (a Git host's API, say) can stand in without touching the API handlers.
|
|
35
|
-
*
|
|
36
|
-
* Keys are `/`-separated paths relative to the content directory: `site.json`, `pages/about.json`.
|
|
37
|
-
* Values are text. Parsing, validation and the JSON layout belong to the caller.
|
|
38
|
-
*
|
|
39
|
-
* Not part of the store: undo history (local editor state in `.editor/`), `Commit changes`
|
|
40
|
-
* (needs a local git work tree), and the loaders that run at build time.
|
|
41
|
-
*/
|
|
42
|
-
interface ContentStore {
|
|
43
|
-
/** The text at `key`, or `undefined` when there is none. */
|
|
44
|
-
read(key: string): Promise<string | undefined>;
|
|
45
|
-
exists(key: string): Promise<boolean>;
|
|
46
|
-
/** Names of the files directly inside the directory `dir`, sorted, or `undefined` when it does not exist. */
|
|
47
|
-
list(dir: string): Promise<string[] | undefined>;
|
|
48
|
-
/**
|
|
49
|
-
* Apply changes that belong together, such as a rename (write the new file, remove the old one).
|
|
50
|
-
* Writes run before removals, so a failure never leaves the content with a page missing. An
|
|
51
|
-
* implementation that can make the whole batch atomic (one commit) should.
|
|
52
|
-
*/
|
|
53
|
-
apply(operations: readonly StoreOperation[]): Promise<void>;
|
|
54
|
-
/** Uploaded images. */
|
|
55
|
-
readonly uploads: UploadStore;
|
|
56
|
-
/** Uploaded videos, served from `public/`. Absent in stores that only hold images. */
|
|
57
|
-
readonly videos?: VideoStore;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the image file an image field points at (`src/assets/...`) exists. Saves that point at a missing file
|
|
60
|
-
* fail validation. A store without it skips that check.
|
|
61
|
-
*/
|
|
62
|
-
assetExists?(src: string): Promise<boolean>;
|
|
63
|
-
}
|
|
64
|
-
type StoreOperation = {
|
|
65
|
-
type: 'write';
|
|
66
|
-
key: string;
|
|
67
|
-
text: string;
|
|
68
|
-
} | {
|
|
69
|
-
type: 'remove';
|
|
70
|
-
key: string;
|
|
71
|
-
};
|
|
72
|
-
interface UploadStore {
|
|
73
|
-
list(): Promise<ListedImage[]>;
|
|
74
|
-
/** Store the bytes under a unique, sanitised name and return where it went. `path` is what image fields hold. */
|
|
75
|
-
save(input: {
|
|
76
|
-
originalName: string;
|
|
77
|
-
bytes: Uint8Array;
|
|
78
|
-
kind: ImageKind;
|
|
79
|
-
}): Promise<SavedImage>;
|
|
80
|
-
/** Delete one upload by file name. False when there is no such upload. */
|
|
81
|
-
remove(filename: string): Promise<boolean>;
|
|
82
|
-
}
|
|
83
|
-
interface VideoStore {
|
|
84
|
-
list(): Promise<ListedVideo[]>;
|
|
85
|
-
save(input: {
|
|
86
|
-
originalName: string;
|
|
87
|
-
bytes: Uint8Array;
|
|
88
|
-
kind: VideoKind;
|
|
89
|
-
}): Promise<SavedVideo>;
|
|
90
|
-
remove(filename: string): Promise<boolean>;
|
|
91
|
-
}
|
|
92
|
-
interface FileStoreOptions {
|
|
93
|
-
/** Project root. Upload paths are relative to it. */
|
|
94
|
-
root: string;
|
|
95
|
-
contentDir: string;
|
|
96
|
-
uploadsDir: string;
|
|
97
|
-
/** Where uploaded videos go. Without it the store takes no video uploads. */
|
|
98
|
-
videosDir?: string;
|
|
99
|
-
}
|
|
100
|
-
/** The content store for a local project: content as JSON files, uploads in a folder. */
|
|
101
|
-
declare function createFileStore({ root, contentDir, uploadsDir, videosDir }: FileStoreOptions): ContentStore;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/upload-rules.d.ts
|
|
104
|
-
/** Re-encode uploads in the browser before they are sent. */
|
|
105
|
-
interface ImageConvertOptions {
|
|
106
|
-
to: 'webp';
|
|
107
|
-
/** Wider images are scaled down to this width, never up. Default: no width cap. */
|
|
108
|
-
maxWidth?: number;
|
|
109
|
-
/** WebP quality, 0.1 to 1. Default 0.82. */
|
|
110
|
-
quality?: number;
|
|
111
|
-
}
|
|
112
|
-
/** What the browser needs to know before it sends a file. */
|
|
113
|
-
interface UploadRules {
|
|
114
|
-
maxBytes: number;
|
|
115
|
-
convert: {
|
|
116
|
-
to: 'webp';
|
|
117
|
-
maxWidth: number | null;
|
|
118
|
-
quality: number;
|
|
119
|
-
} | null;
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/options.d.ts
|
|
123
|
-
interface BearminionOptions extends ContentModel {
|
|
124
|
-
/** Directory that contains `site.json` and `pages/`. Default `content`. */
|
|
125
|
-
contentDir?: string;
|
|
126
|
-
/** Directory for uploaded images. Default `src/assets/uploads`. */
|
|
127
|
-
uploadsDir?: string;
|
|
128
|
-
/** Directory for uploaded videos. It must be inside `public/`, which serves them as they are. Default `public/videos`. */
|
|
129
|
-
videosDir?: string;
|
|
130
|
-
/** Largest video the editor accepts, in bytes. Default 50 MB. */
|
|
131
|
-
maxVideoBytes?: number;
|
|
132
|
-
/**
|
|
133
|
-
* Largest image the editor accepts, in bytes. Default 5 MB. The editor checks it in the browser before it uploads,
|
|
134
|
-
* and the server checks it again.
|
|
135
|
-
*/
|
|
136
|
-
maxImageBytes?: number;
|
|
137
|
-
/**
|
|
138
|
-
* Re-encode images in the browser before they are uploaded, so phone photos stay out of the repository:
|
|
139
|
-
* `{ to: 'webp', maxWidth: 2400, quality: 0.82 }`. Animated GIFs are never converted, and an image that would come
|
|
140
|
-
* out larger is kept as it is. Default: off, images are uploaded as they are.
|
|
141
|
-
*/
|
|
142
|
-
imageConvert?: false | ImageConvertOptions;
|
|
143
|
-
/**
|
|
144
|
-
* Which page operations the editor allows: `{ rename: false, delete: false }` for a site whose addresses must not
|
|
145
|
-
* change (they carry search ranking or are the target of redirects). Both default to true. A locked operation is
|
|
146
|
-
* refused by the API as well as hidden in the editor. `rename: false` also blocks making another page the home page,
|
|
147
|
-
* because that moves the old home page to a new address.
|
|
148
|
-
*/
|
|
149
|
-
pages?: Partial<PageRules>;
|
|
150
|
-
/**
|
|
151
|
-
* Vite module id loaded by the dev server to render a draft page.
|
|
152
|
-
* Default `/src/lib/render-preview.ts`. Preview never writes to disk.
|
|
153
|
-
*/
|
|
154
|
-
previewModule?: string;
|
|
155
|
-
/**
|
|
156
|
-
* The folder that holds the section directories and the files `bearminion sync` generates from them, relative to the
|
|
157
|
-
* project root. When set, `astro build`, `astro check` and `astro sync` stop if those files are stale, and
|
|
158
|
-
* `astro dev` warns. Default: not checked.
|
|
159
|
-
*/
|
|
160
|
-
sectionsDir?: string;
|
|
161
|
-
/**
|
|
162
|
-
* The dev route for the forms in your site. A file `src/forms/contact.ts` that default-exports `defineForm(...)`
|
|
163
|
-
* answers at `/api/contact` during `astro dev`, as a dry run unless `BEARMINION_FORMS_LIVE=on`. `dir` is the folder
|
|
164
|
-
* (default `src/forms`) and `prefix` the path (default `/api`). `false` turns the route off, for a site whose
|
|
165
|
-
* Astro adapter serves the endpoint itself.
|
|
166
|
-
*/
|
|
167
|
-
forms?: false | {
|
|
168
|
-
dir?: string;
|
|
169
|
-
prefix?: string;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Show Commit changes in the editor, which commits the changed content and uploads to the local git repository.
|
|
173
|
-
* Off by default. It never pushes, and it does nothing outside a git work tree.
|
|
174
|
-
*/
|
|
175
|
-
git?: boolean;
|
|
176
|
-
/**
|
|
177
|
-
* Where content and uploads are read and written. Default: the local project, using `contentDir` and `uploadsDir`.
|
|
178
|
-
* A custom store replaces those two folders for the editor API; undo history, the live-reload watcher and
|
|
179
|
-
* `git` still work on the local project.
|
|
180
|
-
*/
|
|
181
|
-
store?: ContentStore;
|
|
182
|
-
}
|
|
183
|
-
interface EditorContext {
|
|
184
|
-
root: string;
|
|
185
|
-
contentDir: string;
|
|
186
|
-
uploadsDir: string;
|
|
187
|
-
videosDir: string;
|
|
188
|
-
maxVideoBytes: number;
|
|
189
|
-
maxImageBytes: number;
|
|
190
|
-
pageRules: PageRules;
|
|
191
|
-
/** `imageConvert`, validated and with its defaults filled in. `null` when conversion is off. */
|
|
192
|
-
imageConvert: UploadRules['convert'];
|
|
193
|
-
sections: SectionRegistry;
|
|
194
|
-
site: SiteDefinition;
|
|
195
|
-
theme: ThemeDefinition;
|
|
196
|
-
store: ContentStore;
|
|
197
|
-
/** Upgrades files written under an older `schemaVersion` and stamps the current one on write. */
|
|
198
|
-
migrator: ContentMigrator;
|
|
199
|
-
/** Commit changes is enabled. */
|
|
200
|
-
git: boolean;
|
|
201
|
-
/** The folder with the site's form handlers, or `null` when the `forms` option turns them off. */
|
|
202
|
-
formsDir?: string | null;
|
|
203
|
-
}
|
|
204
|
-
//#endregion
|
|
205
|
-
export { StoreOperation as a, FileStoreOptions as i, EditorContext as n, UploadStore as o, ContentStore as r, createFileStore as s, BearminionOptions as t };
|