defuss-astro 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.cjs CHANGED
@@ -1,13 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var client$1 = require('defuss/client');
4
- var defuss = require('defuss');
5
4
  var render = require('./render-DkMOLcUd.cjs');
5
+ require('defuss');
6
6
 
7
7
  var client = (element) => async (Component, props, { default: children, ...slotted }, { client }) => {
8
8
  console.log("client render", client);
9
9
  if (!element.hasAttribute("ssr")) return;
10
- globalThis.jsx = defuss.jsx;
11
10
  Object.entries(slotted).forEach(([key, value]) => {
12
11
  props[key] = render.StaticHtml(value);
13
12
  });
@@ -23,7 +22,12 @@ var client = (element) => async (Component, props, { default: children, ...slott
23
22
  }
24
23
  componentProps.children = children;
25
24
  }
26
- const dom = client$1.render(Component(componentProps), element);
25
+ const vdom = Component(componentProps);
26
+ console.log("if element", element, "has children, DIFF (hydrate) the vdom sub-tree");
27
+ if (element.hasChildNodes()) {
28
+ console.log("hydrate the vdom sub-tree!");
29
+ }
30
+ const dom = client$1.render(vdom, element);
27
31
  for (const [key, value] of Object.entries(props)) {
28
32
  if (key !== "children") {
29
33
  dom.setAttribute(key, value);
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { jsx } from 'defuss'\nimport { StaticHtml } from './render.js';\n\n// TODO: is a differential update possible?\n\nexport default (element: HTMLElement) =>\n\tasync (\n\t\tComponent: any,\n\t\tprops: Record<string, any>,\n\t\t{ default: children, ...slotted }: Record<string, any>,\n\t\t{ client }: Record<string, string>,\n\t) => {\n\n\t\tconsole.log('client render', client);\n\t\t\n\t\tif (!element.hasAttribute('ssr')) return;\n\n\t\t// we use \"classic\" runtime, so we need to set the global jsx function\n\t\t// otherwise it would need to be imported in every component\n\t\t(globalThis as any).jsx = jsx;\n\n\t\tObject.entries(slotted).forEach(([key, value]) => {\n\t\t\tprops[key] = StaticHtml(value);\n\t\t});\n\n\t\t// traverse the props object and create a new object with the same values\n\t\tconst componentProps: Props = { ...props };\n\n\t\t// children is a special prop that contains the children of the component\n\t\tif (children) {\n\t\t\t// all children are passed as an array\n\t\t\tif (!Array.isArray(children)) {\n\t\t\t\tchildren = [children];\n\t\t\t} \n\n\t\t\tfor (let i=0; i<children.length; i++) {\n\t\t\t\tif (typeof children[i] === 'string') {\n\t\t\t\t\t// turn static HTML into a component\n\t\t\t\t\tchildren[i] = StaticHtml(children[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomponentProps.children = children;\n\t\t}\n\n\t\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\t\tconst dom: HTMLElement = render(Component(componentProps), element) as HTMLElement;\n\n\t\t// set all props as top level attributes\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (key !== 'children') {\n\t\t\t\tdom.setAttribute(key, value);\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener('astro:unmount', () => {\n\t\t\t// remove the rendered component from the DOM\n\t\t\tif (dom.parentNode) {\n\t\t\t\tdom.parentNode.removeChild(dom);\n\t\t\t}\n }, { once: true });\n\t};"],"names":["jsx","StaticHtml","render"],"mappings":";;;;;;AAIA,aAAe,CAAC,OAAO,KAAK,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK;AACvG,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC;AACtC,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;AACpC,EAAE,UAAU,CAAC,GAAG,GAAGA,UAAG;AACtB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AACpD,IAAI,KAAK,CAAC,GAAG,CAAC,GAAGC,iBAAU,CAAC,KAAK,CAAC;AAClC,GAAG,CAAC;AACJ,EAAE,MAAM,cAAc,GAAG,EAAE,GAAG,KAAK,EAAE;AACrC,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAClC,MAAM,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAC3B;AACA,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC9C,MAAM,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;AAC3C,QAAQ,QAAQ,CAAC,CAAC,CAAC,GAAGA,iBAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC7C;AACA;AACA,IAAI,cAAc,CAAC,QAAQ,GAAG,QAAQ;AACtC;AACA,EAAE,MAAM,GAAG,GAAGC,eAAM,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;AACxD,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACpD,IAAI,IAAI,GAAG,KAAK,UAAU,EAAE;AAC5B,MAAM,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC;AAClC;AACA;AACA,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM;AAClD,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE;AACxB,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;AACrC;AACA,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACpB,CAAC;;;;"}
1
+ {"version":3,"file":"client.cjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { StaticHtml } from './render.js';\n\n// TODO: is a differential update possible?\n\nexport default (element: HTMLElement) =>\n\tasync (\n\t\tComponent: any,\n\t\tprops: Record<string, any>,\n\t\t{ default: children, ...slotted }: Record<string, any>,\n\t\t{ client }: Record<string, string>,\n\t) => {\n\n\t\tconsole.log('client render', client);\n\t\t\n\t\tif (!element.hasAttribute('ssr')) return;\n\n\t\t// <slot> mechanics\n\t\tObject.entries(slotted).forEach(([key, value]) => {\n\t\t\tprops[key] = StaticHtml(value);\n\t\t});\n\n\t\t// traverse the props object and create a new object with the same values\n\t\tconst componentProps: Props = { ...props };\n\n\t\t// children is a special prop that contains the children of the component\n\t\tif (children) {\n\t\t\t// all children are passed as an array\n\t\t\tif (!Array.isArray(children)) {\n\t\t\t\tchildren = [children];\n\t\t\t} \n\n\t\t\tfor (let i=0; i<children.length; i++) {\n\t\t\t\tif (typeof children[i] === 'string') {\n\t\t\t\t\t// turn static HTML into a component\n\t\t\t\t\tchildren[i] = StaticHtml(children[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomponentProps.children = children;\n\t\t}\n\n\t\tconst vdom = Component(componentProps);\n\t\tconsole.log(\"if element\", element, \"has children, DIFF (hydrate) the vdom sub-tree\")\n\n\t\tif (element.hasChildNodes()) {\n\t\t\t// hydrate the vdom sub-tree\n\t\t\tconsole.log(\"hydrate the vdom sub-tree!\",)\n\t\t}\n\n\t\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\t\tconst dom: HTMLElement = render(vdom, element) as HTMLElement;\n\n\t\t// set all props as top level attributes\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (key !== 'children') {\n\t\t\t\tdom.setAttribute(key, value);\n\t\t\t}\n\t\t}\n\n\n\t\telement.addEventListener('astro:unmount', () => {\n\t\t\t// remove the rendered component from the DOM\n\t\t\tif (dom.parentNode) {\n\t\t\t\tdom.parentNode.removeChild(dom);\n\t\t\t}\n }, { once: true });\n\t};"],"names":["StaticHtml","render"],"mappings":";;;;;;AAGA,aAAe,CAAC,OAAO,KAAK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CAAC,IAAI,EAAE,OAAO,CAAC;AACnC,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACpD,IAAI,IAAI,GAAG,KAAK,UAAU,EAAE;AAC5B,MAAM,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC;AAClC;AACA;AACA,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM;AAClD,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE;AACxB,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;AACrC;AACA,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACpB,CAAC;;;;"}
package/dist/client.mjs CHANGED
@@ -1,11 +1,10 @@
1
1
  import { render } from 'defuss/client';
2
- import { jsx } from 'defuss';
3
2
  import { S as StaticHtml } from './render-viAgneG-.mjs';
3
+ import 'defuss';
4
4
 
5
5
  var client = (element) => async (Component, props, { default: children, ...slotted }, { client }) => {
6
6
  console.log("client render", client);
7
7
  if (!element.hasAttribute("ssr")) return;
8
- globalThis.jsx = jsx;
9
8
  Object.entries(slotted).forEach(([key, value]) => {
10
9
  props[key] = StaticHtml(value);
11
10
  });
@@ -21,7 +20,12 @@ var client = (element) => async (Component, props, { default: children, ...slott
21
20
  }
22
21
  componentProps.children = children;
23
22
  }
24
- const dom = render(Component(componentProps), element);
23
+ const vdom = Component(componentProps);
24
+ console.log("if element", element, "has children, DIFF (hydrate) the vdom sub-tree");
25
+ if (element.hasChildNodes()) {
26
+ console.log("hydrate the vdom sub-tree!");
27
+ }
28
+ const dom = render(vdom, element);
25
29
  for (const [key, value] of Object.entries(props)) {
26
30
  if (key !== "children") {
27
31
  dom.setAttribute(key, value);
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { jsx } from 'defuss'\nimport { StaticHtml } from './render.js';\n\n// TODO: is a differential update possible?\n\nexport default (element: HTMLElement) =>\n\tasync (\n\t\tComponent: any,\n\t\tprops: Record<string, any>,\n\t\t{ default: children, ...slotted }: Record<string, any>,\n\t\t{ client }: Record<string, string>,\n\t) => {\n\n\t\tconsole.log('client render', client);\n\t\t\n\t\tif (!element.hasAttribute('ssr')) return;\n\n\t\t// we use \"classic\" runtime, so we need to set the global jsx function\n\t\t// otherwise it would need to be imported in every component\n\t\t(globalThis as any).jsx = jsx;\n\n\t\tObject.entries(slotted).forEach(([key, value]) => {\n\t\t\tprops[key] = StaticHtml(value);\n\t\t});\n\n\t\t// traverse the props object and create a new object with the same values\n\t\tconst componentProps: Props = { ...props };\n\n\t\t// children is a special prop that contains the children of the component\n\t\tif (children) {\n\t\t\t// all children are passed as an array\n\t\t\tif (!Array.isArray(children)) {\n\t\t\t\tchildren = [children];\n\t\t\t} \n\n\t\t\tfor (let i=0; i<children.length; i++) {\n\t\t\t\tif (typeof children[i] === 'string') {\n\t\t\t\t\t// turn static HTML into a component\n\t\t\t\t\tchildren[i] = StaticHtml(children[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomponentProps.children = children;\n\t\t}\n\n\t\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\t\tconst dom: HTMLElement = render(Component(componentProps), element) as HTMLElement;\n\n\t\t// set all props as top level attributes\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (key !== 'children') {\n\t\t\t\tdom.setAttribute(key, value);\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener('astro:unmount', () => {\n\t\t\t// remove the rendered component from the DOM\n\t\t\tif (dom.parentNode) {\n\t\t\t\tdom.parentNode.removeChild(dom);\n\t\t\t}\n }, { once: true });\n\t};"],"names":[],"mappings":";;;;AAIA,aAAe,CAAC,OAAO,KAAK,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,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C,gBAAgB,CAAC,eAAe,EAAE,MAAM;AAClD,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE;AACxB,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;AACrC;AACA,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACpB,CAAC;;;;"}
1
+ {"version":3,"file":"client.mjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { StaticHtml } from './render.js';\n\n// TODO: is a differential update possible?\n\nexport default (element: HTMLElement) =>\n\tasync (\n\t\tComponent: any,\n\t\tprops: Record<string, any>,\n\t\t{ default: children, ...slotted }: Record<string, any>,\n\t\t{ client }: Record<string, string>,\n\t) => {\n\n\t\tconsole.log('client render', client);\n\t\t\n\t\tif (!element.hasAttribute('ssr')) return;\n\n\t\t// <slot> mechanics\n\t\tObject.entries(slotted).forEach(([key, value]) => {\n\t\t\tprops[key] = StaticHtml(value);\n\t\t});\n\n\t\t// traverse the props object and create a new object with the same values\n\t\tconst componentProps: Props = { ...props };\n\n\t\t// children is a special prop that contains the children of the component\n\t\tif (children) {\n\t\t\t// all children are passed as an array\n\t\t\tif (!Array.isArray(children)) {\n\t\t\t\tchildren = [children];\n\t\t\t} \n\n\t\t\tfor (let i=0; i<children.length; i++) {\n\t\t\t\tif (typeof children[i] === 'string') {\n\t\t\t\t\t// turn static HTML into a component\n\t\t\t\t\tchildren[i] = StaticHtml(children[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomponentProps.children = children;\n\t\t}\n\n\t\tconst vdom = Component(componentProps);\n\t\tconsole.log(\"if element\", element, \"has children, DIFF (hydrate) the vdom sub-tree\")\n\n\t\tif (element.hasChildNodes()) {\n\t\t\t// hydrate the vdom sub-tree\n\t\t\tconsole.log(\"hydrate the vdom sub-tree!\",)\n\t\t}\n\n\t\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\t\tconst dom: HTMLElement = render(vdom, element) as HTMLElement;\n\n\t\t// set all props as top level attributes\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (key !== 'children') {\n\t\t\t\tdom.setAttribute(key, value);\n\t\t\t}\n\t\t}\n\n\n\t\telement.addEventListener('astro:unmount', () => {\n\t\t\t// remove the rendered component from the DOM\n\t\t\tif (dom.parentNode) {\n\t\t\t\tdom.parentNode.removeChild(dom);\n\t\t\t}\n }, { once: true });\n\t};"],"names":[],"mappings":";;;;AAGA,aAAe,CAAC,OAAO,KAAK,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK;AACvG,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC;AACtC,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;AACpC,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AACpD,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC;AAClC,GAAG,CAAC;AACJ,EAAE,MAAM,cAAc,GAAG,EAAE,GAAG,KAAK,EAAE;AACrC,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAClC,MAAM,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAC3B;AACA,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC9C,MAAM,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;AAC3C,QAAQ,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC7C;AACA;AACA,IAAI,cAAc,CAAC,QAAQ,GAAG,QAAQ;AACtC;AACA,EAAE,MAAM,IAAI,GAAG,SAAS,CAAC,cAAc,CAAC;AACxC,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,gDAAgD,CAAC;AACtF,EAAE,IAAI,OAAO,CAAC,aAAa,EAAE,EAAE;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;AAC7C;AACA,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;AACnC,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACpD,IAAI,IAAI,GAAG,KAAK,UAAU,EAAE;AAC5B,MAAM,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC;AAClC;AACA;AACA,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM;AAClD,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE;AACxB,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;AACrC;AACA,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACpB,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { AstroIntegration, AstroRenderer, ContainerRenderer, ViteUserConfig } from 'astro';\nimport type { Options } from './types.js';\nimport defussPlugin from 'defuss-vite';\n\nconst getRenderer = (development: boolean): AstroRenderer => ({\n name: 'defuss',\n clientEntrypoint: 'defuss-astro/client.js',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport const getContainerRenderer = (): ContainerRenderer => ({\n name: 'defuss',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport default function ({ include, exclude }: Options = {}): AstroIntegration {\n\treturn {\n\t\tname: 'defuss',\n\t\thooks: {\n\t\t\t'astro:config:setup': ({ addRenderer, updateConfig, command, injectScript }) => {\n\t\t\t\taddRenderer(getRenderer(command === 'dev'));\n\t\t\t\tupdateConfig({\n\t\t\t\t\tvite: {\n optimizeDeps: {\n include: ['defuss-astro/client.js', 'defuss-astro/server.js'],\n },\n plugins: [defussPlugin()],\n },\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n}"],"names":[],"mappings":";;;;;;AAEA,MAAM,WAAW,GAAG,CAAC,WAAW,MAAM;AACtC,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE,wBAAwB;AAC5C,EAAE,gBAAgB,EAAE;AACpB,CAAC,CAAC;AACU,MAAC,oBAAoB,GAAG,OAAO;AAC3C,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE;AACpB,CAAC;AACc,cAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;AACnD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,QAAQ;AAClB,IAAI,KAAK,EAAE;AACX,MAAM,oBAAoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;AACtF,QAAQ,WAAW,CAAC,WAAW,CAAkB,CAAC,CAAC;AACnD,QAAQ,YAAY,CAAC;AACrB,UAAU,IAAI,EAAE;AAChB,YAAY,YAAY,EAAE;AAC1B,cAAc,OAAO,EAAE,CAAC,wBAAwB,EAAE,wBAAwB;AAC1E,aAAa;AACb,YAAY,OAAO,EAAE,CAAC,YAAY,EAAE;AACpC;AACA,SAAS,CAAC;AACV;AACA;AACA,GAAG;AACH;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { AstroIntegration, AstroRenderer, ContainerRenderer, ViteUserConfig } from 'astro';\nimport type { Options } from './types.js';\nimport defussPlugin from 'defuss-vite';\n\nconst getRenderer = (development: boolean): AstroRenderer => ({\n name: 'defuss',\n clientEntrypoint: 'defuss-astro/client.js',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport const getContainerRenderer = (): ContainerRenderer => ({\n name: 'defuss',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport default function ({ include, exclude }: Options = {}): AstroIntegration {\n\treturn {\n\t\tname: 'defuss',\n\t\thooks: {\n\t\t\t'astro:config:setup': ({ addRenderer, updateConfig, command, injectScript }) => {\n\t\t\t\taddRenderer(getRenderer(command === 'dev'));\n\t\t\t\tupdateConfig({\n\t\t\t\t\tvite: {\n\t\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\t\tinclude: ['defuss-astro/client.js', 'defuss-astro/server.js'],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tplugins: [defussPlugin()],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n}"],"names":[],"mappings":";;;;;;AAEA,MAAM,WAAW,GAAG,CAAC,WAAW,MAAM;AACtC,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE,wBAAwB;AAC5C,EAAE,gBAAgB,EAAE;AACpB,CAAC,CAAC;AACU,MAAC,oBAAoB,GAAG,OAAO;AAC3C,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE;AACpB,CAAC;AACc,cAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;AACnD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,QAAQ;AAClB,IAAI,KAAK,EAAE;AACX,MAAM,oBAAoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;AACtF,QAAQ,WAAW,CAAC,WAAW,CAAkB,CAAC,CAAC;AACnD,QAAQ,YAAY,CAAC;AACrB,UAAU,IAAI,EAAE;AAChB,YAAY,YAAY,EAAE;AAC1B,cAAc,OAAO,EAAE,CAAC,wBAAwB,EAAE,wBAAwB;AAC1E,aAAa;AACb,YAAY,OAAO,EAAE,CAAC,YAAY,EAAE;AACpC;AACA,SAAS,CAAC;AACV;AACA;AACA,GAAG;AACH;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { AstroIntegration, AstroRenderer, ContainerRenderer, ViteUserConfig } from 'astro';\nimport type { Options } from './types.js';\nimport defussPlugin from 'defuss-vite';\n\nconst getRenderer = (development: boolean): AstroRenderer => ({\n name: 'defuss',\n clientEntrypoint: 'defuss-astro/client.js',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport const getContainerRenderer = (): ContainerRenderer => ({\n name: 'defuss',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport default function ({ include, exclude }: Options = {}): AstroIntegration {\n\treturn {\n\t\tname: 'defuss',\n\t\thooks: {\n\t\t\t'astro:config:setup': ({ addRenderer, updateConfig, command, injectScript }) => {\n\t\t\t\taddRenderer(getRenderer(command === 'dev'));\n\t\t\t\tupdateConfig({\n\t\t\t\t\tvite: {\n optimizeDeps: {\n include: ['defuss-astro/client.js', 'defuss-astro/server.js'],\n },\n plugins: [defussPlugin()],\n },\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n}"],"names":[],"mappings":";;AAEA,MAAM,WAAW,GAAG,CAAC,WAAW,MAAM;AACtC,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE,wBAAwB;AAC5C,EAAE,gBAAgB,EAAE;AACpB,CAAC,CAAC;AACU,MAAC,oBAAoB,GAAG,OAAO;AAC3C,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE;AACpB,CAAC;AACc,cAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;AACnD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,QAAQ;AAClB,IAAI,KAAK,EAAE;AACX,MAAM,oBAAoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;AACtF,QAAQ,WAAW,CAAC,WAAW,CAAkB,CAAC,CAAC;AACnD,QAAQ,YAAY,CAAC;AACrB,UAAU,IAAI,EAAE;AAChB,YAAY,YAAY,EAAE;AAC1B,cAAc,OAAO,EAAE,CAAC,wBAAwB,EAAE,wBAAwB;AAC1E,aAAa;AACb,YAAY,OAAO,EAAE,CAAC,YAAY,EAAE;AACpC;AACA,SAAS,CAAC;AACV;AACA;AACA,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { AstroIntegration, AstroRenderer, ContainerRenderer, ViteUserConfig } from 'astro';\nimport type { Options } from './types.js';\nimport defussPlugin from 'defuss-vite';\n\nconst getRenderer = (development: boolean): AstroRenderer => ({\n name: 'defuss',\n clientEntrypoint: 'defuss-astro/client.js',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport const getContainerRenderer = (): ContainerRenderer => ({\n name: 'defuss',\n serverEntrypoint: 'defuss-astro/server.js',\n})\n\nexport default function ({ include, exclude }: Options = {}): AstroIntegration {\n\treturn {\n\t\tname: 'defuss',\n\t\thooks: {\n\t\t\t'astro:config:setup': ({ addRenderer, updateConfig, command, injectScript }) => {\n\t\t\t\taddRenderer(getRenderer(command === 'dev'));\n\t\t\t\tupdateConfig({\n\t\t\t\t\tvite: {\n\t\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\t\tinclude: ['defuss-astro/client.js', 'defuss-astro/server.js'],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tplugins: [defussPlugin()],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n}"],"names":[],"mappings":";;AAEA,MAAM,WAAW,GAAG,CAAC,WAAW,MAAM;AACtC,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE,wBAAwB;AAC5C,EAAE,gBAAgB,EAAE;AACpB,CAAC,CAAC;AACU,MAAC,oBAAoB,GAAG,OAAO;AAC3C,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,gBAAgB,EAAE;AACpB,CAAC;AACc,cAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;AACnD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,QAAQ;AAClB,IAAI,KAAK,EAAE;AACX,MAAM,oBAAoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;AACtF,QAAQ,WAAW,CAAC,WAAW,CAAkB,CAAC,CAAC;AACnD,QAAQ,YAAY,CAAC;AACrB,UAAU,IAAI,EAAE;AAChB,YAAY,YAAY,EAAE;AAC1B,cAAc,OAAO,EAAE,CAAC,wBAAwB,EAAE,wBAAwB;AAC1E,aAAa;AACb,YAAY,OAAO,EAAE,CAAC,YAAY,EAAE;AACpC;AACA,SAAS,CAAC;AACV;AACA;AACA,GAAG;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","sources":["../src/server.ts"],"sourcesContent":["import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro';\nimport type { RendererContext } from './types.js';\nimport { renderToString, render } from 'defuss/server'\nimport { type Props, jsx } from 'defuss'\nimport { StaticHtml } from './render.js';\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\n// TODO: is a differential update possible?\n\nasync function check(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\tchildren: any,\n) {\n\tif (typeof Component !== 'function') return false;\n\n\tconsole.log('server check', this);\n\n\treturn true; // always (re-)render for now (TODO: implement proper check)\n}\n\nasync function renderToStaticMarkup(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\t{ default: children, ...slotted }: Record<string, any>,\n\tmetadata: AstroComponentMetadata | undefined,\n) {\n\n\tconsole.log('server render', this);\n\n\t// we use \"classic\" runtime, so we need to set the global jsx function\n\t// otherwise it would need to be imported in every component\n\t(globalThis as any).jsx = jsx;\n\n\tconst slots: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(slotted)) {\n\t\tconst name = slotName(key);\n\t\tslots[name] = StaticHtml(value);\n\t}\n\n\t// traverse the props object and create a new object with the same values\n\tconst componentProps: Props = { ...props };\n\n\t// children is a special prop that contains the children of the component\n\tif (children) {\n\t\tcomponentProps.children = children;\n\t}\n\n\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\tconst dom: HTMLElement = render(Component(componentProps)) as HTMLElement;\n\n\tconst attrs = {};\n\t\n\t// set all props as top level attributes\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tif (key !== 'children') {\n\t\t\t(attrs as Record<string, unknown>)[key] = value;\n\t\t}\n\t}\n\n\tconst html = renderToString(dom);\n\n\treturn { attrs, html };\n}\n\nconst renderer: NamedSSRLoadedRendererValue = {\n\tname: 'defuss',\n\tcheck,\n\trenderToStaticMarkup,\n\tsupportsAstroStaticSlot: true,\n};\n\nexport default renderer;"],"names":["jsx","StaticHtml","render","renderToString"],"mappings":";;;;;;AAIA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACvF,eAAe,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACjD,EAAE,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,OAAO,KAAK;AACnD,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC;AACnC,EAAE,OAAO,IAAI;AACb;AACA,eAAe,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,QAAQ,EAAE;AACnG,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC;AACpC,EAAE,UAAU,CAAC,GAAG,GAAGA,UAAG;AAEtB,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AACtD,IAAiB,QAAQ,CAAC,GAAG;AAC7B,IAAkBC,iBAAU,CAAC,KAAK,CAAC;AACnC;AACA,EAAE,MAAM,cAAc,GAAG,EAAE,GAAG,KAAK,EAAE;AACrC,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,cAAc,CAAC,QAAQ,GAAG,QAAQ;AACtC;AACA,EAAE,MAAM,GAAG,GAAGC,aAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAC/C,EAAE,MAAM,KAAK,GAAG,EAAE;AAClB,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACpD,IAAI,IAAI,GAAG,KAAK,UAAU,EAAE;AAC5B,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;AACxB;AACA;AACA,EAAE,MAAM,IAAI,GAAGC,qBAAc,CAAC,GAAG,CAAC;AAClC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;AACxB;AACK,MAAC,QAAQ,GAAG;AACjB,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,KAAK;AACP,EAAE,oBAAoB;AACtB,EAAE,uBAAuB,EAAE;AAC3B;;;;"}
1
+ {"version":3,"file":"server.cjs","sources":["../src/server.ts"],"sourcesContent":["import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro';\nimport type { RendererContext } from './types.js';\nimport { renderToString, render } from 'defuss/server'\nimport { type Props, jsx } from 'defuss'\nimport { StaticHtml } from './render.js';\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\nasync function check(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\tchildren: any,\n) {\n\tif (typeof Component !== 'function') return false;\n\n\tconsole.log('server check', this);\n\n\treturn true; // always (re-)render for now (TODO: implement proper check)\n}\n\nasync function renderToStaticMarkup(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\t{ default: children, ...slotted }: Record<string, any>,\n\tmetadata: AstroComponentMetadata | undefined,\n) {\n\n\tconsole.log('server render', this);\n\n\t// we use \"classic\" runtime, so we need to set the global jsx function\n\t// otherwise it would need to be imported in every component\n\t(globalThis as any).jsx = jsx;\n\n\tconst slots: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(slotted)) {\n\t\tconst name = slotName(key);\n\t\tslots[name] = StaticHtml(value);\n\t}\n\n\t// traverse the props object and create a new object with the same values\n\tconst componentProps: Props = { ...props };\n\n\t// children is a special prop that contains the children of the component\n\tif (children) {\n\t\tcomponentProps.children = children;\n\t}\n\n\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\tconst dom: HTMLElement = render(Component(componentProps)) as HTMLElement;\n\n\tconst attrs = {};\n\t\n\t// set all props as top level attributes\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tif (key !== 'children') {\n\t\t\t(attrs as Record<string, unknown>)[key] = value;\n\t\t}\n\t}\n\n\tconst html = renderToString(dom);\n\n\treturn { attrs, html };\n}\n\nconst renderer: NamedSSRLoadedRendererValue = {\n\tname: 'defuss',\n\tcheck,\n\trenderToStaticMarkup,\n\tsupportsAstroStaticSlot: true,\n};\n\nexport default renderer;"],"names":["jsx","StaticHtml","render","renderToString"],"mappings":";;;;;;AAIA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACvF,eAAe,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACjD,EAAE,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,OAAO,KAAK;AACnD,EAA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cesContent":["import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro';\nimport type { RendererContext } from './types.js';\nimport { renderToString, render } from 'defuss/server'\nimport { type Props, jsx } from 'defuss'\nimport { StaticHtml } from './render.js';\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\n// TODO: is a differential update possible?\n\nasync function check(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\tchildren: any,\n) {\n\tif (typeof Component !== 'function') return false;\n\n\tconsole.log('server check', this);\n\n\treturn true; // always (re-)render for now (TODO: implement proper check)\n}\n\nasync function renderToStaticMarkup(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\t{ default: children, ...slotted }: Record<string, any>,\n\tmetadata: AstroComponentMetadata | undefined,\n) {\n\n\tconsole.log('server render', this);\n\n\t// we use \"classic\" runtime, so we need to set the global jsx function\n\t// otherwise it would need to be imported in every component\n\t(globalThis as any).jsx = jsx;\n\n\tconst slots: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(slotted)) {\n\t\tconst name = slotName(key);\n\t\tslots[name] = StaticHtml(value);\n\t}\n\n\t// traverse the props object and create a new object with the same values\n\tconst componentProps: Props = { ...props };\n\n\t// children is a special prop that contains the children of the component\n\tif (children) {\n\t\tcomponentProps.children = children;\n\t}\n\n\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\tconst dom: HTMLElement = render(Component(componentProps)) as HTMLElement;\n\n\tconst attrs = {};\n\t\n\t// set all props as top level attributes\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tif (key !== 'children') {\n\t\t\t(attrs as Record<string, unknown>)[key] = value;\n\t\t}\n\t}\n\n\tconst html = renderToString(dom);\n\n\treturn { attrs, html };\n}\n\nconst renderer: NamedSSRLoadedRendererValue = {\n\tname: 'defuss',\n\tcheck,\n\trenderToStaticMarkup,\n\tsupportsAstroStaticSlot: true,\n};\n\nexport default renderer;"],"names":[],"mappings":";;;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M,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC;AAClC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;AACxB;AACK,MAAC,QAAQ,GAAG;AACjB,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,KAAK;AACP,EAAE,oBAAoB;AACtB,EAAE,uBAAuB,EAAE;AAC3B;;;;"}
1
+ {"version":3,"file":"server.mjs","sources":["../src/server.ts"],"sourcesContent":["import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro';\nimport type { RendererContext } from './types.js';\nimport { renderToString, render } from 'defuss/server'\nimport { type Props, jsx } from 'defuss'\nimport { StaticHtml } from './render.js';\n\nconst slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());\n\nasync function check(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\tchildren: any,\n) {\n\tif (typeof Component !== 'function') return false;\n\n\tconsole.log('server check', this);\n\n\treturn true; // always (re-)render for now (TODO: implement proper check)\n}\n\nasync function renderToStaticMarkup(\n\tthis: RendererContext,\n\tComponent: any,\n\tprops: Record<string, any>,\n\t{ default: children, ...slotted }: Record<string, any>,\n\tmetadata: AstroComponentMetadata | undefined,\n) {\n\n\tconsole.log('server render', this);\n\n\t// we use \"classic\" runtime, so we need to set the global jsx function\n\t// otherwise it would need to be imported in every component\n\t(globalThis as any).jsx = jsx;\n\n\tconst slots: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(slotted)) {\n\t\tconst name = slotName(key);\n\t\tslots[name] = StaticHtml(value);\n\t}\n\n\t// traverse the props object and create a new object with the same values\n\tconst componentProps: Props = { ...props };\n\n\t// children is a special prop that contains the children of the component\n\tif (children) {\n\t\tcomponentProps.children = children;\n\t}\n\n\t// turn the component AST into an actual DOM element and attach it to the element passed in\n\tconst dom: HTMLElement = render(Component(componentProps)) as HTMLElement;\n\n\tconst attrs = {};\n\t\n\t// set all props as top level attributes\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tif (key !== 'children') {\n\t\t\t(attrs as Record<string, unknown>)[key] = value;\n\t\t}\n\t}\n\n\tconst html = renderToString(dom);\n\n\treturn { attrs, html };\n}\n\nconst renderer: NamedSSRLoadedRendererValue = {\n\tname: 'defuss',\n\tcheck,\n\trenderToStaticMarkup,\n\tsupportsAstroStaticSlot: true,\n};\n\nexport default renderer;"],"names":[],"mappings":";;;;AAIA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACvF,eAAe,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACjD,EAAE,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,OAAO,KAAK;AACnD,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC;AACnC,EAAE,OAAO,IAAI;AACb;AACA,eAAe,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,QAAQ,EAAE;AACnG,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC;AACpC,EAAE,UAAU,CAAC,GAAG,GAAG,GAAG;AAEtB,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AACtD,IAAiB,QAAQ,CAAC,GAAG;AAC7B,IAAkB,UAAU,CAAC,KAAK,CAAC;AACnC;AACA,EAAE,MAAM,cAAc,GAAG,EAAE,GAAG,KAAK,EAAE;AACrC,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,cAAc,CAAC,QAAQ,GAAG,QAAQ;AACtC;AACA,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAC/C,EAAE,MAAM,KAAK,GAAG,EAAE;AAClB,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACpD,IAAI,IAAI,GAAG,KAAK,UAAU,EAAE;AAC5B,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;AACxB;AACA;AACA,EAAE,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC;AAClC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;AACxB;AACK,MAAC,QAAQ,GAAG;AACjB,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,KAAK;AACP,EAAE,oBAAoB;AACtB,EAAE,uBAAuB,EAAE;AAC3B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defuss-astro",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -74,8 +74,8 @@
74
74
  "node": "^18.17.1 || ^20.3.0 || >=21.0.0"
75
75
  },
76
76
  "dependencies": {
77
- "defuss": "workspace:*",
78
- "defuss-vite": "workspace:*",
77
+ "defuss": "^1.2.4",
78
+ "defuss-vite": "^1.0.5",
79
79
  "astro": "^4.16.13",
80
80
  "vite": "^5.4.11"
81
81
  }