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.
@@ -1,21 +1,5 @@
1
1
  import { r as TextMark, t as FontMark } from "./marks-BzLa48Y9.js";
2
2
  import { z } from "zod";
3
- //#region src/field-rules.d.ts
4
- /**
5
- * Field rules a section declares beside its schema, in a form the editor overlay can read without zod.
6
- *
7
- * - Field keys name a place in `props` the same way for every item of a list: `steps[].icon`, `badge.tag`.
8
- * - `showWhen` keeps a prop out of the sidebar unless the section's options have the given values.
9
- */
10
- /** A choice an option must have, or a list of choices any of which will do. */
11
- type ShowCondition = string | boolean | readonly string[];
12
- /** Prop name → option name → the value(s) that show it. Every option listed must match. */
13
- type ShowWhen = Readonly<Record<string, Readonly<Record<string, ShowCondition>>>>;
14
- /** Field key → fixed choices, derived from the schema's enums. */
15
- type FieldChoices = Readonly<Record<string, readonly string[]>>;
16
- /** Field key → choice → SVG path data on a 24 × 24 grid, drawn as a stroke. */
17
- type FieldIcons = Readonly<Record<string, Readonly<Record<string, string>>>>;
18
- //#endregion
19
3
  //#region src/section-options.d.ts
20
4
  /**
21
5
  * Design-system option catalog.
@@ -76,161 +60,6 @@ declare const motionOption: BooleanOption;
76
60
  /** The variant control of one section: its layouts and the one a new section starts with. */
77
61
  declare function variantOption(choices: readonly string[], defaultValue: string): EnumOption;
78
62
  //#endregion
79
- //#region src/section-optional.d.ts
80
- /**
81
- * Props a section can drop. The editor shows each one as an empty field or an "Add" slot
82
- * when it is missing, and prunes empty strings before a preview or a save. Nested keys
83
- * live under the array prop that holds the items. Each section lists its own in `definition.ts`,
84
- * and a test checks that list against the section schema, so a new optional prop that is not
85
- * listed there fails.
86
- */
87
- interface OptionalContent {
88
- /** Top-level props. */
89
- props: readonly string[];
90
- /** Optional keys inside each item of an array prop. */
91
- items?: Readonly<Record<string, readonly string[]>>;
92
- }
93
- //#endregion
94
- //#region src/wireframe.d.ts
95
- /**
96
- * Picker wireframes. A section directory ships a `wireframe.ts` that describes one greyscale
97
- * thumbnail as a list of rectangles, so the Add section picker needs no knowledge of the section.
98
- * Plain data (not a component) because the picker runs in the browser and cannot render `.astro`.
99
- */
100
- /**
101
- * What a rectangle stands for. The editor maps each kind to a fixed greyscale fill, so a theme
102
- * colour never reaches the thumbnail.
103
- *
104
- * - `title` dark bar, a heading
105
- * - `text` light bar, a line of body text or a label
106
- * - `block` pale panel, an image or a media frame
107
- * - `button` dark pill, a filled button
108
- * - `outline` outlined pill, a secondary button
109
- * - `card` white card with a hairline ring
110
- * - `highlight` white card with a strong ring, the featured card
111
- * - `avatar` round grey dot
112
- * - `dark` dark panel behind inverse content
113
- * - `light` white bar on a dark panel
114
- * - `figure` mid-grey block on a dark panel, a big number
115
- */
116
- declare const wireKinds: readonly ["title", "text", "block", "button", "outline", "card", "highlight", "avatar", "dark", "light", "figure"];
117
- type WireKind = (typeof wireKinds)[number];
118
- /** `[left %, top %, width %, height %, kind]` inside a 100 × 100 frame. Later rectangles paint over earlier ones. */
119
- type WireRect = readonly [left: number, top: number, width: number, height: number, kind: WireKind];
120
- type Wireframe = readonly WireRect[];
121
- /** Returns the problems with a wireframe; empty when it is usable. */
122
- declare function wireframeIssues(wireframe: Wireframe): string[];
123
- /** Identity helper that types a wireframe literal. Validation happens in `defineSection`. */
124
- declare function defineWireframe(wireframe: Wireframe): Wireframe;
125
- //#endregion
126
- //#region src/define-section.d.ts
127
- /**
128
- * A registered section type, assembled from the files in its directory.
129
- *
130
- * - `schema` validates `props` and is the source for editor forms.
131
- * - `defaults` is the props object inserted when the section is added.
132
- * - `variants` / `defaultVariant` are the layouts; they become the section's `variant` field and control.
133
- * - `options` are all controls the sidebar shows: variant, tone, motion, then the section's own.
134
- * - `optional` names the props an author may drop.
135
- * - `counts` holds item-count rules per array prop.
136
- * - `wireframe` is the thumbnail in the Add section picker.
137
- * - `choices` lists every string enum in `props` (derived from the schema); the sidebar offers them as choices.
138
- * - `icons` draws those choices as icons in the sidebar's picker.
139
- * - `form` names the handler in `src/forms` that receives what the section's form sends. The sidebar says whether it exists.
140
- * - `showWhen` hides props in the sidebar while the section's options make them unused.
141
- */
142
- interface SectionDefinition<TType extends string = string, TSchema extends z.ZodType = z.ZodType, TVariant extends string = string> {
143
- readonly type: TType;
144
- readonly label: string;
145
- /** One line shown under the name in the Add section picker. */
146
- readonly description: string;
147
- readonly schema: TSchema;
148
- readonly defaults: z.infer<TSchema>;
149
- readonly variants: readonly TVariant[];
150
- readonly defaultVariant: TVariant;
151
- readonly options: readonly Option[];
152
- readonly optional: OptionalContent;
153
- readonly counts: Readonly<Record<string, CountRule>>;
154
- readonly wireframe: Wireframe;
155
- readonly choices: FieldChoices;
156
- readonly icons: FieldIcons;
157
- readonly showWhen: ShowWhen;
158
- readonly form?: string;
159
- /** Cross-field rules the schema cannot express, such as a variant that needs an exact item count. */
160
- refine?(section: {
161
- variant: TVariant;
162
- props: z.infer<TSchema>;
163
- }, ctx: z.RefinementCtx): void;
164
- }
165
- interface SectionConfig<TType extends string, TSchema extends z.ZodType, TVariants extends readonly [string, ...string[]]> {
166
- type: TType;
167
- label: string;
168
- description: string;
169
- schema: TSchema;
170
- defaults: z.infer<TSchema>;
171
- variants: TVariants;
172
- defaultVariant: TVariants[number];
173
- /** Controls beyond variant, tone and motion, for example a number the section reads. */
174
- options?: readonly Option[];
175
- optional: OptionalContent;
176
- counts?: Readonly<Record<string, CountRule>>;
177
- wireframe: Wireframe;
178
- /**
179
- * Icons for a fixed-choice field, shown in the sidebar's picker instead of the choice names alone. Keyed by field
180
- * (`steps[].icon`, list items as `[]`), then by choice: SVG path data on a 24 × 24 grid, drawn as a 1.8 stroke.
181
- * Every choice of the field needs one.
182
- */
183
- icons?: FieldIcons;
184
- /**
185
- * Props the sidebar shows only while options have these values, such as `{ poster: { kind: 'video' } }`. A list
186
- * means any of its values; `variant`, `tone` and `motion` count as options. A hidden prop keeps its value in the file.
187
- */
188
- showWhen?: ShowWhen;
189
- /** The form handler this section posts to: the file `src/forms/<form>.ts`, answering at `/api/<form>`. */
190
- form?: string;
191
- refine?(section: {
192
- variant: TVariants[number];
193
- props: z.infer<TSchema>;
194
- }, ctx: z.RefinementCtx): void;
195
- }
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]>;
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
63
  //#region src/fields.d.ts
235
64
  /** Non-empty plain text. */
236
65
  declare const textSchema: z.ZodString;
@@ -1223,6 +1052,228 @@ interface SiteDefinition<THeader extends string = string, TFooter extends string
1223
1052
  type SiteOf<TDefinition extends SiteDefinition> = z.output<TDefinition['schema']>;
1224
1053
  declare function defineSite<const THeaderVariants extends readonly [string, ...string[]], const TFooterVariants extends readonly [string, ...string[]]>(config: SiteConfig<THeaderVariants, TFooterVariants>): SiteDefinition<THeaderVariants[number], TFooterVariants[number]>;
1225
1054
  //#endregion
1055
+ //#region src/json-ld.d.ts
1056
+ /** JSON-LD blocks as a page stores them: parsed, so diffs stay readable and output can be escaped safely. */
1057
+ type JsonLdBlock = Record<string, unknown>;
1058
+ type JsonLdResult = {
1059
+ ok: true;
1060
+ value: JsonLdBlock[];
1061
+ } | {
1062
+ ok: false;
1063
+ error: string;
1064
+ };
1065
+ /**
1066
+ * Parses what a person pastes into the JSON-LD box: an object, an array of objects, or either one inside a
1067
+ * `<script type="application/ld+json">` tag. Empty input is valid and means "no custom JSON-LD".
1068
+ */
1069
+ declare function parseJsonLdInput(raw: string): JsonLdResult;
1070
+ /** The text shown in the editor box: one block as an object, several as an array, none as empty. */
1071
+ declare function formatJsonLd(blocks: readonly JsonLdBlock[] | undefined): string;
1072
+ /** Advice, not errors: a block without `@type` or `@context` is usually a paste mistake, but Google decides what it accepts. */
1073
+ declare function jsonLdWarnings(blocks: readonly JsonLdBlock[]): string[];
1074
+ /** Custom structured data. At most 10 blocks and 50 KB, so a stray paste cannot bloat every page. */
1075
+ declare const jsonLdSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1076
+ /** The `@id` the generated site blocks use, so a page's markup can point at them. */
1077
+ interface SiteJsonLdIds {
1078
+ organization: string;
1079
+ website: string;
1080
+ }
1081
+ /** `<site.url>/#organization` and `<site.url>/#website`, with trailing slashes on the site URL ignored. */
1082
+ declare function siteJsonLdIds(siteUrl: string): SiteJsonLdIds;
1083
+ /** Whether a block with this `@id` is in the list. */
1084
+ declare function hasJsonLdId(blocks: readonly JsonLdBlock[] | undefined, id: string): boolean;
1085
+ /**
1086
+ * The blocks a page emits: every site block, then the page's own. A block with the same `@id` is
1087
+ * emitted once and the page's copy wins, so a page can refine what the site says without repeating it.
1088
+ */
1089
+ declare function mergeJsonLd(site: readonly JsonLdBlock[] | undefined, page: readonly JsonLdBlock[]): JsonLdBlock[];
1090
+ /** What the Generate button reads from the site settings. */
1091
+ interface SiteJsonLdSource {
1092
+ name: string;
1093
+ url: string;
1094
+ /** BCP 47 tag. Default `en`. */
1095
+ lang?: string;
1096
+ /** An absolute https address. Local images get their address at build time, so they cannot go here. */
1097
+ logo?: string;
1098
+ }
1099
+ /** An `Organization` and a `WebSite` block for the site, in the `@id` convention of {@link siteJsonLdIds}. */
1100
+ declare function generateSiteJsonLd(source: SiteJsonLdSource): JsonLdBlock[];
1101
+ /** Puts generated blocks into a list: a block with the same `@id` is replaced in place, the rest is kept. */
1102
+ declare function upsertJsonLd(blocks: readonly JsonLdBlock[], generated: readonly JsonLdBlock[]): JsonLdBlock[];
1103
+ /** True while the site URL is still the template's `example.com` placeholder. */
1104
+ declare function isPlaceholderSiteUrl(siteUrl: string): boolean;
1105
+ //#endregion
1106
+ //#region src/field-rules.d.ts
1107
+ /**
1108
+ * Field rules a section declares beside its schema, in a form the editor overlay can read without zod.
1109
+ *
1110
+ * - Field keys name a place in `props` the same way for every item of a list: `steps[].icon`, `badge.tag`.
1111
+ * - `showWhen` keeps a prop out of the sidebar unless the section's options have the given values.
1112
+ */
1113
+ /** A choice an option must have, or a list of choices any of which will do. */
1114
+ type ShowCondition = string | boolean | readonly string[];
1115
+ /** Prop name → option name → the value(s) that show it. Every option listed must match. */
1116
+ type ShowWhen = Readonly<Record<string, Readonly<Record<string, ShowCondition>>>>;
1117
+ /** Field key → fixed choices, derived from the schema's enums. */
1118
+ type FieldChoices = Readonly<Record<string, readonly string[]>>;
1119
+ /** Field key → choice → SVG path data on a 24 × 24 grid, drawn as a stroke. */
1120
+ type FieldIcons = Readonly<Record<string, Readonly<Record<string, string>>>>;
1121
+ //#endregion
1122
+ //#region src/section-optional.d.ts
1123
+ /**
1124
+ * Props a section can drop. The editor shows each one as an empty field or an "Add" slot
1125
+ * when it is missing, and prunes empty strings before a preview or a save. Nested keys
1126
+ * live under the array prop that holds the items. Each section lists its own in `definition.ts`,
1127
+ * and a test checks that list against the section schema, so a new optional prop that is not
1128
+ * listed there fails.
1129
+ */
1130
+ interface OptionalContent {
1131
+ /** Top-level props. */
1132
+ props: readonly string[];
1133
+ /** Optional keys inside each item of an array prop. */
1134
+ items?: Readonly<Record<string, readonly string[]>>;
1135
+ }
1136
+ //#endregion
1137
+ //#region src/wireframe.d.ts
1138
+ /**
1139
+ * Picker wireframes. A section directory ships a `wireframe.ts` that describes one greyscale
1140
+ * thumbnail as a list of rectangles, so the Add section picker needs no knowledge of the section.
1141
+ * Plain data (not a component) because the picker runs in the browser and cannot render `.astro`.
1142
+ */
1143
+ /**
1144
+ * What a rectangle stands for. The editor maps each kind to a fixed greyscale fill, so a theme
1145
+ * colour never reaches the thumbnail.
1146
+ *
1147
+ * - `title` dark bar, a heading
1148
+ * - `text` light bar, a line of body text or a label
1149
+ * - `block` pale panel, an image or a media frame
1150
+ * - `button` dark pill, a filled button
1151
+ * - `outline` outlined pill, a secondary button
1152
+ * - `card` white card with a hairline ring
1153
+ * - `highlight` white card with a strong ring, the featured card
1154
+ * - `avatar` round grey dot
1155
+ * - `dark` dark panel behind inverse content
1156
+ * - `light` white bar on a dark panel
1157
+ * - `figure` mid-grey block on a dark panel, a big number
1158
+ */
1159
+ declare const wireKinds: readonly ["title", "text", "block", "button", "outline", "card", "highlight", "avatar", "dark", "light", "figure"];
1160
+ type WireKind = (typeof wireKinds)[number];
1161
+ /** `[left %, top %, width %, height %, kind]` inside a 100 × 100 frame. Later rectangles paint over earlier ones. */
1162
+ type WireRect = readonly [left: number, top: number, width: number, height: number, kind: WireKind];
1163
+ type Wireframe = readonly WireRect[];
1164
+ /** Returns the problems with a wireframe; empty when it is usable. */
1165
+ declare function wireframeIssues(wireframe: Wireframe): string[];
1166
+ /** Identity helper that types a wireframe literal. Validation happens in `defineSection`. */
1167
+ declare function defineWireframe(wireframe: Wireframe): Wireframe;
1168
+ //#endregion
1169
+ //#region src/define-section.d.ts
1170
+ /**
1171
+ * A registered section type, assembled from the files in its directory.
1172
+ *
1173
+ * - `schema` validates `props` and is the source for editor forms.
1174
+ * - `defaults` is the props object inserted when the section is added.
1175
+ * - `variants` / `defaultVariant` are the layouts; they become the section's `variant` field and control.
1176
+ * - `options` are all controls the sidebar shows: variant, tone, motion, then the section's own.
1177
+ * - `optional` names the props an author may drop.
1178
+ * - `counts` holds item-count rules per array prop.
1179
+ * - `wireframe` is the thumbnail in the Add section picker.
1180
+ * - `choices` lists every string enum in `props` (derived from the schema); the sidebar offers them as choices.
1181
+ * - `icons` draws those choices as icons in the sidebar's picker.
1182
+ * - `form` names the handler in `src/forms` that receives what the section's form sends. The sidebar says whether it exists.
1183
+ * - `showWhen` hides props in the sidebar while the section's options make them unused.
1184
+ */
1185
+ interface SectionDefinition<TType extends string = string, TSchema extends z.ZodType = z.ZodType, TVariant extends string = string> {
1186
+ readonly type: TType;
1187
+ readonly label: string;
1188
+ /** One line shown under the name in the Add section picker. */
1189
+ readonly description: string;
1190
+ readonly schema: TSchema;
1191
+ readonly defaults: z.infer<TSchema>;
1192
+ readonly variants: readonly TVariant[];
1193
+ readonly defaultVariant: TVariant;
1194
+ readonly options: readonly Option[];
1195
+ readonly optional: OptionalContent;
1196
+ readonly counts: Readonly<Record<string, CountRule>>;
1197
+ readonly wireframe: Wireframe;
1198
+ readonly choices: FieldChoices;
1199
+ readonly icons: FieldIcons;
1200
+ readonly showWhen: ShowWhen;
1201
+ readonly form?: string;
1202
+ /** Cross-field rules the schema cannot express, such as a variant that needs an exact item count. */
1203
+ refine?(section: {
1204
+ variant: TVariant;
1205
+ props: z.infer<TSchema>;
1206
+ }, ctx: z.RefinementCtx): void;
1207
+ }
1208
+ interface SectionConfig<TType extends string, TSchema extends z.ZodType, TVariants extends readonly [string, ...string[]]> {
1209
+ type: TType;
1210
+ label: string;
1211
+ description: string;
1212
+ schema: TSchema;
1213
+ defaults: z.infer<TSchema>;
1214
+ variants: TVariants;
1215
+ defaultVariant: TVariants[number];
1216
+ /** Controls beyond variant, tone and motion, for example a number the section reads. */
1217
+ options?: readonly Option[];
1218
+ optional: OptionalContent;
1219
+ counts?: Readonly<Record<string, CountRule>>;
1220
+ wireframe: Wireframe;
1221
+ /**
1222
+ * Icons for a fixed-choice field, shown in the sidebar's picker instead of the choice names alone. Keyed by field
1223
+ * (`steps[].icon`, list items as `[]`), then by choice: SVG path data on a 24 × 24 grid, drawn as a 1.8 stroke.
1224
+ * Every choice of the field needs one.
1225
+ */
1226
+ icons?: FieldIcons;
1227
+ /**
1228
+ * Props the sidebar shows only while options have these values, such as `{ poster: { kind: 'video' } }`. A list
1229
+ * means any of its values; `variant`, `tone` and `motion` count as options. A hidden prop keeps its value in the file.
1230
+ */
1231
+ showWhen?: ShowWhen;
1232
+ /** The form handler this section posts to: the file `src/forms/<form>.ts`, answering at `/api/<form>`. */
1233
+ form?: string;
1234
+ refine?(section: {
1235
+ variant: TVariants[number];
1236
+ props: z.infer<TSchema>;
1237
+ }, ctx: z.RefinementCtx): void;
1238
+ }
1239
+ 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]>;
1240
+ //#endregion
1241
+ //#region src/migrate.d.ts
1242
+ /** Which kind of document a migration is upgrading. */
1243
+ type DocumentKind = 'page' | 'site';
1244
+ /** Upgrades one document from version N to N + 1. Return the new document; do not mutate the input. */
1245
+ type ContentMigration = (document: Record<string, unknown>, kind: DocumentKind) => Record<string, unknown>;
1246
+ /** How a site versions its content files. */
1247
+ interface ContentVersioning {
1248
+ /**
1249
+ * The content format version this site's schemas describe. Default 1. Raise it when a schema change
1250
+ * would reject files written before it, and add the migration that upgrades them.
1251
+ */
1252
+ schemaVersion?: number;
1253
+ /** `migrations[n]` upgrades a document from version `n` to `n + 1`. Needed for every `n` below `schemaVersion`. */
1254
+ migrations?: Readonly<Record<number, ContentMigration>>;
1255
+ }
1256
+ /** The key that stores a document's version. It is stripped on read and stamped on write; schemas never see it. */
1257
+ declare const SCHEMA_VERSION_KEY = "schemaVersion";
1258
+ type UpgradeResult = {
1259
+ ok: true;
1260
+ value: unknown;
1261
+ } | {
1262
+ ok: false;
1263
+ message: string;
1264
+ };
1265
+ interface ContentMigrator {
1266
+ /** The version this site writes. */
1267
+ readonly version: number;
1268
+ /** Upgrade a parsed file to the current version and remove its version key. Non-objects pass through for the schema to reject. */
1269
+ upgrade(raw: unknown, kind: DocumentKind): UpgradeResult;
1270
+ /** The document as written to disk: its version key plus the content. */
1271
+ stamp<T extends object>(document: T): T & {
1272
+ schemaVersion: number;
1273
+ };
1274
+ }
1275
+ declare function createMigrator(versioning?: ContentVersioning): ContentMigrator;
1276
+ //#endregion
1226
1277
  //#region src/theme.d.ts
1227
1278
  /**
1228
1279
  * The contract between bearminion and a theme.
@@ -1276,57 +1327,6 @@ interface ContentModel extends ContentVersioning {
1276
1327
  theme?: ThemeDefinition;
1277
1328
  }
1278
1329
  //#endregion
1279
- //#region src/json-ld.d.ts
1280
- /** JSON-LD blocks as a page stores them: parsed, so diffs stay readable and output can be escaped safely. */
1281
- type JsonLdBlock = Record<string, unknown>;
1282
- type JsonLdResult = {
1283
- ok: true;
1284
- value: JsonLdBlock[];
1285
- } | {
1286
- ok: false;
1287
- error: string;
1288
- };
1289
- /**
1290
- * Parses what a person pastes into the JSON-LD box: an object, an array of objects, or either one inside a
1291
- * `<script type="application/ld+json">` tag. Empty input is valid and means "no custom JSON-LD".
1292
- */
1293
- declare function parseJsonLdInput(raw: string): JsonLdResult;
1294
- /** The text shown in the editor box: one block as an object, several as an array, none as empty. */
1295
- declare function formatJsonLd(blocks: readonly JsonLdBlock[] | undefined): string;
1296
- /** Advice, not errors: a block without `@type` or `@context` is usually a paste mistake, but Google decides what it accepts. */
1297
- declare function jsonLdWarnings(blocks: readonly JsonLdBlock[]): string[];
1298
- /** Custom structured data. At most 10 blocks and 50 KB, so a stray paste cannot bloat every page. */
1299
- declare const jsonLdSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1300
- /** The `@id` the generated site blocks use, so a page's markup can point at them. */
1301
- interface SiteJsonLdIds {
1302
- organization: string;
1303
- website: string;
1304
- }
1305
- /** `<site.url>/#organization` and `<site.url>/#website`, with trailing slashes on the site URL ignored. */
1306
- declare function siteJsonLdIds(siteUrl: string): SiteJsonLdIds;
1307
- /** Whether a block with this `@id` is in the list. */
1308
- declare function hasJsonLdId(blocks: readonly JsonLdBlock[] | undefined, id: string): boolean;
1309
- /**
1310
- * The blocks a page emits: every site block, then the page's own. A block with the same `@id` is
1311
- * emitted once and the page's copy wins, so a page can refine what the site says without repeating it.
1312
- */
1313
- declare function mergeJsonLd(site: readonly JsonLdBlock[] | undefined, page: readonly JsonLdBlock[]): JsonLdBlock[];
1314
- /** What the Generate button reads from the site settings. */
1315
- interface SiteJsonLdSource {
1316
- name: string;
1317
- url: string;
1318
- /** BCP 47 tag. Default `en`. */
1319
- lang?: string;
1320
- /** An absolute https address. Local images get their address at build time, so they cannot go here. */
1321
- logo?: string;
1322
- }
1323
- /** An `Organization` and a `WebSite` block for the site, in the `@id` convention of {@link siteJsonLdIds}. */
1324
- declare function generateSiteJsonLd(source: SiteJsonLdSource): JsonLdBlock[];
1325
- /** Puts generated blocks into a list: a block with the same `@id` is replaced in place, the rest is kept. */
1326
- declare function upsertJsonLd(blocks: readonly JsonLdBlock[], generated: readonly JsonLdBlock[]): JsonLdBlock[];
1327
- /** True while the site URL is still the template's `example.com` placeholder. */
1328
- declare function isPlaceholderSiteUrl(siteUrl: string): boolean;
1329
- //#endregion
1330
1330
  //#region src/section-schema.d.ts
1331
1331
  declare const sectionIdSchema: z.ZodString;
1332
1332
  declare const anchorSchema: 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 $, 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 };
1405
+ export { mergeJsonLd as $, tones as $t, SectionDefinition as A, MAX_NAV_DEPTH as At, FieldIcons as B, toneSchema as Bt, ContentMigration as C, siteConsentSchema as Ct, SCHEMA_VERSION_KEY as D, ButtonStyle as Dt, DocumentKind as E, themeSchema as Et, defineWireframe as F, imageSchema as Ft, SiteJsonLdIds as G, EnumOption as Gt, ShowWhen as H, withEmphasis as Ht, wireKinds as I, linkSchema as It, generateSiteJsonLd as J, StringOption as Jt, SiteJsonLdSource as K, NumberOption as Kt, wireframeIssues as L, richTextSchema as Lt, WireKind as M, Text as Mt, WireRect as N, Tone as Nt, createMigrator as O, Image as Ot, Wireframe as P, htmlIdSchema as Pt, jsonLdWarnings as Q, toneOption as Qt, OptionalContent as R, textMarkSchema as Rt, defineTheme as S, siteAnalyticsSchema as St, ContentVersioning as T, themeColorsSchema as Tt, JsonLdBlock as U, BooleanOption as Ut, ShowCondition as V, trackingIdSchema as Vt, JsonLdResult as W, CountRule as Wt, isPlaceholderSiteUrl as X, motionOption as Xt, hasJsonLdId as Y, buttonStyles as Yt, jsonLdSchema as Z, themeModes as Zt, SectionRegistry as _, SiteSeo as _t, createPageSchema as a, DEFAULT_MAX_HEADER_ACTIONS as at, ThemeFont as b, brandLogoSchema as bt, withoutOrphanSections as c, FooterConfig as ct, SectionOf as d, Site as dt, variantOption as en, parseJsonLdInput as et, anchorSchema as f, SiteAnalytics as ft, ContentModel as g, SiteOf as gt, API_PREFIX as h, SiteDefinition as ht, Seo as i, DEFAULT_MAX_FOOTER_COLUMNS as it, defineSection as j, RichText as jt, SectionConfig as k, Link as kt, BaseSection as l, Header as lt, sectionIdSchema as m, SiteConsent as mt, PageRules as n, upsertJsonLd as nt, isSystemPage as o, Footer as ot, createSectionSchema as p, SiteConfig as pt, formatJsonLd as q, Option as qt, SYSTEM_PAGES as r, BRAND_LOGO_HEIGHT as rt, seoSchema as s, FooterColumn as st, Page as t, siteJsonLdIds as tt, PropsOf as u, HeaderConfig as ut, ThemeConfig as v, SiteWith as vt, ContentMigrator as w, siteSeoSchema as wt, defaultTheme as x, defineSite as xt, ThemeDefinition as y, Theme as yt, FieldChoices as z, textSchema as zt };
@@ -0,0 +1,90 @@
1
+ import { s as slugSchema } from "./page-wlcQJAA-.js";
2
+ import { t as DEFAULT_IMAGE_BYTE_LIMIT } from "./upload-rules-Cao9uY5K.js";
3
+ //#region src/request-guards.ts
4
+ const JSON_BODY_LIMIT = 1048576;
5
+ DEFAULT_IMAGE_BYTE_LIMIT + 262144;
6
+ const LOCAL_HOSTS = /* @__PURE__ */ new Set([
7
+ "localhost",
8
+ "127.0.0.1",
9
+ "::1"
10
+ ]);
11
+ function hostnameFromHostHeader(host) {
12
+ if (host === null) return null;
13
+ const trimmed = host.trim().toLowerCase();
14
+ if (trimmed === "") return null;
15
+ if (trimmed.startsWith("[")) {
16
+ const end = trimmed.indexOf("]");
17
+ if (end <= 1) return null;
18
+ return trimmed.slice(1, end);
19
+ }
20
+ const colon = trimmed.lastIndexOf(":");
21
+ if (colon === -1) return trimmed;
22
+ const maybePort = trimmed.slice(colon + 1);
23
+ if (/^\d+$/.test(maybePort)) return trimmed.slice(0, colon);
24
+ return trimmed;
25
+ }
26
+ function isLocalHostname(hostname) {
27
+ return hostname !== null && LOCAL_HOSTS.has(hostname);
28
+ }
29
+ function isLocalAddress(address) {
30
+ if (!address) return false;
31
+ const normalized = address.toLowerCase().replace(/^::ffff:/, "");
32
+ return normalized === "127.0.0.1" || normalized === "::1";
33
+ }
34
+ /**
35
+ * Allow the request when Host is local and, if Origin is present, its host is local. When the browser sends
36
+ * `Sec-Fetch-Site`, it must be `same-origin` or `none` (typed in, or a tool such as curl), so a page on another
37
+ * site cannot even read-probe the API with a no-cors GET, which carries no Origin.
38
+ * When `remoteAddress` is provided it must be a loopback address. Omit it only in tests
39
+ * that do not model a socket; the dev middleware always passes it.
40
+ */
41
+ function isLocalRequest(headers, remoteAddress) {
42
+ if (!isLocalHostname(hostnameFromHostHeader(headers.get("host")))) return false;
43
+ const site = headers.get("sec-fetch-site");
44
+ if (site !== null && site !== "same-origin" && site !== "none") return false;
45
+ const origin = headers.get("origin");
46
+ if (origin !== null) {
47
+ let hostname;
48
+ try {
49
+ hostname = new URL(origin).hostname.toLowerCase();
50
+ } catch {
51
+ return false;
52
+ }
53
+ if (!isLocalHostname(hostname)) return false;
54
+ }
55
+ if (remoteAddress !== void 0 && !isLocalAddress(remoteAddress)) return false;
56
+ return true;
57
+ }
58
+ /**
59
+ * The check for a hosted editor, where the caller has already signed the person in: the request must come from this
60
+ * site's own pages. The browser's `Sec-Fetch-Site` must be `same-origin` or `none`, and an `Origin`, when sent, must
61
+ * name the host the request went to (its URL, or the Host header). That refuses a form or script on another site that rides on the person's cookie.
62
+ */
63
+ function isSameOriginRequest(headers, url) {
64
+ const site = headers.get("sec-fetch-site");
65
+ if (site !== null && site !== "same-origin" && site !== "none") return false;
66
+ const origin = headers.get("origin");
67
+ if (origin === null) return true;
68
+ try {
69
+ const hosts = /* @__PURE__ */ new Set([new URL(url).host.toLowerCase()]);
70
+ const header = headers.get("host");
71
+ if (header !== null) hosts.add(header.trim().toLowerCase());
72
+ return hosts.has(new URL(origin).host.toLowerCase());
73
+ } catch {
74
+ return false;
75
+ }
76
+ }
77
+ /** Decode one URL segment and accept it only when it is a content slug. */
78
+ function readSlug(segment) {
79
+ let decoded;
80
+ try {
81
+ decoded = decodeURIComponent(segment);
82
+ } catch {
83
+ return null;
84
+ }
85
+ if (decoded.includes("\0") || decoded.includes("/") || decoded.includes("\\") || decoded.includes("..")) return null;
86
+ const parsed = slugSchema.safeParse(decoded);
87
+ return parsed.success ? parsed.data : null;
88
+ }
89
+ //#endregion
90
+ export { readSlug as i, isLocalRequest as n, isSameOriginRequest as r, JSON_BODY_LIMIT as t };
package/dist/ui/mount.js CHANGED
@@ -2,7 +2,8 @@ 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 { 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";
5
+ import { n as formatBytes, t as DEFAULT_IMAGE_BYTE_LIMIT } from "../upload-rules-Cao9uY5K.js";
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-DBEfw_Gq.js";
6
7
  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";
7
8
  import { Component, Fragment, createContext, isValidElement, options, render } from "preact";
8
9
  import { useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
@@ -0,0 +1,36 @@
1
+ //#region src/upload-rules.ts
2
+ /**
3
+ * Image upload rules shared by the dev server and the editor in the browser. No Node imports: the browser bundle
4
+ * uses it too.
5
+ */
6
+ /** The default largest image the editor accepts: 5 MB. */
7
+ const DEFAULT_IMAGE_BYTE_LIMIT = 5242880;
8
+ const DEFAULT_CONVERT_QUALITY = .82;
9
+ const MAX_CONVERT_WIDTH = 16384;
10
+ /** Check `imageConvert` and fill in its defaults. `false` and `undefined` mean no conversion. */
11
+ function resolveConvert(input) {
12
+ if (input === void 0 || input === false) return null;
13
+ if (input.to !== "webp") throw new Error(`bearminion(): imageConvert.to must be "webp", got "${String(input.to)}".`);
14
+ const { maxWidth, quality = DEFAULT_CONVERT_QUALITY } = input;
15
+ if (maxWidth !== void 0 && (!Number.isInteger(maxWidth) || maxWidth < 16 || maxWidth > 16384)) throw new Error(`bearminion(): imageConvert.maxWidth must be a whole number from 16 to ${MAX_CONVERT_WIDTH}.`);
16
+ if (!Number.isFinite(quality) || quality < .1 || quality > 1) throw new Error("bearminion(): imageConvert.quality must be a number from 0.1 to 1.");
17
+ return {
18
+ to: "webp",
19
+ maxWidth: maxWidth ?? null,
20
+ quality
21
+ };
22
+ }
23
+ /** Check `maxImageBytes`. */
24
+ function resolveMaxImageBytes(input) {
25
+ if (input === void 0) return DEFAULT_IMAGE_BYTE_LIMIT;
26
+ if (!Number.isInteger(input) || input < 1024) throw new Error("bearminion(): maxImageBytes must be a whole number of bytes, at least 1024.");
27
+ return input;
28
+ }
29
+ /** "4.2 MB", "310 KB", "512 B". */
30
+ function formatBytes(bytes) {
31
+ if (bytes >= 1048576) return `${(bytes / 1048576).toFixed(1).replace(/\.0$/, "")} MB`;
32
+ if (bytes >= 1024) return `${Math.round(bytes / 1024)} KB`;
33
+ return `${bytes} B`;
34
+ }
35
+ //#endregion
36
+ export { resolveMaxImageBytes as i, formatBytes as n, resolveConvert as r, DEFAULT_IMAGE_BYTE_LIMIT as t };