diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..4b787d7d1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Files with the language manually specified, sorted alphabetically. +/internal/**/*.snap linguist-language=Markdown \ No newline at end of file diff --git a/go.mod b/go.mod index bba9c73eb..a515c8c88 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/withastro/compiler -go 1.20 +go 1.21 require ( github.com/google/go-cmp v0.5.9 @@ -11,3 +11,17 @@ require ( golang.org/x/net v0.0.0-20221004154528-8021a29435af golang.org/x/sys v0.0.0-20221010170243-090e33056c14 ) + +require ( + github.com/gkampitakis/ciinfo v0.3.0 // indirect + github.com/gkampitakis/go-diff v1.3.2 // indirect + github.com/gkampitakis/go-snaps v0.5.2 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/maruel/natural v1.1.1 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/tidwall/gjson v1.17.0 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.1 // indirect + github.com/tidwall/sjson v1.2.5 // indirect +) diff --git a/go.sum b/go.sum index 60fa07fd6..2ce2953b2 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,42 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8= +github.com/gkampitakis/ciinfo v0.3.0/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= +github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= +github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= +github.com/gkampitakis/go-snaps v0.5.2 h1:ay/6f7WHwRkOgpBec9DjMLRBAApziJommZ21NkOOCwY= +github.com/gkampitakis/go-snaps v0.5.2/go.mod h1:ZABkO14uCuVxBHAXAfKG+bqNz+aa1bGPAg8jkI0Nk8Y= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= +github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= +github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd h1:tHn7K76q9eJ2rXLH/OoxHkdprM3l2A+0kdxOrKYcV7U= github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd/go.mod h1:8iuQLyTSvuzwy6R6l6w6J+i9c/6xPEVoVdcMz9E8FEw= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/tdewolff/parse/v2 v2.6.4 h1:KCkDvNUMof10e3QExio9OPZJT8SbdKojLBumw8YZycQ= github.com/tdewolff/parse/v2 v2.6.4/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs= github.com/tdewolff/test v1.0.7 h1:8Vs0142DmPFW/bQeHRP3MV19m1gvndjUb1sn8yy74LM= github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= +github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= +github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4= golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc= diff --git a/internal/printer/__snapshots__/All_components.snap b/internal/printer/__snapshots__/All_components.snap new file mode 100755 index 000000000..d4573bce5 --- /dev/null +++ b/internal/printer/__snapshots__/All_components.snap @@ -0,0 +1,59 @@ + +[TestPrinter/All_components - 1] +## Input + +``` +/-/-/-/ +import { Container, Col, Row } from 'react-bootstrap'; +/-/-/-/ + + + +

Hi!

+ +
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import { Container, Col, Row } from 'react-bootstrap'; + +import * as $$module1 from 'react-bootstrap'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'react-bootstrap', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Container',Container,{},{"default": () => $$render` + ${$$renderComponent($$result,'Row',Row,{},{"default": () => $$render` + ${$$renderComponent($$result,'Col',Col,{},{"default": () => $$render` + ${$$maybeRenderHead($$result)}

Hi!

+ `,})} + `,})} +`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Component_is_raw.snap b/internal/printer/__snapshots__/Component_is_raw.snap new file mode 100755 index 000000000..4589929b1 --- /dev/null +++ b/internal/printer/__snapshots__/Component_is_raw.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Component_is:raw - 1] +## Input + +``` +{<% awesome %>} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`{<% awesome %>}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Component_names_A-Z.snap b/internal/printer/__snapshots__/Component_names_A-Z.snap new file mode 100755 index 000000000..f8b43bfaf --- /dev/null +++ b/internal/printer/__snapshots__/Component_names_A-Z.snap @@ -0,0 +1,57 @@ + +[TestPrinter/Component_names_A-Z - 1] +## Input + +``` +/-/-/-/ +import AComponent from '../components/AComponent.jsx'; +import ZComponent from '../components/ZComponent.jsx'; +/-/-/-/ + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import AComponent from '../components/AComponent.jsx'; +import ZComponent from '../components/ZComponent.jsx'; + +import * as $$module1 from '../components/AComponent.jsx'; +import * as $$module2 from '../components/ZComponent.jsx'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: '../components/AComponent.jsx', assert: {} }, { module: $$module2, specifier: '../components/ZComponent.jsx', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)} + ${$$renderComponent($$result,'AComponent',AComponent,{})} + ${$$renderComponent($$result,'ZComponent',ZComponent,{})} +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Component_siblings_are_siblings.snap b/internal/printer/__snapshots__/Component_siblings_are_siblings.snap new file mode 100755 index 000000000..b1e9254dd --- /dev/null +++ b/internal/printer/__snapshots__/Component_siblings_are_siblings.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Component_siblings_are_siblings - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'BaseHead',BaseHead,{})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Empty_attribute_expression.snap b/internal/printer/__snapshots__/Empty_attribute_expression.snap new file mode 100755 index 000000000..1d77ea8fc --- /dev/null +++ b/internal/printer/__snapshots__/Empty_attribute_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Empty_attribute_expression - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Empty_expression.snap b/internal/printer/__snapshots__/Empty_expression.snap new file mode 100755 index 000000000..183b9fc41 --- /dev/null +++ b/internal/printer/__snapshots__/Empty_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Empty_expression - 1] +## Input + +``` +({}) +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}(${(void 0)})`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Empty_expression_with_whitespace.snap b/internal/printer/__snapshots__/Empty_expression_with_whitespace.snap new file mode 100755 index 000000000..7a8cf769b --- /dev/null +++ b/internal/printer/__snapshots__/Empty_expression_with_whitespace.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Empty_expression_with_whitespace - 1] +## Input + +``` +({ }) +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}(${(void 0) })`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Empty_script.snap b/internal/printer/__snapshots__/Empty_script.snap new file mode 100755 index 000000000..14e2b9d99 --- /dev/null +++ b/internal/printer/__snapshots__/Empty_script.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Empty_script - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Empty_style.snap b/internal/printer/__snapshots__/Empty_style.snap new file mode 100755 index 000000000..0c43e5dd4 --- /dev/null +++ b/internal/printer/__snapshots__/Empty_style.snap @@ -0,0 +1,42 @@ + +[TestPrinter/Empty_style - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{ color: "Gainsboro" }]); +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Expression_in_form_followed_by_other_sibling_forms.snap b/internal/printer/__snapshots__/Expression_in_form_followed_by_other_sibling_forms.snap new file mode 100755 index 000000000..08f76768a --- /dev/null +++ b/internal/printer/__snapshots__/Expression_in_form_followed_by_other_sibling_forms.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Expression_in_form_followed_by_other_sibling_forms - 1] +## Input + +``` +

No expression here. So the next form will render.

{data.formLabelA}

{data.formLabelB}

No expression here, but the last form before me had an expression, so my form didn't render.

{data.formLabelC}

Here is some in-between content

{data.formLabelD}

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

No expression here. So the next form will render.

${data.formLabelA}

${data.formLabelB}

No expression here, but the last form before me had an expression, so my form didn't render.

${data.formLabelC}

Here is some in-between content

${data.formLabelD}

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Fragment.snap b/internal/printer/__snapshots__/Fragment.snap new file mode 100755 index 000000000..369a59be3 --- /dev/null +++ b/internal/printer/__snapshots__/Fragment.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Fragment - 1] +## Input + +``` +
Default
Named
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`
Default
Named
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Fragment_literal_only.snap b/internal/printer/__snapshots__/Fragment_literal_only.snap new file mode 100755 index 000000000..741ae8a95 --- /dev/null +++ b/internal/printer/__snapshots__/Fragment_literal_only.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Fragment_literal_only - 1] +## Input + +``` +world +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`world`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Fragment_shorthand.snap b/internal/printer/__snapshots__/Fragment_shorthand.snap new file mode 100755 index 000000000..dc96c896e --- /dev/null +++ b/internal/printer/__snapshots__/Fragment_shorthand.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Fragment_shorthand - 1] +## Input + +``` +<>
Default
Named
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`
Default
Named
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Fragment_shorthand_only.snap b/internal/printer/__snapshots__/Fragment_shorthand_only.snap new file mode 100755 index 000000000..59870acb1 --- /dev/null +++ b/internal/printer/__snapshots__/Fragment_shorthand_only.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Fragment_shorthand_only - 1] +## Input + +``` +<>Hello +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`Hello`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Fragment_slotted.snap b/internal/printer/__snapshots__/Fragment_slotted.snap new file mode 100755 index 000000000..e9a59f027 --- /dev/null +++ b/internal/printer/__snapshots__/Fragment_slotted.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Fragment_slotted - 1] +## Input + +``` +<>
Default
Named
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`
Default
Named
`,})}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Fragment_slotted_with_name.snap b/internal/printer/__snapshots__/Fragment_slotted_with_name.snap new file mode 100755 index 000000000..4eeb9e5b9 --- /dev/null +++ b/internal/printer/__snapshots__/Fragment_slotted_with_name.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Fragment_slotted_with_name - 1] +## Input + +``` +
Default
Named
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Component',Component,{},{"named": () => $$render`${$$renderComponent($$result,'Fragment',Fragment,{"slot":"named"},{"default": () => $$render`
Default
Named
`,})}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_I.snap b/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_I.snap new file mode 100755 index 000000000..2295e0d28 --- /dev/null +++ b/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_I.snap @@ -0,0 +1,41 @@ + +[TestPrinter/HTML_comment_in_component_inside_expression_I - 1] +## Input + +``` +{(() => )} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${(() => $$render`${$$renderComponent($$result,'Component',Component,{},{})}`)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_II.snap b/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_II.snap new file mode 100755 index 000000000..9ed6ef937 --- /dev/null +++ b/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/HTML_comment_in_component_inside_expression_II - 1] +## Input + +``` +{list.map(() => )} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${list.map(() => $$render`${$$renderComponent($$result,'Component',Component,{},{})}`)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Mixed_style_siblings.snap b/internal/printer/__snapshots__/Mixed_style_siblings.snap new file mode 100755 index 000000000..947fc2d1d --- /dev/null +++ b/internal/printer/__snapshots__/Mixed_style_siblings.snap @@ -0,0 +1,51 @@ + +[TestPrinter/Mixed_style_siblings - 1] +## Input + +``` + + + + + +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + + +${$$renderHead($$result)} +
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Nested_HTML_in_expressions,_wrapped_in_parens.snap b/internal/printer/__snapshots__/Nested_HTML_in_expressions,_wrapped_in_parens.snap new file mode 100755 index 000000000..068712239 --- /dev/null +++ b/internal/printer/__snapshots__/Nested_HTML_in_expressions,_wrapped_in_parens.snap @@ -0,0 +1,48 @@ + +[TestPrinter/Nested_HTML_in_expressions,_wrapped_in_parens - 1] +## Input + +``` +/-/-/-/ +const image = './penguin.png'; +const canonicalURL = new URL('http://example.com'); +/-/-/-/ +{image && ()} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const image = './penguin.png'; +const canonicalURL = new URL('http://example.com'); + +return $$render`${image && ($$render``)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/No_extra_script_tag.snap b/internal/printer/__snapshots__/No_extra_script_tag.snap new file mode 100755 index 000000000..497d90112 --- /dev/null +++ b/internal/printer/__snapshots__/No_extra_script_tag.snap @@ -0,0 +1,120 @@ + +[TestPrinter/No_extra_script_tag - 1] +## Input + +``` + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + + + + + + + + + + + + + + + + + + + + + + + +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Parser_can_handle_files___4096_chars.snap b/internal/printer/__snapshots__/Parser_can_handle_files___4096_chars.snap new file mode 100755 index 000000000..371fb499d --- /dev/null +++ b/internal/printer/__snapshots__/Parser_can_handle_files___4096_chars.snap @@ -0,0 +1,48 @@ + +[TestPrinter/Parser_can_handle_files_>_4096_chars - 1] +## Input + +``` +abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.? +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'",.?`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Preserve_namespaces.snap b/internal/printer/__snapshots__/Preserve_namespaces.snap new file mode 100755 index 000000000..140213a2f --- /dev/null +++ b/internal/printer/__snapshots__/Preserve_namespaces.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Preserve_namespaces - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Preserve_namespaces_for_components.snap b/internal/printer/__snapshots__/Preserve_namespaces_for_components.snap new file mode 100755 index 000000000..4f3c562b1 --- /dev/null +++ b/internal/printer/__snapshots__/Preserve_namespaces_for_components.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Preserve_namespaces_for_components - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{"some:thing":"foobar"})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Preserve_namespaces_in_expressions.snap b/internal/printer/__snapshots__/Preserve_namespaces_in_expressions.snap new file mode 100755 index 000000000..a50b4ec31 --- /dev/null +++ b/internal/printer/__snapshots__/Preserve_namespaces_in_expressions.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Preserve_namespaces_in_expressions - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Preserve_slot_whitespace.snap b/internal/printer/__snapshots__/Preserve_slot_whitespace.snap new file mode 100755 index 000000000..a88a1cc87 --- /dev/null +++ b/internal/printer/__snapshots__/Preserve_slot_whitespace.snap @@ -0,0 +1,47 @@ + +[TestPrinter/Preserve_slot_whitespace - 1] +## Input + +``` + +

Paragraph 1

+

Paragraph 2

+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + ${$$maybeRenderHead($$result)}

Paragraph 1

+

Paragraph 2

+`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Preserve_slots_inside_custom-element.snap b/internal/printer/__snapshots__/Preserve_slots_inside_custom-element.snap new file mode 100755 index 000000000..b742b5787 --- /dev/null +++ b/internal/printer/__snapshots__/Preserve_slots_inside_custom-element.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Preserve_slots_inside_custom-element - 1] +## Input + +``` +
Name
Default
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderComponent($$result,'my-element','my-element',{},{"default": () => $$render`
Name
Default
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/React_framework_example.snap b/internal/printer/__snapshots__/React_framework_example.snap new file mode 100755 index 000000000..d7dceb9f0 --- /dev/null +++ b/internal/printer/__snapshots__/React_framework_example.snap @@ -0,0 +1,115 @@ + +[TestPrinter/React_framework_example - 1] +## Input + +``` +/-/-/-/ +// Component Imports +import Counter from '../components/Counter.jsx' +const someProps = { + count: 0, +} + +// Full Astro Component Syntax: +// https://docs.astro.build/core-concepts/astro-components/ +/-/-/-/ + + + + + + + + +
+ +

Hello React!

+
+
+ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Counter from '../components/Counter.jsx' + + +import * as $$module1 from '../components/Counter.jsx'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: '../components/Counter.jsx', assert: {} }], hydratedComponents: [Counter], clientOnlyComponents: [], hydrationDirectives: new Set(['visible']), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +// Component Imports + +const someProps = { + count: 0, +} + +// Full Astro Component Syntax: +// https://docs.astro.build/core-concepts/astro-components/ + +return $$render` + + + + + + ${$$renderHead($$result)} + +
+ ${$$renderComponent($$result,'Counter',Counter,{...(someProps),"client:visible":true,"client:component-hydration":"visible","client:component-path":("../components/Counter.jsx"),"client:component-export":("default"),"class":"astro-hmnnhvcq"},{"default": () => $$render` +

Hello React!

+ `,})} +
+ `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/SVG_styles.snap b/internal/printer/__snapshots__/SVG_styles.snap new file mode 100755 index 000000000..be2a50df5 --- /dev/null +++ b/internal/printer/__snapshots__/SVG_styles.snap @@ -0,0 +1,41 @@ + +[TestPrinter/SVG_styles - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_components_in_head_can_have_siblings.snap b/internal/printer/__snapshots__/Self-closing_components_in_head_can_have_siblings.snap new file mode 100755 index 000000000..e11dfd4ed --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_components_in_head_can_have_siblings.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Self-closing_components_in_head_can_have_siblings - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'BaseHead',BaseHead,{})}${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_components_siblings_are_siblings.snap b/internal/printer/__snapshots__/Self-closing_components_siblings_are_siblings.snap new file mode 100755 index 000000000..2234254f0 --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_components_siblings_are_siblings.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Self-closing_components_siblings_are_siblings - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'BaseHead',BaseHead,{})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_formatting_elements.snap b/internal/printer/__snapshots__/Self-closing_formatting_elements.snap new file mode 100755 index 000000000..eb930bff6 --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_formatting_elements.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Self-closing_formatting_elements - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_formatting_elements_2.snap b/internal/printer/__snapshots__/Self-closing_formatting_elements_2.snap new file mode 100755 index 000000000..5f5c046ee --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_formatting_elements_2.snap @@ -0,0 +1,49 @@ + +[TestPrinter/Self-closing_formatting_elements_2 - 1] +## Input + +``` + +
+
+
+ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)} +
+
+
+`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_script_in_head_works.snap b/internal/printer/__snapshots__/Self-closing_script_in_head_works.snap new file mode 100755 index 000000000..ec156d5ec --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_script_in_head_works.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Self-closing_script_in_head_works - 1] +## Input + +``` +${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_title.snap b/internal/printer/__snapshots__/Self-closing_title.snap new file mode 100755 index 000000000..3a60b2a2f --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_title.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Self-closing_title - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`<title>`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Self-closing_title_II.snap b/internal/printer/__snapshots__/Self-closing_title_II.snap new file mode 100755 index 000000000..e7463f236 --- /dev/null +++ b/internal/printer/__snapshots__/Self-closing_title_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/Self-closing_title_II - 1] +## Input + +``` +</head><body></body></html> +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`<html><head><title>${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/Use_of_interfaces_within_frontmatter.snap b/internal/printer/__snapshots__/Use_of_interfaces_within_frontmatter.snap new file mode 100755 index 000000000..7e1ddec92 --- /dev/null +++ b/internal/printer/__snapshots__/Use_of_interfaces_within_frontmatter.snap @@ -0,0 +1,60 @@ + +[TestPrinter/Use_of_interfaces_within_frontmatter - 1] +## Input + +``` +/-/-/-/ +interface MarkdownFrontmatter { + date: number; + image: string; + author: string; +} +let allPosts = Astro.fetchContent('./post/*.md'); +/-/-/-/ +
testing
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +interface MarkdownFrontmatter { + date: number; + image: string; + author: string; +} +let allPosts = Astro.fetchContent('./post/*.md'); + +return $$render`${$$maybeRenderHead($$result)}
testing
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/XElement.snap b/internal/printer/__snapshots__/XElement.snap new file mode 100755 index 000000000..9c97ab3d5 --- /dev/null +++ b/internal/printer/__snapshots__/XElement.snap @@ -0,0 +1,41 @@ + +[TestPrinter/XElement - 1] +## Input + +``` +{onLoadString ? : null } +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'XElement',XElement,{...(attrs)})}${onLoadString ? $$render`` : null }`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/_955_ternary_slot_with_elements.snap b/internal/printer/__snapshots__/_955_ternary_slot_with_elements.snap new file mode 100755 index 000000000..bcc72087c --- /dev/null +++ b/internal/printer/__snapshots__/_955_ternary_slot_with_elements.snap @@ -0,0 +1,41 @@ + +[TestPrinter/#955_ternary_slot_with_elements - 1] +## Input + +``` +
{isLeaf ?

Leaf

:

Branch

}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${$$maybeRenderHead($$result)}
${isLeaf ? $$render`

Leaf

` : $$render`

Branch

`}
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/_955_ternary_slot_with_text.snap b/internal/printer/__snapshots__/_955_ternary_slot_with_text.snap new file mode 100755 index 000000000..c96aa96eb --- /dev/null +++ b/internal/printer/__snapshots__/_955_ternary_slot_with_text.snap @@ -0,0 +1,41 @@ + +[TestPrinter/#955_ternary_slot_with_text - 1] +## Input + +``` +Hello{isLeaf ?

Leaf

:

Branch

}world
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`Hello${isLeaf ? $$render`${$$maybeRenderHead($$result)}

Leaf

` : $$render`

Branch

`}world`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/advanced_svg_expression.snap b/internal/printer/__snapshots__/advanced_svg_expression.snap new file mode 100755 index 000000000..fccefbbe9 --- /dev/null +++ b/internal/printer/__snapshots__/advanced_svg_expression.snap @@ -0,0 +1,46 @@ + +[TestPrinter/advanced_svg_expression - 1] +## Input + +``` +/-/-/-/ +const title = 'icon'; +/-/-/-/ +{title ? {title} : null} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const title = 'icon'; + +return $$render`${$$maybeRenderHead($$result)}${title ? $$render`${title}` : null}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/anchor_content.snap b/internal/printer/__snapshots__/anchor_content.snap new file mode 100755 index 000000000..300acce1e --- /dev/null +++ b/internal/printer/__snapshots__/anchor_content.snap @@ -0,0 +1,41 @@ + +[TestPrinter/anchor_content - 1] +## Input + +``` +

  • {expr}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

  • ${expr}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/anchor_expressions.snap b/internal/printer/__snapshots__/anchor_expressions.snap new file mode 100755 index 000000000..8b32c5f28 --- /dev/null +++ b/internal/printer/__snapshots__/anchor_expressions.snap @@ -0,0 +1,41 @@ + +[TestPrinter/anchor_expressions - 1] +## Input + +``` +{expr} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${expr}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/anchor_inside_expression.snap b/internal/printer/__snapshots__/anchor_inside_expression.snap new file mode 100755 index 000000000..80b4d9e06 --- /dev/null +++ b/internal/printer/__snapshots__/anchor_inside_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/anchor_inside_expression - 1] +## Input + +``` +{true && expr} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${true && $$render`${$$maybeRenderHead($$result)}expr`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/attribute_with_template_literal.snap b/internal/printer/__snapshots__/attribute_with_template_literal.snap new file mode 100755 index 000000000..b6391d018 --- /dev/null +++ b/internal/printer/__snapshots__/attribute_with_template_literal.snap @@ -0,0 +1,41 @@ + +[TestPrinter/attribute_with_template_literal - 1] +## Input + +``` +Home +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}Home`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/attribute_with_template_literal_interpolation.snap b/internal/printer/__snapshots__/attribute_with_template_literal_interpolation.snap new file mode 100755 index 000000000..c6a00c075 --- /dev/null +++ b/internal/printer/__snapshots__/attribute_with_template_literal_interpolation.snap @@ -0,0 +1,41 @@ + +[TestPrinter/attribute_with_template_literal_interpolation - 1] +## Input + +``` +Home +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}Home`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/backtick_in_HTML_comment.snap b/internal/printer/__snapshots__/backtick_in_HTML_comment.snap new file mode 100755 index 000000000..14a71ed19 --- /dev/null +++ b/internal/printer/__snapshots__/backtick_in_HTML_comment.snap @@ -0,0 +1,41 @@ + +[TestPrinter/backtick_in_HTML_comment - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/basic__frontmatter_.snap b/internal/printer/__snapshots__/basic__frontmatter_.snap new file mode 100755 index 000000000..ace5c57c7 --- /dev/null +++ b/internal/printer/__snapshots__/basic__frontmatter_.snap @@ -0,0 +1,46 @@ + +[TestPrinter/basic_(frontmatter) - 1] +## Input + +``` +/-/-/-/ +const href = '/about'; +/-/-/-/ +About +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const href = '/about'; + +return $$render`${$$maybeRenderHead($$result)}About`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/basic__no_frontmatter_.snap b/internal/printer/__snapshots__/basic__no_frontmatter_.snap new file mode 100755 index 000000000..992e68815 --- /dev/null +++ b/internal/printer/__snapshots__/basic__no_frontmatter_.snap @@ -0,0 +1,41 @@ + +[TestPrinter/basic_(no_frontmatter) - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/basic_renderHead.snap b/internal/printer/__snapshots__/basic_renderHead.snap new file mode 100755 index 000000000..b5fa910da --- /dev/null +++ b/internal/printer/__snapshots__/basic_renderHead.snap @@ -0,0 +1,41 @@ + +[TestPrinter/basic_renderHead - 1] +## Input + +``` +Ah +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`Ah${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/caption_only.snap b/internal/printer/__snapshots__/caption_only.snap new file mode 100755 index 000000000..25deb9e0e --- /dev/null +++ b/internal/printer/__snapshots__/caption_only.snap @@ -0,0 +1,41 @@ + +[TestPrinter/caption_only - 1] +## Input + +``` +Hello world! +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}Hello world!`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/class_and_class_list_object.snap b/internal/printer/__snapshots__/class_and_class_list_object.snap new file mode 100755 index 000000000..8d1e55353 --- /dev/null +++ b/internal/printer/__snapshots__/class_and_class_list_object.snap @@ -0,0 +1,41 @@ + +[TestPrinter/class_and_class_list_object - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/class_and_class_list_set.snap b/internal/printer/__snapshots__/class_and_class_list_set.snap new file mode 100755 index 000000000..58149cad6 --- /dev/null +++ b/internal/printer/__snapshots__/class_and_class_list_set.snap @@ -0,0 +1,41 @@ + +[TestPrinter/class_and_class_list_set - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/class_and_class_list_simple_array.snap b/internal/printer/__snapshots__/class_and_class_list_simple_array.snap new file mode 100755 index 000000000..a22a7e365 --- /dev/null +++ b/internal/printer/__snapshots__/class_and_class_list_simple_array.snap @@ -0,0 +1,41 @@ + +[TestPrinter/class_and_class_list_simple_array - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/class_list.snap b/internal/printer/__snapshots__/class_list.snap new file mode 100755 index 000000000..bfa9bb627 --- /dev/null +++ b/internal/printer/__snapshots__/class_list.snap @@ -0,0 +1,41 @@ + +[TestPrinter/class_list - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/class_list_with_spread.snap b/internal/printer/__snapshots__/class_list_with_spread.snap new file mode 100755 index 000000000..2243489b9 --- /dev/null +++ b/internal/printer/__snapshots__/class_list_with_spread.snap @@ -0,0 +1,45 @@ + +[TestPrinter/class:list_with_spread - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/class_with_spread.snap b/internal/printer/__snapshots__/class_with_spread.snap new file mode 100755 index 000000000..b0aa07b43 --- /dev/null +++ b/internal/printer/__snapshots__/class_with_spread.snap @@ -0,0 +1,45 @@ + +[TestPrinter/class_with_spread - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/client_only_component__default_.snap b/internal/printer/__snapshots__/client_only_component__default_.snap new file mode 100755 index 000000000..efbac84c8 --- /dev/null +++ b/internal/printer/__snapshots__/client_only_component__default_.snap @@ -0,0 +1,58 @@ + +[TestPrinter/client:only_component_(default) - 1] +## Input + +``` +/-/-/-/ +import Component from '../components'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Component from '../components'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: ['../components'], hydrationDirectives: new Set(['only']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'Component',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/client_only_component__multiple_.snap b/internal/printer/__snapshots__/client_only_component__multiple_.snap new file mode 100755 index 000000000..5a83903cd --- /dev/null +++ b/internal/printer/__snapshots__/client_only_component__multiple_.snap @@ -0,0 +1,62 @@ + +[TestPrinter/client:only_component_(multiple) - 1] +## Input + +``` +/-/-/-/ +import Component from '../components'; +/-/-/-/ + + + Hello world + + + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Component from '../components'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: ['../components'], hydrationDirectives: new Set(['only']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'Component',null,{"test":"a","client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} + ${$$renderComponent($$result,'Component',null,{"test":"b","client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} + ${$$renderComponent($$result,'Component',null,{"test":"c","client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/client_only_component__named_.snap b/internal/printer/__snapshots__/client_only_component__named_.snap new file mode 100755 index 000000000..dd1cfcf84 --- /dev/null +++ b/internal/printer/__snapshots__/client_only_component__named_.snap @@ -0,0 +1,58 @@ + +[TestPrinter/client:only_component_(named) - 1] +## Input + +``` +/-/-/-/ +import { Component } from '../components'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import { Component } from '../components'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: ['../components'], hydrationDirectives: new Set(['only']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'Component',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"Component"})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/client_only_component__namespace_.snap b/internal/printer/__snapshots__/client_only_component__namespace_.snap new file mode 100755 index 000000000..270f8c2e0 --- /dev/null +++ b/internal/printer/__snapshots__/client_only_component__namespace_.snap @@ -0,0 +1,58 @@ + +[TestPrinter/client:only_component_(namespace) - 1] +## Input + +``` +/-/-/-/ +import * as components from '../components'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import * as components from '../components'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: ['../components'], hydrationDirectives: new Set(['only']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'components.A',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"A"})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/client_only_component__namespaced_default_.snap b/internal/printer/__snapshots__/client_only_component__namespaced_default_.snap new file mode 100755 index 000000000..9fa008ef7 --- /dev/null +++ b/internal/printer/__snapshots__/client_only_component__namespaced_default_.snap @@ -0,0 +1,58 @@ + +[TestPrinter/client:only_component_(namespaced_default) - 1] +## Input + +``` +/-/-/-/ +import defaultImport from '../components/ui-1'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import defaultImport from '../components/ui-1'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: ['../components/ui-1'], hydrationDirectives: new Set(['only']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'defaultImport.Counter1',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components/ui-1")),"client:component-export":"default.Counter1"})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/client_only_component__namespaced_named_.snap b/internal/printer/__snapshots__/client_only_component__namespaced_named_.snap new file mode 100755 index 000000000..bf3a677a4 --- /dev/null +++ b/internal/printer/__snapshots__/client_only_component__namespaced_named_.snap @@ -0,0 +1,58 @@ + +[TestPrinter/client:only_component_(namespaced_named) - 1] +## Input + +``` +/-/-/-/ +import { namedImport } from '../components/ui-2'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import { namedImport } from '../components/ui-2'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: ['../components/ui-2'], hydrationDirectives: new Set(['only']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'namedImport.Counter2',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components/ui-2")),"client:component-export":"namedImport.Counter2"})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/comment_only_expressions_are_removed_I.snap b/internal/printer/__snapshots__/comment_only_expressions_are_removed_I.snap new file mode 100755 index 000000000..aa1e473dd --- /dev/null +++ b/internal/printer/__snapshots__/comment_only_expressions_are_removed_I.snap @@ -0,0 +1,41 @@ + +[TestPrinter/comment_only_expressions_are_removed_I - 1] +## Input + +``` +{/* a comment 1 */}

{/* a comment 2*/}Hello

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

Hello

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/comment_only_expressions_are_removed_II.snap b/internal/printer/__snapshots__/comment_only_expressions_are_removed_II.snap new file mode 100755 index 000000000..0b7df2b8f --- /dev/null +++ b/internal/printer/__snapshots__/comment_only_expressions_are_removed_II.snap @@ -0,0 +1,53 @@ + +[TestPrinter/comment_only_expressions_are_removed_II - 1] +## Input + +``` +{ + list.map((i) => ( + + { + // hello + } + + )) +} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${ + list.map((i) => ( + $$render`${$$renderComponent($$result,'Component',Component,{},{})}` + )) +}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/comment_only_expressions_are_removed_III.snap b/internal/printer/__snapshots__/comment_only_expressions_are_removed_III.snap new file mode 100755 index 000000000..d3d9be19f --- /dev/null +++ b/internal/printer/__snapshots__/comment_only_expressions_are_removed_III.snap @@ -0,0 +1,53 @@ + +[TestPrinter/comment_only_expressions_are_removed_III - 1] +## Input + +``` +{ + list.map((i) => ( + + { + /* hello */ + } + + )) +} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${ + list.map((i) => ( + $$render`${$$renderComponent($$result,'Component',Component,{},{})}` + )) +}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/comments_removed_from_attribute_list.snap b/internal/printer/__snapshots__/comments_removed_from_attribute_list.snap new file mode 100755 index 000000000..6f0fdc5f1 --- /dev/null +++ b/internal/printer/__snapshots__/comments_removed_from_attribute_list.snap @@ -0,0 +1,41 @@ + +[TestPrinter/comments_removed_from_attribute_list - 1] +## Input + +``` +

Hello

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

Hello

${$$renderComponent($$result,'Component',Component,{"value":"1",})}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/complex_nested_template_literal_expression.snap b/internal/printer/__snapshots__/complex_nested_template_literal_expression.snap new file mode 100755 index 000000000..947c5084f --- /dev/null +++ b/internal/printer/__snapshots__/complex_nested_template_literal_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/complex_nested_template_literal_expression - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/complex_recursive_component.snap b/internal/printer/__snapshots__/complex_recursive_component.snap new file mode 100755 index 000000000..b18163aa5 --- /dev/null +++ b/internal/printer/__snapshots__/complex_recursive_component.snap @@ -0,0 +1,45 @@ + +[TestPrinter/complex_recursive_component - 1] +## Input + +``` +{(`} />{Node.children.map((child) => ())}`} />)} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/projects/app/src/components/RenderNode.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$RenderNode = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$RenderNode; + +return $$render`${($$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${$$unescapeHTML(`<${Node.tag} ${stringifyAttributes(Node.attributes)}>`)}`,})}${Node.children.map((child) => ($$render`${$$renderComponent($$result,'Astro.self',Astro.self,{"node":(child)})}`))}${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${$$unescapeHTML(``)}`,})}`,})}`)}`; +}, '/projects/app/src/components/RenderNode.astro', undefined); +export default $$RenderNode; +``` +--- diff --git a/internal/printer/__snapshots__/complex_table.snap b/internal/printer/__snapshots__/complex_table.snap new file mode 100755 index 000000000..2ccfb7a3d --- /dev/null +++ b/internal/printer/__snapshots__/complex_table.snap @@ -0,0 +1,131 @@ + +[TestPrinter/complex_table - 1] +## Input + +``` + + + + + Astro Multi Table + + +
+
+ {Array(3).fill(false).map((item, idx) =>
+
+ {'a'} + + + + <>{Array(7).fill(false).map((entry, index) => )} + + + + + +
A
+
+
)} +
+
+
+ + + + + + + + + + + +
BBB
+
+
+
+ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render` + + + + Astro Multi Table + ${$$renderHead($$result)} + +
+
+ ${Array(3).fill(false).map((item, idx) => $$render`
+
+ ${'a'} + + + + ${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${Array(7).fill(false).map((entry, index) => $$render``)}`,})} + + + + + +
A
+
+
`)} +
+
+
+ + + + + + + + + + + +
BBB
+
+
+
+ +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/component.snap b/internal/printer/__snapshots__/component.snap new file mode 100755 index 000000000..9eca5e784 --- /dev/null +++ b/internal/printer/__snapshots__/component.snap @@ -0,0 +1,60 @@ + +[TestPrinter/component - 1] +## Input + +``` +/-/-/-/ +import VueComponent from '../components/Vue.vue'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import VueComponent from '../components/Vue.vue'; + +import * as $$module1 from '../components/Vue.vue'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: '../components/Vue.vue', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'VueComponent',VueComponent,{})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/component_in_expression_with_its_child_expression_before_its_child_element.snap b/internal/printer/__snapshots__/component_in_expression_with_its_child_expression_before_its_child_element.snap new file mode 100755 index 000000000..0818708b8 --- /dev/null +++ b/internal/printer/__snapshots__/component_in_expression_with_its_child_expression_before_its_child_element.snap @@ -0,0 +1,41 @@ + +[TestPrinter/component_in_expression_with_its_child_expression_before_its_child_element - 1] +## Input + +``` +{list.map(() => ({name}))} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${list.map(() => ($$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${name}`,})}`))}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/component_with_only_a_script.snap b/internal/printer/__snapshots__/component_with_only_a_script.snap new file mode 100755 index 000000000..9209c351e --- /dev/null +++ b/internal/printer/__snapshots__/component_with_only_a_script.snap @@ -0,0 +1,41 @@ + +[TestPrinter/component_with_only_a_script - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log('hello world');` }] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/component_with_quoted_attributes.snap b/internal/printer/__snapshots__/component_with_quoted_attributes.snap new file mode 100755 index 000000000..30ad56a59 --- /dev/null +++ b/internal/printer/__snapshots__/component_with_quoted_attributes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/component_with_quoted_attributes - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{"is":"\"cool\""})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/condition_expressions_at_the_top-level.snap b/internal/printer/__snapshots__/condition_expressions_at_the_top-level.snap new file mode 100755 index 000000000..dd37e7463 --- /dev/null +++ b/internal/printer/__snapshots__/condition_expressions_at_the_top-level.snap @@ -0,0 +1,41 @@ + +[TestPrinter/condition_expressions_at_the_top-level - 1] +## Input + +``` +{cond && }{cond && } +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${cond && $$render`${$$maybeRenderHead($$result)}`}${cond && $$render``}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/condition_expressions_at_the_top-level_with_head_content.snap b/internal/printer/__snapshots__/condition_expressions_at_the_top-level_with_head_content.snap new file mode 100755 index 000000000..e935fca0a --- /dev/null +++ b/internal/printer/__snapshots__/condition_expressions_at_the_top-level_with_head_content.snap @@ -0,0 +1,41 @@ + +[TestPrinter/condition_expressions_at_the_top-level_with_head_content - 1] +## Input + +``` +{cond && }{cond && My title} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${cond && $$render``}${cond && $$render`My title`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/conditional_iframe.snap b/internal/printer/__snapshots__/conditional_iframe.snap new file mode 100755 index 000000000..633c11277 --- /dev/null +++ b/internal/printer/__snapshots__/conditional_iframe.snap @@ -0,0 +1,41 @@ + +[TestPrinter/conditional_iframe - 1] +## Input + +``` +{bool && } +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${bool && $$render`${$$maybeRenderHead($$result)}`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/conditional_noscript.snap b/internal/printer/__snapshots__/conditional_noscript.snap new file mode 100755 index 000000000..8a313b772 --- /dev/null +++ b/internal/printer/__snapshots__/conditional_noscript.snap @@ -0,0 +1,41 @@ + +[TestPrinter/conditional_noscript - 1] +## Input + +``` +{mode === "production" && } +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${mode === "production" && $$render`${$$maybeRenderHead($$result)}`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/conditional_render.snap b/internal/printer/__snapshots__/conditional_render.snap new file mode 100755 index 000000000..8fbfb68fe --- /dev/null +++ b/internal/printer/__snapshots__/conditional_render.snap @@ -0,0 +1,41 @@ + +[TestPrinter/conditional_render - 1] +## Input + +``` +{false ?
#f
:
#t
} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${false ? $$render`
#f
` : $$render`
#t
`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/conditional_rendering_of_title_containing_expression.snap b/internal/printer/__snapshots__/conditional_rendering_of_title_containing_expression.snap new file mode 100755 index 000000000..63509cfa5 --- /dev/null +++ b/internal/printer/__snapshots__/conditional_rendering_of_title_containing_expression.snap @@ -0,0 +1,57 @@ + +[TestPrinter/conditional_rendering_of_title_containing_expression - 1] +## Input + +``` +{ + props.title && ( + <> + {props.title} + + + + ) +} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${ + props.title && ( + $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + ${props.title} + + + `,})}` + ) +}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/conditional_slot.snap b/internal/printer/__snapshots__/conditional_slot.snap new file mode 100755 index 000000000..2d863a417 --- /dev/null +++ b/internal/printer/__snapshots__/conditional_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/conditional_slot - 1] +## Input + +``` +{value &&
foo
}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"test": () => $$render`${value && $$render`${$$maybeRenderHead($$result)}
foo
`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git "a/internal/printer/__snapshots__/css_comment_doesn\342\200\231t_produce_semicolon.snap" "b/internal/printer/__snapshots__/css_comment_doesn\342\200\231t_produce_semicolon.snap" new file mode 100755 index 000000000..b1af7b64c --- /dev/null +++ "b/internal/printer/__snapshots__/css_comment_doesn\342\200\231t_produce_semicolon.snap" @@ -0,0 +1,44 @@ + +[TestPrinter/css_comment_doesn’t_produce_semicolon - 1] +## Input + +``` +
My Text
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
My Text
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/css_imports_are_not_included_in_module_metadata.snap b/internal/printer/__snapshots__/css_imports_are_not_included_in_module_metadata.snap new file mode 100755 index 000000000..04f26da00 --- /dev/null +++ b/internal/printer/__snapshots__/css_imports_are_not_included_in_module_metadata.snap @@ -0,0 +1,44 @@ + +[TestPrinter/css_imports_are_not_included_in_module_metadata - 1] +## Input + +``` +/-/-/-/ + import './styles.css'; + --- +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import './styles.css'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/custom-element.snap b/internal/printer/__snapshots__/custom-element.snap new file mode 100755 index 000000000..1aa837bc4 --- /dev/null +++ b/internal/printer/__snapshots__/custom-element.snap @@ -0,0 +1,41 @@ + +[TestPrinter/custom-element - 1] +## Input + +``` +{show && } +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${show && $$render`${$$renderComponent($$result,'client-only-element','client-only-element',{})}`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/custom_elements.snap b/internal/printer/__snapshots__/custom_elements.snap new file mode 100755 index 000000000..794fbbeb3 --- /dev/null +++ b/internal/printer/__snapshots__/custom_elements.snap @@ -0,0 +1,47 @@ + +[TestPrinter/custom_elements - 1] +## Input + +``` +/-/-/-/ +import 'test'; +/-/-/-/ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import 'test'; + +import * as $$module1 from 'test'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'my-element','my-element',{})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_a_module_script_with_imports.snap b/internal/printer/__snapshots__/define_vars_on_a_module_script_with_imports.snap new file mode 100755 index 000000000..dd9db1a1a --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_a_module_script_with_imports.snap @@ -0,0 +1,41 @@ + +[TestPrinter/define:vars_on_a_module_script_with_imports - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_non-root_elements.snap b/internal/printer/__snapshots__/define_vars_on_non-root_elements.snap new file mode 100755 index 000000000..0990d8305 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_non-root_elements.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_non-root_elements - 1] +## Input + +``` +{true ?

foo

:

bar

} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${true ? $$render`${$$maybeRenderHead($$result)}

foo

` : $$render`

bar

`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_script_with_StaticExpression_turned_on.snap b/internal/printer/__snapshots__/define_vars_on_script_with_StaticExpression_turned_on.snap new file mode 100755 index 000000000..88fc47e28 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_script_with_StaticExpression_turned_on.snap @@ -0,0 +1,41 @@ + +[TestPrinter/define:vars_on_script_with_StaticExpression_turned_on - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `var two = 'two';` }] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_style.snap b/internal/printer/__snapshots__/define_vars_on_style.snap new file mode 100755 index 000000000..738a717a2 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_style.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_style - 1] +## Input + +``` +

testing

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}

testing

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap new file mode 100755 index 000000000..218b4e5f2 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_style_tag_with_style_empty_attribute_on_element - 1] +## Input + +``` +

testing

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}testing`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap new file mode 100755 index 000000000..6b21cbc67 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_style_tag_with_style_expression_attribute_on_element - 1] +## Input + +``` +

testing

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}testing`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap new file mode 100755 index 000000000..c015f3742 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_style_tag_with_style_quoted_attribute_on_element - 1] +## Input + +``` +

testing

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}testing`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap new file mode 100755 index 000000000..aec56ae08 --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_style_tag_with_style_shorthand_attribute_on_element - 1] +## Input + +``` +

testing

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}testing`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap new file mode 100755 index 000000000..6a909777b --- /dev/null +++ b/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap @@ -0,0 +1,42 @@ + +[TestPrinter/define:vars_on_style_tag_with_style_template_literal_attribute_on_element - 1] +## Input + +``` +

testing

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}testing`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/division_inside_expression.snap b/internal/printer/__snapshots__/division_inside_expression.snap new file mode 100755 index 000000000..c487a3a6e --- /dev/null +++ b/internal/printer/__snapshots__/division_inside_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/division_inside_expression - 1] +## Input + +``` +
{16 / 4}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${16 / 4}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/doctype.snap b/internal/printer/__snapshots__/doctype.snap new file mode 100755 index 000000000..18f3251ee --- /dev/null +++ b/internal/printer/__snapshots__/doctype.snap @@ -0,0 +1,41 @@ + +[TestPrinter/doctype - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/dot_component.snap b/internal/printer/__snapshots__/dot_component.snap new file mode 100755 index 000000000..682318f4a --- /dev/null +++ b/internal/printer/__snapshots__/dot_component.snap @@ -0,0 +1,60 @@ + +[TestPrinter/dot_component - 1] +## Input + +``` +/-/-/-/ +import * as ns from '../components'; +/-/-/-/ + + + Hello world + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import * as ns from '../components'; + +import * as $$module1 from '../components'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: '../components', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + Hello world + ${$$renderHead($$result)} + + ${$$renderComponent($$result,'ns.Component',ns.Component,{})} + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/dynamic_import.snap b/internal/printer/__snapshots__/dynamic_import.snap new file mode 100755 index 000000000..660742d98 --- /dev/null +++ b/internal/printer/__snapshots__/dynamic_import.snap @@ -0,0 +1,52 @@ + +[TestPrinter/dynamic_import - 1] +## Input + +``` +/-/-/-/ +const markdownDocs = await Astro.glob('../markdown/*.md') +const article2 = await import('../markdown/article2.md') +/-/-/-/ +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(async ($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +const markdownDocs = await Astro.glob('../markdown/*.md') +const article2 = await import('../markdown/article2.md') + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/escaped_entity.snap b/internal/printer/__snapshots__/escaped_entity.snap new file mode 100755 index 000000000..feb0ec59e --- /dev/null +++ b/internal/printer/__snapshots__/escaped_entity.snap @@ -0,0 +1,41 @@ + +[TestPrinter/escaped_entity - 1] +## Input + +``` +A person saying "hello" +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}A person saying "hello"`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/export_comments_I.snap b/internal/printer/__snapshots__/export_comments_I.snap new file mode 100755 index 000000000..fe9dc61e2 --- /dev/null +++ b/internal/printer/__snapshots__/export_comments_I.snap @@ -0,0 +1,52 @@ + +[TestPrinter/export_comments_I - 1] +## Input + +``` +/-/-/-/ +// hmm +export const foo = 0 +/* +*/ +/-/-/-/ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +export const foo = 0 + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +// hmm +/* +*/ + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/export_comments_II.snap b/internal/printer/__snapshots__/export_comments_II.snap new file mode 100755 index 000000000..c25a7f5c1 --- /dev/null +++ b/internal/printer/__snapshots__/export_comments_II.snap @@ -0,0 +1,52 @@ + +[TestPrinter/export_comments_II - 1] +## Input + +``` +/-/-/-/ +// hmm +export const foo = 0; +/* +*/ +/-/-/-/ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +export const foo = 0; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +// hmm + +/* +*/ + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/export_member_does_not_panic.snap b/internal/printer/__snapshots__/export_member_does_not_panic.snap new file mode 100755 index 000000000..d29211e2f --- /dev/null +++ b/internal/printer/__snapshots__/export_member_does_not_panic.snap @@ -0,0 +1,46 @@ + +[TestPrinter/export_member_does_not_panic - 1] +## Input + +``` +/-/-/-/ +mod.export(); +/-/-/-/ +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +mod.export(); + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/expression_returning_multiple_elements.snap b/internal/printer/__snapshots__/expression_returning_multiple_elements.snap new file mode 100755 index 000000000..536a09632 --- /dev/null +++ b/internal/printer/__snapshots__/expression_returning_multiple_elements.snap @@ -0,0 +1,89 @@ + +[TestPrinter/expression_returning_multiple_elements - 1] +## Input + +``` + +
+

Welcome to Astro

+ { + Object.entries(DUMMY_DATA).map(([dummyKey, dummyValue]) => { + return ( +

+ onlyp {dummyKey} +

+

+ onlyh2 {dummyKey} +

+
+

div+h2 {dummyKey}

+
+

+

p+h2 {dummyKey}

+

+ ); + }) + } +
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$renderComponent($$result,'Layout',Layout,{"title":"Welcome to Astro."},{"default": () => $$render` + ${$$maybeRenderHead($$result)}
+

Welcome to Astro

+ ${ + Object.entries(DUMMY_DATA).map(([dummyKey, dummyValue]) => { + return ( + $$render`

+ onlyp ${dummyKey} +

+

+ onlyh2 ${dummyKey} +

+
+

div+h2 ${dummyKey}

+
+

+

p+h2 ${dummyKey}

+ ` + ); + }) + } +
+`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/expression_slot.snap b/internal/printer/__snapshots__/expression_slot.snap new file mode 100755 index 000000000..1392c83b9 --- /dev/null +++ b/internal/printer/__snapshots__/expression_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/expression_slot - 1] +## Input + +``` +{true &&
A
}{false &&
B
}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"a": () => $$render`${true && $$render`${$$maybeRenderHead($$result)}
A
`}`,"b": () => $$render`${false && $$render`
B
`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/expression_with_leading_whitespace.snap b/internal/printer/__snapshots__/expression_with_leading_whitespace.snap new file mode 100755 index 000000000..ebb720984 --- /dev/null +++ b/internal/printer/__snapshots__/expression_with_leading_whitespace.snap @@ -0,0 +1,55 @@ + +[TestPrinter/expression_with_leading_whitespace - 1] +## Input + +``` +
+
    + { +
  • Build: { new Date().toISOString() }
  • +
  • NODE_VERSION: { process.env.NODE_VERSION }
  • + } +
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
+
    + ${ + $$render`
  • Build: ${ new Date().toISOString() }
  • +
  • NODE_VERSION: ${ process.env.NODE_VERSION }
  • ` + } +
+
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/expressions_with_JS_comments.snap b/internal/printer/__snapshots__/expressions_with_JS_comments.snap new file mode 100755 index 000000000..d663f5d2c --- /dev/null +++ b/internal/printer/__snapshots__/expressions_with_JS_comments.snap @@ -0,0 +1,62 @@ + +[TestPrinter/expressions_with_JS_comments - 1] +## Input + +``` +/-/-/-/ +const items = ['red', 'yellow', 'blue']; +/-/-/-/ +
+ {items.map((item) => ( + // foo < > < } +
color
+ ))} + {items.map((item) => ( + /* foo < > < } */
color
+ ))} +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const items = ['red', 'yellow', 'blue']; + +return $$render`${$$maybeRenderHead($$result)}
+ ${items.map((item) => ( + // foo < > < } + $$render`color
` + ))} + ${items.map((item) => ( + /* foo < > < } */ $$render`color
` + ))} +
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/expressions_with_multiple_curly_braces.snap b/internal/printer/__snapshots__/expressions_with_multiple_curly_braces.snap new file mode 100755 index 000000000..752722b52 --- /dev/null +++ b/internal/printer/__snapshots__/expressions_with_multiple_curly_braces.snap @@ -0,0 +1,61 @@ + +[TestPrinter/expressions_with_multiple_curly_braces - 1] +## Input + +``` +
+{ + () => { + let generate = (input) => { + let a = () => { return; }; + let b = () => { return; }; + let c = () => { return; }; + }; + } +} +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
+${ + () => { + let generate = (input) => { + let a = () => { return; }; + let b = () => { return; }; + let c = () => { return; }; + }; + } +} +
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/function_expression_slots_I.snap b/internal/printer/__snapshots__/function_expression_slots_I.snap new file mode 100755 index 000000000..c7fb2c4b2 --- /dev/null +++ b/internal/printer/__snapshots__/function_expression_slots_I.snap @@ -0,0 +1,53 @@ + +[TestPrinter/function_expression_slots_I - 1] +## Input + +``` + +{() => { switch (value) { +case 'a': return
A
+case 'b': return
B
+case 'c': return
C
+} +}} +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},$$mergeSlots({},() => { switch (value) { +case 'a': return {"a": () => $$render`${$$maybeRenderHead($$result)}
A
`} +case 'b': return {"b": () => $$render`
B
`} +case 'c': return {"c": () => $$render`
C
`} +} +}))}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/function_expression_slots_II___959_.snap b/internal/printer/__snapshots__/function_expression_slots_II___959_.snap new file mode 100755 index 000000000..54d22d1c2 --- /dev/null +++ b/internal/printer/__snapshots__/function_expression_slots_II___959_.snap @@ -0,0 +1,69 @@ + +[TestPrinter/function_expression_slots_II_(#959) - 1] +## Input + +``` + +
+ + {components.map((component, i) => { + switch(component) { + case "Hero": + return
Hero
+ case "Component2": + return
Component2
+ } + })} +
+
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$renderComponent($$result,'Layout',Layout,{"title":"Welcome to Astro."},{"default": () => $$render` + ${$$maybeRenderHead($$result)}
+ ${$$renderComponent($$result,'Layout',Layout,{"title":"switch bug"},{"default": () => $$render`${components.map((component, i) => { + switch(component) { + case "Hero": + return $$render`
Hero
` + case "Component2": + return $$render`
Component2
` + } + })}`,})} +
+`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/getStaticPaths__basic_.snap b/internal/printer/__snapshots__/getStaticPaths__basic_.snap new file mode 100755 index 000000000..8b46fb2e6 --- /dev/null +++ b/internal/printer/__snapshots__/getStaticPaths__basic_.snap @@ -0,0 +1,49 @@ + +[TestPrinter/getStaticPaths_(basic) - 1] +## Input + +``` +/-/-/-/ +export const getStaticPaths = async () => { + return { paths: [] } +} +/-/-/-/ +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +export const getStaticPaths = async () => { + return { paths: [] } +} +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/getStaticPaths__hoisted_.snap b/internal/printer/__snapshots__/getStaticPaths__hoisted_.snap new file mode 100755 index 000000000..b48a4f2ac --- /dev/null +++ b/internal/printer/__snapshots__/getStaticPaths__hoisted_.snap @@ -0,0 +1,52 @@ + +[TestPrinter/getStaticPaths_(hoisted) - 1] +## Input + +``` +/-/-/-/ +const a = 0; +export const getStaticPaths = async () => { + return { paths: [] } +} +/-/-/-/ +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +export const getStaticPaths = async () => { + return { paths: [] } +} +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const a = 0; + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/getStaticPaths__hoisted_II_.snap b/internal/printer/__snapshots__/getStaticPaths__hoisted_II_.snap new file mode 100755 index 000000000..43859a3bf --- /dev/null +++ b/internal/printer/__snapshots__/getStaticPaths__hoisted_II_.snap @@ -0,0 +1,55 @@ + +[TestPrinter/getStaticPaths_(hoisted_II) - 1] +## Input + +``` +/-/-/-/ +const a = 0; +export async function getStaticPaths() { + return { paths: [] } +} +const b = 0; +/-/-/-/ +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +export async function getStaticPaths() { + return { paths: [] } +} +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const a = 0; + +const b = 0; + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/gets_all_potential_hydrated_components.snap b/internal/printer/__snapshots__/gets_all_potential_hydrated_components.snap new file mode 100755 index 000000000..ca5db5972 --- /dev/null +++ b/internal/printer/__snapshots__/gets_all_potential_hydrated_components.snap @@ -0,0 +1,60 @@ + +[TestPrinter/gets_all_potential_hydrated_components - 1] +## Input + +``` +/-/-/-/ +import One from 'one'; +import Two from 'two'; +import 'custom-element'; +const name = 'world'; +/-/-/-/ + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import One from 'one'; +import Two from 'two'; +import 'custom-element'; + +import * as $$module1 from 'one'; +import * as $$module2 from 'two'; +import * as $$module3 from 'custom-element'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'one', assert: {} }, { module: $$module2, specifier: 'two', assert: {} }, { module: $$module3, specifier: 'custom-element', assert: {} }], hydratedComponents: ['my-element', Two, One], clientOnlyComponents: [], hydrationDirectives: new Set(['load']), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const name = 'world'; + +return $$render`${$$renderComponent($$result,'One',One,{"client:load":true,"client:component-hydration":"load","client:component-path":("one"),"client:component-export":("default")})} +${$$renderComponent($$result,'Two',Two,{"client:load":true,"client:component-hydration":"load","client:component-path":("two"),"client:component-export":("default")})} +${$$renderComponent($$result,'my-element','my-element',{"client:load":true,"client:component-hydration":"load"})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/head_expression.snap b/internal/printer/__snapshots__/head_expression.snap new file mode 100755 index 000000000..93092dca0 --- /dev/null +++ b/internal/printer/__snapshots__/head_expression.snap @@ -0,0 +1,59 @@ + +[TestPrinter/head_expression - 1] +## Input + +``` +/-/-/-/ +const name = "world"; +/-/-/-/ + + + Hello {name} + + +
+ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const name = "world"; + +return $$render` + + Hello ${name} + ${$$renderHead($$result)} + +
+ `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/head_expression_and_conditional_rendering_of_fragment.snap b/internal/printer/__snapshots__/head_expression_and_conditional_rendering_of_fragment.snap new file mode 100755 index 000000000..cbfdeead2 --- /dev/null +++ b/internal/printer/__snapshots__/head_expression_and_conditional_rendering_of_fragment.snap @@ -0,0 +1,63 @@ + +[TestPrinter/head_expression_and_conditional_rendering_of_fragment - 1] +## Input + +``` +/-/-/-/ +const testBool = true; +/-/-/-/ + + + + {testBool ? "Hey" : "Bye"} + {testBool && (<>)} + + +
+ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const testBool = true; + +return $$render` + + + ${testBool ? "Hey" : "Bye"} + ${testBool && ($$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render``,})}`)} + ${$$renderHead($$result)} + +
+ `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/head_inside_slot.snap b/internal/printer/__snapshots__/head_inside_slot.snap new file mode 100755 index 000000000..83fe49596 --- /dev/null +++ b/internal/printer/__snapshots__/head_inside_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/head_inside_slot - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderSlot($$result,$$slots["default"],$$render`${$$renderHead($$result)}`)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/head_slot.snap b/internal/printer/__snapshots__/head_slot.snap new file mode 100755 index 000000000..3c647e576 --- /dev/null +++ b/internal/printer/__snapshots__/head_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/head_slot - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderSlot($$result,$$slots["default"])}${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/head_slot_II.snap b/internal/printer/__snapshots__/head_slot_II.snap new file mode 100755 index 000000000..e34674c30 --- /dev/null +++ b/internal/printer/__snapshots__/head_slot_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/head_slot_II - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderSlot($$result,$$slots["default"])}${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/head_slot_III.snap b/internal/printer/__snapshots__/head_slot_III.snap new file mode 100755 index 000000000..ba21336d5 --- /dev/null +++ b/internal/printer/__snapshots__/head_slot_III.snap @@ -0,0 +1,41 @@ + +[TestPrinter/head_slot_III - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderSlot($$result,$$slots["baseHeadExtension"],$$render``)}${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/html5_boilerplate.snap b/internal/printer/__snapshots__/html5_boilerplate.snap new file mode 100755 index 000000000..d17075fda --- /dev/null +++ b/internal/printer/__snapshots__/html5_boilerplate.snap @@ -0,0 +1,97 @@ + +[TestPrinter/html5_boilerplate - 1] +## Input + +``` + + + + + + + + A Basic HTML5 Template + + + + + + + + + + + + + + + + + + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + + + + A Basic HTML5 Template + + + + + + + + + + + + + + + +${$$renderHead($$result)} + + + + + +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/iframe.snap b/internal/printer/__snapshots__/iframe.snap new file mode 100755 index 000000000..c08306a64 --- /dev/null +++ b/internal/printer/__snapshots__/iframe.snap @@ -0,0 +1,41 @@ + +[TestPrinter/iframe - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/import.meta.env.snap b/internal/printer/__snapshots__/import.meta.env.snap new file mode 100755 index 000000000..a2bdb6686 --- /dev/null +++ b/internal/printer/__snapshots__/import.meta.env.snap @@ -0,0 +1,129 @@ + +[TestPrinter/import.meta.env - 1] +## Input + +``` +/-/-/-/ +import Header from '../../components/Header.jsx' +import Footer from '../../components/Footer.astro' +import ProductPageContent from '../../components/ProductPageContent.jsx'; + +export async function getStaticPaths() { + let products = await fetch(`${import.meta.env.PUBLIC_NETLIFY_URL}/.netlify/functions/get-product-list`) + .then(res => res.json()).then((response) => { + console.log('--- built product pages ---') + return response.products.edges + }); + + return products.map((p, i) => { + return { + params: {pid: p.node.handle}, + props: {product: p}, + }; + }); +} + +const { product } = Astro.props; +/-/-/-/ + + + + + + + Shoperoni | Buy {product.node.title} + + + + + +
+
+
+ +
+
+
+ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Header from '../../components/Header.jsx' + +import Footer from '../../components/Footer.astro' + +import ProductPageContent from '../../components/ProductPageContent.jsx'; + +import * as $$module1 from '../../components/Header.jsx'; +import * as $$module2 from '../../components/Footer.astro'; +import * as $$module3 from '../../components/ProductPageContent.jsx'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: '../../components/Header.jsx', assert: {} }, { module: $$module2, specifier: '../../components/Footer.astro', assert: {} }, { module: $$module3, specifier: '../../components/ProductPageContent.jsx', assert: {} }], hydratedComponents: [ProductPageContent], clientOnlyComponents: [], hydrationDirectives: new Set(['visible']), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +export async function getStaticPaths() { + let products = await fetch(`${import.meta.env.PUBLIC_NETLIFY_URL}/.netlify/functions/get-product-list`) + .then(res => res.json()).then((response) => { + console.log('--- built product pages ---') + return response.products.edges + }); + + return products.map((p, i) => { + return { + params: {pid: p.node.handle}, + props: {product: p}, + }; + }); +} +const $$Component = $$createComponent(async ($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +const { product } = Astro.props; + +return $$render` + + + + Shoperoni | Buy ${product.node.title} + + + +${$$renderHead($$result)} + + ${$$renderComponent($$result,'Header',Header,{})} +
+
+ ${$$renderComponent($$result,'ProductPageContent',ProductPageContent,{"client:visible":true,"product":(product.node),"client:component-hydration":"visible","client:component-path":("../../components/ProductPageContent.jsx"),"client:component-export":("default")})} +
+
+ ${$$renderComponent($$result,'Footer',Footer,{})} +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/import.meta.snap b/internal/printer/__snapshots__/import.meta.snap new file mode 100755 index 000000000..93f096a84 --- /dev/null +++ b/internal/printer/__snapshots__/import.meta.snap @@ -0,0 +1,49 @@ + +[TestPrinter/import.meta - 1] +## Input + +``` +/-/-/-/ +const components = import.meta.glob("../components/*.astro", { + import: 'default' +}); +/-/-/-/ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const components = import.meta.glob("../components/*.astro", { + import: 'default' +}); + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/import_assertions.snap b/internal/printer/__snapshots__/import_assertions.snap new file mode 100755 index 000000000..b68650646 --- /dev/null +++ b/internal/printer/__snapshots__/import_assertions.snap @@ -0,0 +1,46 @@ + +[TestPrinter/import_assertions - 1] +## Input + +``` +/-/-/-/ +import data from "test" assert { type: 'json' }; +/-/-/-/ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import data from "test" assert { type: 'json' }; + +import * as $$module1 from 'test' assert {type:'json'}; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {type:'json'} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/import_order.snap b/internal/printer/__snapshots__/import_order.snap new file mode 100755 index 000000000..6c2f452e2 --- /dev/null +++ b/internal/printer/__snapshots__/import_order.snap @@ -0,0 +1,53 @@ + +[TestPrinter/import_order - 1] +## Input + +``` +/-/-/-/ +let testWord = "Test" +// comment +import data from "test"; +/-/-/-/ + +
{data}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import data from "test"; + +import * as $$module1 from 'test'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +let testWord = "Test" +// comment + +return $$render`${$$maybeRenderHead($$result)}
${data}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/import_to_identifier_named_assert.snap b/internal/printer/__snapshots__/import_to_identifier_named_assert.snap new file mode 100755 index 000000000..1d6f469d7 --- /dev/null +++ b/internal/printer/__snapshots__/import_to_identifier_named_assert.snap @@ -0,0 +1,46 @@ + +[TestPrinter/import_to_identifier_named_assert - 1] +## Input + +``` +/-/-/-/ +import assert from 'test'; +/-/-/-/ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import assert from 'test'; + +import * as $$module1 from 'test'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/includes_comments_for_expression_attribute.snap b/internal/printer/__snapshots__/includes_comments_for_expression_attribute.snap new file mode 100755 index 000000000..14dcc8a78 --- /dev/null +++ b/internal/printer/__snapshots__/includes_comments_for_expression_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/includes_comments_for_expression_attribute - 1] +## Input + +``` +

Hello

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
Hello${$$renderComponent($$result,'Component',Component,{"attr":(/* comment 1 */ isTrue ? 1 : 2 /* comment 2 */)})}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/includes_comments_for_shorthand_attribute.snap b/internal/printer/__snapshots__/includes_comments_for_shorthand_attribute.snap new file mode 100755 index 000000000..4bb9c1fa3 --- /dev/null +++ b/internal/printer/__snapshots__/includes_comments_for_shorthand_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/includes_comments_for_shorthand_attribute - 1] +## Input + +``` +

Hello

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
Hello${$$renderComponent($$result,'Component',Component,{"id":(/* comment 1 */ id /* comment 2 */)})}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/is_raw.snap b/internal/printer/__snapshots__/is_raw.snap new file mode 100755 index 000000000..833e8c100 --- /dev/null +++ b/internal/printer/__snapshots__/is_raw.snap @@ -0,0 +1,41 @@ + +[TestPrinter/is:raw - 1] +## Input + +``` +
<% awesome %>
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
<% awesome %>
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/map_basic.snap b/internal/printer/__snapshots__/map_basic.snap new file mode 100755 index 000000000..2f81166f6 --- /dev/null +++ b/internal/printer/__snapshots__/map_basic.snap @@ -0,0 +1,54 @@ + +[TestPrinter/map_basic - 1] +## Input + +``` +/-/-/-/ +const items = [0, 1, 2]; +/-/-/-/ +
    + {items.map(item => { + return
  • {item}
  • ; + })} +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const items = [0, 1, 2]; + +return $$render`${$$maybeRenderHead($$result)}
    + ${items.map(item => { + return $$render`
  • ${item}
  • `; + })} +
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/map_nested.snap b/internal/printer/__snapshots__/map_nested.snap new file mode 100755 index 000000000..8c218e7a7 --- /dev/null +++ b/internal/printer/__snapshots__/map_nested.snap @@ -0,0 +1,62 @@ + +[TestPrinter/map_nested - 1] +## Input + +``` +/-/-/-/ +const groups = [[0, 1, 2], [3, 4, 5]]; +/-/-/-/ +
+ {groups.map(items => { + return
    { + items.map(item => { + return
  • {item}
  • ; + }) + }
+ })} +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const groups = [[0, 1, 2], [3, 4, 5]]; + +return $$render`${$$maybeRenderHead($$result)}
+ ${groups.map(items => { + return $$render`
    ${ + items.map(item => { + return $$render`
  • ${item}
  • `; + }) + }
` + })} +
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/map_with_component.snap b/internal/printer/__snapshots__/map_with_component.snap new file mode 100755 index 000000000..160a073a8 --- /dev/null +++ b/internal/printer/__snapshots__/map_with_component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/map_with_component - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderComponent($$result,'Hello',Hello,{})}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/map_without_component.snap b/internal/printer/__snapshots__/map_without_component.snap new file mode 100755 index 000000000..103e4e91e --- /dev/null +++ b/internal/printer/__snapshots__/map_without_component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/map_without_component - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/maybeRenderHead_not_printed_for_hoisted_scripts.snap b/internal/printer/__snapshots__/maybeRenderHead_not_printed_for_hoisted_scripts.snap new file mode 100755 index 000000000..a640a1749 --- /dev/null +++ b/internal/printer/__snapshots__/maybeRenderHead_not_printed_for_hoisted_scripts.snap @@ -0,0 +1,41 @@ + +[TestPrinter/maybeRenderHead_not_printed_for_hoisted_scripts - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Page = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Layout',Layout,{})}`; +}, '/projects/app/src/pages/page.astro', undefined); +export default $$Page; +``` +--- diff --git a/internal/printer/__snapshots__/multibyte_character_+_script.snap b/internal/printer/__snapshots__/multibyte_character_+_script.snap new file mode 100755 index 000000000..a74ff64f2 --- /dev/null +++ b/internal/printer/__snapshots__/multibyte_character_+_script.snap @@ -0,0 +1,41 @@ + +[TestPrinter/multibyte_character_+_script - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log('foo')` }] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/multibyte_character_+_style.snap b/internal/printer/__snapshots__/multibyte_character_+_style.snap new file mode 100755 index 000000000..90c2c0803 --- /dev/null +++ b/internal/printer/__snapshots__/multibyte_character_+_style.snap @@ -0,0 +1,41 @@ + +[TestPrinter/multibyte_character_+_style - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/multibyte_characters.snap b/internal/printer/__snapshots__/multibyte_characters.snap new file mode 100755 index 000000000..49276e507 --- /dev/null +++ b/internal/printer/__snapshots__/multibyte_characters.snap @@ -0,0 +1,43 @@ + +[TestPrinter/multibyte_characters - 1] +## Input + +``` +/-/-/-/ +/-/-/-/ +

こんにちは

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

こんにちは

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/multiple_define_vars_on_style.snap b/internal/printer/__snapshots__/multiple_define_vars_on_style.snap new file mode 100755 index 000000000..0c082c436 --- /dev/null +++ b/internal/printer/__snapshots__/multiple_define_vars_on_style.snap @@ -0,0 +1,42 @@ + +[TestPrinter/multiple_define:vars_on_style - 1] +## Input + +``` +

foo

bar

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const $$definedVars = $$defineStyleVars([{color:'red'},{color:'green'}]); +return $$render`${$$maybeRenderHead($$result)}

foo

bar

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions.snap b/internal/printer/__snapshots__/nested_expressions.snap new file mode 100755 index 000000000..209aef555 --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions.snap @@ -0,0 +1,45 @@ + +[TestPrinter/nested_expressions - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$maybeRenderHead($$result)}
${(previous || next) && $$render``}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_II.snap b/internal/printer/__snapshots__/nested_expressions_II.snap new file mode 100755 index 000000000..e59e39aa1 --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_II.snap @@ -0,0 +1,45 @@ + +[TestPrinter/nested_expressions_II - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$maybeRenderHead($$result)}
${(previous || next) && $$render``}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_III.snap b/internal/printer/__snapshots__/nested_expressions_III.snap new file mode 100755 index 000000000..2cffc9fac --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_III.snap @@ -0,0 +1,41 @@ + +[TestPrinter/nested_expressions_III - 1] +## Input + +``` +
{x.map((x) => x ?
{true ? {x} : null}
:
{false ? null : {x}}
)}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${x.map((x) => x ? $$render`
${true ? $$render`${x}` : null}
` : $$render`
${false ? null : $$render`${x}`}
`)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_IV.snap b/internal/printer/__snapshots__/nested_expressions_IV.snap new file mode 100755 index 000000000..1989856ae --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_IV.snap @@ -0,0 +1,41 @@ + +[TestPrinter/nested_expressions_IV - 1] +## Input + +``` +
{() => { if (value > 0.25) { return Default } else if (value > 0.5) { return Another } else if (value > 0.75) { return Other } return Yet Other }}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${() => { if (value > 0.25) { return $$render`Default` } else if (value > 0.5) { return $$render`Another` } else if (value > 0.75) { return $$render`Other` } return $$render`Yet Other` }}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_V.snap b/internal/printer/__snapshots__/nested_expressions_V.snap new file mode 100755 index 000000000..29d2d8afa --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_V.snap @@ -0,0 +1,41 @@ + +[TestPrinter/nested_expressions_V - 1] +## Input + +``` +

title

{list.map(group =>

{group.label}

{group.items.map(item => {item})}
)}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

title

${list.map(group => $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`

${group.label}

${group.items.map(item => $$render`${item}`)}`,})}`)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_VI.snap b/internal/printer/__snapshots__/nested_expressions_VI.snap new file mode 100755 index 000000000..95129dcaa --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_VI.snap @@ -0,0 +1,41 @@ + +[TestPrinter/nested_expressions_VI - 1] +## Input + +``` +
{()=>{ if (true) { return
;} if (true) { return ;}}}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${()=>{ if (true) { return $$render`
`;} if (true) { return $$render``;}}}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_VII.snap b/internal/printer/__snapshots__/nested_expressions_VII.snap new file mode 100755 index 000000000..d09be0625 --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_VII.snap @@ -0,0 +1,41 @@ + +[TestPrinter/nested_expressions_VII - 1] +## Input + +``` +
{() => { if (value > 0.25) { return
;} else if (value > 0.5) { return
;} else if (value > 0.75) { return
;} return
Yaaay
;}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${() => { if (value > 0.25) { return $$render`
`;} else if (value > 0.5) { return $$render`
`;} else if (value > 0.75) { return $$render`
`;} return $$render`
Yaaay
`;}}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_expressions_VIII.snap b/internal/printer/__snapshots__/nested_expressions_VIII.snap new file mode 100755 index 000000000..2d25a8017 --- /dev/null +++ b/internal/printer/__snapshots__/nested_expressions_VIII.snap @@ -0,0 +1,41 @@ + +[TestPrinter/nested_expressions_VIII - 1] +## Input + +``` +
{ items.map(({ type, ...data }) => { switch (type) { case 'card': { return ( ); } case 'paragraph': { return (

{data.body}

);}}})}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${ items.map(({ type, ...data }) => { switch (type) { case 'card': { return ( $$render`${$$renderComponent($$result,'Card',Card,{...(data)})}` ); } case 'paragraph': { return ( $$render`

${data.body}

`);}}})}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_head_content_stays_in_the_head.snap b/internal/printer/__snapshots__/nested_head_content_stays_in_the_head.snap new file mode 100755 index 000000000..fcca634f6 --- /dev/null +++ b/internal/printer/__snapshots__/nested_head_content_stays_in_the_head.snap @@ -0,0 +1,72 @@ + +[TestPrinter/nested_head_content_stays_in_the_head - 1] +## Input + +``` +/-/-/-/ +const meta = { title: 'My App' }; +/-/-/-/ + + + + + + { + meta && {meta.title} + } + + + + +

My App

+ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const meta = { title: 'My App' }; + +return $$render` + + + + ${ + meta && $$render`${meta.title}` + } + + + ${$$renderHead($$result)} + +

My App

+ `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/nested_template_literal_expression.snap b/internal/printer/__snapshots__/nested_template_literal_expression.snap new file mode 100755 index 000000000..246c6db7b --- /dev/null +++ b/internal/printer/__snapshots__/nested_template_literal_expression.snap @@ -0,0 +1,91 @@ + +[TestPrinter/nested_template_literal_expression - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- + +[TestPrinter/nested_template_literal_expression#01 - 1] +## Input + +``` + + +{Object.keys(importedAuthors).map(author =>

hello

)} +{Object.keys(importedAuthors).map(author =>

{author}

)} + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` +${$$maybeRenderHead($$result)} +${Object.keys(importedAuthors).map(author => $$render`

hello
`)} +${Object.keys(importedAuthors).map(author => $$render`

${author}
`)} +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/no_expressions_in_math.snap b/internal/printer/__snapshots__/no_expressions_in_math.snap new file mode 100755 index 000000000..7f1a4c5d3 --- /dev/null +++ b/internal/printer/__snapshots__/no_expressions_in_math.snap @@ -0,0 +1,82 @@ + +[TestPrinter/no_expressions_in_math - 1] +## Input + +``` +

Hello, world! This is a buggy formula: f ⁣:XR2xf\colon X \to \mathbb R^{2x}

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

Hello, world! This is a buggy formula: f ⁣:XR2xf\\colon X \\to \\mathbb R^{2x}

`; +}, undefined, undefined); +export default $$Component; +``` +--- + +[TestPrinter/no_expressions_in_math#01 - 1] +## Input + +``` +

Hello, world! This is a buggy formula: f ⁣:XR2xf\colon X \to \mathbb R^{2x}

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

Hello, world! This is a buggy formula: f ⁣:XR2xf\\colon X \\to \\mathbb R^{2x}

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/noscript_component.snap b/internal/printer/__snapshots__/noscript_component.snap new file mode 100755 index 000000000..5dea0d880 --- /dev/null +++ b/internal/printer/__snapshots__/noscript_component.snap @@ -0,0 +1,54 @@ + +[TestPrinter/noscript_component - 1] +## Input + +``` + + + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + ${$$renderHead($$result)} + + + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/noscript_deep_styles.snap b/internal/printer/__snapshots__/noscript_deep_styles.snap new file mode 100755 index 000000000..065adac17 --- /dev/null +++ b/internal/printer/__snapshots__/noscript_deep_styles.snap @@ -0,0 +1,41 @@ + +[TestPrinter/noscript_deep_styles - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/noscript_only.snap b/internal/printer/__snapshots__/noscript_only.snap new file mode 100755 index 000000000..65811d3af --- /dev/null +++ b/internal/printer/__snapshots__/noscript_only.snap @@ -0,0 +1,41 @@ + +[TestPrinter/noscript_only - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/noscript_styles.snap b/internal/printer/__snapshots__/noscript_styles.snap new file mode 100755 index 000000000..442c16dde --- /dev/null +++ b/internal/printer/__snapshots__/noscript_styles.snap @@ -0,0 +1,41 @@ + +[TestPrinter/noscript_styles - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/orphan_slot.snap b/internal/printer/__snapshots__/orphan_slot.snap new file mode 100755 index 000000000..4a0718491 --- /dev/null +++ b/internal/printer/__snapshots__/orphan_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/orphan_slot - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderSlot($$result,$$slots["default"])}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap b/internal/printer/__snapshots__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap new file mode 100755 index 000000000..d9285beae --- /dev/null +++ b/internal/printer/__snapshots__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes - 1] +## Input + +``` +
test
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page-with-\'-quotes.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$PageWithQuotes = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
test
`; +}, '/projects/app/src/pages/page-with-\'-quotes.astro', undefined); +export default $$PageWithQuotes; +``` +--- diff --git a/internal/printer/__snapshots__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap b/internal/printer/__snapshots__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap new file mode 100755 index 000000000..febb9aaf7 --- /dev/null +++ b/internal/printer/__snapshots__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap @@ -0,0 +1,41 @@ + +[TestPrinter/passes_filename_into_createComponent_if_passed_into_the_compiler_options - 1] +## Input + +``` +
test
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Page = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
test
`; +}, '/projects/app/src/pages/page.astro', undefined); +export default $$Page; +``` +--- diff --git a/internal/printer/__snapshots__/preserve_is_inline_slot.snap b/internal/printer/__snapshots__/preserve_is_inline_slot.snap new file mode 100755 index 000000000..b48c19984 --- /dev/null +++ b/internal/printer/__snapshots__/preserve_is_inline_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/preserve_is:inline_slot - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/preserve_is_inline_slot_II.snap b/internal/printer/__snapshots__/preserve_is_inline_slot_II.snap new file mode 100755 index 000000000..f05573ce5 --- /dev/null +++ b/internal/printer/__snapshots__/preserve_is_inline_slot_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/preserve_is:inline_slot_II - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script__renderScript__true_.snap b/internal/printer/__snapshots__/script__renderScript__true_.snap new file mode 100755 index 000000000..e9fee4c87 --- /dev/null +++ b/internal/printer/__snapshots__/script__renderScript__true_.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_(renderScript:_true) - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/src/pages/index.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log("Hello");` }] }); + +const $$Index = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}
`; +}, '/src/pages/index.astro', undefined); +export default $$Index; +``` +--- diff --git a/internal/printer/__snapshots__/script_before_elements.snap b/internal/printer/__snapshots__/script_before_elements.snap new file mode 100755 index 000000000..f1fbc30a3 --- /dev/null +++ b/internal/printer/__snapshots__/script_before_elements.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_before_elements - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `Here` }] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_define_vars_I.snap b/internal/printer/__snapshots__/script_define_vars_I.snap new file mode 100755 index 000000000..36066a224 --- /dev/null +++ b/internal/printer/__snapshots__/script_define_vars_I.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_define:vars_I - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_define_vars_II.snap b/internal/printer/__snapshots__/script_define_vars_II.snap new file mode 100755 index 000000000..0ac6b79eb --- /dev/null +++ b/internal/printer/__snapshots__/script_define_vars_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_define:vars_II - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_external__renderScript__true_.snap b/internal/printer/__snapshots__/script_external__renderScript__true_.snap new file mode 100755 index 000000000..88be65653 --- /dev/null +++ b/internal/printer/__snapshots__/script_external__renderScript__true_.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_external_(renderScript:_true) - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/src/pages/index.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'external', src: './hello.js' }] }); + +const $$Index = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}
`; +}, '/src/pages/index.astro', undefined); +export default $$Index; +``` +--- diff --git a/internal/printer/__snapshots__/script_hoist_with_frontmatter.snap b/internal/printer/__snapshots__/script_hoist_with_frontmatter.snap new file mode 100755 index 000000000..6cbde7c78 --- /dev/null +++ b/internal/printer/__snapshots__/script_hoist_with_frontmatter.snap @@ -0,0 +1,43 @@ + +[TestPrinter/script_hoist_with_frontmatter - 1] +## Input + +``` +/-/-/-/ +/-/-/-/ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log("Hello");` }] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_hoist_without_frontmatter.snap b/internal/printer/__snapshots__/script_hoist_without_frontmatter.snap new file mode 100755 index 000000000..7abf3adc4 --- /dev/null +++ b/internal/printer/__snapshots__/script_hoist_without_frontmatter.snap @@ -0,0 +1,44 @@ + +[TestPrinter/script_hoist_without_frontmatter - 1] +## Input + +``` +
+ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log("Hello");` }] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
+ +
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_in__head_.snap b/internal/printer/__snapshots__/script_in__head_.snap new file mode 100755 index 000000000..90ceaa62b --- /dev/null +++ b/internal/printer/__snapshots__/script_in__head_.snap @@ -0,0 +1,56 @@ + +[TestPrinter/script_in_ - 1] +## Input + +``` +/-/-/-/ +import Widget from '../components/Widget.astro'; +import Widget2 from '../components/Widget2.astro'; +/-/-/-/ + + + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Widget from '../components/Widget.astro'; +import Widget2 from '../components/Widget2.astro'; + +import * as $$module1 from '../components/Widget.astro'; +import * as $$module2 from '../components/Widget2.astro'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: '../components/Widget.astro', assert: {} }, { module: $$module2, specifier: '../components/Widget2.astro', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + + ${$$renderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_inline.snap b/internal/printer/__snapshots__/script_inline.snap new file mode 100755 index 000000000..6257ebe1e --- /dev/null +++ b/internal/printer/__snapshots__/script_inline.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_inline - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_inline__renderScript__true_.snap b/internal/printer/__snapshots__/script_inline__renderScript__true_.snap new file mode 100755 index 000000000..b32089fc8 --- /dev/null +++ b/internal/printer/__snapshots__/script_inline__renderScript__true_.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_inline_(renderScript:_true) - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/script_mixed_handled_and_inline__renderScript__true_.snap b/internal/printer/__snapshots__/script_mixed_handled_and_inline__renderScript__true_.snap new file mode 100755 index 000000000..87d237a04 --- /dev/null +++ b/internal/printer/__snapshots__/script_mixed_handled_and_inline__renderScript__true_.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_mixed_handled_and_inline_(renderScript:_true) - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/src/pages/index.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log("Hello");` }] }); + +const $$Index = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}
`; +}, '/src/pages/index.astro', undefined); +export default $$Index; +``` +--- diff --git a/internal/printer/__snapshots__/script_multiple__renderScript__true_.snap b/internal/printer/__snapshots__/script_multiple__renderScript__true_.snap new file mode 100755 index 000000000..12b257be5 --- /dev/null +++ b/internal/printer/__snapshots__/script_multiple__renderScript__true_.snap @@ -0,0 +1,41 @@ + +[TestPrinter/script_multiple_(renderScript:_true) - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata("/src/pages/index.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log("World");` }, { type: 'inline', value: `console.log("Hello");` }] }); + +const $$Index = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=1&lang.ts")}
`; +}, '/src/pages/index.astro', undefined); +export default $$Index; +``` +--- diff --git a/internal/printer/__snapshots__/select_in_form.snap b/internal/printer/__snapshots__/select_in_form.snap new file mode 100755 index 000000000..0c1ab1c32 --- /dev/null +++ b/internal/printer/__snapshots__/select_in_form.snap @@ -0,0 +1,41 @@ + +[TestPrinter/select_in_form - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/select_map_expression.snap b/internal/printer/__snapshots__/select_map_expression.snap new file mode 100755 index 000000000..d34377c1d --- /dev/null +++ b/internal/printer/__snapshots__/select_map_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/select_map_expression - 1] +## Input + +``` +
Hello world!
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
Hello world!
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/select_nested_option.snap b/internal/printer/__snapshots__/select_nested_option.snap new file mode 100755 index 000000000..4377b2884 --- /dev/null +++ b/internal/printer/__snapshots__/select_nested_option.snap @@ -0,0 +1,46 @@ + +[TestPrinter/select_nested_option - 1] +## Input + +``` +/-/-/-/ +const value = 'test'; +/-/-/-/ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const value = 'test'; + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/select_option_expression.snap b/internal/printer/__snapshots__/select_option_expression.snap new file mode 100755 index 000000000..b6f007bb5 --- /dev/null +++ b/internal/printer/__snapshots__/select_option_expression.snap @@ -0,0 +1,46 @@ + +[TestPrinter/select_option_expression - 1] +## Input + +``` +/-/-/-/ +const value = 'test'; +/-/-/-/ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const value = 'test'; + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/self-closing_td.snap b/internal/printer/__snapshots__/self-closing_td.snap new file mode 100755 index 000000000..265ab3f77 --- /dev/null +++ b/internal/printer/__snapshots__/self-closing_td.snap @@ -0,0 +1,41 @@ + +[TestPrinter/self-closing_td - 1] +## Input + +``` +{data.map(row => {row.map(cell => )}
)}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${data.map(row => $$render`${row.map(cell => $$render``)}`)}
${$$unescapeHTML(cell)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html.snap b/internal/printer/__snapshots__/set_html.snap new file mode 100755 index 000000000..ce64cebae --- /dev/null +++ b/internal/printer/__snapshots__/set_html.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_and_set_text.snap b/internal/printer/__snapshots__/set_html_and_set_text.snap new file mode 100755 index 000000000..aee1a4e9f --- /dev/null +++ b/internal/printer/__snapshots__/set_html_and_set_text.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_and_set:text - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Component.snap b/internal/printer/__snapshots__/set_html_on_Component.snap new file mode 100755 index 000000000..319d943b1 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Component - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${$$unescapeHTML(content)}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Component_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_Component_with_quoted_attribute.snap new file mode 100755 index 000000000..4a60e9775 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Component_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Component_with_quoted_attribute - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${"content"}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..300ac11e9 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Component_with_template_literal_attribute_with_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${`${content}`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..e5e121ae6 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Component_with_template_literal_attribute_without_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${`content`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Fragment.snap b/internal/printer/__snapshots__/set_html_on_Fragment.snap new file mode 100755 index 000000000..4c5b66ee0 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Fragment.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Fragment - 1] +## Input + +``` +<i>This should NOT be italic</i>

"} /> +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${$$unescapeHTML("

<i>This should NOT be italic</i>

")}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Fragment_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_Fragment_with_quoted_attribute.snap new file mode 100755 index 000000000..31bd82825 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Fragment_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Fragment_with_quoted_attribute - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${"

This should NOT be italic

"}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..99bb11d27 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Fragment_with_template_literal_attribute_with_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${`${content}`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..0a9abd742 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_Fragment_with_template_literal_attribute_without_variable - 1] +## Input + +``` +<i>This should NOT be italic</i>

` /> +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`${`

This should NOT be italic

`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_custom-element.snap b/internal/printer/__snapshots__/set_html_on_custom-element.snap new file mode 100755 index 000000000..adcd889ff --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_custom-element.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_custom-element - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${$$unescapeHTML(content)}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_custom-element_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_custom-element_with_quoted_attribute.snap new file mode 100755 index 000000000..69d3478e2 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_custom-element_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_custom-element_with_quoted_attribute - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${"content"}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..070e13aa9 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_custom-element_with_template_literal_attribute_with_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${`${content}`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..6fec1b799 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_custom-element_with_template_literal_attribute_without_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${`content`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag.snap b/internal/printer/__snapshots__/set_html_on_empty_tag.snap new file mode 100755 index 000000000..aa8fdb335 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_empty_tag.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_empty_tag - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_empty_tag_with_quoted_attribute.snap new file mode 100755 index 000000000..b4d4ce8be --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_empty_tag_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_empty_tag_with_quoted_attribute - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${"content"}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..c670581cf --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_empty_tag_with_template_literal_attribute_with_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..169ecb33e --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_empty_tag_with_template_literal_attribute_without_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_script.snap b/internal/printer/__snapshots__/set_html_on_script.snap new file mode 100755 index 000000000..704b9a819 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_script.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_script - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_script_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_script_with_quoted_attribute.snap new file mode 100755 index 000000000..16afbae21 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_script_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_script_with_quoted_attribute - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..e13a7e936 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_script_with_template_literal_attribute_with_variable - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..3accc5210 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_script_with_template_literal_attribute_without_variable - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag.snap b/internal/printer/__snapshots__/set_html_on_self-closing_tag.snap new file mode 100755 index 000000000..0581c6114 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_self-closing_tag.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_self-closing_tag - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_quoted_attribute.snap new file mode 100755 index 000000000..96470f3c6 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_self-closing_tag_with_quoted_attribute - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${"content"}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..8b04af08c --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_self-closing_tag_with_template_literal_attribute_with_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..5682f31b3 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_self-closing_tag_with_template_literal_attribute_without_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_style.snap b/internal/printer/__snapshots__/set_html_on_style.snap new file mode 100755 index 000000000..e8c5b8a14 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_style.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_style - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_style_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_style_with_quoted_attribute.snap new file mode 100755 index 000000000..d37a87040 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_style_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_style_with_quoted_attribute - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..a1589416e --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_style_with_template_literal_attribute_with_variable - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..c2b7edef6 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_style_with_template_literal_attribute_without_variable - 1] +## Input + +``` +`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children.snap b/internal/printer/__snapshots__/set_html_on_tag_with_children.snap new file mode 100755 index 000000000..b9286bef2 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_children.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_children - 1] +## Input + +``` +
!!!
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children_and_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_tag_with_children_and_quoted_attribute.snap new file mode 100755 index 000000000..8f6a06562 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_children_and_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_children_and_quoted_attribute - 1] +## Input + +``` +
!!!
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${"content"}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..e7b350225 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_children_and_template_literal_attribute_with_variable - 1] +## Input + +``` +
!!!
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..5a4c94970 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_children_and_template_literal_attribute_without_variable - 1] +## Input + +``` +
!!!
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace.snap b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace.snap new file mode 100755 index 000000000..889614661 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_empty_whitespace - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap new file mode 100755 index 000000000..41487a1bc --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_empty_whitespace_and_quoted_attribute - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${"content"}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..e9b02534e --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..5bcf9f004 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_other_attributes.snap b/internal/printer/__snapshots__/set_html_with_other_attributes.snap new file mode 100755 index 000000000..66b8dc4fc --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_other_attributes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_other_attributes - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$unescapeHTML(content)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_html_with_quoted_attribute.snap new file mode 100755 index 000000000..4ffa3d4e4 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_quoted_attribute - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${"content"}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_quoted_attribute_and_other_attributes.snap b/internal/printer/__snapshots__/set_html_with_quoted_attribute_and_other_attributes.snap new file mode 100755 index 000000000..4189ec268 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_quoted_attribute_and_other_attributes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_quoted_attribute_and_other_attributes - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${"content"}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..4f15145c1 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_template_literal_attribute_with_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap new file mode 100755 index 000000000..1a1e422ac --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_template_literal_attribute_with_variable_and_other_attributes - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..f1ac4d5d2 --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_template_literal_attribute_without_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap new file mode 100755 index 000000000..d9d343dec --- /dev/null +++ b/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:html_with_template_literal_attribute_without_variable_and_other_attributes - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text.snap b/internal/printer/__snapshots__/set_text.snap new file mode 100755 index 000000000..853449cf8 --- /dev/null +++ b/internal/printer/__snapshots__/set_text.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${content}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_Component.snap b/internal/printer/__snapshots__/set_text_on_Component.snap new file mode 100755 index 000000000..a4052bc4c --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_Component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_Component - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${content}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_Component_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_text_on_Component_with_quoted_attribute.snap new file mode 100755 index 000000000..e25fb6706 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_Component_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_Component_with_quoted_attribute - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`content`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..2348bf667 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_Component_with_template_literal_attribute_with_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${`${content}`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..acd40ccc7 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_Component_with_template_literal_attribute_without_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${`content`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_custom-element.snap b/internal/printer/__snapshots__/set_text_on_custom-element.snap new file mode 100755 index 000000000..2988d0cb8 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_custom-element.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_custom-element - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${content}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_custom-element_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_text_on_custom-element_with_quoted_attribute.snap new file mode 100755 index 000000000..640dd91d6 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_custom-element_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_custom-element_with_quoted_attribute - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`content`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..c95bddd30 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_custom-element_with_template_literal_attribute_with_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${`${content}`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..4e0944630 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_on_custom-element_with_template_literal_attribute_without_variable - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render`${`content`}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_with_quoted_attribute.snap b/internal/printer/__snapshots__/set_text_with_quoted_attribute.snap new file mode 100755 index 000000000..6718bf3fe --- /dev/null +++ b/internal/printer/__snapshots__/set_text_with_quoted_attribute.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_with_quoted_attribute - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
content
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_with_template_literal_attribute_with_variable.snap b/internal/printer/__snapshots__/set_text_with_template_literal_attribute_with_variable.snap new file mode 100755 index 000000000..1ddc834e8 --- /dev/null +++ b/internal/printer/__snapshots__/set_text_with_template_literal_attribute_with_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_with_template_literal_attribute_with_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`${content}`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/set_text_with_template_literal_attribute_without_variable.snap b/internal/printer/__snapshots__/set_text_with_template_literal_attribute_without_variable.snap new file mode 100755 index 000000000..78e9a3b7c --- /dev/null +++ b/internal/printer/__snapshots__/set_text_with_template_literal_attribute_without_variable.snap @@ -0,0 +1,41 @@ + +[TestPrinter/set:text_with_template_literal_attribute_without_variable - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${`content`}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/sibling_expressions.snap b/internal/printer/__snapshots__/sibling_expressions.snap new file mode 100755 index 000000000..aa3fbe1f2 --- /dev/null +++ b/internal/printer/__snapshots__/sibling_expressions.snap @@ -0,0 +1,53 @@ + +[TestPrinter/sibling_expressions - 1] +## Input + +``` + + + {true ? () : null} + {true ? () : null} + {true ? () : null} +
Row 1
Row 2
Row 3
+ +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)} + + ${true ? ($$render``) : null} + ${true ? ($$render``) : null} + ${true ? ($$render``) : null} +
Row 1
Row 2
Row 3
+`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/simple_ternary.snap b/internal/printer/__snapshots__/simple_ternary.snap new file mode 100755 index 000000000..f09f36dc2 --- /dev/null +++ b/internal/printer/__snapshots__/simple_ternary.snap @@ -0,0 +1,41 @@ + +[TestPrinter/simple_ternary - 1] +## Input + +``` +{link ? {link} :
no link
} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${link ? $$render`${link}` : $$render`
no link
`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slot_inside_of_Base.snap b/internal/printer/__snapshots__/slot_inside_of_Base.snap new file mode 100755 index 000000000..adf19af70 --- /dev/null +++ b/internal/printer/__snapshots__/slot_inside_of_Base.snap @@ -0,0 +1,41 @@ + +[TestPrinter/slot_inside_of_Base - 1] +## Input + +``` +
Hello
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Base',Base,{"title":"Home"},{"default": () => $$render`${$$maybeRenderHead($$result)}
Hello
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slot_with_fallback.snap b/internal/printer/__snapshots__/slot_with_fallback.snap new file mode 100755 index 000000000..45e425c8c --- /dev/null +++ b/internal/printer/__snapshots__/slot_with_fallback.snap @@ -0,0 +1,41 @@ + +[TestPrinter/slot_with_fallback - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"],$$render`

Hello world!

`)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slot_with_fallback_II.snap b/internal/printer/__snapshots__/slot_with_fallback_II.snap new file mode 100755 index 000000000..83868fc4b --- /dev/null +++ b/internal/printer/__snapshots__/slot_with_fallback_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/slot_with_fallback_II - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderSlot($$result,$$slots["test"],$$render`${$$maybeRenderHead($$result)}

Hello world!

`)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slot_with_fallback_III.snap b/internal/printer/__snapshots__/slot_with_fallback_III.snap new file mode 100755 index 000000000..166993e13 --- /dev/null +++ b/internal/printer/__snapshots__/slot_with_fallback_III.snap @@ -0,0 +1,41 @@ + +[TestPrinter/slot_with_fallback_III - 1] +## Input + +``` +

Fallback

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderSlot($$result,$$slots["test"],$$render`

Fallback

`)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slot_with_quoted_attributes.snap b/internal/printer/__snapshots__/slot_with_quoted_attributes.snap new file mode 100755 index 000000000..c9c4cf72c --- /dev/null +++ b/internal/printer/__snapshots__/slot_with_quoted_attributes.snap @@ -0,0 +1,41 @@ + +[TestPrinter/slot_with_quoted_attributes - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"\"name\"": () => $$render`${$$maybeRenderHead($$result)}
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slots__basic_.snap b/internal/printer/__snapshots__/slots__basic_.snap new file mode 100755 index 000000000..1f05996c4 --- /dev/null +++ b/internal/printer/__snapshots__/slots__basic_.snap @@ -0,0 +1,53 @@ + +[TestPrinter/slots_(basic) - 1] +## Input + +``` +/-/-/-/ +import Component from "test"; +/-/-/-/ + +
Default
+
Named
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Component from "test"; + +import * as $$module1 from 'test'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + ${$$maybeRenderHead($$result)}
Default
+ +`,"named": () => $$render`
Named
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slots__dynamic_name_.snap b/internal/printer/__snapshots__/slots__dynamic_name_.snap new file mode 100755 index 000000000..38feae1dc --- /dev/null +++ b/internal/printer/__snapshots__/slots__dynamic_name_.snap @@ -0,0 +1,53 @@ + +[TestPrinter/slots_(dynamic_name) - 1] +## Input + +``` +/-/-/-/ +import Component from 'test'; +const name = 'named'; + --- + +
Named
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Component from 'test'; + +import * as $$module1 from 'test'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const name = 'named'; + + +return $$render`${$$renderComponent($$result,'Component',Component,{},{[name]: () => $$render`${$$maybeRenderHead($$result)}
Named
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slots__expression_.snap b/internal/printer/__snapshots__/slots__expression_.snap new file mode 100755 index 000000000..1fb70aded --- /dev/null +++ b/internal/printer/__snapshots__/slots__expression_.snap @@ -0,0 +1,43 @@ + +[TestPrinter/slots_(expression) - 1] +## Input + +``` + + {items.map(item =>
{item}
)} +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{"data":(data)},{"default": () => $$render`${items.map(item => $$render`${$$maybeRenderHead($$result)}
${item}
`)}`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slots__named_only_.snap b/internal/printer/__snapshots__/slots__named_only_.snap new file mode 100755 index 000000000..75711b40b --- /dev/null +++ b/internal/printer/__snapshots__/slots__named_only_.snap @@ -0,0 +1,45 @@ + +[TestPrinter/slots_(named_only) - 1] +## Input + +``` + + A + B + C + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Slotted',Slotted,{},{"a": () => $$render`${$$maybeRenderHead($$result)}A`,"b": () => $$render`B`,"c": () => $$render`C`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/slots__no_comments_.snap b/internal/printer/__snapshots__/slots__no_comments_.snap new file mode 100755 index 000000000..7568a2db6 --- /dev/null +++ b/internal/printer/__snapshots__/slots__no_comments_.snap @@ -0,0 +1,55 @@ + +[TestPrinter/slots_(no_comments) - 1] +## Input + +``` +/-/-/-/ +import Component from 'test'; +/-/-/-/ + +
Default
+ +
Named
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import Component from 'test'; + +import * as $$module1 from 'test'; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [{ module: $$module1, specifier: 'test', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + ${$$maybeRenderHead($$result)}
Default
+ + +`,"named": () => $$render`
Named
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/small_expression.snap b/internal/printer/__snapshots__/small_expression.snap new file mode 100755 index 000000000..48e74a5e0 --- /dev/null +++ b/internal/printer/__snapshots__/small_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/small_expression - 1] +## Input + +``` +
{a}{data.map(a => )}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${a}${data.map(a => $$render`${$$renderComponent($$result,'Component',Component,{"value":(a)})}`)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/solidus_in_template_literal_expression.snap b/internal/printer/__snapshots__/solidus_in_template_literal_expression.snap new file mode 100755 index 000000000..579b1c064 --- /dev/null +++ b/internal/printer/__snapshots__/solidus_in_template_literal_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/solidus_in_template_literal_expression - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/spread_with_double_quotation_marks.snap b/internal/printer/__snapshots__/spread_with_double_quotation_marks.snap new file mode 100755 index 000000000..18b833ff0 --- /dev/null +++ b/internal/printer/__snapshots__/spread_with_double_quotation_marks.snap @@ -0,0 +1,41 @@ + +[TestPrinter/spread_with_double_quotation_marks - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/spread_with_style_but_no_explicit_class.snap b/internal/printer/__snapshots__/spread_with_style_but_no_explicit_class.snap new file mode 100755 index 000000000..b5ddae568 --- /dev/null +++ b/internal/printer/__snapshots__/spread_with_style_but_no_explicit_class.snap @@ -0,0 +1,45 @@ + +[TestPrinter/spread_with_style_but_no_explicit_class - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/spread_without_style_or_class.snap b/internal/printer/__snapshots__/spread_without_style_or_class.snap new file mode 100755 index 000000000..3a490af24 --- /dev/null +++ b/internal/printer/__snapshots__/spread_without_style_or_class.snap @@ -0,0 +1,45 @@ + +[TestPrinter/spread_without_style_or_class - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/styles__no_frontmatter_.snap b/internal/printer/__snapshots__/styles__no_frontmatter_.snap new file mode 100755 index 000000000..935863b54 --- /dev/null +++ b/internal/printer/__snapshots__/styles__no_frontmatter_.snap @@ -0,0 +1,56 @@ + +[TestPrinter/styles_(no_frontmatter) - 1] +## Input + +``` + + +

Page Title

+

I’m a page

+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render` + + ${$$maybeRenderHead($$result)}

Page Title

+

I’m a page

`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/svg_expressions.snap b/internal/printer/__snapshots__/svg_expressions.snap new file mode 100755 index 000000000..c71f6cad1 --- /dev/null +++ b/internal/printer/__snapshots__/svg_expressions.snap @@ -0,0 +1,46 @@ + +[TestPrinter/svg_expressions - 1] +## Input + +``` +/-/-/-/ +const title = 'icon'; +/-/-/-/ +{title ?? null} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const title = 'icon'; + +return $$render`${$$maybeRenderHead($$result)}${title ?? null}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table.snap b/internal/printer/__snapshots__/table.snap new file mode 100755 index 000000000..48b958aac --- /dev/null +++ b/internal/printer/__snapshots__/table.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table - 1] +## Input + +``` +{[0,1,2].map(x => ())}
{x}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${[0,1,2].map(x => ($$render``))}
${x}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_II.snap b/internal/printer/__snapshots__/table_II.snap new file mode 100755 index 000000000..1c763335d --- /dev/null +++ b/internal/printer/__snapshots__/table_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_II - 1] +## Input + +``` +{['Hey','Ho'].map((item)=> )}
{item}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${['Hey','Ho'].map((item)=> $$render``)}
${item}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_III.snap b/internal/printer/__snapshots__/table_III.snap new file mode 100755 index 000000000..01ca27eeb --- /dev/null +++ b/internal/printer/__snapshots__/table_III.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_III - 1] +## Input + +``` +
Cell
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Cell',Cell,{})}${$$renderComponent($$result,'Cell',Cell,{})}${$$renderComponent($$result,'Cell',Cell,{})}
Cell
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_IV.snap b/internal/printer/__snapshots__/table_IV.snap new file mode 100755 index 000000000..869d01290 --- /dev/null +++ b/internal/printer/__snapshots__/table_IV.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_IV - 1] +## Input + +``` +
hello world
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
hello world
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_caption_expression.snap b/internal/printer/__snapshots__/table_caption_expression.snap new file mode 100755 index 000000000..7f871ad72 --- /dev/null +++ b/internal/printer/__snapshots__/table_caption_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_caption_expression - 1] +## Input + +``` +
{title}
Hello
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${title}
Hello
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_expression_with_trailing_div.snap b/internal/printer/__snapshots__/table_expression_with_trailing_div.snap new file mode 100755 index 000000000..14834b680 --- /dev/null +++ b/internal/printer/__snapshots__/table_expression_with_trailing_div.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_expression_with_trailing_div - 1] +## Input + +``` +
{title}
Div
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${title}
Div
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_expressions__no_implicit_tbody_.snap b/internal/printer/__snapshots__/table_expressions__no_implicit_tbody_.snap new file mode 100755 index 000000000..5e0c43ab0 --- /dev/null +++ b/internal/printer/__snapshots__/table_expressions__no_implicit_tbody_.snap @@ -0,0 +1,46 @@ + +[TestPrinter/table_expressions_(no_implicit_tbody) - 1] +## Input + +``` +/-/-/-/ +const items = ["Dog", "Cat", "Platipus"]; +/-/-/-/ +{items.map(item => ())}
{item}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const items = ["Dog", "Cat", "Platipus"]; + +return $$render`${$$maybeRenderHead($$result)}${items.map(item => ($$render``))}
${item}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_simple_case.snap b/internal/printer/__snapshots__/table_simple_case.snap new file mode 100755 index 000000000..f40d2a822 --- /dev/null +++ b/internal/printer/__snapshots__/table_simple_case.snap @@ -0,0 +1,76 @@ + +[TestPrinter/table_simple_case - 1] +## Input + +``` +/-/-/-/ +const content = "lol"; +/-/-/-/ + + + + + + + + { + ( + + + + ) + } +
{content}
1
Hello + + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const content = "lol"; + +return $$render` + ${$$maybeRenderHead($$result)} + + + + + ${ + ( + $$render` + + ` + ) + } +
${content}
1
Hello + `; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_slot_I.snap b/internal/printer/__snapshots__/table_slot_I.snap new file mode 100755 index 000000000..e4e97824f --- /dev/null +++ b/internal/printer/__snapshots__/table_slot_I.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_slot_I - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_slot_II.snap b/internal/printer/__snapshots__/table_slot_II.snap new file mode 100755 index 000000000..5ad7f9232 --- /dev/null +++ b/internal/printer/__snapshots__/table_slot_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_slot_II - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_slot_III.snap b/internal/printer/__snapshots__/table_slot_III.snap new file mode 100755 index 000000000..82cc88a6a --- /dev/null +++ b/internal/printer/__snapshots__/table_slot_III.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_slot_III - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${$$renderSlot($$result,$$slots["default"])}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_slot_IV.snap b/internal/printer/__snapshots__/table_slot_IV.snap new file mode 100755 index 000000000..acb47d3df --- /dev/null +++ b/internal/printer/__snapshots__/table_slot_IV.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_slot_IV - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_slot_V.snap b/internal/printer/__snapshots__/table_slot_V.snap new file mode 100755 index 000000000..288d194f1 --- /dev/null +++ b/internal/printer/__snapshots__/table_slot_V.snap @@ -0,0 +1,41 @@ + +[TestPrinter/table_slot_V - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/table_with_expression_in_'th'.snap b/internal/printer/__snapshots__/table_with_expression_in_'th'.snap new file mode 100755 index 000000000..6459a0d10 --- /dev/null +++ b/internal/printer/__snapshots__/table_with_expression_in_'th'.snap @@ -0,0 +1,133 @@ + +[TestPrinter/table_with_expression_in_'th' - 1] +## Input + +``` +/-/-/-/ +const { title, footnotes, tables } = Astro.props; + +interface Table { + title: string; + data: any[]; + showTitle: boolean; + footnotes: string; +} +console.log(tables); +/-/-/-/ + +
+
+

+ {title} +

+ { + tables.map((table: Table) => ( + <> +
+

{table.title}

+ + + {Object.keys(table.data[0]).map((thead) => ( + + ))} + + + {table.data.map((trow) => ( + + {Object.values(trow).map((cell, index) => ( + + ))} + + ))} + +
{thead}
+ {cell} +
+
+ + )) + } +
+
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +const { title, footnotes, tables } = Astro.props; + +interface Table { + title: string; + data: any[]; + showTitle: boolean; + footnotes: string; +} +console.log(tables); + +return $$render`${$$maybeRenderHead($$result)}
+
+

+ ${title} +

+ ${ + tables.map((table: Table) => ( + $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` +
+

${table.title}

+ + + ${Object.keys(table.data[0]).map((thead) => ( + $$render`` + ))} + + + ${table.data.map((trow) => ( + $$render` + ${Object.values(trow).map((cell, index) => ( + $$render`` + ))} + ` + ))} + +
${thead}
+ ${cell} +
+
+ `,})}` + )) + } +
+
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/tbody_expressions.snap b/internal/printer/__snapshots__/tbody_expressions.snap new file mode 100755 index 000000000..d0552cb58 --- /dev/null +++ b/internal/printer/__snapshots__/tbody_expressions.snap @@ -0,0 +1,46 @@ + +[TestPrinter/tbody_expressions - 1] +## Input + +``` +/-/-/-/ +const items = ["Dog", "Cat", "Platipus"]; +/-/-/-/ +{items.map(item => ())}
Name
{item}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const items = ["Dog", "Cat", "Platipus"]; + +return $$render`${$$maybeRenderHead($$result)}${items.map(item => ($$render``))}
Name
${item}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/tbody_expressions_2.snap b/internal/printer/__snapshots__/tbody_expressions_2.snap new file mode 100755 index 000000000..4d6380ecc --- /dev/null +++ b/internal/printer/__snapshots__/tbody_expressions_2.snap @@ -0,0 +1,46 @@ + +[TestPrinter/tbody_expressions_2 - 1] +## Input + +``` +/-/-/-/ +const items = ["Dog", "Cat", "Platipus"]; +/-/-/-/ +{items.map(item => ())}
Name
{item}{item + 's'}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const items = ["Dog", "Cat", "Platipus"]; + +return $$render`${$$maybeRenderHead($$result)}${items.map(item => ($$render``))}
Name
${item}${item + 's'}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/tbody_expressions_3.snap b/internal/printer/__snapshots__/tbody_expressions_3.snap new file mode 100755 index 000000000..acde1a1a6 --- /dev/null +++ b/internal/printer/__snapshots__/tbody_expressions_3.snap @@ -0,0 +1,41 @@ + +[TestPrinter/tbody_expressions_3 - 1] +## Input + +``` +{rows.map(row => ())}
{row}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${rows.map(row => ($$render``))}
${row}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/td_expressions.snap b/internal/printer/__snapshots__/td_expressions.snap new file mode 100755 index 000000000..97bf09d58 --- /dev/null +++ b/internal/printer/__snapshots__/td_expressions.snap @@ -0,0 +1,41 @@ + +[TestPrinter/td_expressions - 1] +## Input + +``` +

Row 1

{title}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}

Row 1

${title}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/td_expressions_II.snap b/internal/printer/__snapshots__/td_expressions_II.snap new file mode 100755 index 000000000..5acc0b745 --- /dev/null +++ b/internal/printer/__snapshots__/td_expressions_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/td_expressions_II - 1] +## Input + +``` +{data.map(row => {row.map(cell => )})}
{cell}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}${data.map(row => $$render`${row.map(cell => $$render``)}`)}
${cell}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/template_literal_attribute_on_component.snap b/internal/printer/__snapshots__/template_literal_attribute_on_component.snap new file mode 100755 index 000000000..b0353259c --- /dev/null +++ b/internal/printer/__snapshots__/template_literal_attribute_on_component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/template_literal_attribute_on_component - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{"class":`red`})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/template_literal_attribute_with_variable_on_component.snap b/internal/printer/__snapshots__/template_literal_attribute_with_variable_on_component.snap new file mode 100755 index 000000000..64e8f2566 --- /dev/null +++ b/internal/printer/__snapshots__/template_literal_attribute_with_variable_on_component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/template_literal_attribute_with_variable_on_component - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{"class":`${color}`})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/ternary_component.snap b/internal/printer/__snapshots__/ternary_component.snap new file mode 100755 index 000000000..f1ed17001 --- /dev/null +++ b/internal/printer/__snapshots__/ternary_component.snap @@ -0,0 +1,41 @@ + +[TestPrinter/ternary_component - 1] +## Input + +``` +{special ?

Special

:

Not special

} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${special ? $$render`${$$renderComponent($$result,'ChildDiv',ChildDiv,{},{"default": () => $$render`${$$maybeRenderHead($$result)}

Special

`,})}` : $$render`

Not special

`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/ternary_layout.snap b/internal/printer/__snapshots__/ternary_layout.snap new file mode 100755 index 000000000..812e6d87f --- /dev/null +++ b/internal/printer/__snapshots__/ternary_layout.snap @@ -0,0 +1,45 @@ + +[TestPrinter/ternary_layout - 1] +## Input + +``` +{toggleError ?

SITE: {Astro.site}

: <>

SITE: {Astro.site}

} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Astro = $$createAstro('https://astro.build'); +const Astro = $$Astro; +const $$Component = $$createComponent(($$result, $$props, $$slots) => { +const Astro = $$result.createAstro($$Astro, $$props, $$slots); +Astro.self = $$Component; + +return $$render`${toggleError ? $$render`${$$renderComponent($$result,'BaseLayout',BaseLayout,{},{"default": () => $$render`${$$maybeRenderHead($$result)}

SITE: ${Astro.site}

`,})}` : $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`

SITE: ${Astro.site}

`,})}`}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/ternary_slot.snap b/internal/printer/__snapshots__/ternary_slot.snap new file mode 100755 index 000000000..996f5d179 --- /dev/null +++ b/internal/printer/__snapshots__/ternary_slot.snap @@ -0,0 +1,41 @@ + +[TestPrinter/ternary_slot - 1] +## Input + +``` +{Math.random() > 0.5 ?
A
:
B
}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},$$mergeSlots({},Math.random() > 0.5 ? {"a": () => $$render`${$$maybeRenderHead($$result)}
A
`} : {"b": () => $$render`
B
`}))}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/text_after_title_expression.snap b/internal/printer/__snapshots__/text_after_title_expression.snap new file mode 100755 index 000000000..0ac466dd3 --- /dev/null +++ b/internal/printer/__snapshots__/text_after_title_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/text_after_title_expression - 1] +## Input + +``` +a {expr} b +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`a ${expr} b`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/text_after_title_expressions.snap b/internal/printer/__snapshots__/text_after_title_expressions.snap new file mode 100755 index 000000000..00ebf410f --- /dev/null +++ b/internal/printer/__snapshots__/text_after_title_expressions.snap @@ -0,0 +1,41 @@ + +[TestPrinter/text_after_title_expressions - 1] +## Input + +``` +a {expr} b {expr} c +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`a ${expr} b ${expr} c`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/text_only.snap b/internal/printer/__snapshots__/text_only.snap new file mode 100755 index 000000000..ea448282d --- /dev/null +++ b/internal/printer/__snapshots__/text_only.snap @@ -0,0 +1,82 @@ + +[TestPrinter/text_only - 1] +## Input + +``` +Foo +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`Foo`; +}, undefined, undefined); +export default $$Component; +``` +--- + +[TestPrinter/text_only#01 - 1] +## Input + +``` +Hello! +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`Hello!`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/textarea.snap b/internal/printer/__snapshots__/textarea.snap new file mode 100755 index 000000000..a3ce6a282 --- /dev/null +++ b/internal/printer/__snapshots__/textarea.snap @@ -0,0 +1,46 @@ + +[TestPrinter/textarea - 1] +## Input + +``` +/-/-/-/ +const value = 'test'; +/-/-/-/ + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +const value = 'test'; + +return $$render`${$$maybeRenderHead($$result)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/textarea_in_form.snap b/internal/printer/__snapshots__/textarea_in_form.snap new file mode 100755 index 000000000..9d95b54b3 --- /dev/null +++ b/internal/printer/__snapshots__/textarea_in_form.snap @@ -0,0 +1,41 @@ + +[TestPrinter/textarea_in_form - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${$$maybeRenderHead($$result)}
`,})}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/textarea_inside_expression.snap b/internal/printer/__snapshots__/textarea_inside_expression.snap new file mode 100755 index 000000000..4f6d6c078 --- /dev/null +++ b/internal/printer/__snapshots__/textarea_inside_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/textarea_inside_expression - 1] +## Input + +``` +{bool && } {!bool && } +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${bool && $$render`${$$maybeRenderHead($$result)}`} ${!bool && $$render``}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/th_expressions.snap b/internal/printer/__snapshots__/th_expressions.snap new file mode 100755 index 000000000..99f5fe8ff --- /dev/null +++ b/internal/printer/__snapshots__/th_expressions.snap @@ -0,0 +1,41 @@ + +[TestPrinter/th_expressions - 1] +## Input + +``` +
{title}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${title}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/tr_only.snap b/internal/printer/__snapshots__/tr_only.snap new file mode 100755 index 000000000..b5c43c811 --- /dev/null +++ b/internal/printer/__snapshots__/tr_only.snap @@ -0,0 +1,41 @@ + +[TestPrinter/tr_only - 1] +## Input + +``` +col 1col 2{foo} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}col 1col 2${foo}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/trailing_expression.snap b/internal/printer/__snapshots__/trailing_expression.snap new file mode 100755 index 000000000..4e890049c --- /dev/null +++ b/internal/printer/__snapshots__/trailing_expression.snap @@ -0,0 +1,41 @@ + +[TestPrinter/trailing_expression - 1] +## Input + +``` +{} +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{})}${(void 0)}`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/transition_animate_on_Component.snap b/internal/printer/__snapshots__/transition_animate_on_Component.snap new file mode 100755 index 000000000..bea44a654 --- /dev/null +++ b/internal/printer/__snapshots__/transition_animate_on_Component.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:animate_on_Component - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Page = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'Component',Component,{"class":"bar","data-astro-transition-scope":($$renderTransition($$result, "wkm5vset", "morph", ""))})}`; +}, '/projects/app/src/pages/page.astro', 'self'); +export default $$Page; +``` +--- diff --git a/internal/printer/__snapshots__/transition_animate_with_an_expression.snap b/internal/printer/__snapshots__/transition_animate_with_an_expression.snap new file mode 100755 index 000000000..2a8cfef84 --- /dev/null +++ b/internal/printer/__snapshots__/transition_animate_with_an_expression.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:animate_with_an_expression - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Page = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, '/projects/app/src/pages/page.astro', 'self'); +export default $$Page; +``` +--- diff --git a/internal/printer/__snapshots__/transition_name_with_an_expression.snap b/internal/printer/__snapshots__/transition_name_with_an_expression.snap new file mode 100755 index 000000000..afdd28fdf --- /dev/null +++ b/internal/printer/__snapshots__/transition_name_with_an_expression.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:name_with_an_expression - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Page = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, '/projects/app/src/pages/page.astro', 'self'); +export default $$Page; +``` +--- diff --git a/internal/printer/__snapshots__/transition_name_with_an_template_literal.snap b/internal/printer/__snapshots__/transition_name_with_an_template_literal.snap new file mode 100755 index 000000000..adcd84809 --- /dev/null +++ b/internal/printer/__snapshots__/transition_name_with_an_template_literal.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:name_with_an_template_literal - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Page = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, '/projects/app/src/pages/page.astro', 'self'); +export default $$Page; +``` +--- diff --git a/internal/printer/__snapshots__/transition_persist-props_converted_to_a_data_attribute.snap b/internal/printer/__snapshots__/transition_persist-props_converted_to_a_data_attribute.snap new file mode 100755 index 000000000..bce20a07f --- /dev/null +++ b/internal/printer/__snapshots__/transition_persist-props_converted_to_a_data_attribute.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:persist-props_converted_to_a_data_attribute - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$renderComponent($$result,'my-island','my-island',{"data-astro-transition-persist-props":"false","data-astro-transition-persist":($$createTransitionScope($$result, "otghnj5u"))})}`; +}, undefined, 'self'); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/transition_persist_converted_to_a_data_attribute.snap b/internal/printer/__snapshots__/transition_persist_converted_to_a_data_attribute.snap new file mode 100755 index 000000000..869008869 --- /dev/null +++ b/internal/printer/__snapshots__/transition_persist_converted_to_a_data_attribute.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:persist_converted_to_a_data_attribute - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, 'self'); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/transition_persist_uses_transition_name_if_defined.snap b/internal/printer/__snapshots__/transition_persist_uses_transition_name_if_defined.snap new file mode 100755 index 000000000..5ae784b94 --- /dev/null +++ b/internal/printer/__snapshots__/transition_persist_uses_transition_name_if_defined.snap @@ -0,0 +1,42 @@ + +[TestPrinter/transition:persist_uses_transition:name_if_defined - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import "transitions.css"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, 'self'); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/type_import.snap b/internal/printer/__snapshots__/type_import.snap new file mode 100755 index 000000000..80b6c7298 --- /dev/null +++ b/internal/printer/__snapshots__/type_import.snap @@ -0,0 +1,47 @@ + +[TestPrinter/type_import - 1] +## Input + +``` +/-/-/-/ +import type data from "test" +/-/-/-/ + +
{data}
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; +import type data from "test" + + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
${data}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/unusual_line_terminator_I.snap b/internal/printer/__snapshots__/unusual_line_terminator_I.snap new file mode 100755 index 000000000..dd8314cf1 --- /dev/null +++ b/internal/printer/__snapshots__/unusual_line_terminator_I.snap @@ -0,0 +1,41 @@ + +[TestPrinter/unusual_line_terminator_I - 1] +## Input + +``` +Pre-set & Time-limited \u2028holiday campaigns +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`Pre-set & Time-limited \\u2028holiday campaigns`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/unusual_line_terminator_II.snap b/internal/printer/__snapshots__/unusual_line_terminator_II.snap new file mode 100755 index 000000000..78f0e17ad --- /dev/null +++ b/internal/printer/__snapshots__/unusual_line_terminator_II.snap @@ -0,0 +1,41 @@ + +[TestPrinter/unusual_line_terminator_II - 1] +## Input + +``` +Pre-set & Time-limited 
holiday campaigns +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`Pre-set & Time-limited 
holiday campaigns`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/user-defined_`implicit`_is_printed.snap b/internal/printer/__snapshots__/user-defined_`implicit`_is_printed.snap new file mode 100755 index 000000000..a28ca3242 --- /dev/null +++ b/internal/printer/__snapshots__/user-defined_`implicit`_is_printed.snap @@ -0,0 +1,41 @@ + +[TestPrinter/user-defined_`implicit`_is_printed - 1] +## Input + +``` + +``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render``; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index 1b2863dfb..454ceaee4 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -2,12 +2,12 @@ package printer import ( "fmt" - "math/rand" "regexp" "strconv" "strings" "testing" + "github.com/gkampitakis/go-snaps/snaps" astro "github.com/withastro/compiler/internal" "github.com/withastro/compiler/internal/handler" types "github.com/withastro/compiler/internal/t" @@ -49,9 +49,6 @@ export default $$Component;` var CREATE_ASTRO_CALL = "const $$Astro = $$createAstro('https://astro.build');\nconst Astro = $$Astro;" var RENDER_HEAD_RESULT = "${$$renderHead($$result)}" -// SPECIAL TEST FIXTURES -var NON_WHITESPACE_CHARS = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'\",.?") - func suffixWithFilename(filename string, transitions bool) string { propagationArg := "undefined" if transitions { @@ -96,8 +93,8 @@ type jsonTestcase struct { func TestPrinter(t *testing.T) { longRandomString := "" - for i := 0; i < 4080; i++ { - longRandomString += string(NON_WHITESPACE_CHARS[rand.Intn(len(NON_WHITESPACE_CHARS))]) + for i := 0; i < 40; i++ { + longRandomString += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[];:'\",.?" } tests := []testcase{ @@ -3707,6 +3704,23 @@ const meta = { title: 'My App' }; if diff := test_utils.ANSIDiff(test_utils.RemoveNewlines(test_utils.Dedent(toMatch)), test_utils.RemoveNewlines(test_utils.Dedent(output))); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) } + + snapshotName := strings.ReplaceAll(tt.name, "#", "_") + snapshotName = strings.ReplaceAll(snapshotName, "<", "_") + snapshotName = strings.ReplaceAll(snapshotName, ">", "_") + snapshotName = strings.ReplaceAll(snapshotName, ")", "_") + snapshotName = strings.ReplaceAll(snapshotName, "(", "_") + snapshotName = strings.ReplaceAll(snapshotName, ":", "_") + snapshotName = strings.ReplaceAll(snapshotName, " ", "_") + snapshotName = strings.ReplaceAll(snapshotName, "#", "_") + + s := snaps.WithConfig( + snaps.Filename(snapshotName), + ) + + snapshot := fmt.Sprintf("%s%s%s%s%s%s%s%s", "## Input\n\n", "```\n", test_utils.Dedent(code), "\n```", "\n\n## Output\n\n", "```js\n", test_utils.Dedent(output), "\n```") + + s.MatchSnapshot(t, snapshot) }) } }