@hedystia/astro 2.3.8 → 2.3.17

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/client.cjs CHANGED
@@ -2,7 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- require("./_virtual/_rolldown/runtime.cjs");
6
5
  let _hedystia_view = require("@hedystia/view");
7
6
  //#region src/client.ts
8
7
  var client_default = (element) => (Component, props, slotted, { client }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { mount } from \"@hedystia/view\";\n\nexport default (element: HTMLElement) =>\n (Component: any, props: any, slotted: any, { client }: { client: string }) => {\n if (!element.hasAttribute(\"ssr\")) {\n return;\n }\n\n const _slots: Record<string, any> = {};\n let _slot: HTMLElement | null;\n\n if (Object.keys(slotted).length > 0) {\n if (client !== \"only\") {\n const iterator = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, (node) => {\n if (node === element) {\n return NodeFilter.FILTER_SKIP;\n }\n if (node.nodeName === \"ASTRO-SLOT\") {\n return NodeFilter.FILTER_ACCEPT;\n }\n if (node.nodeName === \"ASTRO-ISLAND\") {\n return NodeFilter.FILTER_REJECT;\n }\n return NodeFilter.FILTER_SKIP;\n });\n let slot: HTMLElement | null;\n\n while (true) {\n slot = iterator.nextNode() as HTMLElement | null;\n if (!slot) {\n break;\n }\n\n _slots[slot.getAttribute(\"name\") || \"default\"] = slot;\n }\n }\n for (const [key, value] of Object.entries(slotted)) {\n if (_slots[key]) {\n continue;\n }\n _slots[key] = document.createElement(\"astro-slot\");\n if (key !== \"default\") {\n _slots[key].setAttribute(\"name\", key);\n }\n _slots[key].innerHTML = value;\n }\n }\n\n const { default: children, ...slots } = _slots;\n\n element.innerHTML = \"\";\n\n const app = mount(() => Component({ ...props, ...slots, children }), element);\n\n element.addEventListener(\"astro:unmount\", () => app.dispose(), { once: true });\n };\n"],"mappings":";;;;;;;AAEA,IAAA,kBAAgB,aACb,WAAgB,OAAY,SAAc,EAAE,aAAiC;CAC5E,IAAI,CAAC,QAAQ,aAAa,KAAK,GAC7B;CAGF,MAAM,SAA8B,CAAC;CAGrC,IAAI,OAAO,KAAK,OAAO,EAAE,SAAS,GAAG;EACnC,IAAI,WAAW,QAAQ;GACrB,MAAM,WAAW,SAAS,iBAAiB,SAAS,WAAW,eAAe,SAAS;IACrF,IAAI,SAAS,SACX,OAAO,WAAW;IAEpB,IAAI,KAAK,aAAa,cACpB,OAAO,WAAW;IAEpB,IAAI,KAAK,aAAa,gBACpB,OAAO,WAAW;IAEpB,OAAO,WAAW;GACpB,CAAC;GACD,IAAI;GAEJ,OAAO,MAAM;IACX,OAAO,SAAS,SAAS;IACzB,IAAI,CAAC,MACH;IAGF,OAAO,KAAK,aAAa,MAAM,KAAK,aAAa;GACnD;EACF;EACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;GAClD,IAAI,OAAO,MACT;GAEF,OAAO,OAAO,SAAS,cAAc,YAAY;GACjD,IAAI,QAAQ,WACV,OAAO,KAAK,aAAa,QAAQ,GAAG;GAEtC,OAAO,KAAK,YAAY;EAC1B;CACF;CAEA,MAAM,EAAE,SAAS,UAAU,GAAG,UAAU;CAExC,QAAQ,YAAY;CAEpB,MAAM,OAAA,GAAA,eAAA,aAAkB,UAAU;EAAE,GAAG;EAAO,GAAG;EAAO;CAAS,CAAC,GAAG,OAAO;CAE5E,QAAQ,iBAAiB,uBAAuB,IAAI,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/E"}
1
+ {"version":3,"file":"client.cjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { mount } from \"@hedystia/view\";\n\nexport default (element: HTMLElement) =>\n (Component: any, props: any, slotted: any, { client }: { client: string }) => {\n if (!element.hasAttribute(\"ssr\")) {\n return;\n }\n\n const _slots: Record<string, any> = {};\n let _slot: HTMLElement | null;\n\n if (Object.keys(slotted).length > 0) {\n if (client !== \"only\") {\n const iterator = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, (node) => {\n if (node === element) {\n return NodeFilter.FILTER_SKIP;\n }\n if (node.nodeName === \"ASTRO-SLOT\") {\n return NodeFilter.FILTER_ACCEPT;\n }\n if (node.nodeName === \"ASTRO-ISLAND\") {\n return NodeFilter.FILTER_REJECT;\n }\n return NodeFilter.FILTER_SKIP;\n });\n let slot: HTMLElement | null;\n\n while (true) {\n slot = iterator.nextNode() as HTMLElement | null;\n if (!slot) {\n break;\n }\n\n _slots[slot.getAttribute(\"name\") || \"default\"] = slot;\n }\n }\n for (const [key, value] of Object.entries(slotted)) {\n if (_slots[key]) {\n continue;\n }\n _slots[key] = document.createElement(\"astro-slot\");\n if (key !== \"default\") {\n _slots[key].setAttribute(\"name\", key);\n }\n _slots[key].innerHTML = value;\n }\n }\n\n const { default: children, ...slots } = _slots;\n\n element.innerHTML = \"\";\n\n const app = mount(() => Component({ ...props, ...slots, children }), element);\n\n element.addEventListener(\"astro:unmount\", () => app.dispose(), { once: true });\n };\n"],"mappings":";;;;;;AAEA,IAAA,kBAAgB,aACb,WAAgB,OAAY,SAAc,EAAE,aAAiC;CAC5E,IAAI,CAAC,QAAQ,aAAa,KAAK,GAC7B;CAGF,MAAM,SAA8B,CAAC;CAGrC,IAAI,OAAO,KAAK,OAAO,EAAE,SAAS,GAAG;EACnC,IAAI,WAAW,QAAQ;GACrB,MAAM,WAAW,SAAS,iBAAiB,SAAS,WAAW,eAAe,SAAS;IACrF,IAAI,SAAS,SACX,OAAO,WAAW;IAEpB,IAAI,KAAK,aAAa,cACpB,OAAO,WAAW;IAEpB,IAAI,KAAK,aAAa,gBACpB,OAAO,WAAW;IAEpB,OAAO,WAAW;GACpB,CAAC;GACD,IAAI;GAEJ,OAAO,MAAM;IACX,OAAO,SAAS,SAAS;IACzB,IAAI,CAAC,MACH;IAGF,OAAO,KAAK,aAAa,MAAM,KAAK,aAAa;GACnD;EACF;EACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;GAClD,IAAI,OAAO,MACT;GAEF,OAAO,OAAO,SAAS,cAAc,YAAY;GACjD,IAAI,QAAQ,WACV,OAAO,KAAK,aAAa,QAAQ,GAAG;GAEtC,OAAO,KAAK,YAAY;EAC1B;CACF;CAEA,MAAM,EAAE,SAAS,UAAU,GAAG,UAAU;CAExC,QAAQ,YAAY;CAEpB,MAAM,OAAA,GAAA,eAAA,aAAkB,UAAU;EAAE,GAAG;EAAO,GAAG;EAAO;CAAS,CAAC,GAAG,OAAO;CAE5E,QAAQ,iBAAiB,uBAAuB,IAAI,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/E"}
package/dist/index.cjs CHANGED
@@ -38,7 +38,7 @@ function src_default(options = {}) {
38
38
  };
39
39
  }
40
40
  function injectCSSIntoHTML(dir, css) {
41
- const styleTag = `<style data-hedystia-css>${css}</style>`;
41
+ const styleTag = `<style data-hedystia-css">${css.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</style>`;
42
42
  for (const file of findHTMLFiles(dir)) {
43
43
  let content = node_fs.default.readFileSync(file, "utf-8");
44
44
  if (content.includes("data-hedystia-css")) continue;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["fs","path"],"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { viewPlugin } from \"@hedystia/view/vite\";\nimport type { AstroIntegration, AstroRenderer } from \"astro\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: \"@hedystia/astro\",\n clientEntrypoint: \"@hedystia/astro/client.js\",\n serverEntrypoint: \"@hedystia/astro/server.js\",\n };\n}\n\nexport { getRenderer as getContainerRenderer };\n\nexport interface Options {\n include?: string[];\n exclude?: string[];\n}\n\nexport default function (options: Options = {}): AstroIntegration {\n const { plugins, collectedCSS } = viewPlugin(options);\n\n return {\n name: \"@hedystia/astro\",\n hooks: {\n \"astro:config:setup\": async ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({\n vite: {\n plugins: [...plugins, configEnvironmentPlugin()],\n ssr: {\n noExternal: [\"@hedystia/view\"],\n },\n },\n });\n },\n \"astro:build:done\": async ({ dir }) => {\n if (collectedCSS.size > 0) {\n const css = Array.from(collectedCSS.values()).join(\"\\n\");\n injectCSSIntoHTML(dir.pathname, css);\n }\n },\n },\n };\n}\n\nfunction injectCSSIntoHTML(dir: string, css: string): void {\n const styleTag = `<style data-hedystia-css>${css}</style>`;\n\n for (const file of findHTMLFiles(dir)) {\n let content = fs.readFileSync(file, \"utf-8\");\n if (content.includes(\"data-hedystia-css\")) {\n continue;\n }\n if (content.includes(\"</head>\")) {\n content = content.replace(\"</head>\", `${styleTag}</head>`);\n } else {\n content = `${styleTag}${content}`;\n }\n fs.writeFileSync(file, content, \"utf-8\");\n }\n}\n\nfunction findHTMLFiles(dir: string): string[] {\n const files: string[] = [];\n const walk = (d: string) => {\n for (const entry of fs.readdirSync(d, { withFileTypes: true })) {\n const full = path.join(d, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n } else if (entry.name.endsWith(\".html\")) {\n files.push(full);\n }\n }\n };\n walk(dir);\n return files;\n}\n\nfunction configEnvironmentPlugin(): Plugin {\n return {\n name: \"@hedystia/astro:config-environment\",\n configEnvironment(environmentName: string): UserConfig | Promise<UserConfig> | undefined {\n return {\n optimizeDeps: {\n include: environmentName === \"client\" ? [\"@hedystia/astro/client.js\"] : [],\n exclude: [\"@hedystia/astro/server.js\"],\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAS,cAA6B;CACpC,OAAO;EACL,MAAM;EACN,kBAAkB;EAClB,kBAAkB;CACpB;AACF;AASA,SAAA,YAAyB,UAAmB,CAAC,GAAqB;CAChE,MAAM,EAAE,SAAS,kBAAA,GAAA,oBAAA,YAA4B,OAAO;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c;IACZ,SAAS,oBAAoB,WAAW,CAAC,2BAA2B,IAAI,CAAC;IACzE,SAAS,CAAC,2BAA2B;GACvC,EACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["fs","path"],"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { viewPlugin } from \"@hedystia/view/vite\";\nimport type { AstroIntegration, AstroRenderer } from \"astro\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: \"@hedystia/astro\",\n clientEntrypoint: \"@hedystia/astro/client.js\",\n serverEntrypoint: \"@hedystia/astro/server.js\",\n };\n}\n\nexport { getRenderer as getContainerRenderer };\n\nexport interface Options {\n include?: string[];\n exclude?: string[];\n}\n\nexport default function (options: Options = {}): AstroIntegration {\n const { plugins, collectedCSS } = viewPlugin(options);\n\n return {\n name: \"@hedystia/astro\",\n hooks: {\n \"astro:config:setup\": async ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({\n vite: {\n plugins: [...plugins, configEnvironmentPlugin()],\n ssr: {\n noExternal: [\"@hedystia/view\"],\n },\n },\n });\n },\n \"astro:build:done\": async ({ dir }) => {\n if (collectedCSS.size > 0) {\n const css = Array.from(collectedCSS.values()).join(\"\\n\");\n injectCSSIntoHTML(dir.pathname, css);\n }\n },\n },\n };\n}\n\nfunction injectCSSIntoHTML(dir: string, css: string): void {\n const styleTag = `<style data-hedystia-css\">${css.replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\")}</style>`;\n\n for (const file of findHTMLFiles(dir)) {\n let content = fs.readFileSync(file, \"utf-8\");\n if (content.includes(\"data-hedystia-css\")) {\n continue;\n }\n if (content.includes(\"</head>\")) {\n content = content.replace(\"</head>\", `${styleTag}</head>`);\n } else {\n content = `${styleTag}${content}`;\n }\n fs.writeFileSync(file, content, \"utf-8\");\n }\n}\n\nfunction findHTMLFiles(dir: string): string[] {\n const files: string[] = [];\n const walk = (d: string) => {\n for (const entry of fs.readdirSync(d, { withFileTypes: true })) {\n const full = path.join(d, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n } else if (entry.name.endsWith(\".html\")) {\n files.push(full);\n }\n }\n };\n walk(dir);\n return files;\n}\n\nfunction configEnvironmentPlugin(): Plugin {\n return {\n name: \"@hedystia/astro:config-environment\",\n configEnvironment(environmentName: string): UserConfig | Promise<UserConfig> | undefined {\n return {\n optimizeDeps: {\n include: environmentName === \"client\" ? [\"@hedystia/astro/client.js\"] : [],\n exclude: [\"@hedystia/astro/server.js\"],\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAS,cAA6B;CACpC,OAAO;EACL,MAAM;EACN,kBAAkB;EAClB,kBAAkB;CACpB;AACF;AASA,SAAA,YAAyB,UAAmB,CAAC,GAAqB;CAChE,MAAM,EAAE,SAAS,kBAAA,GAAA,oBAAA,YAA4B,OAAO;CAEpD,OAAO;EACL,MAAM;EACN,OAAO;GACL,sBAAsB,OAAO,EAAE,aAAa,mBAAmB;IAC7D,YAAY,YAAY,CAAC;IACzB,aAAa,EACX,MAAM;KACJ,SAAS,CAAC,GAAG,SAAS,wBAAwB,CAAC;KAC/C,KAAK,EACH,YAAY,CAAC,gBAAgB,EAC/B;IACF,EACF,CAAC;GACH;GACA,oBAAoB,OAAO,EAAE,UAAU;IACrC,IAAI,aAAa,OAAO,GAAG;KACzB,MAAM,MAAM,MAAM,KAAK,aAAa,OAAO,CAAC,EAAE,KAAK,IAAI;KACvD,kBAAkB,IAAI,UAAU,GAAG;IACrC;GACF;EACF;CACF;AACF;AAEA,SAAS,kBAAkB,KAAa,KAAmB;CACzD,MAAM,WAAW,6BAA6B,IAAI,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM,EAAE;CAE9F,KAAK,MAAM,QAAQ,cAAc,GAAG,GAAG;EACrC,IAAI,UAAUA,QAAAA,QAAG,aAAa,MAAM,OAAO;EAC3C,IAAI,QAAQ,SAAS,mBAAmB,GACtC;EAEF,IAAI,QAAQ,SAAS,SAAS,GAC5B,UAAU,QAAQ,QAAQ,WAAW,GAAG,SAAS,QAAQ;OAEzD,UAAU,GAAG,WAAW;EAE1B,QAAA,QAAG,cAAc,MAAM,SAAS,OAAO;CACzC;AACF;AAEA,SAAS,cAAc,KAAuB;CAC5C,MAAM,QAAkB,CAAC;CACzB,MAAM,QAAQ,MAAc;EAC1B,KAAK,MAAM,SAASA,QAAAA,QAAG,YAAY,GAAG,EAAE,eAAe,KAAK,CAAC,GAAG;GAC9D,MAAM,OAAOC,UAAAA,QAAK,KAAK,GAAG,MAAM,IAAI;GACpC,IAAI,MAAM,YAAY,GACpB,KAAK,IAAI;QACJ,IAAI,MAAM,KAAK,SAAS,OAAO,GACpC,MAAM,KAAK,IAAI;EAEnB;CACF;CACA,KAAK,GAAG;CACR,OAAO;AACT;AAEA,SAAS,0BAAkC;CACzC,OAAO;EACL,MAAM;EACN,kBAAkB,iBAAuE;GACvF,OAAO,EACL,cAAc;IACZ,SAAS,oBAAoB,WAAW,CAAC,2BAA2B,IAAI,CAAC;IACzE,SAAS,CAAC,2BAA2B;GACvC,EACF;EACF;CACF;AACF"}
package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ function src_default(options = {}) {
31
31
  };
32
32
  }
33
33
  function injectCSSIntoHTML(dir, css) {
34
- const styleTag = `<style data-hedystia-css>${css}</style>`;
34
+ const styleTag = `<style data-hedystia-css">${css.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</style>`;
35
35
  for (const file of findHTMLFiles(dir)) {
36
36
  let content = fs.readFileSync(file, "utf-8");
37
37
  if (content.includes("data-hedystia-css")) continue;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { viewPlugin } from \"@hedystia/view/vite\";\nimport type { AstroIntegration, AstroRenderer } from \"astro\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: \"@hedystia/astro\",\n clientEntrypoint: \"@hedystia/astro/client.js\",\n serverEntrypoint: \"@hedystia/astro/server.js\",\n };\n}\n\nexport { getRenderer as getContainerRenderer };\n\nexport interface Options {\n include?: string[];\n exclude?: string[];\n}\n\nexport default function (options: Options = {}): AstroIntegration {\n const { plugins, collectedCSS } = viewPlugin(options);\n\n return {\n name: \"@hedystia/astro\",\n hooks: {\n \"astro:config:setup\": async ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({\n vite: {\n plugins: [...plugins, configEnvironmentPlugin()],\n ssr: {\n noExternal: [\"@hedystia/view\"],\n },\n },\n });\n },\n \"astro:build:done\": async ({ dir }) => {\n if (collectedCSS.size > 0) {\n const css = Array.from(collectedCSS.values()).join(\"\\n\");\n injectCSSIntoHTML(dir.pathname, css);\n }\n },\n },\n };\n}\n\nfunction injectCSSIntoHTML(dir: string, css: string): void {\n const styleTag = `<style data-hedystia-css>${css}</style>`;\n\n for (const file of findHTMLFiles(dir)) {\n let content = fs.readFileSync(file, \"utf-8\");\n if (content.includes(\"data-hedystia-css\")) {\n continue;\n }\n if (content.includes(\"</head>\")) {\n content = content.replace(\"</head>\", `${styleTag}</head>`);\n } else {\n content = `${styleTag}${content}`;\n }\n fs.writeFileSync(file, content, \"utf-8\");\n }\n}\n\nfunction findHTMLFiles(dir: string): string[] {\n const files: string[] = [];\n const walk = (d: string) => {\n for (const entry of fs.readdirSync(d, { withFileTypes: true })) {\n const full = path.join(d, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n } else if (entry.name.endsWith(\".html\")) {\n files.push(full);\n }\n }\n };\n walk(dir);\n return files;\n}\n\nfunction configEnvironmentPlugin(): Plugin {\n return {\n name: \"@hedystia/astro:config-environment\",\n configEnvironment(environmentName: string): UserConfig | Promise<UserConfig> | undefined {\n return {\n optimizeDeps: {\n include: environmentName === \"client\" ? [\"@hedystia/astro/client.js\"] : [],\n exclude: [\"@hed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AI,MAAM,KAAK,SAAS,OAAO,GACpC,MAAM,KAAK,IAAI;EAEnB;CACF;CACA,KAAK,GAAG;CACR,OAAO;AACT;AAEA,SAAS,0BAAkC;CACzC,OAAO;EACL,MAAM;EACN,kBAAkB,iBAAuE;GACvF,OAAO,EACL,cAAc;IACZ,SAAS,oBAAoB,WAAW,CAAC,2BAA2B,IAAI,CAAC;IACzE,SAAS,CAAC,2BAA2B;GACvC,EACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { viewPlugin } from \"@hedystia/view/vite\";\nimport type { AstroIntegration, AstroRenderer } from \"astro\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: \"@hedystia/astro\",\n clientEntrypoint: \"@hedystia/astro/client.js\",\n serverEntrypoint: \"@hedystia/astro/server.js\",\n };\n}\n\nexport { getRenderer as getContainerRenderer };\n\nexport interface Options {\n include?: string[];\n exclude?: string[];\n}\n\nexport default function (options: Options = {}): AstroIntegration {\n const { plugins, collectedCSS } = viewPlugin(options);\n\n return {\n name: \"@hedystia/astro\",\n hooks: {\n \"astro:config:setup\": async ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({\n vite: {\n plugins: [...plugins, configEnvironmentPlugin()],\n ssr: {\n noExternal: [\"@hedystia/view\"],\n },\n },\n });\n },\n \"astro:build:done\": async ({ dir }) => {\n if (collectedCSS.size > 0) {\n const css = Array.from(collectedCSS.values()).join(\"\\n\");\n injectCSSIntoHTML(dir.pathname, css);\n }\n },\n },\n };\n}\n\nfunction injectCSSIntoHTML(dir: string, css: string): void {\n const styleTag = `<style data-hedystia-css\">${css.replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\")}</style>`;\n\n for (const file of findHTMLFiles(dir)) {\n let content = fs.readFileSync(file, \"utf-8\");\n if (content.includes(\"data-hedystia-css\")) {\n continue;\n }\n if (content.includes(\"</head>\")) {\n content = content.replace(\"</head>\", `${styleTag}</head>`);\n } else {\n content = `${styleTag}${content}`;\n }\n fs.writeFileSync(file, content, \"utf-8\");\n }\n}\n\nfunction findHTMLFiles(dir: string): string[] {\n const files: string[] = [];\n const walk = (d: string) => {\n for (const entry of fs.readdirSync(d, { withFileTypes: true })) {\n const full = path.join(d, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n } else if (entry.name.endsWith(\".html\")) {\n files.push(full);\n }\n }\n };\n walk(dir);\n return files;\n}\n\nfunction configEnvironmentPlugin(): Plugin {\n return {\n name: \"@hedystia/astro:config-environment\",\n configEnvironment(environmentName: string): UserConfig | Promise<UserConfig> | undefined {\n return {\n optimizeDeps: {\n include: environmentName === \"client\" ? [\"@hedystia/astro/client.js\"] : [],\n exclude: [\"@hedystia/astro/server.js\"],\n },\n };\n },\n };\n}\n"],"mappings":";;;;AAMA,SAAS,cAA6B;CACpC,OAAO;EACL,MAAM;EACN,kBAAkB;EAClB,kBAAkB;CACpB;AACF;AASA,SAAA,YAAyB,UAAmB,CAAC,GAAqB;CAChE,MAAM,EAAE,SAAS,iBAAiB,WAAW,OAAO;CAEpD,OAAO;EACL,MAAM;EACN,OAAO;GACL,sBAAsB,OAAO,EAAE,aAAa,mBAAmB;IAC7D,YAAY,YAAY,CAAC;IACzB,aAAa,EACX,MAAM;KACJ,SAAS,CAAC,GAAG,SAAS,wBAAwB,CAAC;KAC/C,KAAK,EACH,YAAY,CAAC,gBAAgB,EAC/B;IACF,EACF,CAAC;GACH;GACA,oBAAoB,OAAO,EAAE,UAAU;IACrC,IAAI,aAAa,OAAO,GAAG;KACzB,MAAM,MAAM,MAAM,KAAK,aAAa,OAAO,CAAC,EAAE,KAAK,IAAI;KACvD,kBAAkB,IAAI,UAAU,GAAG;IACrC;GACF;EACF;CACF;AACF;AAEA,SAAS,kBAAkB,KAAa,KAAmB;CACzD,MAAM,WAAW,6BAA6B,IAAI,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM,EAAE;CAE9F,KAAK,MAAM,QAAQ,cAAc,GAAG,GAAG;EACrC,IAAI,UAAU,GAAG,aAAa,MAAM,OAAO;EAC3C,IAAI,QAAQ,SAAS,mBAAmB,GACtC;EAEF,IAAI,QAAQ,SAAS,SAAS,GAC5B,UAAU,QAAQ,QAAQ,WAAW,GAAG,SAAS,QAAQ;OAEzD,UAAU,GAAG,WAAW;EAE1B,GAAG,cAAc,MAAM,SAAS,OAAO;CACzC;AACF;AAEA,SAAS,cAAc,KAAuB;CAC5C,MAAM,QAAkB,CAAC;CACzB,MAAM,QAAQ,MAAc;EAC1B,KAAK,MAAM,SAAS,GAAG,YAAY,GAAG,EAAE,eAAe,KAAK,CAAC,GAAG;GAC9D,MAAM,OAAO,KAAK,KAAK,GAAG,MAAM,IAAI;GACpC,IAAI,MAAM,YAAY,GACpB,KAAK,IAAI;QACJ,IAAI,MAAM,KAAK,SAAS,OAAO,GACpC,MAAM,KAAK,IAAI;EAEnB;CACF;CACA,KAAK,GAAG;CACR,OAAO;AACT;AAEA,SAAS,0BAAkC;CACzC,OAAO;EACL,MAAM;EACN,kBAAkB,iBAAuE;GACvF,OAAO,EACL,cAAc;IACZ,SAAS,oBAAoB,WAAW,CAAC,2BAA2B,IAAI,CAAC;IACzE,SAAS,CAAC,2BAA2B;GACvC,EACF;EACF;CACF;AACF"}
package/dist/server.cjs CHANGED
@@ -2,7 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- require("./_virtual/_rolldown/runtime.cjs");
6
5
  const require_context = require("./context.cjs");
7
6
  let _hedystia_view = require("@hedystia/view");
8
7
  //#region src/server.ts
@@ -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 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,KAAK,EAAE,QAAQ,iBAAiB,GAAG,MAAM,EAAE,YAAY,CAAC;AAE9F,eAAe,MAEb,WACA,QACA,WACA;CACA,IAAI,OAAO,cAAc,YACvB,OAAO;CAET,IAAI,UAAU,SAAS,iBACrB,OAAO;CAET,IAAI,UAAU,SAAS,EAAE,SAAS,WAAW,GAC3C,OAAO;CAGT,IAAI;EAEF,MAAM,QAAA,GAAA,eAAA,gBADS,UAAU,MACQ,CAAC;EAClC,OAAO,OAAO,SAAS,YAAY,KAAK,SAAS;CACnD,SAAS,GAAG;EACV,QAAQ,MAAM,mCAAmC,CAAC;EAClD,OAAO;CACT;AACF;AAEA,eAAe,qBAEb,WACA,OACA,EAAE,SAAS,UAAU,GAAG,WACxB,UACA;CACA,MAAM,MAAMA,gBAAAA,WAAW,KAAK,MAAM;CAClC,MAAM,WAAW,UAAU,UAAUC,gBAAAA,YAAY,GAAG,IAAI;CAExD,MAAM,WADe,UAAU,kBAAkB,CAAC,CAAC,SAAS,UAAU,QACvC,eAAe;CAE9C,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;EAClD,MAAM,OAAO,SAAS,GAAG;EACzB,MAAM,QAAQ,IAAI,QAAQ,SAAS,KAAK,IAAI,MAAM,IAAI,QAAQ;CAChE;CAEA,MAAM,eAAe,YAAY,OAAO,IAAI,QAAQ,GAAG,SAAS,IAAI,QAAQ,KAAK,KAAA;CAQjF,MAAM,iBAAA,GAAA,eAAA,gBAA+B,UAAU;EAL7C,GAAG;EACH,GAAG;EACH,UAAU;CAG0C,CAAC,CAAC;CAExD,OAAO;EACL,OAAO,EACL,uBAAuB,SACzB;EACA,MAAM;CACR;AACF;AAEA,MAAM,WAAwC;CAC5C,MAAM;CACN;CACA;CACA,yBAAyB;AAC3B"}
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,KAAK,EAAE,QAAQ,iBAAiB,GAAG,MAAM,EAAE,YAAY,CAAC;AAE9F,eAAe,MAEb,WACA,QACA,WACA;CACA,IAAI,OAAO,cAAc,YACvB,OAAO;CAET,IAAI,UAAU,SAAS,iBACrB,OAAO;CAET,IAAI,UAAU,SAAS,EAAE,SAAS,WAAW,GAC3C,OAAO;CAGT,IAAI;EAEF,MAAM,QAAA,GAAA,eAAA,gBADS,UAAU,MACQ,CAAC;EAClC,OAAO,OAAO,SAAS,YAAY,KAAK,SAAS;CACnD,SAAS,GAAG;EACV,QAAQ,MAAM,mCAAmC,CAAC;EAClD,OAAO;CACT;AACF;AAEA,eAAe,qBAEb,WACA,OACA,EAAE,SAAS,UAAU,GAAG,WACxB,UACA;CACA,MAAM,MAAMA,gBAAAA,WAAW,KAAK,MAAM;CAClC,MAAM,WAAW,UAAU,UAAUC,gBAAAA,YAAY,GAAG,IAAI;CAExD,MAAM,WADe,UAAU,kBAAkB,CAAC,CAAC,SAAS,UAAU,QACvC,eAAe;CAE9C,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;EAClD,MAAM,OAAO,SAAS,GAAG;EACzB,MAAM,QAAQ,IAAI,QAAQ,SAAS,KAAK,IAAI,MAAM,IAAI,QAAQ;CAChE;CAEA,MAAM,eAAe,YAAY,OAAO,IAAI,QAAQ,GAAG,SAAS,IAAI,QAAQ,KAAK,KAAA;CAQjF,MAAM,iBAAA,GAAA,eAAA,gBAA+B,UAAU;EAL7C,GAAG;EACH,GAAG;EACH,UAAU;CAG0C,CAAC,CAAC;CAExD,OAAO;EACL,OAAO,EACL,uBAAuB,SACzB;EACA,MAAM;CACR;AACF;AAEA,MAAM,WAAwC;CAC5C,MAAM;CACN;CACA;CACA,yBAAyB;AAC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedystia/astro",
3
- "version": "2.3.8",
3
+ "version": "2.3.17",
4
4
  "description": "Use @hedystia/view components within Astro",
5
5
  "homepage": "https://docs.hedystia.com",
6
6
  "private": false,
@@ -36,12 +36,11 @@
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsdown --config-loader unrun",
39
- "release:pkg": "bun publish --provenance --access public",
40
39
  "dev": "tsdown --watch"
41
40
  },
42
41
  "devDependencies": {
43
- "@types/bun": "^1.3.11",
44
- "typescript": "6.0.2"
42
+ "@types/bun": "catalog:",
43
+ "typescript": "catalog:"
45
44
  },
46
45
  "peerDependencies": {
47
46
  "@hedystia/view": ">= 2.0.0",