@hedystia/astro 2.2.1 → 2.2.2

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 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
- return typeof (0, _hedystia_view.renderToString)(() => Component(_props)) === "string";
15
- } catch {
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 newProps = {
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
@@ -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 html = renderToString(() => Component(_props));\n return typeof html === \"string\";\n } catch {\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;AAEF,SAAO,QAAA,GAAA,eAAA,sBAD2B,UAAU,OAAO,CAAC,KAC7B;SACjB;AACN,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;CAEjF,MAAM,WAAW;EACf,GAAG;EACH,GAAG;EACH,UAAU;EACX;CAED,MAAM,iBAAA,GAAA,eAAA,sBAAqC,UAAU,SAAS,CAAC;AAE/D,QAAO;EACL,OAAO,EACL,uBAAuB,UACxB;EACD,MAAM;EACP;;AAGH,MAAM,WAAwC;CAC5C,MAAM;CACN;CACA;CACA,yBAAyB;CAC1B"}
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
- return typeof renderToString(() => Component(_props)) === "string";
11
- } catch {
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 newProps = {
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
@@ -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 html = renderToString(() => Component(_props));\n return typeof html === \"string\";\n } catch {\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;AAEF,SAAO,OADM,qBAAqB,UAAU,OAAO,CAAC,KAC7B;SACjB;AACN,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;CAEjF,MAAM,WAAW;EACf,GAAG;EACH,GAAG;EACH,UAAU;EACX;CAED,MAAM,gBAAgB,qBAAqB,UAAU,SAAS,CAAC;AAE/D,QAAO;EACL,OAAO,EACL,uBAAuB,UACxB;EACD,MAAM;EACP;;AAGH,MAAM,WAAwC;CAC5C,MAAM;CACN;CACA;CACA,yBAAyB;CAC1B"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedystia/astro",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Use @hedystia/view components within Astro",
5
5
  "homepage": "https://docs.hedystia.com",
6
6
  "private": false,