From 99d61877d6f411f33e0db578f04b333fb2110ddd Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 20 May 2022 00:45:51 -0700 Subject: [solid] more progress, no fragments, but still not right --- .../solid-dom-fixtures/SVG/code.js | 74 ++++ .../solid-dom-fixtures/SVG/output.bun.js | 33 ++ .../solid-dom-fixtures/SVG/output.js | 108 +++++ .../attributeExpressions/code.js | 115 ++++++ .../attributeExpressions/output.bun.js | 155 +++++++ .../attributeExpressions/output.js | 241 +++++++++++ .../solid-dom-fixtures/components/code.js | 161 ++++++++ .../solid-dom-fixtures/components/output.bun.js | 205 ++++++++++ .../solid-dom-fixtures/components/output.js | 443 +++++++++++++++++++++ .../conditionalExpressions/code.js | 71 ++++ .../conditionalExpressions/output.bun.js | 144 +++++++ .../conditionalExpressions/output.js | 319 +++++++++++++++ .../solid-dom-fixtures/customElements/code.js | 29 ++ .../customElements/output.bun.js | 27 ++ .../solid-dom-fixtures/customElements/output.js | 66 +++ .../solid-dom-fixtures/eventExpressions/code.js | 32 ++ .../eventExpressions/output.bun.js | 57 +++ .../solid-dom-fixtures/eventExpressions/output.js | 63 +++ .../solid-dom-fixtures/fragments/code.js | 83 ++++ .../solid-dom-fixtures/fragments/output.bun.js | 13 + .../solid-dom-fixtures/fragments/output.js | 66 +++ .../solid-dom-fixtures/insertChildren/code.js | 36 ++ .../solid-dom-fixtures/insertChildren/output.js | 185 +++++++++ .../solid-dom-fixtures/namespaceElements/code.js | 6 + .../solid-dom-fixtures/namespaceElements/output.js | 16 + .../solid-dom-fixtures/simpleElements/code.js | 9 + .../simpleElements/output.bun.js | 5 + .../solid-dom-fixtures/simpleElements/output.js | 8 + .../solid-dom-fixtures/textInterpolation/code.js | 72 ++++ .../textInterpolation/output.bun.js | 71 ++++ .../solid-dom-fixtures/textInterpolation/output.js | 144 +++++++ 31 files changed, 3057 insertions(+) create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/SVG/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/components/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/components/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/components/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/customElements/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/fragments/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/code.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.bun.js create mode 100644 integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.js (limited to 'integration/bunjs-only-snippets') diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/code.js new file mode 100644 index 000000000..0ffded054 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/code.js @@ -0,0 +1,74 @@ +const template = ( + + + + + + +); + +const template2 = ( + + + +); + +const template3 = ( + + + +); + +const template4 = ; + +const template5 = ( + <> + + +); + +const template6 = ( + + + +); + +const template7 = ( + + + + MDN Web Docs + + + +); + +const template8 = ( + + + +); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.bun.js new file mode 100644 index 000000000..44d092f15 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.bun.js @@ -0,0 +1,33 @@ +var _tmpl$1 = _template$('', 4), _tmpl$2 = _template$('', 2), _tmpl$3 = _template$('', 2), _tmpl$4 = _template$('', 0), _tmpl$5 = _template$('MDN Web Docs', 6), _tmpl$6 = _template$('', 2); +const template = _tmpl$1.cloneNode(true); +const template2 = () => { + var _el = _tmpl$1.cloneNode(true); + effect(() => { + return setAttribute(_el, "className", state.name); + }); + effect(() => { + return setAttribute(_el, "stroke-width", state.width); + }); + effect(() => { + return setAttribute(_el, "x", state.x); + }); + effect(() => { + return setAttribute(_el, "y", state.y); + }); + ; + return _el; +}; +const template3 = _tmpl$3.cloneNode(true); +const template4 = _tmpl$4.cloneNode(true); +const template5 = ; +const template6 = createComponent(Component, {}); +const template7 = () => { + var _el = _tmpl$4.cloneNode(true); + setAttribute(_el, "xlink:href", url); + return _el; +}; +const template8 = () => { + var _el = _tmpl$5.cloneNode(true); + setAttribute(_el, "textContent", text); + return _el; +}; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.js new file mode 100644 index 000000000..edac460af --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/SVG/output.js @@ -0,0 +1,108 @@ +import { template as _$template } from "r-dom"; +import { setAttributeNS as _$setAttributeNS } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; +import { spread as _$spread } from "r-dom"; +import { setAttribute as _$setAttribute } from "r-dom"; +import { effect as _$effect } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template( + ``, + 8 + ), + _tmpl$2 = /*#__PURE__*/ _$template( + ``, + 4 + ), + _tmpl$3 = /*#__PURE__*/ _$template( + ``, + 4 + ), + _tmpl$4 = /*#__PURE__*/ _$template( + ``, + 4, + true + ), + _tmpl$5 = /*#__PURE__*/ _$template( + `MDN Web Docs`, + 6 + ), + _tmpl$6 = /*#__PURE__*/ _$template( + ``, + 4 + ); + +const template = _tmpl$.cloneNode(true); + +const template2 = (() => { + const _el$2 = _tmpl$2.cloneNode(true), + _el$3 = _el$2.firstChild; + + _el$3.style.setProperty("fill", "red"); + + _el$3.style.setProperty("stroke", "black"); + + _el$3.style.setProperty("opacity", "0.5"); + + _$effect( + (_p$) => { + const _v$ = state.name, + _v$2 = state.width, + _v$3 = state.x, + _v$4 = state.y, + _v$5 = props.stroke; + _v$ !== _p$._v$ && _$setAttribute(_el$3, "class", (_p$._v$ = _v$)); + _v$2 !== _p$._v$2 && + _$setAttribute(_el$3, "stroke-width", (_p$._v$2 = _v$2)); + _v$3 !== _p$._v$3 && _$setAttribute(_el$3, "x", (_p$._v$3 = _v$3)); + _v$4 !== _p$._v$4 && _$setAttribute(_el$3, "y", (_p$._v$4 = _v$4)); + _v$5 !== _p$._v$5 && + _el$3.style.setProperty("stroke-width", (_p$._v$5 = _v$5)); + return _p$; + }, + { + _v$: undefined, + _v$2: undefined, + _v$3: undefined, + _v$4: undefined, + _v$5: undefined, + } + ); + + return _el$2; +})(); + +const template3 = (() => { + const _el$4 = _tmpl$3.cloneNode(true), + _el$5 = _el$4.firstChild; + + _$spread(_el$5, props, true, false); + + return _el$4; +})(); + +const template4 = _tmpl$4.cloneNode(true); + +const template5 = _tmpl$4.cloneNode(true); + +const template6 = _$createComponent(Component, { + get children() { + return _tmpl$4.cloneNode(true); + }, +}); + +const template7 = (() => { + const _el$9 = _tmpl$5.cloneNode(true), + _el$10 = _el$9.firstChild; + + _$setAttributeNS(_el$10, "http://www.w3.org/1999/xlink", "xlink:href", url); + + return _el$9; +})(); + +const template8 = (() => { + const _el$11 = _tmpl$6.cloneNode(true), + _el$12 = _el$11.firstChild; + + _el$12.textContent = text; + return _el$11; +})(); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/code.js new file mode 100644 index 000000000..b64949434 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/code.js @@ -0,0 +1,115 @@ +const selected = true; +let id = "my-h1"; +let link; +const template = ( + +); + +const template2 = ( +
+
+
+
"} /> +
+); + +const template3 = ( +
+); + +const template4 = ( +
+); + +const template5 =
; + +const template6 =
; + +const template7 = ( +
+); + +let refTarget; +const template8 =
; + +const template9 =
console.log(e)} />; + +const template10 =
; + +const template11 =
; + +const template12 =
; + +const template13 = ; + +const template14 = ; + +const template15 =
`$`
; + +const template16 = ( + +); + +const template17 = ( + +); + +const template18 = ( +
+); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.bun.js new file mode 100644 index 000000000..4bb3e1b39 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.bun.js @@ -0,0 +1,155 @@ +var _tmpl = _template$( + '', + 6 + ), + _tmpl$2 = _template$( + '
', + 2 + ), + _tmpl$2 = _template$("
", 0), + _tmpl$3 = _template$('
', 0), + _tmpl$5 = _template$('
', 0), + _tmpl$5 = _template$('
', 0), + _tmpl$6 = _template$("
", 0), + _tmpl$8 = _template$('', 0), + _tmpl$8 = _template$('', 0), + _tmpl$10 = _template$('
`$`
', 2), + _tmpl$10 = _template$( + '', + 2 + ), + _tmpl$11 = _template$("", 2); +const selected = true; +let id = "my-h1"; +let link; +const template = () => { + var _el = _tmpl.cloneNode(true), + _el$1 = _el.firstChild, + _el$2 = _el$1.nextSibling; + effect(() => { + return setAttribute(_el, "classList", { selected: unknown }); + }); + setAttribute(_el$1, "id", id); + effect(() => { + return setAttribute(_el$1, "title", welcoming()); + }); + effect(() => { + return setAttribute(_el$1, "classList", { dynamic: dynamic(), selected }); + }); + setAttribute(_el$2, "ref", link); + effect(() => { + return setAttribute(_el$2, "classList", { "ccc ddd": true }); + }); + setAttribute(_el$2, "readonly", value); + return _el; +}; +const template2 = () => { + var _el = _tmpl$1.cloneNode(true), + _el$1 = _el.firstChild; + setAttribute(_el, "textContent", rowId); + effect(() => { + return setAttribute(_el$1, "textContent", row.label); + }); + return _el; +}; +const template3 = () => { + var _el = _tmpl$2.cloneNode(true); + effect(() => { + return setAttribute(_el, "id", state.id); + }); + effect(() => { + return setAttribute(_el, "name", state.name); + }); + effect(() => { + return setAttribute(_el, "textContent", state.content); + }); + return _el; +}; +const template4 = () => { + var _el = _tmpl$3.cloneNode(true); + effect(() => { + return setAttribute(_el, "className", state.class); + }); + effect(() => { + return setAttribute(_el, "classList", { "ccc:ddd": true }); + }); + return _el; +}; +const template5 = _tmpl$5.cloneNode(true); +const template6 = () => { + var _el = _tmpl$5.cloneNode(true); + return _el; +}; +const template7 = () => { + var _el = _tmpl$2.cloneNode(true); + effect(() => { + return setAttribute(_el, "style:padding-top", props.top); + }); + effect(() => { + return setAttribute(_el, "class:my-class", props.active); + }); + return _el; +}; +let refTarget; +const template8 = () => { + var _el = _tmpl$2.cloneNode(true); + setAttribute(_el, "ref", refTarget); + return _el; +}; +const template9 = () => { + var _el = _tmpl$2.cloneNode(true); + effect(() => { + return setAttribute(_el, "ref", (e) => console.log(e)); + }); + return _el; +}; +const template10 = () => { + var _el = _tmpl$2.cloneNode(true); + effect(() => { + return setAttribute(_el, "ref", refFactory()); + }); + return _el; +}; +const template11 = () => { + var _el = _tmpl$6.cloneNode(true); + setAttribute(_el, "use:another", thing); + return _el; +}; +const template12 = () => { + var _el = _tmpl$2.cloneNode(true); + setAttribute(_el, "prop:htmlFor", thing); + return _el; +}; +const template13 = _tmpl$8.cloneNode(true); +const template14 = () => { + var _el = _tmpl$8.cloneNode(true); + effect(() => { + return setAttribute(_el, "checked", state.visible); + }); + return _el; +}; +const template15 = _tmpl$10.cloneNode(true); +const template16 = () => { + var _el = _tmpl$10.cloneNode(true); + effect(() => { + return setAttribute(_el, "classList", { + hi: "k", + }); + }); + return _el; +}; +const template17 = () => { + var _el = _tmpl$11.cloneNode(true); + effect(() => { + return setAttribute(_el, "classList", { + a: true, + b: true, + c: true, + }); + }); + effect(() => { + return (_el.$$click = increment); + }); + return _el; +}; +const template18 = _tmpl$2.cloneNode(true); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.js new file mode 100644 index 000000000..14f700218 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/attributeExpressions/output.js @@ -0,0 +1,241 @@ +const _tmpl$ = /*#__PURE__*/ _$template( + ``, + 6 + ), + _tmpl$2 = /*#__PURE__*/ _$template( + `
`, + 8 + ), + _tmpl$3 = /*#__PURE__*/ _$template(`
`, 2), + _tmpl$4 = /*#__PURE__*/ _$template(`
`, 2), + _tmpl$5 = /*#__PURE__*/ _$template(``, 1), + _tmpl$6 = /*#__PURE__*/ _$template(`
\`$\`
`, 2), + _tmpl$7 = /*#__PURE__*/ _$template( + ``, + 2 + ), + _tmpl$8 = /*#__PURE__*/ _$template(``, 2); + +const selected = true; +let id = "my-h1"; +let link; + +const template = (() => { + const _el$ = _tmpl$.cloneNode(true), + _el$2 = _el$.firstChild, + _el$3 = _el$2.firstChild; + + _$spread(_el$, results, false, true); + + _el$.classList.toggle("selected", unknown); + + _el$.style.setProperty("color", color); + + _$spread(_el$2, results, false, true); + + _el$2.style.setProperty("margin-right", "40px"); + + const _ref$ = link; + typeof _ref$ === "function" ? _ref$(_el$3) : (link = _el$3); + + _$classList(_el$3, { + "ccc ddd": true, + }); + + _el$3.readOnly = value; + + _$effect( + (_p$) => { + const _v$ = welcoming(), + _v$2 = color(), + _v$3 = !!dynamic(); + + _v$ !== _p$._v$ && _$setAttribute(_el$2, "title", (_p$._v$ = _v$)); + _v$2 !== _p$._v$2 && + _el$2.style.setProperty("background-color", (_p$._v$2 = _v$2)); + _v$3 !== _p$._v$3 && _el$2.classList.toggle("dynamic", (_p$._v$3 = _v$3)); + return _p$; + }, + { + _v$: undefined, + _v$2: undefined, + _v$3: undefined, + } + ); + + return _el$; +})(); + +const template2 = (() => { + const _el$4 = _tmpl$2.cloneNode(true), + _el$5 = _el$4.firstChild, + _el$6 = _el$5.nextSibling, + _el$7 = _el$6.firstChild, + _el$8 = _el$6.nextSibling; + + _$spread(_el$4, () => getProps("test"), false, true); + + _el$5.textContent = rowId; + _el$8.innerHTML = "
"; + + _$effect(() => (_el$7.data = row.label)); + + return _el$4; +})(); + +const template3 = (() => { + const _el$9 = _tmpl$3.cloneNode(true); + + _$setAttribute(_el$9, "id", state.id); + + _el$9.style.setProperty("background-color", state.color); + + _el$9.textContent = state.content; + + _$effect(() => _$setAttribute(_el$9, "name", state.name)); + + return _el$9; +})(); + +const template4 = (() => { + const _el$10 = _tmpl$3.cloneNode(true); + + _$classList(_el$10, { + "ccc:ddd": true, + }); + + _$effect(() => _$className(_el$10, `hi ${state.class || ""}`)); + + return _el$10; +})(); + +const template5 = _tmpl$4.cloneNode(true); + +const template6 = (() => { + const _el$12 = _tmpl$3.cloneNode(true); + + _el$12.textContent = "Hi"; + + _$effect((_$p) => _$style(_el$12, someStyle(), _$p)); + + return _el$12; +})(); + +const template7 = (() => { + const _el$13 = _tmpl$3.cloneNode(true); + + _$effect( + (_p$) => { + const _v$4 = { + "background-color": color(), + "margin-right": "40px", + ...props.style, + }, + _v$5 = props.top, + _v$6 = !!props.active; + + _p$._v$4 = _$style(_el$13, _v$4, _p$._v$4); + _v$5 !== _p$._v$5 && + _el$13.style.setProperty("padding-top", (_p$._v$5 = _v$5)); + _v$6 !== _p$._v$6 && + _el$13.classList.toggle("my-class", (_p$._v$6 = _v$6)); + return _p$; + }, + { + _v$4: undefined, + _v$5: undefined, + _v$6: undefined, + } + ); + + return _el$13; +})(); + +let refTarget; + +const template8 = (() => { + const _el$14 = _tmpl$3.cloneNode(true); + + const _ref$2 = refTarget; + typeof _ref$2 === "function" ? _ref$2(_el$14) : (refTarget = _el$14); + return _el$14; +})(); + +const template9 = (() => { + const _el$15 = _tmpl$3.cloneNode(true); + + ((e) => console.log(e))(_el$15); + + return _el$15; +})(); + +const template10 = (() => { + const _el$16 = _tmpl$3.cloneNode(true); + + const _ref$3 = refFactory(); + + typeof _ref$3 === "function" && _ref$3(_el$16); + return _el$16; +})(); + +const template11 = (() => { + const _el$17 = _tmpl$3.cloneNode(true); + + zero(_el$17, () => 0); + another(_el$17, () => thing); + something(_el$17, () => true); + return _el$17; +})(); + +const template12 = (() => { + const _el$18 = _tmpl$3.cloneNode(true); + + _el$18.htmlFor = thing; + return _el$18; +})(); + +const template13 = (() => { + const _el$19 = _tmpl$5.cloneNode(true); + + _el$19.checked = true; + return _el$19; +})(); + +const template14 = (() => { + const _el$20 = _tmpl$5.cloneNode(true); + + _$effect(() => (_el$20.checked = state.visible)); + + return _el$20; +})(); + +const template15 = _tmpl$6.cloneNode(true); + +const template16 = _tmpl$7.cloneNode(true); + +const template17 = (() => { + const _el$23 = _tmpl$8.cloneNode(true); + + _$addEventListener(_el$23, "click", increment, true); + + return _el$23; +})(); + +const template18 = (() => { + const _el$24 = _tmpl$3.cloneNode(true); + + _$spread( + _el$24, + () => ({ + get [key()]() { + return props.value; + }, + }), + false, + false + ); + + return _el$24; +})(); + +_$delegateEvents(["click"]); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/components/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/components/code.js new file mode 100644 index 000000000..f3bd159d6 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/components/code.js @@ -0,0 +1,161 @@ +import { Show } from "somewhere"; + +const Child = (props) => { + const [s, set] = createSignal(); + return ( + <> +
Hello {props.name}
+
{props.children}
+ + ); +}; + +const template = (props) => { + let childRef; + const { content } = props; + return ( +
+ +
From Parent
+
+ + {/* Comment Node */} +
{content}
+
+ + {(context) => context} + +
+ ); +}; + +const template2 = ( + (e = el)} + /> +); + +const template3 = ( + +
+
+
+ After + +); + +const [s, set] = createSignal(); +const template4 = {
}; + +const template5 = {state.dynamic}; + +// builtIns +const template6 = ( + }> + {(item) => {item}} + +); + +const template7 = ( + +
+ {state.dynamic} + +); + +const template8 = ( + + {(item) => item} + {(item) => item} + +); + +const template9 = <_garbage>Hi; + +const template10 = ( +
+ new + {" | "} + comments + {" | "} + show + {" | "} + ask + {" | "} + jobs + {" | "} + submit +
+); + +const template11 = ( +
+ new + {" | "} + comments + show + {" | "} + ask + jobs + {" | "} + submit +
+); + +const template12 = ( +
+ {" | "} + comments + {" | "} + {" | "} + {" | "} + show + {" | "} +
+); + +class Template13 { + render() { + this.shouldStay}> + {this.content} + ; + } +} + +const Template14 = {data()}; + +const Template15 = ; + +const Template16 = ; + +const Template17 = ( +
+    1 2 3
+  
+); +const Template18 = ( +
+    1
+    2
+    3
+  
+); + +const Template19 = ; + +const Template20 = ; + +const template21 = ( + +); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/components/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/components/output.bun.js new file mode 100644 index 000000000..5ab4d5614 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/components/output.bun.js @@ -0,0 +1,205 @@ +var _tmpl = _template$("
From Parent
", 9), _tmpl$1 = _template$("
| | | | |
", 8), _tmpl$2 = _template$("
| | |
", 8); +import {Show} from "somewhere"; +const Child = (props) => { + const [s, set] = createSignal(); + return ; +}; +const template = (props) => { + let childRef; + const { content } = props; + return () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, createComponent(Child, { + name: "John", + ref: childRef, + booleanProperty: true + }), null); + insert(_tmpl, content, null); + insert(_tmpl, createComponent(Child, { + name: "Jason", + ref: props.ref + }), null); + insert(_tmpl, createComponent(Context.Consumer, { + ref: props.consumerRef(), + get children: [ + (context) => context + ] + }), null); + return _tmpl; + }; +}; +const template2 = createComponent(Child, { + name: "Jake", + dynamic: state.data, + stale: state.data, + handleClick: clickHandler, + "hyphen-ated": state.data, + get ref: () => { + return (el) => e = el; + } +}); +const template3 = createComponent(Child, { + get children: [ + "After" + ] +}); +const [s, set] = createSignal(); +const template4 = createComponent(Child, { + ref: set +}); +const template5 = createComponent(Child, { + dynamic: state.dynamic, + get children: [ + state.dynamic + ] +}); +const template6 = createComponent(For, { + each: state.list, + fallback: , + get children: [ + (item) => createComponent(Show, { + when: state.condition, + get children: [ + item + ] + }) + ] +}); +const template7 = createComponent(Child, { + get children: [ + state.dynamic + ] +}); +const template8 = createComponent(Child, { + get children: [ + (item) => item, + (item) => item + ] +}); +const template9 = createComponent(_garbage, { + get children: [ + "Hi" + ] +}); +const template10 = () => { + var _tmpl$1 = _tmpl$1.cloneNode(true); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "new" + ] + }), null); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "comments" + ] + }), null); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "show" + ] + }), null); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "ask" + ] + }), null); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "jobs" + ] + }), null); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "submit" + ] + }), null); + return _tmpl$1; +}; +const template11 = () => { + var _tmpl$2 = _tmpl$2.cloneNode(true); + insert(_tmpl$2, createComponent(Link, { + get children: [ + "new" + ] + }), null); + insert(_tmpl$2, createComponent(Link, { + get children: [ + "comments" + ] + }), null); + insert(_tmpl$2, createComponent(Link, { + get children: [ + "show" + ] + }), null); + insert(_tmpl$2, createComponent(Link, { + get children: [ + "ask" + ] + }), null); + insert(_tmpl$2, createComponent(Link, { + get children: [ + "jobs" + ] + }), null); + insert(_tmpl$2, createComponent(Link, { + get children: [ + "submit" + ] + }), null); + return _tmpl$2; +}; +const template12 = () => { + var _tmpl$1 = _tmpl$1.cloneNode(true); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "comments" + ] + }), null); + insert(_tmpl$1, createComponent(Link, { + get children: [ + "show" + ] + }), null); + return _tmpl$1; +}; + +class Template13 { + render() { + createComponent(Component, { + prop: this.something, + get onClick: () => { + return () => this.shouldStay; + }, + get children: [ + createComponent(Nested, { + prop: this.data, + get children: [ + this.content + ] + }) + ] + }); + } +} +const Template14 = createComponent(Component, { + get children: [ + data() + ] +}); +const Template15 = createComponent(Component, {}); +const Template16 = createComponent(Component, { + something +}); +const Template17 = createComponent(Pre, { + get children: [ + " ", + " " + ] +}); +const Template18 = createComponent(Pre, {}); +const Template19 = createComponent(Component, {}); +const Template20 = createComponent(Component, { + class: prop.red ? "red" : "green" +}); +const template21 = createComponent(Component, {}); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/components/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/components/output.js new file mode 100644 index 000000000..0c49d60a3 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/components/output.js @@ -0,0 +1,443 @@ +import { template as _$template } from "r-dom"; +import { memo as _$memo } from "r-dom"; +import { For as _$For } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; +import { mergeProps as _$mergeProps } from "r-dom"; +import { insert as _$insert } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(`
Hello
`, 2), + _tmpl$2 = /*#__PURE__*/ _$template(`
`, 2), + _tmpl$3 = /*#__PURE__*/ _$template(`
From Parent
`, 2), + _tmpl$4 = /*#__PURE__*/ _$template( + `
| | | | |
`, + 6 + ), + _tmpl$5 = /*#__PURE__*/ _$template(`
| | |
`, 4), + _tmpl$6 = /*#__PURE__*/ _$template(`
| | | | |
`, 4), + _tmpl$7 = /*#__PURE__*/ _$template(`1`, 2), + _tmpl$8 = /*#__PURE__*/ _$template(`2`, 2), + _tmpl$9 = /*#__PURE__*/ _$template(`3`, 2); + +import { Show } from "somewhere"; + +const Child = (props) => { + const [s, set] = createSignal(); + return [ + (() => { + const _el$ = _tmpl$.cloneNode(true), + _el$2 = _el$.firstChild; + + const _ref$ = props.ref; + typeof _ref$ === "function" ? _ref$(_el$) : (props.ref = _el$); + + _$insert(_el$, () => props.name, null); + + return _el$; + })(), + (() => { + const _el$3 = _tmpl$2.cloneNode(true); + + set(_el$3); + + _$insert(_el$3, () => props.children); + + return _el$3; + })(), + ]; +}; + +const template = (props) => { + let childRef; + const { content } = props; + return (() => { + const _el$4 = _tmpl$2.cloneNode(true); + + _$insert( + _el$4, + _$createComponent( + Child, + _$mergeProps( + { + name: "John", + }, + props, + { + ref(r$) { + const _ref$2 = childRef; + typeof _ref$2 === "function" ? _ref$2(r$) : (childRef = r$); + }, + + booleanProperty: true, + + get children() { + return _tmpl$3.cloneNode(true); + }, + } + ) + ), + null + ); + + _$insert( + _el$4, + _$createComponent( + Child, + _$mergeProps( + { + name: "Jason", + }, + dynamicSpread, + { + ref(r$) { + const _ref$3 = props.ref; + typeof _ref$3 === "function" ? _ref$3(r$) : (props.ref = r$); + }, + + get children() { + const _el$6 = _tmpl$2.cloneNode(true); + + _$insert(_el$6, content); + + return _el$6; + }, + } + ) + ), + null + ); + + _$insert( + _el$4, + _$createComponent(Context.Consumer, { + ref(r$) { + const _ref$4 = props.consumerRef(); + + typeof _ref$4 === "function" && _ref$4(r$); + }, + + children: (context) => context, + }), + null + ); + + return _el$4; + })(); +}; + +const template2 = _$createComponent(Child, { + name: "Jake", + + get dynamic() { + return state.data; + }, + + stale: state.data, + handleClick: clickHandler, + + get ["hyphen-ated"]() { + return state.data; + }, + + ref: (el) => (e = el), +}); + +const template3 = _$createComponent(Child, { + get children() { + return [ + _tmpl$2.cloneNode(true), + _tmpl$2.cloneNode(true), + _tmpl$2.cloneNode(true), + "After", + ]; + }, +}); + +const [s, set] = createSignal(); + +const template4 = _$createComponent(Child, { + ref: set, + + get children() { + return _tmpl$2.cloneNode(true); + }, +}); + +const template5 = _$createComponent(Child, { + get dynamic() { + return state.dynamic; + }, + + get children() { + return state.dynamic; + }, +}); // builtIns + +const template6 = _$createComponent(_$For, { + get each() { + return state.list; + }, + + get fallback() { + return _$createComponent(Loading, {}); + }, + + children: (item) => + _$createComponent(Show, { + get when() { + return state.condition; + }, + + children: item, + }), +}); + +const template7 = _$createComponent(Child, { + get children() { + return [_tmpl$2.cloneNode(true), _$memo(() => state.dynamic)]; + }, +}); + +const template8 = _$createComponent(Child, { + get children() { + return [(item) => item, (item) => item]; + }, +}); + +const template9 = _$createComponent(_garbage, { + children: "Hi", +}); + +const template10 = (() => { + const _el$12 = _tmpl$4.cloneNode(true), + _el$13 = _el$12.firstChild, + _el$18 = _el$13.nextSibling, + _el$14 = _el$18.nextSibling, + _el$19 = _el$14.nextSibling, + _el$15 = _el$19.nextSibling, + _el$20 = _el$15.nextSibling, + _el$16 = _el$20.nextSibling, + _el$21 = _el$16.nextSibling, + _el$17 = _el$21.nextSibling; + + _$insert( + _el$12, + _$createComponent(Link, { + children: "new", + }), + _el$13 + ); + + _$insert( + _el$12, + _$createComponent(Link, { + children: "comments", + }), + _el$18 + ); + + _$insert( + _el$12, + _$createComponent(Link, { + children: "show", + }), + _el$19 + ); + + _$insert( + _el$12, + _$createComponent(Link, { + children: "ask", + }), + _el$20 + ); + + _$insert( + _el$12, + _$createComponent(Link, { + children: "jobs", + }), + _el$21 + ); + + _$insert( + _el$12, + _$createComponent(Link, { + children: "submit", + }), + null + ); + + return _el$12; +})(); + +const template11 = (() => { + const _el$22 = _tmpl$5.cloneNode(true), + _el$23 = _el$22.firstChild, + _el$26 = _el$23.nextSibling, + _el$24 = _el$26.nextSibling, + _el$27 = _el$24.nextSibling, + _el$25 = _el$27.nextSibling; + + _$insert( + _el$22, + _$createComponent(Link, { + children: "new", + }), + _el$23 + ); + + _$insert( + _el$22, + _$createComponent(Link, { + children: "comments", + }), + _el$26 + ); + + _$insert( + _el$22, + _$createComponent(Link, { + children: "show", + }), + _el$26 + ); + + _$insert( + _el$22, + _$createComponent(Link, { + children: "ask", + }), + _el$27 + ); + + _$insert( + _el$22, + _$createComponent(Link, { + children: "jobs", + }), + _el$27 + ); + + _$insert( + _el$22, + _$createComponent(Link, { + children: "submit", + }), + null + ); + + return _el$22; +})(); + +const template12 = (() => { + const _el$28 = _tmpl$6.cloneNode(true), + _el$29 = _el$28.firstChild, + _el$34 = _el$29.nextSibling, + _el$30 = _el$34.nextSibling, + _el$35 = _el$30.nextSibling, + _el$33 = _el$35.nextSibling; + + _$insert( + _el$28, + _$createComponent(Link, { + children: "comments", + }), + _el$34 + ); + + _$insert( + _el$28, + _$createComponent(Link, { + children: "show", + }), + _el$35 + ); + + return _el$28; +})(); + +class Template13 { + render() { + const _self$ = this; + + _$createComponent(Component, { + get prop() { + return _self$.something; + }, + + onClick: () => _self$.shouldStay, + + get children() { + return _$createComponent(Nested, { + get prop() { + return _self$.data; + }, + + get children() { + return _self$.content; + }, + }); + }, + }); + } +} + +const Template14 = _$createComponent(Component, { + get children() { + return data(); + }, +}); + +const Template15 = _$createComponent(Component, props); + +const Template16 = _$createComponent( + Component, + _$mergeProps( + { + something: something, + }, + props + ) +); + +const Template17 = _$createComponent(Pre, { + get children() { + return [ + _tmpl$7.cloneNode(true), + " ", + _tmpl$8.cloneNode(true), + " ", + _tmpl$9.cloneNode(true), + ]; + }, +}); + +const Template18 = _$createComponent(Pre, { + get children() { + return [ + _tmpl$7.cloneNode(true), + _tmpl$8.cloneNode(true), + _tmpl$9.cloneNode(true), + ]; + }, +}); + +const Template19 = _$createComponent( + Component, + _$mergeProps(() => s.dynamic()) +); + +const Template20 = _$createComponent(Component, { + get ["class"]() { + return prop.red ? "red" : "green"; + }, +}); + +const template21 = _$createComponent( + Component, + _$mergeProps(() => ({ + get [key()]() { + return props.value; + }, + })) +); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/code.js new file mode 100644 index 000000000..80f1a6a4f --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/code.js @@ -0,0 +1,71 @@ +const template1 =
{simple}
; + +const template2 =
{state.dynamic}
; + +const template3 =
{simple ? good : bad}
; + +const template4 =
{simple ? good() : bad}
; + +const template5 =
{state.dynamic ? good() : bad}
; + +const template6 =
{state.dynamic && good()}
; + +const template7 = ( +
{state.count > 5 ? (state.dynamic ? best : good()) : bad}
+); + +const template8 =
{state.dynamic && state.something && good()}
; + +const template9 =
{(state.dynamic && good()) || bad}
; + +const template10 = ( +
{state.a ? "a" : state.b ? "b" : state.c ? "c" : "fallback"}
+); + +const template11 = ( +
{state.a ? a() : state.b ? b() : state.c ? "c" : "fallback"}
+); + +const template12 = ; + +// no dynamic predicate +const template13 = ; + +const template14 = ; + +// no dynamic predicate +const template15 = ; + +const template16 = ; + +const template17 = : } />; + +const template18 = {state.dynamic ? : }; + +const template19 =
: } />; + +const template20 =
{state.dynamic ? : }
; + +const template21 = ; + +const template22 = {state?.dynamic ? "a" : "b"}; + +const template23 =
; + +const template24 =
{state?.dynamic ? "a" : "b"}
; + +const template25 = } />; + +const template26 = {state.dynamic ?? }; + +const template27 =
} />; + +const template28 =
{state.dynamic ?? }
; + +const template29 =
{(thing() && thing1()) ?? thing2() ?? thing3()}
; + +const template30 =
{thing() || thing1() || thing2()}
; + +const template31 = ( + +); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.bun.js new file mode 100644 index 000000000..36c3f649b --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.bun.js @@ -0,0 +1,144 @@ +var _tmpl = template("", 2), _tmpl$1 = template("
", 0); +const template1 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, simple, null); + return _tmpl; +}; +const template2 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic, null); + return _tmpl; +}; +const template3 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, simple ? good : bad, null); + return _tmpl; +}; +const template4 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, simple ? good() : bad, null); + return _tmpl; +}; +const template5 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic ? good() : bad, null); + return _tmpl; +}; +const template6 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic && good(), null); + return _tmpl; +}; +const template7 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.count > 5 ? state.dynamic ? best : good() : bad, null); + return _tmpl; +}; +const template8 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic && state.something && good(), null); + return _tmpl; +}; +const template9 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic && good() || bad, null); + return _tmpl; +}; +const template10 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.a ? "a" : state.b ? "b" : state.c ? "c" : "fallback", null); + return _tmpl; +}; +const template11 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.a ? a() : state.b ? b() : state.c ? "c" : "fallback", null); + return _tmpl; +}; +const template12 = createComponent(Comp, { + render: state.dynamic ? good() : bad +}); +const template13 = createComponent(Comp, { + render: state.dynamic ? good : bad +}); +const template14 = createComponent(Comp, { + render: state.dynamic && good() +}); +const template15 = createComponent(Comp, { + render: state.dynamic && good +}); +const template16 = createComponent(Comp, { + render: state.dynamic || good() +}); +const template17 = createComponent(Comp, { + render: state.dynamic ? createComponent(Comp, {}) : createComponent(Comp, {}) +}); +const template18 = createComponent(Comp, { + get children: [ + state.dynamic ? createComponent(Comp, {}) : createComponent(Comp, {}) + ] +}); +const template19 = () => { + var _el = _tmpl$1.cloneNode(true); + effect(() => { + return setAttribute(_el, "innerHTML", state.dynamic ? createComponent(Comp, {}) : createComponent(Comp, {})); + }); + return _el; +}; +const template20 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic ? createComponent(Comp, {}) : createComponent(Comp, {}), null); + return _tmpl; +}; +const template21 = createComponent(Comp, { + render: state?.dynamic ? "a" : "b" +}); +const template22 = createComponent(Comp, { + get children: [ + state?.dynamic ? "a" : "b" + ] +}); +const template23 = () => { + var _el = _tmpl$1.cloneNode(true); + effect(() => { + return setAttribute(_el, "innerHTML", state?.dynamic ? "a" : "b"); + }); + return _el; +}; +const template24 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state?.dynamic ? "a" : "b", null); + return _tmpl; +}; +const template25 = createComponent(Comp, { + render: state.dynamic ?? createComponent(Comp, {}) +}); +const template26 = createComponent(Comp, { + get children: [ + state.dynamic ?? createComponent(Comp, {}) + ] +}); +const template27 = () => { + var _el = _tmpl$1.cloneNode(true); + effect(() => { + return setAttribute(_el, "innerHTML", state.dynamic ?? createComponent(Comp, {})); + }); + return _el; +}; +const template28 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, state.dynamic ?? createComponent(Comp, {}), null); + return _tmpl; +}; +const template29 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, (thing() && thing1()) ?? thing2() ?? thing3(), null); + return _tmpl; +}; +const template30 = () => { + var _tmpl = _tmpl.cloneNode(true); + insert(_tmpl, thing() || thing1() || thing2(), null); + return _tmpl; +}; +const template31 = createComponent(Comp, { + value: count() ? count() ? count() : count() : count() +}); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.js new file mode 100644 index 000000000..1511f4222 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/conditionalExpressions/output.js @@ -0,0 +1,319 @@ +import { template as _$template } from "r-dom"; +import { effect as _$effect } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; +import { memo as _$memo } from "r-dom"; +import { insert as _$insert } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(`
`, 2); + +const template1 = (() => { + const _el$ = _tmpl$.cloneNode(true); + + _$insert(_el$, simple); + + return _el$; +})(); + +const template2 = (() => { + const _el$2 = _tmpl$.cloneNode(true); + + _$insert(_el$2, () => state.dynamic); + + return _el$2; +})(); + +const template3 = (() => { + const _el$3 = _tmpl$.cloneNode(true); + + _$insert(_el$3, simple ? good : bad); + + return _el$3; +})(); + +const template4 = (() => { + const _el$4 = _tmpl$.cloneNode(true); + + _$insert(_el$4, () => (simple ? good() : bad)); + + return _el$4; +})(); + +const template5 = (() => { + const _el$5 = _tmpl$.cloneNode(true); + + _$insert( + _el$5, + (() => { + const _c$ = _$memo(() => !!state.dynamic, true); + + return () => (_c$() ? good() : bad); + })() + ); + + return _el$5; +})(); + +const template6 = (() => { + const _el$6 = _tmpl$.cloneNode(true); + + _$insert( + _el$6, + (() => { + const _c$2 = _$memo(() => !!state.dynamic, true); + + return () => _c$2() && good(); + })() + ); + + return _el$6; +})(); + +const template7 = (() => { + const _el$7 = _tmpl$.cloneNode(true); + + _$insert( + _el$7, + (() => { + const _c$3 = _$memo(() => state.count > 5, true); + + return () => + _c$3() + ? (() => { + const _c$4 = _$memo(() => !!state.dynamic, true); + + return () => (_c$4() ? best : good()); + })() + : bad; + })() + ); + + return _el$7; +})(); + +const template8 = (() => { + const _el$8 = _tmpl$.cloneNode(true); + + _$insert( + _el$8, + (() => { + const _c$5 = _$memo(() => !!(state.dynamic && state.something), true); + + return () => _c$5() && good(); + })() + ); + + return _el$8; +})(); + +const template9 = (() => { + const _el$9 = _tmpl$.cloneNode(true); + + _$insert( + _el$9, + (() => { + const _c$6 = _$memo(() => !!state.dynamic, true); + + return () => (_c$6() && good()) || bad; + })() + ); + + return _el$9; +})(); + +const template10 = (() => { + const _el$10 = _tmpl$.cloneNode(true); + + _$insert(_el$10, () => + state.a ? "a" : state.b ? "b" : state.c ? "c" : "fallback" + ); + + return _el$10; +})(); + +const template11 = (() => { + const _el$11 = _tmpl$.cloneNode(true); + + _$insert( + _el$11, + (() => { + const _c$7 = _$memo(() => !!state.a, true); + + return () => + _c$7() + ? a() + : (() => { + const _c$8 = _$memo(() => !!state.b, true); + + return () => (_c$8() ? b() : state.c ? "c" : "fallback"); + })(); + })() + ); + + return _el$11; +})(); + +const template12 = _$createComponent(Comp, { + get render() { + return _$memo(() => !!state.dynamic, true)() ? good() : bad; + }, +}); // no dynamic predicate + +const template13 = _$createComponent(Comp, { + get render() { + return state.dynamic ? good : bad; + }, +}); + +const template14 = _$createComponent(Comp, { + get render() { + return _$memo(() => !!state.dynamic, true)() && good(); + }, +}); // no dynamic predicate + +const template15 = _$createComponent(Comp, { + get render() { + return state.dynamic && good; + }, +}); + +const template16 = _$createComponent(Comp, { + get render() { + return state.dynamic || good(); + }, +}); + +const template17 = _$createComponent(Comp, { + get render() { + return _$memo(() => !!state.dynamic, true)() + ? _$createComponent(Comp, {}) + : _$createComponent(Comp, {}); + }, +}); + +const template18 = _$createComponent(Comp, { + get children() { + return _$memo(() => !!state.dynamic, true)() + ? _$createComponent(Comp, {}) + : _$createComponent(Comp, {}); + }, +}); + +const template19 = (() => { + const _el$12 = _tmpl$.cloneNode(true); + + _$effect( + () => + (_el$12.innerHTML = state.dynamic + ? _$createComponent(Comp, {}) + : _$createComponent(Comp, {})) + ); + + return _el$12; +})(); + +const template20 = (() => { + const _el$13 = _tmpl$.cloneNode(true); + + _$insert( + _el$13, + (() => { + const _c$9 = _$memo(() => !!state.dynamic, true); + + return () => + _c$9() ? _$createComponent(Comp, {}) : _$createComponent(Comp, {}); + })() + ); + + return _el$13; +})(); + +const template21 = _$createComponent(Comp, { + get render() { + return state?.dynamic ? "a" : "b"; + }, +}); + +const template22 = _$createComponent(Comp, { + get children() { + return state?.dynamic ? "a" : "b"; + }, +}); + +const template23 = (() => { + const _el$14 = _tmpl$.cloneNode(true); + + _$effect(() => (_el$14.innerHTML = state?.dynamic ? "a" : "b")); + + return _el$14; +})(); + +const template24 = (() => { + const _el$15 = _tmpl$.cloneNode(true); + + _$insert(_el$15, () => (state?.dynamic ? "a" : "b")); + + return _el$15; +})(); + +const template25 = _$createComponent(Comp, { + get render() { + return state.dynamic ?? _$createComponent(Comp, {}); + }, +}); + +const template26 = _$createComponent(Comp, { + get children() { + return state.dynamic ?? _$createComponent(Comp, {}); + }, +}); + +const template27 = (() => { + const _el$16 = _tmpl$.cloneNode(true); + + _$effect( + () => (_el$16.innerHTML = state.dynamic ?? _$createComponent(Comp, {})) + ); + + return _el$16; +})(); + +const template28 = (() => { + const _el$17 = _tmpl$.cloneNode(true); + + _$insert(_el$17, () => state.dynamic ?? _$createComponent(Comp, {})); + + return _el$17; +})(); + +const template29 = (() => { + const _el$18 = _tmpl$.cloneNode(true); + + _$insert( + _el$18, + (() => { + const _c$10 = _$memo(() => !!thing(), true); + + return () => (_c$10() && thing1()) ?? thing2() ?? thing3(); + })() + ); + + return _el$18; +})(); + +const template30 = (() => { + const _el$19 = _tmpl$.cloneNode(true); + + _$insert(_el$19, () => thing() || thing1() || thing2()); + + return _el$19; +})(); + +const template31 = _$createComponent(Comp, { + get value() { + return _$memo(() => !!count(), true)() + ? _$memo(() => !!count(), true)() + ? count() + : count() + : count(); + }, +}); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/code.js new file mode 100644 index 000000000..f2e2bd02d --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/code.js @@ -0,0 +1,29 @@ +const template = ( + +); + +const template2 = ( + +); + +const template3 = ( + +
Title
+
+); + +const template4 = ( + <> + + +); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.bun.js new file mode 100644 index 000000000..79c46280c --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.bun.js @@ -0,0 +1,27 @@ +var _tmpl = _template$("", 0), _tmpl$2 = _template$('
Title
', 4); +const template = () => { + var _el = _tmpl.cloneNode(true); + setAttribute(_el, "some-attr", name); + setAttribute(_el, "notProp", data); + setAttribute(_el, "attr:my-attr", data); + setAttribute(_el, "prop:someProp", data); + return _el; +}; +const template2 = () => { + var _el = _tmpl.cloneNode(true); + effect(() => { + return setAttribute(_el, "some-attr", state.name); + }); + effect(() => { + return setAttribute(_el, "notProp", state.data); + }); + effect(() => { + return setAttribute(_el, "attr:my-attr", state.data); + }); + effect(() => { + return setAttribute(_el, "prop:someProp", state.data); + }); + return _el; +}; +const template3 = _tmpl$2.cloneNode(true); +const template4 = ; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.js new file mode 100644 index 000000000..79274ce2c --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/customElements/output.js @@ -0,0 +1,66 @@ +import { template as _$template } from "r-dom"; +import { effect as _$effect } from "r-dom"; +import { getOwner as _$getOwner } from "r-dom"; +import { setAttribute as _$setAttribute } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(``, 2), + _tmpl$2 = /*#__PURE__*/ _$template( + `
Title
`, + 4 + ), + _tmpl$3 = /*#__PURE__*/ _$template(``, 2); + +const template = (() => { + const _el$ = document.importNode(_tmpl$, true); + + _el$.someAttr = name; + _el$.notprop = data; + + _$setAttribute(_el$, "my-attr", data); + + _el$.someProp = data; + _el$._$owner = _$getOwner(); + return _el$; +})(); + +const template2 = (() => { + const _el$2 = document.importNode(_tmpl$, true); + + _el$2._$owner = _$getOwner(); + + _$effect( + (_p$) => { + const _v$ = state.name, + _v$2 = state.data, + _v$3 = state.data, + _v$4 = state.data; + _v$ !== _p$._v$ && (_el$2.someAttr = _p$._v$ = _v$); + _v$2 !== _p$._v$2 && (_el$2.notprop = _p$._v$2 = _v$2); + _v$3 !== _p$._v$3 && _$setAttribute(_el$2, "my-attr", (_p$._v$3 = _v$3)); + _v$4 !== _p$._v$4 && (_el$2.someProp = _p$._v$4 = _v$4); + return _p$; + }, + { + _v$: undefined, + _v$2: undefined, + _v$3: undefined, + _v$4: undefined, + } + ); + + return _el$2; +})(); + +const template3 = (() => { + const _el$3 = document.importNode(_tmpl$2, true); + + _el$3._$owner = _$getOwner(); + return _el$3; +})(); + +const template4 = (() => { + const _el$4 = _tmpl$3.cloneNode(true); + + _el$4._$owner = _$getOwner(); + return _el$4; +})(); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/code.js new file mode 100644 index 000000000..78bc5e199 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/code.js @@ -0,0 +1,32 @@ +function hoisted1() { + console.log("hoisted"); +} +const hoisted2 = () => console.log("hoisted delegated"); + +const template = ( +
+ + + + + + + + + + + + +
+); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.bun.js new file mode 100644 index 000000000..5d90654f9 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.bun.js @@ -0,0 +1,57 @@ +var _tmpl$1 = _template$( + '
', + 26 +); +function hoisted1() { + console.log("hoisted"); +} +const hoisted2 = () => console.log("hoisted delegated"); +const template = () => { + var _el = _tmpl.cloneNode(true), + _el$1 = _el.firstChild, + _el$2 = _el$1.nextSibling, + _el$3 = _el$2.nextSibling, + _el$4 = _el$3.nextSibling, + _el$5 = _el$4.nextSibling, + _el$6 = _el$5.nextSibling, + _el$7 = _el$6.nextSibling, + _el$8 = _el$7.nextSibling, + _el$9 = _el$8.nextSibling, + _el$10 = _el$9.nextSibling, + _el$11 = _el$10.nextSibling; + effect(() => { + return setAttribute(_el, "onchange", () => console.log("bound")); + }); + effect(() => { + return setAttribute(_el$1, "onChange", [ + (id) => console.log("bound", id), + id, + ]); + }); + setAttribute(_el$2, "onchange", handler); + effect(() => { + return setAttribute(_el$3, "onchange", [handler]); + }); + setAttribute(_el$4, "onchange", hoisted1); + _el$5.$$click = () => console.log("delegated"); + effect(() => { + return (_el$6.$$click = [(id) => console.log("delegated", id), rowId]); + }); + effect(() => { + return (_el$7.$$click = handler); + }); + effect(() => { + return (_el$8.$$click = [handler]); + }); + effect(() => { + return (_el$9.$$click = hoisted2); + }); + _el$10.addEventListener("click", () => console.log("listener")); + _el$10.addEventListener("CAPS-ev", () => console.log("custom")); + _el$11.addEventListener( + "apture:camelClick", + () => console.log("listener"), + true + ); + return _el; +}; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.js new file mode 100644 index 000000000..c24a1f89f --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/eventExpressions/output.js @@ -0,0 +1,63 @@ +import { template as _$template } from "r-dom"; +import { delegateEvents as _$delegateEvents } from "r-dom"; +import { addEventListener as _$addEventListener } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template( + `
`, + 26 +); + +function hoisted1() { + console.log("hoisted"); +} + +const hoisted2 = () => console.log("hoisted delegated"); + +const template = (() => { + const _el$ = _tmpl$.cloneNode(true), + _el$2 = _el$.firstChild, + _el$3 = _el$2.nextSibling, + _el$4 = _el$3.nextSibling, + _el$5 = _el$4.nextSibling, + _el$6 = _el$5.nextSibling, + _el$7 = _el$6.nextSibling, + _el$8 = _el$7.nextSibling, + _el$9 = _el$8.nextSibling, + _el$10 = _el$9.nextSibling, + _el$11 = _el$10.nextSibling, + _el$12 = _el$11.nextSibling, + _el$13 = _el$12.nextSibling; + + _el$2.addEventListener("change", () => console.log("bound")); + + _el$3.addEventListener("change", (e) => + ((id) => console.log("bound", id))(id, e) + ); + + _$addEventListener(_el$4, "change", handler); + + _el$5.addEventListener("change", handler); + + _el$6.addEventListener("change", hoisted1); + + _el$7.$$click = () => console.log("delegated"); + + _el$8.$$click = (id) => console.log("delegated", id); + + _el$8.$$clickData = rowId; + + _$addEventListener(_el$9, "click", handler, true); + + _el$10.$$click = handler; + _el$11.$$click = hoisted2; + + _el$12.addEventListener("click", () => console.log("listener")); + + _el$12.addEventListener("CAPS-ev", () => console.log("custom")); + + _el$13.addEventListener("camelClick", () => console.log("listener"), true); + + return _el$; +})(); + +_$delegateEvents(["click"]); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/code.js new file mode 100644 index 000000000..0b6021e44 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/code.js @@ -0,0 +1,83 @@ +const multiStatic = ( + <> +
First
+
Last
+ +); + +const multiExpression = ( + <> +
First
+ {inserted} +
Last
+ After + +); + +const multiDynamic = ( + <> +
First
+ {state.inserted} +
Last
+ After + +); + +const singleExpression = <>{inserted}; + +const singleDynamic = <>{inserted()}; + +const firstStatic = ( + <> + {inserted} +
+ +); + +const firstDynamic = ( + <> + {inserted()} +
+ +); + +const firstComponent = ( + <> + +
+ +); + +const lastStatic = ( + <> +
+ {inserted} + +); + +const lastDynamic = ( + <> +
+ {inserted()} + +); + +const lastComponent = ( + <> +
+ + +); + +const spaces = ( + <> + 1 2 3 + +); +const multiLineTrailing = ( + <> + 1 + 2 + 3 + +); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.bun.js new file mode 100644 index 000000000..54d980cee --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.bun.js @@ -0,0 +1,13 @@ +const multiStatic = ; +const multiExpression = ; +const multiDynamic = ; +const singleExpression = ; +const singleDynamic = ; +const firstStatic = ; +const firstDynamic = ; +const firstComponent = ; +const lastStatic = ; +const lastDynamic = ; +const lastComponent = ; +const spaces = ; +const multiLineTrailing = ; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.js new file mode 100644 index 000000000..5fe0c767c --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/fragments/output.js @@ -0,0 +1,66 @@ +import { template as _$template } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; +import { memo as _$memo } from "r-dom"; +import { setAttribute as _$setAttribute } from "r-dom"; +import { effect as _$effect } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(`
First
`, 2), + _tmpl$2 = /*#__PURE__*/ _$template(`
Last
`, 2), + _tmpl$3 = /*#__PURE__*/ _$template(`
`, 2), + _tmpl$4 = /*#__PURE__*/ _$template(`1`, 2), + _tmpl$5 = /*#__PURE__*/ _$template(`2`, 2), + _tmpl$6 = /*#__PURE__*/ _$template(`3`, 2); + +const multiStatic = [_tmpl$.cloneNode(true), _tmpl$2.cloneNode(true)]; +const multiExpression = [ + _tmpl$.cloneNode(true), + inserted, + _tmpl$2.cloneNode(true), + "After", +]; +const multiDynamic = [ + (() => { + const _el$5 = _tmpl$.cloneNode(true); + + _$effect(() => _$setAttribute(_el$5, "id", state.first)); + + return _el$5; + })(), + _$memo(() => state.inserted), + (() => { + const _el$6 = _tmpl$2.cloneNode(true); + + _$effect(() => _$setAttribute(_el$6, "id", state.last)); + + return _el$6; + })(), + "After", +]; +const singleExpression = inserted; + +const singleDynamic = _$memo(inserted); + +const firstStatic = [inserted, _tmpl$3.cloneNode(true)]; +const firstDynamic = [_$memo(inserted), _tmpl$3.cloneNode(true)]; +const firstComponent = [ + _$createComponent(Component, {}), + _tmpl$3.cloneNode(true), +]; +const lastStatic = [_tmpl$3.cloneNode(true), inserted]; +const lastDynamic = [_tmpl$3.cloneNode(true), _$memo(inserted)]; +const lastComponent = [ + _tmpl$3.cloneNode(true), + _$createComponent(Component, {}), +]; +const spaces = [ + _tmpl$4.cloneNode(true), + " ", + _tmpl$5.cloneNode(true), + " ", + _tmpl$6.cloneNode(true), +]; +const multiLineTrailing = [ + _tmpl$4.cloneNode(true), + _tmpl$5.cloneNode(true), + _tmpl$6.cloneNode(true), +]; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/code.js new file mode 100644 index 000000000..41d3d017e --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/code.js @@ -0,0 +1,36 @@ +const children =
; +const dynamic = { + children, +}; +const template = ; +const template2 = ; +const template3 = Hello; +const template4 = ( + + + +); +const template5 = ; +const template6 = ; +const template7 = ; +const template8 = Hello; +const template9 = {dynamic.children}; +const template10 = Hello; +const template11 = ; +const template12 = ; +const template13 = {...children}; +const template14 = {...children}; +const template15 = {...dynamic.children}; +const template16 = {...dynamic.children}; +const template18 = Hi {...children}; +const template19 = Hi {...children}; +const template20 = {children()}; +const template21 = {children()}; +const template22 = {state.children()}; +const template23 = {state.children()}; + +const tiles = []; +tiles.push(
Test 1
); +const template24 =
{tiles}
; + +const comma =
{(expression(), "static")}
; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/output.js new file mode 100644 index 000000000..9ad937742 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/insertChildren/output.js @@ -0,0 +1,185 @@ +import { template as _$template } from "r-dom"; +import { mergeProps as _$mergeProps } from "r-dom"; +import { spread as _$spread } from "r-dom"; +import { insert as _$insert } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(`
`, 2), + _tmpl$2 = /*#__PURE__*/ _$template(``, 2), + _tmpl$3 = /*#__PURE__*/ _$template(`Hello`, 2), + _tmpl$4 = /*#__PURE__*/ _$template(`Hi `, 2), + _tmpl$5 = /*#__PURE__*/ _$template(`
Test 1
`, 2); + +const children = _tmpl$.cloneNode(true); + +const dynamic = { + children, +}; + +const template = _$createComponent(Module, { + children: children, +}); + +const template2 = (() => { + const _el$2 = _tmpl$2.cloneNode(true); + + _$insert(_el$2, children); + + return _el$2; +})(); + +const template3 = _tmpl$3.cloneNode(true); + +const template4 = (() => { + const _el$4 = _tmpl$2.cloneNode(true); + + _$insert(_el$4, _$createComponent(Hello, {})); + + return _el$4; +})(); + +const template5 = (() => { + const _el$5 = _tmpl$2.cloneNode(true); + + _$insert(_el$5, () => dynamic.children); + + return _el$5; +})(); + +const template6 = _$createComponent(Module, { + get children() { + return dynamic.children; + }, +}); + +const template7 = (() => { + const _el$6 = _tmpl$2.cloneNode(true); + + _$spread(_el$6, dynamic, false, false); + + return _el$6; +})(); + +const template8 = (() => { + const _el$7 = _tmpl$3.cloneNode(true); + + _$spread(_el$7, dynamic, false, true); + + return _el$7; +})(); + +const template9 = (() => { + const _el$8 = _tmpl$2.cloneNode(true); + + _$spread(_el$8, dynamic, false, true); + + _$insert(_el$8, () => dynamic.children); + + return _el$8; +})(); + +const template10 = _$createComponent( + Module, + _$mergeProps(dynamic, { + children: "Hello", + }) +); + +const template11 = (() => { + const _el$9 = _tmpl$2.cloneNode(true); + + _$insert(_el$9, state.children); + + return _el$9; +})(); + +const template12 = _$createComponent(Module, { + children: state.children, +}); + +const template13 = (() => { + const _el$10 = _tmpl$2.cloneNode(true); + + _$insert(_el$10, children); + + return _el$10; +})(); + +const template14 = _$createComponent(Module, { + children: children, +}); + +const template15 = (() => { + const _el$11 = _tmpl$2.cloneNode(true); + + _$insert(_el$11, () => dynamic.children); + + return _el$11; +})(); + +const template16 = _$createComponent(Module, { + get children() { + return dynamic.children; + }, +}); + +const template18 = (() => { + const _el$12 = _tmpl$4.cloneNode(true); + + _$insert(_el$12, children, null); + + return _el$12; +})(); + +const template19 = _$createComponent(Module, { + get children() { + return ["Hi ", children]; + }, +}); + +const template20 = (() => { + const _el$13 = _tmpl$2.cloneNode(true); + + _$insert(_el$13, children); + + return _el$13; +})(); + +const template21 = _$createComponent(Module, { + get children() { + return children(); + }, +}); + +const template22 = (() => { + const _el$14 = _tmpl$2.cloneNode(true); + + _$insert(_el$14, () => state.children()); + + return _el$14; +})(); + +const template23 = _$createComponent(Module, { + get children() { + return state.children(); + }, +}); + +const tiles = []; +tiles.push(_tmpl$5.cloneNode(true)); + +const template24 = (() => { + const _el$16 = _tmpl$.cloneNode(true); + + _$insert(_el$16, tiles); + + return _el$16; +})(); + +const comma = (() => { + const _el$17 = _tmpl$.cloneNode(true); + + _$insert(_el$17, () => (expression(), "static")); + + return _el$17; +})(); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/code.js new file mode 100644 index 000000000..7ad410329 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/code.js @@ -0,0 +1,6 @@ +const template = ; +const template2 = ; +const template3 = ; +const template4 = ; +const template5 = ; +const template6 = ; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/output.js new file mode 100644 index 000000000..162ffb140 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/namespaceElements/output.js @@ -0,0 +1,16 @@ +import { template as _$template } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(``, 2); + +const template = _$createComponent(module.A, {}); + +const template2 = _$createComponent(module.a.B, {}); + +const template3 = _$createComponent(module.A.B, {}); + +const template4 = _$createComponent(module["a-b"], {}); + +const template5 = _$createComponent(module["a-b"]["c-d"], {}); + +const template6 = _tmpl$.cloneNode(true); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/code.js new file mode 100644 index 000000000..c3537ee7d --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/code.js @@ -0,0 +1,9 @@ +const template = ( +
+ +

Welcome

+ + + {/* Comment Node */} +
+); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.bun.js new file mode 100644 index 000000000..72d61c1e3 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.bun.js @@ -0,0 +1,5 @@ +var _tmpl$1 = _template$( + '

Welcome

', + 8 +); +const template = _tmpl$1.cloneNode(true); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.js new file mode 100644 index 000000000..5d16f6767 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/simpleElements/output.js @@ -0,0 +1,8 @@ +import { template as _$template } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template( + `

Welcome

`, + 9 +); + +const template = _tmpl$.cloneNode(true); diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/code.js b/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/code.js new file mode 100644 index 000000000..21698ea89 --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/code.js @@ -0,0 +1,72 @@ +const trailing = Hello ; +const leading = John; + +/* prettier-ignore */ +const extraSpaces = Hello John; + +const trailingExpr = Hello {name}; +const leadingExpr = {greeting} John; + +/* prettier-ignore */ +const multiExpr = {greeting} {name}; + +/* prettier-ignore */ +const multiExprSpaced = {greeting} {name} ; + +/* prettier-ignore */ +const multiExprTogether = {greeting}{name} ; + +/* prettier-ignore */ +const multiLine = + + Hello + + + +/* prettier-ignore */ +const multiLineTrailingSpace = + Hello + John + + +/* prettier-ignore */ +const multiLineNoTrailingSpace = + Hello + John + + +/* prettier-ignore */ +const escape = +  <Hi>  + + +/* prettier-ignore */ +const escape2 = +  <Hi>  + + +/* prettier-ignore */ +const escape3 = <> +  <Hi>  + + +const injection = Hi{""}; + +let value = "World"; +const evaluated = Hello {value + "!"}; + +let number = 4 + 5; +const evaluatedNonString = 4 + 5 = {number}; + +const newLineLiteral = ( +
+ {s} + {"\n"}d +
+); + +const trailingSpace =
{expr}
; + +const trailingSpaceComp = {expr}; + +const trailingSpaceFrag = <>{expr}; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.bun.js b/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.bun.js new file mode 100644 index 000000000..eb4c5347a --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.bun.js @@ -0,0 +1,71 @@ +var _tmpl$1 = template("Hello ", 2), _tmpl$2 = template(" John", 2), _tmpl$3 = template("Hello John", 2), _tmpl$3 = template(" ", 4), _tmpl$4 = template(" ", 4), _tmpl$5 = template(" ", 4), _tmpl$7 = template("Hello", 2), _tmpl$8 = template("Hello John", 2), _tmpl$9 = template(" <Hi> ", 2), _tmpl$10 = template("Hi<script>alert();</script>", 2), _tmpl$10 = template("4 + 5 = ", 3), _tmpl$11 = template("
\nd
", 3), _tmpl$12 = template("", 2); +const trailing = _tmpl$1.cloneNode(true); +const leading = _tmpl$2.cloneNode(true); +const extraSpaces = _tmpl$3.cloneNode(true); +const trailingExpr = () => { + var _tmpl$1 = _tmpl$1.cloneNode(true); + insert(_tmpl$1, name, null); + return _tmpl$1; +}; +const leadingExpr = () => { + var _tmpl$2 = _tmpl$2.cloneNode(true); + insert(_tmpl$2, greeting, null); + return _tmpl$2; +}; +const multiExpr = () => { + var _tmpl$3 = _tmpl$3.cloneNode(true); + insert(_tmpl$3, greeting, null); + insert(_tmpl$3, name, null); + return _tmpl$3; +}; +const multiExprSpaced = () => { + var _tmpl$4 = _tmpl$4.cloneNode(true); + insert(_tmpl$4, greeting, null); + insert(_tmpl$4, name, null); + return _tmpl$4; +}; +const multiExprTogether = () => { + var _tmpl$5 = _tmpl$5.cloneNode(true); + insert(_tmpl$5, greeting, null); + insert(_tmpl$5, name, null); + return _tmpl$5; +}; +const multiLine = _tmpl$7.cloneNode(true); +const multiLineTrailingSpace = _tmpl$8.cloneNode(true); +const multiLineNoTrailingSpace = _tmpl$8.cloneNode(true); +const escape = _tmpl$9.cloneNode(true); +const escape2 = createComponent(Comp, { + get children: [ + "\xA0\xA0" + ] +}); +const escape3 = ; +const injection = _tmpl$10.cloneNode(true); +let value = "World"; +const evaluated = () => { + var _tmpl$1 = _tmpl$1.cloneNode(true); + insert(_tmpl$1, value + "!", null); + return _tmpl$1; +}; +let number = 4 + 5; +const evaluatedNonString = () => { + var _tmpl$10 = _tmpl$10.cloneNode(true); + insert(_tmpl$10, number, null); + return _tmpl$10; +}; +const newLineLiteral = () => { + var _tmpl$11 = _tmpl$11.cloneNode(true); + insert(_tmpl$11, s, null); + return _tmpl$11; +}; +const trailingSpace = () => { + var _tmpl$12 = _tmpl$12.cloneNode(true); + insert(_tmpl$12, expr, null); + return _tmpl$12; +}; +const trailingSpaceComp = createComponent(Comp, { + get children: [ + expr + ] +}); +const trailingSpaceFrag = ; diff --git a/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.js b/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.js new file mode 100644 index 000000000..b86a631fb --- /dev/null +++ b/integration/bunjs-only-snippets/solid-dom-fixtures/textInterpolation/output.js @@ -0,0 +1,144 @@ +import { template as _$template } from "r-dom"; +import { createComponent as _$createComponent } from "r-dom"; +import { insert as _$insert } from "r-dom"; + +const _tmpl$ = /*#__PURE__*/ _$template(`Hello `, 2), + _tmpl$2 = /*#__PURE__*/ _$template(` John`, 2), + _tmpl$3 = /*#__PURE__*/ _$template(`Hello John`, 2), + _tmpl$4 = /*#__PURE__*/ _$template(` `, 2), + _tmpl$5 = /*#__PURE__*/ _$template(` `, 4), + _tmpl$6 = /*#__PURE__*/ _$template(` `, 3), + _tmpl$7 = /*#__PURE__*/ _$template(`Hello`, 2), + _tmpl$8 = /*#__PURE__*/ _$template(` <Hi> `, 2), + _tmpl$9 = /*#__PURE__*/ _$template( + `Hi<script>alert();</script>`, + 2 + ), + _tmpl$10 = /*#__PURE__*/ _$template(`Hello World!`, 2), + _tmpl$11 = /*#__PURE__*/ _$template(`4 + 5 = 9`, 2), + _tmpl$12 = /*#__PURE__*/ _$template( + `
+d
`, + 2 + ), + _tmpl$13 = /*#__PURE__*/ _$template(`
`, 2); + +const trailing = _tmpl$.cloneNode(true); + +const leading = _tmpl$2.cloneNode(true); +/* prettier-ignore */ + +const extraSpaces = _tmpl$3.cloneNode(true); + +const trailingExpr = (() => { + const _el$4 = _tmpl$.cloneNode(true), + _el$5 = _el$4.firstChild; + + _$insert(_el$4, name, null); + + return _el$4; +})(); + +const leadingExpr = (() => { + const _el$6 = _tmpl$2.cloneNode(true), + _el$7 = _el$6.firstChild; + + _$insert(_el$6, greeting, _el$7); + + return _el$6; +})(); +/* prettier-ignore */ + +const multiExpr = (() => { + const _el$8 = _tmpl$4.cloneNode(true), + _el$9 = _el$8.firstChild; + + _$insert(_el$8, greeting, _el$9); + + _$insert(_el$8, name, null); + + return _el$8; +})(); +/* prettier-ignore */ + +const multiExprSpaced = (() => { + const _el$10 = _tmpl$5.cloneNode(true), + _el$11 = _el$10.firstChild, + _el$14 = _el$11.nextSibling, + _el$12 = _el$14.nextSibling, + _el$15 = _el$12.nextSibling, + _el$13 = _el$15.nextSibling; + + _$insert(_el$10, greeting, _el$14); + + _$insert(_el$10, name, _el$15); + + return _el$10; +})(); +/* prettier-ignore */ + +const multiExprTogether = (() => { + const _el$16 = _tmpl$6.cloneNode(true), + _el$17 = _el$16.firstChild, + _el$19 = _el$17.nextSibling, + _el$18 = _el$19.nextSibling; + + _$insert(_el$16, greeting, _el$19); + + _$insert(_el$16, name, _el$19); + + return _el$16; +})(); +/* prettier-ignore */ + +const multiLine = _tmpl$7.cloneNode(true); +/* prettier-ignore */ + +const multiLineTrailingSpace = _tmpl$3.cloneNode(true); +/* prettier-ignore */ + +const multiLineNoTrailingSpace = _tmpl$3.cloneNode(true); +/* prettier-ignore */ + +const escape = _tmpl$8.cloneNode(true); +/* prettier-ignore */ + +const escape2 = _$createComponent(Comp, { + children: "\xA0\xA0" +}); +/* prettier-ignore */ + +const escape3 = "\xA0\xA0"; + +const injection = _tmpl$9.cloneNode(true); + +let value = "World"; + +const evaluated = _tmpl$10.cloneNode(true); + +let number = 4 + 5; + +const evaluatedNonString = _tmpl$11.cloneNode(true); + +const newLineLiteral = (() => { + const _el$27 = _tmpl$12.cloneNode(true), + _el$28 = _el$27.firstChild; + + _$insert(_el$27, s, _el$28); + + return _el$27; +})(); + +const trailingSpace = (() => { + const _el$29 = _tmpl$13.cloneNode(true); + + _$insert(_el$29, expr); + + return _el$29; +})(); + +const trailingSpaceComp = _$createComponent(Comp, { + children: expr, +}); + +const trailingSpaceFrag = expr; -- cgit v1.2.3