fuma-content 1.0.3 → 1.1.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/dist/{async-cache-C0J_pTbk.js → async-cache-U87GzQTb.js} +1 -1
- package/dist/{async-cache-C0J_pTbk.js.map → async-cache-U87GzQTb.js.map} +1 -1
- package/dist/{build-mdx-DugsQ0sk.js → build-mdx-BZxE8t2a.js} +14 -9
- package/dist/build-mdx-BZxE8t2a.js.map +1 -0
- package/dist/build-mdx-LhpFasX-.js +4 -0
- package/dist/bun/index.d.ts +7 -4
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +25 -14
- package/dist/bun/index.js.map +1 -1
- package/dist/{bun-Br1ReMiq.js → bun-CBROq3I0.js} +2 -2
- package/dist/bun-CBROq3I0.js.map +1 -0
- package/dist/code-generator-CjC4EEXg.js +102 -0
- package/dist/code-generator-CjC4EEXg.js.map +1 -0
- package/dist/collections/data/runtime.d.ts +15 -0
- package/dist/collections/data/runtime.d.ts.map +1 -0
- package/dist/collections/{meta → data}/runtime.js +4 -4
- package/dist/collections/data/runtime.js.map +1 -0
- package/dist/collections/data.d.ts +47 -0
- package/dist/collections/data.d.ts.map +1 -0
- package/dist/collections/data.js +5 -0
- package/dist/collections/fs.d.ts +3 -0
- package/dist/collections/fs.js +3 -0
- package/dist/collections/index.d.ts +2 -2
- package/dist/collections/index.js +2 -15
- package/dist/collections/json/loader-webpack.d.ts +9 -0
- package/dist/collections/json/loader-webpack.d.ts.map +1 -0
- package/dist/collections/json/loader-webpack.js +15 -0
- package/dist/collections/json/loader-webpack.js.map +1 -0
- package/dist/collections/mdx/loader-webpack.d.ts +5 -5
- package/dist/collections/mdx/loader-webpack.d.ts.map +1 -1
- package/dist/collections/mdx/loader-webpack.js +11 -21
- package/dist/collections/mdx/loader-webpack.js.map +1 -1
- package/dist/collections/mdx/react.d.ts +22 -0
- package/dist/collections/mdx/react.d.ts.map +1 -0
- package/dist/collections/mdx/react.js +35 -0
- package/dist/collections/mdx/react.js.map +1 -0
- package/dist/collections/mdx/runtime-browser.d.ts +11 -45
- package/dist/collections/mdx/runtime-browser.js +6 -44
- package/dist/collections/mdx/runtime-browser.js.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.d.ts +16 -28
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.js +17 -20
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
- package/dist/collections/mdx/runtime.d.ts +10 -49
- package/dist/collections/mdx/runtime.js +2 -11
- package/dist/collections/mdx/runtime.js.map +1 -1
- package/dist/collections/mdx.d.ts +6 -2
- package/dist/collections/mdx.js +6 -247
- package/dist/collections/runtime/file-store.d.ts +4 -22
- package/dist/collections/runtime/file-store.js +15 -14
- package/dist/collections/runtime/file-store.js.map +1 -1
- package/dist/collections/runtime/store.d.ts +3 -3
- package/dist/collections/runtime/store.js +2 -2
- package/dist/collections/yaml/loader-webpack.d.ts +9 -0
- package/dist/collections/yaml/loader-webpack.d.ts.map +1 -0
- package/dist/collections/yaml/loader-webpack.js +15 -0
- package/dist/collections/yaml/loader-webpack.js.map +1 -0
- package/dist/collections-DNFRdCuB.js +98 -0
- package/dist/collections-DNFRdCuB.js.map +1 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/core-BO3b8jMg.d.ts +313 -0
- package/dist/core-BO3b8jMg.d.ts.map +1 -0
- package/dist/{core-CnZQDCJ1.js → core-D5QHSKk6.js} +65 -47
- package/dist/core-D5QHSKk6.js.map +1 -0
- package/dist/data-9h98oZwj.js +158 -0
- package/dist/data-9h98oZwj.js.map +1 -0
- package/dist/dynamic-CTYYdl7_.d.ts +33 -0
- package/dist/dynamic-CTYYdl7_.d.ts.map +1 -0
- package/dist/dynamic-DhKTOrIl.js +29 -0
- package/dist/dynamic-DhKTOrIl.js.map +1 -0
- package/dist/dynamic.d.ts +3 -24
- package/dist/dynamic.js +2 -27
- package/dist/file-store-laO4IjvB.d.ts +21 -0
- package/dist/file-store-laO4IjvB.d.ts.map +1 -0
- package/dist/fs-D34Sztbh.d.ts +44 -0
- package/dist/fs-D34Sztbh.d.ts.map +1 -0
- package/dist/fs-WWbLA7Gx.js +66 -0
- package/dist/fs-WWbLA7Gx.js.map +1 -0
- package/dist/{fuma-matter-D3kkMkdj.js → fuma-matter-BuBO2w-p.js} +1 -1
- package/dist/{fuma-matter-D3kkMkdj.js.map → fuma-matter-BuBO2w-p.js.map} +1 -1
- package/dist/git-2CjUW3M5.d.ts +37 -0
- package/dist/git-2CjUW3M5.d.ts.map +1 -0
- package/dist/git-CQWA37-X.js +60 -0
- package/dist/git-CQWA37-X.js.map +1 -0
- package/dist/index-Da88Sj8w.d.ts +87 -0
- package/dist/index-Da88Sj8w.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -5
- package/dist/load-from-file-BZxc_BhC.js +3 -0
- package/dist/{load-from-file-XiM8eZha.js → load-from-file-irx0JI6j.js} +4 -6
- package/dist/load-from-file-irx0JI6j.js.map +1 -0
- package/dist/loader-AIEwGc2f.js +9 -0
- package/dist/loader-BhXHF8vy.js +16 -0
- package/dist/loader-BhXHF8vy.js.map +1 -0
- package/dist/loader-BuR4gkKg.js +77 -0
- package/dist/loader-BuR4gkKg.js.map +1 -0
- package/dist/loader-BzQpSBvP.js +59 -0
- package/dist/loader-BzQpSBvP.js.map +1 -0
- package/dist/{loader-C7W_Rwj8.js → loader-D6StkShK.js} +7 -6
- package/dist/loader-D6StkShK.js.map +1 -0
- package/dist/loader-DCK4RwOh.js +8 -0
- package/dist/loader-DwpOcxgh.js +17 -0
- package/dist/loader-DwpOcxgh.js.map +1 -0
- package/dist/loader-zsTVgQjO.js +8 -0
- package/dist/mdx-Dt9hirUu.d.ts +144 -0
- package/dist/mdx-Dt9hirUu.d.ts.map +1 -0
- package/dist/mdx-iZ2uP27Z.js +303 -0
- package/dist/mdx-iZ2uP27Z.js.map +1 -0
- package/dist/next/index.d.ts +6 -10
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +20 -28
- package/dist/next/index.js.map +1 -1
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +10 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/loader.d.ts +5 -2
- package/dist/node/loader.d.ts.map +1 -1
- package/dist/node/loader.js +17 -11
- package/dist/node/loader.js.map +1 -1
- package/dist/{node-CVAU22o3.js → node-2VZOh3P9.js} +7 -5
- package/dist/node-2VZOh3P9.js.map +1 -0
- package/dist/plugins/git.d.ts +3 -2
- package/dist/plugins/git.js +2 -61
- package/dist/plugins/json-schema.d.ts +26 -2
- package/dist/plugins/json-schema.d.ts.map +1 -0
- package/dist/plugins/json-schema.js +41 -50
- package/dist/plugins/json-schema.js.map +1 -1
- package/dist/plugins/loader/index.d.ts +4 -0
- package/dist/plugins/loader/index.js +3 -0
- package/dist/plugins/loader/webpack.d.ts +4 -0
- package/dist/plugins/loader/webpack.js +60 -0
- package/dist/plugins/loader/webpack.js.map +1 -0
- package/dist/runtime-HN-HSB0Z.d.ts +31 -0
- package/dist/runtime-HN-HSB0Z.d.ts.map +1 -0
- package/dist/runtime-browser-BQEk7qjc.d.ts +29 -0
- package/dist/runtime-browser-BQEk7qjc.d.ts.map +1 -0
- package/dist/store-DiuGdV5M.d.ts +31 -0
- package/dist/store-DiuGdV5M.d.ts.map +1 -0
- package/dist/{store-D166MOLw.js → store-IvpEBdxi.js} +4 -4
- package/dist/store-IvpEBdxi.js.map +1 -0
- package/dist/{validation-BYUzZIfc.js → validation-BvVvvLII.js} +1 -1
- package/dist/{validation-BYUzZIfc.js.map → validation-BvVvvLII.js.map} +1 -1
- package/dist/vite/index.d.ts +5 -15
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +18 -21
- package/dist/vite/index.js.map +1 -1
- package/dist/{vite-6awgG092.js → vite-C1qXY47G.js} +2 -2
- package/dist/vite-C1qXY47G.js.map +1 -0
- package/package.json +19 -18
- package/dist/build-mdx-CSrSOQxF.js +0 -4
- package/dist/build-mdx-DugsQ0sk.js.map +0 -1
- package/dist/bun-Br1ReMiq.js.map +0 -1
- package/dist/code-generator-BvuyL0UO.js +0 -133
- package/dist/code-generator-BvuyL0UO.js.map +0 -1
- package/dist/collections/handlers/fs.d.ts +0 -2
- package/dist/collections/handlers/fs.js +0 -31
- package/dist/collections/handlers/fs.js.map +0 -1
- package/dist/collections/index.js.map +0 -1
- package/dist/collections/mdx/runtime-browser.d.ts.map +0 -1
- package/dist/collections/mdx/runtime.d.ts.map +0 -1
- package/dist/collections/mdx.js.map +0 -1
- package/dist/collections/meta/loader-webpack.d.ts +0 -9
- package/dist/collections/meta/loader-webpack.d.ts.map +0 -1
- package/dist/collections/meta/loader-webpack.js +0 -25
- package/dist/collections/meta/loader-webpack.js.map +0 -1
- package/dist/collections/meta/runtime.d.ts +0 -11
- package/dist/collections/meta/runtime.d.ts.map +0 -1
- package/dist/collections/meta/runtime.js.map +0 -1
- package/dist/collections/meta.d.ts +0 -2
- package/dist/collections/meta.js +0 -131
- package/dist/collections/meta.js.map +0 -1
- package/dist/collections/runtime/file-store.d.ts.map +0 -1
- package/dist/core-CRWvbE7W.d.ts +0 -588
- package/dist/core-CRWvbE7W.d.ts.map +0 -1
- package/dist/core-CnZQDCJ1.js.map +0 -1
- package/dist/dynamic.d.ts.map +0 -1
- package/dist/dynamic.js.map +0 -1
- package/dist/load-from-file-BctwhOUd.js +0 -3
- package/dist/load-from-file-XiM8eZha.js.map +0 -1
- package/dist/loader-BHMDOncZ.js +0 -4
- package/dist/loader-C7W_Rwj8.js.map +0 -1
- package/dist/loader-DLSJPUiO.js +0 -69
- package/dist/loader-DLSJPUiO.js.map +0 -1
- package/dist/loader-DkmGoUvo.js +0 -4
- package/dist/next/index.cjs +0 -497
- package/dist/node-CVAU22o3.js.map +0 -1
- package/dist/pipe-UEMV1mRg.js +0 -31
- package/dist/pipe-UEMV1mRg.js.map +0 -1
- package/dist/plugins/git.js.map +0 -1
- package/dist/plugins/with-loader/index.d.ts +0 -2
- package/dist/plugins/with-loader/index.js +0 -28
- package/dist/plugins/with-loader/index.js.map +0 -1
- package/dist/plugins/with-loader/webpack.d.ts +0 -19
- package/dist/plugins/with-loader/webpack.d.ts.map +0 -1
- package/dist/plugins/with-loader/webpack.js +0 -43
- package/dist/plugins/with-loader/webpack.js.map +0 -1
- package/dist/store-BtGmZUAC.d.ts +0 -31
- package/dist/store-BtGmZUAC.d.ts.map +0 -1
- package/dist/store-D166MOLw.js.map +0 -1
- package/dist/vite-6awgG092.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fuma-content",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The content processing layer for your app.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
6
|
+
"Content",
|
|
7
7
|
"Docs"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://fuma-content.vercel.app",
|
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
"repository": "github:fuma-nama/fuma-content",
|
|
13
13
|
"bin": "./dist/bin.js",
|
|
14
14
|
"files": [
|
|
15
|
-
"loader-mdx.cjs",
|
|
16
|
-
"loader-meta.cjs",
|
|
17
15
|
"dist/*"
|
|
18
16
|
],
|
|
19
17
|
"type": "module",
|
|
@@ -30,8 +28,7 @@
|
|
|
30
28
|
},
|
|
31
29
|
"./next": {
|
|
32
30
|
"types": "./dist/next/index.d.ts",
|
|
33
|
-
"import": "./dist/next/index.js"
|
|
34
|
-
"require": "./dist/next/index.cjs"
|
|
31
|
+
"import": "./dist/next/index.js"
|
|
35
32
|
},
|
|
36
33
|
"./vite": {
|
|
37
34
|
"types": "./dist/vite/index.d.ts",
|
|
@@ -45,22 +42,26 @@
|
|
|
45
42
|
"types": "./dist/collections/index.d.ts",
|
|
46
43
|
"import": "./dist/collections/index.js"
|
|
47
44
|
},
|
|
45
|
+
"./collections/mdx/react": {
|
|
46
|
+
"types": "./dist/collections/mdx/react.d.ts",
|
|
47
|
+
"import": "./dist/collections/mdx/react.js"
|
|
48
|
+
},
|
|
48
49
|
"./collections/*": {
|
|
49
50
|
"types": "./dist/collections/*.d.ts",
|
|
50
51
|
"import": "./dist/collections/*.js",
|
|
51
52
|
"default": "./dist/collections/*.js"
|
|
52
53
|
},
|
|
53
|
-
"./node
|
|
54
|
-
"types": "./dist/node/
|
|
55
|
-
"import": "./dist/node/
|
|
54
|
+
"./node": {
|
|
55
|
+
"types": "./dist/node/index.d.ts",
|
|
56
|
+
"import": "./dist/node/index.js"
|
|
56
57
|
},
|
|
57
58
|
"./bun": {
|
|
58
59
|
"types": "./dist/bun/index.d.ts",
|
|
59
60
|
"import": "./dist/bun/index.js"
|
|
60
61
|
},
|
|
61
|
-
"./plugins/
|
|
62
|
-
"types": "./dist/plugins/
|
|
63
|
-
"import": "./dist/plugins/
|
|
62
|
+
"./plugins/loader": {
|
|
63
|
+
"types": "./dist/plugins/loader/index.d.ts",
|
|
64
|
+
"import": "./dist/plugins/loader/index.js"
|
|
64
65
|
},
|
|
65
66
|
"./plugins/*": {
|
|
66
67
|
"types": "./dist/plugins/*.d.ts",
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
"dependencies": {
|
|
74
75
|
"@mdx-js/mdx": "^3.1.1",
|
|
75
76
|
"@standard-schema/spec": "^1.1.0",
|
|
77
|
+
"@types/mdx": "^2.0.13",
|
|
76
78
|
"chokidar": "^5.0.0",
|
|
77
79
|
"esbuild": "^0.27.2",
|
|
78
80
|
"estree-util-value-to-estree": "^3.5.0",
|
|
@@ -90,17 +92,16 @@
|
|
|
90
92
|
"zod": "^4.3.5"
|
|
91
93
|
},
|
|
92
94
|
"devDependencies": {
|
|
93
|
-
"@types/bun": "^1.3.
|
|
95
|
+
"@types/bun": "^1.3.6",
|
|
94
96
|
"@types/js-yaml": "^4.0.9",
|
|
95
97
|
"@types/mdast": "^4.0.4",
|
|
96
|
-
"@types/
|
|
97
|
-
"@types/node": "^25.0.3",
|
|
98
|
+
"@types/node": "^25.0.9",
|
|
98
99
|
"@types/picomatch": "^4.0.2",
|
|
99
|
-
"@types/react": "^19.2.
|
|
100
|
-
"fumadocs-core": "^16.4.
|
|
100
|
+
"@types/react": "^19.2.8",
|
|
101
|
+
"fumadocs-core": "^16.4.7",
|
|
101
102
|
"mdast-util-directive": "^3.1.0",
|
|
102
103
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
103
|
-
"next": "16.1.
|
|
104
|
+
"next": "16.1.3",
|
|
104
105
|
"react": "^19.2.3",
|
|
105
106
|
"remark": "^15.0.1",
|
|
106
107
|
"remark-directive": "^4.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-mdx-DugsQ0sk.js","names":["newChildren: RootContent[]","ElementLikeTypes: ElementLikeContent[\"type\"][]","attributes: Record<string, string | null>","nodes: RootContent[] | undefined","extractedLines: string[]","content: string","fs","path","queue: Promise<void>[]","_stringifyProcessor: Processor | undefined","urls: ExtractedReference[]","postprocessOptions: PostprocessOptions","remarkIncludeOptions: RemarkIncludeOptions"],"sources":["../src/collections/mdx/remark-unravel.ts","../src/collections/mdx/mdast-utils.ts","../src/collections/mdx/remark-include.ts","../src/collections/mdx/remark-postprocess.ts","../src/collections/mdx/remark-preprocess.ts","../src/collections/mdx/build-mdx.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, (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 PluggableList, 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 \"@/collections/mdx/fuma-matter\";\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from \"mdast-util-mdx-jsx\";\nimport { VFile } from \"vfile\";\nimport type { Directives } from \"mdast-util-directive\";\nimport { remarkMarkAndUnravel } from \"@/collections/mdx/remark-unravel\";\nimport { flattenNode } from \"./mdast-utils\";\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\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 RemarkIncludeOptions {\n /**\n * remark plugins to preprocess the MDAST tree before scanning headings/sections.\n *\n * e.g. parse headings before extraction.\n */\n preprocess?: PluggableList;\n}\n\nexport function remarkInclude(\n this: Processor,\n { preprocess = [] }: RemarkIncludeOptions = {},\n): Transformer<Root, Root> {\n const TagName = \"include\";\n const preprocessor = unified().use(remarkMarkAndUnravel).use(preprocess);\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 if (params.lang || (ext !== \".md\" && ext !== \".mdx\")) {\n const lang = params.lang ?? ext.slice(1);\n\n return {\n type: \"code\",\n lang,\n meta: params.meta,\n value: heading ? extractCodeRegion(content, heading) : content,\n data: {},\n } satisfies Code;\n }\n\n const parser = await _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\n let mdast = await preprocessor.run(parser.parse(targetFile) as Root, targetFile);\n\n if (heading) {\n const extracted = extractSection(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 }\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(\n \"cwd\" in attributes ? file.cwd : (file.dirname ?? \"\"),\n relativePath,\n );\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","import type { Processor, Transformer } from \"unified\";\nimport type { Root, RootContent } from \"mdast\";\nimport { visit } from \"unist-util-visit\";\nimport { toMarkdown } from \"mdast-util-to-markdown\";\nimport { valueToEstree } from \"estree-util-value-to-estree\";\nimport { removePosition } from \"unist-util-remove-position\";\nimport remarkMdx from \"remark-mdx\";\nimport { flattenNode } from \"./mdast-utils\";\n\nexport interface ExtractedReference {\n href: string;\n}\n\nexport interface PostprocessOptions {\n _format: \"md\" | \"mdx\";\n\n /**\n * Properties to export from `vfile.data`\n */\n valueToExport?: string[];\n\n /**\n * stringify MDAST and export via `_markdown`.\n */\n includeProcessedMarkdown?: boolean;\n\n /**\n * extract link references, export via `extractedReferences`.\n */\n extractLinkReferences?: boolean;\n\n /**\n * store MDAST and export via `_mdast`.\n */\n includeMDAST?:\n | boolean\n | {\n removePosition?: boolean;\n };\n}\n\n/**\n * - collect references\n * - write frontmatter (auto-title & description)\n */\nexport function remarkPostprocess(\n this: Processor,\n {\n _format,\n includeProcessedMarkdown = false,\n includeMDAST = false,\n extractLinkReferences = false,\n valueToExport = [],\n }: PostprocessOptions,\n): Transformer<Root, Root> {\n let _stringifyProcessor: Processor | undefined;\n const getStringifyProcessor = () => {\n return (_stringifyProcessor ??=\n _format === \"mdx\"\n ? this\n : // force Markdown processor to stringify MDX nodes\n this().use(remarkMdx).freeze());\n };\n\n return (tree, file) => {\n const frontmatter = (file.data.frontmatter ??= {});\n if (!frontmatter.title) {\n visit(tree, \"heading\", (node) => {\n if (node.depth === 1) {\n frontmatter.title = flattenNode(node);\n return false;\n }\n });\n }\n\n file.data[\"mdx-export\"] ??= [];\n file.data[\"mdx-export\"].push({\n name: \"frontmatter\",\n value: frontmatter,\n });\n\n if (extractLinkReferences) {\n const urls: ExtractedReference[] = [];\n\n visit(tree, \"link\", (node) => {\n urls.push({\n href: node.url,\n });\n return \"skip\";\n });\n\n file.data[\"mdx-export\"].push({\n name: \"extractedReferences\",\n value: urls,\n });\n }\n\n if (includeProcessedMarkdown) {\n const processor = getStringifyProcessor();\n const markdown = toMarkdown(tree, {\n ...processor.data(\"settings\"),\n // from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js\n extensions: processor.data(\"toMarkdownExtensions\") || [],\n });\n\n file.data[\"mdx-export\"].push({\n name: \"_markdown\",\n value: markdown,\n });\n }\n\n if (includeMDAST) {\n const options = includeMDAST === true ? {} : includeMDAST;\n const mdast = JSON.stringify(\n options.removePosition ? removePosition(structuredClone(tree)) : tree,\n );\n\n file.data[\"mdx-export\"].push({\n name: \"_mdast\",\n value: mdast,\n });\n }\n\n for (const { name, value } of file.data[\"mdx-export\"]) {\n tree.children.unshift(getMdastExport(name, value));\n }\n\n // reset the data to reduce memory usage\n file.data[\"mdx-export\"] = [];\n\n for (const name of valueToExport) {\n if (!(name in file.data)) continue;\n\n tree.children.unshift(getMdastExport(name, file.data[name]));\n }\n };\n}\n\n/**\n * MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins\n *\n * Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node\n */\nfunction getMdastExport(name: string, value: unknown): RootContent {\n return {\n type: \"mdxjsEsm\",\n value: \"\",\n data: {\n estree: {\n type: \"Program\",\n sourceType: \"module\",\n body: [\n {\n type: \"ExportNamedDeclaration\",\n specifiers: [],\n attributes: [],\n source: null,\n declaration: {\n type: \"VariableDeclaration\",\n kind: \"let\",\n declarations: [\n {\n type: \"VariableDeclarator\",\n id: {\n type: \"Identifier\",\n name,\n },\n init: valueToEstree(value),\n },\n ],\n },\n },\n ],\n },\n },\n };\n}\n","import type { Processor, Transformer } from \"unified\";\nimport type { Root } from \"mdast\";\n\nexport interface PreprocessOptions {\n preprocessor?: Processor<Root>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap {\n _preprocessed?: boolean;\n }\n}\n\nexport function remarkPreprocess(options?: PreprocessOptions): Transformer<Root, Root> {\n return async (tree, file) => {\n if (file.data._preprocessed) return;\n file.data._preprocessed = true;\n\n if (options?.preprocessor) {\n return (await options.preprocessor.run(tree)) as Root;\n }\n };\n}\n","import { createProcessor } from \"@mdx-js/mdx\";\nimport { VFile } from \"vfile\";\nimport { remarkInclude, type RemarkIncludeOptions } from \"@/collections/mdx/remark-include\";\nimport { type PostprocessOptions, remarkPostprocess } from \"@/collections/mdx/remark-postprocess\";\nimport type { Core } from \"@/core\";\nimport { remarkPreprocess } from \"@/collections/mdx/remark-preprocess\";\nimport type { Pluggable } from \"unified\";\nimport type { Collection } from \"@/collections\";\nimport { createCache } from \"@/utils/async-cache\";\nimport type { CompilerOptions } from \"@/plugins/with-loader\";\nimport type { FC } from \"react\";\nimport type { MDXProps } from \"mdx/types\";\n\ntype MDXProcessor = ReturnType<typeof createProcessor>;\n\ninterface BuildMDXOptions {\n /**\n * Specify a file path for source\n */\n filePath: string;\n source: string;\n frontmatter?: Record<string, unknown>;\n\n environment: \"bundler\" | \"runtime\";\n isDevelopment: boolean;\n _compiler?: CompilerOptions;\n}\n\nexport interface FumaContentDataMap {\n /**\n * [Fuma Content] raw frontmatter, you can modify it\n */\n frontmatter?: Record<string, unknown>;\n\n /**\n * [Fuma Content] additional ESM exports to write\n */\n \"mdx-export\"?: { name: string; value: unknown }[];\n\n /**\n * [Fuma Content] The compiler object from loader\n */\n _compiler?: CompilerOptions;\n\n /**\n * [Fuma Content] get internal processor, do not use this on user land.\n */\n _getProcessor?: (format: \"md\" | \"mdx\") => MDXProcessor | Promise<MDXProcessor>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap extends FumaContentDataMap {}\n}\n\nexport type CompiledMDX<Frontmatter = Record<string, unknown>> = {\n frontmatter: Frontmatter;\n} & CompiledMDXData &\n Record<string, unknown>;\n\nexport interface CompiledMDXData {\n default: FC<MDXProps>;\n\n /**\n * Enable from `postprocess` option.\n */\n _markdown?: string;\n /**\n * Enable from `postprocess` option.\n */\n _mdast?: string;\n}\n\nexport async function buildMDX(\n core: Core,\n collection: Collection | undefined,\n { filePath, frontmatter, source, _compiler, environment, isDevelopment }: BuildMDXOptions,\n): Promise<VFile> {\n const handler = collection?.handlers.mdx;\n const processorCache = createCache(core.cache).$value<MDXProcessor>();\n\n function getProcessor(format: \"md\" | \"mdx\") {\n const key = `build-mdx:${collection?.name ?? \"global\"}:${format}`;\n\n return processorCache.cached(key, async () => {\n const mdxOptions = await handler?.getMDXOptions?.(environment);\n const preprocessPlugin = [remarkPreprocess, handler?.preprocess] satisfies Pluggable;\n const postprocessOptions: PostprocessOptions = {\n _format: format,\n ...handler?.postprocess,\n };\n const remarkIncludeOptions: RemarkIncludeOptions = {\n preprocess: [preprocessPlugin],\n };\n\n return createProcessor({\n outputFormat: \"program\",\n development: isDevelopment,\n ...mdxOptions,\n remarkPlugins: [\n preprocessPlugin,\n [remarkInclude, remarkIncludeOptions],\n ...(mdxOptions?.remarkPlugins ?? []),\n [remarkPostprocess, postprocessOptions],\n ],\n format,\n });\n });\n }\n\n let vfile = new VFile({\n value: source,\n path: filePath,\n cwd: core.getOptions().cwd,\n data: {\n frontmatter,\n _compiler,\n _getProcessor: getProcessor,\n },\n });\n\n if (collection && handler) {\n vfile = await handler.vfile.run(vfile, {\n collection,\n filePath,\n source,\n });\n }\n\n return (await getProcessor(filePath.endsWith(\".mdx\") ? \"mdx\" : \"md\")).process(vfile);\n}\n"],"mappings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Aa,MAAM,SAAS,gBAAgB,YAAY;GAC9D,MAAM,mBAAmB,CAAC,kBAAkB,SAAS,WAAW;GAChE,MAAMC,qBAAyC;IAC7C,SAAS;IACT,GAAG,SAAS;IACb;GACD,MAAMC,uBAA6C,EACjD,YAAY,CAAC,iBAAiB,EAC/B;AAED,UAAO,gBAAgB;IACrB,cAAc;IACd,aAAa;IACb,GAAG;IACH,eAAe;KACb;KACA,CAAC,eAAe,qBAAqB;KACrC,GAAI,YAAY,iBAAiB,EAAE;KACnC,CAAC,mBAAmB,mBAAmB;KACxC;IACD;IACD,CAAC;IACF;;CAGJ,IAAI,QAAQ,IAAI,MAAM;EACpB,OAAO;EACP,MAAM;EACN,KAAK,KAAK,YAAY,CAAC;EACvB,MAAM;GACJ;GACA;GACA,eAAe;GAChB;EACF,CAAC;AAEF,KAAI,cAAc,QAChB,SAAQ,MAAM,QAAQ,MAAM,IAAI,OAAO;EACrC;EACA;EACA;EACD,CAAC;AAGJ,SAAQ,MAAM,aAAa,SAAS,SAAS,OAAO,GAAG,QAAQ,KAAK,EAAE,QAAQ,MAAM"}
|
package/dist/bun-Br1ReMiq.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun-Br1ReMiq.js","names":["input: LoaderInput"],"sources":["../src/plugins/with-loader/bun.ts"],"sourcesContent":["import { parse } from \"node:querystring\";\nimport { readFileSync } from \"node:fs\";\nimport type { LoaderInput, Loader, LoaderOutput } from \"@/plugins/with-loader\";\n\nexport function toBun(test: RegExp = /.+/, loader: Loader) {\n function toResult(output: LoaderOutput | null): Bun.OnLoadResult {\n // it errors, treat this as an exception\n if (!output) return;\n\n return {\n contents: output.code,\n loader: output.moduleType ?? \"js\",\n };\n }\n\n return (build: Bun.PluginBuilder): void => {\n // avoid using async here, because it will cause dynamic require() to fail\n build.onLoad({ filter: test }, (args) => {\n const [filePath, query = \"\"] = args.path.split(\"?\", 2);\n const input: LoaderInput = {\n async getSource() {\n return Bun.file(filePath).text();\n },\n query: parse(query),\n filePath,\n development: false,\n compiler: {\n addDependency() {},\n },\n };\n\n if (loader.bun?.load) {\n return loader.bun.load(readFileSync(filePath).toString(), input);\n }\n\n const result = loader.load(input);\n if (result instanceof Promise) {\n return result.then(toResult);\n }\n return toResult(result);\n });\n };\n}\n"],"mappings":";;;;AAIA,SAAgB,MAAM,OAAe,MAAM,QAAgB;CACzD,SAAS,SAAS,QAA+C;AAE/D,MAAI,CAAC,OAAQ;AAEb,SAAO;GACL,UAAU,OAAO;GACjB,QAAQ,OAAO,cAAc;GAC9B;;AAGH,SAAQ,UAAmC;AAEzC,QAAM,OAAO,EAAE,QAAQ,MAAM,GAAG,SAAS;GACvC,MAAM,CAAC,UAAU,QAAQ,MAAM,KAAK,KAAK,MAAM,KAAK,EAAE;GACtD,MAAMA,QAAqB;IACzB,MAAM,YAAY;AAChB,YAAO,IAAI,KAAK,SAAS,CAAC,MAAM;;IAElC,OAAO,MAAM,MAAM;IACnB;IACA,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF;AAED,OAAI,OAAO,KAAK,KACd,QAAO,OAAO,IAAI,KAAK,aAAa,SAAS,CAAC,UAAU,EAAE,MAAM;GAGlE,MAAM,SAAS,OAAO,KAAK,MAAM;AACjC,OAAI,kBAAkB,QACpB,QAAO,OAAO,KAAK,SAAS;AAE9B,UAAO,SAAS,OAAO;IACvB"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { t as createCache } from "./async-cache-C0J_pTbk.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { glob } from "tinyglobby";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/code-generator.ts
|
|
6
|
-
function importInfo() {
|
|
7
|
-
return {
|
|
8
|
-
named: /* @__PURE__ */ new Map(),
|
|
9
|
-
namespaces: /* @__PURE__ */ new Set(),
|
|
10
|
-
isUsed: /* @__PURE__ */ new Set()
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Code generator (one instance per file)
|
|
15
|
-
*/
|
|
16
|
-
var CodeGenerator = class {
|
|
17
|
-
lines = [];
|
|
18
|
-
globCache;
|
|
19
|
-
importInfos = /* @__PURE__ */ new Map();
|
|
20
|
-
eagerImportId = 0;
|
|
21
|
-
options;
|
|
22
|
-
constructor({ target = "default", jsExtension = false, globCache = /* @__PURE__ */ new Map(), outDir = "" }) {
|
|
23
|
-
this.options = {
|
|
24
|
-
target,
|
|
25
|
-
jsExtension,
|
|
26
|
-
globCache,
|
|
27
|
-
outDir
|
|
28
|
-
};
|
|
29
|
-
this.globCache = createCache(globCache);
|
|
30
|
-
}
|
|
31
|
-
addNamespaceImport(namespace, specifier, types = false) {
|
|
32
|
-
const info = this.importInfos.get(specifier) ?? importInfo();
|
|
33
|
-
this.importInfos.set(specifier, info);
|
|
34
|
-
if (!types) info.isUsed.add(namespace);
|
|
35
|
-
info.namespaces.add(namespace);
|
|
36
|
-
}
|
|
37
|
-
addNamedImport(names, specifier, types = false) {
|
|
38
|
-
const info = this.importInfos.get(specifier) ?? importInfo();
|
|
39
|
-
this.importInfos.set(specifier, info);
|
|
40
|
-
for (const name of names) {
|
|
41
|
-
const [memberName, importName = memberName] = name.split(/\s+as\s+/, 2);
|
|
42
|
-
info.named.set(importName, memberName);
|
|
43
|
-
if (!types) info.isUsed.add(importName);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
push(...insert) {
|
|
47
|
-
this.lines.push(...insert);
|
|
48
|
-
}
|
|
49
|
-
async pushAsync(insert) {
|
|
50
|
-
for (const line of await Promise.all(insert)) {
|
|
51
|
-
if (line === void 0) continue;
|
|
52
|
-
this.lines.push(line);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async generateGlobImport(patterns, options) {
|
|
56
|
-
if (this.options.target === "vite") return this.generateViteGlobImport(patterns, options);
|
|
57
|
-
return this.generateNodeGlobImport(patterns, options);
|
|
58
|
-
}
|
|
59
|
-
generateViteGlobImport(patterns, { base, ...rest }) {
|
|
60
|
-
patterns = (typeof patterns === "string" ? [patterns] : patterns).map(normalizeViteGlobPath);
|
|
61
|
-
return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify({
|
|
62
|
-
base: normalizeViteGlobPath(path.relative(this.options.outDir, base)),
|
|
63
|
-
...rest
|
|
64
|
-
}, null, 2)})`;
|
|
65
|
-
}
|
|
66
|
-
async generateNodeGlobImport(patterns, { base, eager = false, query = {}, import: importName }) {
|
|
67
|
-
const files = await this.globCache.cached(JSON.stringify({
|
|
68
|
-
patterns,
|
|
69
|
-
base
|
|
70
|
-
}), () => glob(patterns, { cwd: base }));
|
|
71
|
-
let code = "{";
|
|
72
|
-
for (const item of files) {
|
|
73
|
-
const fullPath = path.join(base, item);
|
|
74
|
-
const searchParams = new URLSearchParams();
|
|
75
|
-
for (const [k, v] of Object.entries(query)) if (v !== void 0) searchParams.set(k, v);
|
|
76
|
-
const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;
|
|
77
|
-
if (eager) {
|
|
78
|
-
const name = `__fd_glob_${this.eagerImportId++}`;
|
|
79
|
-
this.lines.unshift(importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`);
|
|
80
|
-
code += `${JSON.stringify(item)}: ${name}, `;
|
|
81
|
-
} else {
|
|
82
|
-
let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
|
|
83
|
-
if (importName) line += `.then(mod => mod.${importName})`;
|
|
84
|
-
code += `${line}, `;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
code += "}";
|
|
88
|
-
return code;
|
|
89
|
-
}
|
|
90
|
-
formatImportPath(file) {
|
|
91
|
-
const ext = path.extname(file);
|
|
92
|
-
let filename;
|
|
93
|
-
if (ext === ".ts") {
|
|
94
|
-
filename = file.substring(0, file.length - ext.length);
|
|
95
|
-
if (this.options.jsExtension) filename += ".js";
|
|
96
|
-
} else filename = file;
|
|
97
|
-
const importPath = slash(path.relative(this.options.outDir, filename));
|
|
98
|
-
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
99
|
-
}
|
|
100
|
-
toString() {
|
|
101
|
-
const final = ["// @ts-nocheck"];
|
|
102
|
-
if (this.options.target === "vite") final.push("/// <reference types=\"vite/client\" />");
|
|
103
|
-
for (const [specifier, info] of this.importInfos) {
|
|
104
|
-
const { namespaces, named, isUsed } = info;
|
|
105
|
-
for (const namespace of namespaces) final.push(isUsed.has(namespace) ? `import * as ${namespace} from "${specifier}";` : `import type * as ${namespace} from "${specifier}";`);
|
|
106
|
-
const namedImports = [];
|
|
107
|
-
for (const [importName, memberName] of named) {
|
|
108
|
-
const item = importName === memberName ? importName : `${memberName} as ${importName}`;
|
|
109
|
-
namedImports.push(isUsed.has(importName) ? item : `type ${item}`);
|
|
110
|
-
}
|
|
111
|
-
if (namedImports.length > 0) final.push(`import { ${namedImports.join(", ")} } from "${specifier}";`);
|
|
112
|
-
}
|
|
113
|
-
final.push(...this.lines);
|
|
114
|
-
return final.join("\n");
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* convert into POSIX & relative file paths, such that Vite can accept it.
|
|
119
|
-
*/
|
|
120
|
-
function normalizeViteGlobPath(file) {
|
|
121
|
-
file = slash(file);
|
|
122
|
-
if (file.startsWith("./")) return file;
|
|
123
|
-
if (file.startsWith("/")) return `.${file}`;
|
|
124
|
-
return `./${file}`;
|
|
125
|
-
}
|
|
126
|
-
function slash(path$1) {
|
|
127
|
-
if (path$1.startsWith("\\\\?\\")) return path$1;
|
|
128
|
-
return path$1.replaceAll("\\", "/");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
export { slash as n, CodeGenerator as t };
|
|
133
|
-
//# sourceMappingURL=code-generator-BvuyL0UO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-generator-BvuyL0UO.js","names":["code: string","filename: string","final: string[]","namedImports: string[]","path"],"sources":["../src/utils/code-generator.ts"],"sourcesContent":["import path from \"node:path\";\nimport { glob } from \"tinyglobby\";\nimport { type AsyncCache, createCache } from \"@/utils/async-cache\";\n\nexport interface GlobImportOptions {\n base: string;\n query?: Record<string, string | undefined>;\n import?: string;\n eager?: boolean;\n}\n\nexport interface CodeGeneratorOptions {\n target: \"default\" | \"vite\";\n outDir: string;\n /**\n * add .js extenstion to imports\n */\n jsExtension: boolean;\n globCache: Map<string, Promise<string[]>>;\n}\n\ninterface ImportInfo {\n // import name -> member name\n named: Map<string, string>;\n namespaces: Set<string>;\n /**\n * a set of import names, the import is type-only if its name is missing in this set.\n */\n isUsed: Set<string>;\n}\n\nfunction importInfo(): ImportInfo {\n return {\n named: new Map(),\n namespaces: new Set(),\n isUsed: new Set(),\n };\n}\n\n/**\n * Code generator (one instance per file)\n */\nexport class CodeGenerator {\n private readonly lines: string[] = [];\n private readonly globCache: AsyncCache<string[]>;\n // specifier -> imported members/info\n private readonly importInfos = new Map<string, ImportInfo>();\n private eagerImportId = 0;\n\n readonly options: CodeGeneratorOptions;\n constructor({\n target = \"default\",\n jsExtension = false,\n globCache = new Map(),\n outDir = \"\",\n }: Partial<CodeGeneratorOptions>) {\n this.options = {\n target,\n jsExtension,\n globCache,\n outDir,\n };\n this.globCache = createCache(globCache);\n }\n\n addNamespaceImport(namespace: string, specifier: string, types = false) {\n const info = this.importInfos.get(specifier) ?? importInfo();\n this.importInfos.set(specifier, info);\n if (!types) info.isUsed.add(namespace);\n info.namespaces.add(namespace);\n }\n\n addNamedImport(names: string[], specifier: string, types = false) {\n const info = this.importInfos.get(specifier) ?? importInfo();\n this.importInfos.set(specifier, info);\n for (const name of names) {\n const [memberName, importName = memberName] = name.split(/\\s+as\\s+/, 2);\n info.named.set(importName, memberName);\n if (!types) info.isUsed.add(importName);\n }\n }\n\n push(...insert: string[]) {\n this.lines.push(...insert);\n }\n\n async pushAsync(insert: Promise<string | undefined>[]) {\n for (const line of await Promise.all(insert)) {\n if (line === undefined) continue;\n\n this.lines.push(line);\n }\n }\n\n async generateGlobImport(\n patterns: string | string[],\n options: GlobImportOptions,\n ): Promise<string> {\n if (this.options.target === \"vite\") {\n return this.generateViteGlobImport(patterns, options);\n }\n\n return this.generateNodeGlobImport(patterns, options);\n }\n\n private generateViteGlobImport(\n patterns: string | string[],\n { base, ...rest }: GlobImportOptions,\n ): string {\n patterns = (typeof patterns === \"string\" ? [patterns] : patterns).map(normalizeViteGlobPath);\n\n return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(\n {\n base: normalizeViteGlobPath(path.relative(this.options.outDir, base)),\n ...rest,\n },\n null,\n 2,\n )})`;\n }\n\n private async generateNodeGlobImport(\n patterns: string | string[],\n { base, eager = false, query = {}, import: importName }: GlobImportOptions,\n ): Promise<string> {\n const files = await this.globCache.cached(JSON.stringify({ patterns, base }), () =>\n glob(patterns, {\n cwd: base,\n }),\n );\n\n let code: string = \"{\";\n for (const item of files) {\n const fullPath = path.join(base, item);\n const searchParams = new URLSearchParams();\n\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined) searchParams.set(k, v);\n }\n\n const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;\n if (eager) {\n const name = `__fd_glob_${this.eagerImportId++}`;\n this.lines.unshift(\n importName\n ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}`\n : `import * as ${name} from ${JSON.stringify(importPath)}`,\n );\n\n code += `${JSON.stringify(item)}: ${name}, `;\n } else {\n let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;\n if (importName) {\n line += `.then(mod => mod.${importName})`;\n }\n\n code += `${line}, `;\n }\n }\n\n code += \"}\";\n return code;\n }\n\n formatImportPath(file: string) {\n const ext = path.extname(file);\n let filename: string;\n\n if (ext === \".ts\") {\n filename = file.substring(0, file.length - ext.length);\n if (this.options.jsExtension) filename += \".js\";\n } else {\n filename = file;\n }\n\n const importPath = slash(path.relative(this.options.outDir, filename));\n return importPath.startsWith(\".\") ? importPath : `./${importPath}`;\n }\n\n toString() {\n const final: string[] = [\"// @ts-nocheck\"];\n if (this.options.target === \"vite\") {\n final.push('/// <reference types=\"vite/client\" />');\n }\n\n for (const [specifier, info] of this.importInfos) {\n const { namespaces, named, isUsed } = info;\n for (const namespace of namespaces) {\n final.push(\n isUsed.has(namespace)\n ? `import * as ${namespace} from \"${specifier}\";`\n : `import type * as ${namespace} from \"${specifier}\";`,\n );\n }\n\n const namedImports: string[] = [];\n for (const [importName, memberName] of named) {\n const item = importName === memberName ? importName : `${memberName} as ${importName}`;\n\n namedImports.push(isUsed.has(importName) ? item : `type ${item}`);\n }\n\n if (namedImports.length > 0) {\n final.push(`import { ${namedImports.join(\", \")} } from \"${specifier}\";`);\n }\n }\n\n final.push(...this.lines);\n return final.join(\"\\n\");\n }\n}\n\n/**\n * convert into POSIX & relative file paths, such that Vite can accept it.\n */\nfunction normalizeViteGlobPath(file: string) {\n file = slash(file);\n if (file.startsWith(\"./\")) return file;\n if (file.startsWith(\"/\")) return `.${file}`;\n\n return `./${file}`;\n}\n\nexport function slash(path: string): string {\n const isExtendedLengthPath = path.startsWith(\"\\\\\\\\?\\\\\");\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll(\"\\\\\", \"/\");\n}\n\nexport function ident(code: string, tab: number = 1) {\n return code\n .split(\"\\n\")\n .map((v) => \" \".repeat(tab) + v)\n .join(\"\\n\");\n}\n"],"mappings":";;;;;AA+BA,SAAS,aAAyB;AAChC,QAAO;EACL,uBAAO,IAAI,KAAK;EAChB,4BAAY,IAAI,KAAK;EACrB,wBAAQ,IAAI,KAAK;EAClB;;;;;AAMH,IAAa,gBAAb,MAA2B;CACzB,AAAiB,QAAkB,EAAE;CACrC,AAAiB;CAEjB,AAAiB,8BAAc,IAAI,KAAyB;CAC5D,AAAQ,gBAAgB;CAExB,AAAS;CACT,YAAY,EACV,SAAS,WACT,cAAc,OACd,4BAAY,IAAI,KAAK,EACrB,SAA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,aAAa,KAAK;;CAGxD,WAAW;EACT,MAAMC,QAAkB,CAAC,iBAAiB;AAC1C,MAAI,KAAK,QAAQ,WAAW,OAC1B,OAAM,KAAK,0CAAwC;AAGrD,OAAK,MAAM,CAAC,WAAW,SAAS,KAAK,aAAa;GAChD,MAAM,EAAE,YAAY,OAAO,WAAW;AACtC,QAAK,MAAM,aAAa,WACtB,OAAM,KACJ,OAAO,IAAI,UAAU,GACjB,eAAe,UAAU,SAAS,UAAU,MAC5C,oBAAoB,UAAU,SAAS,UAAU,IACtD;GAGH,MAAMC,eAAyB,EAAE;AACjC,QAAK,MAAM,CAAC,YAAY,eAAe,OAAO;IAC5C,MAAM,OAAO,eAAe,aAAa,aAAa,GAAG,WAAW,MAAM;AAE1E,iBAAa,KAAK,OAAO,IAAI,WAAW,GAAG,OAAO,QAAQ,OAAO;;AAGnE,OAAI,aAAa,SAAS,EACxB,OAAM,KAAK,YAAY,aAAa,KAAK,KAAK,CAAC,WAAW,UAAU,IAAI;;AAI5E,QAAM,KAAK,GAAG,KAAK,MAAM;AACzB,SAAO,MAAM,KAAK,KAAK;;;;;;AAO3B,SAAS,sBAAsB,MAAc;AAC3C,QAAO,MAAM,KAAK;AAClB,KAAI,KAAK,WAAW,KAAK,CAAE,QAAO;AAClC,KAAI,KAAK,WAAW,IAAI,CAAE,QAAO,IAAI;AAErC,QAAO,KAAK;;AAGd,SAAgB,MAAM,QAAsB;AAG1C,KAF6BC,OAAK,WAAW,UAAU,CAGrD,QAAOA;AAGT,QAAOA,OAAK,WAAW,MAAM,IAAI"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import picomatch from "picomatch";
|
|
3
|
-
|
|
4
|
-
//#region src/collections/handlers/fs.ts
|
|
5
|
-
function initFileCollection(collection, init, config) {
|
|
6
|
-
const { cwd } = init.core.getOptions();
|
|
7
|
-
const { supportedFormats } = config;
|
|
8
|
-
let matcher;
|
|
9
|
-
collection.handlers.fs = {
|
|
10
|
-
patterns: config.files ?? [supportedFormats ? `**/*.{${supportedFormats.join(",")}}` : `**/*`],
|
|
11
|
-
dir: path.resolve(cwd, config.dir),
|
|
12
|
-
isFileSupported(filePath) {
|
|
13
|
-
if (!supportedFormats) return true;
|
|
14
|
-
return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
|
|
15
|
-
},
|
|
16
|
-
async getFiles() {
|
|
17
|
-
const { glob } = await import("tinyglobby");
|
|
18
|
-
return (await glob(this.patterns, { cwd: this.dir })).filter((v) => this.isFileSupported(v));
|
|
19
|
-
},
|
|
20
|
-
hasFile(filePath) {
|
|
21
|
-
if (!this.isFileSupported(filePath)) return false;
|
|
22
|
-
const relativePath = path.relative(this.dir, filePath);
|
|
23
|
-
if (relativePath.startsWith(`..${path.sep}`)) return false;
|
|
24
|
-
return (matcher ??= picomatch(this.patterns))(relativePath);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { initFileCollection };
|
|
31
|
-
//# sourceMappingURL=fs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","names":["matcher: picomatch.Matcher"],"sources":["../../../src/collections/handlers/fs.ts"],"sourcesContent":["import picomatch from \"picomatch\";\nimport path from \"node:path\";\nimport type { Collection, InitOptions } from \"@/collections\";\n\nexport interface FileHandlerConfig {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n\n /**\n * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.\n */\n supportedFormats?: string[];\n}\n\nexport interface FIleCollectionHandler {\n /**\n * content directory (absolute)\n */\n dir: string;\n hasFile: (filePath: string) => boolean;\n isFileSupported: (filePath: string) => boolean;\n /**\n * get all included files, relative to `dir`\n */\n getFiles: () => Promise<string[]>;\n patterns: string[];\n}\n\nexport function initFileCollection(\n collection: Collection,\n init: InitOptions,\n config: FileHandlerConfig,\n) {\n const { cwd } = init.core.getOptions();\n const { supportedFormats } = config;\n let matcher: picomatch.Matcher;\n\n collection.handlers.fs = {\n patterns: config.files ?? [supportedFormats ? `**/*.{${supportedFormats.join(\",\")}}` : `**/*`],\n dir: path.resolve(cwd, config.dir),\n isFileSupported(filePath) {\n if (!supportedFormats) return true;\n\n return supportedFormats.some((format) => filePath.endsWith(`.${format}`));\n },\n async getFiles() {\n const { glob } = await import(\"tinyglobby\");\n return (await glob(this.patterns, { cwd: this.dir })).filter((v) => this.isFileSupported(v));\n },\n hasFile(filePath) {\n if (!this.isFileSupported(filePath)) return false;\n\n const relativePath = path.relative(this.dir, filePath);\n if (relativePath.startsWith(`..${path.sep}`)) return false;\n\n return (matcher ??= picomatch(this.patterns))(relativePath);\n },\n };\n}\n"],"mappings":";;;;AAqCA,SAAgB,mBACd,YACA,MACA,QACA;CACA,MAAM,EAAE,QAAQ,KAAK,KAAK,YAAY;CACtC,MAAM,EAAE,qBAAqB;CAC7B,IAAIA;AAEJ,YAAW,SAAS,KAAK;EACvB,UAAU,OAAO,SAAS,CAAC,mBAAmB,SAAS,iBAAiB,KAAK,IAAI,CAAC,KAAK,OAAO;EAC9F,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI;EAClC,gBAAgB,UAAU;AACxB,OAAI,CAAC,iBAAkB,QAAO;AAE9B,UAAO,iBAAiB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;EAE3E,MAAM,WAAW;GACf,MAAM,EAAE,SAAS,MAAM,OAAO;AAC9B,WAAQ,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,CAAC,EAAE,QAAQ,MAAM,KAAK,gBAAgB,EAAE,CAAC;;EAE9F,QAAQ,UAAU;AAChB,OAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE,QAAO;GAE5C,MAAM,eAAe,KAAK,SAAS,KAAK,KAAK,SAAS;AACtD,OAAI,aAAa,WAAW,KAAK,KAAK,MAAM,CAAE,QAAO;AAErD,WAAQ,YAAY,UAAU,KAAK,SAAS,EAAE,aAAa;;EAE9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/collections/index.ts"],"sourcesContent":["import type { JSONSchemaHandler } from \"@/plugins/json-schema\";\nimport type { FIleCollectionHandler } from \"@/collections/handlers/fs\";\nimport type { MDXCollectionHandler } from \"@/collections/mdx\";\nimport type { MetaCollectionHandler } from \"@/collections/meta\";\nimport type { VersionControlHandler } from \"@/plugins/git\";\nimport type { Core, PluginOption } from \"@/core\";\n\nexport interface InitOptions {\n name: string;\n core: Core;\n}\n\nexport interface Collection {\n name: string;\n init?: (options: InitOptions) => void;\n\n readonly handlers: CollectionHandlers;\n\n /**\n * information for the collection type, can be shared for all collections of same type.\n */\n readonly typeInfo: CollectionTypeInfo;\n}\n\nexport interface CollectionTypeInfo {\n /**\n * ID for collection type.\n *\n * @example `my-package:my-collection-type`\n */\n readonly id: string;\n\n /**\n * plugins to register, registered once for each collection type.\n */\n readonly plugins?: PluginOption;\n}\n\nexport interface CollectionHandlers {\n fs?: FIleCollectionHandler;\n mdx?: MDXCollectionHandler;\n meta?: MetaCollectionHandler;\n \"json-schema\"?: JSONSchemaHandler;\n \"version-control\"?: VersionControlHandler;\n}\n\nexport function createCollection(\n info: CollectionTypeInfo,\n init: (collection: Collection, options: InitOptions) => void,\n): Collection {\n return {\n name: \"\",\n handlers: {},\n init(options) {\n this.name = options.name;\n init(this, options);\n },\n typeInfo: info,\n };\n}\n"],"mappings":";AA8CA,SAAgB,iBACd,MACA,MACY;AACZ,QAAO;EACL,MAAM;EACN,UAAU,EAAE;EACZ,KAAK,SAAS;AACZ,QAAK,OAAO,QAAQ;AACpB,QAAK,MAAM,QAAQ;;EAErB,UAAU;EACX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-browser.d.ts","names":[],"sources":["../../../src/utils/async-cache.ts","../../../src/collections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V,CAoCkB,UApClB,CAoC6B,CApC7B,CAAA,MAAA,CAAA,CAAA,CAAA,GAoC2C,GApC3C,CAAA;CAAR,GAsCJ,CAtCI;AAAO,iBAyCL,oBAAA,CAAA,CAzCK,EAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EA6BV,CA7BU,EAAA,GA6BV,CA7BU,SA6BV,YA7BU,CAAA,OAAA,CAAA,GA6BV,CA7BU,GAAA;EAGL,QAAA,EAAA;IACP;;;IAIC,mBAAA,EAsCe,kBAtCf,EAAA;EAE6C,CAAA;CAAQ,IAAA,yBAAA,CAAA,OAAA,CAAA,IAAA,GAAA;EAAvB,IAAA,EAAA,GAAA,UAAA,QAAA,WAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA,GAAA;IAAjB;;;IAkBP,mBAAe,EAkBN,kBAlBM,EAAA;EACZ,CAAA,CAAA;CACP,IAAA;AAAU,iBAoBN,eAAA,CAAA,CApBM,EAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EADX,CACW,EAAA,GADX,CACW,SADX,YACW,CAAA,OAAA,CAAA,GADX,CACW,GAAA;EACd,QAAA,wBAAA;CACY,IAAA,yBAAA,CAAA,OAAA,CAAA,IAAA,GAAA;EAEZ,IAAA,EAAA,GAAA,UAAA,QAAA,WAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA,yBAAA,CAAA;CAAU,IAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mdx.js","names":["mdxTypeInfo: CollectionTypeInfo","mdxHandler: MDXCollectionHandler","mdxHandler","base","initializer: string","serializableCoreOptions: CoreOptions","base: Plugin","plugin","loaderOptions: WebpackLoaderOptions"],"sources":["../../src/collections/mdx.ts"],"sourcesContent":["import { type Collection, type CollectionTypeInfo, createCollection } from \"@/collections\";\nimport { type FileHandlerConfig, initFileCollection } from \"@/collections/handlers/fs\";\nimport type { PostprocessOptions } from \"@/collections/mdx/remark-postprocess\";\nimport type { CoreOptions, EmitCodeGeneratorContext, Plugin } from \"@/core\";\nimport type { ProcessorOptions } from \"@mdx-js/mdx\";\nimport path from \"node:path\";\nimport type { VFile } from \"vfile\";\nimport type { TurbopackLoaderOptions } from \"next/dist/server/config-shared\";\nimport type { Configuration } from \"webpack\";\nimport type { WebpackLoaderOptions } from \"@/plugins/with-loader/webpack\";\nimport { withLoader } from \"@/plugins/with-loader\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { PreprocessOptions } from \"@/collections/mdx/remark-preprocess\";\nimport { slash } from \"@/utils/code-generator\";\nimport { validate } from \"@/utils/validation\";\nimport type { Awaitable } from \"@/types\";\nimport { type AsyncPipe, asyncPipe, type Pipe, pipe } from \"@/utils/pipe\";\n\ninterface CompilationContext {\n collection: Collection;\n filePath: string;\n source: string;\n}\n\nexport interface MDXCollectionHandler {\n readonly dynamic: boolean;\n readonly lazy: boolean;\n\n preprocess?: PreprocessOptions;\n postprocess?: Partial<PostprocessOptions>;\n getMDXOptions?: (environment: \"bundler\" | \"runtime\") => Awaitable<ProcessorOptions>;\n\n /**\n * Frontmatter schema (if defined)\n */\n frontmatterSchema?: StandardSchemaV1;\n\n /**\n * Transform & validate frontmatter\n */\n frontmatter: AsyncPipe<Record<string, unknown> | undefined, CompilationContext>;\n\n /**\n * Transform `vfile` on compilation stage\n */\n vfile: AsyncPipe<VFile, CompilationContext>;\n\n /**\n * Transform the initializer code (TypeScript) for collection store\n */\n storeInitializer: Pipe<\n string,\n EmitCodeGeneratorContext & {\n environment: \"browser\" | \"server\" | \"dynamic\";\n }\n >;\n}\n\nexport interface MDXCollectionConfig<\n FrontmatterSchema extends StandardSchemaV1 | undefined = undefined,\n> extends FileHandlerConfig {\n postprocess?: Partial<PostprocessOptions>;\n frontmatter?: FrontmatterSchema;\n options?: (environment: \"bundler\" | \"runtime\") => Awaitable<ProcessorOptions>;\n lazy?: boolean;\n dynamic?: boolean;\n}\n\nexport interface MDXCollection<Frontmatter> extends Collection {\n _frontmatter?: Frontmatter;\n}\n\nconst mdxTypeInfo: CollectionTypeInfo = {\n id: \"mdx\",\n plugins: [plugin()],\n};\n\nconst RuntimePaths = {\n browser: \"fuma-content/collections/mdx/runtime-browser\",\n dynamic: \"fuma-content/collections/mdx/runtime-dynamic\",\n server: \"fuma-content/collections/mdx/runtime\",\n};\n\nexport function defineMDX<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined>(\n config: MDXCollectionConfig<FrontmatterSchema>,\n): MDXCollection<\n FrontmatterSchema extends StandardSchemaV1\n ? StandardSchemaV1.InferOutput<FrontmatterSchema>\n : Record<string, unknown>\n> {\n const { lazy = false, dynamic = false } = config;\n return createCollection(mdxTypeInfo, (collection, init) => {\n initFileCollection(collection, init, {\n supportedFormats: [\"mdx\", \"md\"],\n ...config,\n });\n const mdxHandler: MDXCollectionHandler = (collection.handlers.mdx = {\n postprocess: config.postprocess,\n getMDXOptions: config.options,\n dynamic,\n lazy: lazy,\n vfile: asyncPipe(),\n frontmatter: asyncPipe(),\n storeInitializer: pipe(),\n });\n\n if (config.frontmatter) {\n const frontmatter = config.frontmatter;\n // Store schema for use in studio/editors\n mdxHandler.frontmatterSchema = frontmatter;\n mdxHandler.frontmatter.pipe((data, { filePath }) => {\n return validate(\n frontmatter,\n data,\n undefined,\n `invalid frontmatter in ${filePath}`,\n ) as Promise<Record<string, unknown>>;\n });\n }\n\n if (mdxHandler.postprocess?.extractLinkReferences) {\n mdxHandler.storeInitializer.pipe((initializer, { codegen, environment }) => {\n codegen.addNamedImport([\"$extractedReferences\"], RuntimePaths[environment]);\n return `${initializer}.$data($extractedReferences())`;\n });\n }\n\n collection.handlers[\"version-control\"] = {\n client({ client }) {\n const mdxHandler = collection.handlers.mdx;\n if (!mdxHandler) return;\n\n mdxHandler.storeInitializer.pipe((initializer, { codegen, environment }) => {\n codegen.addNamedImport([\"$versionControl\"], RuntimePaths[environment]);\n return `${initializer}.$data($versionControl())`;\n });\n\n mdxHandler.vfile.pipe(async (file) => {\n const vcData = await client.getFileData({ filePath: file.path });\n file.data[\"mdx-export\"] ??= [];\n file.data[\"mdx-export\"].push(\n {\n name: \"lastModified\",\n value: vcData.lastModified,\n },\n {\n name: \"creationDate\",\n value: vcData.creationDate,\n },\n );\n return file;\n });\n },\n };\n });\n}\n\nfunction plugin(): Plugin {\n const mdxLoaderGlob = /\\.mdx?(\\?.+?)?$/;\n\n function generateDocCollectionFrontmatterGlob(\n context: EmitCodeGeneratorContext,\n collection: Collection,\n eager = false,\n ) {\n const handler = collection.handlers.fs;\n if (!handler) return \"\";\n return context.codegen.generateGlobImport(handler.patterns, {\n query: {\n collection: collection.name,\n only: \"frontmatter\",\n workspace: context.workspace,\n },\n import: \"frontmatter\",\n base: handler.dir,\n eager,\n });\n }\n\n function generateDocCollectionGlob(\n context: EmitCodeGeneratorContext,\n collection: Collection,\n eager = false,\n ) {\n const handler = collection.handlers.fs;\n if (!handler) return \"\";\n return context.codegen.generateGlobImport(handler.patterns, {\n query: {\n collection: collection.name,\n workspace: context.workspace,\n },\n base: handler.dir,\n eager,\n });\n }\n\n async function generateCollectionStoreServer(\n context: EmitCodeGeneratorContext,\n collection: Collection,\n ) {\n const mdxHandler = collection.handlers.mdx;\n const fsHandler = collection.handlers.fs;\n if (!fsHandler || !mdxHandler) return;\n const { core, codegen } = context;\n const runtimePath = RuntimePaths.server;\n const base = slash(core._toRuntimePath(fsHandler.dir));\n let initializer: string;\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n\n if (mdxHandler.lazy) {\n codegen.addNamedImport([\"mdxStoreLazy\"], runtimePath);\n const [headGlob, bodyGlob] = await Promise.all([\n generateDocCollectionFrontmatterGlob(context, collection, true),\n generateDocCollectionGlob(context, collection),\n ]);\n\n initializer = `mdxStoreLazy<typeof Config, \"${collection.name}\">(\"${collection.name}\", \"${base}\", { head: ${headGlob}, body: ${bodyGlob} })`;\n } else {\n codegen.addNamedImport([\"mdxStore\"], runtimePath);\n initializer = `mdxStore<typeof Config, \"${collection.name}\">(\"${collection.name}\", \"${base}\", ${await generateDocCollectionGlob(context, collection, true)})`;\n }\n\n initializer = mdxHandler.storeInitializer.run(initializer, {\n ...context,\n environment: \"server\",\n });\n codegen.push(`export const ${collection.name} = ${initializer};`);\n }\n\n async function generateCollectionStoreBrowser(\n context: EmitCodeGeneratorContext,\n collection: Collection,\n ) {\n const mdxHandler = collection.handlers.mdx;\n const fsHandler = collection.handlers.fs;\n if (!fsHandler || !mdxHandler) return;\n const { core, codegen } = context;\n const runtimePath = RuntimePaths.browser;\n codegen.addNamedImport([\"mdxStoreBrowser\"], runtimePath);\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n\n let initializer = `mdxStoreBrowser<typeof Config, \"${collection.name}\">(\"${collection.name}\", ${await generateDocCollectionGlob(context, collection)})`;\n\n initializer = mdxHandler.storeInitializer.run(initializer, {\n ...context,\n environment: \"browser\",\n });\n codegen.push(`export const ${collection.name} = ${initializer};`);\n }\n\n async function generateCollectionStoreDynamic(\n context: EmitCodeGeneratorContext,\n collection: Collection,\n ) {\n const mdxHandler = collection.handlers.mdx;\n const fsHandler = collection.handlers.fs;\n if (!fsHandler || !mdxHandler || !mdxHandler.dynamic) return;\n const { core, codegen } = context;\n const runtimePath = RuntimePaths.dynamic;\n const base = slash(core._toRuntimePath(fsHandler.dir));\n codegen.addNamespaceImport(\"Config\", codegen.formatImportPath(core.getOptions().configPath));\n codegen.addNamedImport([\"mdxStoreDynamic\"], runtimePath);\n\n const coreOptions = core.getOptions();\n const serializableCoreOptions: CoreOptions = {\n ...coreOptions,\n configPath: core._toRuntimePath(coreOptions.configPath),\n outDir: core._toRuntimePath(coreOptions.outDir),\n cwd: core._toRuntimePath(coreOptions.cwd),\n };\n let initializer = `mdxStoreDynamic<typeof Config, \"${collection.name}\">(Config, ${JSON.stringify(\n serializableCoreOptions,\n )}, \"${collection.name}\", \"${base}\", ${await generateDocCollectionFrontmatterGlob(context, collection, true)})`;\n\n initializer = mdxHandler.storeInitializer.run(initializer, {\n ...context,\n environment: \"dynamic\",\n });\n codegen.push(`export const ${collection.name} = ${initializer};`);\n }\n\n const base: Plugin = {\n name: \"mdx\",\n configureServer(server) {\n if (!server.watcher) return;\n\n server.watcher.on(\"all\", async (event, file) => {\n const updatedCollection = this.core.getCollections().find((collection) => {\n const handlers = collection.handlers;\n if (!handlers.mdx || !handlers.fs) return false;\n if (event === \"change\" && !handlers.mdx.dynamic) return false;\n return handlers.fs.hasFile(file);\n });\n\n if (!updatedCollection) return;\n await this.core.emit({\n filterPlugin: (plugin) => plugin.name === base.name,\n filterWorkspace: () => false,\n write: true,\n });\n });\n },\n emit() {\n return Promise.all([\n this.createCodeGenerator(\"mdx.ts\", async (ctx) => {\n for (const collection of this.core.getCollections()) {\n await generateCollectionStoreServer(ctx, collection);\n }\n }),\n\n this.createCodeGenerator(\"mdx-browser.ts\", async (ctx) => {\n for (const collection of this.core.getCollections()) {\n await generateCollectionStoreBrowser(ctx, collection);\n }\n\n ctx.codegen.push(`export { useRenderer } from \"${RuntimePaths.browser}\";`);\n }),\n\n this.createCodeGenerator(\"mdx-dynamic.ts\", async (ctx) => {\n for (const collection of this.core.getCollections()) {\n await generateCollectionStoreDynamic(ctx, collection);\n }\n }),\n ]);\n },\n next: {\n config(nextConfig) {\n const { configPath, outDir } = this.core.getOptions();\n const loaderPath = \"fuma-content/collections/mdx/loader-webpack\";\n const loaderOptions: WebpackLoaderOptions = {\n configPath,\n outDir,\n absoluteCompiledConfigPath: path.resolve(this.core.getCompiledConfigPath()),\n isDev: process.env.NODE_ENV === \"development\",\n };\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.{md,mdx}\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.js\",\n },\n },\n },\n pageExtensions: [\n ...(nextConfig.pageExtensions ?? [\"js\", \"jsx\", \"tsx\", \"ts\"]),\n \"mdx\",\n \"md\",\n ],\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test: mdxLoaderGlob,\n use: [\n options.defaultLoaders.babel,\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n },\n };\n\n return withLoader(base, {\n test: mdxLoaderGlob,\n async createLoader() {\n const { createMdxLoader } = await import(\"./mdx/loader\");\n return createMdxLoader({\n getCore: () => this.core,\n });\n },\n });\n}\n\nexport type { ExtractedReference } from \"@/collections/mdx/remark-postprocess\";\nexport type { CompiledMDXData, CompiledMDX } from \"@/collections/mdx/build-mdx\";\n"],"mappings":";;;;;;;;;AAwEA,MAAMA,cAAkC;CACtC,IAAI;CACJ,SAAS,CAAC,QAAQ,CAAC;CACpB;AAED,MAAM,eAAe;CACnB,SAAS;CACT,SAAS;CACT,QAAQ;CACT;AAED,SAAgB,UACd,QAKA;CACA,MAAM,EAAE,OAAO,OAAO,UAAU,UAAU;AAC1C,QAAO,iBAAiB,cAAc,YAAY,SAAS;AACzD,qBAAmB,YAAY,MAAM;GACnC,kBAAkB,CAAC,OAAO,KAAK;GAC/B,GAAG;GACJ,CAAC;EACF,MAAMC,aAAoC,WAAW,SAAS,MAAM;GAClE,aAAa,OAAO;GACpB,eAAe,OAAO;GACtB;GACM;GACN,OAAO,WAAW;GAClB,aAAa,WAAW;GACxB,kBAAkB,MAAM;GACzB;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,cAAc,OAAO;AAE3B,cAAW,oBAAoB;AAC/B,cAAW,YAAY,MAAM,MAAM,EAAE,eAAe;AAClD,WAAO,SACL,aACA,MACA,QACA,0BAA0B,WAC3B;KACD;;AAGJ,MAAI,WAAW,aAAa,sBAC1B,YAAW,iBAAiB,MAAM,aAAa,EAAE,SAAS,kBAAkB;AAC1E,WAAQ,eAAe,CAAC,uBAAuB,E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eAAe,OACvB;OACE,QAAQ;OACR,SAAS;OACV,CACF;MACF,CAAC;AAEF,YAAO,WAAW,UAAU,QAAQ,QAAQ,IAAI;;IAEnD;KAEJ;EACF;AAED,QAAO,WAAW,MAAM;EACtB,MAAM;EACN,MAAM,eAAe;GACnB,MAAM,EAAE,oBAAoB,MAAM,OAAO;AACzC,UAAO,gBAAgB,EACrB,eAAe,KAAK,MACrB,CAAC;;EAEL,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import "../../core-CRWvbE7W.js";
|
|
2
|
-
import { WebpackLoaderOptions } from "../../plugins/with-loader/webpack.js";
|
|
3
|
-
import { LoaderContext } from "webpack";
|
|
4
|
-
|
|
5
|
-
//#region src/collections/meta/loader-webpack.d.ts
|
|
6
|
-
declare function loader(this: LoaderContext<WebpackLoaderOptions>, source: string): Promise<void>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { loader as default };
|
|
9
|
-
//# sourceMappingURL=loader-webpack.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader-webpack.d.ts","names":[],"sources":["../../../src/collections/meta/loader-webpack.ts"],"sourcesContent":[],"mappings":";;;;;iBAY8B,MAAA,OACtB,cAAc,wCAEnB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createDynamicCore } from "../../dynamic.js";
|
|
2
|
-
import "../../code-generator-BvuyL0UO.js";
|
|
3
|
-
import "../../core-CnZQDCJ1.js";
|
|
4
|
-
import "../../validation-BYUzZIfc.js";
|
|
5
|
-
import { getCore, toWebpack } from "../../plugins/with-loader/webpack.js";
|
|
6
|
-
import { t as createMetaLoader } from "../../loader-DLSJPUiO.js";
|
|
7
|
-
|
|
8
|
-
//#region src/collections/meta/loader-webpack.ts
|
|
9
|
-
let instance;
|
|
10
|
-
async function loader(source) {
|
|
11
|
-
const callback = this.async();
|
|
12
|
-
const options = this.getOptions();
|
|
13
|
-
this.cacheable(true);
|
|
14
|
-
this.addDependency(options.absoluteCompiledConfigPath);
|
|
15
|
-
if (!instance) instance = toWebpack(createMetaLoader(createDynamicCore({
|
|
16
|
-
core: getCore(options),
|
|
17
|
-
buildConfig: false,
|
|
18
|
-
mode: options.isDev ? "dev" : "production"
|
|
19
|
-
}), { json: "json" }));
|
|
20
|
-
await instance.call(this, source, callback);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { loader as default };
|
|
25
|
-
//# sourceMappingURL=loader-webpack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader-webpack.js","names":["instance: WebpackLoader | undefined"],"sources":["../../../src/collections/meta/loader-webpack.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\nimport { createMetaLoader } from \"@/collections/meta/loader\";\nimport {\n toWebpack,\n getCore,\n type WebpackLoader,\n type WebpackLoaderOptions,\n} from \"@/plugins/with-loader/webpack\";\nimport { createDynamicCore } from \"@/dynamic\";\n\nlet instance: WebpackLoader | undefined;\n\nexport default async function loader(\n this: LoaderContext<WebpackLoaderOptions>,\n source: string,\n): Promise<void> {\n const callback = this.async();\n const options = this.getOptions();\n this.cacheable(true);\n this.addDependency(options.absoluteCompiledConfigPath);\n\n if (!instance) {\n instance = toWebpack(\n createMetaLoader(\n createDynamicCore({\n core: getCore(options),\n buildConfig: false,\n mode: options.isDev ? \"dev\" : \"production\",\n }),\n {\n json: \"json\",\n },\n ),\n );\n }\n\n await instance.call(this, source, callback);\n}\n"],"mappings":";;;;;;;;AAUA,IAAIA;AAEJ,eAA8B,OAE5B,QACe;CACf,MAAM,WAAW,KAAK,OAAO;CAC7B,MAAM,UAAU,KAAK,YAAY;AACjC,MAAK,UAAU,KAAK;AACpB,MAAK,cAAc,QAAQ,2BAA2B;AAEtD,KAAI,CAAC,SACH,YAAW,UACT,iBACE,kBAAkB;EAChB,MAAM,QAAQ,QAAQ;EACtB,aAAa;EACb,MAAM,QAAQ,QAAQ,QAAQ;EAC/B,CAAC,EACF,EACE,MAAM,QACP,CACF,CACF;AAGH,OAAM,SAAS,KAAK,MAAM,QAAQ,SAAS"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { q as GetCollectionConfig, w as MetaCollection } from "../../core-CRWvbE7W.js";
|
|
2
|
-
import "../../store-BtGmZUAC.js";
|
|
3
|
-
import { FileCollectionStore } from "../runtime/file-store.js";
|
|
4
|
-
|
|
5
|
-
//#region src/collections/meta/runtime.d.ts
|
|
6
|
-
declare function metaStore<Config, Name extends string>(_name: Name, base: string, input: Record<string, unknown>): FileCollectionStore<{
|
|
7
|
-
data: GetCollectionConfig<Config, Name> extends MetaCollection<infer Data> ? Data : never;
|
|
8
|
-
}>;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { metaStore };
|
|
11
|
-
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../../../src/collections/meta/runtime.ts"],"sourcesContent":[],"mappings":";;;;;iBAIgB,8CACP,2BAEA,0BACN;QACK,oBAAoB,QAAQ,cAAc;AALlD,CAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../../../src/collections/meta/runtime.ts"],"sourcesContent":["import type { GetCollectionConfig } from \"@/types\";\nimport { FileCollectionStore } from \"@/collections/runtime/file-store\";\nimport type { MetaCollection } from \"@/collections/meta\";\n\nexport function metaStore<Config, Name extends string>(\n _name: Name,\n base: string,\n input: Record<string, unknown>,\n): FileCollectionStore<{\n data: GetCollectionConfig<Config, Name> extends MetaCollection<infer Data> ? Data : never;\n}> {\n type Metadata =\n GetCollectionConfig<Config, Name> extends MetaCollection<infer Data> ? Data : never;\n const merged = input as Record<\n string,\n {\n data: Metadata;\n }\n >;\n\n for (const [key, value] of Object.entries(input)) {\n merged[key] = {\n data: value as Metadata,\n };\n }\n\n return new FileCollectionStore(base, merged);\n}\n"],"mappings":";;;AAIA,SAAgB,UACd,OACA,MACA,OAGC;CAGD,MAAM,SAAS;AAOf,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,QAAO,OAAO,EACZ,MAAM,OACP;AAGH,QAAO,IAAI,oBAAoB,MAAM,OAAO"}
|