@jk2908/mdsrc 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 - 2026-05-21
4
+
5
+ - Breaking: moved markdown customization under the `markdown` key, replacing the old root-level `plugins` option with `markdown.plugins`.
6
+ - Replaced the HTML renderer dependency with `markdown-it-ts` and added `markdown.config` support for renderer options.
7
+ - Re-exported `MarkdownItConfig` from `@jk2908/mdsrc` so consumers can type markdown renderer config without importing from `markdown-it-ts` directly.
8
+ - Updated the README examples to document the nested markdown config and the default renderer options merge.
9
+
3
10
  ## 0.2.0 - 2026-05-07
4
11
 
5
12
  - Breaking: replaced the generated `body` field with `html` and `markdown` on every entry.
package/README.md CHANGED
@@ -11,14 +11,21 @@ npm install @jk2908/mdsrc
11
11
  ## Usage
12
12
 
13
13
  ```ts
14
- import plugin from '@jk2908/mdsrc'
14
+ import plugin, { type MarkdownItConfig } from '@jk2908/mdsrc'
15
15
  import comark from '@comark/markdown-it'
16
16
  import { defineConfig } from 'vite'
17
17
 
18
+ const markdownItConfig: MarkdownItConfig = {
19
+ linkify: true,
20
+ }
21
+
18
22
  export default defineConfig({
19
23
  plugins: [
20
24
  plugin({
21
- plugins: [comark],
25
+ markdown: {
26
+ plugins: [comark],
27
+ config: markdownItConfig,
28
+ },
22
29
  collections: [
23
30
  {
24
31
  dir: 'content',
@@ -33,15 +40,16 @@ export default defineConfig({
33
40
  })
34
41
  ```
35
42
 
36
- The plugin reads markdown content, validates frontmatter against your schema, and generates typed modules during build and watch. Root config uses `collections`, optional `plugins`, and `logger`. Collection config uses `name`, `dir`, and `schema`.
43
+ The plugin reads markdown content, validates frontmatter against your schema, and generates typed modules during build and watch. Root config uses `collections`, optional `markdown`, and `logger`. Collection config uses `name`, `dir`, and `schema`.
37
44
 
38
45
  Each entry exports both `html` and `markdown`.
39
46
 
40
- - `html` is rendered with `markdown-it`, with hard line breaks preserved.
47
+ - `html` is rendered with `markdown-it-ts`, with hard line breaks preserved by default.
41
48
  - Raw HTML is escaped by default because the renderer runs with `html: false`.
42
49
  - `markdown` preserves the original body for custom renderers like `@comark/react`.
43
50
 
44
- Root `plugins` accepts markdown-it plugins directly or tuples like `[plugin, ...args]` and applies them to every collection.
51
+ Use `markdown.plugins` for `markdown-it-ts` compatible plugins, and `markdown.config` to pass renderer options.
52
+ `MarkdownItConfig` is re-exported from `@jk2908/mdsrc`, and `markdown.config` is merged with the default renderer options `{ html: false, breaks: true }`.
45
53
 
46
54
  See `examples/basic` for the default HTML output flow and `examples/components` for the shared `@comark/markdown-it` plugin used with React.
47
55
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from 'vite';
2
2
  import type { BuildContext, PluginConfig } from './types.js';
3
+ export type { MarkdownItConfig } from './types.js';
3
4
  /**
4
5
  * Read every markdown file in a collection and turn it into the raw entry shape
5
6
  * add mdsrc metadata like slug and filename alongside the trimmed body
@@ -14,7 +15,7 @@ export declare function create(dir: string, buildContext: BuildContext): Promise
14
15
  markdown: string;
15
16
  }[]>;
16
17
  /**
17
- * Build the vite plugin that validates collections and writes the generated modules
18
+ * Build the Vite plugin that validates collections and writes the generated modules
18
19
  * keep the runtime data and declaration files in the same pass
19
20
  * resolve package imports from the generated directory
20
21
  */
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { realpathSync } from "node:fs";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
- import MarkdownIt from "markdown-it";
5
+ import MarkdownIt from "markdown-it-ts";
6
6
 
7
7
  // src/config.ts
8
8
  var NAME = "mdsrc";
@@ -116,6 +116,10 @@ function debounce(fn, wait) {
116
116
 
117
117
  // src/index.ts
118
118
  var fileCache = new Map;
119
+ var DEFAULT_MARKDOWN_CONFIG = {
120
+ html: false,
121
+ breaks: true
122
+ };
119
123
  function toModuleName(name) {
120
124
  return name.toLowerCase();
121
125
  }
@@ -136,13 +140,13 @@ function parse(content) {
136
140
  return { metadata, body };
137
141
  }
138
142
  async function create(dir, buildContext) {
139
- const { logger: logger2, plugins = [] } = buildContext;
143
+ const { logger: logger2 } = buildContext;
140
144
  const markdown = new MarkdownIt({
141
- html: false,
142
- breaks: true
145
+ ...DEFAULT_MARKDOWN_CONFIG,
146
+ ...buildContext.markdown?.config
143
147
  });
144
- for (const plugin of plugins) {
145
- if (typeof plugin === "function") {
148
+ for (const plugin of buildContext.markdown?.plugins ?? []) {
149
+ if (typeof plugin === "function" || "default" in plugin) {
146
150
  markdown.use(plugin);
147
151
  continue;
148
152
  }
@@ -386,7 +390,7 @@ function mdsrc(config) {
386
390
  const isWatchedFile = (filePath) => watchedRoots.some((root) => resolveWatchFile(filePath).startsWith(root));
387
391
  const buildContext = {
388
392
  logger: logger2,
389
- plugins: config.plugins,
393
+ markdown: config.markdown,
390
394
  outDir,
391
395
  names: []
392
396
  };
@@ -471,4 +475,4 @@ export {
471
475
  create
472
476
  };
473
477
 
474
- //# debugId=4A1919CF4AE2D2C864756E2164756E21
478
+ //# debugId=99F5D645BFF7D65564756E2164756E21
package/dist/index.js.map CHANGED
@@ -2,12 +2,12 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/config.ts", "../src/logger.ts", "../src/utils.ts"],
4
4
  "sourcesContent": [
5
- "import { realpathSync } from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { Plugin, ViteDevServer } from 'vite'\n\nimport MarkdownIt from 'markdown-it'\n\nimport type {\n\tBuildContext,\n\tCollection,\n\tEntries,\n\tIssue,\n\tPluginConfig,\n\tRaw,\n\tResult,\n\tSchema,\n} from './types.js'\nimport { GENERATED_DIR, PKG_NAME } from './config.js'\nimport { Logger } from './logger.js'\nimport { capitalise, debounce, pluralise } from './utils.js'\n\nconst fileCache = new Map<string, string>()\n\nfunction toModuleName(name: string) {\n\treturn name.toLowerCase()\n}\n\n/**\n * Split a markdown file into frontmatter data and the body content\n * keep the format small so the parser stays easy to trust\n * fail fast if the opening fence is missing\n */\nfunction parse(content: string) {\n\t// look for one fenced frontmatter block right at the top\n\t// leave the rest of the markdown body alone\n\tconst regex = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---([\\s\\S]*)$/\n\tconst match = content.match(regex)\n\tconst metadata: Entries = {}\n\n\tif (!match) throw new Error('Invalid frontmatter')\n\n\tconst [, frontmatter, body] = match\n\n\tif (frontmatter) {\n\t\t// treat each line as a simple key: value pair\n\t\t// this is a small subset, not full yaml\n\t\tfor (const line of frontmatter.split('\\n')) {\n\t\t\tconst [key, value] = line.split(': ').map(str => str.trim())\n\t\t\tmetadata[key as keyof Entries] = value\n\t\t}\n\t}\n\n\treturn { metadata, body }\n}\n\n/**\n * Read every markdown file in a collection and turn it into the raw entry shape\n * add mdsrc metadata like slug and filename alongside the trimmed body\n * return an empty list if the directory read fails\n */\nexport async function create(dir: string, buildContext: BuildContext) {\n\tconst { logger, plugins = [] } = buildContext\n\n\tconst markdown = new MarkdownIt({\n\t\thtml: false,\n\t\tbreaks: true,\n\t})\n\n\tfor (const plugin of plugins) {\n\t\tif (typeof plugin === 'function') {\n\t\t\tmarkdown.use(plugin)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst [applyPlugin, ...params] = plugin\n\t\tmarkdown.use(applyPlugin, ...params)\n\t}\n\n\ttry {\n\t\t// only pick up markdown files from this directory\n\t\t// leave everything else alone\n\t\tconst files = (await fs.readdir(dir)).filter(\n\t\t\t(file: string) => path.extname(file) === '.md',\n\t\t)\n\t\tconst filePaths = files.map(file => path.join(dir, file))\n\n\t\tif (!files.length) {\n\t\t\tconsole.warn(`mdsrc: ${dir} is empty`)\n\t\t\treturn []\n\t\t}\n\n\t\treturn Promise.all(\n\t\t\tfilePaths.map(async filePath => {\n\t\t\t\tconst file = path.basename(filePath)\n\n\t\t\t\t// keep the parsed fields, body, and mdsrc metadata together\n\t\t\t\t// build the slug from the filename\n\t\t\t\tconst parsed = parse(await fs.readFile(filePath, 'utf-8'))\n\n\t\t\t\tconst body = parsed.body ? parsed.body.trim() : ''\n\n\t\t\t\treturn {\n\t\t\t\t\t...parsed.metadata,\n\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\tslug: path.basename(file, '.md').toLowerCase().replace(/\\s+/g, '-'),\n\t\t\t\t\t\tfilename: file,\n\t\t\t\t\t},\n\t\t\t\t\thtml: body ? markdown.render(body).trim() : body,\n\t\t\t\t\tmarkdown: body,\n\t\t\t\t} satisfies Raw\n\t\t\t}),\n\t\t)\n\t} catch (err) {\n\t\tlogger.error('[create]: failed to create entries', err)\n\t\treturn []\n\t}\n}\n\n/**\n * Write a file only if the content has changed since the last build\n */\nasync function maybeWrite(filePath: string, content: string) {\n\tconst cached = fileCache.get(filePath)\n\n\tif (cached === content) {\n\t\ttry {\n\t\t\tawait fs.access(filePath)\n\t\t\treturn false\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {\n\t\t\t\tthrow err\n\t\t\t}\n\n\t\t\t// file was deleted since the last build, fall through and write it again\n\t\t}\n\t}\n\n\tif (cached === undefined) {\n\t\ttry {\n\t\t\tconst current = await fs.readFile(filePath, 'utf-8')\n\t\t\tfileCache.set(filePath, current)\n\n\t\t\tif (current === content) {\n\t\t\t\tfileCache.set(filePath, content)\n\t\t\t\treturn false\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {\n\t\t\t\tthrow err\n\t\t\t}\n\t\t}\n\t}\n\n\t// file is new or changed since the last build, write it and refresh the cache\n\tawait fs.writeFile(filePath, content)\n\tfileCache.set(filePath, content)\n\n\treturn true\n}\n\n/**\n * Check one entry against the declared schema and coerce what can be coerced\n * leave missing optional keys alone instead of treating them as errors\n * normalise dates to iso strings for output\n */\nfunction validate(input: Entries, schema: Schema) {\n\t// keep valid values separate so bad fields never sneak into output\n\tconst validated: Entries = {}\n\t// collect every problem so one pass can report the lot\n\tconst issues: Issue[] = []\n\n\t// bail out early if the frontmatter is not even an object\n\tif (typeof input !== 'object' || input === null) {\n\t\tissues.push({ message: 'Input must be an object' })\n\t\treturn { issues } satisfies Result<Entries>\n\t}\n\n\t// drive validation from the schema so the rules always stay in charge\n\tfor (const key in schema) {\n\t\tconst entry = schema[key]\n\n\t\t// if the key is missing, only complain when the schema says it must exist\n\t\tif (!(key in input)) {\n\t\t\tif (!entry.optional) {\n\t\t\t\tissues.push({ message: `Missing required key: ${key}` })\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// once the key exists, coerce it into the shape the schema expects\n\t\tconst value = input[key]\n\n\t\tswitch (entry.type) {\n\t\t\tcase 'string': {\n\t\t\t\t// strings just need the basic type check and any length limits\n\t\t\t\tif (typeof value !== 'string') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a string` })\n\t\t\t\t} else {\n\t\t\t\t\tif (entry.minLength && value.length < entry.minLength) {\n\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\tmessage: `Key ${key} must be at least ${entry.minLength} characters`,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\tif (entry.maxLength && value.length > entry.maxLength) {\n\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\tmessage: `Key ${key} must be at most ${entry.maxLength} characters`,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\tvalidated[key] = value\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tlet num = value\n\n\t\t\t\t// frontmatter usually starts life as text, so numeric strings still count\n\t\t\t\tif (typeof value === 'string' && !Number.isNaN(Number(value))) {\n\t\t\t\t\tnum = Number(value)\n\t\t\t\t}\n\n\t\t\t\tif (typeof num !== 'number') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a number` })\n\t\t\t\t} else {\n\t\t\t\t\tvalidated[key] = num\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'boolean': {\n\t\t\t\tlet bool = value\n\t\t\t\t// booleans often come through as the words true or false\n\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\tif (value.toLowerCase() === 'true') {\n\t\t\t\t\t\tbool = true\n\t\t\t\t\t} else if (value.toLowerCase() === 'false') {\n\t\t\t\t\t\tbool = false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (typeof bool !== 'boolean') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a boolean` })\n\t\t\t\t} else {\n\t\t\t\t\tvalidated[key] = bool\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'date': {\n\t\t\t\t// keep dates as iso strings because that is what generated output exposes\n\t\t\t\tif (typeof value !== 'string') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a date` })\n\t\t\t\t} else {\n\t\t\t\t\tconst date = new Date(value)\n\n\t\t\t\t\tif (Number.isNaN(date.getTime())) {\n\t\t\t\t\t\tissues.push({ message: `Key ${key} must be a valid date` })\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalidated[key] = date.toISOString()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// hand back the clean entry when validation passes\n\t// otherwise return the full issue list\n\treturn (issues.length ? { issues } : { value: validated }) satisfies Result<Entries>\n}\n\nasync function build(src: Collection[], buildContext: BuildContext) {\n\tconst { logger, outDir } = buildContext\n\tlet names: string[] = []\n\n\t// keep each validated collection beside its schema so emit stays in sync\n\tconst collections: Record<\n\t\tstring,\n\t\t{\n\t\t\titems: Raw[]\n\t\t\tschema: Schema\n\t\t}\n\t> = {}\n\n\ttry {\n\t\tif (!outDir) throw new Error('Output directory is not defined')\n\n\t\t// make sure the output directory exists before the writes begin\n\t\t// that way the emit step can stay simple\n\t\tawait fs.mkdir(outDir, { recursive: true })\n\n\t\t// read and validate every collection before writing anything out\n\t\t// this keeps the js and dts outputs in step\n\t\tfor (const collection of src) {\n\t\t\tconst raw = await create(path.join(process.cwd(), collection.dir), buildContext)\n\n\t\t\t// check each raw item before it makes it into the generated collection\n\t\t\t// bad entries get logged and dropped\n\t\t\tconst validated = await Promise.all(\n\t\t\t\traw.map(async item => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { html, markdown, __mdsrc, ...metadata } = item\n\t\t\t\t\t\tconst res = validate(metadata, collection.schema)\n\n\t\t\t\t\t\tif (res.issues) throw new Error(JSON.stringify(res.issues, null, 2))\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tmarkdown,\n\t\t\t\t\t\t\t...res.value,\n\t\t\t\t\t\t\t__mdsrc,\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t`[buildStart]: failed to validate item in ${collection.name}`,\n\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t)\n\n\t\t\tcollections[collection.name] = {\n\t\t\t\t// keep the cleaned items with the schema they came from\n\t\t\t\t// both js and dts generation read from this shape\n\t\t\t\titems: validated.filter(e => e !== null),\n\t\t\t\tschema: collection.schema,\n\t\t\t}\n\t\t}\n\n\t\t// take the collection names after validation has settled\n\t\t// every generated file then works from the same list\n\t\tnames = Object.keys(collections)\n\t\t// queue the file writes first so the emit phase can run together\n\t\t// wait for them once every output is ready\n\t\tconst promises = []\n\n\t\t// build the type file from the schema rather than the observed data\n\t\t// that keeps optional fields and date output honest\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'types.ts'),\n\t\t\t\t`\n\t\t\t\t\t${names\n\t\t\t\t\t\t// make one named type per collection so the dts mirrors the js surface.\n\t\t\t\t\t\t// html and markdown are always present on generated entries\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport type ${capitalise(name)} = {\n\t\t\t\t\t\t\t\t\thtml: string\n\t\t\t\t\t\t\t\t\tmarkdown: string\n\t\t\t\t\t\t\t\t\t${Object.entries(collections[name].schema)\n\t\t\t\t\t\t\t\t\t\t// turn each schema field into a ts property line\n\t\t\t\t\t\t\t\t\t\t// keep optional markers and date strings in step with validation\n\t\t\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t\t\t([key, entry]) =>\n\t\t\t\t\t\t\t\t\t\t\t\t`${key}${entry.optional ? '?' : ''}: ${entry.type === 'date' ? 'string' : entry.type}`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.join('\\n ')}\n\t\t\t\t\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\t\t\t\t\tslug: string\n\t\t\t\t\t\t\t\t\t\tfilename: string\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// write the package surface separately so consumers get typed named exports\n\t\t// this mirrors the generated js entry file\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.d.ts'),\n\t\t\t\t`\t\n\t\t\t\t\timport type { ${names.map(name => capitalise(name)).join(', ')} } from './types.js'\n\n\t\t\t\t\t${names\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}\n\n\t\t\t\t\tdeclare module '${PKG_NAME}' {\n\t\t\t\t\t\t${names\n\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.join('\\n\\n')}\n\t\t\t\t\t}\n\t\t\t\t`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// serialise each validated collection as a plain module for vite to load\n\t\t// empty collections still export a stable array shape\n\t\tfor (const name of names) {\n\t\t\tconst collection = collections[name]?.items\n\t\t\tconst fileName = toModuleName(name)\n\n\t\t\tpromises.push(\n\t\t\t\tmaybeWrite(\n\t\t\t\t\tpath.join(outDir, `${fileName}.js`),\n\t\t\t\t\t`export const all${capitalise(pluralise(name, 2))} = ${collection?.length ? JSON.stringify(collection) : '[]'}`.trim(),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\t// stitch the per-collection modules into the public js entrypoint\n\t\t// this is the file the root package import resolves to\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.js'),\n\t\t\t\tnames.map(name => `export * from './${toModuleName(name)}.js'`).join('\\n'),\n\t\t\t),\n\t\t)\n\n\t\t// flush every generated artifact once all the content is ready\n\t\t// let any failed write fail the build\n\t\tconst writes = await Promise.all(promises)\n\t\tbuildContext.names = names\n\n\t\treturn writes.some(changed => changed)\n\t} catch (err) {\n\t\tlogger.error('[build]: failed to generate data', err)\n\t\tthrow err\n\t}\n}\n\n// convert watcher paths to a consistent slash format before comparing them\nconst normaliseWatchPath = (p: string) => p.replace(/\\\\/g, '/')\n\n/**\n * Build the vite plugin that validates collections and writes the generated modules\n * keep the runtime data and declaration files in the same pass\n * resolve package imports from the generated directory\n */\nexport default function mdsrc(config: PluginConfig): Plugin {\n\tconst src = config.collections\n\n\t// use one logger for the whole build so every step reports the same way\n\t// stay chatty outside production\n\tconst logger = new Logger(\n\t\tconfig.logger?.level ?? (process.env.NODE_ENV === 'production' ? 'error' : 'debug'),\n\t)\n\n\t// write generated files into a hidden folder at the project root\n\t// keep the generated surface out of src\n\tconst outDir = path.join(process.cwd(), GENERATED_DIR)\n\tconst watchRoot = normaliseWatchPath(realpathSync.native(process.cwd()))\n\tconst watchedRoots = src.map(c => `${normaliseWatchPath(path.join(watchRoot, c.dir))}/`)\n\n\t// watcher events can arrive through symlinked paths like /var while cwd has\n\t// already resolved to /private/var, so canonicalise the parent dir once and\n\t// reattach the file name for stable prefix checks\n\tconst resolveWatchFile = (filePath: string) => {\n\t\tconst absolutePath = path.resolve(watchRoot, filePath)\n\t\tconst parentPath = path.dirname(absolutePath)\n\n\t\ttry {\n\t\t\tconst resolvedParentPath = normaliseWatchPath(realpathSync.native(parentPath))\n\t\t\treturn normaliseWatchPath(\n\t\t\t\tpath.join(resolvedParentPath, path.basename(absolutePath)),\n\t\t\t)\n\t\t} catch {\n\t\t\treturn normaliseWatchPath(absolutePath)\n\t\t}\n\t}\n\n\tconst isWatchedFile = (filePath: string) =>\n\t\twatchedRoots.some(root => resolveWatchFile(filePath).startsWith(root))\n\n\t// pass shared build tools into helpers without dragging lots of state around\n\t// keep the helper signatures small\n\tconst buildContext = {\n\t\tlogger,\n\t\tplugins: config.plugins,\n\t\toutDir,\n\t\tnames: [],\n\t} satisfies BuildContext\n\n\tlet rebuildRunning = false\n\tlet rebuildQueued = false\n\tlet rebuildReason = 'change'\n\tconst rebuild = debounce((event: string, filePath: string) => {\n\t\tconst queue = () => {\n\t\t\tvoid (async () => {\n\t\t\t\t// collapse bursts of file events into one active rebuild plus a single\n\t\t\t\t// queued rerun when changes land mid-build\n\t\t\t\tif (rebuildRunning) {\n\t\t\t\t\trebuildQueued = true\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\trebuildRunning = true\n\n\t\t\t\tdo {\n\t\t\t\t\trebuildQueued = false\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst changed = await build(src, buildContext)\n\n\t\t\t\t\t\tif (changed) logger.info(`[watch]: content rebuilt (${rebuildReason})`)\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error('[watch] content rebuild failed', err)\n\t\t\t\t\t}\n\t\t\t\t} while (rebuildQueued)\n\n\t\t\t\trebuildRunning = false\n\t\t\t})()\n\t\t}\n\n\t\t// ignore anything outside the watched content dirs\n\t\tif (!isWatchedFile(filePath)) return\n\n\t\tconst file = resolveWatchFile(filePath)\n\n\t\trebuildReason = `${event}: ${path.relative(watchRoot, file)}`\n\t\tqueue()\n\t}, 75)\n\n\treturn {\n\t\tname: 'mdsrc',\n\t\tenforce: 'pre',\n\t\tconfig(viteConfig) {\n\t\t\tviteConfig.optimizeDeps ??= {}\n\t\t\tviteConfig.optimizeDeps.exclude = [\n\t\t\t\t...new Set([...(viteConfig.optimizeDeps.exclude ?? []), PKG_NAME]),\n\t\t\t]\n\n\t\t\tviteConfig.resolve ??= {}\n\n\t\t\tif (Array.isArray(viteConfig.resolve.alias)) {\n\t\t\t\tviteConfig.resolve.alias = [\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t{\n\t\t\t\t\t\tfind: PKG_NAME,\n\t\t\t\t\t\treplacement: path.join(outDir, 'index.js'),\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t} else {\n\t\t\t\tviteConfig.resolve.alias = {\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t[PKG_NAME]: path.join(outDir, 'index.js'),\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync buildStart() {\n\t\t\tawait build(src, buildContext)\n\t\t},\n\t\tconfigureServer(server: ViteDevServer) {\n\t\t\tlogger.info(\n\t\t\t\t`[configureServer]: Watching for changes in ./${src.map(c => c.dir).join(', ')}...`,\n\t\t\t)\n\n\t\t\tserver.watcher\n\t\t\t\t.on('add', (p: string) => rebuild('add', p))\n\t\t\t\t.on('change', (p: string) => rebuild('change', p))\n\t\t\t\t.on('unlink', (p: string) => rebuild('unlink', p))\n\t\t},\n\t\tresolveId(id) {\n\t\t\t// point imports at generated files rather than source files\n\t\t\t// that makes the package behave like a normal module\n\t\t\tif (id === PKG_NAME) {\n\t\t\t\treturn path.join(outDir, 'index.js')\n\t\t\t}\n\n\t\t\tif (id.startsWith(`${PKG_NAME}/`)) {\n\t\t\t\t// allow collection subpath imports once the build knows their names\n\t\t\t\t// leave unknown subpaths unresolved\n\t\t\t\tconst subpath = id.slice(PKG_NAME.length + 1)\n\t\t\t\tconst match = buildContext.names.find(\n\t\t\t\t\tname => name === subpath || toModuleName(name) === subpath,\n\t\t\t\t)\n\n\t\t\t\tif (match) {\n\t\t\t\t\treturn path.join(outDir, `${toModuleName(match)}.js`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\t}\n}\n",
5
+ "import { realpathSync } from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { Plugin, ViteDevServer } from 'vite'\n\nimport MarkdownIt from 'markdown-it-ts'\n\nimport type {\n\tBuildContext,\n\tCollection,\n\tEntries,\n\tIssue,\n\tMarkdownItConfig,\n\tPluginConfig,\n\tRaw,\n\tResult,\n\tSchema,\n} from './types.js'\nimport { GENERATED_DIR, PKG_NAME } from './config.js'\nimport { Logger } from './logger.js'\nimport { capitalise, debounce, pluralise } from './utils.js'\n\nconst fileCache = new Map<string, string>()\n\nconst DEFAULT_MARKDOWN_CONFIG = {\n\thtml: false,\n\tbreaks: true,\n} satisfies MarkdownItConfig\n\nexport type { MarkdownItConfig } from './types.js'\n\nfunction toModuleName(name: string) {\n\treturn name.toLowerCase()\n}\n\n/**\n * Split a markdown file into frontmatter data and the body content\n * keep the format small so the parser stays easy to trust\n * fail fast if the opening fence is missing\n */\nfunction parse(content: string) {\n\t// look for one fenced frontmatter block right at the top\n\t// leave the rest of the markdown body alone\n\tconst regex = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---([\\s\\S]*)$/\n\tconst match = content.match(regex)\n\tconst metadata: Entries = {}\n\n\tif (!match) throw new Error('Invalid frontmatter')\n\n\tconst [, frontmatter, body] = match\n\n\tif (frontmatter) {\n\t\t// treat each line as a simple key: value pair\n\t\t// this is a small subset, not full yaml\n\t\tfor (const line of frontmatter.split('\\n')) {\n\t\t\tconst [key, value] = line.split(': ').map(str => str.trim())\n\t\t\tmetadata[key as keyof Entries] = value\n\t\t}\n\t}\n\n\treturn { metadata, body }\n}\n\n/**\n * Read every markdown file in a collection and turn it into the raw entry shape\n * add mdsrc metadata like slug and filename alongside the trimmed body\n * return an empty list if the directory read fails\n */\nexport async function create(dir: string, buildContext: BuildContext) {\n\tconst { logger } = buildContext\n\tconst markdown = new MarkdownIt({\n\t\t...DEFAULT_MARKDOWN_CONFIG,\n\t\t...buildContext.markdown?.config,\n\t})\n\n\tfor (const plugin of buildContext.markdown?.plugins ?? []) {\n\t\tif (typeof plugin === 'function' || 'default' in plugin) {\n\t\t\tmarkdown.use(plugin)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst [applyPlugin, ...params] = plugin\n\t\tmarkdown.use(applyPlugin, ...params)\n\t}\n\n\ttry {\n\t\t// only pick up markdown files from this directory\n\t\t// leave everything else alone\n\t\tconst files = (await fs.readdir(dir)).filter(\n\t\t\t(file: string) => path.extname(file) === '.md',\n\t\t)\n\t\tconst filePaths = files.map(file => path.join(dir, file))\n\n\t\tif (!files.length) {\n\t\t\tconsole.warn(`mdsrc: ${dir} is empty`)\n\t\t\treturn []\n\t\t}\n\n\t\treturn Promise.all(\n\t\t\tfilePaths.map(async filePath => {\n\t\t\t\tconst file = path.basename(filePath)\n\n\t\t\t\t// keep the parsed fields, body, and mdsrc metadata together\n\t\t\t\t// build the slug from the filename\n\t\t\t\tconst parsed = parse(await fs.readFile(filePath, 'utf-8'))\n\n\t\t\t\tconst body = parsed.body ? parsed.body.trim() : ''\n\n\t\t\t\treturn {\n\t\t\t\t\t...parsed.metadata,\n\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\tslug: path.basename(file, '.md').toLowerCase().replace(/\\s+/g, '-'),\n\t\t\t\t\t\tfilename: file,\n\t\t\t\t\t},\n\t\t\t\t\thtml: body ? markdown.render(body).trim() : body,\n\t\t\t\t\tmarkdown: body,\n\t\t\t\t} satisfies Raw\n\t\t\t}),\n\t\t)\n\t} catch (err) {\n\t\tlogger.error('[create]: failed to create entries', err)\n\t\treturn []\n\t}\n}\n\n/**\n * Write a file only if the content has changed since the last build\n */\nasync function maybeWrite(filePath: string, content: string) {\n\tconst cached = fileCache.get(filePath)\n\n\tif (cached === content) {\n\t\ttry {\n\t\t\tawait fs.access(filePath)\n\t\t\treturn false\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {\n\t\t\t\tthrow err\n\t\t\t}\n\n\t\t\t// file was deleted since the last build, fall through and write it again\n\t\t}\n\t}\n\n\tif (cached === undefined) {\n\t\ttry {\n\t\t\tconst current = await fs.readFile(filePath, 'utf-8')\n\t\t\tfileCache.set(filePath, current)\n\n\t\t\tif (current === content) {\n\t\t\t\tfileCache.set(filePath, content)\n\t\t\t\treturn false\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {\n\t\t\t\tthrow err\n\t\t\t}\n\t\t}\n\t}\n\n\t// file is new or changed since the last build, write it and refresh the cache\n\tawait fs.writeFile(filePath, content)\n\tfileCache.set(filePath, content)\n\n\treturn true\n}\n\n/**\n * Check one entry against the declared schema and coerce what can be coerced\n * leave missing optional keys alone instead of treating them as errors\n * normalise dates to iso strings for output\n */\nfunction validate(input: Entries, schema: Schema) {\n\t// keep valid values separate so bad fields never sneak into output\n\tconst validated: Entries = {}\n\t// collect every problem so one pass can report the lot\n\tconst issues: Issue[] = []\n\n\t// bail out early if the frontmatter is not even an object\n\tif (typeof input !== 'object' || input === null) {\n\t\tissues.push({ message: 'Input must be an object' })\n\t\treturn { issues } satisfies Result<Entries>\n\t}\n\n\t// drive validation from the schema so the rules always stay in charge\n\tfor (const key in schema) {\n\t\tconst entry = schema[key]\n\n\t\t// if the key is missing, only complain when the schema says it must exist\n\t\tif (!(key in input)) {\n\t\t\tif (!entry.optional) {\n\t\t\t\tissues.push({ message: `Missing required key: ${key}` })\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// once the key exists, coerce it into the shape the schema expects\n\t\tconst value = input[key]\n\n\t\tswitch (entry.type) {\n\t\t\tcase 'string': {\n\t\t\t\t// strings just need the basic type check and any length limits\n\t\t\t\tif (typeof value !== 'string') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a string` })\n\t\t\t\t} else {\n\t\t\t\t\tif (entry.minLength && value.length < entry.minLength) {\n\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\tmessage: `Key ${key} must be at least ${entry.minLength} characters`,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\tif (entry.maxLength && value.length > entry.maxLength) {\n\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\tmessage: `Key ${key} must be at most ${entry.maxLength} characters`,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\tvalidated[key] = value\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tlet num = value\n\n\t\t\t\t// frontmatter usually starts life as text, so numeric strings still count\n\t\t\t\tif (typeof value === 'string' && !Number.isNaN(Number(value))) {\n\t\t\t\t\tnum = Number(value)\n\t\t\t\t}\n\n\t\t\t\tif (typeof num !== 'number') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a number` })\n\t\t\t\t} else {\n\t\t\t\t\tvalidated[key] = num\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'boolean': {\n\t\t\t\tlet bool = value\n\t\t\t\t// booleans often come through as the words true or false\n\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\tif (value.toLowerCase() === 'true') {\n\t\t\t\t\t\tbool = true\n\t\t\t\t\t} else if (value.toLowerCase() === 'false') {\n\t\t\t\t\t\tbool = false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (typeof bool !== 'boolean') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a boolean` })\n\t\t\t\t} else {\n\t\t\t\t\tvalidated[key] = bool\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'date': {\n\t\t\t\t// keep dates as iso strings because that is what generated output exposes\n\t\t\t\tif (typeof value !== 'string') {\n\t\t\t\t\tissues.push({ message: `Key ${key} must be a date` })\n\t\t\t\t} else {\n\t\t\t\t\tconst date = new Date(value)\n\n\t\t\t\t\tif (Number.isNaN(date.getTime())) {\n\t\t\t\t\t\tissues.push({ message: `Key ${key} must be a valid date` })\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalidated[key] = date.toISOString()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// hand back the clean entry when validation passes\n\t// otherwise return the full issue list\n\treturn (issues.length ? { issues } : { value: validated }) satisfies Result<Entries>\n}\n\nasync function build(src: Collection[], buildContext: BuildContext) {\n\tconst { logger, outDir } = buildContext\n\tlet names: string[] = []\n\n\t// keep each validated collection beside its schema so emit stays in sync\n\tconst collections: Record<\n\t\tstring,\n\t\t{\n\t\t\titems: Raw[]\n\t\t\tschema: Schema\n\t\t}\n\t> = {}\n\n\ttry {\n\t\tif (!outDir) throw new Error('Output directory is not defined')\n\n\t\t// make sure the output directory exists before the writes begin\n\t\t// that way the emit step can stay simple\n\t\tawait fs.mkdir(outDir, { recursive: true })\n\n\t\t// read and validate every collection before writing anything out\n\t\t// this keeps the js and dts outputs in step\n\t\tfor (const collection of src) {\n\t\t\tconst raw = await create(path.join(process.cwd(), collection.dir), buildContext)\n\n\t\t\t// check each raw item before it makes it into the generated collection\n\t\t\t// bad entries get logged and dropped\n\t\t\tconst validated = await Promise.all(\n\t\t\t\traw.map(async item => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { html, markdown, __mdsrc, ...metadata } = item\n\t\t\t\t\t\tconst res = validate(metadata, collection.schema)\n\n\t\t\t\t\t\tif (res.issues) throw new Error(JSON.stringify(res.issues, null, 2))\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tmarkdown,\n\t\t\t\t\t\t\t...res.value,\n\t\t\t\t\t\t\t__mdsrc,\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t`[buildStart]: failed to validate item in ${collection.name}`,\n\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t)\n\n\t\t\tcollections[collection.name] = {\n\t\t\t\t// keep the cleaned items with the schema they came from\n\t\t\t\t// both js and dts generation read from this shape\n\t\t\t\titems: validated.filter(e => e !== null),\n\t\t\t\tschema: collection.schema,\n\t\t\t}\n\t\t}\n\n\t\t// take the collection names after validation has settled\n\t\t// every generated file then works from the same list\n\t\tnames = Object.keys(collections)\n\t\t// queue the file writes first so the emit phase can run together\n\t\t// wait for them once every output is ready\n\t\tconst promises = []\n\n\t\t// build the type file from the schema rather than the observed data\n\t\t// that keeps optional fields and date output honest\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'types.ts'),\n\t\t\t\t`\n\t\t\t\t\t${names\n\t\t\t\t\t\t// make one named type per collection so the dts mirrors the js surface.\n\t\t\t\t\t\t// html and markdown are always present on generated entries\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport type ${capitalise(name)} = {\n\t\t\t\t\t\t\t\t\thtml: string\n\t\t\t\t\t\t\t\t\tmarkdown: string\n\t\t\t\t\t\t\t\t\t${Object.entries(collections[name].schema)\n\t\t\t\t\t\t\t\t\t\t// turn each schema field into a ts property line\n\t\t\t\t\t\t\t\t\t\t// keep optional markers and date strings in step with validation\n\t\t\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t\t\t([key, entry]) =>\n\t\t\t\t\t\t\t\t\t\t\t\t`${key}${entry.optional ? '?' : ''}: ${entry.type === 'date' ? 'string' : entry.type}`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.join('\\n ')}\n\t\t\t\t\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\t\t\t\t\tslug: string\n\t\t\t\t\t\t\t\t\t\tfilename: string\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// write the package surface separately so consumers get typed named exports\n\t\t// this mirrors the generated js entry file\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.d.ts'),\n\t\t\t\t`\t\n\t\t\t\t\timport type { ${names.map(name => capitalise(name)).join(', ')} } from './types.js'\n\n\t\t\t\t\t${names\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}\n\n\t\t\t\t\tdeclare module '${PKG_NAME}' {\n\t\t\t\t\t\t${names\n\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.join('\\n\\n')}\n\t\t\t\t\t}\n\t\t\t\t`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// serialise each validated collection as a plain module for Vite to load\n\t\t// empty collections still export a stable array shape\n\t\tfor (const name of names) {\n\t\t\tconst collection = collections[name]?.items\n\t\t\tconst fileName = toModuleName(name)\n\n\t\t\tpromises.push(\n\t\t\t\tmaybeWrite(\n\t\t\t\t\tpath.join(outDir, `${fileName}.js`),\n\t\t\t\t\t`export const all${capitalise(pluralise(name, 2))} = ${collection?.length ? JSON.stringify(collection) : '[]'}`.trim(),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\t// stitch the per-collection modules into the public js entrypoint\n\t\t// this is the file the root package import resolves to\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.js'),\n\t\t\t\tnames.map(name => `export * from './${toModuleName(name)}.js'`).join('\\n'),\n\t\t\t),\n\t\t)\n\n\t\t// flush every generated artifact once all the content is ready\n\t\t// let any failed write fail the build\n\t\tconst writes = await Promise.all(promises)\n\t\tbuildContext.names = names\n\n\t\treturn writes.some(changed => changed)\n\t} catch (err) {\n\t\tlogger.error('[build]: failed to generate data', err)\n\t\tthrow err\n\t}\n}\n\n// convert watcher paths to a consistent slash format before comparing them\nconst normaliseWatchPath = (p: string) => p.replace(/\\\\/g, '/')\n\n/**\n * Build the Vite plugin that validates collections and writes the generated modules\n * keep the runtime data and declaration files in the same pass\n * resolve package imports from the generated directory\n */\nexport default function mdsrc(config: PluginConfig): Plugin {\n\tconst src = config.collections\n\n\t// use one logger for the whole build so every step reports the same way\n\t// stay chatty outside production\n\tconst logger = new Logger(\n\t\tconfig.logger?.level ?? (process.env.NODE_ENV === 'production' ? 'error' : 'debug'),\n\t)\n\n\t// write generated files into a hidden folder at the project root\n\t// keep the generated surface out of src\n\tconst outDir = path.join(process.cwd(), GENERATED_DIR)\n\tconst watchRoot = normaliseWatchPath(realpathSync.native(process.cwd()))\n\tconst watchedRoots = src.map(c => `${normaliseWatchPath(path.join(watchRoot, c.dir))}/`)\n\n\t// watcher events can arrive through symlinked paths like /var while cwd has\n\t// already resolved to /private/var, so canonicalise the parent dir once and\n\t// reattach the file name for stable prefix checks\n\tconst resolveWatchFile = (filePath: string) => {\n\t\tconst absolutePath = path.resolve(watchRoot, filePath)\n\t\tconst parentPath = path.dirname(absolutePath)\n\n\t\ttry {\n\t\t\tconst resolvedParentPath = normaliseWatchPath(realpathSync.native(parentPath))\n\t\t\treturn normaliseWatchPath(\n\t\t\t\tpath.join(resolvedParentPath, path.basename(absolutePath)),\n\t\t\t)\n\t\t} catch {\n\t\t\treturn normaliseWatchPath(absolutePath)\n\t\t}\n\t}\n\n\tconst isWatchedFile = (filePath: string) =>\n\t\twatchedRoots.some(root => resolveWatchFile(filePath).startsWith(root))\n\n\t// pass shared build tools into helpers without dragging lots of state around\n\t// keep the helper signatures small\n\tconst buildContext = {\n\t\tlogger,\n\t\tmarkdown: config.markdown,\n\t\toutDir,\n\t\tnames: [],\n\t} satisfies BuildContext\n\n\tlet rebuildRunning = false\n\tlet rebuildQueued = false\n\tlet rebuildReason = 'change'\n\tconst rebuild = debounce((event: string, filePath: string) => {\n\t\tconst queue = () => {\n\t\t\tvoid (async () => {\n\t\t\t\t// collapse bursts of file events into one active rebuild plus a single\n\t\t\t\t// queued rerun when changes land mid-build\n\t\t\t\tif (rebuildRunning) {\n\t\t\t\t\trebuildQueued = true\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\trebuildRunning = true\n\n\t\t\t\tdo {\n\t\t\t\t\trebuildQueued = false\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst changed = await build(src, buildContext)\n\n\t\t\t\t\t\tif (changed) logger.info(`[watch]: content rebuilt (${rebuildReason})`)\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error('[watch] content rebuild failed', err)\n\t\t\t\t\t}\n\t\t\t\t} while (rebuildQueued)\n\n\t\t\t\trebuildRunning = false\n\t\t\t})()\n\t\t}\n\n\t\t// ignore anything outside the watched content dirs\n\t\tif (!isWatchedFile(filePath)) return\n\n\t\tconst file = resolveWatchFile(filePath)\n\n\t\trebuildReason = `${event}: ${path.relative(watchRoot, file)}`\n\t\tqueue()\n\t}, 75)\n\n\treturn {\n\t\tname: 'mdsrc',\n\t\tenforce: 'pre',\n\t\tconfig(viteConfig) {\n\t\t\tviteConfig.optimizeDeps ??= {}\n\t\t\tviteConfig.optimizeDeps.exclude = [\n\t\t\t\t...new Set([...(viteConfig.optimizeDeps.exclude ?? []), PKG_NAME]),\n\t\t\t]\n\n\t\t\tviteConfig.resolve ??= {}\n\n\t\t\tif (Array.isArray(viteConfig.resolve.alias)) {\n\t\t\t\tviteConfig.resolve.alias = [\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t{\n\t\t\t\t\t\tfind: PKG_NAME,\n\t\t\t\t\t\treplacement: path.join(outDir, 'index.js'),\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t} else {\n\t\t\t\tviteConfig.resolve.alias = {\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t[PKG_NAME]: path.join(outDir, 'index.js'),\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync buildStart() {\n\t\t\tawait build(src, buildContext)\n\t\t},\n\t\tconfigureServer(server: ViteDevServer) {\n\t\t\tlogger.info(\n\t\t\t\t`[configureServer]: Watching for changes in ./${src.map(c => c.dir).join(', ')}...`,\n\t\t\t)\n\n\t\t\tserver.watcher\n\t\t\t\t.on('add', (p: string) => rebuild('add', p))\n\t\t\t\t.on('change', (p: string) => rebuild('change', p))\n\t\t\t\t.on('unlink', (p: string) => rebuild('unlink', p))\n\t\t},\n\t\tresolveId(id) {\n\t\t\t// point imports at generated files rather than source files\n\t\t\t// that makes the package behave like a normal module\n\t\t\tif (id === PKG_NAME) {\n\t\t\t\treturn path.join(outDir, 'index.js')\n\t\t\t}\n\n\t\t\tif (id.startsWith(`${PKG_NAME}/`)) {\n\t\t\t\t// allow collection subpath imports once the build knows their names\n\t\t\t\t// leave unknown subpaths unresolved\n\t\t\t\tconst subpath = id.slice(PKG_NAME.length + 1)\n\t\t\t\tconst match = buildContext.names.find(\n\t\t\t\t\tname => name === subpath || toModuleName(name) === subpath,\n\t\t\t\t)\n\n\t\t\t\tif (match) {\n\t\t\t\t\treturn path.join(outDir, `${toModuleName(match)}.js`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\t}\n}\n",
6
6
  "export const NAME = 'mdsrc'\nexport const PKG_NAME = `@jk2908/${NAME}`\nexport const GENERATED_DIR = `.${NAME}`",
7
7
  "import { NAME } from './config.js'\n\nconst LEVELS = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n\tfatal: 4,\n} as const\n\nexport type LogLevel = keyof typeof LEVELS\n\ntype LogEntry = {\n\tts: number\n\tlevel: LogLevel\n\tmessage: string\n\terror?:\n\t\t| Error\n\t\t| {\n\t\t\t\tmessage: string\n\t\t\t\tstack?: string\n\t\t\t\tcause?: unknown\n\t\t }\n}\n\n/**\n * Log messages with different severity levels\n */\nexport class Logger {\n\tstatic #defaultLevel: LogLevel = 'info'\n\n\t#level?: LogLevel\n\n\tconstructor(level?: LogLevel) {\n\t\tthis.#level = level\n\t}\n\n\tstatic set defaultLevel(level: LogLevel) {\n\t\tLogger.#defaultLevel = level\n\t}\n\n\tstatic get defaultLevel() {\n\t\treturn Logger.#defaultLevel\n\t}\n\n\t/**\n\t * Convert a value to an Error instance\n\t */\n\tstatic toError(err: unknown) {\n\t\treturn err instanceof Error ? err : new Error(String(err), { cause: err })\n\t}\n\n\t/**\n\t * Stringify the error for logging\n\t */\n\tstatic print(err: unknown) {\n\t\tif (err instanceof Error) {\n\t\t\treturn err.message + (err.stack ? `\\n${err.stack}` : '')\n\t\t}\n\n\t\t// for plain objects, attempt to stringify with indentation\n\t\t// for readability\n\t\tif (typeof err === 'object' && err !== null) {\n\t\t\ttry {\n\t\t\t\treturn JSON.stringify(err, null, 2)\n\t\t\t} catch {\n\t\t\t\t// if stringify fails (e.g. circular reference), fall back\n\t\t\t\t// to basic string conversion\n\t\t\t\treturn String(err)\n\t\t\t}\n\t\t}\n\n\t\treturn String(err)\n\t}\n\n\tset level(level: LogLevel) {\n\t\tthis.#level = level\n\t}\n\n\tget level() {\n\t\treturn this.#level ?? Logger.#defaultLevel\n\t}\n\n\t/**\n\t * Log a message with a specific level\n\t */\n\tlog(level: LogLevel, message: string, error?: Error) {\n\t\tif (LEVELS[level] < LEVELS[this.level]) return\n\n\t\tconst entry: LogEntry = {\n\t\t\tts: Date.now(),\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t}\n\n\t\tif (level === 'error' || level === 'fatal') {\n\t\t\tentry.error = error ? Logger.toError(error) : new Error(message)\n\t\t}\n\n\t\tconst line = `[${NAME}] [${entry.ts}] [${level.toUpperCase()}] ${message}`\n\t\tconst extra = entry.error ? `\\n${Logger.print(entry.error)}` : ''\n\n\t\tif (level === 'warn') {\n\t\t\tconsole.warn(line, extra)\n\t\t\treturn\n\t\t}\n\n\t\tif (level === 'error' || level === 'fatal') {\n\t\t\tconsole.error(line, extra)\n\t\t\treturn\n\t\t}\n\n\t\tconsole.log(line, extra)\n\t}\n\n\t/**\n\t * Log a debug message\n\t */\n\tdebug(...messages: string[]) {\n\t\tthis.log('debug', messages.join(' '))\n\t}\n\n\t/**\n\t * Log an info message\n\t */\n\tinfo(...messages: string[]) {\n\t\tthis.log('info', messages.join(' '))\n\t}\n\n\t/**\n\t * Log a warning message\n\t */\n\twarn(...messages: string[]) {\n\t\tthis.log('warn', messages.join(' '))\n\t}\n\n\t/**\n\t * Log an error message\n\t */\n\terror(message: string, error?: unknown) {\n\t\tthis.log('error', message, error === undefined ? undefined : Logger.toError(error))\n\t}\n\n\t/**\n\t * Log a fatal error message\n\t */\n\tfatal(message: string, error?: unknown) {\n\t\tthis.log('fatal', message, error === undefined ? undefined : Logger.toError(error))\n\t}\n}\n\nexport const logger = new Logger(\n\tprocess.env.NODE_ENV === 'production' ? 'error' : 'debug',\n)\n",
8
8
  "export function capitalise(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function pluralise(str: string, count: number) {\n\treturn count === 1 ? str : str.endsWith('s') ? str : `${str}s`\n}\n\nexport function debounce<T extends unknown[]>(fn: (...args: T) => void, wait: number) {\n\tlet timeoutId: ReturnType<typeof setTimeout> | null = null\n\n\treturn (...args: T) => {\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId)\n\t\t}\n\n\t\ttimeoutId = setTimeout(() => {\n\t\t\tfn.apply(null, args)\n\t\t}, wait)\n\t}\n}\n"
9
9
  ],
10
- "mappings": ";AAAA;AACA;AACA;AAIA;;;ACNO,IAAM,OAAO;AACb,IAAM,WAAW,WAAW;AAC5B,IAAM,gBAAgB,IAAI;;;ACAjC,IAAM,SAAS;AAAA,EACd,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACR;AAAA;AAoBO,MAAM,OAAO;AAAA,SACZ,gBAA0B;AAAA,EAEjC;AAAA,EAEA,WAAW,CAAC,OAAkB;AAAA,IAC7B,KAAK,SAAS;AAAA;AAAA,aAGJ,YAAY,CAAC,OAAiB;AAAA,IACxC,OAAO,gBAAgB;AAAA;AAAA,aAGb,YAAY,GAAG;AAAA,IACzB,OAAO,OAAO;AAAA;AAAA,SAMR,OAAO,CAAC,KAAc;AAAA,IAC5B,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,GAAG,EAAE,OAAO,IAAI,CAAC;AAAA;AAAA,SAMnE,KAAK,CAAC,KAAc;AAAA,IAC1B,IAAI,eAAe,OAAO;AAAA,MACzB,OAAO,IAAI,WAAW,IAAI,QAAQ;AAAA,EAAK,IAAI,UAAU;AAAA,IACtD;AAAA,IAIA,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAAA,MAC5C,IAAI;AAAA,QACH,OAAO,KAAK,UAAU,KAAK,MAAM,CAAC;AAAA,QACjC,MAAM;AAAA,QAGP,OAAO,OAAO,GAAG;AAAA;AAAA,IAEnB;AAAA,IAEA,OAAO,OAAO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AAA,QAEA,IAAI,OAAO;AAAA,UACV,OAAO,KAAK,KAAK,QAAQ,GAAG,aAAa,KAAK,MAAM;AAAA,QACrD;AAAA,MACD;AAAA,MAEA,OAAO;AAAA;AAAA,EAET;AAAA;",
11
+ "debugId": "99F5D645BFF7D65564756E2164756E21",
12
12
  "names": []
13
13
  }
package/dist/types.d.ts CHANGED
@@ -1,21 +1,26 @@
1
- import type MarkdownIt from 'markdown-it';
1
+ import type { MarkdownIt, MarkdownItOptions } from 'markdown-it-ts';
2
2
  import type { LogLevel, Logger } from './logger.js';
3
3
  type MarkdownItUseArgs = Parameters<MarkdownIt['use']>;
4
+ export type MarkdownItConfig = MarkdownItOptions;
4
5
  export type MarkdownPlugin = MarkdownItUseArgs[0];
5
6
  export type MarkdownPluginUse = MarkdownPlugin | readonly [
6
7
  plugin: MarkdownPlugin,
7
8
  ...params: MarkdownItUseArgs extends [unknown, ...infer Params] ? Params : never
8
9
  ];
10
+ export type MarkdownConfig = {
11
+ plugins?: MarkdownPluginUse[];
12
+ config?: MarkdownItConfig;
13
+ };
9
14
  export type PluginConfig = {
10
15
  collections: Collection[];
11
16
  logger?: {
12
17
  level?: LogLevel;
13
18
  };
14
- plugins?: MarkdownPluginUse[];
19
+ markdown?: MarkdownConfig;
15
20
  };
16
21
  export type BuildContext = {
17
22
  logger: InstanceType<typeof Logger>;
18
- plugins?: MarkdownPluginUse[];
23
+ markdown?: MarkdownConfig;
19
24
  outDir?: string;
20
25
  names?: string[];
21
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jk2908/mdsrc",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "author": "Jerome Kenway",
6
6
  "description": "A Vite plugin for turning structured Markdown content into importable, type-safe modules",
@@ -15,8 +15,7 @@
15
15
  "test": "cd ../.. && bun test"
16
16
  },
17
17
  "dependencies": {
18
- "@types/markdown-it": "^14.1.2",
19
- "markdown-it": "^14.1.0"
18
+ "markdown-it-ts": "^1.0.0"
20
19
  },
21
20
  "peerDependencies": {
22
21
  "vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"