@hedystia/astro 2.2.1 → 2.2.3
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/server.cjs +6 -5
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +6 -5
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -11,8 +11,10 @@ async function check(Component, _props, _children) {
|
|
|
11
11
|
if (Component.name === "QwikComponent") return false;
|
|
12
12
|
if (Component.toString().includes("$$payload")) return false;
|
|
13
13
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const html = (0, _hedystia_view.renderToString)(Component(_props));
|
|
15
|
+
return typeof html === "string" && html.length > 0;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.error("[@hedystia/astro] check failed:", e);
|
|
16
18
|
return false;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -26,12 +28,11 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl
|
|
|
26
28
|
slots[name] = `<${tagName} name="${name}">${value}</${tagName}>`;
|
|
27
29
|
}
|
|
28
30
|
const childrenHtml = children != null ? `<${tagName}>${children}</${tagName}>` : void 0;
|
|
29
|
-
const
|
|
31
|
+
const componentHtml = (0, _hedystia_view.renderToString)(Component({
|
|
30
32
|
...props,
|
|
31
33
|
...slots,
|
|
32
34
|
children: childrenHtml
|
|
33
|
-
};
|
|
34
|
-
const componentHtml = (0, _hedystia_view.renderToString)(() => Component(newProps));
|
|
35
|
+
}));
|
|
35
36
|
return {
|
|
36
37
|
attrs: { "data-view-render-id": renderId },
|
|
37
38
|
html: componentHtml
|
package/dist/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["getContext","incrementId"],"sources":["../src/server.ts"],"sourcesContent":["import { renderToString } from \"@hedystia/view\";\nimport type { NamedSSRLoadedRendererValue } from \"astro\";\nimport { getContext, incrementId } from \"./context\";\nimport type { RendererContext } from \"./types\";\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\nasync function check(\n this: RendererContext,\n Component: any,\n _props: Record<string, any>,\n _children: any,\n) {\n if (typeof Component !== \"function\") {\n return false;\n }\n if (Component.name === \"QwikComponent\") {\n return false;\n }\n if (Component.toString().includes(\"$$payload\")) {\n return false;\n }\n\n try {\n const
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["getContext","incrementId"],"sources":["../src/server.ts"],"sourcesContent":["import { renderToString } from \"@hedystia/view\";\nimport type { NamedSSRLoadedRendererValue } from \"astro\";\nimport { getContext, incrementId } from \"./context\";\nimport type { RendererContext } from \"./types\";\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\nasync function check(\n this: RendererContext,\n Component: any,\n _props: Record<string, any>,\n _children: any,\n) {\n if (typeof Component !== \"function\") {\n return false;\n }\n if (Component.name === \"QwikComponent\") {\n return false;\n }\n if (Component.toString().includes(\"$$payload\")) {\n return false;\n }\n\n try {\n const result = Component(_props);\n const html = renderToString(result);\n return typeof html === \"string\" && html.length > 0;\n } catch (e) {\n console.error(\"[@hedystia/astro] check failed:\", e);\n return false;\n }\n}\n\nasync function renderToStaticMarkup(\n this: RendererContext,\n Component: any,\n props: Record<string, any>,\n { default: children, ...slotted }: any,\n metadata?: Record<string, any>,\n) {\n const ctx = getContext(this.result);\n const renderId = metadata?.hydrate ? incrementId(ctx) : \"\";\n const needsHydrate = metadata?.astroStaticSlot ? !!metadata.hydrate : true;\n const tagName = needsHydrate ? \"astro-slot\" : \"astro-static-slot\";\n\n const slots: Record<string, string> = {};\n for (const [key, value] of Object.entries(slotted)) {\n const name = slotName(key);\n slots[name] = `<${tagName} name=\"${name}\">${value}</${tagName}>`;\n }\n\n const childrenHtml = children != null ? `<${tagName}>${children}</${tagName}>` : undefined;\n\n const newProps = {\n ...props,\n ...slots,\n children: childrenHtml,\n };\n\n const componentHtml = renderToString(Component(newProps));\n\n return {\n attrs: {\n \"data-view-render-id\": renderId,\n },\n html: componentHtml,\n };\n}\n\nconst renderer: NamedSSRLoadedRendererValue = {\n name: \"@hedystia/astro\",\n check,\n renderToStaticMarkup,\n supportsAstroStaticSlot: true,\n};\n\nexport default renderer;\n"],"mappings":";;;;;;;AAKA,MAAM,YAAY,QAAgB,IAAI,MAAM,CAAC,QAAQ,iBAAiB,GAAG,MAAM,EAAE,aAAa,CAAC;AAE/F,eAAe,MAEb,WACA,QACA,WACA;AACA,KAAI,OAAO,cAAc,WACvB,QAAO;AAET,KAAI,UAAU,SAAS,gBACrB,QAAO;AAET,KAAI,UAAU,UAAU,CAAC,SAAS,YAAY,CAC5C,QAAO;AAGT,KAAI;EAEF,MAAM,QAAA,GAAA,eAAA,gBADS,UAAU,OAAO,CACG;AACnC,SAAO,OAAO,SAAS,YAAY,KAAK,SAAS;UAC1C,GAAG;AACV,UAAQ,MAAM,mCAAmC,EAAE;AACnD,SAAO;;;AAIX,eAAe,qBAEb,WACA,OACA,EAAE,SAAS,UAAU,GAAG,WACxB,UACA;CACA,MAAM,MAAMA,gBAAAA,WAAW,KAAK,OAAO;CACnC,MAAM,WAAW,UAAU,UAAUC,gBAAAA,YAAY,IAAI,GAAG;CAExD,MAAM,WADe,UAAU,kBAAkB,CAAC,CAAC,SAAS,UAAU,QACvC,eAAe;CAE9C,MAAM,QAAgC,EAAE;AACxC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,EAAE;EAClD,MAAM,OAAO,SAAS,IAAI;AAC1B,QAAM,QAAQ,IAAI,QAAQ,SAAS,KAAK,IAAI,MAAM,IAAI,QAAQ;;CAGhE,MAAM,eAAe,YAAY,OAAO,IAAI,QAAQ,GAAG,SAAS,IAAI,QAAQ,KAAK,KAAA;CAQjF,MAAM,iBAAA,GAAA,eAAA,gBAA+B,UANpB;EACf,GAAG;EACH,GAAG;EACH,UAAU;EACX,CAEuD,CAAC;AAEzD,QAAO;EACL,OAAO,EACL,uBAAuB,UACxB;EACD,MAAM;EACP;;AAGH,MAAM,WAAwC;CAC5C,MAAM;CACN;CACA;CACA,yBAAyB;CAC1B"}
|
package/dist/server.mjs
CHANGED
|
@@ -7,8 +7,10 @@ async function check(Component, _props, _children) {
|
|
|
7
7
|
if (Component.name === "QwikComponent") return false;
|
|
8
8
|
if (Component.toString().includes("$$payload")) return false;
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const html = renderToString(Component(_props));
|
|
11
|
+
return typeof html === "string" && html.length > 0;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error("[@hedystia/astro] check failed:", e);
|
|
12
14
|
return false;
|
|
13
15
|
}
|
|
14
16
|
}
|
|
@@ -22,12 +24,11 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl
|
|
|
22
24
|
slots[name] = `<${tagName} name="${name}">${value}</${tagName}>`;
|
|
23
25
|
}
|
|
24
26
|
const childrenHtml = children != null ? `<${tagName}>${children}</${tagName}>` : void 0;
|
|
25
|
-
const
|
|
27
|
+
const componentHtml = renderToString(Component({
|
|
26
28
|
...props,
|
|
27
29
|
...slots,
|
|
28
30
|
children: childrenHtml
|
|
29
|
-
};
|
|
30
|
-
const componentHtml = renderToString(() => Component(newProps));
|
|
31
|
+
}));
|
|
31
32
|
return {
|
|
32
33
|
attrs: { "data-view-render-id": renderId },
|
|
33
34
|
html: componentHtml
|
package/dist/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { renderToString } from \"@hedystia/view\";\nimport type { NamedSSRLoadedRendererValue } from \"astro\";\nimport { getContext, incrementId } from \"./context\";\nimport type { RendererContext } from \"./types\";\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\nasync function check(\n this: RendererContext,\n Component: any,\n _props: Record<string, any>,\n _children: any,\n) {\n if (typeof Component !== \"function\") {\n return false;\n }\n if (Component.name === \"QwikComponent\") {\n return false;\n }\n if (Component.toString().includes(\"$$payload\")) {\n return false;\n }\n\n try {\n const
|
|
1
|
+
{"version":3,"file":"server.mjs","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { renderToString } from \"@hedystia/view\";\nimport type { NamedSSRLoadedRendererValue } from \"astro\";\nimport { getContext, incrementId } from \"./context\";\nimport type { RendererContext } from \"./types\";\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\nasync function check(\n this: RendererContext,\n Component: any,\n _props: Record<string, any>,\n _children: any,\n) {\n if (typeof Component !== \"function\") {\n return false;\n }\n if (Component.name === \"QwikComponent\") {\n return false;\n }\n if (Component.toString().includes(\"$$payload\")) {\n return false;\n }\n\n try {\n const result = Component(_props);\n const html = renderToString(result);\n return typeof html === \"string\" && html.length > 0;\n } catch (e) {\n console.error(\"[@hedystia/astro] check failed:\", e);\n return false;\n }\n}\n\nasync function renderToStaticMarkup(\n this: RendererContext,\n Component: any,\n props: Record<string, any>,\n { default: children, ...slotted }: any,\n metadata?: Record<string, any>,\n) {\n const ctx = getContext(this.result);\n const renderId = metadata?.hydrate ? incrementId(ctx) : \"\";\n const needsHydrate = metadata?.astroStaticSlot ? !!metadata.hydrate : true;\n const tagName = needsHydrate ? \"astro-slot\" : \"astro-static-slot\";\n\n const slots: Record<string, string> = {};\n for (const [key, value] of Object.entries(slotted)) {\n const name = slotName(key);\n slots[name] = `<${tagName} name=\"${name}\">${value}</${tagName}>`;\n }\n\n const childrenHtml = children != null ? `<${tagName}>${children}</${tagName}>` : undefined;\n\n const newProps = {\n ...props,\n ...slots,\n children: childrenHtml,\n };\n\n const componentHtml = renderToString(Component(newProps));\n\n return {\n attrs: {\n \"data-view-render-id\": renderId,\n },\n html: componentHtml,\n };\n}\n\nconst renderer: NamedSSRLoadedRendererValue = {\n name: \"@hedystia/astro\",\n check,\n renderToStaticMarkup,\n supportsAstroStaticSlot: true,\n};\n\nexport default renderer;\n"],"mappings":";;;AAKA,MAAM,YAAY,QAAgB,IAAI,MAAM,CAAC,QAAQ,iBAAiB,GAAG,MAAM,EAAE,aAAa,CAAC;AAE/F,eAAe,MAEb,WACA,QACA,WACA;AACA,KAAI,OAAO,cAAc,WACvB,QAAO;AAET,KAAI,UAAU,SAAS,gBACrB,QAAO;AAET,KAAI,UAAU,UAAU,CAAC,SAAS,YAAY,CAC5C,QAAO;AAGT,KAAI;EAEF,MAAM,OAAO,eADE,UAAU,OAAO,CACG;AACnC,SAAO,OAAO,SAAS,YAAY,KAAK,SAAS;UAC1C,GAAG;AACV,UAAQ,MAAM,mCAAmC,EAAE;AACnD,SAAO;;;AAIX,eAAe,qBAEb,WACA,OACA,EAAE,SAAS,UAAU,GAAG,WACxB,UACA;CACA,MAAM,MAAM,WAAW,KAAK,OAAO;CACnC,MAAM,WAAW,UAAU,UAAU,YAAY,IAAI,GAAG;CAExD,MAAM,WADe,UAAU,kBAAkB,CAAC,CAAC,SAAS,UAAU,QACvC,eAAe;CAE9C,MAAM,QAAgC,EAAE;AACxC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,EAAE;EAClD,MAAM,OAAO,SAAS,IAAI;AAC1B,QAAM,QAAQ,IAAI,QAAQ,SAAS,KAAK,IAAI,MAAM,IAAI,QAAQ;;CAGhE,MAAM,eAAe,YAAY,OAAO,IAAI,QAAQ,GAAG,SAAS,IAAI,QAAQ,KAAK,KAAA;CAQjF,MAAM,gBAAgB,eAAe,UANpB;EACf,GAAG;EACH,GAAG;EACH,UAAU;EACX,CAEuD,CAAC;AAEzD,QAAO;EACL,OAAO,EACL,uBAAuB,UACxB;EACD,MAAM;EACP;;AAGH,MAAM,WAAwC;CAC5C,MAAM;CACN;CACA;CACA,yBAAyB;CAC1B"}
|