[
  {
    "path": ".github/workflows/rust.yml",
    "content": "name: Rust\n\non:\n  push:\n    branches: [ master ]\n\nenv:\n  CARGO_TERM_COLOR: always\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v2\n    - name: Setup toolchain\n      uses: dtolnay/rust-toolchain@master\n      with:\n        toolchain: stable\n        targets: wasm32-unknown-unknown\n        components: rust-src\n    - uses: jetli/wasm-pack-action@v0.4.0\n      with:\n        # Optional version of wasm-pack to install(eg. '0.9.1', 'latest')\n        version: 'latest'\n    - uses: jetli/trunk-action@v0.5.0\n      with:\n        # Optional version of trunk to install(eg. 'v0.16.0', 'latest')\n        version: 'latest'\n    - name: Cargo fmt & clippy\n      run: |\n        cargo fmt --all -- --check\n        cargo clippy -- --deny=warnings\n    - name: Tests\n      run: |\n        cd crates/yew-app\n        cargo test\n    - name: Run web tests\n      run: |\n        cd crates/yew-app && wasm-pack test --headless --chrome\n    - name: Build app\n      run: |\n        cd crates/yew-app && trunk build --public-url=/create-yew-app/\n    - name: Deploy\n      uses: JamesIves/github-pages-deploy-action@v4.2.2\n      with:\n        branch: gh-pages\n        folder: crates/yew-app/dist\n        clean: true\n"
  },
  {
    "path": ".gitignore",
    "content": "# Generated by Cargo\n# will have compiled files and executables\n/target/\n\n# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries\n# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html\nCargo.lock\n\n# These are backup files generated by rustfmt\n**/*.rs.bk\n\n# JS\n.idea/\n.vscode/\nnode_modules/\nbuild\ndist\npkg\n.cache\n.DS_Store\nmy-app*\nlerna-debug.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n/.changelog\n.npm/\nyarn.lock\npackage-lock.json\n"
  },
  {
    "path": "Cargo.toml",
    "content": "[workspace]\nresolver = \"2\"\nmembers = [\"crates/*\"]\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Create Yew App\n\nCreate Yew apps with no build configuration.\n\n- [Creating an App](#creating-an-app) – How to create a new app.\n- [Yew](https://github.com/yewstack/yew) - Rust / Wasm framework for building client web apps.\n- [Awesome Yew](https://github.com/jetli/awesome-yew) - A curated list of awesome things related to Yew / WebAssembly.\n- [Realworld example](https://github.com/jetli/rust-yew-realworld-example-app) - Exemplary real world app built with Rust + Yew + WebAssembly.\n\n[Check out a live demo](https://jetli.github.io/create-yew-app/) powered by Create Yew App.\n\n## Quick Overview\n\n```sh\nnpx create-yew-app my-app\ncd my-app\ntrunk serve\n```\n\n_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_\n\nThen open [http://localhost:8080/](http://localhost:8080/) to see your app.<br/>\nWhen you’re ready to deploy to production, create a minified bundle with `trunk build`.\n\n## Getting Started\n\n### Install Rust wasm target\n\n```sh\nrustup target add wasm32-unknown-unknown\n```\n\n### Install [Trunk](https://trunkrs.dev).\n\n## Creating an App\n\n**You’ll need to have Node 8.16.0 or Node 10.16.0 or later version on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to switch Node versions between different projects.\n\nTo create a new app, you may choose one of the following methods:\n\n### npx\n\n```sh\nnpx create-yew-app my-app\n```\n\n_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) is a package runner tool that comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_\n\n### npm\n\n```sh\nnpm init yew-app my-app\n```\n\n_`npm init <initializer>` is available in npm 6+_\n\n### Yarn\n\n```sh\nyarn create yew-app my-app\n```\n\n_[`yarn create <starter-kit-package>`](https://yarnpkg.com/lang/en/docs/cli/create/) is available in Yarn 0.25+_\n\n### Project structure\n\nIt will create a directory called `my-app` inside the current folder.<br/>\nInside that directory, it will generate the initial project structure and install the transitive dependencies:\n\n```\nmy-app\n├── README.md\n├── .gitignore\n├── Cargo.toml\n├── index.html\n├── LICENSE-APACHE\n├── LICENSE-MIT\n├── tailwind.config.js\n├── tailwind.css\n├── Trunk.toml\n├── public\n│   ├── favicon.ico\n│   ├── logo.svg\n└── src\n    ├── lib.rs\n    ├── main.rs\n    ├── app\n    │   ├── about.rs\n    │   ├── home.rs\n    │   └── mod.rs\n    └── components\n        ├── nav.rs\n        └── mod.rs\n```\nNo configuration or complicated folder structures, only the files you need to build your app.<br>\nOnce the installation is done, you can open your project folder:\n\n```sh\ncd my-app\n```\n\nInside the newly created project, you can run some built-in commands:\n\n### `trunk serve`\n\nRuns the app in development mode.<br>\nOpen [http://localhost:8080](http://localhost:8080) to view it in the browser.\n\nThe page will automatically reload if you make changes to the code.<br>\nYou will see the build errors and lint warnings in the console.\n\n### `trunk build`\n\nBuilds the app for production to the `dist` folder.<br>\nIt correctly bundles Yew in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.<br>\n\nYour app is ready to be deployed.\n\n### `wasm-pack test --headless --chrome`\n\nRuns the test watcher in an interactive mode.<br>\nBy default, runs tests related to files changed since the last commit.\n\n# Contributing\n\nFeel free to take a look at the current issues in this repo for anything that currently needs to be worked on.\n\nYou are also welcome to open a PR or a new issue if you see something is missing or could be improved upon.\n\n# License\n\nApache License (Version 2.0)\n\nSee [LICENSE](./LICENSE) for details.\n"
  },
  {
    "path": "crates/yew-app/.gitignore",
    "content": "# Generated by Cargo\n# will have compiled files and executables\n/target/\n\n# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries\n# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html\nCargo.lock\n\n# These are backup files generated by rustfmt\n**/*.rs.bk\n\n\n# JS\nnode_modules\n/dist\n/pkg\n/wasm-pack.log\n.cache"
  },
  {
    "path": "crates/yew-app/Cargo.toml",
    "content": "[package]\nauthors = [\"You <you@example.com>\"]\ncategories = [\"wasm\"]\ndescription = \"My awesome Yew app.\"\nedition = \"2021\"\nlicense = \"Apache-2.0/MIT\"\nname = \"yew-app\"\nreadme = \"./README.md\"\nrepository = \"https://github.com/jetli/create-yew-app.git\"\nversion = \"0.1.0\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\nlog = \"0.4\"\nserde = \"1\"\nreqwest = { version = \"0.12\", features = [\"json\"] }\nyew = { version = \"0.23\", features = [\"csr\"] }\nyew-router = \"0.20\"\nyew-hooks = \"0.6\"\nwasm-bindgen = \"0.2\"\nwasm-logger = \"0.2\"\n\n[dev-dependencies]\nwasm-bindgen-test = \"0.3\"\ngloo-utils = \"0.2\"\n\n[dev-dependencies.web-sys]\nversion = \"0.3\"\nfeatures = [\"Document\", \"Element\", \"HtmlCollection\"]\n"
  },
  {
    "path": "crates/yew-app/LICENSE-APACHE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License."
  },
  {
    "path": "crates/yew-app/LICENSE-MIT",
    "content": "Copyright (c) 2018 The Rust Project Developers\n\nPermission is hereby granted, free of charge, to any\nperson obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the\nSoftware without restriction, including without\nlimitation the rights to use, copy, modify, merge,\npublish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software\nis furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice\nshall be included in all copies or substantial portions\nof the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF\nANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\nTO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\nPARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\nSHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR\nIN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE."
  },
  {
    "path": "crates/yew-app/README.md",
    "content": "# My Awesome Yew App\n\nThis is the official base template for [Create Yew App](https://github.com/jetli/create-yew-app).\n\n## How to run in debug mode\n\n```sh\n# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes.\ntrunk serve\n```\n\n## How to build in release mode\n\n```sh\n# Builds the project and places it into the `dist` folder.\ntrunk build\n```\n\n## How to run unit tests\n\n```sh\n# Runs tests\nwasm-pack test --headless --chrome\n```\n"
  },
  {
    "path": "crates/yew-app/Trunk.toml",
    "content": "[build]\ntarget = \"index.html\"\ndist = \"dist\"\n"
  },
  {
    "path": "crates/yew-app/index.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <title>Yew App</title>\n\n    <link rel=\"shortcut icon\" href=\"favicon.ico\">\n    <link data-trunk rel=\"rust\" />\n    <link data-trunk rel=\"copy-file\" href=\"public/favicon.ico\"/>\n    <link data-trunk rel=\"copy-file\" href=\"public/logo.svg\"/>\n    <link data-trunk rel=\"tailwind-css\" href=\"tailwind.css\"/>\n    <base data-trunk-public-url/>\n  </head>\n  <body class=\"min-h-screen\">\n  </body>\n</html>"
  },
  {
    "path": "crates/yew-app/src/app/about.rs",
    "content": "use serde::{de::DeserializeOwned, Deserialize, Serialize};\nuse yew::prelude::*;\nuse yew_hooks::prelude::*;\n\nuse crate::components::ui::button::Button;\n\n/// About page\n#[function_component(About)]\npub fn about() -> Html {\n    let state =\n        use_async(async move { fetch_repo((\"jetli/create-yew-app\".to_string()).clone()).await });\n\n    let onclick = {\n        let state = state.clone();\n        Callback::from(move |_| {\n            state.run();\n        })\n    };\n\n    html! {\n        <div class=\"container text-center\">\n            <header class=\"space-y-8\">\n                <p class=\"mt-24\">\n                    <a class=\"text-emerald-800 underline\" href=\"https://github.com/jetli/create-yew-app\" target=\"_blank\" rel=\"noopener noreferrer\"\n                    >\n                        { \"Create Yew App\" }\n                    </a>\n                    { \", Set up a modern yew web app by running one command.\" }\n                </p>\n                <p>\n                    <Button {onclick}>{ \"Load info of this repo\" }</Button>\n                </p>\n                <p>\n                    {\n                        if state.loading {\n                            html! { \"Loading, wait a sec...\" }\n                        } else {\n                            html! {}\n                        }\n                    }\n                </p>\n                {\n                    if let Some(repo) = &state.data {\n                        html! {\n                            <>\n                                <p>{ \"Repo name: \" }<b>{ &repo.name }</b></p>\n                                <p>{ \"Repo full name: \" }<b>{ &repo.full_name }</b></p>\n                                <p>{ \"Repo description: \" }<b>{ &repo.description }</b></p>\n                            </>\n                            }\n                    } else {\n                        html! {}\n                    }\n                }\n                <p>\n                    {\n                        if let Some(error) = &state.error {\n                            match error {\n                                Error::DeserializeError => html! { \"DeserializeError\" },\n                                Error::RequestError => html! { \"RequestError\" },\n                            }\n                        } else {\n                            html! {}\n                        }\n                    }\n                </p>\n                <p>\n                    { \"Edit \" } <code>{ \"src/app/about.rs\" }</code> { \" and save to reload.\" }\n                </p>\n            </header>\n        </div>\n    }\n}\n\nasync fn fetch_repo(repo: String) -> Result<Repo, Error> {\n    fetch::<Repo>(format!(\"https://api.github.com/repos/{}\", repo)).await\n}\n\n/// You can use reqwest or other crates to fetch your api.\nasync fn fetch<T>(url: String) -> Result<T, Error>\nwhere\n    T: DeserializeOwned,\n{\n    let response = reqwest::get(url).await;\n    if let Ok(data) = response {\n        if let Ok(repo) = data.json::<T>().await {\n            Ok(repo)\n        } else {\n            Err(Error::DeserializeError)\n        }\n    } else {\n        Err(Error::RequestError)\n    }\n}\n\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]\nstruct Repo {\n    id: i32,\n    name: String,\n    full_name: String,\n    description: String,\n}\n\n// You can use thiserror to define your errors.\n#[derive(Clone, Debug, PartialEq)]\nenum Error {\n    RequestError,\n    DeserializeError,\n    // etc.\n}\n\n#[cfg(test)]\nmod tests {\n    use std::time::Duration;\n    use wasm_bindgen_test::*;\n    use yew::platform::time::sleep;\n\n    wasm_bindgen_test_configure!(run_in_browser);\n\n    use super::About;\n\n    #[wasm_bindgen_test]\n    async fn _about_page_has_an_app_link() {\n        yew::Renderer::<About>::with_root(\n            gloo_utils::document().get_element_by_id(\"output\").unwrap(),\n        )\n        .render();\n\n        sleep(Duration::ZERO).await;\n\n        let app_links = gloo_utils::document().get_elements_by_tag_name(\"a\");\n\n        assert_eq!(app_links.length(), 1);\n\n        let link = app_links.item(0).expect(\"No app-link\").inner_html();\n        assert_eq!(link, \"Create Yew App\");\n    }\n}\n"
  },
  {
    "path": "crates/yew-app/src/app/home.rs",
    "content": "use yew::prelude::*;\nuse yew_hooks::prelude::*;\n\nuse crate::components::ui::button::Button;\n\n/// Home page\n#[function_component(Home)]\npub fn home() -> Html {\n    let counter = use_counter(0);\n\n    let onincrease = {\n        let counter = counter.clone();\n        Callback::from(move |_| counter.increase())\n    };\n    let ondecrease = {\n        let counter = counter.clone();\n        Callback::from(move |_| counter.decrease())\n    };\n\n    html! {\n        <div class=\"container text-center\">\n            <header class=\"space-y-8\">\n                <p>\n                    <a href=\"https://yew.rs\" target=\"_blank\" rel=\"noopener noreferrer\">\n                        <img class=\"w-48 h-48 mx-auto mt-24\" src=\"logo.svg\" alt=\"Yew\" />\n                    </a>\n                </p>\n                <p>\n                    <a id=\"learn_yew\" class=\"text-emerald-800 underline\" href=\"https://yew.rs\" target=\"_blank\" rel=\"noopener noreferrer\">{ \"Learn Yew\" }</a>\n                </p>\n                <p class=\"space-x-4\">\n                    <Button onclick={ondecrease}>{ \"Decrease\" }</Button>\n                    <span class=\"w-12 inline-block\">{ *counter }</span>\n                    <Button onclick={onincrease}>{ \"Increase\" }</Button>\n                </p>\n                <p>\n                    { \"Edit \" } <code>{ \"src/app/home.rs\" }</code> { \" and save to reload.\" }\n                </p>\n            </header>\n        </div>\n    }\n}\n"
  },
  {
    "path": "crates/yew-app/src/app/mod.rs",
    "content": "use yew::prelude::*;\nuse yew_router::prelude::*;\n\npub mod about;\npub mod home;\n\nuse crate::components::nav::Nav;\nuse about::About;\nuse home::Home;\n\n/// App routes\n#[derive(Routable, Debug, Clone, PartialEq, Eq)]\npub enum AppRoute {\n    #[at(\"/about\")]\n    About,\n    #[not_found]\n    #[at(\"/page-not-found\")]\n    PageNotFound,\n    #[at(\"/\")]\n    Home,\n}\n\n/// Switch app routes\npub fn switch(routes: AppRoute) -> Html {\n    match routes.clone() {\n        AppRoute::Home => html! { <Home /> },\n        AppRoute::About => html! { <About /> },\n        AppRoute::PageNotFound => html! { \"Page not found\" },\n    }\n}\n\n/// Root app component\n#[function_component(App)]\npub fn app() -> Html {\n    html! {\n        <HashRouter>\n            <div class=\"flex min-h-screen flex-col\">\n                <Nav />\n                <Switch<AppRoute> render={switch} />\n            </div>\n        </HashRouter>\n    }\n}\n"
  },
  {
    "path": "crates/yew-app/src/components/mod.rs",
    "content": "pub mod nav;\npub mod ui;\n"
  },
  {
    "path": "crates/yew-app/src/components/nav.rs",
    "content": "use yew::prelude::*;\nuse yew_router::prelude::*;\n\nuse crate::app::AppRoute;\n\n/// Nav component\n#[function_component(Nav)]\npub fn nav() -> Html {\n    html! {\n        <div class=\"container py-4\">\n            <nav class=\"flex space-x-4 items-center\">\n                <Link<AppRoute> to={AppRoute::Home} classes=\"text-emerald-800 underline\" >\n                    <img class=\"w-10 h-10\" src=\"logo.svg\" alt=\"Yew\" />\n                </Link<AppRoute>>\n                <Link<AppRoute> to={AppRoute::Home} classes=\"text-emerald-800 underline\" >{ \"Home\" }</Link<AppRoute>>\n                <Link<AppRoute> to={AppRoute::About} classes=\"text-emerald-800 underline\">{ \"About\" }</Link<AppRoute>>\n            </nav>\n        </div>\n    }\n}\n"
  },
  {
    "path": "crates/yew-app/src/components/ui/button.rs",
    "content": "use yew::prelude::*;\n\n#[derive(Properties, Clone, PartialEq)]\npub struct ButtonProps {\n    #[prop_or_default]\n    pub onclick: Callback<MouseEvent>,\n    #[prop_or_default]\n    pub disabled: bool,\n    #[prop_or_default]\n    pub button_ref: NodeRef,\n    #[prop_or_default]\n    pub children: Children,\n}\n\n#[function_component]\npub fn Button(props: &ButtonProps) -> Html {\n    html! {\n        <button\n            class=\"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 bg-emerald-600 text-slate-100 hover:bg-emerald-600/90\"\n            onclick={props.onclick.clone()}\n            disabled={props.disabled}\n            ref={props.button_ref.clone()}>\n            { for props.children.iter() }\n        </button>\n    }\n}\n"
  },
  {
    "path": "crates/yew-app/src/components/ui/mod.rs",
    "content": "pub mod button;\n"
  },
  {
    "path": "crates/yew-app/src/lib.rs",
    "content": "pub mod app;\npub mod components;\n"
  },
  {
    "path": "crates/yew-app/src/main.rs",
    "content": "use yew_app::app::App;\n\n// This is the entry point for the web app\nfn main() {\n    wasm_logger::init(wasm_logger::Config::default());\n    yew::Renderer::<App>::new().render();\n}\n"
  },
  {
    "path": "crates/yew-app/tailwind.config.js",
    "content": "module.exports = {\n    mode: \"jit\",\n    content: {\n      files: [\"src/**/*.rs\", \"**/*.html\"],\n    },\n    darkMode: \"class\", // 'media' or 'class'\n    theme: {\n      container: {\n        center: true,\n        padding: '2rem',\n        screens: {\n          '2xl': '1400px'\n        }\n      },\n      extend: {},\n    },\n    variants: {\n      extend: {},\n    },\n    plugins: [],\n  };"
  },
  {
    "path": "crates/yew-app/tailwind.css",
    "content": "@tailwind base;\n@tailwind components;\n@tailwind utilities;"
  },
  {
    "path": "crates/yew-app/tests/web.rs",
    "content": "use std::time::Duration;\nuse wasm_bindgen_test::*;\nuse yew::platform::time::sleep;\n\nwasm_bindgen_test_configure!(run_in_browser);\n\nuse yew_app::app::App;\n\n#[wasm_bindgen_test]\nasync fn _app_has_a_home_page() {\n    yew::Renderer::<App>::with_root(gloo_utils::document().get_element_by_id(\"output\").unwrap())\n        .render();\n\n    sleep(Duration::ZERO).await;\n\n    let learn_yew = gloo_utils::document()\n        .get_element_by_id(\"learn_yew\")\n        .expect(\"No learn yew anchor or no home page\")\n        .inner_html();\n    assert_eq!(learn_yew, \"Learn Yew\");\n}\n"
  },
  {
    "path": "packages/create-yew-app/README.md",
    "content": "# create-yew-app\nThis package includes the global command for [Create Yew App](https://github.com/jetli/create-yew-app). <br/>\nPlease refer to its documentation:\n\n- [Quick Overview](https://github.com/jetli/create-yew-app#quick-overview) – How to create a new app.\n- [Creating an App](https://github.com/jetli/create-yew-app#creating-an-app) – How to develop apps bootstrapped with Create Yew App.\n\n## Getting Started\n\n### Install Rust wasm target\n\n```sh\nrustup target add wasm32-unknown-unknown\n```\n\n### Install [Trunk](https://trunkrs.dev)\n\n### Creating an App\n\n```sh\nnpx create-yew-app my-app\ncd my-app\ntrunk serve\n```\n\nThen open [http://localhost:8080/](http://localhost:8080/) to see your app.<br/>\nWhen you’re ready to deploy to production, create a minified bundle with `trunk build`.\n"
  },
  {
    "path": "packages/create-yew-app/createYewApp.js",
    "content": "#!/usr/bin/env node\n\n'use strict';\n\nconst { execSync } = require(\"child_process\");\nconst spawn = require('cross-spawn');\nconst chalk = require('chalk');\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst cpr = require(\"cpr\");\nconst rimraf = require(\"rimraf\");\n\n// Check if a tool is present.\nfunction isPresent(dep) {\n  try {\n    execSync(dep, {stdio: 'ignore'});\n    return true;\n  } catch (err) {\n    return false;\n  }\n}\n\n// Run a tool\nfunction run(cmd, args, opts) {\n  const output = spawn.sync(cmd, args, opts);\n\n  if (output.error != null) {\n    throw output.error;\n  }\n\n  if (output.status !== 0) {\n    throw new Error(\"Bad error code when running `\" + cmd + \" \" + args.join(\" \") + \"`: \" + output.status);\n  }\n}\n\n// Check required tools\nif (!isPresent(\"git --version\")) {\n  console.log('\\n git is required, see: https://git-scm.com/downloads');\n  process.exit(1);\n}\n\nif (!isPresent(\"cargo --version\")) {\n  console.log('\\n Rust/Cargo is required, see: https://www.rust-lang.org/tools/install');\n  process.exit(1);\n}\n\nif (!isPresent(\"trunk --version\")) {\n  console.log('\\n Trunk is required, see: https://trunkrs.dev');\n  process.exit(1);\n}\n\nconst args = process.argv.slice(2);\n\nlet folderName = '.';\n\n// Make a dir for the app\nif (args.length >= 1) {\n  folderName = args[0];\n  \n  if (!fs.existsSync(folderName)) {\n    fs.mkdirSync(folderName);\n  }\n}\n\nlet rootFolder = path.resolve(folderName);\nlet gitFolder = path.join(folderName, \".git-clone\");\n\nconsole.log();\nconsole.log(` Creating a new Yew app in ${chalk.green(rootFolder)}. `);\nconsole.log();\n\n// This uses --no-tags and --depth 1 in order to make the cloning faster\nrun(\"git\", [\"clone\", \"--no-tags\", \"--depth\", \"1\", \"https://github.com/jetli/create-yew-app.git\", gitFolder]);\n\n// Copies the yew-app folder\ncpr(path.join(gitFolder, \"crates/yew-app\"), folderName, {}, function (err, files) {\n  // Removes the git folder regardless of whether cpr succeeded or not\n  rimraf.sync(gitFolder);\n\n  if (err) {\n    throw err;\n\n  } else {\n    console.log(\" 🦀 Rust + 🕸 WebAssembly + Yew = ❤️ \");\n    console.log();\n    console.log(\" Installing dependencies... \");\n\n    // Install wasm-pack\n    if (!isPresent(\"wasm-pack --version\")) {\n      run(\"cargo\", [\"install\", \"wasm-pack\"]);\n    }\n\n    console.log(\" Installed dependencies ✅ \");\n    console.log();\n\n    // Git init\n    run(\"git\", [\"init\"], { cwd: folderName, stdio: 'ignore' });\n\n    console.log(\" Initialized a git repository ✅ \");\n    console.log();\n\n    console.log(` Success! 🎉  Created ${folderName} at ${chalk.green(rootFolder)}`);\n    console.log(' Inside that directory, you can run several commands:');\n    console.log();\n    console.log(chalk.cyan('   trunk serve'));\n    console.log('     Starts the development server.');\n    console.log();\n    console.log(chalk.cyan('   trunk build'));\n    console.log('     Bundles the app into static files for production.');\n    console.log();\n    console.log(chalk.cyan('   wasm-pack test --headless --chrome'));\n    console.log('     Starts the test runner.');\n    console.log();\n    console.log(' We suggest that you begin by typing:');\n    console.log();\n    console.log(chalk.cyan('   cd'), folderName);\n    console.log(chalk.cyan('   trunk serve'));\n    console.log();\n    console.log(' Happy hacking! 😎 ');\n    console.log();\n  }\n});"
  },
  {
    "path": "packages/create-yew-app/index.js",
    "content": "#!/usr/bin/env node\n\n'use strict';\n\nvar currentNodeVersion = process.versions.node;\nvar semver = currentNodeVersion.split('.');\nvar major = semver[0];\n\nif (major < 8) {\n  console.error(\n    'You are running Node ' +\n      currentNodeVersion +\n      '.\\n' +\n      'Create React App requires Node 8 or higher. \\n' +\n      'Please update your version of Node.'\n  );\n  process.exit(1);\n}\n\nrequire('./createYewApp');"
  },
  {
    "path": "packages/create-yew-app/package.json",
    "content": "{\n  \"name\": \"create-yew-app\",\n  \"version\": \"0.2.0\",\n  \"description\": \"Set up a modern Yew web app by running one command. \",\n  \"bin\": {\n    \"create-yew-app\": \"./index.js\"\n  },\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/jetli/create-yew-app.git\",\n    \"directory\": \"packages/create-yew-app\"\n  },\n  \"files\": [\n    \"index.js\",\n    \"createYewApp.js\"\n  ],\n  \"keywords\": [\n    \"yew\",\n    \"create-yew-app\",\n    \"wasm\",\n    \"webassembly\",\n    \"wasm-bindgen\",\n    \"wasm-pack\",\n    \"rust\"\n  ],\n  \"author\": \"Jet Li <jing.i.qin@icloud.com>\",\n  \"license\": \"Apache-2.0\",\n  \"engines\": {\n    \"node\": \">=8\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/jetli/create-yew-app/issues\"\n  },\n  \"homepage\": \"https://github.com/jetli/create-yew-app#readme\",\n  \"dependencies\": {\n    \"chalk\": \"3.0.0\",\n    \"cpr\": \"^3.0.1\",\n    \"cross-spawn\": \"^7.0.3\",\n    \"rimraf\": \"^3.0.0\"\n  }\n}\n"
  }
]