|
1661 | 1661 | })(); |
1662 | 1662 |
|
1663 | 1663 | const exampleJS = `// index.tsx |
1664 | | -import { h as r, Fragment as s, render as c } from "preact"; |
| 1664 | +import { h as u, Fragment as l, render as c } from "preact"; |
1665 | 1665 |
|
1666 | 1666 | // counter.tsx |
1667 | | -import { h as t, Component as a } from "preact"; |
1668 | | -import { useState as l } from "preact/hooks"; |
1669 | | -var o = class extends a { |
| 1667 | +import { h as t, Component as i } from "preact"; |
| 1668 | +import { useState as a } from "preact/hooks"; |
| 1669 | +var n = class extends i { |
1670 | 1670 | constructor(e) { |
1671 | 1671 | super(e); |
1672 | | - this.state = { value: 0 }; |
1673 | | - this.increment = () => this.setState({ value: this.state.value + 1 }); |
1674 | | - this.decrement = () => this.setState({ value: this.state.value - 1 }); |
1675 | | - this.state.value = e.initialValue; |
| 1672 | + this.n = () => this.setState({ t: this.state.t + 1 }); |
| 1673 | + this.r = () => this.setState({ t: this.state.t - 1 }); |
| 1674 | + this.state.t = e.e; |
1676 | 1675 | } |
1677 | 1676 | render() { |
1678 | 1677 | return t("div", { |
1679 | 1678 | class: "counter" |
1680 | 1679 | }, t("h1", null, this.props.label), t("p", null, t("button", { |
1681 | | - onClick: this.decrement |
1682 | | - }, "-"), " ", this.state.value, " ", t("button", { |
1683 | | - onClick: this.increment |
| 1680 | + onClick: this.r |
| 1681 | + }, "-"), " ", this.state.t, " ", t("button", { |
| 1682 | + onClick: this.n |
1684 | 1683 | }, "+"))); |
1685 | 1684 | } |
1686 | | -}, i = (n) => { |
1687 | | - let [e, u] = l(n.initialValue); |
| 1685 | +}, s = (r) => { |
| 1686 | + let [o, e] = a(r.e); |
1688 | 1687 | return t("div", { |
1689 | 1688 | class: "counter" |
1690 | | - }, t("h1", null, n.label), t("p", null, t("button", { |
1691 | | - onClick: () => u(e - 1) |
1692 | | - }, "-"), " ", e, " ", t("button", { |
1693 | | - onClick: () => u(e + 1) |
| 1689 | + }, t("h1", null, r.o), t("p", null, t("button", { |
| 1690 | + onClick: () => e(o - 1) |
| 1691 | + }, "-"), " ", o, " ", t("button", { |
| 1692 | + onClick: () => e(o + 1) |
1694 | 1693 | }, "+"))); |
1695 | 1694 | }; |
1696 | 1695 |
|
1697 | 1696 | // index.tsx |
1698 | | -c(r(s, null, r(o, { |
1699 | | - label: "Counter 1", |
1700 | | - initialValue: 100 |
1701 | | -}), r(i, { |
1702 | | - label: "Counter 2", |
1703 | | - initialValue: 200 |
1704 | | -})), document.getElementById("root")); |
| 1697 | +c( |
| 1698 | + u(l, null, u(n, { |
| 1699 | + o: "Counter 1", |
| 1700 | + e: 100 |
| 1701 | + }), u(s, { |
| 1702 | + o: "Counter 2", |
| 1703 | + e: 200 |
| 1704 | + })), |
| 1705 | + document.getElementById("root") |
| 1706 | +); |
1705 | 1707 | //# sourceMappingURL=example.js.map |
1706 | 1708 | `; |
1707 | 1709 |
|
1708 | 1710 | const exampleMap = `{ |
1709 | 1711 | "version": 3, |
1710 | 1712 | "sources": ["index.tsx", "counter.tsx"], |
1711 | | - "sourcesContent": ["import { h, Fragment, render } from 'preact'\\nimport { CounterClass, CounterFunction } from './counter'\\n\\nrender(\\n <>\\n <CounterClass label=\\"Counter 1\\" initialValue={100} />\\n <CounterFunction label=\\"Counter 2\\" initialValue={200} />\\n </>,\\n document.getElementById('root')!,\\n)\\n", "import { h, Component } from 'preact'\\nimport { useState } from 'preact/hooks'\\n\\ninterface CounterProps {\\n label: string\\n initialValue: number\\n}\\n\\ninterface CounterState {\\n value: number\\n}\\n\\nexport class CounterClass extends Component<CounterProps, CounterState> {\\n state: CounterState = { value: 0 }\\n\\n constructor(props: CounterProps) {\\n super(props)\\n this.state.value = props.initialValue\\n }\\n\\n increment = () => this.setState({ value: this.state.value + 1 })\\n decrement = () => this.setState({ value: this.state.value - 1 })\\n\\n render() {\\n return <div class=\\"counter\\">\\n <h1>{this.props.label}</h1>\\n <p>\\n <button onClick={this.decrement}>-</button>\\n {' '}\\n {this.state.value}\\n {' '}\\n <button onClick={this.increment}>+</button>\\n </p>\\n </div>\\n }\\n}\\n\\nexport let CounterFunction = (props: CounterProps) => {\\n let [value, setValue] = useState(props.initialValue)\\n return <div class=\\"counter\\">\\n <h1>{props.label}</h1>\\n <p>\\n <button onClick={() => setValue(value - 1)}>-</button>\\n {' '}\\n {value}\\n {' '}\\n <button onClick={() => setValue(value + 1)}>+</button>\\n </p>\\n </div>\\n}\\n"], |
1712 | | - "mappings": ";AAAA;;;ACAA;AACA;AAWO,sBAA2B,EAAsC;AAAA,EAGtE,YAAY,GAAqB;AAC/B,UAAM;AAHR,iBAAsB,EAAE,OAAO;AAO/B,qBAAY,MAAM,KAAK,SAAS,EAAE,OAAO,KAAK,MAAM,QAAQ;AAC5D,qBAAY,MAAM,KAAK,SAAS,EAAE,OAAO,KAAK,MAAM,QAAQ;AAJ1D,SAAK,MAAM,QAAQ,EAAM;AAAA;AAAA,EAM3B,SAAS;AACP,WAAO,EAAC,OAAD;AAAA,MAAK,OAAM;AAAA,OAChB,EAAC,MAAD,MAAK,KAAK,MAAM,QAChB,EAAC,KAAD,MACE,EAAC,UAAD;AAAA,MAAQ,SAAS,KAAK;AAAA,OAAW,MAChC,KACA,KAAK,MAAM,OACX,KACD,EAAC,UAAD;AAAA,MAAQ,SAAS,KAAK;AAAA,OAAW;AAAA;AAAA,GAM9B,IAAkB,CAAC,MAAwB;AACpD,MAAI,CAAC,GAAO,KAAY,EAAS,EAAM;AACvC,SAAO,EAAC,OAAD;AAAA,IAAK,OAAM;AAAA,KAChB,EAAC,MAAD,MAAK,EAAM,QACX,EAAC,KAAD,MACE,EAAC,UAAD;AAAA,IAAQ,SAAS,MAAM,EAAS,IAAQ;AAAA,KAAI,MAC3C,KACA,GACA,KACD,EAAC,UAAD;AAAA,IAAQ,SAAS,MAAM,EAAS,IAAQ;AAAA,KAAI;AAAA;;;AD3ClD,EACE,WACE,EAAC,GAAD;AAAA,EAAc,OAAM;AAAA,EAAY,cAAc;AAAA,IAC9C,EAAC,GAAD;AAAA,EAAiB,OAAM;AAAA,EAAY,cAAc;AAAA,KAEnD,SAAS,eAAe;", |
1713 | | - "names": [] |
| 1713 | + "sourcesContent": ["import { h, Fragment, render } from 'preact'\\nimport { CounterClass, CounterFunction } from './counter'\\n\\nrender(\\n <>\\n <CounterClass label_=\\"Counter 1\\" initialValue_={100} />\\n <CounterFunction label_=\\"Counter 2\\" initialValue_={200} />\\n </>,\\n document.getElementById('root')!,\\n)\\n", "import { h, Component } from 'preact'\\nimport { useState } from 'preact/hooks'\\n\\ninterface CounterProps {\\n label_: string\\n initialValue_: number\\n}\\n\\ninterface CounterState {\\n value_: number\\n}\\n\\nexport class CounterClass extends Component<CounterProps, CounterState> {\\n state: CounterState\\n\\n constructor(props: CounterProps) {\\n super(props)\\n this.state.value_ = props.initialValue_\\n }\\n\\n increment_ = () => this.setState({ value_: this.state.value_ + 1 })\\n decrement_ = () => this.setState({ value_: this.state.value_ - 1 })\\n\\n render() {\\n return <div class=\\"counter\\">\\n <h1>{this.props.label}</h1>\\n <p>\\n <button onClick={this.decrement_}>-</button>\\n {' '}\\n {this.state.value_}\\n {' '}\\n <button onClick={this.increment_}>+</button>\\n </p>\\n </div>\\n }\\n}\\n\\nexport let CounterFunction = (props: CounterProps) => {\\n let [value, setValue] = useState(props.initialValue_)\\n return <div class=\\"counter\\">\\n <h1>{props.label_}</h1>\\n <p>\\n <button onClick={() => setValue(value - 1)}>-</button>\\n {' '}\\n {value}\\n {' '}\\n <button onClick={() => setValue(value + 1)}>+</button>\\n </p>\\n </div>\\n}\\n"], |
| 1714 | + "mappings": ";AAAA,SAAS,KAAAA,GAAG,YAAAC,GAAU,UAAAC,SAAc;;;ACApC,SAAS,KAAAC,GAAG,aAAAC,SAAiB;AAC7B,SAAS,YAAAC,SAAgB;AAWlB,IAAMC,IAAN,cAA2BF,EAAsC;AAAA,EAGtE,YAAYG,GAAqB;AAC/B,UAAMA,CAAK;AAIb,SAAAC,IAAa,MAAM,KAAK,SAAS,EAAEC,GAAQ,KAAK,MAAMA,IAAS,EAAE,CAAC;AAClE,SAAAC,IAAa,MAAM,KAAK,SAAS,EAAED,GAAQ,KAAK,MAAMA,IAAS,EAAE,CAAC;AAJhE,SAAK,MAAMA,IAASF,EAAMI;AAAA,EAC5B;AAAA,EAKA,SAAS;AACP,WAAOR,EAAC;AAAA,MAAI,OAAM;AAAA,OAChBA,EAAC,YAAI,KAAK,MAAM,KAAM,GACtBA,EAAC,WACCA,EAAC;AAAA,MAAO,SAAS,KAAKO;AAAA,OAAY,GAAC,GAClC,KACA,KAAK,MAAMD,GACX,KACDN,EAAC;AAAA,MAAO,SAAS,KAAKK;AAAA,OAAY,GAAC,CACrC,CACF;AAAA,EACF;AACF,GAEWI,IAAkB,CAACL,MAAwB;AACpD,MAAI,CAACM,GAAOC,CAAQ,IAAIT,EAASE,EAAMI,CAAa;AACpD,SAAOR,EAAC;AAAA,IAAI,OAAM;AAAA,KAChBA,EAAC,YAAII,EAAMQ,CAAO,GAClBZ,EAAC,WACCA,EAAC;AAAA,IAAO,SAAS,MAAMW,EAASD,IAAQ,CAAC;AAAA,KAAG,GAAC,GAC5C,KACAA,GACA,KACDV,EAAC;AAAA,IAAO,SAAS,MAAMW,EAASD,IAAQ,CAAC;AAAA,KAAG,GAAC,CAC/C,CACF;AACF;;;AD9CAG;AAAA,EACEC,EAAAC,GAAA,MACED,EAACE,GAAA;AAAA,IAAaC,GAAO;AAAA,IAAYC,GAAe;AAAA,GAAK,GACrDJ,EAACK,GAAA;AAAA,IAAgBF,GAAO;AAAA,IAAYC,GAAe;AAAA,GAAK,CAC1D;AAAA,EACA,SAAS,eAAe,MAAM;AAChC;", |
| 1715 | + "names": ["h", "Fragment", "render", "h", "Component", "useState", "CounterClass", "props", "increment_", "value_", "decrement_", "initialValue_", "CounterFunction", "value", "setValue", "label_", "render", "h", "Fragment", "CounterClass", "label_", "initialValue_", "CounterFunction"] |
1714 | 1716 | } |
1715 | 1717 | `; |
0 commit comments