@wondocs/next-plugin 0.0.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/index.cjs ADDED
@@ -0,0 +1,35 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_path = require("node:path");
3
+ let next_constants_js = require("next/constants.js");
4
+ let _wondocs_core_config = require("@wondocs/core/config");
5
+ let _wondocs_core_build = require("@wondocs/core/build");
6
+ let _wondocs_core_watch = require("@wondocs/core/watch");
7
+ //#region src/plugin.ts
8
+ const outDir = (0, node_path.join)(process.cwd(), ".wondocs");
9
+ let watchHandle = null;
10
+ function createWonDocs(wonDocsConfig = {}) {
11
+ return function withWonDocs(nextConfig = {}) {
12
+ return async function(phase) {
13
+ const resolvedConfig = (0, _wondocs_core_config.loadConfig)(wonDocsConfig);
14
+ const shouldWatch = phase === next_constants_js.PHASE_DEVELOPMENT_SERVER || process.argv.includes("--watch");
15
+ const shouldBuild = phase === next_constants_js.PHASE_PRODUCTION_BUILD;
16
+ if (shouldWatch) {
17
+ if (watchHandle) watchHandle.close();
18
+ watchHandle = await (0, _wondocs_core_watch.watchDocs)(resolvedConfig);
19
+ } else if (shouldBuild) await (0, _wondocs_core_build.buildDocs)(resolvedConfig);
20
+ return {
21
+ ...nextConfig,
22
+ turbopack: {
23
+ ...nextConfig.turbopack,
24
+ resolveAlias: {
25
+ ...nextConfig.turbopack?.resolveAlias,
26
+ "#wondocs/sidebar": (0, node_path.join)(outDir, "sidebar.js"),
27
+ "#wondocs/pages": (0, node_path.join)(outDir, "pages.js")
28
+ }
29
+ }
30
+ };
31
+ };
32
+ };
33
+ }
34
+ //#endregion
35
+ exports.createWonDocs = createWonDocs;
@@ -0,0 +1,7 @@
1
+ import { NextConfig } from "next";
2
+ import { WonDocsConfig } from "@wondocs/core/config";
3
+ //#region src/plugin.d.ts
4
+ declare function createWonDocs(wonDocsConfig?: WonDocsConfig): (nextConfig?: NextConfig) => (phase: string) => Promise<NextConfig>;
5
+ //#endregion
6
+ export { createWonDocs };
7
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;iBAegB,cAAc,gBAAe,iBACf,aAAY,gBAGf,kBAAgB,QAAQ"}
@@ -0,0 +1,7 @@
1
+ import { WonDocsConfig } from "@wondocs/core/config";
2
+ import { NextConfig } from "next";
3
+ //#region src/plugin.d.ts
4
+ declare function createWonDocs(wonDocsConfig?: WonDocsConfig): (nextConfig?: NextConfig) => (phase: string) => Promise<NextConfig>;
5
+ //#endregion
6
+ export { createWonDocs };
7
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;iBAegB,cAAc,gBAAe,iBACf,aAAY,gBAGf,kBAAgB,QAAQ"}
package/dist/index.mjs ADDED
@@ -0,0 +1,36 @@
1
+ import { join } from "node:path";
2
+ import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "next/constants.js";
3
+ import { loadConfig } from "@wondocs/core/config";
4
+ import { buildDocs } from "@wondocs/core/build";
5
+ import { watchDocs } from "@wondocs/core/watch";
6
+ //#region src/plugin.ts
7
+ const outDir = join(process.cwd(), ".wondocs");
8
+ let watchHandle = null;
9
+ function createWonDocs(wonDocsConfig = {}) {
10
+ return function withWonDocs(nextConfig = {}) {
11
+ return async function(phase) {
12
+ const resolvedConfig = loadConfig(wonDocsConfig);
13
+ const shouldWatch = phase === PHASE_DEVELOPMENT_SERVER || process.argv.includes("--watch");
14
+ const shouldBuild = phase === PHASE_PRODUCTION_BUILD;
15
+ if (shouldWatch) {
16
+ if (watchHandle) watchHandle.close();
17
+ watchHandle = await watchDocs(resolvedConfig);
18
+ } else if (shouldBuild) await buildDocs(resolvedConfig);
19
+ return {
20
+ ...nextConfig,
21
+ turbopack: {
22
+ ...nextConfig.turbopack,
23
+ resolveAlias: {
24
+ ...nextConfig.turbopack?.resolveAlias,
25
+ "#wondocs/sidebar": join(outDir, "sidebar.js"),
26
+ "#wondocs/pages": join(outDir, "pages.js")
27
+ }
28
+ }
29
+ };
30
+ };
31
+ };
32
+ }
33
+ //#endregion
34
+ export { createWonDocs };
35
+
36
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type { NextConfig } from \"next\";\nimport {\n PHASE_DEVELOPMENT_SERVER,\n PHASE_PRODUCTION_BUILD,\n} from \"next/constants\";\n\nimport { loadConfig, type WonDocsConfig } from \"@wondocs/core/config\";\nimport { buildDocs } from \"@wondocs/core/build\";\nimport { watchDocs } from \"@wondocs/core/watch\";\n\nconst outDir = join(process.cwd(), \".wondocs\");\n\nlet watchHandle: { close(): void } | null = null;\n\nexport function createWonDocs(wonDocsConfig: WonDocsConfig = {}) {\n return function withWonDocs(nextConfig: NextConfig = {}) {\n // Returns an async function because Turbopack has no plugin API to hook into\n // individual compilations — scanning runs once when next.config is evaluated.\n return async function (phase: string): Promise<NextConfig> {\n const resolvedConfig = loadConfig(wonDocsConfig);\n const shouldWatch =\n phase === PHASE_DEVELOPMENT_SERVER || process.argv.includes(\"--watch\");\n const shouldBuild = phase === PHASE_PRODUCTION_BUILD;\n\n // next.config is also evaluated on `next start` (PHASE_PRODUCTION_SERVER) and other\n // non-build phases — skip there so we don't re-scan/recompile docs (and re-write\n // .wondocs/) on every server boot, which can also fail on read-only production filesystems.\n if (shouldWatch) {\n if (watchHandle) watchHandle.close();\n watchHandle = await watchDocs(resolvedConfig);\n } else if (shouldBuild) {\n await buildDocs(resolvedConfig);\n }\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n \"#wondocs/sidebar\": join(outDir, \"sidebar.js\"),\n \"#wondocs/pages\": join(outDir, \"pages.js\"),\n },\n },\n };\n };\n };\n}\n"],"mappings":";;;;;;AAWA,MAAM,SAAS,KAAK,QAAQ,IAAI,GAAG,UAAU;AAE7C,IAAI,cAAwC;AAE5C,SAAgB,cAAc,gBAA+B,CAAC,GAAG;CAC/D,OAAO,SAAS,YAAY,aAAyB,CAAC,GAAG;EAGvD,OAAO,eAAgB,OAAoC;GACzD,MAAM,iBAAiB,WAAW,aAAa;GAC/C,MAAM,cACJ,UAAU,4BAA4B,QAAQ,KAAK,SAAS,SAAS;GACvE,MAAM,cAAc,UAAU;GAK9B,IAAI,aAAa;IACf,IAAI,aAAa,YAAY,MAAM;IACnC,cAAc,MAAM,UAAU,cAAc;GAC9C,OAAO,IAAI,aACT,MAAM,UAAU,cAAc;GAGhC,OAAO;IACL,GAAG;IACH,WAAW;KACT,GAAG,WAAW;KACd,cAAc;MACZ,GAAG,WAAW,WAAW;MACzB,oBAAoB,KAAK,QAAQ,YAAY;MAC7C,kBAAkB,KAAK,QAAQ,UAAU;KAC3C;IACF;GACF;EACF;CACF;AACF"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@wondocs/next-plugin",
3
+ "description": "WonDocs Next.js Plugin - A plugin for integrating WonDocs with Next.js applications.",
4
+ "version": "0.0.0",
5
+ "private": false,
6
+ "type": "module",
7
+ "keywords": [
8
+ "documentation",
9
+ "docs",
10
+ "nextjs",
11
+ "plugin",
12
+ "wondocs",
13
+ "mdx",
14
+ "markdown",
15
+ "typescript"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/wonwon0307/wondocs.git",
20
+ "directory": "packages/next-plugin"
21
+ },
22
+ "license": "UNLICENSED",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org/"
29
+ },
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.mts",
33
+ "require": "./dist/index.cjs",
34
+ "import": "./dist/index.mjs",
35
+ "default": "./dist/index.mjs"
36
+ }
37
+ },
38
+ "scripts": {
39
+ "prebuild": "rm -rf dist",
40
+ "build": "tsdown",
41
+ "dev": "tsdown --watch",
42
+ "lint": "eslint .",
43
+ "typecheck": "tsc --noEmit"
44
+ },
45
+ "dependencies": {
46
+ "@wondocs/core": "workspace:*"
47
+ },
48
+ "peerDependencies": {
49
+ "next": ">=16.0.0"
50
+ },
51
+ "devDependencies": {
52
+ "next": "^16.2.11"
53
+ }
54
+ }