@hanzo/docs-mdx 14.2.5 → 14.2.6
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/dist/{build-GdAvxpd7.js → build-DbdeZyKK.js} +1 -1
- package/dist/{build-GdAvxpd7.js.map → build-DbdeZyKK.js.map} +1 -1
- package/dist/{build-mdx-COY0QD1z.js → build-mdx-BTwSGUFs.js} +2 -2
- package/dist/{build-mdx-COY0QD1z.js.map → build-mdx-BTwSGUFs.js.map} +1 -1
- package/dist/build-mdx-Cg4YpCKX.js +5 -0
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.js +7 -7
- package/dist/{codegen-Dd9ILNOr.js → codegen-IYa8t8xV.js} +1 -1
- package/dist/{codegen-Dd9ILNOr.js.map → codegen-IYa8t8xV.js.map} +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +2 -2
- package/dist/{config-DSrG5Dfc.js → config-s4QVhqzA.js} +4 -4
- package/dist/{config-DSrG5Dfc.js.map → config-s4QVhqzA.js.map} +1 -1
- package/dist/{core-DOav5JBx.js → core-CCsY8cxS.js} +2 -2
- package/dist/{core-DOav5JBx.js.map → core-CCsY8cxS.js.map} +1 -1
- package/dist/{core-D2BJuXMW.d.ts → core-CgLkZ4NQ.d.ts} +11 -1
- package/dist/core-CgLkZ4NQ.d.ts.map +1 -0
- package/dist/{fuma-matter-DL-PfQJ7.js → fuma-matter-BWdOvvCf.js} +1 -1
- package/dist/{fuma-matter-DL-PfQJ7.js.map → fuma-matter-BWdOvvCf.js.map} +1 -1
- package/dist/{index-file-B3LmDGdu.js → index-file-DsOEtYCF.js} +3 -3
- package/dist/{index-file-B3LmDGdu.js.map → index-file-DsOEtYCF.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{load-from-file-dsGIDpOc.js → load-from-file-Bx1TjN0x.js} +2 -2
- package/dist/{load-from-file-dsGIDpOc.js.map → load-from-file-Bx1TjN0x.js.map} +1 -1
- package/dist/load-from-file-DPPJI83O.js +5 -0
- package/dist/{loaders-Mp-ZCdLT.js → loaders-BjG6ii1-.js} +1 -1
- package/dist/{loaders-Mp-ZCdLT.js.map → loaders-BjG6ii1-.js.map} +1 -1
- package/dist/{mdx-CJaKR3FR.js → mdx-DBBqLhht.js} +5 -5
- package/dist/{mdx-CJaKR3FR.js.map → mdx-DBBqLhht.js.map} +1 -1
- package/dist/{meta-CKrL1Sl9.js → meta-u6oJ9ej1.js} +3 -3
- package/dist/{meta-CKrL1Sl9.js.map → meta-u6oJ9ej1.js.map} +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +7 -7
- package/dist/node/loader.js +6 -6
- package/dist/plugins/index-file.d.ts +1 -1
- package/dist/plugins/index-file.js +3 -3
- package/dist/plugins/json-schema.d.ts +1 -1
- package/dist/plugins/json-schema.js +1 -1
- package/dist/plugins/last-modified.d.ts +1 -1
- package/dist/plugins/last-modified.js +1 -1
- package/dist/{remark-include-BbnDmUoc.js → remark-include-BnRd6OBo.js} +4 -4
- package/dist/{remark-include-BbnDmUoc.js.map → remark-include-BnRd6OBo.js.map} +1 -1
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/dynamic.d.ts +1 -1
- package/dist/runtime/dynamic.js +7 -7
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/server.js +6 -0
- package/dist/runtime/server.js.map +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +9 -9
- package/dist/webpack/mdx.d.ts +1 -1
- package/dist/webpack/mdx.js +6 -6
- package/dist/webpack/meta.d.ts +1 -1
- package/dist/webpack/meta.js +5 -5
- package/dist/{webpack-BHjsXgTD.js → webpack-fHsy5QQI.js} +2 -2
- package/dist/{webpack-BHjsXgTD.js.map → webpack-fHsy5QQI.js.map} +1 -1
- package/package.json +14 -14
- package/LICENSE +0 -21
- package/dist/build-mdx-hB1gzgHy.js +0 -5
- package/dist/core-D2BJuXMW.d.ts.map +0 -1
- package/dist/load-from-file-BoO9y-n6.js +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as buildConfig } from "./build-
|
|
1
|
+
import { t as buildConfig } from "./build-DbdeZyKK.js";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
|
|
4
4
|
//#region src/config/load-from-file.ts
|
|
@@ -35,4 +35,4 @@ async function loadConfig(core, build = false) {
|
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
export { loadConfig as t };
|
|
38
|
-
//# sourceMappingURL=load-from-file-
|
|
38
|
+
//# sourceMappingURL=load-from-file-Bx1TjN0x.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-from-file-
|
|
1
|
+
{"version":3,"file":"load-from-file-Bx1TjN0x.js","names":[],"sources":["../src/config/load-from-file.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport type { LoadedConfig } from '@/config/build';\nimport { buildConfig } from '@/config/build';\nimport type { Core } from '@/core';\n\nasync function compileConfig(core: Core) {\n const { build } = await import('esbuild');\n const { configPath, outDir } = core.getOptions();\n\n const transformed = await build({\n entryPoints: [{ in: configPath, out: 'source.config' }],\n bundle: true,\n outdir: outDir,\n target: 'node20',\n write: true,\n platform: 'node',\n format: 'esm',\n packages: 'external',\n outExtension: {\n '.js': '.mjs',\n },\n allowOverwrite: true,\n });\n\n if (transformed.errors.length > 0) {\n throw new Error('failed to compile configuration file');\n }\n}\n\n/**\n * Load config\n *\n * @param build - By default, it assumes the config file has been compiled. Set this `true` to compile the config first.\n */\nexport async function loadConfig(core: Core, build = false): Promise<LoadedConfig> {\n if (build) await compileConfig(core);\n\n const url = pathToFileURL(core.getCompiledConfigPath());\n // always return a new config\n url.searchParams.set('hash', Date.now().toString());\n\n const config = import(url.href).then((loaded) => buildConfig(loaded as Record<string, unknown>));\n\n return await config;\n}\n"],"mappings":";;;;AAKA,eAAe,cAAc,MAAY;CACvC,MAAM,EAAE,UAAU,MAAM,OAAO;CAC/B,MAAM,EAAE,YAAY,WAAW,KAAK,YAAY;AAiBhD,MAfoB,MAAM,MAAM;EAC9B,aAAa,CAAC;GAAE,IAAI;GAAY,KAAK;GAAiB,CAAC;EACvD,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,UAAU;EACV,QAAQ;EACR,UAAU;EACV,cAAc,EACZ,OAAO,QACR;EACD,gBAAgB;EACjB,CAAC,EAEc,OAAO,SAAS,EAC9B,OAAM,IAAI,MAAM,uCAAuC;;;;;;;AAS3D,eAAsB,WAAW,MAAY,QAAQ,OAA8B;AACjF,KAAI,MAAO,OAAM,cAAc,KAAK;CAEpC,MAAM,MAAM,cAAc,KAAK,uBAAuB,CAAC;AAEvD,KAAI,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC,UAAU,CAAC;AAInD,QAAO,MAFQ,OAAO,IAAI,MAAM,MAAM,WAAW,YAAY,OAAkC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaders-
|
|
1
|
+
{"version":3,"file":"loaders-BjG6ii1-.js","names":[],"sources":["../src/loaders/index.ts"],"sourcesContent":["export const metaLoaderGlob = /\\.(json|yaml)(\\?.+?)?$/;\nexport const mdxLoaderGlob = /\\.mdx?(\\?.+?)?$/;\n"],"mappings":";AAAA,MAAa,iBAAiB;AAC9B,MAAa,gBAAgB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { z } from "zod";
|
|
1
|
+
import { t as mdxLoaderGlob } from "./loaders-BjG6ii1-.js";
|
|
2
|
+
import { t as fumaMatter } from "./fuma-matter-BWdOvvCf.js";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import fs from "node:fs/promises";
|
|
5
|
+
import { z } from "zod";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
|
|
8
8
|
//#region src/loaders/mdx/index.ts
|
|
@@ -59,7 +59,7 @@ function createMdxLoader({ getCore }) {
|
|
|
59
59
|
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
60
60
|
map: null
|
|
61
61
|
};
|
|
62
|
-
const { buildMDX } = await import("./build-mdx-
|
|
62
|
+
const { buildMDX } = await import("./build-mdx-Cg4YpCKX.js");
|
|
63
63
|
const compiled = await buildMDX(core, docCollection, {
|
|
64
64
|
isDevelopment,
|
|
65
65
|
source: "\n".repeat(countLines(matter.matter)) + matter.content,
|
|
@@ -88,4 +88,4 @@ function countLines(s) {
|
|
|
88
88
|
|
|
89
89
|
//#endregion
|
|
90
90
|
export { createMdxLoader as t };
|
|
91
|
-
//# sourceMappingURL=mdx-
|
|
91
|
+
//# sourceMappingURL=mdx-DBBqLhht.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx-
|
|
1
|
+
{"version":3,"file":"mdx-DBBqLhht.js","names":["after: (() => Promise<void>) | undefined","docCollection: DocCollectionItem | undefined"],"sources":["../src/loaders/mdx/index.ts"],"sourcesContent":["import { fumaMatter } from '@/utils/fuma-matter';\nimport type { SourceMap } from 'rollup';\nimport type { Loader } from '@/loaders/adapter';\nimport { z } from 'zod';\nimport type { DocCollectionItem } from '@/config/build';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { createHash } from 'node:crypto';\nimport type { ConfigLoader } from '@/loaders/config';\nimport { mdxLoaderGlob } from '..';\n\nconst querySchema = z\n .object({\n only: z.literal(['frontmatter', 'all']).default('all'),\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\nconst cacheEntry = z.object({\n code: z.string(),\n map: z.any().optional(),\n hash: z.string().optional(),\n});\n\ntype CacheEntry = z.infer<typeof cacheEntry>;\n\nexport function createMdxLoader({ getCore }: ConfigLoader): Loader {\n return {\n test: mdxLoaderGlob,\n async load({ getSource, development: isDevelopment, query, compiler, filePath }) {\n let core = await getCore();\n const value = await getSource();\n const matter = fumaMatter(value);\n const { collection: collectionName, workspace, only } = querySchema.parse(query);\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let after: (() => Promise<void>) | undefined;\n\n const { experimentalBuildCache = false } = core.getConfig().global;\n if (!isDevelopment && experimentalBuildCache) {\n const cacheDir = experimentalBuildCache;\n const cacheKey = `${collectionName ?? 'global'}_${generateCacheHash(filePath)}`;\n\n const cached = await fs\n .readFile(path.join(cacheDir, cacheKey))\n .then((content) => cacheEntry.parse(JSON.parse(content.toString())))\n .catch(() => null);\n\n if (cached && cached.hash === generateCacheHash(value)) return cached;\n after = async () => {\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(\n path.join(cacheDir, cacheKey),\n JSON.stringify({\n ...out,\n hash: generateCacheHash(value),\n } satisfies CacheEntry),\n );\n };\n }\n\n const collection = collectionName ? core.getCollection(collectionName) : undefined;\n\n let docCollection: DocCollectionItem | undefined;\n switch (collection?.type) {\n case 'doc':\n docCollection = collection;\n break;\n case 'docs':\n docCollection = collection.docs;\n break;\n }\n\n if (docCollection) {\n matter.data = await core.transformFrontmatter(\n { collection: docCollection, filePath, source: value },\n matter.data as Record<string, unknown>,\n );\n }\n\n if (only === 'frontmatter') {\n return {\n code: `export const frontmatter = ${JSON.stringify(matter.data)}`,\n map: null,\n };\n }\n\n const { buildMDX } = await import('@/loaders/mdx/build-mdx');\n const compiled = await buildMDX(core, docCollection, {\n isDevelopment,\n // ensure the line number is correct in errors\n source: '\\n'.repeat(countLines(matter.matter)) + matter.content,\n filePath,\n frontmatter: matter.data as Record<string, unknown>,\n _compiler: compiler,\n environment: 'bundler',\n });\n\n const out = {\n code: String(compiled.value),\n map: compiled.map as SourceMap,\n };\n\n await after?.();\n return out;\n },\n };\n}\n\nfunction generateCacheHash(input: string): string {\n return createHash('md5').update(input).digest('hex');\n}\n\nfunction countLines(s: string) {\n let num = 0;\n\n for (const c of s) {\n if (c === '\\n') num++;\n }\n\n return num;\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,cAAc,EACjB,OAAO;CACN,MAAM,EAA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AAM,aAAa,iBAAiB,KAAK,cAAc,eAAe,GAAG;GAEzE,IAAIC;AACJ,WAAQ,YAAY,MAApB;IACE,KAAK;AACH,qBAAgB;AAChB;IACF,KAAK;AACH,qBAAgB,WAAW;AAC3B;;AAGJ,OAAI,cACF,QAAO,OAAO,MAAM,KAAK,qBACvB;IAAE,YAAY;IAAe;IAAU,QAAQ;IAAO,EACtD,OAAO,KACR;AAGH,OAAI,SAAS,cACX,QAAO;IACL,MAAM,8BAA8B,KAAK,UAAU,OAAO,KAAK;IAC/D,KAAK;IACN;GAGH,MAAM,EAAE,aAAa,MAAM,OAAO;GAClC,MAAM,WAAW,MAAM,SAAS,MAAM,eAAe;IACnD;IAEA,QAAQ,KAAK,OAAO,WAAW,OAAO,OAAO,CAAC,GAAG,OAAO;IACxD;IACA,aAAa,OAAO;IACpB,WAAW;IACX,aAAa;IACd,CAAC;GAEF,MAAM,MAAM;IACV,MAAM,OAAO,SAAS,MAAM;IAC5B,KAAK,SAAS;IACf;AAED,SAAM,SAAS;AACf,UAAO;;EAEV;;AAGH,SAAS,kBAAkB,OAAuB;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGtD,SAAS,WAAW,GAAW;CAC7B,IAAI,MAAM;AAEV,MAAK,MAAM,KAAK,EACd,KAAI,MAAM,KAAM;AAGlB,QAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as metaLoaderGlob } from "./loaders-
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
import { n as metaLoaderGlob } from "./loaders-BjG6ii1-.js";
|
|
3
2
|
import { load } from "js-yaml";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/loaders/meta.ts
|
|
6
6
|
const querySchema = z.object({
|
|
@@ -78,4 +78,4 @@ function createMetaLoader({ getCore }, resolve = {}) {
|
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { createMetaLoader as t };
|
|
81
|
-
//# sourceMappingURL=meta-
|
|
81
|
+
//# sourceMappingURL=meta-u6oJ9ej1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-
|
|
1
|
+
{"version":3,"file":"meta-u6oJ9ej1.js","names":["metaCollection: MetaCollectionItem | undefined"],"sources":["../src/loaders/meta.ts"],"sourcesContent":["import type { Loader, LoaderInput } from '@/loaders/adapter';\nimport type { ConfigLoader } from '@/loaders/config';\nimport { load } from 'js-yaml';\nimport { z } from 'zod';\nimport { metaLoaderGlob } from '.';\nimport type { MetaCollectionItem } from '@/config/build';\n\nconst querySchema = z\n .object({\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\n/**\n * load meta files, fallback to bundler's built-in plugins when ?collection is unspecified.\n */\nexport function createMetaLoader(\n { getCore }: ConfigLoader,\n resolve: {\n json?: 'json' | 'js';\n yaml?: 'js';\n } = {},\n): Loader {\n const { json: resolveJson = 'js' } = resolve;\n\n function parse(filePath: string, source: string) {\n try {\n if (filePath.endsWith('.json')) return JSON.parse(source);\n if (filePath.endsWith('.yaml')) return load(source);\n } catch (e) {\n throw new Error(`invalid data in ${filePath}`, { cause: e });\n }\n\n throw new Error('Unknown file type ' + filePath);\n }\n\n function onMeta(source: string, { filePath, query }: LoaderInput) {\n const parsed = querySchema.safeParse(query);\n if (!parsed.success || !parsed.data.collection) return null;\n const { collection: collectionName, workspace } = parsed.data;\n\n return async (): Promise<unknown> => {\n let core = await getCore();\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n const collection = core.getCollection(collectionName);\n let metaCollection: MetaCollectionItem | undefined;\n\n switch (collection?.type) {\n case 'meta':\n metaCollection = collection;\n break;\n case 'docs':\n metaCollection = collection.meta;\n break;\n }\n\n const data = parse(filePath, source);\n\n if (!metaCollection) return data;\n return core.transformMeta(\n {\n collection: metaCollection,\n filePath,\n source,\n },\n data,\n );\n };\n }\n\n return {\n test: metaLoaderGlob,\n async load(input) {\n const result = onMeta(await input.getSource(), input);\n if (result === null) return null;\n const data = await result();\n\n if (input.filePath.endsWith('.json')) {\n return {\n moduleType: resolveJson,\n code:\n resolveJson === 'json'\n ? JSON.stringify(data)\n : `export default ${JSON.stringify(data)}`,\n };\n } else {\n return {\n moduleType: 'js',\n code: `export default ${JSON.stringify(data)}`,\n };\n }\n },\n bun: {\n load(source, input) {\n const result = onMeta(source, input);\n if (result === null)\n return {\n loader: 'object',\n exports: parse(input.filePath, source),\n };\n\n return result().then((data) => ({\n loader: 'object',\n exports: { default: data },\n }));\n },\n },\n };\n}\n"],"mappings":";;;;;AAOA,MAAM,cAAc,EACjB,OAAO;CACN,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC,CACD,OAAO;;;;AAKV,SAAgB,iBACd,EAAE,WACF,UAGI,EAAE,EACE;CACR,MAAM,EAAE,MAAM,cAAc,SAAS;CAErC,SAAS,MAAM,UAAkB,QAAgB;AAC/C,MAAI;AACF,OAAI,SAAS,SAAS,QAAQ,CAAE,QAAO,KAAK,MAAM,OAAO;AACzD,OAAI,SAAS,SAAS,QAAQ,CAAE,QAAO,KAAK,OAAO;WAC5C,GAAG;AACV,SAAM,IAAI,MAAM,mBAAmB,YAAY,EAAE,OAAO,GAAG,CAAC;;AAG9D,QAAM,IAAI,MAAM,uBAAuB,SAAS;;CAGlD,SAAS,OAAO,QAAgB,EAAE,UAAU,SAAsB;EAChE,MAAM,SAAS,YAAY,UAAU,MAAM;AAC3C,MAAI,CAAC,OAAO,WAAW,CAAC,OAAO,KAAK,WAAY,QAAO;EACvD,MAAM,EAAE,YAAY,gBAAgB,cAAc,OAAO;AAEzD,SAAO,YAA8B;GACnC,IAAI,OAAO,MAAM,SAAS;AAC1B,OAAI,UACF,QAAO,KAAK,eAAe,CAAC,IAAI,UAAU,IAAI;GAGhD,MAAM,aAAa,KAAK,cAAc,eAAe;GACrD,IAAIA;AAEJ,WAAQ,YAAY,MAApB;IACE,KAAK;AACH,sBAAiB;AACjB;IACF,KAAK;AACH,sBAAiB,WAAW;AAC5B;;GAGJ,MAAM,OAAO,MAAM,UAAU,OAAO;AAEpC,OAAI,CAAC,eAAgB,QAAO;AAC5B,UAAO,KAAK,cACV;IACE,YAAY;IACZ;IACA;IACD,EACD,KACD;;;AAIL,QAAO;EACL,MAAM;EACN,MAAM,KAAK,OAAO;GAChB,MAAM,SAAS,OAAO,MAAM,MAAM,WAAW,EAAE,MAAM;AACrD,OAAI,WAAW,KAAM,QAAO;GAC5B,MAAM,OAAO,MAAM,QAAQ;AAE3B,OAAI,MAAM,SAAS,SAAS,QAAQ,CAClC,QAAO;IACL,YAAY;IACZ,MACE,gBAAgB,SACZ,KAAK,UAAU,KAAK,GACpB,kBAAkB,KAAK,UAAU,KAAK;IAC7C;OAED,QAAO;IACL,YAAY;IACZ,MAAM,kBAAkB,KAAK,UAAU,KAAK;IAC7C;;EAGL,KAAK,EACH,KAAK,QAAQ,OAAO;GAClB,MAAM,SAAS,OAAO,QAAQ,MAAM;AACpC,OAAI,WAAW,KACb,QAAO;IACL,QAAQ;IACR,SAAS,MAAM,MAAM,UAAU,OAAO;IACvC;AAEH,UAAO,QAAQ,CAAC,MAAM,UAAU;IAC9B,QAAQ;IACR,SAAS,EAAE,SAAS,MAAM;IAC3B,EAAE;KAEN;EACF"}
|
package/dist/next/index.d.ts
CHANGED
package/dist/next/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "../preset-D_quDsKp.js";
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import { t as
|
|
5
|
-
import
|
|
6
|
-
import "../
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
2
|
+
import "../build-DbdeZyKK.js";
|
|
3
|
+
import { t as loadConfig } from "../load-from-file-Bx1TjN0x.js";
|
|
4
|
+
import { n as createCore, t as _Defaults } from "../core-CCsY8cxS.js";
|
|
5
|
+
import "../codegen-IYa8t8xV.js";
|
|
6
|
+
import { n as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-BjG6ii1-.js";
|
|
7
|
+
import { t as indexFile } from "../index-file-DsOEtYCF.js";
|
|
8
|
+
import "../fuma-matter-BWdOvvCf.js";
|
|
9
9
|
import * as path$1 from "node:path";
|
|
10
10
|
|
|
11
11
|
//#region src/next/index.ts
|
package/dist/node/loader.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import
|
|
3
|
-
import "../
|
|
4
|
-
import { t as createMdxLoader } from "../mdx-
|
|
5
|
-
import { i as toNode, n as createStandaloneConfigLoader } from "../config-
|
|
6
|
-
import { t as createMetaLoader } from "../meta-
|
|
1
|
+
import { n as createCore, t as _Defaults } from "../core-CCsY8cxS.js";
|
|
2
|
+
import "../codegen-IYa8t8xV.js";
|
|
3
|
+
import "../fuma-matter-BWdOvvCf.js";
|
|
4
|
+
import { t as createMdxLoader } from "../mdx-DBBqLhht.js";
|
|
5
|
+
import { i as toNode, n as createStandaloneConfigLoader } from "../config-s4QVhqzA.js";
|
|
6
|
+
import { t as createMetaLoader } from "../meta-u6oJ9ej1.js";
|
|
7
7
|
|
|
8
8
|
//#region src/node/loader.ts
|
|
9
9
|
const configLoader = createStandaloneConfigLoader({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as indexFile, h as IndexFilePluginOptions, m as IndexFilePlugin } from "../core-
|
|
1
|
+
import { g as indexFile, h as IndexFilePluginOptions, m as IndexFilePlugin } from "../core-CgLkZ4NQ.js";
|
|
2
2
|
export { IndexFilePlugin, IndexFilePluginOptions, indexFile as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import
|
|
1
|
+
import "../codegen-IYa8t8xV.js";
|
|
2
|
+
import { t as indexFile } from "../index-file-DsOEtYCF.js";
|
|
3
|
+
import "../fuma-matter-BWdOvvCf.js";
|
|
4
4
|
|
|
5
5
|
export { indexFile as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as fumaMatter } from "./fuma-matter-
|
|
2
|
-
import { unified } from "unified";
|
|
3
|
-
import { visit } from "unist-util-visit";
|
|
1
|
+
import { t as fumaMatter } from "./fuma-matter-BWdOvvCf.js";
|
|
4
2
|
import * as path$1 from "node:path";
|
|
5
3
|
import * as fs$1 from "node:fs/promises";
|
|
4
|
+
import { unified } from "unified";
|
|
5
|
+
import { visit } from "unist-util-visit";
|
|
6
6
|
import { remarkHeading } from "@hanzo/docs-core/mdx-plugins";
|
|
7
7
|
import { VFile } from "vfile";
|
|
8
8
|
|
|
@@ -244,4 +244,4 @@ function remarkInclude() {
|
|
|
244
244
|
|
|
245
245
|
//#endregion
|
|
246
246
|
export { flattenNode as n, remarkInclude as t };
|
|
247
|
-
//# sourceMappingURL=remark-include-
|
|
247
|
+
//# sourceMappingURL=remark-include-BnRd6OBo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-include-BbnDmUoc.js","names":["newChildren: RootContent[]","extractedLines: string[]","ElementLikeTypes: ElementLikeContent['type'][]","attributes: Record<string, string | null>","nodes: RootContent[] | undefined","content: string","fs","path","queue: Promise<void>[]"],"sources":["../src/loaders/mdx/remark-unravel.ts","../src/loaders/mdx/mdast-utils.ts","../src/loaders/mdx/remark-include.ts"],"sourcesContent":["// from internal remark plugins in https://github.com/mdx-js/mdx/blob/main/packages/mdx/lib/plugin/remark-mark-and-unravel.js\n// we need to ensure consistency with MDX.js when parsing embed content in `remark-include`\nimport { visit } from 'unist-util-visit';\nimport type { Transformer } from 'unified';\nimport type { Root, RootContent } from 'mdast';\n\nexport function remarkMarkAndUnravel(): Transformer<Root, Root> {\n return (tree) => {\n visit(tree, function (node, index, parent) {\n let offset = -1;\n let all = true;\n let oneOrMore = false;\n\n if (parent && typeof index === 'number' && node.type === 'paragraph') {\n const children = node.children;\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === 'mdxJsxTextElement' || child.type === 'mdxTextExpression') {\n oneOrMore = true;\n } else if (child.type === 'text' && child.value.trim().length === 0) {\n // Empty.\n } else {\n all = false;\n break;\n }\n }\n\n if (all && oneOrMore) {\n offset = -1;\n const newChildren: RootContent[] = [];\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === 'mdxJsxTextElement') {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = 'mdxJsxFlowElement';\n }\n\n if (child.type === 'mdxTextExpression') {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = 'mdxFlowExpression';\n }\n\n if (child.type === 'text' && /^[\\t\\r\\n ]+$/.test(String(child.value))) {\n // Empty.\n } else {\n newChildren.push(child);\n }\n }\n\n parent.children.splice(index, 1, ...newChildren);\n return index;\n }\n }\n });\n };\n}\n","import type { RootContent } from 'mdast';\n\nexport function flattenNode(node: RootContent): string {\n if ('children' in node) return node.children.map((child) => flattenNode(child)).join('');\n\n if ('value' in node) return node.value;\n\n return '';\n}\n","import { type Processor, type Transformer, unified } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport type { Code, Node, Root, RootContent } from 'mdast';\nimport * as path from 'node:path';\nimport * as fs from 'node:fs/promises';\nimport { fumaMatter } from '@/utils/fuma-matter';\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';\nimport { remarkHeading } from '@hanzo/docs-core/mdx-plugins';\nimport { VFile } from 'vfile';\nimport type { Directives } from 'mdast-util-directive';\nimport { remarkMarkAndUnravel } from '@/loaders/mdx/remark-unravel';\nimport { flattenNode } from './mdast-utils';\n\n/**\n * VS Code–style region extraction\n * Adapted from VitePress:\n * https://github.com/vuejs/vitepress/blob/main/src/node/markdown/plugins/snippet.ts\n */\n\n// region marker regexes\nconst REGION_MARKERS = [\n {\n start: /^\\s*\\/\\/\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*\\/\\/\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*<!--\\s*#?region\\b\\s*(.*?)\\s*-->/,\n end: /^\\s*<!--\\s*#?endregion\\b\\s*(.*?)\\s*-->/,\n },\n {\n start: /^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\//,\n end: /^\\s*\\/\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\//,\n },\n {\n start: /^\\s*#[rR]egion\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#[eE]nd ?[rR]egion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*(?:--|::|@?REM)\\s*#region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*(?:--|::|@?REM)\\s*#endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#pragma\\s+region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#pragma\\s+endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*\\(\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\)/,\n end: /^\\s*\\(\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\)/,\n },\n];\n\nfunction dedent(lines: string[]): string {\n const minIndent = lines.reduce((min, line) => {\n const match = line.match(/^(\\s*)\\S/);\n return match ? Math.min(min, match[1].length) : min;\n }, Infinity);\n\n return minIndent === Infinity\n ? lines.join('\\n')\n : lines.map((l) => l.slice(minIndent)).join('\\n');\n}\n\nfunction extractCodeRegion(content: string, regionName: string): string {\n const lines = content.split('\\n');\n\n for (let i = 0; i < lines.length; i++) {\n for (const re of REGION_MARKERS) {\n let match = re.start.exec(lines[i]);\n if (match?.[1] !== regionName) continue;\n\n let depth = 1;\n const extractedLines: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n match = re.start.exec(lines[j]);\n if (match) {\n depth++;\n continue;\n }\n\n match = re.end.exec(lines[j]);\n if (match) {\n if (match[1] === regionName) depth = 0;\n else if (match[1] === '') depth--;\n else continue;\n\n if (depth > 0) continue;\n return dedent(extractedLines);\n } else {\n extractedLines.push(lines[j]);\n }\n }\n }\n }\n throw new Error(`Region \"${regionName}\" not found`);\n}\n\nexport interface Params {\n lang?: string;\n meta?: string;\n}\n\nconst ElementLikeTypes: ElementLikeContent['type'][] = [\n 'mdxJsxFlowElement',\n 'mdxJsxTextElement',\n 'containerDirective',\n 'textDirective',\n 'leafDirective',\n];\ntype ElementLikeContent = MdxJsxFlowElement | MdxJsxTextElement | Directives;\n\nfunction isElementLike(node: Node): node is ElementLikeContent {\n return ElementLikeTypes.includes(node.type as ElementLikeContent['type']);\n}\n\nfunction parseElementAttributes(\n element: ElementLikeContent,\n): Record<string, string | null | undefined> {\n if (Array.isArray(element.attributes)) {\n const attributes: Record<string, string | null> = {};\n\n for (const attr of element.attributes) {\n if (\n attr.type === 'mdxJsxAttribute' &&\n (typeof attr.value === 'string' || attr.value === null)\n ) {\n attributes[attr.name] = attr.value;\n }\n }\n\n return attributes;\n }\n\n return element.attributes ?? {};\n}\n\nfunction parseSpecifier(specifier: string): {\n file: string;\n section?: string;\n} {\n const idx = specifier.lastIndexOf('#');\n if (idx === -1) return { file: specifier };\n\n return {\n file: specifier.slice(0, idx),\n section: specifier.slice(idx + 1),\n };\n}\n\nfunction extractSection(root: Root, section: string): Root | undefined {\n let nodes: RootContent[] | undefined;\n let capturingHeadingContent = false;\n\n visit(root, (node) => {\n if (node.type === 'heading') {\n if (capturingHeadingContent) {\n return false;\n }\n\n if (node.data?.hProperties?.id === section) {\n capturingHeadingContent = true;\n nodes = [node];\n return 'skip';\n }\n\n return;\n }\n\n if (capturingHeadingContent) {\n nodes?.push(node as RootContent);\n return 'skip';\n }\n\n if (isElementLike(node) && node.name === 'section') {\n const attributes = parseElementAttributes(node);\n\n if (attributes.id === section) {\n nodes = node.children;\n return false;\n }\n }\n });\n\n if (nodes)\n return {\n type: 'root',\n children: nodes,\n };\n}\n\nexport function remarkInclude(this: Processor): Transformer<Root, Root> {\n const TagName = 'include';\n\n const embedContent = async (\n targetPath: string,\n heading: string | undefined,\n params: Params,\n parent: VFile,\n ) => {\n const { _getProcessor = () => this, _compiler } = parent.data;\n let content: string;\n try {\n content = (await fs.readFile(targetPath)).toString();\n } catch (e) {\n throw new Error(\n `failed to read file ${targetPath}\\n${e instanceof Error ? e.message : String(e)}`,\n { cause: e },\n );\n }\n\n const ext = path.extname(targetPath);\n _compiler?.addDependency(targetPath);\n // For non-Markdown files, support VS Code–style region extraction\n if (params.lang || (ext !== '.md' && ext !== '.mdx')) {\n const lang = params.lang ?? ext.slice(1);\n let value = content;\n if (heading) {\n value = extractCodeRegion(content, heading.trim());\n }\n return {\n type: 'code',\n lang,\n meta: params.meta,\n value,\n data: {},\n } satisfies Code;\n }\n\n const parser = _getProcessor(ext === '.mdx' ? 'mdx' : 'md');\n const parsed = fumaMatter(content);\n const targetFile = new VFile({\n path: targetPath,\n value: parsed.content,\n data: {\n ...parent.data,\n frontmatter: parsed.data as Record<string, unknown>,\n },\n });\n let mdast = parser.parse(targetFile) as Root;\n const baseProcessor = unified().use(remarkMarkAndUnravel);\n\n if (heading) {\n // parse headings before extraction\n const extracted = extractSection(await baseProcessor.use(remarkHeading).run(mdast), heading);\n if (!extracted)\n throw new Error(\n `Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id=\"${heading}\"> tag, or a :::section directive with remark-directive configured.`,\n );\n\n mdast = extracted;\n } else {\n mdast = await baseProcessor.run(mdast);\n }\n\n await update(mdast, targetFile);\n return mdast;\n };\n\n async function update(tree: Root, file: VFile) {\n const queue: Promise<void>[] = [];\n\n visit(tree, ElementLikeTypes, (_node, _, parent) => {\n const node = _node as ElementLikeContent;\n if (node.name !== TagName) return;\n\n const specifier = flattenNode(node);\n if (specifier.length === 0) return 'skip';\n\n const attributes = parseElementAttributes(node);\n const { file: relativePath, section } = parseSpecifier(specifier);\n const targetPath = path.resolve('cwd' in attributes ? file.cwd : file.dirname!, relativePath);\n\n queue.push(\n embedContent(targetPath, section, attributes, file).then((replace) => {\n Object.assign(parent && parent.type === 'paragraph' ? parent : node, replace);\n }),\n );\n\n return 'skip';\n });\n\n await Promise.all(queue);\n }\n\n return async (tree, file) => {\n await update(tree, file);\n };\n}\n"],"mappings":";;;;;;;;;AAMA,SAAgB,uBAAgD;AAC9D,SAAQ,SAAS;AACf,QAAM,MAAM,SAAU,MAAM,OAAO,QAAQ;GACzC,IAAI,SAAS;GACb,IAAI,MAAM;GACV,IAAI,YAAY;AAEhB,OAAI,UAAU,OAAO,UAAU,YAAY,KAAK,SAAS,aAAa;IACpE,MAAM,WAAW,KAAK;AAEtB,WAAO,EAAE,SAAS,SAAS,QAAQ;KACjC,MAAM,QAAQ,SAAS;AAEvB,SAAI,MAAM,SAAS,uBAAuB,MAAM,SAAS,oBACvD,aAAY;cACH,MAAM,SAAS,UAAU,MAAM,MAAM,MAAM,CAAC,WAAW,GAAG,QAE9D;AACL,YAAM;AACN;;;AAIJ,QAAI,OAAO,WAAW;AACpB,cAAS;KACT,MAAMA,cAA6B,EAAE;AAErC,YAAO,EAAE,SAAS,SAAS,QAAQ;MACjC,MAAM,QAAQ,SAAS;AAEvB,UAAI,MAAM,SAAS,oBAEjB,OAAM,OAAO;AAGf,UAAI,MAAM,SAAS,oBAEjB,OAAM,OAAO;AAGf,UAAI,MAAM,SAAS,UAAU,eAAe,KAAK,OAAO,MAAM,MAAM,CAAC,EAAE,OAGrE,aAAY,KAAK,MAAM;;AAI3B,YAAO,SAAS,OAAO,OAAO,GAAG,GAAG,YAAY;AAChD,YAAO;;;IAGX;;;;;;ACvDN,SAAgB,YAAY,MAA2B;AACrD,KAAI,cAAc,KAAM,QAAO,KAAK,SAAS,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC,KAAK,GAAG;AAExF,KAAI,WAAW,KAAM,QAAO,KAAK;AAEjC,QAAO;;;;;;;;;;ACaT,MAAM,iBAAiB;CACrB;EACE,OAAO;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nC,OAAI,UAAU,WAAW,EAAG,QAAO;GAEnC,MAAM,aAAa,uBAAuB,KAAK;GAC/C,MAAM,EAAE,MAAM,cAAc,YAAY,eAAe,UAAU;GACjE,MAAM,aAAaD,OAAK,QAAQ,SAAS,aAAa,KAAK,MAAM,KAAK,SAAU,aAAa;AAE7F,SAAM,KACJ,aAAa,YAAY,SAAS,YAAY,KAAK,CAAC,MAAM,YAAY;AACpE,WAAO,OAAO,UAAU,OAAO,SAAS,cAAc,SAAS,MAAM,QAAQ;KAC7E,CACH;AAED,UAAO;IACP;AAEF,QAAM,QAAQ,IAAI,MAAM;;AAG1B,QAAO,OAAO,MAAM,SAAS;AAC3B,QAAM,OAAO,MAAM,KAAK"}
|
|
1
|
+
{"version":3,"file":"remark-include-BnRd6OBo.js","names":["newChildren: RootContent[]","extractedLines: string[]","ElementLikeTypes: ElementLikeContent['type'][]","attributes: Record<string, string | null>","nodes: RootContent[] | undefined","content: string","fs","path","queue: Promise<void>[]"],"sources":["../src/loaders/mdx/remark-unravel.ts","../src/loaders/mdx/mdast-utils.ts","../src/loaders/mdx/remark-include.ts"],"sourcesContent":["// from internal remark plugins in https://github.com/mdx-js/mdx/blob/main/packages/mdx/lib/plugin/remark-mark-and-unravel.js\n// we need to ensure consistency with MDX.js when parsing embed content in `remark-include`\nimport { visit } from 'unist-util-visit';\nimport type { Transformer } from 'unified';\nimport type { Root, RootContent } from 'mdast';\n\nexport function remarkMarkAndUnravel(): Transformer<Root, Root> {\n return (tree) => {\n visit(tree, function (node, index, parent) {\n let offset = -1;\n let all = true;\n let oneOrMore = false;\n\n if (parent && typeof index === 'number' && node.type === 'paragraph') {\n const children = node.children;\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === 'mdxJsxTextElement' || child.type === 'mdxTextExpression') {\n oneOrMore = true;\n } else if (child.type === 'text' && child.value.trim().length === 0) {\n // Empty.\n } else {\n all = false;\n break;\n }\n }\n\n if (all && oneOrMore) {\n offset = -1;\n const newChildren: RootContent[] = [];\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === 'mdxJsxTextElement') {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = 'mdxJsxFlowElement';\n }\n\n if (child.type === 'mdxTextExpression') {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = 'mdxFlowExpression';\n }\n\n if (child.type === 'text' && /^[\\t\\r\\n ]+$/.test(String(child.value))) {\n // Empty.\n } else {\n newChildren.push(child);\n }\n }\n\n parent.children.splice(index, 1, ...newChildren);\n return index;\n }\n }\n });\n };\n}\n","import type { RootContent } from 'mdast';\n\nexport function flattenNode(node: RootContent): string {\n if ('children' in node) return node.children.map((child) => flattenNode(child)).join('');\n\n if ('value' in node) return node.value;\n\n return '';\n}\n","import { type Processor, type Transformer, unified } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport type { Code, Node, Root, RootContent } from 'mdast';\nimport * as path from 'node:path';\nimport * as fs from 'node:fs/promises';\nimport { fumaMatter } from '@/utils/fuma-matter';\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';\nimport { remarkHeading } from '@hanzo/docs-core/mdx-plugins';\nimport { VFile } from 'vfile';\nimport type { Directives } from 'mdast-util-directive';\nimport { remarkMarkAndUnravel } from '@/loaders/mdx/remark-unravel';\nimport { flattenNode } from './mdast-utils';\n\n/**\n * VS Code–style region extraction\n * Adapted from VitePress:\n * https://github.com/vuejs/vitepress/blob/main/src/node/markdown/plugins/snippet.ts\n */\n\n// region marker regexes\nconst REGION_MARKERS = [\n {\n start: /^\\s*\\/\\/\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*\\/\\/\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*<!--\\s*#?region\\b\\s*(.*?)\\s*-->/,\n end: /^\\s*<!--\\s*#?endregion\\b\\s*(.*?)\\s*-->/,\n },\n {\n start: /^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\//,\n end: /^\\s*\\/\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\//,\n },\n {\n start: /^\\s*#[rR]egion\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#[eE]nd ?[rR]egion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*(?:--|::|@?REM)\\s*#region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*(?:--|::|@?REM)\\s*#endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#pragma\\s+region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#pragma\\s+endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*\\(\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\)/,\n end: /^\\s*\\(\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\)/,\n },\n];\n\nfunction dedent(lines: string[]): string {\n const minIndent = lines.reduce((min, line) => {\n const match = line.match(/^(\\s*)\\S/);\n return match ? Math.min(min, match[1].length) : min;\n }, Infinity);\n\n return minIndent === Infinity\n ? lines.join('\\n')\n : lines.map((l) => l.slice(minIndent)).join('\\n');\n}\n\nfunction extractCodeRegion(content: string, regionName: string): string {\n const lines = content.split('\\n');\n\n for (let i = 0; i < lines.length; i++) {\n for (const re of REGION_MARKERS) {\n let match = re.start.exec(lines[i]);\n if (match?.[1] !== regionName) continue;\n\n let depth = 1;\n const extractedLines: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n match = re.start.exec(lines[j]);\n if (match) {\n depth++;\n continue;\n }\n\n match = re.end.exec(lines[j]);\n if (match) {\n if (match[1] === regionName) depth = 0;\n else if (match[1] === '') depth--;\n else continue;\n\n if (depth > 0) continue;\n return dedent(extractedLines);\n } else {\n extractedLines.push(lines[j]);\n }\n }\n }\n }\n throw new Error(`Region \"${regionName}\" not found`);\n}\n\nexport interface Params {\n lang?: string;\n meta?: string;\n}\n\nconst ElementLikeTypes: ElementLikeContent['type'][] = [\n 'mdxJsxFlowElement',\n 'mdxJsxTextElement',\n 'containerDirective',\n 'textDirective',\n 'leafDirective',\n];\ntype ElementLikeContent = MdxJsxFlowElement | MdxJsxTextElement | Directives;\n\nfunction isElementLike(node: Node): node is ElementLikeContent {\n return ElementLikeTypes.includes(node.type as ElementLikeContent['type']);\n}\n\nfunction parseElementAttributes(\n element: ElementLikeContent,\n): Record<string, string | null | undefined> {\n if (Array.isArray(element.attributes)) {\n const attributes: Record<string, string | null> = {};\n\n for (const attr of element.attributes) {\n if (\n attr.type === 'mdxJsxAttribute' &&\n (typeof attr.value === 'string' || attr.value === null)\n ) {\n attributes[attr.name] = attr.value;\n }\n }\n\n return attributes;\n }\n\n return element.attributes ?? {};\n}\n\nfunction parseSpecifier(specifier: string): {\n file: string;\n section?: string;\n} {\n const idx = specifier.lastIndexOf('#');\n if (idx === -1) return { file: specifier };\n\n return {\n file: specifier.slice(0, idx),\n section: specifier.slice(idx + 1),\n };\n}\n\nfunction extractSection(root: Root, section: string): Root | undefined {\n let nodes: RootContent[] | undefined;\n let capturingHeadingContent = false;\n\n visit(root, (node) => {\n if (node.type === 'heading') {\n if (capturingHeadingContent) {\n return false;\n }\n\n if (node.data?.hProperties?.id === section) {\n capturingHeadingContent = true;\n nodes = [node];\n return 'skip';\n }\n\n return;\n }\n\n if (capturingHeadingContent) {\n nodes?.push(node as RootContent);\n return 'skip';\n }\n\n if (isElementLike(node) && node.name === 'section') {\n const attributes = parseElementAttributes(node);\n\n if (attributes.id === section) {\n nodes = node.children;\n return false;\n }\n }\n });\n\n if (nodes)\n return {\n type: 'root',\n children: nodes,\n };\n}\n\nexport function remarkInclude(this: Processor): Transformer<Root, Root> {\n const TagName = 'include';\n\n const embedContent = async (\n targetPath: string,\n heading: string | undefined,\n params: Params,\n parent: VFile,\n ) => {\n const { _getProcessor = () => this, _compiler } = parent.data;\n let content: string;\n try {\n content = (await fs.readFile(targetPath)).toString();\n } catch (e) {\n throw new Error(\n `failed to read file ${targetPath}\\n${e instanceof Error ? e.message : String(e)}`,\n { cause: e },\n );\n }\n\n const ext = path.extname(targetPath);\n _compiler?.addDependency(targetPath);\n // For non-Markdown files, support VS Code–style region extraction\n if (params.lang || (ext !== '.md' && ext !== '.mdx')) {\n const lang = params.lang ?? ext.slice(1);\n let value = content;\n if (heading) {\n value = extractCodeRegion(content, heading.trim());\n }\n return {\n type: 'code',\n lang,\n meta: params.meta,\n value,\n data: {},\n } satisfies Code;\n }\n\n const parser = _getProcessor(ext === '.mdx' ? 'mdx' : 'md');\n const parsed = fumaMatter(content);\n const targetFile = new VFile({\n path: targetPath,\n value: parsed.content,\n data: {\n ...parent.data,\n frontmatter: parsed.data as Record<string, unknown>,\n },\n });\n let mdast = parser.parse(targetFile) as Root;\n const baseProcessor = unified().use(remarkMarkAndUnravel);\n\n if (heading) {\n // parse headings before extraction\n const extracted = extractSection(await baseProcessor.use(remarkHeading).run(mdast), heading);\n if (!extracted)\n throw new Error(\n `Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id=\"${heading}\"> tag, or a :::section directive with remark-directive configured.`,\n );\n\n mdast = extracted;\n } else {\n mdast = await baseProcessor.run(mdast);\n }\n\n await update(mdast, targetFile);\n return mdast;\n };\n\n async function update(tree: Root, file: VFile) {\n const queue: Promise<void>[] = [];\n\n visit(tree, ElementLikeTypes, (_node, _, parent) => {\n const node = _node as ElementLikeContent;\n if (node.name !== TagName) return;\n\n const specifier = flattenNode(node);\n if (specifier.length === 0) return 'skip';\n\n const attributes = parseElementAttributes(node);\n const { file: relativePath, section } = parseSpecifier(specifier);\n const targetPath = path.resolve('cwd' in attributes ? file.cwd : file.dirname!, relativePath);\n\n queue.push(\n embedContent(targetPath, section, attributes, file).then((replace) => {\n Object.assign(parent && parent.type === 'paragraph' ? parent : node, replace);\n }),\n );\n\n return 'skip';\n });\n\n await Promise.all(queue);\n }\n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SAAS,aAAa,KAAK,MAAM,KAAK,SAAU,aAAa;AAE7F,SAAM,KACJ,aAAa,YAAY,SAAS,YAAY,KAAK,CAAC,MAAM,YAAY;AACpE,WAAO,OAAO,UAAU,OAAO,SAAS,cAAc,SAAS,MAAM,QAAQ;KAC7E,CACH;AAED,UAAO;IACP;AAEF,QAAM,QAAQ,IAAI,MAAM;;AAG1B,QAAO,OAAO,MAAM,SAAS;AAC3B,QAAM,OAAO,MAAM,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as DocCollection, N as DocsCollection } from "../core-
|
|
1
|
+
import { M as DocCollection, N as DocsCollection } from "../core-CgLkZ4NQ.js";
|
|
2
2
|
import { i as InternalTypeConfig } from "../types-CBMeukTI.js";
|
|
3
3
|
import { t as CompiledMDXProperties } from "../build-mdx-DyJk_jWV.js";
|
|
4
4
|
import { FC, ReactNode } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ServerOptions, M as DocCollection, N as DocsCollection, _ as AsyncDocCollectionEntry, r as CoreOptions, v as AsyncDocsCollectionEntry } from "../core-
|
|
1
|
+
import { C as ServerOptions, M as DocCollection, N as DocsCollection, _ as AsyncDocCollectionEntry, r as CoreOptions, v as AsyncDocsCollectionEntry } from "../core-CgLkZ4NQ.js";
|
|
2
2
|
import { i as InternalTypeConfig, r as FileInfo } from "../types-CBMeukTI.js";
|
|
3
3
|
import * as _standard_schema_spec0 from "@standard-schema/spec";
|
|
4
4
|
import * as _hanzo_docs_core_source0 from "@hanzo/docs-core/source";
|
package/dist/runtime/dynamic.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../preset-D_quDsKp.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import "../
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import "../
|
|
7
|
-
import { t as buildMDX } from "../build-mdx-
|
|
2
|
+
import { t as buildConfig } from "../build-DbdeZyKK.js";
|
|
3
|
+
import { n as createCore } from "../core-CCsY8cxS.js";
|
|
4
|
+
import "../codegen-IYa8t8xV.js";
|
|
5
|
+
import { t as fumaMatter } from "../fuma-matter-BWdOvvCf.js";
|
|
6
|
+
import "../remark-include-BnRd6OBo.js";
|
|
7
|
+
import { t as buildMDX } from "../build-mdx-BTwSGUFs.js";
|
|
8
8
|
import { server } from "./server.js";
|
|
9
|
-
import fs from "node:fs/promises";
|
|
10
9
|
import { pathToFileURL } from "node:url";
|
|
10
|
+
import fs from "node:fs/promises";
|
|
11
11
|
import { executeMdx } from "@hanzo/mdx-runtime/client";
|
|
12
12
|
|
|
13
13
|
//#region src/runtime/dynamic.ts
|
package/dist/runtime/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as ServerOptions, S as ServerCreate, T as toFumadocsSource, _ as AsyncDocCollectionEntry, b as DocsCollectionEntry, v as AsyncDocsCollectionEntry, w as server, x as MetaCollectionEntry, y as DocCollectionEntry } from "../core-
|
|
1
|
+
import { C as ServerOptions, S as ServerCreate, T as toFumadocsSource, _ as AsyncDocCollectionEntry, b as DocsCollectionEntry, v as AsyncDocsCollectionEntry, w as server, x as MetaCollectionEntry, y as DocCollectionEntry } from "../core-CgLkZ4NQ.js";
|
|
2
2
|
export { AsyncDocCollectionEntry, AsyncDocsCollectionEntry, DocCollectionEntry, DocsCollectionEntry, MetaCollectionEntry, ServerCreate, ServerOptions, server, toFumadocsSource };
|
package/dist/runtime/server.js
CHANGED
|
@@ -59,6 +59,9 @@ function server(options = {}) {
|
|
|
59
59
|
meta: await this.meta(name, base, metaGlob),
|
|
60
60
|
toFumadocsSource() {
|
|
61
61
|
return toFumadocsSource(this.docs, this.meta);
|
|
62
|
+
},
|
|
63
|
+
toSource() {
|
|
64
|
+
return toFumadocsSource(this.docs, this.meta);
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
67
|
},
|
|
@@ -68,6 +71,9 @@ function server(options = {}) {
|
|
|
68
71
|
meta: await this.meta(name, base, metaGlob),
|
|
69
72
|
toFumadocsSource() {
|
|
70
73
|
return toFumadocsSource(this.docs, this.meta);
|
|
74
|
+
},
|
|
75
|
+
toSource() {
|
|
76
|
+
return toFumadocsSource(this.docs, this.meta);
|
|
71
77
|
}
|
|
72
78
|
};
|
|
73
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["path","data: DocData","data: CompiledMDXProperties","files: VirtualFile<{\n pageData: Page;\n metaData: Meta;\n }>[]"],"sources":["../../src/runtime/server.ts"],"sourcesContent":["import type { MetaData, PageData, Source, VirtualFile } from '@hanzo/docs-core/source';\nimport * as path from 'node:path';\nimport type { DocCollection, DocsCollection, MetaCollection } from '@/config';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { CompiledMDXProperties } from '@/loaders/mdx/build-mdx';\nimport type { InternalTypeConfig, DocData, DocMethods, FileInfo, MetaMethods } from './types';\n\nexport type MetaCollectionEntry<Data> = Data & MetaMethods;\n\nexport type DocCollectionEntry<\n Name extends string = string,\n Frontmatter = unknown,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> = DocData & DocMethods & Frontmatter & TC['DocData'][Name];\n\nexport type AsyncDocCollectionEntry<\n Name extends string = string,\n Frontmatter = unknown,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> = {\n load: () => Promise<DocData & TC['DocData'][Name]>;\n} & DocMethods &\n Frontmatter;\n\nexport interface DocsCollectionEntry<\n Name extends string = string,\n Frontmatter extends PageData = PageData,\n Meta extends MetaData = MetaData,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> {\n docs: DocCollectionEntry<Name, Frontmatter, TC>[];\n meta: MetaCollectionEntry<Meta>[];\n toFumadocsSource: () => Source<{\n pageData: DocCollectionEntry<Name, Frontmatter, TC>;\n metaData: MetaCollectionEntry<Meta>;\n }>;\n}\n\nexport interface AsyncDocsCollectionEntry<\n Name extends string = string,\n Frontmatter extends PageData = PageData,\n Meta extends MetaData = MetaData,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> {\n docs: AsyncDocCollectionEntry<Name, Frontmatter, TC>[];\n meta: MetaCollectionEntry<Meta>[];\n toFumadocsSource: () => Source<{\n pageData: AsyncDocCollectionEntry<Name, Frontmatter, TC>;\n metaData: MetaCollectionEntry<Meta>;\n }>;\n}\n\ntype AwaitableGlobEntries<T> = Record<string, T | (() => Promise<T>)>;\n\nexport type ServerCreate<Config, TC extends InternalTypeConfig = InternalTypeConfig> = ReturnType<\n typeof server<Config, TC>\n>;\n\nexport interface ServerOptions {\n doc?: {\n passthroughs?: string[];\n };\n}\n\nexport function server<Config, TC extends InternalTypeConfig>(options: ServerOptions = {}) {\n const { doc: { passthroughs: docPassthroughs = [] } = {} } = options;\n\n function fileInfo(file: string, base: string): FileInfo {\n if (file.startsWith('./')) {\n file = file.slice(2);\n }\n\n return {\n path: file,\n fullPath: path.join(base, file),\n };\n }\n\n function mapDocData(entry: CompiledMDXProperties): DocData {\n const data: DocData = {\n body: entry.default,\n toc: entry.toc,\n structuredData: entry.structuredData,\n _exports: entry as unknown as Record<string, unknown>,\n };\n\n for (const key of docPassthroughs) {\n // @ts-expect-error -- handle passthrough properties\n data[key] = entry[key];\n }\n\n return data;\n }\n\n return {\n async doc<Name extends keyof Config & string>(\n _name: Name,\n base: string,\n glob: AwaitableGlobEntries<unknown>,\n ) {\n const out = await Promise.all(\n Object.entries(glob).map(async ([k, v]) => {\n const data: CompiledMDXProperties = typeof v === 'function' ? await v() : v;\n\n return {\n ...mapDocData(data),\n ...(data.frontmatter as object),\n ...createDocMethods(fileInfo(k, base), () => data),\n } satisfies DocCollectionEntry;\n }),\n );\n\n return out as unknown as Config[Name] extends\n | DocCollection<infer Schema>\n | DocsCollection<infer Schema>\n ? DocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC>[]\n : never;\n },\n async docLazy<Name extends keyof Config & string>(\n _name: Name,\n base: string,\n head: AwaitableGlobEntries<unknown>,\n body: Record<string, () => Promise<unknown>>,\n ) {\n const out = await Promise.all(\n Object.entries(head).map(async ([k, v]) => {\n const data = typeof v === 'function' ? await v() : v;\n const content = body[k] as () => Promise<CompiledMDXProperties>;\n\n return {\n ...data,\n ...createDocMethods(fileInfo(k, base), content),\n async load() {\n return mapDocData(await content());\n },\n } satisfies AsyncDocCollectionEntry;\n }),\n );\n\n return out as unknown as Config[Name] extends\n | DocCollection<infer Schema>\n | DocsCollection<infer Schema>\n ? AsyncDocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC>[]\n : never;\n },\n async meta<Name extends keyof Config & string>(\n _name: Name,\n base: string,\n glob: AwaitableGlobEntries<unknown>,\n ) {\n const out = await Promise.all(\n Object.entries(glob).map(async ([k, v]) => {\n const data = typeof v === 'function' ? await v() : v;\n\n return {\n info: fileInfo(k, base),\n ...data,\n } satisfies MetaCollectionEntry<unknown>;\n }),\n );\n\n return out as unknown as Config[Name] extends\n | MetaCollection<infer Schema>\n | DocsCollection<StandardSchemaV1, infer Schema>\n ? MetaCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[]\n : never;\n },\n\n async docs<Name extends keyof Config & string>(\n name: Name,\n base: string,\n metaGlob: AwaitableGlobEntries<unknown>,\n docGlob: AwaitableGlobEntries<unknown>,\n ) {\n const entry = {\n docs: await this.doc(name, base, docGlob),\n meta: await this.meta(name, base, metaGlob),\n toFumadocsSource() {\n return toFumadocsSource(this.docs, this.meta);\n },\n } satisfies DocsCollectionEntry;\n\n return entry as Config[Name] extends DocsCollection<infer Page, infer Meta>\n ? StandardSchemaV1.InferOutput<Page> extends PageData\n ? StandardSchemaV1.InferOutput<Meta> extends MetaData\n ? DocsCollectionEntry<\n Name,\n StandardSchemaV1.InferOutput<Page>,\n StandardSchemaV1.InferOutput<Meta>,\n TC\n >\n : never\n : never\n : never;\n },\n async docsLazy<Name extends keyof Config & string>(\n name: Name,\n base: string,\n metaGlob: AwaitableGlobEntries<unknown>,\n docHeadGlob: AwaitableGlobEntries<unknown>,\n docBodyGlob: Record<string, () => Promise<unknown>>,\n ) {\n const entry = {\n docs: await this.docLazy(name, base, docHeadGlob, docBodyGlob),\n meta: await this.meta(name, base, metaGlob),\n toFumadocsSource() {\n return toFumadocsSource(this.docs, this.meta);\n },\n } satisfies AsyncDocsCollectionEntry;\n\n return entry as Config[Name] extends DocsCollection<infer Page, infer Meta>\n ? StandardSchemaV1.InferOutput<Page> extends PageData\n ? StandardSchemaV1.InferOutput<Meta> extends MetaData\n ? AsyncDocsCollectionEntry<\n Name,\n StandardSchemaV1.InferOutput<Page>,\n StandardSchemaV1.InferOutput<Meta>,\n TC\n >\n : never\n : never\n : never;\n },\n };\n}\n\nexport function toFumadocsSource<\n Page extends DocMethods & PageData,\n Meta extends MetaMethods & MetaData,\n>(\n pages: Page[],\n metas: Meta[],\n): Source<{\n pageData: Page;\n metaData: Meta;\n}> {\n const files: VirtualFile<{\n pageData: Page;\n metaData: Meta;\n }>[] = [];\n\n for (const entry of pages) {\n files.push({\n type: 'page',\n path: entry.info.path,\n absolutePath: entry.info.fullPath,\n data: entry,\n });\n }\n\n for (const entry of metas) {\n files.push({\n type: 'meta',\n path: entry.info.path,\n absolutePath: entry.info.fullPath,\n data: entry,\n });\n }\n\n return {\n files,\n };\n}\n\nfunction createDocMethods(\n info: FileInfo,\n load: () => CompiledMDXProperties | Promise<CompiledMDXProperties>,\n): DocMethods {\n return {\n info,\n async getText(type) {\n if (type === 'raw') {\n const fs = await import('node:fs/promises');\n\n return (await fs.readFile(info.fullPath)).toString();\n }\n\n const data = await load();\n if (typeof data._markdown !== 'string')\n throw new Error(\n \"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config.\",\n );\n return data._markdown;\n },\n async getMDAST() {\n const data = await load();\n\n if (!data._mdast)\n throw new Error(\n 'getMDAST() requires `includeMDAST` to be enabled in your collection config.',\n );\n return JSON.parse(data._mdast);\n },\n };\n}\n"],"mappings":";;;AAgEA,SAAgB,OAA8C,UAAyB,EAAE,EAAE;CACzF,MAAM,EAAE,KAAK,EAA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
|
|
1
|
+
{"version":3,"file":"server.js","names":["path","data: DocData","data: CompiledMDXProperties","files: VirtualFile<{\n pageData: Page;\n metaData: Meta;\n }>[]"],"sources":["../../src/runtime/server.ts"],"sourcesContent":["import type { MetaData, PageData, Source, VirtualFile } from '@hanzo/docs-core/source';\nimport * as path from 'node:path';\nimport type { DocCollection, DocsCollection, MetaCollection } from '@/config';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { CompiledMDXProperties } from '@/loaders/mdx/build-mdx';\nimport type { InternalTypeConfig, DocData, DocMethods, FileInfo, MetaMethods } from './types';\n\nexport type MetaCollectionEntry<Data> = Data & MetaMethods;\n\nexport type DocCollectionEntry<\n Name extends string = string,\n Frontmatter = unknown,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> = DocData & DocMethods & Frontmatter & TC['DocData'][Name];\n\nexport type AsyncDocCollectionEntry<\n Name extends string = string,\n Frontmatter = unknown,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> = {\n load: () => Promise<DocData & TC['DocData'][Name]>;\n} & DocMethods &\n Frontmatter;\n\nexport interface DocsCollectionEntry<\n Name extends string = string,\n Frontmatter extends PageData = PageData,\n Meta extends MetaData = MetaData,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> {\n docs: DocCollectionEntry<Name, Frontmatter, TC>[];\n meta: MetaCollectionEntry<Meta>[];\n /** @deprecated Use toSource() instead */\n toFumadocsSource: () => Source<{\n pageData: DocCollectionEntry<Name, Frontmatter, TC>;\n metaData: MetaCollectionEntry<Meta>;\n }>;\n toSource: () => Source<{\n pageData: DocCollectionEntry<Name, Frontmatter, TC>;\n metaData: MetaCollectionEntry<Meta>;\n }>;\n}\n\nexport interface AsyncDocsCollectionEntry<\n Name extends string = string,\n Frontmatter extends PageData = PageData,\n Meta extends MetaData = MetaData,\n TC extends InternalTypeConfig = InternalTypeConfig,\n> {\n docs: AsyncDocCollectionEntry<Name, Frontmatter, TC>[];\n meta: MetaCollectionEntry<Meta>[];\n /** @deprecated Use toSource() instead */\n toFumadocsSource: () => Source<{\n pageData: AsyncDocCollectionEntry<Name, Frontmatter, TC>;\n metaData: MetaCollectionEntry<Meta>;\n }>;\n toSource: () => Source<{\n pageData: AsyncDocCollectionEntry<Name, Frontmatter, TC>;\n metaData: MetaCollectionEntry<Meta>;\n }>;\n}\n\ntype AwaitableGlobEntries<T> = Record<string, T | (() => Promise<T>)>;\n\nexport type ServerCreate<Config, TC extends InternalTypeConfig = InternalTypeConfig> = ReturnType<\n typeof server<Config, TC>\n>;\n\nexport interface ServerOptions {\n doc?: {\n passthroughs?: string[];\n };\n}\n\nexport function server<Config, TC extends InternalTypeConfig>(options: ServerOptions = {}) {\n const { doc: { passthroughs: docPassthroughs = [] } = {} } = options;\n\n function fileInfo(file: string, base: string): FileInfo {\n if (file.startsWith('./')) {\n file = file.slice(2);\n }\n\n return {\n path: file,\n fullPath: path.join(base, file),\n };\n }\n\n function mapDocData(entry: CompiledMDXProperties): DocData {\n const data: DocData = {\n body: entry.default,\n toc: entry.toc,\n structuredData: entry.structuredData,\n _exports: entry as unknown as Record<string, unknown>,\n };\n\n for (const key of docPassthroughs) {\n // @ts-expect-error -- handle passthrough properties\n data[key] = entry[key];\n }\n\n return data;\n }\n\n return {\n async doc<Name extends keyof Config & string>(\n _name: Name,\n base: string,\n glob: AwaitableGlobEntries<unknown>,\n ) {\n const out = await Promise.all(\n Object.entries(glob).map(async ([k, v]) => {\n const data: CompiledMDXProperties = typeof v === 'function' ? await v() : v;\n\n return {\n ...mapDocData(data),\n ...(data.frontmatter as object),\n ...createDocMethods(fileInfo(k, base), () => data),\n } satisfies DocCollectionEntry;\n }),\n );\n\n return out as unknown as Config[Name] extends\n | DocCollection<infer Schema>\n | DocsCollection<infer Schema>\n ? DocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC>[]\n : never;\n },\n async docLazy<Name extends keyof Config & string>(\n _name: Name,\n base: string,\n head: AwaitableGlobEntries<unknown>,\n body: Record<string, () => Promise<unknown>>,\n ) {\n const out = await Promise.all(\n Object.entries(head).map(async ([k, v]) => {\n const data = typeof v === 'function' ? await v() : v;\n const content = body[k] as () => Promise<CompiledMDXProperties>;\n\n return {\n ...data,\n ...createDocMethods(fileInfo(k, base), content),\n async load() {\n return mapDocData(await content());\n },\n } satisfies AsyncDocCollectionEntry;\n }),\n );\n\n return out as unknown as Config[Name] extends\n | DocCollection<infer Schema>\n | DocsCollection<infer Schema>\n ? AsyncDocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC>[]\n : never;\n },\n async meta<Name extends keyof Config & string>(\n _name: Name,\n base: string,\n glob: AwaitableGlobEntries<unknown>,\n ) {\n const out = await Promise.all(\n Object.entries(glob).map(async ([k, v]) => {\n const data = typeof v === 'function' ? await v() : v;\n\n return {\n info: fileInfo(k, base),\n ...data,\n } satisfies MetaCollectionEntry<unknown>;\n }),\n );\n\n return out as unknown as Config[Name] extends\n | MetaCollection<infer Schema>\n | DocsCollection<StandardSchemaV1, infer Schema>\n ? MetaCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[]\n : never;\n },\n\n async docs<Name extends keyof Config & string>(\n name: Name,\n base: string,\n metaGlob: AwaitableGlobEntries<unknown>,\n docGlob: AwaitableGlobEntries<unknown>,\n ) {\n const entry = {\n docs: await this.doc(name, base, docGlob),\n meta: await this.meta(name, base, metaGlob),\n toFumadocsSource() {\n return toFumadocsSource(this.docs, this.meta);\n },\n toSource() {\n return toFumadocsSource(this.docs, this.meta);\n },\n } satisfies DocsCollectionEntry;\n\n return entry as Config[Name] extends DocsCollection<infer Page, infer Meta>\n ? StandardSchemaV1.InferOutput<Page> extends PageData\n ? StandardSchemaV1.InferOutput<Meta> extends MetaData\n ? DocsCollectionEntry<\n Name,\n StandardSchemaV1.InferOutput<Page>,\n StandardSchemaV1.InferOutput<Meta>,\n TC\n >\n : never\n : never\n : never;\n },\n async docsLazy<Name extends keyof Config & string>(\n name: Name,\n base: string,\n metaGlob: AwaitableGlobEntries<unknown>,\n docHeadGlob: AwaitableGlobEntries<unknown>,\n docBodyGlob: Record<string, () => Promise<unknown>>,\n ) {\n const entry = {\n docs: await this.docLazy(name, base, docHeadGlob, docBodyGlob),\n meta: await this.meta(name, base, metaGlob),\n toFumadocsSource() {\n return toFumadocsSource(this.docs, this.meta);\n },\n toSource() {\n return toFumadocsSource(this.docs, this.meta);\n },\n } satisfies AsyncDocsCollectionEntry;\n\n return entry as Config[Name] extends DocsCollection<infer Page, infer Meta>\n ? StandardSchemaV1.InferOutput<Page> extends PageData\n ? StandardSchemaV1.InferOutput<Meta> extends MetaData\n ? AsyncDocsCollectionEntry<\n Name,\n StandardSchemaV1.InferOutput<Page>,\n StandardSchemaV1.InferOutput<Meta>,\n TC\n >\n : never\n : never\n : never;\n },\n };\n}\n\nexport function toFumadocsSource<\n Page extends DocMethods & PageData,\n Meta extends MetaMethods & MetaData,\n>(\n pages: Page[],\n metas: Meta[],\n): Source<{\n pageData: Page;\n metaData: Meta;\n}> {\n const files: VirtualFile<{\n pageData: Page;\n metaData: Meta;\n }>[] = [];\n\n for (const entry of pages) {\n files.push({\n type: 'page',\n path: entry.info.path,\n absolutePath: entry.info.fullPath,\n data: entry,\n });\n }\n\n for (const entry of metas) {\n files.push({\n type: 'meta',\n path: entry.info.path,\n absolutePath: entry.info.fullPath,\n data: entry,\n });\n }\n\n return {\n files,\n };\n}\n\nfunction createDocMethods(\n info: FileInfo,\n load: () => CompiledMDXProperties | Promise<CompiledMDXProperties>,\n): DocMethods {\n return {\n info,\n async getText(type) {\n if (type === 'raw') {\n const fs = await import('node:fs/promises');\n\n return (await fs.readFile(info.fullPath)).toString();\n }\n\n const data = await load();\n if (typeof data._markdown !== 'string')\n throw new Error(\n \"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config.\",\n );\n return data._markdown;\n },\n async getMDAST() {\n const data = await load();\n\n if (!data._mdast)\n throw new Error(\n 'getMDAST() requires `includeMDAST` to be enabled in your collection config.',\n );\n return JSON.parse(data._mdast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AAI,OAAO,KAAK,cAAc,SAC5B,OAAM,IAAI,MACR,oGACD;AACH,UAAO,KAAK;;EAEd,MAAM,WAAW;GACf,MAAM,OAAO,MAAM,MAAM;AAEzB,OAAI,CAAC,KAAK,OACR,OAAM,IAAI,MACR,8EACD;AACH,UAAO,KAAK,MAAM,KAAK,OAAO;;EAEjC"}
|
package/dist/vite/index.d.ts
CHANGED
package/dist/vite/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "../preset-D_quDsKp.js";
|
|
2
|
-
import "../
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
7
|
-
import { t as createMdxLoader } from "../mdx-
|
|
8
|
-
import { a as toVite, t as createIntegratedConfigLoader } from "../config-
|
|
9
|
-
import { t as createMetaLoader } from "../meta-
|
|
2
|
+
import { t as buildConfig } from "../build-DbdeZyKK.js";
|
|
3
|
+
import { n as createCore, r as ValidationError, t as _Defaults } from "../core-CCsY8cxS.js";
|
|
4
|
+
import "../codegen-IYa8t8xV.js";
|
|
5
|
+
import { t as indexFile } from "../index-file-DsOEtYCF.js";
|
|
6
|
+
import "../fuma-matter-BWdOvvCf.js";
|
|
7
|
+
import { t as createMdxLoader } from "../mdx-DBBqLhht.js";
|
|
8
|
+
import { a as toVite, t as createIntegratedConfigLoader } from "../config-s4QVhqzA.js";
|
|
9
|
+
import { t as createMetaLoader } from "../meta-u6oJ9ej1.js";
|
|
10
10
|
import { mergeConfig } from "vite";
|
|
11
11
|
|
|
12
12
|
//#region src/vite/index.ts
|
|
@@ -56,7 +56,7 @@ async function mdx(config, pluginOptions = {}) {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
async function postInstall(pluginOptions = {}) {
|
|
59
|
-
const { loadConfig } = await import("../load-from-file-
|
|
59
|
+
const { loadConfig } = await import("../load-from-file-DPPJI83O.js");
|
|
60
60
|
const core = createViteCore(applyDefaults(pluginOptions));
|
|
61
61
|
await core.init({ config: loadConfig(core, true) });
|
|
62
62
|
await core.emit({ write: true });
|
package/dist/webpack/mdx.d.ts
CHANGED
package/dist/webpack/mdx.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import { t as createMdxLoader } from "../mdx-
|
|
5
|
-
import { n as createStandaloneConfigLoader, o as toWebpack } from "../config-
|
|
6
|
-
import { t as getCore } from "../webpack-
|
|
1
|
+
import "../core-CCsY8cxS.js";
|
|
2
|
+
import "../codegen-IYa8t8xV.js";
|
|
3
|
+
import "../fuma-matter-BWdOvvCf.js";
|
|
4
|
+
import { t as createMdxLoader } from "../mdx-DBBqLhht.js";
|
|
5
|
+
import { n as createStandaloneConfigLoader, o as toWebpack } from "../config-s4QVhqzA.js";
|
|
6
|
+
import { t as getCore } from "../webpack-fHsy5QQI.js";
|
|
7
7
|
|
|
8
8
|
//#region src/webpack/mdx.ts
|
|
9
9
|
let instance;
|
package/dist/webpack/meta.d.ts
CHANGED
package/dist/webpack/meta.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../core-
|
|
2
|
-
import "../codegen-
|
|
3
|
-
import { n as createStandaloneConfigLoader, o as toWebpack } from "../config-
|
|
4
|
-
import { t as createMetaLoader } from "../meta-
|
|
5
|
-
import { t as getCore } from "../webpack-
|
|
1
|
+
import "../core-CCsY8cxS.js";
|
|
2
|
+
import "../codegen-IYa8t8xV.js";
|
|
3
|
+
import { n as createStandaloneConfigLoader, o as toWebpack } from "../config-s4QVhqzA.js";
|
|
4
|
+
import { t as createMetaLoader } from "../meta-u6oJ9ej1.js";
|
|
5
|
+
import { t as getCore } from "../webpack-fHsy5QQI.js";
|
|
6
6
|
|
|
7
7
|
//#region src/webpack/meta.ts
|
|
8
8
|
let instance;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createCore } from "./core-
|
|
1
|
+
import { n as createCore } from "./core-CCsY8cxS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/webpack/index.ts
|
|
4
4
|
let core;
|
|
@@ -12,4 +12,4 @@ function getCore(options) {
|
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
export { getCore as t };
|
|
15
|
-
//# sourceMappingURL=webpack-
|
|
15
|
+
//# sourceMappingURL=webpack-fHsy5QQI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-
|
|
1
|
+
{"version":3,"file":"webpack-fHsy5QQI.js","names":["core: Core"],"sources":["../src/webpack/index.ts"],"sourcesContent":["import { type Core, createCore } from '@/core';\n\nexport interface WebpackLoaderOptions {\n absoluteCompiledConfigPath: string;\n configPath: string;\n outDir: string;\n isDev: boolean;\n}\n\nlet core: Core;\n\nexport function getCore(options: WebpackLoaderOptions) {\n return (core ??= createCore({\n environment: 'webpack',\n outDir: options.outDir,\n configPath: options.configPath,\n }));\n}\n"],"mappings":";;;AASA,IAAIA;AAEJ,SAAgB,QAAQ,SAA+B;AACrD,QAAQ,SAAS,WAAW;EAC1B,aAAa;EACb,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACrB,CAAC"}
|