@wondocs/next-plugin 0.0.0 → 0.1.0-beta.1

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 CHANGED
@@ -6,7 +6,32 @@ let _wondocs_core_build = require("@wondocs/core/build");
6
6
  let _wondocs_core_watch = require("@wondocs/core/watch");
7
7
  //#region src/plugin.ts
8
8
  const outDir = (0, node_path.join)(process.cwd(), ".wondocs");
9
+ function toProjectRelative(absolutePath) {
10
+ return `./${(0, node_path.relative)(process.cwd(), absolutePath).split(node_path.sep).join("/")}`;
11
+ }
9
12
  let watchHandle = null;
13
+ /**
14
+ * Creates a Next.js config wrapper that builds/watches WonDocs content and
15
+ * wires the generated sidebar/pages modules into Turbopack's resolver.
16
+ *
17
+ * @param wonDocsConfig - WonDocs options (contents directory, MDX plugins, etc).
18
+ * @returns A `withWonDocs` function to wrap your `NextConfig`.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // next.config.ts
23
+ * import type { NextConfig } from "next";
24
+ * import { createWonDocs } from "@wondocs/next-plugin";
25
+ *
26
+ * const nextConfig: NextConfig = {
27
+ * reactCompiler: true,
28
+ * };
29
+ *
30
+ * const withWonDocs = createWonDocs({ contentsDir: "docs/" });
31
+ *
32
+ * export default withWonDocs(nextConfig);
33
+ * ```
34
+ */
10
35
  function createWonDocs(wonDocsConfig = {}) {
11
36
  return function withWonDocs(nextConfig = {}) {
12
37
  return async function(phase) {
@@ -23,8 +48,8 @@ function createWonDocs(wonDocsConfig = {}) {
23
48
  ...nextConfig.turbopack,
24
49
  resolveAlias: {
25
50
  ...nextConfig.turbopack?.resolveAlias,
26
- "#wondocs/sidebar": (0, node_path.join)(outDir, "sidebar.js"),
27
- "#wondocs/pages": (0, node_path.join)(outDir, "pages.js")
51
+ "#wondocs/sidebar": toProjectRelative((0, node_path.join)(outDir, "sidebar.js")),
52
+ "#wondocs/pages": toProjectRelative((0, node_path.join)(outDir, "pages.js"))
28
53
  }
29
54
  }
30
55
  };
package/dist/index.d.cts CHANGED
@@ -1,6 +1,28 @@
1
1
  import { NextConfig } from "next";
2
2
  import { WonDocsConfig } from "@wondocs/core/config";
3
3
  //#region src/plugin.d.ts
4
+ /**
5
+ * Creates a Next.js config wrapper that builds/watches WonDocs content and
6
+ * wires the generated sidebar/pages modules into Turbopack's resolver.
7
+ *
8
+ * @param wonDocsConfig - WonDocs options (contents directory, MDX plugins, etc).
9
+ * @returns A `withWonDocs` function to wrap your `NextConfig`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // next.config.ts
14
+ * import type { NextConfig } from "next";
15
+ * import { createWonDocs } from "@wondocs/next-plugin";
16
+ *
17
+ * const nextConfig: NextConfig = {
18
+ * reactCompiler: true,
19
+ * };
20
+ *
21
+ * const withWonDocs = createWonDocs({ contentsDir: "docs/" });
22
+ *
23
+ * export default withWonDocs(nextConfig);
24
+ * ```
25
+ */
4
26
  declare function createWonDocs(wonDocsConfig?: WonDocsConfig): (nextConfig?: NextConfig) => (phase: string) => Promise<NextConfig>;
5
27
  //#endregion
6
28
  export { createWonDocs };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;iBAegB,cAAc,gBAAe,iBACf,aAAY,gBAGf,kBAAgB,QAAQ"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;iBA6CgB,cAAc,gBAAe,iBACf,aAAY,gBAGf,kBAAgB,QAAQ"}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,28 @@
1
1
  import { WonDocsConfig } from "@wondocs/core/config";
2
2
  import { NextConfig } from "next";
3
3
  //#region src/plugin.d.ts
4
+ /**
5
+ * Creates a Next.js config wrapper that builds/watches WonDocs content and
6
+ * wires the generated sidebar/pages modules into Turbopack's resolver.
7
+ *
8
+ * @param wonDocsConfig - WonDocs options (contents directory, MDX plugins, etc).
9
+ * @returns A `withWonDocs` function to wrap your `NextConfig`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // next.config.ts
14
+ * import type { NextConfig } from "next";
15
+ * import { createWonDocs } from "@wondocs/next-plugin";
16
+ *
17
+ * const nextConfig: NextConfig = {
18
+ * reactCompiler: true,
19
+ * };
20
+ *
21
+ * const withWonDocs = createWonDocs({ contentsDir: "docs/" });
22
+ *
23
+ * export default withWonDocs(nextConfig);
24
+ * ```
25
+ */
4
26
  declare function createWonDocs(wonDocsConfig?: WonDocsConfig): (nextConfig?: NextConfig) => (phase: string) => Promise<NextConfig>;
5
27
  //#endregion
6
28
  export { createWonDocs };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;iBAegB,cAAc,gBAAe,iBACf,aAAY,gBAGf,kBAAgB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;iBA6CgB,cAAc,gBAAe,iBACf,aAAY,gBAGf,kBAAgB,QAAQ"}
package/dist/index.mjs CHANGED
@@ -1,11 +1,36 @@
1
- import { join } from "node:path";
1
+ import { join, relative, sep } from "node:path";
2
2
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "next/constants.js";
3
3
  import { loadConfig } from "@wondocs/core/config";
4
4
  import { buildDocs } from "@wondocs/core/build";
5
5
  import { watchDocs } from "@wondocs/core/watch";
6
6
  //#region src/plugin.ts
7
7
  const outDir = join(process.cwd(), ".wondocs");
8
+ function toProjectRelative(absolutePath) {
9
+ return `./${relative(process.cwd(), absolutePath).split(sep).join("/")}`;
10
+ }
8
11
  let watchHandle = null;
12
+ /**
13
+ * Creates a Next.js config wrapper that builds/watches WonDocs content and
14
+ * wires the generated sidebar/pages modules into Turbopack's resolver.
15
+ *
16
+ * @param wonDocsConfig - WonDocs options (contents directory, MDX plugins, etc).
17
+ * @returns A `withWonDocs` function to wrap your `NextConfig`.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * // next.config.ts
22
+ * import type { NextConfig } from "next";
23
+ * import { createWonDocs } from "@wondocs/next-plugin";
24
+ *
25
+ * const nextConfig: NextConfig = {
26
+ * reactCompiler: true,
27
+ * };
28
+ *
29
+ * const withWonDocs = createWonDocs({ contentsDir: "docs/" });
30
+ *
31
+ * export default withWonDocs(nextConfig);
32
+ * ```
33
+ */
9
34
  function createWonDocs(wonDocsConfig = {}) {
10
35
  return function withWonDocs(nextConfig = {}) {
11
36
  return async function(phase) {
@@ -22,8 +47,8 @@ function createWonDocs(wonDocsConfig = {}) {
22
47
  ...nextConfig.turbopack,
23
48
  resolveAlias: {
24
49
  ...nextConfig.turbopack?.resolveAlias,
25
- "#wondocs/sidebar": join(outDir, "sidebar.js"),
26
- "#wondocs/pages": join(outDir, "pages.js")
50
+ "#wondocs/sidebar": toProjectRelative(join(outDir, "sidebar.js")),
51
+ "#wondocs/pages": toProjectRelative(join(outDir, "pages.js"))
27
52
  }
28
53
  }
29
54
  };
@@ -1 +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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { join, relative, sep } 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\n// Turbopack's resolveAlias doesn't support absolute filesystem paths (\"server\n// relative imports are not implemented yet\") — it needs a project-relative\n// path, POSIX-separated, with an explicit \"./\" so it isn't treated as a bare\n// specifier.\nfunction toProjectRelative(absolutePath: string): string {\n return `./${relative(process.cwd(), absolutePath).split(sep).join(\"/\")}`;\n}\n\nlet watchHandle: { close(): void } | null = null;\n\n/**\n * Creates a Next.js config wrapper that builds/watches WonDocs content and\n * wires the generated sidebar/pages modules into Turbopack's resolver.\n *\n * @param wonDocsConfig - WonDocs options (contents directory, MDX plugins, etc).\n * @returns A `withWonDocs` function to wrap your `NextConfig`.\n *\n * @example\n * ```ts\n * // next.config.ts\n * import type { NextConfig } from \"next\";\n * import { createWonDocs } from \"@wondocs/next-plugin\";\n *\n * const nextConfig: NextConfig = {\n * reactCompiler: true,\n * };\n *\n * const withWonDocs = createWonDocs({ contentsDir: \"docs/\" });\n *\n * export default withWonDocs(nextConfig);\n * ```\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\": toProjectRelative(join(outDir, \"sidebar.js\")),\n \"#wondocs/pages\": toProjectRelative(join(outDir, \"pages.js\")),\n },\n },\n };\n };\n };\n}\n"],"mappings":";;;;;;AAWA,MAAM,SAAS,KAAK,QAAQ,IAAI,GAAG,UAAU;AAM7C,SAAS,kBAAkB,cAA8B;CACvD,OAAO,KAAK,SAAS,QAAQ,IAAI,GAAG,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;AACvE;AAEA,IAAI,cAAwC;;;;;;;;;;;;;;;;;;;;;;;AAwB5C,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,kBAAkB,KAAK,QAAQ,YAAY,CAAC;MAChE,kBAAkB,kBAAkB,KAAK,QAAQ,UAAU,CAAC;KAC9D;IACF;GACF;EACF;CACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wondocs/next-plugin",
3
3
  "description": "WonDocs Next.js Plugin - A plugin for integrating WonDocs with Next.js applications.",
4
- "version": "0.0.0",
4
+ "version": "0.1.0-beta.1",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "keywords": [
@@ -35,20 +35,20 @@
35
35
  "default": "./dist/index.mjs"
36
36
  }
37
37
  },
38
- "scripts": {
39
- "prebuild": "rm -rf dist",
40
- "build": "tsdown",
41
- "dev": "tsdown --watch",
42
- "lint": "eslint .",
43
- "typecheck": "tsc --noEmit"
44
- },
45
38
  "dependencies": {
46
- "@wondocs/core": "workspace:*"
39
+ "@wondocs/core": "0.1.0-beta.1"
47
40
  },
48
41
  "peerDependencies": {
49
42
  "next": ">=16.0.0"
50
43
  },
51
44
  "devDependencies": {
52
- "next": "^16.2.11"
45
+ "next": "^16.3.0"
46
+ },
47
+ "scripts": {
48
+ "prebuild": "rm -rf dist",
49
+ "build": "tsdown",
50
+ "dev": "tsdown --watch",
51
+ "lint": "eslint .",
52
+ "typecheck": "tsc --noEmit"
53
53
  }
54
- }
54
+ }