defuss-astro 1.1.3 → 1.1.4

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
@@ -5,6 +5,10 @@ var render = require('./render-DkMOLcUd.cjs');
5
5
  require('defuss');
6
6
 
7
7
  var client = (element) => async (Component, props, { default: children, ...slotted }, { client }) => {
8
+ const isHydrate = client !== "only";
9
+ if (element.hasAttribute("ssr")) {
10
+ console.log("ssr attr found isHydrate", isHydrate, Component, "props", props, "slotted", slotted, "children", children, "client", client);
11
+ }
8
12
  if (!element.hasAttribute("ssr")) return;
9
13
  Object.entries(slotted).forEach(([key, value]) => {
10
14
  props[key] = render.StaticHtml(value);
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { StaticHtml } from './render.js';\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\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\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\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,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK;AACvG,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,GAAGA,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,IAAI,GAAG,SAAS,CAAC,cAAc,CAAC;AACxC,EAAE,MAAM,GAAG,GAAGC,eAAM,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
+ {"version":3,"file":"client.cjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { StaticHtml } from './render.js';\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\tconst isHydrate = client !== 'only';\n\n\t\tif (element.hasAttribute('ssr')) {\n\t\t\tconsole.log('ssr attr found isHydrate', isHydrate, Component, 'props', props, 'slotted', slotted, 'children', children, 'client', client);\n\t\t}\n\t\t\n\t\tif (!element.hasAttribute('ssr')) return;\n\t\t\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\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\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,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK;AACvG,EAAE,MAAM,SAAS,GAAG,MAAM,KAAK,MAAM;AACrC,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;AACnC,IAAI,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;AAC7I;AACA,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;A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aticHtml } from './render-viAgneG-.mjs';
3
3
  import 'defuss';
4
4
 
5
5
  var client = (element) => async (Component, props, { default: children, ...slotted }, { client }) => {
6
+ const isHydrate = client !== "only";
7
+ if (element.hasAttribute("ssr")) {
8
+ console.log("ssr attr found isHydrate", isHydrate, Component, "props", props, "slotted", slotted, "children", children, "client", client);
9
+ }
6
10
  if (!element.hasAttribute("ssr")) return;
7
11
  Object.entries(slotted).forEach(([key, value]) => {
8
12
  props[key] = StaticHtml(value);
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { StaticHtml } from './render.js';\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\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\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\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,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,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
+ {"version":3,"file":"client.mjs","sources":["../src/client.ts"],"sourcesContent":["import { type Props, render } from 'defuss/client'\nimport { StaticHtml } from './render.js';\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\tconst isHydrate = client !== 'only';\n\n\t\tif (element.hasAttribute('ssr')) {\n\t\t\tconsole.log('ssr attr found isHydrate', isHydrate, Component, 'props', props, 'slotted', slotted, 'children', children, 'client', client);\n\t\t}\n\t\t\n\t\tif (!element.hasAttribute('ssr')) return;\n\t\t\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\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\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,MAAM,SAAS,GAAG,MAAM,KAAK,MAAM;AACrC,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;AACnC,IAAI,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;AAC7I;AACA,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,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