@takazudo/zfb 0.1.0-next.2

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +207 -0
  4. package/bin/zfb.mjs +61 -0
  5. package/dist/config.d.ts +542 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +24 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/content.d.ts +231 -0
  10. package/dist/content.d.ts.map +1 -0
  11. package/dist/content.js +449 -0
  12. package/dist/content.js.map +1 -0
  13. package/dist/frontmatter.d.ts +23 -0
  14. package/dist/frontmatter.d.ts.map +1 -0
  15. package/dist/frontmatter.js +142 -0
  16. package/dist/frontmatter.js.map +1 -0
  17. package/dist/index.d.ts +7 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +21 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/island.d.ts +121 -0
  22. package/dist/island.d.ts.map +1 -0
  23. package/dist/island.js +273 -0
  24. package/dist/island.js.map +1 -0
  25. package/dist/jsx-types.d.ts +37 -0
  26. package/dist/jsx-types.d.ts.map +1 -0
  27. package/dist/jsx-types.js +12 -0
  28. package/dist/jsx-types.js.map +1 -0
  29. package/dist/paginate.d.ts +43 -0
  30. package/dist/paginate.d.ts.map +1 -0
  31. package/dist/paginate.js +44 -0
  32. package/dist/paginate.js.map +1 -0
  33. package/dist/plugins.d.ts +259 -0
  34. package/dist/plugins.d.ts.map +1 -0
  35. package/dist/plugins.js +42 -0
  36. package/dist/plugins.js.map +1 -0
  37. package/dist/runtime.d.ts +101 -0
  38. package/dist/runtime.d.ts.map +1 -0
  39. package/dist/runtime.js +454 -0
  40. package/dist/runtime.js.map +1 -0
  41. package/dist/types.d.ts +27 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +33 -0
  44. package/dist/types.js.map +1 -0
  45. package/package.json +98 -0
@@ -0,0 +1,542 @@
1
+ export type Framework = "preact" | "react";
2
+ export type CollectionDef = {
3
+ /** Identifier used at the call site (e.g. `"blog"`). */
4
+ name: string;
5
+ /** Directory (relative to the project root) holding the entries. */
6
+ path: string;
7
+ /** Optional schema. Reserved for v1.1 — accepted but not enforced today. */
8
+ schema?: Record<string, unknown>;
9
+ /**
10
+ * Optional include globs (Astro-style, evaluated relative to `path`).
11
+ * When set and non-empty, an entry is kept only if at least one
12
+ * pattern matches its relative path. When omitted or empty, no
13
+ * include-filtering happens. Patterns use the `globset` dialect
14
+ * (Unix-style: `*`, `**`, `?`, `[…]`).
15
+ */
16
+ include?: string[];
17
+ /**
18
+ * Optional exclude globs. When set, an entry is dropped if any
19
+ * pattern matches its relative path. Evaluated AFTER `include`.
20
+ * Together they mirror Astro's `['**\/*.mdx', '!**\/*.en.mdx']`
21
+ * convention (zfb splits the negative side into its own field).
22
+ */
23
+ exclude?: string[];
24
+ /**
25
+ * Optional suffix to strip from each kept entry's slug + module
26
+ * specifier. Use with multi-locale layouts where one source
27
+ * directory holds both `foo.mdx` (default locale) and `foo.en.mdx`
28
+ * (locale override) — set `idStripSuffix: ".en"` so the EN
29
+ * collection's slugs round-trip as `foo` instead of `foo.en`.
30
+ */
31
+ idStripSuffix?: string;
32
+ };
33
+ export type TailwindConfig = {
34
+ /** Whether Tailwind is enabled. Default: `true`. */
35
+ enabled?: boolean;
36
+ };
37
+ /**
38
+ * Prefetch options. Mirrors `PrefetchConfig` in `crates/zfb/src/config.rs`.
39
+ */
40
+ export type PrefetchConfig = {
41
+ /**
42
+ * Disable prefetch entirely.
43
+ *
44
+ * When `true`, the bundler emits `globalThis.__zfb.prefetchDisabled = true`
45
+ * in `entry.mjs`, and `<ClientRouter />` renders
46
+ * `<meta name="zfb-prefetch-disabled" content="true">` in `<head>`.
47
+ * The sibling prefetch-core module reads that meta tag at `init()` time
48
+ * and short-circuits — no prefetch wiring runs.
49
+ *
50
+ * The flag is site-wide and static — set once at bundle-emit time,
51
+ * never recomputed per-page. Default: `false`.
52
+ */
53
+ disabled?: boolean;
54
+ };
55
+ /**
56
+ * One plugin entry in `zfb.config.ts`.
57
+ *
58
+ * `name` MUST be a module reference that Node's resolver can locate from
59
+ * the project root. The zfb config loader (`crates/zfb/js/config-loader.mjs`)
60
+ * resolves it to an absolute module specifier and the build / dev plugin
61
+ * host loads it via dynamic `import()`:
62
+ *
63
+ * - `"./plugins/my-plugin.mjs"` / `"../shared/plugin.mjs"` —
64
+ * path-relative to the project root (the dir containing `zfb.config.ts`).
65
+ * - `"/abs/path/to/plugin.mjs"` — absolute filesystem path.
66
+ * - `"@takazudo/zfb-plugin-search"` / `"my-plugin"` — npm bare specifier
67
+ * resolved against the project's `node_modules`.
68
+ *
69
+ * Inline-function hooks are NOT supported; the plugin module's default
70
+ * export must be a [`ZfbPlugin`] (see `@takazudo/zfb/plugins`).
71
+ *
72
+ * `options` is passed verbatim to the plugin's hook contexts; treat
73
+ * the schema as plugin-specific.
74
+ */
75
+ export type PluginConfig = {
76
+ name: string;
77
+ options?: Record<string, unknown>;
78
+ };
79
+ export type ZfbConfig = {
80
+ /** Output directory for built assets. Default: `dist`. */
81
+ outDir?: string;
82
+ /** Public/static directory copied verbatim. Default: `public`. */
83
+ publicDir?: string;
84
+ /** Optional dev/preview server bind host. */
85
+ host?: string;
86
+ /** Optional dev/preview server port. */
87
+ port?: number;
88
+ /** JSX framework runtime. Default: `preact`. */
89
+ framework?: Framework;
90
+ /** Content collections. Mirrors the JSON form one-for-one. */
91
+ collections?: CollectionDef[];
92
+ /** Tailwind options; absent = defaults. */
93
+ tailwind?: TailwindConfig;
94
+ /**
95
+ * Prefetch options. When `disabled: true`, the build emits a meta tag
96
+ * that the runtime's prefetch-core module reads at init time to skip
97
+ * all prefetch wiring. Mirrors `Config::prefetch` in
98
+ * `crates/zfb/src/config.rs`.
99
+ */
100
+ prefetch?: PrefetchConfig;
101
+ /** User-supplied plugins. */
102
+ plugins?: PluginConfig[];
103
+ /**
104
+ * Deploy-target adapter package name. Omit (or `"none"`) for a pure
105
+ * static build — any route exporting `prerender = false` is then a
106
+ * hard build error. A package name like
107
+ * `"@takazudo/zfb-adapter-cloudflare"` selects the matching adapter,
108
+ * and `zfb build` invokes that package's bin to wrap the SSR bundle
109
+ * into a deploy-ready entry (e.g. `dist/_worker.js` for Cloudflare
110
+ * Pages).
111
+ *
112
+ * Mirrors `Config::adapter` in crates/zfb/src/config.rs.
113
+ */
114
+ adapter?: string;
115
+ /**
116
+ * Strip `.md` / `.mdx` from internal `<a href>` paths during MDX
117
+ * compilation, and append a trailing `/` so the resulting URL shape
118
+ * converges with the rest of the site (mirrors the JS engine's
119
+ * `rehypeStripMdExtension`). Default: `false`.
120
+ *
121
+ * Enable this when content authors hand-write `[label](other.md)`
122
+ * style references that should resolve to the rendered route URL
123
+ * (e.g. `other/`) instead of a literal file path. Built dist and
124
+ * `pnpm dev` honour the same flag, so previews match shipped output.
125
+ *
126
+ * Mirrors `Config::strip_md_ext` in crates/zfb/src/config.rs.
127
+ */
128
+ stripMdExt?: boolean;
129
+ /**
130
+ * Public URL prefix mounted in front of every absolute HTML asset
131
+ * URL the build emits — `<link rel="stylesheet">`, `<script type="module">`,
132
+ * and any other `/assets/...`-prefixed reference rewritten by the
133
+ * production asset pipeline.
134
+ *
135
+ * Use this when the site is deployed under a sub-path (e.g.
136
+ * `https://example.com/pj/zudo-doc/`) instead of the domain root.
137
+ * With `base: "/pj/zudo-doc/"` the dist HTML emits
138
+ * `<link rel="stylesheet" href="/pj/zudo-doc/assets/styles-<hash>.css">`
139
+ * instead of the unprefixed `/assets/styles-<hash>.css`.
140
+ *
141
+ * Accepted shapes (all normalised to a single canonical form
142
+ * internally):
143
+ *
144
+ * - omitted / `undefined` / `""` / `"/"` — no prefix; behaviour is
145
+ * byte-identical to the pre-`base` build (root-mounted site).
146
+ * - leading-and-trailing-slash path like `"/pj/zudo-doc/"` — prefix
147
+ * that path onto every asset URL.
148
+ * - absolute URL like `"https://cdn.example.com/"` — emit absolute
149
+ * URLs (CDN-hosted assets).
150
+ *
151
+ * Inputs missing a leading or trailing `/` are normalised at config-
152
+ * load time (paths) or asset-emit time (URL prefixes); callers do
153
+ * not have to pre-trim.
154
+ *
155
+ * Mirrors `Config::base` in crates/zfb/src/config.rs.
156
+ */
157
+ base?: string;
158
+ /**
159
+ * Canonical origin URL for the site (e.g. `"https://example.com"`).
160
+ *
161
+ * When set, the bundler emits `globalThis.__zfb.site = <value>` in
162
+ * `entry.mjs` so layouts can build canonical `<link>` tags,
163
+ * OpenGraph `og:url` meta, sitemap absolute hrefs, and hreflang
164
+ * `<link rel="alternate">` from a single config-level source of truth.
165
+ *
166
+ * **Distinct from `base`**: `base` is a sub-path mount prefix used
167
+ * for asset URLs (e.g. `"/pj/my-site/"`). `site` is the full
168
+ * canonical origin (scheme + host, no path) used to construct
169
+ * absolute page URLs for SEO/social metadata. Both may be set
170
+ * simultaneously.
171
+ *
172
+ * Accepted shape: an absolute HTTP or HTTPS URL. Relative URLs,
173
+ * non-HTTP(S) schemes, and empty strings are rejected at config-load
174
+ * time. Trailing slash normalisation is the consumer's responsibility.
175
+ *
176
+ * When absent, `globalThis.__zfb.site` is not emitted — the build
177
+ * output is byte-for-byte identical to builds without this field.
178
+ *
179
+ * Mirrors `Config::site` in crates/zfb/src/config.rs.
180
+ */
181
+ site?: string;
182
+ /**
183
+ * Markdown link resolver (port of `remarkResolveMarkdownLinks`).
184
+ *
185
+ * When `enabled: true`, the build appends `ResolveLinksPlugin` to the
186
+ * mdast pipeline so author-written `[label](./other.mdx)` links are
187
+ * rewritten to the corresponding rendered route URL — bypassing the
188
+ * file→directory transformation that breaks relative paths in dist
189
+ * HTML when `foo.mdx` becomes `foo/index.html`.
190
+ *
191
+ * Two ways to specify the source dirs:
192
+ *
193
+ * - **Single dir (legacy):** set `docsDir` and the build assumes the
194
+ * `/docs/` route prefix. Convenient for single-locale projects.
195
+ * - **Multi dir (`dirs` non-empty):** explicit `{ dir, routePrefix }`
196
+ * entries — required for any project with locale mirrors (e.g.
197
+ * `docs/` AND `docs-ja/`) so each dir maps to its own route prefix
198
+ * (`/docs/` vs `/ja/docs/`). When `dirs` is non-empty, `docsDir`
199
+ * is ignored.
200
+ *
201
+ * Mirrors `Config::resolve_markdown_links` in crates/zfb/src/config.rs.
202
+ */
203
+ resolveMarkdownLinks?: ResolveMarkdownLinksConfig;
204
+ /**
205
+ * Whether the basePath rewriter should append a trailing `/` to
206
+ * extensionless absolute hrefs (`<a href="/docs/foo">` becomes
207
+ * `<a href="/pj/zudo-doc/docs/foo/">` when `base = "/pj/zudo-doc/"`
208
+ * and this is `true`).
209
+ *
210
+ * Off by default — preserves byte-for-byte parity with the
211
+ * pre-`trailingSlash` build for projects that haven't opted in.
212
+ * Enable when the deploy target serves canonical URLs with trailing
213
+ * slashes (Cloudflare Pages with `trailingSlash: always`, Netlify
214
+ * pretty URLs, etc.) so the dist HTML doesn't ship non-canonical
215
+ * hrefs that 301-redirect on every click.
216
+ *
217
+ * Only the trailing slash for extensionless hrefs is affected.
218
+ * Hrefs that already end in `/`, that have a file extension
219
+ * (`.png`, `.pdf`, …), or that opt out via `data-no-base` pass
220
+ * through unchanged.
221
+ *
222
+ * Mirrors `Config::trailing_slash` in crates/zfb/src/config.rs.
223
+ */
224
+ trailingSlash?: boolean;
225
+ /**
226
+ * Markdown / MDX parsing options. Currently the only knob exposed is
227
+ * [`gfm`](MarkdownConfig.gfm), which toggles GFM constructs
228
+ * (strikethrough, table, autolink-literal, task-list-item,
229
+ * footnote-definition) on or off.
230
+ *
231
+ * Mirrors `Config::markdown` in crates/zfb/src/config.rs.
232
+ */
233
+ markdown?: MarkdownConfig;
234
+ /**
235
+ * Extra absolute filesystem paths watched by the dev server in
236
+ * addition to the project-root tree.
237
+ *
238
+ * Use this when project content reads from outside the project root
239
+ * (a sibling knowledge-base repo, a shared filesystem directory, a
240
+ * `file:` dep that ships content alongside code, etc.) and you want
241
+ * `zfb dev` to live-reload when those external files change.
242
+ *
243
+ * Semantics:
244
+ *
245
+ * - Each entry MUST be an absolute path. Relative paths are
246
+ * rejected at config-load time with a clear error message.
247
+ * - Paths are canonicalised when the watcher boots; events match
248
+ * the canonical form.
249
+ * - A path that does NOT exist at boot is skipped with a warning;
250
+ * the watcher does NOT re-watch the path if it appears later.
251
+ * Restart `zfb dev` after creating the path.
252
+ * - Each entry is watched recursively.
253
+ * - Events from outside the project root bypass fine-grained graph
254
+ * classification and may trigger a broader rebuild than equivalent
255
+ * in-tree edits.
256
+ *
257
+ * **Security note:** opt-in only — do NOT point this at unbounded
258
+ * directories like `$HOME` or `/`. On Linux the recursive watcher
259
+ * registers every subdirectory and can hit the inotify
260
+ * `max_user_watches` ceiling on large trees.
261
+ *
262
+ * Mirrors `Config::extra_watch_paths` in crates/zfb/src/config.rs.
263
+ */
264
+ extraWatchPaths?: string[];
265
+ /**
266
+ * Whether `zfb build` writes the post-build route manifest to disk
267
+ * at `<outDir>/__zfb/routes.json` (#347).
268
+ *
269
+ * The on-disk file mirrors the in-memory `ctx.routes` shape that the
270
+ * plugin API hands to `postBuild` hooks — same fields, same
271
+ * url-sorted order — so any consumer script wired into `pnpm build`
272
+ * can read the manifest without writing a zfb plugin. The plugin
273
+ * `ctx.routes` and the on-disk `routes.json` are two access shapes
274
+ * over the same data, not two contracts.
275
+ *
276
+ * Default: emit (`undefined` is treated as `true`). Set `false` to
277
+ * skip the write — useful for projects that strip everything but
278
+ * shipped assets out of `dist/` before deploy.
279
+ *
280
+ * Mirrors `Config::emit_routes_manifest` in crates/zfb/src/config.rs.
281
+ */
282
+ emitRoutesManifest?: boolean;
283
+ /**
284
+ * Project output mode. Drives the V8-mode decision the build engine
285
+ * makes right after the no-SSR-without-adapter precondition check
286
+ * (sub-task 4.1b / issue #373):
287
+ *
288
+ * - `"static"` — declare a pure-static (SSG-only) project. Errors at
289
+ * build start if any route exports `prerender = false`, pointing
290
+ * at the offending route. Use this on projects that must never
291
+ * accidentally pick up an SSR route as a result of a copy-paste.
292
+ * - `"hybrid"` — declare a project that may host SSR routes. V8-on
293
+ * regardless of detection, even when no `prerender = false` route
294
+ * currently exists. Useful for projects that will add SSR routes
295
+ * later and want a stable build topology in the meantime.
296
+ * - `"auto"` (default) — detection-driven. Non-empty `prerender =
297
+ * false` route set => V8-on; empty => V8-off.
298
+ *
299
+ * Today's load-bearing role is the `"static"` precondition check.
300
+ * The V8-off branch does NOT skip V8 host startup on the shipping
301
+ * `zfb` binary — SSG still needs V8 to render pages. The flag exists
302
+ * as infrastructure for the future shipping path (Tauri sidecar /
303
+ * standalone SSR server). See the
304
+ * [Build engine docs](https://github.com/Takazudo/zudo-front-builder/blob/main/docs/src/content/docs/architecture/build-engine.mdx)
305
+ * for the gate decision table.
306
+ *
307
+ * Mirrors `Config::output` in crates/zfb/src/config.rs.
308
+ */
309
+ output?: OutputMode;
310
+ };
311
+ /**
312
+ * Project output mode.
313
+ *
314
+ * - `"static"` — pure-static (SSG-only); errors on detected SSR routes.
315
+ * - `"hybrid"` — may host SSR routes; V8-on regardless of detection.
316
+ * - `"auto"` — detection-driven; the default.
317
+ *
318
+ * Mirrors `OutputMode` in crates/zfb/src/config.rs.
319
+ */
320
+ export type OutputMode = "static" | "hybrid" | "auto";
321
+ /**
322
+ * Table-of-contents options. Wire via `markdown.toc` in `zfb.config.ts`.
323
+ *
324
+ * When present, a TOC `<ul>/<li>` list is inserted as the next sibling
325
+ * of the first heading whose text matches `heading` (case-insensitive).
326
+ * Each `<a href="#id">` links to the deduplicated `id` that
327
+ * `HeadingLinksPlugin` placed on the corresponding heading.
328
+ *
329
+ * Mirrors `TocConfig` in `crates/zfb-content/src/plugins/toc.rs`.
330
+ */
331
+ export type TocConfig = {
332
+ /**
333
+ * Heading text that triggers TOC insertion. Matched
334
+ * case-insensitively after whitespace trimming. Default: `"TOC"`.
335
+ */
336
+ heading?: string;
337
+ /**
338
+ * Number of heading levels to include starting from `<h2>`.
339
+ *
340
+ * - `1` — h2 only
341
+ * - `2` (default) — h2 + h3
342
+ * - `3` — h2, h3, h4
343
+ * - …up to `5` (h2 through h6)
344
+ */
345
+ maxDepth?: number;
346
+ };
347
+ /**
348
+ * Markdown / MDX parsing options.
349
+ *
350
+ * See [`ZfbConfig.markdown`] for the embed point. Today the knobs are
351
+ * [`gfm`](MarkdownConfig.gfm) and [`toc`](MarkdownConfig.toc); future
352
+ * markdown knobs (e.g. CommonMark variants, custom extensions) would
353
+ * also live here.
354
+ * See [`ZfbConfig.markdown`] for the embed point. Fields: [`gfm`] and
355
+ * [`externalLinks`]; future markdown knobs would also live here.
356
+ * See [`ZfbConfig.markdown`] for the embed point. Today the fields are
357
+ * [`gfm`](MarkdownConfig.gfm) and
358
+ * [`cjkFriendly`](MarkdownConfig.cjkFriendly); future markdown knobs
359
+ * (e.g. CommonMark variants, custom extensions) would also live here.
360
+ *
361
+ * Mirrors `MarkdownConfig` in crates/zfb/src/config.rs.
362
+ */
363
+ export type MarkdownConfig = {
364
+ /**
365
+ * Enable GFM constructs.
366
+ *
367
+ * Accepts three shapes:
368
+ *
369
+ * - `true` — turn every GFM construct ON (strikethrough, table,
370
+ * autolink-literal, task-list-item, footnote-definition).
371
+ * - `false` — turn every GFM construct OFF.
372
+ * - partial object — set individual fields explicitly; fields you
373
+ * omit fall back to the conservative-default values described
374
+ * below.
375
+ *
376
+ * When `markdown` itself is omitted entirely, the conservative
377
+ * default applies: `strikethrough: true`, `table: true`, every other
378
+ * GFM construct off. This is the smallest behavioural delta from
379
+ * zfb's historical effective state (table-only). Projects that want
380
+ * the full GFM surface should opt in with `gfm: true`.
381
+ */
382
+ gfm?: GfmFlag;
383
+ /**
384
+ * Table-of-contents options. When present, a `<ul>/<li>` list is
385
+ * inserted after the first heading whose text matches `heading`
386
+ * (default `"TOC"`, case-insensitive). Each link points to the
387
+ * deduplicated `id` that `HeadingLinksPlugin` placed on the heading.
388
+ *
389
+ * Omitting this field entirely leaves the build byte-for-byte identical
390
+ * to the pre-TOC build. See [`TocConfig`] for the available options.
391
+ *
392
+ * Mirrors `MarkdownConfig::toc` in crates/zfb/src/config.rs.
393
+ */
394
+ toc?: TocConfig;
395
+ /**
396
+ * External-link rewriter. When set, every `<a>` whose href is
397
+ * classified as external receives the configured `target` and `rel`
398
+ * attributes.
399
+ *
400
+ * An href is external when it is an absolute HTTP/HTTPS URL AND its
401
+ * origin differs from the top-level `site` URL (if `site` is
402
+ * configured). When `site` is absent, any absolute HTTP/HTTPS URL is
403
+ * treated as external.
404
+ *
405
+ * `mailto:`, `tel:`, and other non-HTTP(S) schemes are always left
406
+ * unchanged. Relative URLs (`/internal/`, `./file.mdx`, `#anchor`) are
407
+ * always internal.
408
+ *
409
+ * Omitting this field keeps the output byte-for-byte identical to the
410
+ * pre-feature behaviour.
411
+ *
412
+ * Mirrors `ExternalLinksConfig` in crates/zfb/src/config.rs.
413
+ */
414
+ externalLinks?: ExternalLinksConfig;
415
+ /**
416
+ * Enable CJK-friendly emphasis/strong re-tokenisation.
417
+ *
418
+ * CommonMark's left-/right-flanking delimiter-run rules treat CJK
419
+ * characters as non-whitespace non-punctuation, which causes `**foo**`
420
+ * adjacent to CJK text (e.g. `**テスト。**テスト`) to render as literal
421
+ * stars instead of `<strong>`. zfb's built-in `CjkFriendlyPlugin`
422
+ * corrects this post-parse.
423
+ *
424
+ * - **absent / `true` (default):** CJK-friendly re-tokenisation is
425
+ * on. Preserves today's behaviour — existing CJK-content sites are
426
+ * unaffected.
427
+ * - **`false`:** opt-out. `CjkFriendlyPlugin` is NOT added to the
428
+ * pipeline; emphasis markers adjacent to CJK characters follow base
429
+ * CommonMark flanking rules. Rarely the right choice; provided as
430
+ * an escape hatch for projects that need strict CommonMark output.
431
+ *
432
+ * **GFM strikethrough** (`~~foo~~`) at CJK boundaries is unaffected
433
+ * by this toggle — it is handled by markdown-rs's GFM tokeniser, not
434
+ * by `CjkFriendlyPlugin`, and works correctly in both modes.
435
+ *
436
+ * Mirrors `MarkdownConfig::cjk_friendly` in crates/zfb/src/config.rs.
437
+ */
438
+ cjkFriendly?: boolean;
439
+ };
440
+ /**
441
+ * Options for the external-link rewriter (port of `rehype-external-links`).
442
+ *
443
+ * All fields are optional; omitting a field applies the documented default.
444
+ *
445
+ * Mirrors `ExternalLinksConfig` in crates/zfb/src/config.rs.
446
+ */
447
+ export type ExternalLinksConfig = {
448
+ /**
449
+ * `rel` tokens applied to external links.
450
+ *
451
+ * Default: `["noopener", "noreferrer"]`.
452
+ *
453
+ * Tokens are deduplicated (case-insensitive) and merged with any
454
+ * existing `rel` attribute on the `<a>` element — existing tokens
455
+ * appear first.
456
+ */
457
+ rel?: string[];
458
+ /**
459
+ * `target` value for external links.
460
+ *
461
+ * Default: `"_blank"`.
462
+ */
463
+ target?: string;
464
+ };
465
+ /**
466
+ * Either the shorthand boolean form (`true` = all GFM constructs on,
467
+ * `false` = all off) or a partial object that toggles individual
468
+ * constructs.
469
+ *
470
+ * Mirrors `GfmFlag` in crates/zfb/src/config.rs.
471
+ */
472
+ export type GfmFlag = boolean | GfmConstructs;
473
+ /**
474
+ * Per-construct opt-in / opt-out for GFM. Every field is optional;
475
+ * omitted fields fall back to the conservative default
476
+ * (`strikethrough: true`, `table: true`, others `false`).
477
+ *
478
+ * Mirrors `GfmConstructs` in crates/zfb/src/config.rs.
479
+ */
480
+ export type GfmConstructs = {
481
+ /** GFM strikethrough (`~~text~~` → `<del>text</del>`). */
482
+ strikethrough?: boolean;
483
+ /** GFM pipe-style tables. */
484
+ table?: boolean;
485
+ /**
486
+ * GFM autolink literal — bare URLs like `https://example.com` become
487
+ * clickable links without `<…>` brackets.
488
+ */
489
+ autolinkLiteral?: boolean;
490
+ /** GFM task list items (`- [x]` / `- [ ]`). */
491
+ taskListItem?: boolean;
492
+ /** GFM footnote definitions (`[^ref]: …`). */
493
+ footnoteDefinition?: boolean;
494
+ };
495
+ /**
496
+ * What to do when a `.md`/`.mdx` link cannot be resolved.
497
+ *
498
+ * Mirrors `OnBrokenLinks` in crates/zfb/src/config.rs.
499
+ */
500
+ export type OnBrokenLinks = "warn" | "error" | "ignore";
501
+ /**
502
+ * Config for the markdown link resolver. See
503
+ * [`ZfbConfig.resolveMarkdownLinks`] for the design rationale.
504
+ */
505
+ export type ResolveMarkdownLinksConfig = {
506
+ /** Whether to enable link resolution. Default: `false`. */
507
+ enabled?: boolean;
508
+ /**
509
+ * Legacy single-dir field. Used only when [`dirs`] is empty. When
510
+ * non-empty, scanned against the hard-coded `/docs/` route prefix.
511
+ */
512
+ docsDir?: string;
513
+ /**
514
+ * Explicit per-dir source map. Each entry is one collection (e.g.
515
+ * EN docs at `src/content/docs/` → `/docs/`, JA docs at
516
+ * `src/content/docs-ja/` → `/ja/docs/`). Takes precedence over
517
+ * [`docsDir`] when non-empty.
518
+ */
519
+ dirs?: ResolveMarkdownLinksDir[];
520
+ /** What to do with unresolved `.md`/`.mdx` links. Default: `"warn"`. */
521
+ onBrokenLinks?: OnBrokenLinks;
522
+ };
523
+ /** One source-dir entry for [`ResolveMarkdownLinksConfig.dirs`]. */
524
+ export type ResolveMarkdownLinksDir = {
525
+ /**
526
+ * Directory (relative to project root) whose `.md`/`.mdx` files are
527
+ * scanned. Must be relative and must not escape the root via `..`.
528
+ */
529
+ dir: string;
530
+ /**
531
+ * Route prefix prepended to each file's slug. Include leading and
532
+ * trailing slashes (e.g. `"/docs/"` or `"/ja/docs/"`).
533
+ */
534
+ routePrefix: string;
535
+ };
536
+ /**
537
+ * Identity helper: returns the supplied config as-is, but typed against
538
+ * [`ZfbConfig`]. Use as the default export of `zfb.config.ts` so editors
539
+ * surface field-level types and typos surface at compile time.
540
+ */
541
+ export declare function defineConfig(config: ZfbConfig): ZfbConfig;
542
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG;IAC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zD"}
package/dist/config.js ADDED
@@ -0,0 +1,24 @@
1
+ // `zfb/config` — TypeScript helper for the `zfb.config.ts` form.
2
+ //
3
+ // The zfb config loader (`crates/zfb/src/config.rs`) accepts both
4
+ // `zfb.config.ts` and `zfb.config.json`; JSON wins when both files are
5
+ // present, which is the back-compat path for projects predating the TS
6
+ // loader. New projects should prefer the TS form for editor types and
7
+ // `defineConfig` autocomplete.
8
+ //
9
+ // At parse time, zfb bundles the user's `zfb.config.ts` with esbuild and
10
+ // aliases this `zfb/config` import to an internal stub that re-exports
11
+ // `defineConfig` as the identity function — so a user project does not
12
+ // need the `zfb` npm package installed locally just to be parsed.
13
+ //
14
+ // The shape mirrors the Rust `Config` struct one-for-one. Keep them in
15
+ // sync; the `defineConfig` identity helper is the single anchor point.
16
+ /**
17
+ * Identity helper: returns the supplied config as-is, but typed against
18
+ * [`ZfbConfig`]. Use as the default export of `zfb.config.ts` so editors
19
+ * surface field-level types and typos surface at compile time.
20
+ */
21
+ export function defineConfig(config) {
22
+ return config;
23
+ }
24
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,kEAAkE;AAClE,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,+BAA+B;AAC/B,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,uEAAuE;AACvE,kEAAkE;AAClE,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AAujBvE;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC"}