@prudentbird/voxx-core 1.1.0 → 1.2.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/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/content.d.cts +2 -2
- package/dist/content.d.cts.map +1 -1
- package/dist/content.d.mts +2 -2
- package/dist/content.d.mts.map +1 -1
- package/dist/frontmatter.d.cts +1 -1
- package/dist/frontmatter.d.mts +1 -1
- package/dist/next.cjs +54 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +29 -0
- package/dist/next.d.cts.map +1 -0
- package/dist/next.d.mts +29 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +53 -0
- package/dist/next.mjs.map +1 -0
- package/package.json +12 -3
package/dist/config.d.cts
CHANGED
|
@@ -118,7 +118,7 @@ declare const loadConfigEffect: (opts?: LoadConfigOptions) => Effect.Effect<{
|
|
|
118
118
|
jsonLd: boolean;
|
|
119
119
|
defaultImage: string | null;
|
|
120
120
|
};
|
|
121
|
-
}, ConfigError,
|
|
121
|
+
}, ConfigError, FileSystem.FileSystem | Path.Path>;
|
|
122
122
|
//#endregion
|
|
123
123
|
export { CollectionInput, LoadConfigOptions, loadConfigEffect, resolveCollectionDefaults, resolveConfig };
|
|
124
124
|
//# sourceMappingURL=config.d.cts.map
|
package/dist/config.d.mts
CHANGED
|
@@ -118,7 +118,7 @@ declare const loadConfigEffect: (opts?: LoadConfigOptions) => Effect.Effect<{
|
|
|
118
118
|
jsonLd: boolean;
|
|
119
119
|
defaultImage: string | null;
|
|
120
120
|
};
|
|
121
|
-
}, ConfigError,
|
|
121
|
+
}, ConfigError, FileSystem.FileSystem | Path.Path>;
|
|
122
122
|
//#endregion
|
|
123
123
|
export { CollectionInput, LoadConfigOptions, loadConfigEffect, resolveCollectionDefaults, resolveConfig };
|
|
124
124
|
//# sourceMappingURL=config.d.mts.map
|
package/dist/content.d.cts
CHANGED
|
@@ -22,7 +22,7 @@ interface GetPostsEffectOptions {
|
|
|
22
22
|
* @param config - Resolved Voxx config.
|
|
23
23
|
* @param opts - Optional collection filter and draft visibility.
|
|
24
24
|
*/
|
|
25
|
-
declare const getPostsEffect: (config: VoxxConfig, opts?: GetPostsEffectOptions) => Effect.Effect<Post[], ConfigError |
|
|
25
|
+
declare const getPostsEffect: (config: VoxxConfig, opts?: GetPostsEffectOptions) => Effect.Effect<Post[], ConfigError | ContentDirMissing | import("@effect/platform/Error").PlatformError | InvalidFrontmatter | RenderError, FileSystem.FileSystem | Path.Path>;
|
|
26
26
|
/**
|
|
27
27
|
* Finds a post in an already-loaded array by slug or path.
|
|
28
28
|
*
|
|
@@ -35,7 +35,7 @@ declare function findPost(posts: Post[], slug: string): Post | undefined;
|
|
|
35
35
|
* Loads all posts and returns the one matching `slug`.
|
|
36
36
|
* Throws `PostNotFound` if no match exists.
|
|
37
37
|
*/
|
|
38
|
-
declare const getPostEffect: (config: VoxxConfig, slug: string, opts?: GetPostsEffectOptions) => Effect.Effect<Post, ConfigError |
|
|
38
|
+
declare const getPostEffect: (config: VoxxConfig, slug: string, opts?: GetPostsEffectOptions) => Effect.Effect<Post, ConfigError | ContentDirMissing | import("@effect/platform/Error").PlatformError | InvalidFrontmatter | RenderError | PostNotFound, FileSystem.FileSystem | Path.Path>;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { GetPostsEffectOptions, findPost, getPostEffect, getPostsEffect };
|
|
41
41
|
//# sourceMappingURL=content.d.cts.map
|
package/dist/content.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.cts","names":[],"sources":["../src/content.ts"],"mappings":";;;;;;;UAoBiB,qBAAA;EAAA;EAEf,aAAA;;EAEA,UAAU;AAAA;AAiIZ;;;;;;;;;;;AAAA,cAAa,cAAA,GACX,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,qBAAA,KAA0B,MAAA,CAAA,MAAA,CAAA,IAAA,IAAA,WAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"content.d.cts","names":[],"sources":["../src/content.ts"],"mappings":";;;;;;;UAoBiB,qBAAA;EAAA;EAEf,aAAA;;EAEA,UAAU;AAAA;AAiIZ;;;;;;;;;;;AAAA,cAAa,cAAA,GACX,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,qBAAA,KAA0B,MAAA,CAAA,MAAA,CAAA,IAAA,IAAA,WAAA,GAAA,iBAAA,oCAAA,aAAA,GAAA,kBAAA,GAAA,WAAA,EAAA,UAAA,CAAA,UAAA,GAAA,IAAA,CAAA,IAAA;;;;;;;;iBAgFlB,QAAA,CAAS,KAAA,EAAO,IAAA,IAAQ,IAAA,WAAe,IAAI;;;;;cAY9C,aAAA,GACX,MAAA,EAAQ,UAAA,EACR,IAAA,UACA,IAAA,GAAM,qBAAA,KAA0B,MAAA,CAAA,MAAA,CAAA,IAAA,EAAA,WAAA,GAAA,iBAAA,oCAAA,aAAA,GAAA,kBAAA,GAAA,WAAA,GAAA,YAAA,EAAA,UAAA,CAAA,UAAA,GAAA,IAAA,CAAA,IAAA"}
|
package/dist/content.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ interface GetPostsEffectOptions {
|
|
|
22
22
|
* @param config - Resolved Voxx config.
|
|
23
23
|
* @param opts - Optional collection filter and draft visibility.
|
|
24
24
|
*/
|
|
25
|
-
declare const getPostsEffect: (config: VoxxConfig, opts?: GetPostsEffectOptions) => Effect.Effect<Post[], ConfigError |
|
|
25
|
+
declare const getPostsEffect: (config: VoxxConfig, opts?: GetPostsEffectOptions) => Effect.Effect<Post[], ConfigError | ContentDirMissing | import("@effect/platform/Error").PlatformError | InvalidFrontmatter | RenderError, FileSystem.FileSystem | Path.Path>;
|
|
26
26
|
/**
|
|
27
27
|
* Finds a post in an already-loaded array by slug or path.
|
|
28
28
|
*
|
|
@@ -35,7 +35,7 @@ declare function findPost(posts: Post[], slug: string): Post | undefined;
|
|
|
35
35
|
* Loads all posts and returns the one matching `slug`.
|
|
36
36
|
* Throws `PostNotFound` if no match exists.
|
|
37
37
|
*/
|
|
38
|
-
declare const getPostEffect: (config: VoxxConfig, slug: string, opts?: GetPostsEffectOptions) => Effect.Effect<Post, ConfigError |
|
|
38
|
+
declare const getPostEffect: (config: VoxxConfig, slug: string, opts?: GetPostsEffectOptions) => Effect.Effect<Post, ConfigError | ContentDirMissing | import("@effect/platform/Error").PlatformError | InvalidFrontmatter | RenderError | PostNotFound, FileSystem.FileSystem | Path.Path>;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { GetPostsEffectOptions, findPost, getPostEffect, getPostsEffect };
|
|
41
41
|
//# sourceMappingURL=content.d.mts.map
|
package/dist/content.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.mts","names":[],"sources":["../src/content.ts"],"mappings":";;;;;;;UAoBiB,qBAAA;EAAA;EAEf,aAAA;;EAEA,UAAU;AAAA;AAiIZ;;;;;;;;;;;AAAA,cAAa,cAAA,GACX,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,qBAAA,KAA0B,MAAA,CAAA,MAAA,CAAA,IAAA,IAAA,WAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"content.d.mts","names":[],"sources":["../src/content.ts"],"mappings":";;;;;;;UAoBiB,qBAAA;EAAA;EAEf,aAAA;;EAEA,UAAU;AAAA;AAiIZ;;;;;;;;;;;AAAA,cAAa,cAAA,GACX,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,qBAAA,KAA0B,MAAA,CAAA,MAAA,CAAA,IAAA,IAAA,WAAA,GAAA,iBAAA,oCAAA,aAAA,GAAA,kBAAA,GAAA,WAAA,EAAA,UAAA,CAAA,UAAA,GAAA,IAAA,CAAA,IAAA;;;;;;;;iBAgFlB,QAAA,CAAS,KAAA,EAAO,IAAA,IAAQ,IAAA,WAAe,IAAI;;;;;cAY9C,aAAA,GACX,MAAA,EAAQ,UAAA,EACR,IAAA,UACA,IAAA,GAAM,qBAAA,KAA0B,MAAA,CAAA,MAAA,CAAA,IAAA,EAAA,WAAA,GAAA,iBAAA,oCAAA,aAAA,GAAA,kBAAA,GAAA,WAAA,GAAA,YAAA,EAAA,UAAA,CAAA,UAAA,GAAA,IAAA,CAAA,IAAA"}
|
package/dist/frontmatter.d.cts
CHANGED
|
@@ -9,6 +9,7 @@ interface ParsedFile {
|
|
|
9
9
|
}
|
|
10
10
|
declare const parseFrontmatter: (file: string, raw: string) => Effect.Effect<{
|
|
11
11
|
data: {
|
|
12
|
+
readonly order?: number | undefined;
|
|
12
13
|
readonly title: string;
|
|
13
14
|
readonly description?: string | undefined;
|
|
14
15
|
readonly date?: string | undefined;
|
|
@@ -16,7 +17,6 @@ declare const parseFrontmatter: (file: string, raw: string) => Effect.Effect<{
|
|
|
16
17
|
readonly slug?: string | undefined;
|
|
17
18
|
readonly tags: readonly string[];
|
|
18
19
|
readonly category?: string | undefined;
|
|
19
|
-
readonly order?: number | undefined;
|
|
20
20
|
readonly version?: string | undefined;
|
|
21
21
|
readonly draft: boolean;
|
|
22
22
|
readonly image?: string | undefined;
|
package/dist/frontmatter.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ interface ParsedFile {
|
|
|
9
9
|
}
|
|
10
10
|
declare const parseFrontmatter: (file: string, raw: string) => Effect.Effect<{
|
|
11
11
|
data: {
|
|
12
|
+
readonly order?: number | undefined;
|
|
12
13
|
readonly title: string;
|
|
13
14
|
readonly description?: string | undefined;
|
|
14
15
|
readonly date?: string | undefined;
|
|
@@ -16,7 +17,6 @@ declare const parseFrontmatter: (file: string, raw: string) => Effect.Effect<{
|
|
|
16
17
|
readonly slug?: string | undefined;
|
|
17
18
|
readonly tags: readonly string[];
|
|
18
19
|
readonly category?: string | undefined;
|
|
19
|
-
readonly order?: number | undefined;
|
|
20
20
|
readonly version?: string | undefined;
|
|
21
21
|
readonly draft: boolean;
|
|
22
22
|
readonly image?: string | undefined;
|
package/dist/next.cjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
//#region src/next.ts
|
|
5
|
+
const CORE_PACKAGE = "@prudentbird/voxx-core";
|
|
6
|
+
const DEFAULT_CONTENT_DIR = "content";
|
|
7
|
+
/**
|
|
8
|
+
* Reads the relative content directories declared in `voxx.json`, falling back
|
|
9
|
+
* to the default `content` directory when the file is missing or unreadable.
|
|
10
|
+
*/
|
|
11
|
+
function contentDirs(cwd) {
|
|
12
|
+
try {
|
|
13
|
+
const data = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(cwd, "voxx.json"), "utf8"));
|
|
14
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
15
|
+
for (const c of data.collections ?? []) dirs.add(c.dir ?? `${DEFAULT_CONTENT_DIR}/${c.name ?? c.type ?? "blog"}`);
|
|
16
|
+
if (data.content?.dir) dirs.add(data.content.dir);
|
|
17
|
+
return dirs.size > 0 ? [...dirs] : [DEFAULT_CONTENT_DIR];
|
|
18
|
+
} catch {
|
|
19
|
+
return [DEFAULT_CONTENT_DIR];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a Next.js config with the settings every Voxx app needs to run
|
|
24
|
+
* correctly on serverless platforms.
|
|
25
|
+
*
|
|
26
|
+
* Enables Cache Components, marks `@prudentbird/voxx-core` as an external
|
|
27
|
+
* server package, and traces `voxx.json` plus every content directory into the
|
|
28
|
+
* serverless function bundle so runtime config and content reads resolve. Voxx
|
|
29
|
+
* content is filesystem-backed and read at request time during cache
|
|
30
|
+
* revalidation, so without these includes those reads fail on platforms that
|
|
31
|
+
* bundle each route into an isolated function.
|
|
32
|
+
*
|
|
33
|
+
* @param config - Base Next.js config. Existing values are preserved; `cacheComponents` defaults to `true` when unset.
|
|
34
|
+
* @param options - Optional `cwd` override for locating `voxx.json`.
|
|
35
|
+
* @returns The base config merged with Voxx's required settings.
|
|
36
|
+
*/
|
|
37
|
+
function withVoxx(config = {}, options = {}) {
|
|
38
|
+
const base = config;
|
|
39
|
+
const includes = ["./voxx.json", ...contentDirs(options.cwd ?? process.cwd()).map((dir) => `./${dir}/**/*`)];
|
|
40
|
+
const existing = base.outputFileTracingIncludes ?? {};
|
|
41
|
+
return {
|
|
42
|
+
...base,
|
|
43
|
+
cacheComponents: base.cacheComponents ?? true,
|
|
44
|
+
serverExternalPackages: [...new Set([...base.serverExternalPackages ?? [], CORE_PACKAGE])],
|
|
45
|
+
outputFileTracingIncludes: {
|
|
46
|
+
...existing,
|
|
47
|
+
"/*": [...new Set([...existing["/*"] ?? [], ...includes])]
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.withVoxx = withVoxx;
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=next.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.cjs","names":[],"sources":["../src/next.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst CORE_PACKAGE = \"@prudentbird/voxx-core\";\nconst DEFAULT_CONTENT_DIR = \"content\";\n\n/** Options for {@link withVoxx}. */\nexport interface WithVoxxOptions {\n /** Directory containing `voxx.json`. Defaults to `process.cwd()`. */\n cwd?: string;\n}\n\n/** The Next.js config fields {@link withVoxx} manages; all other fields pass through unchanged. */\ninterface ManagedConfig {\n cacheComponents?: boolean;\n serverExternalPackages?: string[];\n outputFileTracingIncludes?: Record<string, string[]>;\n}\n\ninterface RawCollection {\n name?: string;\n type?: string;\n dir?: string;\n}\n\ninterface RawConfig {\n content?: { dir?: string; type?: string };\n collections?: RawCollection[];\n}\n\n/**\n * Reads the relative content directories declared in `voxx.json`, falling back\n * to the default `content` directory when the file is missing or unreadable.\n */\nfunction contentDirs(cwd: string): string[] {\n try {\n const data = JSON.parse(\n readFileSync(join(cwd, \"voxx.json\"), \"utf8\"),\n ) as RawConfig;\n const dirs = new Set<string>();\n for (const c of data.collections ?? []) {\n dirs.add(c.dir ?? `${DEFAULT_CONTENT_DIR}/${c.name ?? c.type ?? \"blog\"}`);\n }\n if (data.content?.dir) dirs.add(data.content.dir);\n return dirs.size > 0 ? [...dirs] : [DEFAULT_CONTENT_DIR];\n } catch {\n return [DEFAULT_CONTENT_DIR];\n }\n}\n\n/**\n * Wraps a Next.js config with the settings every Voxx app needs to run\n * correctly on serverless platforms.\n *\n * Enables Cache Components, marks `@prudentbird/voxx-core` as an external\n * server package, and traces `voxx.json` plus every content directory into the\n * serverless function bundle so runtime config and content reads resolve. Voxx\n * content is filesystem-backed and read at request time during cache\n * revalidation, so without these includes those reads fail on platforms that\n * bundle each route into an isolated function.\n *\n * @param config - Base Next.js config. Existing values are preserved; `cacheComponents` defaults to `true` when unset.\n * @param options - Optional `cwd` override for locating `voxx.json`.\n * @returns The base config merged with Voxx's required settings.\n */\nexport function withVoxx<T extends object>(\n config: T = {} as T,\n options: WithVoxxOptions = {},\n): T & {\n cacheComponents: boolean;\n serverExternalPackages: string[];\n outputFileTracingIncludes: Record<string, string[]>;\n} {\n const base = config as T & ManagedConfig;\n const dirs = contentDirs(options.cwd ?? process.cwd());\n const includes = [\"./voxx.json\", ...dirs.map((dir) => `./${dir}/**/*`)];\n const existing = base.outputFileTracingIncludes ?? {};\n\n return {\n ...base,\n cacheComponents: base.cacheComponents ?? true,\n serverExternalPackages: [\n ...new Set([...(base.serverExternalPackages ?? []), CORE_PACKAGE]),\n ],\n outputFileTracingIncludes: {\n ...existing,\n \"/*\": [...new Set([...(existing[\"/*\"] ?? []), ...includes])],\n },\n };\n}\n"],"mappings":";;;;AAGA,MAAM,eAAe;AACrB,MAAM,sBAAsB;;;;;AA8B5B,SAAS,YAAY,KAAuB;CAC1C,IAAI;EACF,MAAM,OAAO,KAAK,OAAA,GAAA,QAAA,aAAA,EAAA,GAAA,UAAA,KAAA,CACE,KAAK,WAAW,GAAG,MAAM,CAC7C;EACA,MAAM,uBAAO,IAAI,IAAY;EAC7B,KAAK,MAAM,KAAK,KAAK,eAAe,CAAC,GACnC,KAAK,IAAI,EAAE,OAAO,GAAG,oBAAoB,GAAG,EAAE,QAAQ,EAAE,QAAQ,QAAQ;EAE1E,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,KAAK,QAAQ,GAAG;EAChD,OAAO,KAAK,OAAO,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,mBAAmB;CACzD,QAAQ;EACN,OAAO,CAAC,mBAAmB;CAC7B;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,SACd,SAAY,CAAC,GACb,UAA2B,CAAC,GAK5B;CACA,MAAM,OAAO;CAEb,MAAM,WAAW,CAAC,eAAe,GADpB,YAAY,QAAQ,OAAO,QAAQ,IAAI,CACb,CAAC,CAAC,KAAK,QAAQ,KAAK,IAAI,MAAM,CAAC;CACtE,MAAM,WAAW,KAAK,6BAA6B,CAAC;CAEpD,OAAO;EACL,GAAG;EACH,iBAAiB,KAAK,mBAAmB;EACzC,wBAAwB,CACtB,GAAG,IAAI,IAAI,CAAC,GAAI,KAAK,0BAA0B,CAAC,GAAI,YAAY,CAAC,CACnE;EACA,2BAA2B;GACzB,GAAG;GACH,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAI,SAAS,SAAS,CAAC,GAAI,GAAG,QAAQ,CAAC,CAAC;EAC7D;CACF;AACF"}
|
package/dist/next.d.cts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/next.d.ts
|
|
2
|
+
/** Options for {@link withVoxx}. */
|
|
3
|
+
interface WithVoxxOptions {
|
|
4
|
+
/** Directory containing `voxx.json`. Defaults to `process.cwd()`. */
|
|
5
|
+
cwd?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Next.js config with the settings every Voxx app needs to run
|
|
9
|
+
* correctly on serverless platforms.
|
|
10
|
+
*
|
|
11
|
+
* Enables Cache Components, marks `@prudentbird/voxx-core` as an external
|
|
12
|
+
* server package, and traces `voxx.json` plus every content directory into the
|
|
13
|
+
* serverless function bundle so runtime config and content reads resolve. Voxx
|
|
14
|
+
* content is filesystem-backed and read at request time during cache
|
|
15
|
+
* revalidation, so without these includes those reads fail on platforms that
|
|
16
|
+
* bundle each route into an isolated function.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Base Next.js config. Existing values are preserved; `cacheComponents` defaults to `true` when unset.
|
|
19
|
+
* @param options - Optional `cwd` override for locating `voxx.json`.
|
|
20
|
+
* @returns The base config merged with Voxx's required settings.
|
|
21
|
+
*/
|
|
22
|
+
declare function withVoxx<T extends object>(config?: T, options?: WithVoxxOptions): T & {
|
|
23
|
+
cacheComponents: boolean;
|
|
24
|
+
serverExternalPackages: string[];
|
|
25
|
+
outputFileTracingIncludes: Record<string, string[]>;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { WithVoxxOptions, withVoxx };
|
|
29
|
+
//# sourceMappingURL=next.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.cts","names":[],"sources":["../src/next.ts"],"mappings":";;UAOiB,eAAA;EAAe;EAE9B,GAAG;AAAA;AAAA;AAwDL;;;;;;;;;;;;;;AAxDK,iBAwDW,QAAA,mBACd,MAAA,GAAQ,CAAA,EACR,OAAA,GAAS,eAAA,GACR,CAAA;EACD,eAAA;EACA,sBAAA;EACA,yBAAA,EAA2B,MAAA;AAAA"}
|
package/dist/next.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/next.d.ts
|
|
2
|
+
/** Options for {@link withVoxx}. */
|
|
3
|
+
interface WithVoxxOptions {
|
|
4
|
+
/** Directory containing `voxx.json`. Defaults to `process.cwd()`. */
|
|
5
|
+
cwd?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Next.js config with the settings every Voxx app needs to run
|
|
9
|
+
* correctly on serverless platforms.
|
|
10
|
+
*
|
|
11
|
+
* Enables Cache Components, marks `@prudentbird/voxx-core` as an external
|
|
12
|
+
* server package, and traces `voxx.json` plus every content directory into the
|
|
13
|
+
* serverless function bundle so runtime config and content reads resolve. Voxx
|
|
14
|
+
* content is filesystem-backed and read at request time during cache
|
|
15
|
+
* revalidation, so without these includes those reads fail on platforms that
|
|
16
|
+
* bundle each route into an isolated function.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Base Next.js config. Existing values are preserved; `cacheComponents` defaults to `true` when unset.
|
|
19
|
+
* @param options - Optional `cwd` override for locating `voxx.json`.
|
|
20
|
+
* @returns The base config merged with Voxx's required settings.
|
|
21
|
+
*/
|
|
22
|
+
declare function withVoxx<T extends object>(config?: T, options?: WithVoxxOptions): T & {
|
|
23
|
+
cacheComponents: boolean;
|
|
24
|
+
serverExternalPackages: string[];
|
|
25
|
+
outputFileTracingIncludes: Record<string, string[]>;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { WithVoxxOptions, withVoxx };
|
|
29
|
+
//# sourceMappingURL=next.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.mts","names":[],"sources":["../src/next.ts"],"mappings":";;UAOiB,eAAA;EAAe;EAE9B,GAAG;AAAA;AAAA;AAwDL;;;;;;;;;;;;;;AAxDK,iBAwDW,QAAA,mBACd,MAAA,GAAQ,CAAA,EACR,OAAA,GAAS,eAAA,GACR,CAAA;EACD,eAAA;EACA,sBAAA;EACA,yBAAA,EAA2B,MAAA;AAAA"}
|
package/dist/next.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
//#region src/next.ts
|
|
4
|
+
const CORE_PACKAGE = "@prudentbird/voxx-core";
|
|
5
|
+
const DEFAULT_CONTENT_DIR = "content";
|
|
6
|
+
/**
|
|
7
|
+
* Reads the relative content directories declared in `voxx.json`, falling back
|
|
8
|
+
* to the default `content` directory when the file is missing or unreadable.
|
|
9
|
+
*/
|
|
10
|
+
function contentDirs(cwd) {
|
|
11
|
+
try {
|
|
12
|
+
const data = JSON.parse(readFileSync(join(cwd, "voxx.json"), "utf8"));
|
|
13
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const c of data.collections ?? []) dirs.add(c.dir ?? `${DEFAULT_CONTENT_DIR}/${c.name ?? c.type ?? "blog"}`);
|
|
15
|
+
if (data.content?.dir) dirs.add(data.content.dir);
|
|
16
|
+
return dirs.size > 0 ? [...dirs] : [DEFAULT_CONTENT_DIR];
|
|
17
|
+
} catch {
|
|
18
|
+
return [DEFAULT_CONTENT_DIR];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wraps a Next.js config with the settings every Voxx app needs to run
|
|
23
|
+
* correctly on serverless platforms.
|
|
24
|
+
*
|
|
25
|
+
* Enables Cache Components, marks `@prudentbird/voxx-core` as an external
|
|
26
|
+
* server package, and traces `voxx.json` plus every content directory into the
|
|
27
|
+
* serverless function bundle so runtime config and content reads resolve. Voxx
|
|
28
|
+
* content is filesystem-backed and read at request time during cache
|
|
29
|
+
* revalidation, so without these includes those reads fail on platforms that
|
|
30
|
+
* bundle each route into an isolated function.
|
|
31
|
+
*
|
|
32
|
+
* @param config - Base Next.js config. Existing values are preserved; `cacheComponents` defaults to `true` when unset.
|
|
33
|
+
* @param options - Optional `cwd` override for locating `voxx.json`.
|
|
34
|
+
* @returns The base config merged with Voxx's required settings.
|
|
35
|
+
*/
|
|
36
|
+
function withVoxx(config = {}, options = {}) {
|
|
37
|
+
const base = config;
|
|
38
|
+
const includes = ["./voxx.json", ...contentDirs(options.cwd ?? process.cwd()).map((dir) => `./${dir}/**/*`)];
|
|
39
|
+
const existing = base.outputFileTracingIncludes ?? {};
|
|
40
|
+
return {
|
|
41
|
+
...base,
|
|
42
|
+
cacheComponents: base.cacheComponents ?? true,
|
|
43
|
+
serverExternalPackages: [...new Set([...base.serverExternalPackages ?? [], CORE_PACKAGE])],
|
|
44
|
+
outputFileTracingIncludes: {
|
|
45
|
+
...existing,
|
|
46
|
+
"/*": [...new Set([...existing["/*"] ?? [], ...includes])]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { withVoxx };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=next.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.mjs","names":[],"sources":["../src/next.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst CORE_PACKAGE = \"@prudentbird/voxx-core\";\nconst DEFAULT_CONTENT_DIR = \"content\";\n\n/** Options for {@link withVoxx}. */\nexport interface WithVoxxOptions {\n /** Directory containing `voxx.json`. Defaults to `process.cwd()`. */\n cwd?: string;\n}\n\n/** The Next.js config fields {@link withVoxx} manages; all other fields pass through unchanged. */\ninterface ManagedConfig {\n cacheComponents?: boolean;\n serverExternalPackages?: string[];\n outputFileTracingIncludes?: Record<string, string[]>;\n}\n\ninterface RawCollection {\n name?: string;\n type?: string;\n dir?: string;\n}\n\ninterface RawConfig {\n content?: { dir?: string; type?: string };\n collections?: RawCollection[];\n}\n\n/**\n * Reads the relative content directories declared in `voxx.json`, falling back\n * to the default `content` directory when the file is missing or unreadable.\n */\nfunction contentDirs(cwd: string): string[] {\n try {\n const data = JSON.parse(\n readFileSync(join(cwd, \"voxx.json\"), \"utf8\"),\n ) as RawConfig;\n const dirs = new Set<string>();\n for (const c of data.collections ?? []) {\n dirs.add(c.dir ?? `${DEFAULT_CONTENT_DIR}/${c.name ?? c.type ?? \"blog\"}`);\n }\n if (data.content?.dir) dirs.add(data.content.dir);\n return dirs.size > 0 ? [...dirs] : [DEFAULT_CONTENT_DIR];\n } catch {\n return [DEFAULT_CONTENT_DIR];\n }\n}\n\n/**\n * Wraps a Next.js config with the settings every Voxx app needs to run\n * correctly on serverless platforms.\n *\n * Enables Cache Components, marks `@prudentbird/voxx-core` as an external\n * server package, and traces `voxx.json` plus every content directory into the\n * serverless function bundle so runtime config and content reads resolve. Voxx\n * content is filesystem-backed and read at request time during cache\n * revalidation, so without these includes those reads fail on platforms that\n * bundle each route into an isolated function.\n *\n * @param config - Base Next.js config. Existing values are preserved; `cacheComponents` defaults to `true` when unset.\n * @param options - Optional `cwd` override for locating `voxx.json`.\n * @returns The base config merged with Voxx's required settings.\n */\nexport function withVoxx<T extends object>(\n config: T = {} as T,\n options: WithVoxxOptions = {},\n): T & {\n cacheComponents: boolean;\n serverExternalPackages: string[];\n outputFileTracingIncludes: Record<string, string[]>;\n} {\n const base = config as T & ManagedConfig;\n const dirs = contentDirs(options.cwd ?? process.cwd());\n const includes = [\"./voxx.json\", ...dirs.map((dir) => `./${dir}/**/*`)];\n const existing = base.outputFileTracingIncludes ?? {};\n\n return {\n ...base,\n cacheComponents: base.cacheComponents ?? true,\n serverExternalPackages: [\n ...new Set([...(base.serverExternalPackages ?? []), CORE_PACKAGE]),\n ],\n outputFileTracingIncludes: {\n ...existing,\n \"/*\": [...new Set([...(existing[\"/*\"] ?? []), ...includes])],\n },\n };\n}\n"],"mappings":";;;AAGA,MAAM,eAAe;AACrB,MAAM,sBAAsB;;;;;AA8B5B,SAAS,YAAY,KAAuB;CAC1C,IAAI;EACF,MAAM,OAAO,KAAK,MAChB,aAAa,KAAK,KAAK,WAAW,GAAG,MAAM,CAC7C;EACA,MAAM,uBAAO,IAAI,IAAY;EAC7B,KAAK,MAAM,KAAK,KAAK,eAAe,CAAC,GACnC,KAAK,IAAI,EAAE,OAAO,GAAG,oBAAoB,GAAG,EAAE,QAAQ,EAAE,QAAQ,QAAQ;EAE1E,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,KAAK,QAAQ,GAAG;EAChD,OAAO,KAAK,OAAO,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,mBAAmB;CACzD,QAAQ;EACN,OAAO,CAAC,mBAAmB;CAC7B;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,SACd,SAAY,CAAC,GACb,UAA2B,CAAC,GAK5B;CACA,MAAM,OAAO;CAEb,MAAM,WAAW,CAAC,eAAe,GADpB,YAAY,QAAQ,OAAO,QAAQ,IAAI,CACb,CAAC,CAAC,KAAK,QAAQ,KAAK,IAAI,MAAM,CAAC;CACtE,MAAM,WAAW,KAAK,6BAA6B,CAAC;CAEpD,OAAO;EACL,GAAG;EACH,iBAAiB,KAAK,mBAAmB;EACzC,wBAAwB,CACtB,GAAG,IAAI,IAAI,CAAC,GAAI,KAAK,0BAA0B,CAAC,GAAI,YAAY,CAAC,CACnE;EACA,2BAA2B;GACzB,GAAG;GACH,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAI,SAAS,SAAS,CAAC,GAAI,GAAG,QAAQ,CAAC,CAAC;EAC7D;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prudentbird/voxx-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The portable content engine behind Voxx: markdown + frontmatter -> SEO-ready blogs, docs, and changelogs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "prudentbird <me@prudentbird.com> (https://prudentbird.com)",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"type": "module",
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=24"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|
|
@@ -59,6 +59,16 @@
|
|
|
59
59
|
"default": "./dist/effect.cjs"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
+
"./next": {
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./dist/next.d.mts",
|
|
65
|
+
"default": "./dist/next.mjs"
|
|
66
|
+
},
|
|
67
|
+
"require": {
|
|
68
|
+
"types": "./dist/next.d.cts",
|
|
69
|
+
"default": "./dist/next.cjs"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
62
72
|
"./theme/voxx.css": "./theme/voxx.css",
|
|
63
73
|
"./theme/demo-globals.css": "./theme/demo-globals.css",
|
|
64
74
|
"./voxx.schema.json": "./voxx.schema.json",
|
|
@@ -88,7 +98,6 @@
|
|
|
88
98
|
"@types/node": "^25.9.3",
|
|
89
99
|
"@typescript/native-preview": "7.0.0-dev.20260610.1",
|
|
90
100
|
"eslint": "^10.0.2",
|
|
91
|
-
"jiti": "^2.7.0",
|
|
92
101
|
"tsdown": "^0.22.2",
|
|
93
102
|
"typescript": "^6.0.3",
|
|
94
103
|
"vitest": "^4.1.8",
|