@conloca/astro-cms 0.1.14 → 0.1.15
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/collections.d.mts +3 -2
- package/dist/collections.d.mts.map +1 -1
- package/dist/collections.mjs +15 -6
- package/dist/collections.mjs.map +1 -1
- package/dist/components.d.mts +4 -24
- package/dist/components.d.mts.map +1 -1
- package/dist/components.mjs +98 -40
- package/dist/components.mjs.map +1 -1
- package/dist/hydration-scanner-B0NjYkZ_.mjs +109 -0
- package/dist/hydration-scanner-B0NjYkZ_.mjs.map +1 -0
- package/dist/hydration.d.mts +2 -2
- package/dist/hydration.mjs +1 -1
- package/dist/index.d.mts +9 -54
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +17 -796
- package/dist/index.mjs.map +1 -1
- package/dist/internal/acorn-default.mjs +29 -0
- package/dist/internal/cms-handler.d.mts.map +1 -0
- package/dist/{cms-handler.mjs → internal/cms-handler.mjs} +3 -1
- package/dist/internal/cms-handler.mjs.map +1 -0
- package/dist/internal/page-handler.astro +541 -0
- package/dist/lib/hydration-script.d.mts +1 -1
- package/dist/{loader-W3i9kf3p.mjs → loader-By-AQWHc.mjs} +10 -3
- package/dist/loader-By-AQWHc.mjs.map +1 -0
- package/dist/node/content.d.mts +19 -0
- package/dist/node/content.d.mts.map +1 -0
- package/dist/node/content.mjs +4 -0
- package/dist/node/index.d.mts +52 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.mjs +753 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/{serialize-props-DqfDQeFl.mjs → serialize-props-Dhv_MnkY.mjs} +3 -3
- package/dist/{serialize-props-DqfDQeFl.mjs.map → serialize-props-Dhv_MnkY.mjs.map} +1 -1
- package/dist/{types-Bsd_qENn.d.mts → types-CVQNmPxF.d.mts} +1 -1
- package/dist/{types-Bsd_qENn.d.mts.map → types-CVQNmPxF.d.mts.map} +1 -1
- package/dist/{withHydration-692fMySA.mjs → withHydration-EzyzBQ-Y.mjs} +5 -1
- package/dist/withHydration-EzyzBQ-Y.mjs.map +1 -0
- package/dist/{withHydration-BGgQDE-H.d.mts → withHydration-HIvO9ysY.d.mts} +5 -1
- package/dist/withHydration-HIvO9ysY.d.mts.map +1 -0
- package/package.json +35 -25
- package/dist/cms-handler.d.mts.map +0 -1
- package/dist/cms-handler.mjs.map +0 -1
- package/dist/handlers/page-handler.astro +0 -299
- package/dist/loader-W3i9kf3p.mjs.map +0 -1
- package/dist/withHydration-692fMySA.mjs.map +0 -1
- package/dist/withHydration-BGgQDE-H.d.mts.map +0 -1
- /package/dist/{cms-handler.d.mts → internal/cms-handler.d.mts} +0 -0
package/dist/collections.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineCollection } from "astro:content";
|
|
2
2
|
|
|
3
3
|
//#region src/collections.d.ts
|
|
4
|
+
declare const ALL_BLOCKS_COLLECTION = "__conloca_blocks";
|
|
4
5
|
/**
|
|
5
6
|
* Options for createConlocaCollections().
|
|
6
7
|
*/
|
|
@@ -24,12 +25,12 @@ interface ConlocaCollectionsResult {
|
|
|
24
25
|
* @example
|
|
25
26
|
* ```typescript
|
|
26
27
|
* // src/content.config.ts
|
|
27
|
-
* import { createConlocaCollections } from '@conloca/astro-cms/
|
|
28
|
+
* import { createConlocaCollections } from '@conloca/astro-cms/node/content';
|
|
28
29
|
*
|
|
29
30
|
* export const { collections } = await createConlocaCollections();
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
33
|
declare function createConlocaCollections(options?: CreateConlocaCollectionsOptions): Promise<ConlocaCollectionsResult>;
|
|
33
34
|
//#endregion
|
|
34
|
-
export { ConlocaCollectionsResult, CreateConlocaCollectionsOptions, createConlocaCollections };
|
|
35
|
+
export { ALL_BLOCKS_COLLECTION, ConlocaCollectionsResult, CreateConlocaCollectionsOptions, createConlocaCollections };
|
|
35
36
|
//# sourceMappingURL=collections.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.mts","names":[],"sources":["../src/collections.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"collections.d.mts","names":[],"sources":["../src/collections.ts"],"mappings":";;;cAKa,qBAAA;;AAAb;;UAKiB,+BAAA;EALiB;EAOhC,WAAA;EAFe;EAIf,IAAA;AAAA;;;AAMF;UAAiB,wBAAA;;EAEf,WAAA,EAAa,MAAA,SAAe,UAAA,QAAkB,gBAAA;AAAA;;;;;;;;;;AAehD;;;iBAAsB,wBAAA,CACpB,OAAA,GAAS,+BAAA,GACR,OAAA,CAAQ,wBAAA"}
|
package/dist/collections.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { t as conlocaLoader } from "./loader-
|
|
1
|
+
import { t as conlocaLoader } from "./loader-By-AQWHc.mjs";
|
|
2
2
|
import { blockMetaSchema, dataMetaSchema, pageMetaSchema } from "@conloca/content-api/schemas";
|
|
3
|
-
import { createContentAPI } from "@conloca/content-api/node";
|
|
4
3
|
import { defineCollection } from "astro:content";
|
|
4
|
+
import { createContentAPI } from "@conloca/content-api/reader";
|
|
5
5
|
|
|
6
6
|
//#region src/collections.ts
|
|
7
|
+
const ALL_BLOCKS_COLLECTION = "__conloca_blocks";
|
|
7
8
|
/**
|
|
8
9
|
* Creates Astro Content Collections by discovering from indexed content.
|
|
9
10
|
* Uses content-api to find collections that have content.
|
|
@@ -11,7 +12,7 @@ import { defineCollection } from "astro:content";
|
|
|
11
12
|
* @example
|
|
12
13
|
* ```typescript
|
|
13
14
|
* // src/content.config.ts
|
|
14
|
-
* import { createConlocaCollections } from '@conloca/astro-cms/
|
|
15
|
+
* import { createConlocaCollections } from '@conloca/astro-cms/node/content';
|
|
15
16
|
*
|
|
16
17
|
* export const { collections } = await createConlocaCollections();
|
|
17
18
|
* ```
|
|
@@ -20,6 +21,14 @@ async function createConlocaCollections(options = {}) {
|
|
|
20
21
|
const { contentRoot = "./content", site = "default" } = options;
|
|
21
22
|
const api = await createContentAPI({ contentRoot });
|
|
22
23
|
const collections = {};
|
|
24
|
+
collections[ALL_BLOCKS_COLLECTION] = defineCollection({
|
|
25
|
+
loader: conlocaLoader({
|
|
26
|
+
contentRoot,
|
|
27
|
+
site,
|
|
28
|
+
kind: "block"
|
|
29
|
+
}),
|
|
30
|
+
schema: blockMetaSchema.passthrough()
|
|
31
|
+
});
|
|
23
32
|
for (const name of api.blocks.collections) collections[name] = defineCollection({
|
|
24
33
|
loader: conlocaLoader({
|
|
25
34
|
collection: name,
|
|
@@ -27,7 +36,7 @@ async function createConlocaCollections(options = {}) {
|
|
|
27
36
|
site,
|
|
28
37
|
kind: "block"
|
|
29
38
|
}),
|
|
30
|
-
schema: blockMetaSchema
|
|
39
|
+
schema: blockMetaSchema.passthrough()
|
|
31
40
|
});
|
|
32
41
|
for (const name of api.data.collections) collections[name] = defineCollection({
|
|
33
42
|
loader: conlocaLoader({
|
|
@@ -36,7 +45,7 @@ async function createConlocaCollections(options = {}) {
|
|
|
36
45
|
site,
|
|
37
46
|
kind: "data"
|
|
38
47
|
}),
|
|
39
|
-
schema: dataMetaSchema
|
|
48
|
+
schema: dataMetaSchema.passthrough()
|
|
40
49
|
});
|
|
41
50
|
const siteCollections = api.getSite(site)?.collections ?? /* @__PURE__ */ new Set();
|
|
42
51
|
for (const name of siteCollections) collections[name] = defineCollection({
|
|
@@ -52,5 +61,5 @@ async function createConlocaCollections(options = {}) {
|
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
//#endregion
|
|
55
|
-
export { createConlocaCollections };
|
|
64
|
+
export { ALL_BLOCKS_COLLECTION, createConlocaCollections };
|
|
56
65
|
//# sourceMappingURL=collections.mjs.map
|
package/dist/collections.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.mjs","names":[],"sources":["../src/collections.ts"],"sourcesContent":["import { defineCollection } from 'astro:content';\nimport { createContentAPI } from '@conloca/content-api/
|
|
1
|
+
{"version":3,"file":"collections.mjs","names":[],"sources":["../src/collections.ts"],"sourcesContent":["import { defineCollection } from 'astro:content';\nimport { createContentAPI } from '@conloca/content-api/reader';\nimport { blockMetaSchema, dataMetaSchema, pageMetaSchema } from '@conloca/content-api/schemas';\nimport { conlocaLoader } from './loader';\n\nexport const ALL_BLOCKS_COLLECTION = '__conloca_blocks';\n\n/**\n * Options for createConlocaCollections().\n */\nexport interface CreateConlocaCollectionsOptions {\n /** Path to content root directory. @default './content' */\n contentRoot?: string;\n /** Site name for multi-site setups. @default 'default' */\n site?: string;\n}\n\n/**\n * Return type of createConlocaCollections().\n */\nexport interface ConlocaCollectionsResult {\n /** Astro Content Collections definitions - export this as `collections` */\n collections: Record<string, ReturnType<typeof defineCollection>>;\n}\n\n/**\n * Creates Astro Content Collections by discovering from indexed content.\n * Uses content-api to find collections that have content.\n *\n * @example\n * ```typescript\n * // src/content.config.ts\n * import { createConlocaCollections } from '@conloca/astro-cms/node/content';\n *\n * export const { collections } = await createConlocaCollections();\n * ```\n */\nexport async function createConlocaCollections(\n options: CreateConlocaCollectionsOptions = {},\n): Promise<ConlocaCollectionsResult> {\n const { contentRoot = './content', site = 'default' } = options;\n\n const api = await createContentAPI({ contentRoot });\n const collections: Record<string, ReturnType<typeof defineCollection>> = {};\n\n collections[ALL_BLOCKS_COLLECTION] = defineCollection({\n loader: conlocaLoader({ contentRoot, site, kind: 'block' }),\n schema: blockMetaSchema.passthrough() as never,\n });\n\n // Add block collections\n for (const name of api.blocks.collections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'block' }),\n // Cast needed: Astro uses Zod v3 BaseSchema types, our schemas are Zod v4\n schema: blockMetaSchema.passthrough() as never,\n });\n }\n\n // Add data collections\n for (const name of api.data.collections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'data' }),\n schema: dataMetaSchema.passthrough() as never,\n });\n }\n\n // Add page collections for this site\n const siteCollections = api.getSite(site)?.collections ?? new Set<string>();\n for (const name of siteCollections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'page' }),\n schema: pageMetaSchema.passthrough() as never,\n });\n }\n\n return { collections };\n}\n"],"mappings":";;;;;;AAKA,MAAa,wBAAwB;;;;;;;;;;;;;AAgCrC,eAAsB,yBACpB,UAA2C,EAAE,EACV;CACnC,MAAM,EAAE,cAAc,aAAa,OAAO,cAAc;CAExD,MAAM,MAAM,MAAM,iBAAiB,EAAE,aAAa,CAAC;CACnD,MAAM,cAAmE,EAAE;AAE3E,aAAY,yBAAyB,iBAAiB;EACpD,QAAQ,cAAc;GAAE;GAAa;GAAM,MAAM;GAAS,CAAC;EAC3D,QAAQ,gBAAgB,aAAa;EACtC,CAAC;AAGF,MAAK,MAAM,QAAQ,IAAI,OAAO,YAC5B,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAS,CAAC;EAE7E,QAAQ,gBAAgB,aAAa;EACtC,CAAC;AAIJ,MAAK,MAAM,QAAQ,IAAI,KAAK,YAC1B,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAQ,CAAC;EAC5E,QAAQ,eAAe,aAAa;EACrC,CAAC;CAIJ,MAAM,kBAAkB,IAAI,QAAQ,KAAK,EAAE,+BAAe,IAAI,KAAa;AAC3E,MAAK,MAAM,QAAQ,gBACjB,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAQ,CAAC;EAC5E,QAAQ,eAAe,aAAa;EACrC,CAAC;AAGJ,QAAO,EAAE,aAAa"}
|
package/dist/components.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MDXBlockEvaluationResult, evaluateMDXBlocks } from "@conloca/mdx/node";
|
|
1
2
|
import { Config, Data } from "@puckeditor/core";
|
|
2
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
import { ComponentType } from "react";
|
|
@@ -17,31 +18,10 @@ interface MDXComponent {
|
|
|
17
18
|
*
|
|
18
19
|
* @param config - The Puck configuration with component definitions
|
|
19
20
|
* @param data - Puck page data containing component tree
|
|
20
|
-
* @param mdxComponents - Array of evaluated MDX
|
|
21
|
+
* @param mdxComponents - Array of evaluated MDX block results
|
|
21
22
|
* @returns A PageRenderer component with no props needed (components in closure)
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```astro
|
|
25
|
-
* ---
|
|
26
|
-
* import { createPageRendererWithBlocks } from '@conloca/astro-cms/components';
|
|
27
|
-
* import { evaluateMDXBlocks } from '@conloca/mdx/node';
|
|
28
|
-
* import { createContentAPI } from '@conloca/content-api/node';
|
|
29
|
-
* import config from '../puck.config';
|
|
30
|
-
*
|
|
31
|
-
* const api = await createContentAPI({ contentRoot: './content' });
|
|
32
|
-
* const mdxComponents = await evaluateMDXBlocks(api, 'en');
|
|
33
|
-
* const PageRenderer = createPageRendererWithBlocks(config, puckData, mdxComponents);
|
|
34
|
-
* ---
|
|
35
|
-
* <PageRenderer />
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* Benefits:
|
|
39
|
-
* - No dangerouslySetInnerHTML (safer, no XSS risk from HTML strings)
|
|
40
|
-
* - No string conversion round-trip (more efficient)
|
|
41
|
-
* - Type safe React components throughout
|
|
42
|
-
* - Normal React rendering with proper escaping
|
|
43
23
|
*/
|
|
44
|
-
declare function createPageRendererWithBlocks(config: Config, data: Data, mdxComponents: MDXComponent[]): ComponentType;
|
|
24
|
+
declare function createPageRendererWithBlocks(config: Config, data: Data, mdxComponents: (MDXBlockEvaluationResult | MDXComponent)[]): ComponentType;
|
|
45
25
|
//#endregion
|
|
46
26
|
//#region src/components/RenderWithHydration.d.ts
|
|
47
27
|
interface RenderWithHydrationProps {
|
|
@@ -62,5 +42,5 @@ declare function RenderWithHydration({
|
|
|
62
42
|
data
|
|
63
43
|
}: RenderWithHydrationProps): react_jsx_runtime0.JSX.Element;
|
|
64
44
|
//#endregion
|
|
65
|
-
export { RenderWithHydration, createPageRendererWithBlocks };
|
|
45
|
+
export { RenderWithHydration, createPageRendererWithBlocks, evaluateMDXBlocks };
|
|
66
46
|
//# sourceMappingURL=components.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.mts","names":[],"sources":["../src/components/RenderWithBlocks.tsx","../src/components/RenderWithHydration.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.d.mts","names":[],"sources":["../src/components/RenderWithBlocks.tsx","../src/components/RenderWithHydration.tsx"],"mappings":";;;;;;UAQU,YAAA;EACR,EAAA;EACA,KAAA;EACA,SAAA,EAAW,aAAA;AAAA;;;;;;;;;AAsMb;;;;iBAAgB,4BAAA,CACd,MAAA,EAAQ,MAAA,EACR,IAAA,EAAM,IAAA,EACN,aAAA,GAAgB,wBAAA,GAA2B,YAAA,MAC1C,aAAA;;;UChNO,wBAAA;EACR,MAAA,EAAQ,MAAA;EACR,IAAA,EAAM,IAAA;AAAA;;ADHmC;;;;;;;;iBCe3B,mBAAA,CAAA;EAAsB,MAAA;EAAQ;AAAA,GAAQ,wBAAA,GAAwB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/components.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { i as isHydratable, r as hasHydratableComponents, t as serializeProps } from "./serialize-props-
|
|
1
|
+
import { i as isHydratable, r as hasHydratableComponents, t as serializeProps } from "./serialize-props-Dhv_MnkY.mjs";
|
|
2
|
+
import { evaluateMDXBlocks } from "@conloca/mdx/node";
|
|
2
3
|
import { Render } from "@puckeditor/core";
|
|
3
|
-
import
|
|
4
|
+
import cn from "clsx";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
6
|
|
|
5
7
|
//#region src/components/HydrationWrapper.tsx
|
|
6
8
|
/**
|
|
@@ -12,11 +14,12 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
12
14
|
*/
|
|
13
15
|
function HydrationWrapper({ componentName, strategy, props, children }) {
|
|
14
16
|
if (strategy === "none") return /* @__PURE__ */ jsx(Fragment, { children });
|
|
17
|
+
const { puck: _puck, ...hydrateProps } = props;
|
|
15
18
|
return /* @__PURE__ */ jsx("div", {
|
|
16
19
|
style: { display: "contents" },
|
|
17
20
|
"data-hydrate": componentName,
|
|
18
21
|
"data-hydrate-strategy": strategy,
|
|
19
|
-
"data-props": serializeProps(
|
|
22
|
+
"data-props": serializeProps(hydrateProps),
|
|
20
23
|
children
|
|
21
24
|
});
|
|
22
25
|
}
|
|
@@ -57,29 +60,67 @@ function RenderWithHydration({ config, data }) {
|
|
|
57
60
|
|
|
58
61
|
//#endregion
|
|
59
62
|
//#region src/components/RenderWithBlocks.tsx
|
|
63
|
+
function isRenderableBlock(block) {
|
|
64
|
+
return "Component" in block && !("ok" in block);
|
|
65
|
+
}
|
|
66
|
+
const contentBlockWidthClasses = {
|
|
67
|
+
narrow: "max-w-3xl",
|
|
68
|
+
default: "max-w-4xl"
|
|
69
|
+
};
|
|
70
|
+
const contentBlockToneClasses = {
|
|
71
|
+
transparent: "",
|
|
72
|
+
subtle: "rounded-3xl border border-surface-200/80 bg-surface-100/70 p-6 sm:p-8 dark:border-surface-800/60 dark:bg-surface-900/50"
|
|
73
|
+
};
|
|
74
|
+
function createFailedBlockComponent(block) {
|
|
75
|
+
return function FailedBlockComponent() {
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
77
|
+
className: "p-4 bg-red-50 border border-red-200 rounded text-red-600",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx("p", {
|
|
80
|
+
className: "font-semibold mb-2",
|
|
81
|
+
children: "MDX Block Error"
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsxs("p", {
|
|
84
|
+
className: "text-sm",
|
|
85
|
+
children: ["Block: ", block.id]
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsx("p", {
|
|
88
|
+
className: "text-xs mt-2",
|
|
89
|
+
children: block.error.message
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function resolveRenderableBlocks(blocks) {
|
|
96
|
+
return blocks.map((block) => {
|
|
97
|
+
if (isRenderableBlock(block)) return block;
|
|
98
|
+
if (block.ok) return block;
|
|
99
|
+
return {
|
|
100
|
+
id: block.id,
|
|
101
|
+
title: block.title,
|
|
102
|
+
Component: createFailedBlockComponent(block)
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
60
106
|
/**
|
|
61
107
|
* Internal component for rendering Puck pages with MDX blocks.
|
|
62
108
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
109
|
+
* Enhances the Puck config by:
|
|
110
|
+
* 1. Registering each MDX block as a dynamic Puck component (`Block_{id}`)
|
|
111
|
+
* 2. Overriding ContentBlockSection's render to resolve blockId → actual MDX content
|
|
65
112
|
*
|
|
66
113
|
* MDX blocks are passed as React components (not HTML strings), which:
|
|
67
114
|
* - Avoids dangerouslySetInnerHTML security risks
|
|
68
115
|
* - More efficient (no HTML conversion round-trip)
|
|
69
116
|
* - Type-safe with proper React component types
|
|
70
117
|
*
|
|
71
|
-
* **Note:** This function is internal. Use `createPageRendererWithBlocks` instead,
|
|
72
|
-
* which provides a factory pattern to handle the closure correctly.
|
|
73
|
-
*
|
|
74
118
|
* @internal
|
|
75
|
-
* @param props - Component props
|
|
76
|
-
* @param props.config - Base Puck configuration
|
|
77
|
-
* @param props.data - Puck page data containing component tree
|
|
78
|
-
* @param props.mdxComponents - Array of evaluated MDX React components
|
|
79
119
|
*/
|
|
80
120
|
function RenderWithBlocks({ config, data, mdxComponents }) {
|
|
81
121
|
const blockComponents = {};
|
|
82
122
|
const blockCategoryList = [];
|
|
123
|
+
const blockComponentMap = new Map(mdxComponents.map((block) => [block.id, block]));
|
|
83
124
|
mdxComponents.forEach((block) => {
|
|
84
125
|
const componentKey = `Block_${block.id}`;
|
|
85
126
|
const BlockComponent = block.Component;
|
|
@@ -89,7 +130,7 @@ function RenderWithBlocks({ config, data, mdxComponents }) {
|
|
|
89
130
|
defaultProps: {},
|
|
90
131
|
render: () => {
|
|
91
132
|
return /* @__PURE__ */ jsx("div", {
|
|
92
|
-
className: "mdx-content prose
|
|
133
|
+
className: "mdx-content conloca-prose max-w-none",
|
|
93
134
|
children: /* @__PURE__ */ jsx(BlockComponent, {})
|
|
94
135
|
});
|
|
95
136
|
}
|
|
@@ -97,8 +138,44 @@ function RenderWithBlocks({ config, data, mdxComponents }) {
|
|
|
97
138
|
blockCategoryList.push(componentKey);
|
|
98
139
|
});
|
|
99
140
|
const existingCategories = config.categories || {};
|
|
141
|
+
const existingComponents = config.components || {};
|
|
142
|
+
const contentBlockSection = existingComponents.ContentBlockSection;
|
|
143
|
+
const enhancedContentBlockSection = contentBlockSection ? {
|
|
144
|
+
...contentBlockSection,
|
|
145
|
+
render: ({ blockId, label, title, subtitle, tone = "transparent", width = "default" }) => {
|
|
146
|
+
const SelectedBlockComponent = blockComponentMap.get(blockId)?.Component;
|
|
147
|
+
return /* @__PURE__ */ jsx("section", {
|
|
148
|
+
className: "pb-16 sm:pb-20",
|
|
149
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
150
|
+
className: cn("mx-auto px-4 sm:px-6 lg:px-8", contentBlockWidthClasses[width]),
|
|
151
|
+
children: [
|
|
152
|
+
label ? /* @__PURE__ */ jsx("p", {
|
|
153
|
+
className: "mb-4 text-sm font-medium uppercase tracking-[0.18em] text-brand-700 dark:text-brand-300",
|
|
154
|
+
children: label
|
|
155
|
+
}) : null,
|
|
156
|
+
title && /* @__PURE__ */ jsx("h2", {
|
|
157
|
+
className: "text-2xl sm:text-3xl font-bold text-surface-900 dark:text-white mb-4",
|
|
158
|
+
children: title
|
|
159
|
+
}),
|
|
160
|
+
subtitle && /* @__PURE__ */ jsx("p", {
|
|
161
|
+
className: "text-surface-500 dark:text-surface-400 text-sm leading-relaxed mb-6",
|
|
162
|
+
children: subtitle
|
|
163
|
+
}),
|
|
164
|
+
/* @__PURE__ */ jsx("div", {
|
|
165
|
+
className: cn(contentBlockToneClasses[tone]),
|
|
166
|
+
children: SelectedBlockComponent && /* @__PURE__ */ jsx("div", {
|
|
167
|
+
className: "mdx-content conloca-prose max-w-none",
|
|
168
|
+
children: /* @__PURE__ */ jsx(SelectedBlockComponent, {})
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
} : void 0;
|
|
100
176
|
const mergedComponents = {
|
|
101
|
-
...
|
|
177
|
+
...existingComponents,
|
|
178
|
+
...enhancedContentBlockSection && { ContentBlockSection: enhancedContentBlockSection },
|
|
102
179
|
...blockComponents
|
|
103
180
|
};
|
|
104
181
|
const enhancedConfig = {
|
|
@@ -112,10 +189,11 @@ function RenderWithBlocks({ config, data, mdxComponents }) {
|
|
|
112
189
|
},
|
|
113
190
|
components: mergedComponents
|
|
114
191
|
};
|
|
115
|
-
|
|
192
|
+
if (hasHydratableComponents(data, enhancedConfig)) return /* @__PURE__ */ jsx(RenderWithHydration, {
|
|
116
193
|
config: enhancedConfig,
|
|
117
194
|
data
|
|
118
|
-
})
|
|
195
|
+
});
|
|
196
|
+
return /* @__PURE__ */ jsx(Render, {
|
|
119
197
|
config: enhancedConfig,
|
|
120
198
|
data
|
|
121
199
|
});
|
|
@@ -129,40 +207,20 @@ function RenderWithBlocks({ config, data, mdxComponents }) {
|
|
|
129
207
|
*
|
|
130
208
|
* @param config - The Puck configuration with component definitions
|
|
131
209
|
* @param data - Puck page data containing component tree
|
|
132
|
-
* @param mdxComponents - Array of evaluated MDX
|
|
210
|
+
* @param mdxComponents - Array of evaluated MDX block results
|
|
133
211
|
* @returns A PageRenderer component with no props needed (components in closure)
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```astro
|
|
137
|
-
* ---
|
|
138
|
-
* import { createPageRendererWithBlocks } from '@conloca/astro-cms/components';
|
|
139
|
-
* import { evaluateMDXBlocks } from '@conloca/mdx/node';
|
|
140
|
-
* import { createContentAPI } from '@conloca/content-api/node';
|
|
141
|
-
* import config from '../puck.config';
|
|
142
|
-
*
|
|
143
|
-
* const api = await createContentAPI({ contentRoot: './content' });
|
|
144
|
-
* const mdxComponents = await evaluateMDXBlocks(api, 'en');
|
|
145
|
-
* const PageRenderer = createPageRendererWithBlocks(config, puckData, mdxComponents);
|
|
146
|
-
* ---
|
|
147
|
-
* <PageRenderer />
|
|
148
|
-
* ```
|
|
149
|
-
*
|
|
150
|
-
* Benefits:
|
|
151
|
-
* - No dangerouslySetInnerHTML (safer, no XSS risk from HTML strings)
|
|
152
|
-
* - No string conversion round-trip (more efficient)
|
|
153
|
-
* - Type safe React components throughout
|
|
154
|
-
* - Normal React rendering with proper escaping
|
|
155
212
|
*/
|
|
156
213
|
function createPageRendererWithBlocks(config, data, mdxComponents) {
|
|
214
|
+
const renderableBlocks = resolveRenderableBlocks(mdxComponents);
|
|
157
215
|
return function PageRendererWithBlocks() {
|
|
158
216
|
return /* @__PURE__ */ jsx(RenderWithBlocks, {
|
|
159
217
|
config,
|
|
160
218
|
data,
|
|
161
|
-
mdxComponents
|
|
219
|
+
mdxComponents: renderableBlocks
|
|
162
220
|
});
|
|
163
221
|
};
|
|
164
222
|
}
|
|
165
223
|
|
|
166
224
|
//#endregion
|
|
167
|
-
export { RenderWithHydration, createPageRendererWithBlocks };
|
|
225
|
+
export { RenderWithHydration, createPageRendererWithBlocks, evaluateMDXBlocks };
|
|
168
226
|
//# sourceMappingURL=components.mjs.map
|
package/dist/components.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.mjs","names":[],"sources":["../src/components/HydrationWrapper.tsx","../src/components/RenderWithHydration.tsx","../src/components/RenderWithBlocks.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { serializeProps } from '../lib/serialize-props.js';\nimport type { HydrationStrategy } from '../types.js';\n\ninterface HydrationWrapperProps {\n componentName: string;\n strategy: HydrationStrategy;\n props: Record<string, unknown>;\n children: ReactNode;\n}\n\n/**\n * Wraps hydratable components with data attributes for browser hydration.\n *\n * When strategy is 'none', renders children directly without wrapper overhead.\n * Otherwise, wraps in a div with data-hydrate attributes that the browser\n * hydration script uses to find and hydrate components.\n */\nexport function HydrationWrapper({ componentName, strategy, props, children }: HydrationWrapperProps) {\n // No hydration needed - render children directly without wrapper\n if (strategy === 'none') {\n return <>{children}</>;\n }\n\n // Wrap with hydration markers for the browser script to find\n return (\n <div\n style={{ display: 'contents' }}\n data-hydrate={componentName}\n data-hydrate-strategy={strategy}\n data-props={serializeProps(props)}\n >\n {children}\n </div>\n );\n}\n","import type { Config, Data } from '@puckeditor/core';\nimport { Render } from '@puckeditor/core';\nimport { isHydratable } from '../lib/hydration-utils.js';\nimport { HydrationWrapper } from './HydrationWrapper.js';\n\ninterface RenderWithHydrationProps {\n config: Config;\n data: Data;\n}\n\n/**\n * Wrapper around Puck's Render component that adds hydration support.\n *\n * For each component with a hydration strategy configured, wraps the\n * component's render output with HydrationWrapper to add data-hydrate\n * attributes for browser-side hydration.\n *\n * Non-hydratable components render without any wrapper overhead.\n */\nexport function RenderWithHydration({ config, data }: RenderWithHydrationProps) {\n // Create wrapped config with hydration-aware render functions\n const wrappedConfig: Config = {\n ...config,\n components: Object.fromEntries(\n Object.entries(config.components).map(([name, componentConfig]) => {\n const strategy = isHydratable(name, config);\n\n if (strategy === 'none') {\n // No wrapping needed - component stays static\n return [name, componentConfig];\n }\n\n // Wrap the render function so its output becomes HydrationWrapper children\n const originalRender = componentConfig.render;\n return [\n name,\n {\n ...componentConfig,\n render: (props) => (\n <HydrationWrapper componentName={name} strategy={strategy} props={props}>\n {originalRender(props)}\n </HydrationWrapper>\n ),\n },\n ];\n }),\n ),\n };\n\n return <Render config={wrappedConfig} data={data} />;\n}\n","import type { ComponentConfig, Config, Data } from '@puckeditor/core';\nimport { Render } from '@puckeditor/core';\nimport type { ComponentType } from 'react';\nimport { hasHydratableComponents } from '../lib/hydration-utils.js';\nimport { RenderWithHydration } from './RenderWithHydration.js';\n\ninterface MDXComponent {\n id: string;\n title: string;\n Component: ComponentType;\n}\n\ninterface RenderWithBlocksProps {\n config: Config;\n data: Data;\n mdxComponents: MDXComponent[];\n}\n\n/**\n * Internal component for rendering Puck pages with MDX blocks.\n *\n * Uses Puck's Render component for static rendering in Astro.\n * All content is pre-rendered at build time with no client-side JavaScript.\n *\n * MDX blocks are passed as React components (not HTML strings), which:\n * - Avoids dangerouslySetInnerHTML security risks\n * - More efficient (no HTML conversion round-trip)\n * - Type-safe with proper React component types\n *\n * **Note:** This function is internal. Use `createPageRendererWithBlocks` instead,\n * which provides a factory pattern to handle the closure correctly.\n *\n * @internal\n * @param props - Component props\n * @param props.config - Base Puck configuration\n * @param props.data - Puck page data containing component tree\n * @param props.mdxComponents - Array of evaluated MDX React components\n */\nfunction RenderWithBlocks({ config, data, mdxComponents }: RenderWithBlocksProps) {\n // Build enhanced config with MDX blocks\n const blockComponents: Record<string, ComponentConfig> = {};\n const blockCategoryList: string[] = [];\n\n // Create component configs for each block\n mdxComponents.forEach((block) => {\n const componentKey = `Block_${block.id}`;\n\n // Capture component in closure - Puck doesn't persist defaultProps reliably\n const BlockComponent = block.Component;\n\n blockComponents[componentKey] = {\n label: block.title,\n fields: {},\n defaultProps: {},\n render: () => {\n // Use blockId and BlockComponent from closure - no prop dependency\n return (\n <div className=\"mdx-content prose prose-sm max-w-none\">\n <BlockComponent />\n </div>\n );\n },\n };\n blockCategoryList.push(componentKey);\n });\n\n // Merge with existing config\n const existingCategories = config.categories || {};\n const existingComponents = config.components || {};\n\n // Merge block components with existing config components\n const mergedComponents = {\n ...existingComponents,\n ...blockComponents,\n } as Config['components'];\n\n const enhancedConfig: Config = {\n ...config,\n categories: {\n ...existingCategories,\n blocks: {\n title: 'Content Blocks',\n components: blockCategoryList,\n },\n },\n components: mergedComponents,\n };\n\n // Check if page has hydratable components\n const needsHydration = hasHydratableComponents(data, enhancedConfig);\n\n // Render with hydration support if needed, otherwise static\n return needsHydration ? (\n <RenderWithHydration config={enhancedConfig} data={data} />\n ) : (\n <Render config={enhancedConfig} data={data} />\n );\n}\n\n/**\n * Factory function to create a PageRenderer with MDX components baked in via closure.\n *\n * This approach avoids dangerouslySetInnerHTML by keeping React components as components\n * throughout the rendering pipeline. Components are captured in the closure and don't\n * need to be passed as props (which Astro can't serialize).\n *\n * @param config - The Puck configuration with component definitions\n * @param data - Puck page data containing component tree\n * @param mdxComponents - Array of evaluated MDX components\n * @returns A PageRenderer component with no props needed (components in closure)\n *\n * @example\n * ```astro\n * ---\n * import { createPageRendererWithBlocks } from '@conloca/astro-cms/components';\n * import { evaluateMDXBlocks } from '@conloca/mdx/node';\n * import { createContentAPI } from '@conloca/content-api/node';\n * import config from '../puck.config';\n *\n * const api = await createContentAPI({ contentRoot: './content' });\n * const mdxComponents = await evaluateMDXBlocks(api, 'en');\n * const PageRenderer = createPageRendererWithBlocks(config, puckData, mdxComponents);\n * ---\n * <PageRenderer />\n * ```\n *\n * Benefits:\n * - No dangerouslySetInnerHTML (safer, no XSS risk from HTML strings)\n * - No string conversion round-trip (more efficient)\n * - Type safe React components throughout\n * - Normal React rendering with proper escaping\n */\nexport function createPageRendererWithBlocks(config: Config, data: Data, mdxComponents: MDXComponent[]): ComponentType {\n // Capture components in closure - no need to pass as props\n return function PageRendererWithBlocks() {\n return <RenderWithBlocks config={config} data={data} mdxComponents={mdxComponents} />;\n };\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,EAAE,eAAe,UAAU,OAAO,YAAmC;AAEpG,KAAI,aAAa,OACf,QAAO,gCAAG,WAAY;AAIxB,QACE,oBAAC;EACC,OAAO,EAAE,SAAS,YAAY;EAC9B,gBAAc;EACd,yBAAuB;EACvB,cAAY,eAAe,MAAM;EAEhC;GACG;;;;;;;;;;;;;;ACdV,SAAgB,oBAAoB,EAAE,QAAQ,QAAkC;AA8B9E,QAAO,oBAAC;EAAO,QA5Be;GAC5B,GAAG;GACH,YAAY,OAAO,YACjB,OAAO,QAAQ,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,qBAAqB;IACjE,MAAM,WAAW,aAAa,MAAM,OAAO;AAE3C,QAAI,aAAa,OAEf,QAAO,CAAC,MAAM,gBAAgB;IAIhC,MAAM,iBAAiB,gBAAgB;AACvC,WAAO,CACL,MACA;KACE,GAAG;KACH,SAAS,UACP,oBAAC;MAAiB,eAAe;MAAgB;MAAiB;gBAC/D,eAAe,MAAM;OACL;KAEtB,CACF;KACD,CACH;GACF;EAE2C;GAAQ;;;;;;;;;;;;;;;;;;;;;;;;;ACXtD,SAAS,iBAAiB,EAAE,QAAQ,MAAM,iBAAwC;CAEhF,MAAM,kBAAmD,EAAE;CAC3D,MAAM,oBAA8B,EAAE;AAGtC,eAAc,SAAS,UAAU;EAC/B,MAAM,eAAe,SAAS,MAAM;EAGpC,MAAM,iBAAiB,MAAM;AAE7B,kBAAgB,gBAAgB;GAC9B,OAAO,MAAM;GACb,QAAQ,EAAE;GACV,cAAc,EAAE;GAChB,cAAc;AAEZ,WACE,oBAAC;KAAI,WAAU;eACb,oBAAC,mBAAiB;MACd;;GAGX;AACD,oBAAkB,KAAK,aAAa;GACpC;CAGF,MAAM,qBAAqB,OAAO,cAAc,EAAE;CAIlD,MAAM,mBAAmB;EACvB,GAJyB,OAAO,cAAc,EAAE;EAKhD,GAAG;EACJ;CAED,MAAM,iBAAyB;EAC7B,GAAG;EACH,YAAY;GACV,GAAG;GACH,QAAQ;IACN,OAAO;IACP,YAAY;IACb;GACF;EACD,YAAY;EACb;AAMD,QAHuB,wBAAwB,MAAM,eAAe,GAIlE,oBAAC;EAAoB,QAAQ;EAAsB;GAAQ,GAE3D,oBAAC;EAAO,QAAQ;EAAsB;GAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqClD,SAAgB,6BAA6B,QAAgB,MAAY,eAA8C;AAErH,QAAO,SAAS,yBAAyB;AACvC,SAAO,oBAAC;GAAyB;GAAc;GAAqB;IAAiB"}
|
|
1
|
+
{"version":3,"file":"components.mjs","names":[],"sources":["../src/components/HydrationWrapper.tsx","../src/components/RenderWithHydration.tsx","../src/components/RenderWithBlocks.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { serializeProps } from '../lib/serialize-props.js';\nimport type { HydrationStrategy } from '../types.js';\n\ninterface HydrationWrapperProps {\n componentName: string;\n strategy: HydrationStrategy;\n props: Record<string, unknown>;\n children: ReactNode;\n}\n\n/**\n * Wraps hydratable components with data attributes for browser hydration.\n *\n * When strategy is 'none', renders children directly without wrapper overhead.\n * Otherwise, wraps in a div with data-hydrate attributes that the browser\n * hydration script uses to find and hydrate components.\n */\nexport function HydrationWrapper({ componentName, strategy, props, children }: HydrationWrapperProps) {\n // No hydration needed - render children directly without wrapper\n if (strategy === 'none') {\n return <>{children}</>;\n }\n\n // Strip Puck-internal props that aren't needed for hydration.\n // `puck` contains functions (renderDropZone) that can't survive JSON serialization\n // and would crash on hydration if a component called them.\n const { puck: _puck, ...hydrateProps } = props as Record<string, unknown> & { puck?: unknown };\n\n // Wrap with hydration markers for the browser script to find\n return (\n <div\n style={{ display: 'contents' }}\n data-hydrate={componentName}\n data-hydrate-strategy={strategy}\n data-props={serializeProps(hydrateProps)}\n >\n {children}\n </div>\n );\n}\n","import type { Config, Data } from '@puckeditor/core';\nimport { Render } from '@puckeditor/core';\nimport { isHydratable } from '../lib/hydration-utils.js';\nimport { HydrationWrapper } from './HydrationWrapper.js';\n\ninterface RenderWithHydrationProps {\n config: Config;\n data: Data;\n}\n\n/**\n * Wrapper around Puck's Render component that adds hydration support.\n *\n * For each component with a hydration strategy configured, wraps the\n * component's render output with HydrationWrapper to add data-hydrate\n * attributes for browser-side hydration.\n *\n * Non-hydratable components render without any wrapper overhead.\n */\nexport function RenderWithHydration({ config, data }: RenderWithHydrationProps) {\n // Create wrapped config with hydration-aware render functions\n const wrappedConfig: Config = {\n ...config,\n components: Object.fromEntries(\n Object.entries(config.components).map(([name, componentConfig]) => {\n const strategy = isHydratable(name, config);\n\n if (strategy === 'none') {\n // No wrapping needed - component stays static\n return [name, componentConfig];\n }\n\n // Wrap the render function so its output becomes HydrationWrapper children\n const originalRender = componentConfig.render;\n return [\n name,\n {\n ...componentConfig,\n render: (props) => (\n <HydrationWrapper componentName={name} strategy={strategy} props={props}>\n {originalRender(props)}\n </HydrationWrapper>\n ),\n },\n ];\n }),\n ),\n };\n\n return <Render config={wrappedConfig} data={data} />;\n}\n","import type { MDXBlockEvaluationResult } from '@conloca/mdx/node';\nimport type { ComponentConfig, Config, Data } from '@puckeditor/core';\nimport { Render } from '@puckeditor/core';\nimport cn from 'clsx';\nimport type { ComponentType } from 'react';\nimport { hasHydratableComponents } from '../lib/hydration-utils.js';\nimport { RenderWithHydration } from './RenderWithHydration.js';\n\ninterface MDXComponent {\n id: string;\n title: string;\n Component: ComponentType;\n}\n\nfunction isRenderableBlock(block: MDXBlockEvaluationResult | MDXComponent): block is MDXComponent {\n return 'Component' in block && !('ok' in block);\n}\n\ninterface RenderWithBlocksProps {\n config: Config;\n data: Data;\n mdxComponents: MDXComponent[];\n}\n\ninterface ContentBlockSectionProps {\n title?: string;\n subtitle?: string;\n label?: string;\n blockId: string;\n width?: 'narrow' | 'default';\n tone?: 'transparent' | 'subtle';\n}\n\nconst contentBlockWidthClasses: Record<NonNullable<ContentBlockSectionProps['width']>, string> = {\n narrow: 'max-w-3xl',\n default: 'max-w-4xl',\n};\n\nconst contentBlockToneClasses: Record<NonNullable<ContentBlockSectionProps['tone']>, string> = {\n transparent: '',\n subtle:\n 'rounded-3xl border border-surface-200/80 bg-surface-100/70 p-6 sm:p-8 dark:border-surface-800/60 dark:bg-surface-900/50',\n};\n\nfunction createFailedBlockComponent(block: Extract<MDXBlockEvaluationResult, { ok: false }>): ComponentType {\n return function FailedBlockComponent() {\n return (\n <div className=\"p-4 bg-red-50 border border-red-200 rounded text-red-600\">\n <p className=\"font-semibold mb-2\">MDX Block Error</p>\n <p className=\"text-sm\">Block: {block.id}</p>\n <p className=\"text-xs mt-2\">{block.error.message}</p>\n </div>\n );\n };\n}\n\nfunction resolveRenderableBlocks(blocks: (MDXBlockEvaluationResult | MDXComponent)[]): MDXComponent[] {\n return blocks.map((block) => {\n if (isRenderableBlock(block)) {\n return block;\n }\n\n if (block.ok) {\n return block;\n }\n\n return {\n id: block.id,\n title: block.title,\n Component: createFailedBlockComponent(block),\n };\n });\n}\n\n// ── Main Component ──────────────────────────────────────────────────────────\n\n/**\n * Internal component for rendering Puck pages with MDX blocks.\n *\n * Enhances the Puck config by:\n * 1. Registering each MDX block as a dynamic Puck component (`Block_{id}`)\n * 2. Overriding ContentBlockSection's render to resolve blockId → actual MDX content\n *\n * MDX blocks are passed as React components (not HTML strings), which:\n * - Avoids dangerouslySetInnerHTML security risks\n * - More efficient (no HTML conversion round-trip)\n * - Type-safe with proper React component types\n *\n * @internal\n */\nfunction RenderWithBlocks({ config, data, mdxComponents }: RenderWithBlocksProps) {\n // Build enhanced config with MDX blocks\n const blockComponents: Record<string, ComponentConfig> = {};\n const blockCategoryList: string[] = [];\n const blockComponentMap = new Map(mdxComponents.map((block) => [block.id, block]));\n\n // Create component configs for each block\n mdxComponents.forEach((block) => {\n const componentKey = `Block_${block.id}`;\n\n // Capture component in closure - Puck doesn't persist defaultProps reliably\n const BlockComponent = block.Component;\n\n blockComponents[componentKey] = {\n label: block.title,\n fields: {},\n defaultProps: {},\n render: () => {\n // Use blockId and BlockComponent from closure - no prop dependency\n return (\n <div className=\"mdx-content conloca-prose max-w-none\">\n <BlockComponent />\n </div>\n );\n },\n };\n blockCategoryList.push(componentKey);\n });\n\n // Merge with existing config\n const existingCategories = config.categories || {};\n const existingComponents = config.components || {};\n const contentBlockSection = existingComponents.ContentBlockSection as\n | ComponentConfig<ContentBlockSectionProps>\n | undefined;\n\n const enhancedContentBlockSection = contentBlockSection\n ? {\n ...contentBlockSection,\n render: ({\n blockId,\n label,\n title,\n subtitle,\n tone = 'transparent',\n width = 'default',\n }: ContentBlockSectionProps) => {\n const selectedBlock = blockComponentMap.get(blockId);\n const SelectedBlockComponent = selectedBlock?.Component;\n\n return (\n <section className=\"pb-16 sm:pb-20\">\n <div className={cn('mx-auto px-4 sm:px-6 lg:px-8', contentBlockWidthClasses[width])}>\n {label ? (\n <p className=\"mb-4 text-sm font-medium uppercase tracking-[0.18em] text-brand-700 dark:text-brand-300\">\n {label}\n </p>\n ) : null}\n {title && (\n <h2 className=\"text-2xl sm:text-3xl font-bold text-surface-900 dark:text-white mb-4\">{title}</h2>\n )}\n {subtitle && (\n <p className=\"text-surface-500 dark:text-surface-400 text-sm leading-relaxed mb-6\">{subtitle}</p>\n )}\n <div className={cn(contentBlockToneClasses[tone])}>\n {SelectedBlockComponent && (\n <div className=\"mdx-content conloca-prose max-w-none\">\n <SelectedBlockComponent />\n </div>\n )}\n </div>\n </div>\n </section>\n );\n },\n }\n : undefined;\n\n // Merge block components with existing config components\n const mergedComponents = {\n ...existingComponents,\n ...(enhancedContentBlockSection && { ContentBlockSection: enhancedContentBlockSection }),\n ...blockComponents,\n } as Config['components'];\n\n const enhancedConfig: Config = {\n ...config,\n categories: {\n ...existingCategories,\n blocks: {\n title: 'Content Blocks',\n components: blockCategoryList,\n },\n },\n components: mergedComponents,\n };\n\n // Check if page has hydratable components\n const needsHydration = hasHydratableComponents(data, enhancedConfig);\n\n if (needsHydration) {\n return <RenderWithHydration config={enhancedConfig} data={data} />;\n }\n\n return <Render config={enhancedConfig} data={data} />;\n}\n\n/**\n * Factory function to create a PageRenderer with MDX components baked in via closure.\n *\n * This approach avoids dangerouslySetInnerHTML by keeping React components as components\n * throughout the rendering pipeline. Components are captured in the closure and don't\n * need to be passed as props (which Astro can't serialize).\n *\n * @param config - The Puck configuration with component definitions\n * @param data - Puck page data containing component tree\n * @param mdxComponents - Array of evaluated MDX block results\n * @returns A PageRenderer component with no props needed (components in closure)\n */\nexport function createPageRendererWithBlocks(\n config: Config,\n data: Data,\n mdxComponents: (MDXBlockEvaluationResult | MDXComponent)[],\n): ComponentType {\n const renderableBlocks = resolveRenderableBlocks(mdxComponents);\n\n // Capture components in closure - no need to pass as props\n return function PageRendererWithBlocks() {\n return <RenderWithBlocks config={config} data={data} mdxComponents={renderableBlocks} />;\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
3
|
+
import fg from "fast-glob";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/hydration-scanner.ts
|
|
6
|
+
const HYDRATION_IMPORT_PATTERN = /import\s+\{[^}]*withHydration[^}]*\}\s+from\s+['"]@conloca\/astro-cms(?:\/hydration)?['"]/;
|
|
7
|
+
const HYDRATION_PATTERN = /withHydration\s*\(\s*\w+\s*,\s*['"](\w+)['"]\s*\)/g;
|
|
8
|
+
const VALID_STRATEGIES = new Set([
|
|
9
|
+
"load",
|
|
10
|
+
"visible",
|
|
11
|
+
"idle"
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* Derives component scan paths from puckConfigPath.
|
|
15
|
+
*
|
|
16
|
+
* Convention: puckConfigPath directory + '/components/puck'
|
|
17
|
+
* Example: './src/puck.config.tsx' -> './src/components/puck'
|
|
18
|
+
*
|
|
19
|
+
* If explicitPaths provided, they extend (not replace) the auto-discovered path.
|
|
20
|
+
*
|
|
21
|
+
* @param puckConfigPath - Path to the puck config (e.g., './src/puck.config.tsx')
|
|
22
|
+
* @param explicitPaths - Optional additional paths to scan
|
|
23
|
+
* @returns Array of paths to scan for hydratable components
|
|
24
|
+
*/
|
|
25
|
+
function deriveComponentPaths(puckConfigPath, explicitPaths) {
|
|
26
|
+
const defaultScanPath = join(dirname(puckConfigPath), "components", "puck");
|
|
27
|
+
if (explicitPaths && explicitPaths.length > 0) return [defaultScanPath, ...explicitPaths];
|
|
28
|
+
return [defaultScanPath];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Derives a PascalCase component name from a file path.
|
|
32
|
+
*
|
|
33
|
+
* @param filePath - Absolute path to the component file
|
|
34
|
+
* @returns Component name in PascalCase
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* deriveComponentName('/src/components/puck/TestimonialGrid.tsx')
|
|
38
|
+
* // => 'TestimonialGrid'
|
|
39
|
+
*
|
|
40
|
+
* deriveComponentName('/src/components/puck/blog-post-grid.tsx')
|
|
41
|
+
* // => 'BlogPostGrid'
|
|
42
|
+
*/
|
|
43
|
+
function deriveComponentName(filePath) {
|
|
44
|
+
const filename = basename(filePath, extname(filePath));
|
|
45
|
+
if (filename.includes("-")) return filename.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
46
|
+
return filename.charAt(0).toUpperCase() + filename.slice(1);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Scans component directories for files using withHydration wrapper.
|
|
50
|
+
*
|
|
51
|
+
* This function performs static analysis to discover components marked
|
|
52
|
+
* for hydration, without executing any component code.
|
|
53
|
+
*
|
|
54
|
+
* @param componentPaths - Relative paths to scan (e.g., ['src/components/puck'])
|
|
55
|
+
* @param projectRoot - Absolute path to the project root
|
|
56
|
+
* @returns Array of discovered hydratable components with their strategies
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const discoveries = await scanForHydratableComponents(
|
|
61
|
+
* ['src/components/puck'],
|
|
62
|
+
* '/path/to/project'
|
|
63
|
+
* )
|
|
64
|
+
* // => [{ componentName: 'TestimonialGrid', filePath: '...', strategy: 'visible' }]
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
async function scanForHydratableComponents(componentPaths, projectRoot) {
|
|
68
|
+
const discoveries = [];
|
|
69
|
+
const seenNames = /* @__PURE__ */ new Map();
|
|
70
|
+
for (const scanPath of componentPaths) {
|
|
71
|
+
const files = await fg("**/*.tsx", {
|
|
72
|
+
cwd: resolve(projectRoot, scanPath),
|
|
73
|
+
absolute: true,
|
|
74
|
+
onlyFiles: true
|
|
75
|
+
});
|
|
76
|
+
for (const filePath of files) try {
|
|
77
|
+
const content = await readFile(filePath, "utf-8");
|
|
78
|
+
if (!HYDRATION_IMPORT_PATTERN.test(content)) continue;
|
|
79
|
+
const matches = [...content.matchAll(HYDRATION_PATTERN)];
|
|
80
|
+
if (matches.length === 0) continue;
|
|
81
|
+
if (matches.length > 1) console.warn(`[Conloca Hydration] Multiple withHydration calls in ${filePath}. Consider splitting into separate component files. Using first call.`);
|
|
82
|
+
const rawStrategy = matches[0][1];
|
|
83
|
+
if (!VALID_STRATEGIES.has(rawStrategy)) {
|
|
84
|
+
console.warn(`[Conloca Hydration] Invalid strategy '${rawStrategy}' in ${filePath}. Valid options: ${[...VALID_STRATEGIES].join(", ")}. Skipping component.`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const strategy = rawStrategy;
|
|
88
|
+
const componentName = deriveComponentName(filePath);
|
|
89
|
+
const existingPath = seenNames.get(componentName);
|
|
90
|
+
if (existingPath) {
|
|
91
|
+
console.warn(`[Conloca Hydration] Duplicate component name '${componentName}'. Found in: ${existingPath} and ${filePath}. Using first occurrence.`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
seenNames.set(componentName, filePath);
|
|
95
|
+
discoveries.push({
|
|
96
|
+
componentName,
|
|
97
|
+
filePath,
|
|
98
|
+
strategy
|
|
99
|
+
});
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.warn(`[Conloca Hydration] Error reading ${filePath}:`, err);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return discoveries;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
export { scanForHydratableComponents as n, deriveComponentPaths as t };
|
|
109
|
+
//# sourceMappingURL=hydration-scanner-B0NjYkZ_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration-scanner-B0NjYkZ_.mjs","names":[],"sources":["../src/lib/hydration-scanner.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename, dirname, extname, join, resolve } from 'node:path';\nimport fg from 'fast-glob';\n\n/**\n * Result of scanning a component file for withHydration usage.\n */\nexport interface HydrationDiscovery {\n /** Component name derived from filename (PascalCase) */\n componentName: string;\n /** Absolute path to the component file */\n filePath: string;\n /** Hydration strategy extracted from withHydration call */\n strategy: 'load' | 'visible' | 'idle';\n}\n\n// Regex to check if file imports withHydration from @conloca/astro-cms or @conloca/astro-cms/hydration\n// This is faster than es-module-lexer for JSX files and avoids parse errors\nexport const HYDRATION_IMPORT_PATTERN =\n /import\\s+\\{[^}]*withHydration[^}]*\\}\\s+from\\s+['\"]@conloca\\/astro-cms(?:\\/hydration)?['\"]/;\n\n// Regex to find withHydration calls and extract strategy\n// Matches: withHydration(ComponentName, 'strategy') or withHydration(ComponentName, \"strategy\")\nexport const HYDRATION_PATTERN = /withHydration\\s*\\(\\s*\\w+\\s*,\\s*['\"](\\w+)['\"]\\s*\\)/g;\n\n// Valid hydration strategies\nconst VALID_STRATEGIES = new Set(['load', 'visible', 'idle']);\n\n/**\n * Derives component scan paths from puckConfigPath.\n *\n * Convention: puckConfigPath directory + '/components/puck'\n * Example: './src/puck.config.tsx' -> './src/components/puck'\n *\n * If explicitPaths provided, they extend (not replace) the auto-discovered path.\n *\n * @param puckConfigPath - Path to the puck config (e.g., './src/puck.config.tsx')\n * @param explicitPaths - Optional additional paths to scan\n * @returns Array of paths to scan for hydratable components\n */\nexport function deriveComponentPaths(puckConfigPath: string, explicitPaths?: string[]): string[] {\n const puckDir = dirname(puckConfigPath);\n const defaultScanPath = join(puckDir, 'components', 'puck');\n\n if (explicitPaths && explicitPaths.length > 0) {\n return [defaultScanPath, ...explicitPaths];\n }\n return [defaultScanPath];\n}\n\n/**\n * Derives a PascalCase component name from a file path.\n *\n * @param filePath - Absolute path to the component file\n * @returns Component name in PascalCase\n *\n * @example\n * deriveComponentName('/src/components/puck/TestimonialGrid.tsx')\n * // => 'TestimonialGrid'\n *\n * deriveComponentName('/src/components/puck/blog-post-grid.tsx')\n * // => 'BlogPostGrid'\n */\nfunction deriveComponentName(filePath: string): string {\n const filename = basename(filePath, extname(filePath));\n // Convert kebab-case to PascalCase if needed\n if (filename.includes('-')) {\n return filename\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('');\n }\n // Ensure first letter is uppercase\n return filename.charAt(0).toUpperCase() + filename.slice(1);\n}\n\n/**\n * Scans component directories for files using withHydration wrapper.\n *\n * This function performs static analysis to discover components marked\n * for hydration, without executing any component code.\n *\n * @param componentPaths - Relative paths to scan (e.g., ['src/components/puck'])\n * @param projectRoot - Absolute path to the project root\n * @returns Array of discovered hydratable components with their strategies\n *\n * @example\n * ```typescript\n * const discoveries = await scanForHydratableComponents(\n * ['src/components/puck'],\n * '/path/to/project'\n * )\n * // => [{ componentName: 'TestimonialGrid', filePath: '...', strategy: 'visible' }]\n * ```\n */\nexport async function scanForHydratableComponents(\n componentPaths: string[],\n projectRoot: string,\n): Promise<HydrationDiscovery[]> {\n const discoveries: HydrationDiscovery[] = [];\n const seenNames = new Map<string, string>(); // componentName -> first filePath\n\n for (const scanPath of componentPaths) {\n const absolutePath = resolve(projectRoot, scanPath);\n\n // Find all .tsx files in the directory and subdirectories\n const files = await fg('**/*.tsx', {\n cwd: absolutePath,\n absolute: true,\n onlyFiles: true,\n });\n\n for (const filePath of files) {\n try {\n const content = await readFile(filePath, 'utf-8');\n\n // Fast path: check if file imports withHydration from @conloca/astro-cms\n // Using simple regex instead of es-module-lexer to avoid JSX parse errors\n if (!HYDRATION_IMPORT_PATTERN.test(content)) {\n continue;\n }\n\n // Find withHydration calls with regex\n const matches = [...content.matchAll(HYDRATION_PATTERN)];\n\n if (matches.length === 0) {\n continue;\n }\n\n if (matches.length > 1) {\n console.warn(\n `[Conloca Hydration] Multiple withHydration calls in ${filePath}. ` +\n 'Consider splitting into separate component files. Using first call.',\n );\n }\n\n const match = matches[0];\n const rawStrategy = match[1];\n\n // Validate strategy\n if (!VALID_STRATEGIES.has(rawStrategy)) {\n console.warn(\n `[Conloca Hydration] Invalid strategy '${rawStrategy}' in ${filePath}. ` +\n `Valid options: ${[...VALID_STRATEGIES].join(', ')}. Skipping component.`,\n );\n continue;\n }\n\n const strategy = rawStrategy as 'load' | 'visible' | 'idle';\n const componentName = deriveComponentName(filePath);\n\n // Check for naming conflicts\n const existingPath = seenNames.get(componentName);\n if (existingPath) {\n console.warn(\n `[Conloca Hydration] Duplicate component name '${componentName}'. ` +\n `Found in: ${existingPath} and ${filePath}. Using first occurrence.`,\n );\n continue;\n }\n\n seenNames.set(componentName, filePath);\n discoveries.push({\n componentName,\n filePath,\n strategy,\n });\n } catch (err) {\n // Log error but continue scanning other files\n console.warn(`[Conloca Hydration] Error reading ${filePath}:`, err);\n }\n }\n }\n\n return discoveries;\n}\n"],"mappings":";;;;;AAkBA,MAAa,2BACX;AAIF,MAAa,oBAAoB;AAGjC,MAAM,mBAAmB,IAAI,IAAI;CAAC;CAAQ;CAAW;CAAO,CAAC;;;;;;;;;;;;;AAc7D,SAAgB,qBAAqB,gBAAwB,eAAoC;CAE/F,MAAM,kBAAkB,KADR,QAAQ,eAAe,EACD,cAAc,OAAO;AAE3D,KAAI,iBAAiB,cAAc,SAAS,EAC1C,QAAO,CAAC,iBAAiB,GAAG,cAAc;AAE5C,QAAO,CAAC,gBAAgB;;;;;;;;;;;;;;;AAgB1B,SAAS,oBAAoB,UAA0B;CACrD,MAAM,WAAW,SAAS,UAAU,QAAQ,SAAS,CAAC;AAEtD,KAAI,SAAS,SAAS,IAAI,CACxB,QAAO,SACJ,MAAM,IAAI,CACV,KAAK,SAAS,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC,CAC3D,KAAK,GAAG;AAGb,QAAO,SAAS,OAAO,EAAE,CAAC,aAAa,GAAG,SAAS,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;AAsB7D,eAAsB,4BACpB,gBACA,aAC+B;CAC/B,MAAM,cAAoC,EAAE;CAC5C,MAAM,4BAAY,IAAI,KAAqB;AAE3C,MAAK,MAAM,YAAY,gBAAgB;EAIrC,MAAM,QAAQ,MAAM,GAAG,YAAY;GACjC,KAJmB,QAAQ,aAAa,SAAS;GAKjD,UAAU;GACV,WAAW;GACZ,CAAC;AAEF,OAAK,MAAM,YAAY,MACrB,KAAI;GACF,MAAM,UAAU,MAAM,SAAS,UAAU,QAAQ;AAIjD,OAAI,CAAC,yBAAyB,KAAK,QAAQ,CACzC;GAIF,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,kBAAkB,CAAC;AAExD,OAAI,QAAQ,WAAW,EACrB;AAGF,OAAI,QAAQ,SAAS,EACnB,SAAQ,KACN,uDAAuD,SAAS,uEAEjE;GAIH,MAAM,cADQ,QAAQ,GACI;AAG1B,OAAI,CAAC,iBAAiB,IAAI,YAAY,EAAE;AACtC,YAAQ,KACN,yCAAyC,YAAY,OAAO,SAAS,mBACjD,CAAC,GAAG,iBAAiB,CAAC,KAAK,KAAK,CAAC,uBACtD;AACD;;GAGF,MAAM,WAAW;GACjB,MAAM,gBAAgB,oBAAoB,SAAS;GAGnD,MAAM,eAAe,UAAU,IAAI,cAAc;AACjD,OAAI,cAAc;AAChB,YAAQ,KACN,iDAAiD,cAAc,eAChD,aAAa,OAAO,SAAS,2BAC7C;AACD;;AAGF,aAAU,IAAI,eAAe,SAAS;AACtC,eAAY,KAAK;IACf;IACA;IACA;IACD,CAAC;WACK,KAAK;AAEZ,WAAQ,KAAK,qCAAqC,SAAS,IAAI,IAAI;;;AAKzE,QAAO"}
|
package/dist/hydration.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as HydrationStrategy } from "./types-
|
|
2
|
-
import { n as WithHydrationStrategy, r as withHydration, t as HydrationMeta } from "./withHydration-
|
|
1
|
+
import { t as HydrationStrategy } from "./types-CVQNmPxF.mjs";
|
|
2
|
+
import { n as WithHydrationStrategy, r as withHydration, t as HydrationMeta } from "./withHydration-HIvO9ysY.mjs";
|
|
3
3
|
import { ComponentRegistry } from "./lib/hydration-script.mjs";
|
|
4
4
|
export { type ComponentRegistry, type HydrationMeta, type HydrationStrategy, type WithHydrationStrategy, withHydration };
|
package/dist/hydration.mjs
CHANGED