[
  {
    "path": ".github/workflows/compressed-size.yml",
    "content": "name: Compressed Size\n\non: [pull_request]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n      - uses: preactjs/compressed-size-action@v2\n        with:\n          pattern: \"./{dist,mini,react,preact}/{index.js,index.mjs,htm.js,htm.mjs,standalone.js,standalone.mjs}\"\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: Unit Tests\n\non: [pull_request, push]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        # Change the condition for ESM Dist Test below when changing this.\n        node-version: [12.x, 14.x]\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n      - name: Use Node.js ${{ matrix.node-version }}\n        uses: actions/setup-node@v1\n        with:\n          node-version: ${{ matrix.node-version }}\n      - name: Install\n        run: npm install\n      - name: Build and Test\n        run: npm test\n      - if: matrix.node-version == '14.x'\n        name: ESM Dist Test\n        run: npm run test:dist\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\npackage-lock.json\n/preact\n/react\ndist\nmini\nyarn.lock\nhtm.tgz\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, sex characteristics, gender identity and expression,\nlevel of experience, education, socio-economic status, nationality, personal\nappearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or\n advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic\n address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting the project team at jason@developit.ca. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,\navailable at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see\nhttps://www.contributor-covenant.org/faq\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# How to Contribute\n\nWe'd love to accept your patches and contributions to this project. There are\njust a few small guidelines you need to follow.\n\n## Contributor License Agreement\n\nContributions to this project must be accompanied by a Contributor License\nAgreement. You (or your employer) retain the copyright to your contribution,\nthis simply gives us permission to use and redistribute your contributions as\npart of the project. Head over to <https://cla.developers.google.com/> to see\nyour current agreements on file or to sign a new one.\n\nYou generally only need to submit a CLA once, so if you've already submitted one\n(even if it was for a different project), you probably don't need to do it\nagain.\n\n## Code reviews\n\nAll submissions, including submissions by project members, require review. We\nuse GitHub pull requests for this purpose. Consult\n[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more\ninformation on using pull requests.\n\n## Community Guidelines\n\nThis project follows [Google's Open Source Community\nGuidelines](https://opensource.google.com/conduct/)."
  },
  {
    "path": "LICENSE",
    "content": "\n                                 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 2018 Google Inc.\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": "README.md",
    "content": "\n<h1 align=\"center\">\n  HTM (Hyperscript Tagged Markup)\n  <a href=\"https://www.npmjs.org/package/htm\"><img src=\"https://img.shields.io/npm/v/htm.svg?style=flat\" alt=\"npm\"></a>\n</h1>\n<p align=\"center\">\n  <img src=\"https://i.imgur.com/0ph8dbS.png\" width=\"572\" alt=\"hyperscript tagged markup demo\">\n</p>\n\n`htm` is **JSX-like syntax in plain JavaScript** - no transpiler necessary.\n\nDevelop with React/Preact directly in the browser, then compile `htm` away for production.\n\nIt uses standard JavaScript [Tagged Templates] and works in [all modern browsers].\n\n## `htm` by the numbers:\n\n🐣 **< 600 bytes** when used directly in the browser\n\n⚛️ **< 500 bytes** when used with Preact _(thanks gzip 🌈)_\n\n🥚 **< 450 byte** `htm/mini` version\n\n🏅 **0 bytes** if compiled using [babel-plugin-htm]\n\n\n## Syntax: like JSX but also lit\n\nThe syntax you write when using HTM is as close as possible to JSX:\n\n- Spread props: `<div ...${props}>` instead of `<div {...props}>`\n- Self-closing tags: `<div />`\n- Components: `<${Foo}>` instead of `<Foo>` _(where `Foo` is a component reference)_\n- Boolean attributes: `<div draggable />`\n\n\n## Improvements over JSX\n\n`htm` actually takes the JSX-style syntax a couple steps further!\n\nHere's some ergonomic features you get for free that aren't present in JSX:\n\n- **No transpiler necessary**\n- HTML's optional quotes: `<div class=foo>`\n- Component end-tags: `<${Footer}>footer content<//>`\n- Syntax highlighting and language support via the [lit-html VSCode extension] and [vim-jsx-pretty plugin].\n- Multiple root element (fragments): `<div /><div />`\n- Support for HTML-style comments: `<div><!-- comment --></div>`\n\n## Installation\n\n`htm` is published to npm, and accessible via the unpkg.com CDN:\n\n**via npm:**\n\n```js\nnpm i htm\n```\n\n**hotlinking from unpkg:** _(no build tool needed!)_\n\n```js\nimport htm from 'https://unpkg.com/htm?module'\nconst html = htm.bind(React.createElement);\n```\n\n```js\n// just want htm + preact in a single file? there's a highly-optimized version of that:\nimport { html, render } from 'https://unpkg.com/htm/preact/standalone.module.js'\n```\n\n## Usage\n\nIf you're using Preact or React, we've included off-the-shelf bindings to make your life easier.\nThey also have the added benefit of sharing a template cache across all modules.\n\n```js\nimport { render } from 'preact';\nimport { html } from 'htm/preact';\nrender(html`<a href=\"/\">Hello!</a>`, document.body);\n```\n\nSimilarly, for React:\n\n```js\nimport ReactDOM from 'react-dom';\nimport { html } from 'htm/react';\nReactDOM.render(html`<a href=\"/\">Hello!</a>`, document.body);\n```\n\n### Advanced Usage\n\nSince `htm` is a generic library, we need to tell it what to \"compile\" our templates to.\nYou can bind `htm` to any function of the form `h(type, props, ...children)` _([hyperscript])_.\nThis function can return anything - `htm` never looks at the return value.\n\nHere's an example `h()` function that returns tree nodes:\n\n```js\nfunction h(type, props, ...children) {\n  return { type, props, children };\n}\n```\n\nTo use our custom `h()` function, we need to create our own `html` tag function by binding `htm` to our `h()` function:\n\n```js\nimport htm from 'htm';\n\nconst html = htm.bind(h);\n```\n\nNow we have an `html()` template tag that can be used to produce objects in the format we created above.\n\nHere's the whole thing for clarity:\n\n```js\nimport htm from 'htm';\n\nfunction h(type, props, ...children) {\n  return { type, props, children };\n}\n\nconst html = htm.bind(h);\n\nconsole.log( html`<h1 id=hello>Hello world!</h1>` );\n// {\n//   type: 'h1',\n//   props: { id: 'hello' },\n//   children: ['Hello world!']\n// }\n```\n\nIf the template has multiple element at the root level\nthe output is an array of `h` results:\n\n```js\nconsole.log(html`\n  <h1 id=hello>Hello</h1>\n  <div class=world>World!</div>\n`);\n// [\n//   {\n//     type: 'h1',\n//     props: { id: 'hello' },\n//     children: ['Hello']\n//   },\n//   {\n//     type: 'div',\n//     props: { class: 'world' },\n//     children: ['world!']\n//   }\n// ]\n```\n\n### Caching\n\nThe default build of `htm` caches template strings, which means that it can return the same Javascript object at multiple points in the tree. If you don't want this behaviour, you have three options:\n\n* Change your `h` function to copy nodes when needed.\n* Add the code `this[0] = 3;` at the beginning of your `h` function, which disables caching of created elements.\n* Use `htm/mini`, which disables caching by default.\n\n## Example\n\nCurious to see what it all looks like? Here's a working app!\n\nIt's a single HTML file, and there's no build or tooling. You can edit it with nano.\n\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n  <title>htm Demo</title>\n  <script type=\"module\">\n    import { html, Component, render } from 'https://unpkg.com/htm/preact/standalone.module.js';\n\n    class App extends Component {\n      addTodo() {\n        const { todos = [] } = this.state;\n        this.setState({ todos: todos.concat(`Item ${todos.length}`) });\n      }\n      render({ page }, { todos = [] }) {\n        return html`\n          <div class=\"app\">\n            <${Header} name=\"ToDo's (${page})\" />\n            <ul>\n              ${todos.map(todo => html`\n                <li key=${todo}>${todo}</li>\n              `)}\n            </ul>\n            <button onClick=${() => this.addTodo()}>Add Todo</button>\n            <${Footer}>footer content here<//>\n          </div>\n        `;\n      }\n    }\n\n    const Header = ({ name }) => html`<h1>${name} List</h1>`\n\n    const Footer = props => html`<footer ...${props} />`\n\n    render(html`<${App} page=\"All\" />`, document.body);\n  </script>\n</html>\n```\n\n[⚡️ **See live version** ▶](https://htm-demo-preact.glitch.me/)\n\n[⚡️ **Try this on CodeSandbox** ▶](https://codesandbox.io/s/x7pmq32j6q)\n\nHow nifty is that?\n\nNotice there's only one import - here we're using the prebuilt Preact integration since it's easier to import and a bit smaller.\n\nThe same example works fine without the prebuilt version, just using two imports:\n\n```js\nimport { h, Component, render } from 'preact';\nimport htm from 'htm';\n\nconst html = htm.bind(h);\n\nrender(html`<${App} page=\"All\" />`, document.body);\n```\n\n## Other Uses\n\nSince `htm` is designed to meet the same need as JSX, you can use it anywhere you'd use JSX.\n\n**Generate HTML using [vhtml]:**\n\n```js\nimport htm from 'htm';\nimport vhtml from 'vhtml';\n\nconst html = htm.bind(vhtml);\n\nconsole.log( html`<h1 id=hello>Hello world!</h1>` );\n// '<h1 id=\"hello\">Hello world!</h1>'\n```\n\n**Webpack configuration via [jsxobj]:** ([details here](https://webpack.js.org/configuration/configuration-languages/#babel-and-jsx)) _(never do this)_\n\n```js\nimport htm from 'htm';\nimport jsxobj from 'jsxobj';\n\nconst html = htm.bind(jsxobj);\n\nconsole.log(html`\n  <webpack watch mode=production>\n    <entry path=\"src/index.js\" />\n  </webpack>\n`);\n// {\n//   watch: true,\n//   mode: 'production',\n//   entry: {\n//     path: 'src/index.js'\n//   }\n// }\n```\n\n## Demos & Examples\n\n- [Canadian Holidays](https://github.com/pcraig3/hols): A full app using HTM and Server-Side Rendering\n- [HTM SSR Example](https://github.com/timarney/htm-ssr-demo): Shows how to do SSR with HTM\n- [HTM + Preact SSR Demo](https://gist.github.com/developit/699c8d8f180a1e4eed58167f9c6711be)\n- [HTM + vhtml SSR Demo](https://gist.github.com/developit/ff925c3995b4a129b6b977bf7cd12ebd)\n\n## Project Status\n\nThe original goal for `htm` was to create a wrapper around Preact that felt natural for use untranspiled in the browser. I wanted to use Virtual DOM, but I wanted to eschew build tooling and use ES Modules directly.\n\n This meant giving up JSX, and the closest alternative was [Tagged Templates]. So, I wrote this library to patch up the differences between the two as much as possible. The technique turns out to be framework-agnostic, so it should work great with any library or renderer that works with JSX.\n\n`htm` is stable, fast, well-tested and ready for production use.\n\n[Tagged Templates]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates\n[lit-html]: https://github.com/Polymer/lit-html\n[babel-plugin-htm]: https://github.com/developit/htm/tree/master/packages/babel-plugin-htm\n[lit-html VSCode extension]: https://marketplace.visualstudio.com/items?itemName=bierner.lit-html\n[vim-jsx-pretty plugin]: https://github.com/MaxMEllon/vim-jsx-pretty\n[vhtml]: https://github.com/developit/vhtml\n[jsxobj]: https://github.com/developit/jsxobj\n[hyperscript]: https://github.com/hyperhype/hyperscript\n[all modern browsers]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Browser_compatibility\n"
  },
  {
    "path": "babel.config.js",
    "content": "module.exports = {\n\tpresets: [\n\t\t[\n\t\t\t'@babel/preset-env',\n\t\t\t{\n\t\t\t\ttargets: {\n\t\t\t\t\tnode: 'current'\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t]\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"htm\",\n  \"version\": \"3.1.1\",\n  \"description\": \"The Tagged Template syntax for Virtual DOM. Only browser-compatible syntax.\",\n  \"main\": \"dist/htm.js\",\n  \"umd:main\": \"dist/htm.umd.js\",\n  \"module\": \"dist/htm.module.js\",\n  \"types\": \"dist/htm.d.ts\",\n  \"exports\": {\n    \".\": {\n      \"types\": \"./dist/htm.d.ts\",\n      \"browser\": \"./dist/htm.module.js\",\n      \"umd\": \"./dist/htm.umd.js\",\n      \"import\": \"./dist/htm.mjs\",\n      \"require\": \"./dist/htm.js\"\n    },\n    \"./\": \"./\",\n    \"./preact\": {\n      \"types\": \"./preact/index.d.ts\",\n      \"browser\": \"./preact/index.module.js\",\n      \"umd\": \"./preact/index.umd.js\",\n      \"import\": \"./preact/index.mjs\",\n      \"require\": \"./preact/index.js\"\n    },\n    \"./preact/standalone\": {\n      \"types\": \"./preact/index.d.ts\",\n      \"browser\": \"./preact/standalone.module.js\",\n      \"umd\": \"./preact/standalone.umd.js\",\n      \"import\": \"./preact/standalone.mjs\",\n      \"require\": \"./preact/standalone.js\"\n    },\n    \"./react\": {\n      \"types\": \"./react/index.d.ts\",\n      \"browser\": \"./react/index.module.js\",\n      \"umd\": \"./react/index.umd.js\",\n      \"import\": \"./react/index.mjs\",\n      \"require\": \"./react/index.js\"\n    },\n    \"./mini\": {\n      \"types\": \"./mini/index.d.ts\",\n      \"browser\": \"./mini/index.module.js\",\n      \"umd\": \"./mini/index.umd.js\",\n      \"import\": \"./mini/index.mjs\",\n      \"require\": \"./mini/index.js\"\n    }\n  },\n  \"scripts\": {\n    \"build\": \"npm run -s build:main && npm run -s build:mini && npm run -s build:preact && npm run -s build:react && npm run -s build:babel && npm run -s build:babel-transform-jsx && npm run -s build:mjsalias\",\n    \"build:main\": \"microbundle src/index.mjs -f es,umd --no-sourcemap --target web && microbundle src/cjs.mjs -f iife --no-sourcemap --target web && cp src/index.d.ts dist/htm.d.ts\",\n    \"build:mini\": \"microbundle src/index.mjs -o ./mini/index.js -f es,umd --no-sourcemap --target web --alias ./constants.mjs=./constants-mini.mjs && microbundle src/cjs.mjs -o ./mini/index.js -f iife --no-sourcemap --target web --alias ./constants.mjs=./constants-mini.mjs && cp src/index.d.ts mini\",\n    \"build:preact\": \"cd src/integrations/preact && npm run build\",\n    \"build:react\": \"cd src/integrations/react && npm run build\",\n    \"build:babel\": \"cd packages/babel-plugin-htm && npm run build\",\n    \"build:babel-transform-jsx\": \"cd packages/babel-plugin-transform-jsx-to-htm && npm run build\",\n    \"build:mjsalias\": \"cp dist/htm.module.js dist/htm.mjs && cp mini/index.module.js mini/index.mjs && cp preact/index.module.js preact/index.mjs && cp preact/standalone.module.js preact/standalone.mjs && cp react/index.module.js react/index.mjs\",\n    \"test\": \"eslint src/**/*.mjs test/**/*.mjs --ignore-path .gitignore && npm run build && jest test\",\n    \"test:perf\": \"v8 test/__perftest.mjs\",\n    \"test:dist\": \"npm pack && mv htm*.tgz test/fixtures/esm/htm.tgz && cd test/fixtures/esm && npm install && node index.js\",\n    \"release\": \"npm t && git commit -am \\\"$npm_package_version\\\" && git tag $npm_package_version && git push && git push --tags && npm publish\"\n  },\n  \"files\": [\n    \"dist\",\n    \"mini\",\n    \"preact\",\n    \"react\",\n    \"src\"\n  ],\n  \"eslintConfig\": {\n    \"extends\": \"developit\",\n    \"rules\": {\n      \"prefer-const\": 0,\n      \"prefer-spread\": 0,\n      \"prefer-rest-params\": 0,\n      \"func-style\": 0\n    }\n  },\n  \"jest\": {\n    \"testURL\": \"http://localhost\",\n    \"testMatch\": [\n      \"**/__tests__/**/*.?(m)js?(x)\",\n      \"**/?(*.)(spec|test).?(m)js?(x)\"\n    ],\n    \"transform\": {\n      \"\\\\.m?js$\": \"babel-jest\"\n    },\n    \"moduleFileExtensions\": [\n      \"mjs\",\n      \"js\"\n    ],\n    \"moduleNameMapper\": {\n      \"^babel-plugin-transform-jsx-to-htm$\": \"<rootDir>/packages/babel-plugin-transform-jsx-to-htm/index.mjs\",\n      \"^babel-plugin-htm$\": \"<rootDir>/packages/babel-plugin-htm/index.mjs\",\n      \"^htm$\": \"<rootDir>/src/index.mjs\",\n      \"^htm/preact$\": \"<rootDir>/src/integrations/preact/index.mjs\"\n    }\n  },\n  \"repository\": \"developit/htm\",\n  \"keywords\": [\n    \"Hyperscript Tagged Markup\",\n    \"tagged template\",\n    \"template literals\",\n    \"html\",\n    \"htm\",\n    \"jsx\",\n    \"virtual dom\",\n    \"hyperscript\"\n  ],\n  \"author\": \"Jason Miller <jason@developit.ca>\",\n  \"license\": \"Apache-2.0\",\n  \"homepage\": \"https://github.com/developit/htm\",\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.2.2\",\n    \"@babel/preset-env\": \"^7.1.6\",\n    \"@types/jest\": \"^26.0.24\",\n    \"babel-jest\": \"^24.1.0\",\n    \"babel-preset-env\": \"^1.7.0\",\n    \"eslint\": \"^5.2.0\",\n    \"eslint-config-developit\": \"^1.1.1\",\n    \"jest\": \"^24.1.0\",\n    \"microbundle\": \"^0.10.1\",\n    \"preact\": \"^10.2.0\",\n    \"react\": \"^16.8.3\"\n  }\n}\n"
  },
  {
    "path": "packages/babel-plugin-htm/README.md",
    "content": "# `babel-plugin-htm`\n\nA Babel plugin that compiles [htm] syntax to hyperscript, React.createElement, or just plain objects.\n\n## Usage\n\nIn your Babel configuration (`.babelrc`, `babel.config.js`, `\"babel\"` field in package.json, etc), add the plugin:\n\n```js\n{\n  \"plugins\": [\n    [\"htm\", {\n      \"pragma\": \"React.createElement\"\n    }]\n  ]\n}\n```\n\n```js\n// input:\nhtml`<div id=\"foo\">hello ${you}</div>`\n\n// output:\nReact.createElement(\"div\", { id: \"foo\" }, \"hello \", you)\n```\n\n## options\n\n### `pragma`\n\nThe target \"hyperscript\" function to compile elements to (see [Babel docs]).\nDefaults to: `\"h\"`.\n\n### `tag=html`\n\nBy default, `babel-plugin-htm` will process all Tagged Templates with a tag function named `html`. To use a different name, use the `tag` option in your Babel configuration:\n\n```js\n{\"plugins\":[\n  [\"babel-plugin-htm\", {\n    \"tag\": \"myCustomHtmlFunction\"\n  }]\n]}\n```\n\n### `import=false` _(experimental)_\n\nAuto-import the pragma function, off by default.\n\n#### `false` (default)\n\nDon't auto-import anything.\n\n#### `String`\n\nImport the `pragma` like `import {<pragma>} from '<import>'`.\n\nWith Babel config:\n```js\n\"plugins\": [\n  [\"babel-plugin-htm\", {\n    \"tag\": \"$$html\",\n    \"import\": \"htm/preact\"\n  }]\n]\n```\n\n```js\nimport { html as $$html } from 'htm/preact';\n\nexport default $$html`<div id=\"foo\">hello ${you}</div>`\n```\n\nThe above will produce files that look like:\n\n```js\nimport { h } from 'preact';\nimport { html as $$html } from 'htm/preact';\n\nexport default h(\"div\", { id: \"foo\" }, \"hello \", you)\n```\n\n#### `{module: String, export: String}`\n\nImport the `pragma` like `import {<import.export> as <pragma>} from '<import.module>'`.\n\nWith Babel config:\n```js\n\"plugins\": [\n  [\"babel-plugin-htm\", {\n    \"pragma\": \"React.createElement\",\n    \"tag\": \"$$html\",\n    \"import\": {\n      // the module to import:\n      \"module\": \"react\",\n      // a named export to use from that module:\n      \"export\": \"default\"\n    }\n  }]\n]\n```\n\n```js\nimport { html as $$html } from 'htm/react';\n\nexport default $$html`<div id=\"foo\">hello ${you}</div>`\n```\n\nThe above will produce files that look like:\n\n```js\nimport React from 'react';\nimport { html as $$html } from 'htm/react';\n\nexport default React.createElement(\"div\", { id: \"foo\" }, \"hello \", you)\n```\n\n### `useBuiltIns=false`\n\n`babel-plugin-htm` transforms prop spreads (`<a ...${b}>`) into `Object.assign()` calls. For browser support reasons, Babel's standard `_extends` helper is used by default. To use native `Object.assign` directly, pass `{useBuiltIns:true}`.\n\n### `useNativeSpread=false`\n\n`babel-plugin-htm` transforms prop spreads (`<a ...${b} x=y>`) into `{ ...b, x: 'y' }` object spread syntax. For browser support reasons, Babel's standard `_extends` helper is used by default. To use object spread syntax, pass `{useNativeSpread:true}`. This option takes precedence over the `useBuiltIns` option.\n\n### `variableArity=true`\n\nBy default, `babel-plugin-htm` transpiles to the same output as JSX would, which assumes a target function of the form `h(type, props, ...children)`. If, for the purposes of optimization or simplification, you would like all calls to `h()` to be passed exactly 3 arguments, specify `{variableArity:false}` in your Babel config:\n\n```js\nhtml`<div />`  // h('div', null, [])\nhtml`<div a />`  // h('div', { a: true }, [])\nhtml`<div>b</div>`  // h('div', null, ['b'])\nhtml`<div a>b</div>`  // h('div', { a: true }, ['b'])\n```\n\n### `pragma=false` _(experimental)_\n\nSetting `pragma` to `false` changes the output to be plain objects instead of `h()` function calls:\n\n```js\n// input:\nhtml`<div id=\"foo\">hello ${you}</div>`\n// output:\n{ tag:\"div\", props:{ id: \"foo\" }, children:[\"hello \", you] }\n```\n\n### `monomorphic` _(experimental)_\n\nLike `pragma=false` but converts all inline text to objects, resulting in the same object shape being used:\n\n```js\n// input:\nhtml`<div id=\"foo\">hello ${you}</div>`\n// output:\n{ type: 1, tag:\"div\", props:{ id: \"foo\" }, text: null, children:[\n  { type: 3, tag: null, props: null, text: \"hello \", children: null },\n  you\n] }\n```\n\n\n[htm]: https://github.com/developit/htm\n[Babel docs]: https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#pragma\n"
  },
  {
    "path": "packages/babel-plugin-htm/index.mjs",
    "content": "import { build, treeify } from '../../src/build.mjs';\n\n/**\n * @param {Babel} babel\n * @param {object} options\n * @param {string} [options.pragma=h]  JSX/hyperscript pragma.\n * @param {string} [options.tag=html]  The tagged template \"tag\" function name to process.\n * @param {string | boolean | object} [options.import=false]  Import the tag automatically\n * @param {boolean} [options.monomorphic=false]  Output monomorphic inline objects instead of using String literals.\n * @param {boolean} [options.useBuiltIns=false]  Use the native Object.assign instead of trying to polyfill it.\n * @param {boolean} [options.useNativeSpread=false]  Use the native { ...a, ...b } syntax for prop spreads.\n * @param {boolean} [options.variableArity=true] If `false`, always passes exactly 3 arguments to the pragma function.\n */\nexport default function htmBabelPlugin({ types: t }, options = {}) {\n\tconst pragmaString = options.pragma===false ? false : options.pragma || 'h';\n\tconst pragma = pragmaString===false ? false : dottedIdentifier(pragmaString);\n\tconst useBuiltIns = options.useBuiltIns;\n\tconst useNativeSpread = options.useNativeSpread;\n\tconst inlineVNodes = options.monomorphic || pragma===false;\n\tconst importDeclaration = pragmaImport(options.import || false);\n\n\tfunction pragmaImport(imp) {\n\t\tif (pragmaString === false || imp === false) {\n\t\t\treturn null;\n\t\t}\n\t\tconst pragmaRoot = t.identifier(pragmaString.split('.')[0]);\n\t\tconst { module, export: export_ } = typeof imp !== 'string' ? imp : {\n\t\t\tmodule: imp,\n\t\t\texport: null\n\t\t};\n\n\t\tlet specifier;\n\t\tif (export_ === '*') {\n\t\t\tspecifier = t.importNamespaceSpecifier(pragmaRoot);\n\t\t}\n\t\telse if (export_ === 'default') {\n\t\t\tspecifier = t.importDefaultSpecifier(pragmaRoot);\n\t\t}\n\t\telse {\n\t\t\tspecifier = t.importSpecifier(pragmaRoot, export_ ? t.identifier(export_) : pragmaRoot);\n\t\t}\n\t\treturn t.importDeclaration([specifier], t.stringLiteral(module));\n\t}\n\n\tfunction dottedIdentifier(keypath) {\n\t\tconst path = keypath.split('.');\n\t\tlet out;\n\t\tfor (let i=0; i<path.length; i++) {\n\t\t\tconst ident = propertyName(path[i]);\n\t\t\tout = i===0 ? ident : t.memberExpression(out, ident);\n\t\t}\n\t\treturn out;\n\t}\n\n\tfunction patternStringToRegExp(str) {\n\t\tconst parts = str.split('/').slice(1);\n\t\tconst end = parts.pop() || '';\n\t\treturn new RegExp(parts.join('/'), end);\n\t}\n\n\tfunction propertyName(key) {\n\t\tif (t.isValidIdentifier(key)) {\n\t\t\treturn t.identifier(key);\n\t\t}\n\t\treturn t.stringLiteral(key);\n\t}\n\n\tfunction objectProperties(obj) {\n\t\treturn Object.keys(obj).map(key => {\n\t\t\tconst values = obj[key].map(valueOrNode =>\n\t\t\t\tt.isNode(valueOrNode) ? valueOrNode : t.valueToNode(valueOrNode)\n\t\t\t);\n\n\t\t\tlet node = values[0];\n\t\t\tif (values.length > 1 && !t.isStringLiteral(node) && !t.isStringLiteral(values[1])) {\n\t\t\t\tnode = t.binaryExpression('+', t.stringLiteral(''), node);\n\t\t\t}\n\t\t\tvalues.slice(1).forEach(value => {\n\t\t\t\tnode = t.binaryExpression('+', node, value);\n\t\t\t});\n\n\t\t\treturn t.objectProperty(propertyName(key), node);\n\t\t});\n\t}\n\n\tfunction stringValue(str) {\n\t\tif (options.monomorphic) {\n\t\t\treturn t.objectExpression([\n\t\t\t\tt.objectProperty(propertyName('type'), t.numericLiteral(3)),\n\t\t\t\tt.objectProperty(propertyName('tag'), t.nullLiteral()),\n\t\t\t\tt.objectProperty(propertyName('props'), t.nullLiteral()),\n\t\t\t\tt.objectProperty(propertyName('children'), t.nullLiteral()),\n\t\t\t\tt.objectProperty(propertyName('text'), t.stringLiteral(str))\n\t\t\t]);\n\t\t}\n\t\treturn t.stringLiteral(str);\n\t}\n\n\tfunction createVNode(tag, props, children) {\n\t\t// Never pass children=[[]].\n\t\tif (children.elements.length === 1 && t.isArrayExpression(children.elements[0]) && children.elements[0].elements.length === 0) {\n\t\t\tchildren = children.elements[0];\n\t\t}\n\n\t\tif (inlineVNodes) {\n\t\t\treturn t.objectExpression([\n\t\t\t\toptions.monomorphic && t.objectProperty(propertyName('type'), t.numericLiteral(1)),\n\t\t\t\tt.objectProperty(propertyName('tag'), tag),\n\t\t\t\tt.objectProperty(propertyName('props'), props),\n\t\t\t\tt.objectProperty(propertyName('children'), children),\n\t\t\t\toptions.monomorphic && t.objectProperty(propertyName('text'), t.nullLiteral())\n\t\t\t].filter(Boolean));\n\t\t}\n\n\t\t// Passing `{variableArity:false}` always produces `h(tag, props, children)` - where `children` is always an Array.\n\t\t// Otherwise, the default is `h(tag, props, ...children)`.\n\t\tif (options.variableArity !== false) {\n\t\t\tchildren = children.elements;\n\t\t}\n\n\t\treturn t.callExpression(pragma, [tag, props].concat(children));\n\t}\n\n\tfunction spreadNode(args, state) {\n\t\tif (args.length === 0) {\n\t\t\treturn t.nullLiteral();\n\t\t}\n\t\tif (args.length > 0 && t.isNode(args[0])) {\n\t\t\targs.unshift({});\n\t\t}\n\n\t\t// 'Object.assign(x)', can be collapsed to 'x'.\n\t\tif (args.length === 1) {\n\t\t\treturn propsNode(args[0]);\n\t\t}\n\t\t// 'Object.assign({}, x)', can be collapsed to 'x'.\n\t\tif (args.length === 2 && !t.isNode(args[0]) && Object.keys(args[0]).length === 0) {\n\t\t\treturn propsNode(args[1]);\n\t\t}\n\n\t\tif (useNativeSpread) {\n\t\t\tconst properties = [];\n\t\t\targs.forEach(arg => {\n\t\t\t\tif (t.isNode(arg)) {\n\t\t\t\t\tproperties.push(t.spreadElement(arg));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tproperties.push(...objectProperties(arg));\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn t.objectExpression(properties);\n\t\t}\n\n\t\tconst helper = useBuiltIns ? dottedIdentifier('Object.assign') : state.addHelper('extends');\n\t\treturn t.callExpression(helper, args.map(propsNode));\n\t}\n\n\tfunction propsNode(props) {\n\t\treturn t.isNode(props) ? props : t.objectExpression(objectProperties(props));\n\t}\n\n\tfunction transform(node, state) {\n\t\tif (t.isNode(node)) return node;\n\t\tif (typeof node === 'string') return stringValue(node);\n\t\tif (typeof node === 'undefined') return t.identifier('undefined');\n\n\t\tconst { tag, props, children } = node;\n\t\tconst newTag = typeof tag === 'string' ? t.stringLiteral(tag) : tag;\n\t\tconst newProps = spreadNode(props, state);\n\t\tconst newChildren = t.arrayExpression(children.map(child => transform(child, state)));\n\t\treturn createVNode(newTag, newProps, newChildren);\n\t}\n\n\t// The tagged template tag function name we're looking for.\n\t// This is static because it's generally assigned via htm.bind(h),\n\t// which could be imported from elsewhere, making tracking impossible.\n\tconst htmlName = options.tag || 'html';\n\treturn {\n\t\tname: 'htm',\n\t\tvisitor: {\n\t\t\tProgram: {\n\t\t\t\texit(path, state) {\n\t\t\t\t\tif (state.get('hasHtm') && importDeclaration) {\n\t\t\t\t\t\tpath.unshiftContainer('body', importDeclaration);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\tTaggedTemplateExpression(path, state) {\n\t\t\t\tconst tag = path.node.tag.name;\n\t\t\t\tif (htmlName[0]==='/' ? patternStringToRegExp(htmlName).test(tag) : tag === htmlName) {\n\t\t\t\t\tconst statics = path.node.quasi.quasis.map(e => e.value.raw);\n\t\t\t\t\tconst expr = path.node.quasi.expressions;\n\n\t\t\t\t\tconst tree = treeify(build(statics), expr);\n\t\t\t\t\tconst node = !Array.isArray(tree)\n\t\t\t\t\t\t? transform(tree, state)\n\t\t\t\t\t\t: t.arrayExpression(tree.map(root => transform(root, state)));\n\t\t\t\t\tpath.replaceWith(node);\n\t\t\t\t\tstate.set('hasHtm', true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/babel-plugin-htm/package.json",
    "content": "{\n\t\"name\": \"babel-plugin-htm\",\n\t\"version\": \"3.0.0\",\n\t\"description\": \"Babel plugin to compile htm's Tagged Template syntax to hyperscript or inline VNodes.\",\n\t\"main\": \"dist/babel-plugin-htm.js\",\n\t\"module\": \"dist/babel-plugin-htm.mjs\",\n\t\"scripts\": {\n\t\t\"build\": \"microbundle index.mjs -f es,cjs --target node --no-compress --no-sourcemap\",\n\t\t\"prepare\": \"npm run build\"\n\t},\n\t\"files\": [\n\t\t\"dist\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/developit/htm.git\",\n\t\t\"directory\": \"packages/babel-plugin-htm\"\n\t},\n\t\"keywords\": [\n\t\t\"Hyperscript Tagged Markup\",\n\t\t\"tagged template\",\n\t\t\"template literals\",\n\t\t\"html\",\n\t\t\"htm\",\n\t\t\"jsx\",\n\t\t\"virtual dom\",\n\t\t\"hyperscript\",\n\t\t\"babel\",\n\t\t\"babel plugin\",\n\t\t\"babel-plugin\"\n\t],\n\t\"author\": \"Jason Miller <jason@developit.ca>\",\n\t\"license\": \"Apache-2.0\",\n\t\"homepage\": \"https://github.com/developit/htm/tree/master/packages/babel-plugin-htm\",\n\t\"dependencies\": {\n\t\t\"htm\": \"^3.0.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"microbundle\": \"^0.10.1\"\n\t}\n}\n"
  },
  {
    "path": "packages/babel-plugin-transform-jsx-to-htm/README.md",
    "content": "# babel-plugin-transform-jsx-to-htm\n\nThis plugin converts JSX into Tagged Templates that work with [htm].\n\n```js\n// INPUT:\nconst Foo = () => <h1>Hello</h1>\n\n// OUTPUT:\nconst Foo = () => html`<h1>Hello</h1>`\n```\n\n## Installation\n\nGrab it from npm:\n\n```sh\nnpm i -D babel-plugin-transform-jsx-to-htm\n```\n\n... then add it to your Babel config (eg: `.babelrc`):\n\n```js\n\"plugins\": [\n  \"babel-plugin-transform-jsx-to-htm\"\n]\n```\n\n## Options\n\nThe following options are available:\n\n| Option | Type    | Default  | Description\n|--------|---------|----------|------------\n| `tag`  | String  | `\"html\"` | The \"tag\" function to prefix [Tagged Templates] with.\n| `import`  | `false`\\|String\\|Object  | `false` | Auto-import a tag function, off by default.<br>_See [Auto-importing a tag function](#auto-importing-the-tag) for an example._\n\nOptions are passed to a Babel plugin using a nested Array:\n\n```js\n\"plugins\": [\n  [\"babel-plugin-transform-jsx-to-htm\", {\n    \"tag\": \"$$html\"\n  }]\n]\n```\n\n## Auto-importing the tag\n\nWant to automatically import `html` into any file that uses JSX?\nJust use the `import` option:\n\n```js\n\"plugins\": [\n  [\"babel-plugin-transform-jsx-to-htm\", {\n    \"tag\": \"$$html\",\n    \"import\": {\n      // the module to import:\n      \"module\": \"htm/preact\",\n      // a named export to use from that module:\n      \"export\": \"html\"\n    }\n  }]\n]\n```\n\nThe above will produce files that look like:\n\n```js\nimport { html as $$html } from 'htm/preact';\n\nexport default $$html`<h1>hello</h1>`\n```\n\n### License\n\nApache 2\n\n[htm]: https://github.com/developit/htm\n"
  },
  {
    "path": "packages/babel-plugin-transform-jsx-to-htm/index.mjs",
    "content": "import jsx from '@babel/plugin-syntax-jsx';\n\n/**\n * @param {Babel} babel\n * @param {object} [options]\n * @param {string} [options.tag='html']  The tagged template \"tag\" function name to produce.\n * @param {boolean} [options.terse=false]  Use `<//>` for closing component tags\n * @param {string | boolean | object} [options.import=false]  Import the tag automatically\n */\nexport default function jsxToHtmBabelPlugin({ types: t }, options = {}) {\n\tconst tagString = options.tag || 'html';\n\tconst tag = dottedIdentifier(tagString);\n\tconst importDeclaration = tagImport(options.import || false);\n\tconst terse = options.terse === true;\n\n\tfunction tagImport(imp) {\n\t\tif (imp === false) {\n\t\t\treturn null;\n\t\t}\n\t\tconst tagRoot = t.identifier(tagString.split('.')[0]);\n\t\tconst { module, export: export_ } = typeof imp !== 'string' ? imp : {\n\t\t\tmodule: imp,\n\t\t\texport: null\n\t\t};\n\n\t\tlet specifier;\n\t\tif (export_ === '*') {\n\t\t\tspecifier = t.importNamespaceSpecifier(tagRoot);\n\t\t}\n\t\telse if (export_ === 'default') {\n\t\t\tspecifier = t.importDefaultSpecifier(tagRoot);\n\t\t}\n\t\telse {\n\t\t\tspecifier = t.importSpecifier(tagRoot, export_ ? t.identifier(export_) : tagRoot);\n\t\t}\n\t\treturn t.importDeclaration([specifier], t.stringLiteral(module));\n\t}\n\n\tfunction dottedIdentifier(keypath) {\n\t\tconst path = keypath.split('.');\n\t\tlet out;\n\t\tfor (let i = 0; i < path.length; i++) {\n\t\t\tconst ident = t.identifier(path[i]);\n\t\t\tout = i === 0 ? ident : t.memberExpression(out, ident);\n\t\t}\n\t\treturn out;\n\t}\n\n\tlet quasis = [];\n\tlet expressions = [];\n\n\tfunction expr(value) {\n\t\texpressions.push(value);\n\t\tquasis.push(t.templateElement({ raw: '', cooked: '' }));\n\t}\n\n\tfunction raw(str) {\n\t\tconst last = quasis[quasis.length - 1];\n\t\tlast.value.raw += str;\n\t\tlast.value.cooked += str;\n\t}\n\n\tfunction escapeText(text) {\n\t\tif (text.indexOf('<') < 0) {\n\t\t\treturn raw(text);\n\t\t}\n\t\treturn expr(t.stringLiteral(text));\n\t}\n\n\tfunction escapePropValue(node) {\n\t\tconst value = node.value;\n\n\t\tif (value.match(/^.*$/u)) {\n\t\t\tif (value.indexOf('\"') < 0) {\n\t\t\t\treturn raw(`\"${value}\"`);\n\t\t\t}\n\t\t\telse if (value.indexOf(\"'\") < 0) {\n\t\t\t\treturn raw(`'${value}'`);\n\t\t\t}\n\t\t}\n\n\t\treturn expr(t.stringLiteral(node.value));\n\t}\n\n\tconst FRAGMENT_EXPR = dottedIdentifier('React.Fragment');\n\n\tfunction isFragmentName(node) {\n\t\treturn t.isNodesEquivalent(FRAGMENT_EXPR, node);\n\t}\n\t\n\tfunction isComponentName(node) {\n\t\tif (t.isJSXNamespacedName(node)) return false;\n\t\treturn !t.isIdentifier(node) || node.name.match(/^[$_A-Z]/);\n\t}\n\t\n\tfunction getNameExpr(node) {\n\t\tif (t.isJSXNamespacedName(node)) {\n\t\t\treturn t.identifier(node.namespace.name + ':' + node.name.name);\n\t\t}\n\t\tif (!t.isJSXMemberExpression(node)) {\n\t\t\treturn t.identifier(node.name);\n\t\t}\n\t\treturn t.memberExpression(\n\t\t\tgetNameExpr(node.object),\n\t\t\tt.identifier(node.property.name)\n\t\t);\n\t}\n\n\tfunction processChildren(node, name, isFragment) {\n\t\tconst children = t.react.buildChildren(node);\n\t\tif (children && children.length !== 0) {\n\t\t\tif (!isFragment) {\n\t\t\t\traw('>');\n\t\t\t}\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tlet child = children[i];\n\t\t\t\tif (t.isStringLiteral(child)) {\n\t\t\t\t\tescapeText(child.value);\n\t\t\t\t}\n\t\t\t\telse if (t.isJSXElement(child)) {\n\t\t\t\t\tprocessNode(child);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\texpr(child);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!isFragment) {\n\t\t\t\tif (isComponentName(name)) {\n\t\t\t\t\tif (terse) {\n\t\t\t\t\t\traw('<//>');\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\traw('</');\n\t\t\t\t\t\texpr(name);\n\t\t\t\t\t\traw('>');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\traw('</');\n\t\t\t\t\traw(name.name);\n\t\t\t\t\traw('>');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (!isFragment) {\n\t\t\traw('/>');\n\t\t}\n\t}\n\n\tfunction processNode(node, path, isRoot) {\n\t\tconst open = node.openingElement;\n\t\tconst name = getNameExpr(open.name);\n\t\tconst isFragment = isFragmentName(name);\n\t\t\n\t\tif (!isFragment) {\n\t\t\tif (isComponentName(name)) {\n\t\t\t\traw('<');\n\t\t\t\texpr(name);\n\t\t\t}\n\t\t\telse {\n\t\t\t\traw('<');\n\t\t\t\traw(name.name);\n\t\t\t}\n\t\t\t\n\t\t\tif (open.attributes) {\n\t\t\t\tfor (let i = 0; i < open.attributes.length; i++) {\n\t\t\t\t\tconst attr = open.attributes[i];\n\t\t\t\t\traw(' ');\n\t\t\t\t\tif (t.isJSXSpreadAttribute(attr)) {\n\t\t\t\t\t\traw('...');\n\t\t\t\t\t\texpr(attr.argument);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst { name, value } = attr;\n\t\t\t\t\tif (t.isJSXNamespacedName(name)) {\n\t\t\t\t\t\traw(name.namespace.name + ':' + name.name.name);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\traw(name.name);\n\t\t\t\t\t}\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\traw('=');\n\t\t\t\t\t\tif (value.expression) {\n\t\t\t\t\t\t\texpr(value.expression);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (t.isStringLiteral(value)) {\n\t\t\t\t\t\t\tescapePropValue(value);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\texpr(value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprocessChildren(node, name, isFragment);\n\n\t\tif (isRoot) {\n\t\t\tconst template = t.templateLiteral(quasis, expressions);\n\t\t\tconst replacement = t.taggedTemplateExpression(tag, template);\n\t\t\tpath.replaceWith(replacement);\n\t\t}\n\t}\n\n\tfunction jsxVisitorHandler(path, state, isFragment) {\n\t\tlet quasisBefore = quasis;\n\t\tlet expressionsBefore = expressions;\n\t\n\t\tquasis = [t.templateElement({ raw: '', cooked: '' })];\n\t\texpressions = [];\n\t\n\t\tif (isFragment) {\n\t\t\tprocessChildren(path.node, null, true);\n\t\t\tconst template = t.templateLiteral(quasis, expressions);\n\t\t\tconst replacement = t.taggedTemplateExpression(tag, template);\n\t\t\tpath.replaceWith(replacement);\n\t\t}\n\t\telse {\n\t\t\tprocessNode(path.node, path, true);\n\t\t}\n\t\n\t\tquasis = quasisBefore;\n\t\texpressions = expressionsBefore;\n\t\n\t\tstate.set('jsxElement', true);\n\t}\n\n\treturn {\n\t\tname: 'transform-jsx-to-htm',\n\t\tinherits: jsx,\n\t\tvisitor: {\n\t\t\tProgram: {\n\t\t\t\texit(path, state) {\n\t\t\t\t\tif (state.get('jsxElement') && importDeclaration) {\n\t\t\t\t\t\tpath.unshiftContainer('body', importDeclaration);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tJSXElement(path, state) {\n\t\t\t\tjsxVisitorHandler(path, state, false);\n\t\t\t},\n\t\t\t\n\t\t\tJSXFragment(path, state) {\n\t\t\t\tjsxVisitorHandler(path, state, true);\n\t\t\t}\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/babel-plugin-transform-jsx-to-htm/package.json",
    "content": "{\n\t\"name\": \"babel-plugin-transform-jsx-to-htm\",\n\t\"version\": \"2.2.0\",\n\t\"description\": \"Babel plugin to compile JSX to Tagged Templates.\",\n\t\"main\": \"dist/babel-plugin-transform-jsx-to-htm.js\",\n\t\"scripts\": {\n\t\t\"build\": \"microbundle index.mjs -f cjs --target node --no-compress --no-sourcemap\",\n\t\t\"prepare\": \"npm run build\"\n\t},\n\t\"files\": [\n\t\t\"dist\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/developit/htm.git\",\n\t\t\"directory\": \"packages/babel-plugin-transform-jsx-to-htm\"\n\t},\n\t\"keywords\": [\n\t\t\"tagged template\",\n\t\t\"template literals\",\n\t\t\"html\",\n\t\t\"htm\",\n\t\t\"jsx\",\n\t\t\"virtual dom\",\n\t\t\"hyperscript\",\n\t\t\"babel\",\n\t\t\"babel plugin\",\n\t\t\"babel-plugin\"\n\t],\n\t\"author\": \"Jason Miller <jason@developit.ca>\",\n\t\"license\": \"Apache-2.0\",\n\t\"homepage\": \"https://github.com/developit/htm/tree/master/packages/babel-plugin-transform-jsx-to-htm\",\n\t\"dependencies\": {\n\t\t\"@babel/plugin-syntax-jsx\": \"^7.2.0\",\n\t\t\"htm\": \"^3.0.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"microbundle\": \"^0.10.1\"\n\t}\n}\n"
  },
  {
    "path": "src/build.mjs",
    "content": "import { MINI } from './constants.mjs';\n\nconst MODE_SLASH = 0;\nconst MODE_TEXT = 1;\nconst MODE_WHITESPACE = 2;\nconst MODE_TAGNAME = 3;\nconst MODE_COMMENT = 4;\nconst MODE_PROP_SET = 5;\nconst MODE_PROP_APPEND = 6;\n\nconst CHILD_APPEND = 0;\nconst CHILD_RECURSE = 2;\nconst TAG_SET = 3;\nconst PROPS_ASSIGN = 4;\nconst PROP_SET = MODE_PROP_SET;\nconst PROP_APPEND = MODE_PROP_APPEND;\n\n// Turn a result of a build(...) call into a tree that is more\n// convenient to analyze and transform (e.g. Babel plugins).\n// For example:\n// \ttreeify(\n//\t\tbuild`<div href=\"1${a}\" ...${b}><${x} /></div>`,\n//\t\t[X, Y, Z]\n//\t)\n// returns:\n// \t{\n// \t\ttag: 'div',\n//\t\tprops: [ { href: [\"1\", X] }, Y ],\n// \t\tchildren: [ { tag: Z, props: [], children: [] } ]\n// \t}\nexport const treeify = (built, fields) => {\n\tconst _treeify = built => {\n\t\tlet tag = '';\n\t\tlet currentProps = null;\n\t\tconst props = [];\n\t\tconst children = [];\n\n\t\tfor (let i = 1; i < built.length; i++) {\n\t\t\tconst type = built[i++];\n\t\t\tconst value = built[i] ? fields[built[i++]-1] : built[++i];\n\n\t\t\tif (type === TAG_SET) {\n\t\t\t\ttag = value;\n\t\t\t}\n\t\t\telse if (type === PROPS_ASSIGN) {\n\t\t\t\tprops.push(value);\n\t\t\t\tcurrentProps = null;\n\t\t\t}\n\t\t\telse if (type === PROP_SET) {\n\t\t\t\tif (!currentProps) {\n\t\t\t\t\tcurrentProps = Object.create(null);\n\t\t\t\t\tprops.push(currentProps);\n\t\t\t\t}\n\t\t\t\tcurrentProps[built[++i]] = [value];\n\t\t\t}\n\t\t\telse if (type === PROP_APPEND) {\n\t\t\t\tcurrentProps[built[++i]].push(value);\n\t\t\t}\n\t\t\telse if (type === CHILD_RECURSE) {\n\t\t\t\tchildren.push(_treeify(value));\n\t\t\t}\n\t\t\telse if (type === CHILD_APPEND) {\n\t\t\t\tchildren.push(value);\n\t\t\t}\n\t\t}\n\n\t\treturn { tag, props, children };\n\t};\n\tconst { children } = _treeify(built);\n\treturn children.length > 1 ? children : children[0];\n};\n\nexport const evaluate = (h, built, fields, args) => {\n\tlet tmp;\n\n\t// `build()` used the first element of the operation list as\n\t// temporary workspace. Now that `build()` is done we can use\n\t// that space to track whether the current element is \"dynamic\"\n\t// (i.e. it or any of its descendants depend on dynamic values).\n\tbuilt[0] = 0;\n\n\tfor (let i = 1; i < built.length; i++) {\n\t\tconst type = built[i++];\n\n\t\t// Set `built[0]`'s appropriate bits if this element depends on a dynamic value.\n\t\tconst value = built[i] ? ((built[0] |= type ? 1 : 2), fields[built[i++]]) : built[++i];\n\n\t\tif (type === TAG_SET) {\n\t\t\targs[0] = value;\n\t\t}\n\t\telse if (type === PROPS_ASSIGN) {\n\t\t\targs[1] = Object.assign(args[1] || {}, value);\n\t\t}\n\t\telse if (type === PROP_SET) {\n\t\t\t(args[1] = args[1] || {})[built[++i]] = value;\n\t\t}\n\t\telse if (type === PROP_APPEND) {\n\t\t\targs[1][built[++i]] += (value + '');\n\t\t}\n\t\telse if (type) { // type === CHILD_RECURSE\n\t\t\t// Set the operation list (including the staticness bits) as\n\t\t\t// `this` for the `h` call.\n\t\t\ttmp = h.apply(value, evaluate(h, value, fields, ['', null]));\n\t\t\targs.push(tmp);\n\n\t\t\tif (value[0]) {\n\t\t\t\t// Set the 2nd lowest bit it the child element is dynamic.\n\t\t\t\tbuilt[0] |= 2;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Rewrite the operation list in-place if the child element is static.\n\t\t\t\t// The currently evaluated piece `CHILD_RECURSE, 0, [...]` becomes\n\t\t\t\t// `CHILD_APPEND, 0, tmp`.\n\t\t\t\t// Essentially the operation list gets optimized for potential future\n\t\t\t\t// re-evaluations.\n\t\t\t\tbuilt[i-2] = CHILD_APPEND;\n\t\t\t\tbuilt[i] = tmp;\n\t\t\t}\n\t\t}\n\t\telse { // type === CHILD_APPEND\n\t\t\targs.push(value);\n\t\t}\n\t}\n\n\treturn args;\n};\n\nexport const build = function(statics) {\n\tconst fields = arguments;\n\tconst h = this;\n\n\tlet mode = MODE_TEXT;\n\tlet buffer = '';\n\tlet quote = '';\n\tlet current = [0];\n\tlet char, propName;\n\n\tconst commit = field => {\n\t\tif (mode === MODE_TEXT && (field || (buffer = buffer.replace(/^\\s*\\n\\s*|\\s*\\n\\s*$/g,'')))) {\n\t\t\tif (MINI) {\n\t\t\t\tcurrent.push(field ? fields[field] : buffer);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrent.push(CHILD_APPEND, field, buffer);\n\t\t\t}\n\t\t}\n\t\telse if (mode === MODE_TAGNAME && (field || buffer)) {\n\t\t\tif (MINI) {\n\t\t\t\tcurrent[1] = field ? fields[field] : buffer;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrent.push(TAG_SET, field, buffer);\n\t\t\t}\n\t\t\tmode = MODE_WHITESPACE;\n\t\t}\n\t\telse if (mode === MODE_WHITESPACE && buffer === '...' && field) {\n\t\t\tif (MINI) {\n\t\t\t\tcurrent[2] = Object.assign(current[2] || {}, fields[field]);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrent.push(PROPS_ASSIGN, field, 0);\n\t\t\t}\n\t\t}\n\t\telse if (mode === MODE_WHITESPACE && buffer && !field) {\n\t\t\tif (MINI) {\n\t\t\t\t(current[2] = current[2] || {})[buffer] = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrent.push(PROP_SET, 0, true, buffer);\n\t\t\t}\n\t\t}\n\t\telse if (mode >= MODE_PROP_SET) {\n\t\t\tif (MINI) {\n\t\t\t\tif (mode === MODE_PROP_SET) {\n\t\t\t\t\t(current[2] = current[2] || {})[propName] = field ? buffer ? (buffer + fields[field]) : fields[field] : buffer;\n\t\t\t\t\tmode = MODE_PROP_APPEND;\n\t\t\t\t}\n\t\t\t\telse if (field || buffer) {\n\t\t\t\t\tcurrent[2][propName] += field ? buffer + fields[field] : buffer;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (buffer || (!field && mode === MODE_PROP_SET)) {\n\t\t\t\t\tcurrent.push(mode, 0, buffer, propName);\n\t\t\t\t\tmode = MODE_PROP_APPEND;\n\t\t\t\t}\n\t\t\t\tif (field) {\n\t\t\t\t\tcurrent.push(mode, field, 0, propName);\n\t\t\t\t\tmode = MODE_PROP_APPEND;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tbuffer = '';\n\t};\n\n\tfor (let i=0; i<statics.length; i++) {\n\t\tif (i) {\n\t\t\tif (mode === MODE_TEXT) {\n\t\t\t\tcommit();\n\t\t\t}\n\t\t\tcommit(i);\n\t\t}\n\n\t\tfor (let j=0; j<statics[i].length;j++) {\n\t\t\tchar = statics[i][j];\n\n\t\t\tif (mode === MODE_TEXT) {\n\t\t\t\tif (char === '<') {\n\t\t\t\t\t// commit buffer\n\t\t\t\t\tcommit();\n\t\t\t\t\tif (MINI) {\n\t\t\t\t\t\tcurrent = [current, '', null];\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcurrent = [current];\n\t\t\t\t\t}\n\t\t\t\t\tmode = MODE_TAGNAME;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbuffer += char;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (mode === MODE_COMMENT) {\n\t\t\t\t// Ignore everything until the last three characters are '-', '-' and '>'\n\t\t\t\tif (buffer === '--' && char === '>') {\n\t\t\t\t\tmode = MODE_TEXT;\n\t\t\t\t\tbuffer = '';\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbuffer = char + buffer[0];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (quote) {\n\t\t\t\tif (char === quote) {\n\t\t\t\t\tquote = '';\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbuffer += char;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (char === '\"' || char === \"'\") {\n\t\t\t\tquote = char;\n\t\t\t}\n\t\t\telse if (char === '>') {\n\t\t\t\tcommit();\n\t\t\t\tmode = MODE_TEXT;\n\t\t\t}\n\t\t\telse if (!mode) {\n\t\t\t\t// Ignore everything until the tag ends\n\t\t\t}\n\t\t\telse if (char === '=') {\n\t\t\t\tmode = MODE_PROP_SET;\n\t\t\t\tpropName = buffer;\n\t\t\t\tbuffer = '';\n\t\t\t}\n\t\t\telse if (char === '/' && (mode < MODE_PROP_SET || statics[i][j+1] === '>')) {\n\t\t\t\tcommit();\n\t\t\t\tif (mode === MODE_TAGNAME) {\n\t\t\t\t\tcurrent = current[0];\n\t\t\t\t}\n\t\t\t\tmode = current;\n\t\t\t\tif (MINI) {\n\t\t\t\t\t(current = current[0]).push(h.apply(null, mode.slice(1)));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t(current = current[0]).push(CHILD_RECURSE, 0, mode);\n\t\t\t\t}\n\t\t\t\tmode = MODE_SLASH;\n\t\t\t}\n\t\t\telse if (char === ' ' || char === '\\t' || char === '\\n' || char === '\\r') {\n\t\t\t\t// <a disabled>\n\t\t\t\tcommit();\n\t\t\t\tmode = MODE_WHITESPACE;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbuffer += char;\n\t\t\t}\n\n\t\t\tif (mode === MODE_TAGNAME && buffer === '!--') {\n\t\t\t\tmode = MODE_COMMENT;\n\t\t\t\tcurrent = current[0];\n\t\t\t}\n\t\t}\n\t}\n\tcommit();\n\n\tif (MINI) {\n\t\treturn current.length > 2 ? current.slice(1) : current[1];\n\t}\n\treturn current;\n};\n"
  },
  {
    "path": "src/cjs.mjs",
    "content": "import htm from './index.mjs';\nif (typeof module != 'undefined') module.exports = htm;\nelse self.htm = htm;\n"
  },
  {
    "path": "src/constants-mini.mjs",
    "content": "export const MINI = true;\n"
  },
  {
    "path": "src/constants.mjs",
    "content": "export const MINI = false;\n"
  },
  {
    "path": "src/index.d.ts",
    "content": "declare const htm: {\n  bind<HResult>(\n    h: (type: any, props: Record<string, any>, ...children: any[]) => HResult\n  ): (strings: TemplateStringsArray, ...values: any[]) => HResult | HResult[];\n};\nexport default htm;\n"
  },
  {
    "path": "src/index.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport { MINI } from './constants.mjs';\nimport { build, evaluate } from './build.mjs';\n\nconst CACHES = new Map();\n\nconst regular = function(statics) {\n\tlet tmp = CACHES.get(this);\n\tif (!tmp) {\n\t\ttmp = new Map();\n\t\tCACHES.set(this, tmp);\n\t}\n\ttmp = evaluate(this, tmp.get(statics) || (tmp.set(statics, tmp = build(statics)), tmp), arguments, []);\n\treturn tmp.length > 1 ? tmp : tmp[0];\n};\n\nexport default MINI ? build : regular;\n"
  },
  {
    "path": "src/integrations/preact/index.d.ts",
    "content": "import { h, VNode, Component } from 'preact';\nexport * from 'preact/hooks';\ndeclare function render(tree: VNode, parent: HTMLElement): void;\ndeclare const html: (strings: TemplateStringsArray, ...values: any[]) => VNode;\nexport { h, html, render, Component };\n"
  },
  {
    "path": "src/integrations/preact/index.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport { h, Component, render } from 'preact';\nimport htm from 'htm';\n\nconst html = htm.bind(h);\n\nexport { h, html, render, Component };\n"
  },
  {
    "path": "src/integrations/preact/package.json",
    "content": "{\n\t\"name\": \"htm_preact\",\n\t\"module\": \"index.module.js\",\n\t\"main\": \"index.js\",\n\t\"umd:main\": \"index.umd.js\",\n\t\"unpkg\": \"standalone.js\",\n\t\"scripts\": {\n\t\t\"build\": \"npm run -s build:main && npm run -s build:standalone && npm run -s build:static\",\n\t\t\"build:main\": \"microbundle index.mjs -o ../../../preact/index.js --external preact,htm --no-sourcemap --target web\",\n\t\t\"build:static\": \"cp index.d.ts package.json ../../../preact/\",\n\t\t\"build:standalone\": \"microbundle standalone.mjs -o ../../../preact/standalone.js -f es,umd --no-sourcemap --target web\"\n\t}\n}"
  },
  {
    "path": "src/integrations/preact/standalone.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport { h, Component, createContext, createRef, render } from 'preact';\nimport { useState, useReducer, useEffect, useLayoutEffect, useRef, useImperativeHandle, useMemo, useCallback, useContext, useDebugValue, useErrorBoundary } from 'preact/hooks';\nimport htm from '../../index.mjs';\n\nconst html = htm.bind(h);\n\nexport { h, html, render, Component, createContext, createRef, useState, useReducer, useEffect, useLayoutEffect, useRef, useImperativeHandle, useMemo, useCallback, useContext, useDebugValue, useErrorBoundary };\n"
  },
  {
    "path": "src/integrations/react/index.d.ts",
    "content": "import * as React from 'react';\ndeclare const html: (strings: TemplateStringsArray, ...values: any[]) => React.ReactElement;\n"
  },
  {
    "path": "src/integrations/react/index.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport { createElement } from 'react';\nimport htm from 'htm';\nexport const html = htm.bind(createElement);\n"
  },
  {
    "path": "src/integrations/react/package.json",
    "content": "{\n\t\"name\": \"htm_react\",\n\t\"module\": \"index.module.js\",\n\t\"main\": \"index.js\",\n\t\"umd:main\": \"index.umd.js\",\n\t\"unpkg\": \"index.js\",\n\t\"scripts\": {\n\t\t\"build\": \"npm run -s build:main && npm run -s build:static\",\n\t\t\"build:main\": \"microbundle index.mjs -o ../../../react/index.js --external react,htm --no-sourcemap --target web\",\n\t\t\"build:static\": \"cp index.d.ts package.json ../../../react/\"\n\t}\n}"
  },
  {
    "path": "test/__d8.mjs",
    "content": "/*global globalThis*/\n\nconst queue = [];\nlet stack = [];\nlet index = 0;\n\nasync function process() {\n\tconst id = index++;\n\tif (id === queue.length) {\n\t\tqueue.length = index = 0;\n\t\treturn;\n\t}\n\tconst [op, name, fn, extra] = queue[id];\n\tqueue[id] = undefined;\n\tawait processors[op](name, fn, extra);\n\tawait process();\n}\n\nconst processors = {\n\tasync describe(name, fn, path) {\n\t\tstack.push(name);\n\t\tlog('INFO', name);\n\t\tawait fn();\n\t\tstack.pop();\n\t},\n\tasync test(name, fn, path) {\n\t\tlet stackBefore = stack;\n\t\tstack = path.concat(name);\n\t\tlogBuffer = [];\n\t\tawait new Promise(resolve => {\n\t\t\tlet calls = 0;\n\t\t\tconst done = () => {\n\t\t\t\tif (calls++) throw Error(`Callback called multiple times\\n\\t${name}`);\n\t\t\t\tlog('INFO', `✅  ${name}`);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tPromise.resolve(done)\n\t\t\t\t.then(fn)\n\t\t\t\t.then(() => calls || done())\n\t\t\t\t.catch(err => {\n\t\t\t\t\tlog('ERROR', `🚨  ${name}`);\n\t\t\t\t\tlog('ERROR', '\\t' + String(err.stack || err.message || err));\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t});\n\t\tfor (let i=0; i<logBuffer.length; i++) log(...logBuffer[i]);\n\t\tlogBuffer = undefined;\n\t\tstack = stackBefore;\n\t}\n};\n\n\nlet logBuffer;\n\nfunction wrap(obj, method) {\n\tobj[method] = function() {\n\t\tlet out = '  ';\n\t\tfor (let i=0; i<arguments.length; i++) {\n\t\t\tlet val = arguments[i];\n\t\t\tif (typeof val === 'object' && val) {\n\t\t\t\tval = JSON.stringify(val);\n\t\t\t}\n\t\t\tif (out) out += ' ';\n\t\t\tout += val;\n\t\t}\n\t\tif (method!=='error') out = `\\u001b[37m${out}\\u001b[0m`;\n\t\tif (logBuffer) {\n\t\t\tlogBuffer.push([method.toUpperCase(), out]);\n\t\t}\n\t\telse {\n\t\t\tlog(method.toUpperCase(), out);\n\t\t}\n\t};\n}\nwrap(console, 'log');\nwrap(console, 'info');\nwrap(console, 'warn');\nwrap(console, 'error');\n\nfunction log(type, msg) {\n\tif (type === 'ERROR') {\n\t\tmsg = `\\u001b[31m${msg}\\u001b[39m`;\n\t}\n\tif (type === 'SUCCESS') {\n\t\tmsg = `\\u001b[32m${msg}\\u001b[39m`;\n\t}\n\tprint(Array.from({ length: stack.length }).fill('  ').join('') + msg);\n}\n\nfunction push(op, name, fn, extra) {\n\tif (queue.push([op, name, fn, extra]) === 1) {\n\t\tsetTimeout(process);\n\t}\n}\n\nglobalThis.describe = (name, fn) => {\n\tpush('describe', name, fn, stack.slice());\n};\n\nglobalThis.test = (name, fn) => {\n\tpush('test', name, fn, stack.slice());\n};\n\nglobalThis.expect = (subject) => new Expect(subject);\n\nconst SUBJECT = Symbol.for('subject');\nconst NEGATED = Symbol.for('negated');\nclass Expect {\n\tconstructor(subject) {\n\t\tthis[SUBJECT] = subject;\n\t}\n\tget not() {\n\t\tthis[NEGATED] = true;\n\t\treturn this;\n\t}\n\ttoBeGreaterThan(value) {\n\t\tconst subject = this[SUBJECT];\n\t\tconst negated = this[NEGATED];\n\n\t\tconst isOver = subject > value;\n\t\tlet msg = `Expected ${subject}${negated?' not':''} to be greater than ${value}`;\n\t\tif (logBuffer) {\n\t\t\tfor (let i=logBuffer.length; i-- > -1; ) {\n\t\t\t\tif (i<0 || logBuffer[i][2] === 1) {\n\t\t\t\t\tlogBuffer.splice(i+1, 0, [isOver !== negated ? 'SUCCESS' : 'ERROR', '  ' + msg, 1]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tlog(isOver !== negated ? 'SUCCESS' : 'ERROR', '  ' + msg);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "test/__perftest.mjs",
    "content": "import './__d8.mjs';\nimport './perf.test.mjs';\n"
  },
  {
    "path": "test/babel-transform-jsx.test.mjs",
    "content": "import { transform } from '@babel/core';\nimport transformJsxToHtmPlugin from 'babel-plugin-transform-jsx-to-htm';\n\nfunction compile(code, { plugins = [], ...options } = {}) {\n\treturn transform(code, {\n\t\tbabelrc: false,\n\t\tconfigFile: false,\n\t\tsourceType: 'module',\n\t\tplugins: [\n\t\t\t...plugins,\n\t\t\t[transformJsxToHtmPlugin, options]\n\t\t]\n\t}).code;\n}\n\ndescribe('babel-plugin-transform-jsx-to-htm', () => {\n\tdescribe('import', () => {\n\t\ttest('import shortcut', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div />);`, { import: 'htm/preact' })\n\t\t\t).toBe('import { html } from \"htm/preact\";\\nhtml`<div/>`;');\n\t\t});\n\n\t\ttest('import shortcut, dotted tag', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div />);`, { tag: 'html.bound', import: 'htm/preact' })\n\t\t\t).toBe('import { html } from \"htm/preact\";\\nhtml.bound`<div/>`;');\n\t\t});\n\n\t\ttest('named import', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div />);`, { import: { module: 'htm/preact', export: '$html' } })\n\t\t\t).toBe('import { $html as html } from \"htm/preact\";\\nhtml`<div/>`;');\n\t\t});\n\n\t\ttest('named import, dotted tag', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div />);`, { tag: 'html.bound', import: { module: 'htm/preact', export: '$html' } })\n\t\t\t).toBe('import { $html as html } from \"htm/preact\";\\nhtml.bound`<div/>`;');\n\t\t});\n\n\t\ttest('default import', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div />);`, { import: { module: 'htm/preact', export: 'default' } })\n\t\t\t).toBe('import html from \"htm/preact\";\\nhtml`<div/>`;');\n\t\t});\n\n\t\ttest('namespace import', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div />);`, { import: { module: 'htm/preact', export: '*' } })\n\t\t\t).toBe('import * as html from \"htm/preact\";\\nhtml`<div/>`;');\n\t\t});\n\n\t\ttest('no import without JSX', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`false;`, { import: 'htm/preact' })\n\t\t\t).toBe('false;');\n\t\t});\n\t});\n\n\tdescribe('elements and text', () => {\n\t\ttest('single named element', () => {\n\t\t\texpect(\n\t\t\t\tcompile('(<div />);')\n\t\t\t).toBe('html`<div/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<div>a</div>);')\n\t\t\t).toBe('html`<div>a</div>`;');\n\t\t\t\n\t\t\texpect(\n\t\t\t\tcompile('(<div$ />);')\n\t\t\t).toBe('html`<div$/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<div$>a</div$>);')\n\t\t\t).toBe('html`<div$>a</div$>`;');\n\t\t\t\n\t\t\texpect(\n\t\t\t\tcompile('(<div_ />);')\n\t\t\t).toBe('html`<div_/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<div_>a</div_>);')\n\t\t\t).toBe('html`<div_>a</div_>`;');\n\t\t});\n\n\t\ttest('single component element', () => {\n\t\t\texpect(\n\t\t\t\tcompile('(<Foo />);')\n\t\t\t).toBe('html`<${Foo}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<Foo>a</Foo>);')\n\t\t\t).toBe('html`<${Foo}>a</${Foo}>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<$ />);')\n\t\t\t).toBe('html`<${$}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<$>a</$>);')\n\t\t\t).toBe('html`<${$}>a</${$}>`;');\n\t\t\t\n\t\t\texpect(\n\t\t\t\tcompile('(<_ />);')\n\t\t\t).toBe('html`<${_}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<_>a</_>);')\n\t\t\t).toBe('html`<${_}>a</${_}>`;');\n\t\t\t\n\t\t\texpect(\n\t\t\t\tcompile('(<_foo />);')\n\t\t\t).toBe('html`<${_foo}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<_foo>a</_foo>);')\n\t\t\t).toBe('html`<${_foo}>a</${_foo}>`;');\n\t\t\t\n\t\t\texpect(\n\t\t\t\tcompile('(<$foo />);')\n\t\t\t).toBe('html`<${$foo}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<$foo>a</$foo>);')\n\t\t\t).toBe('html`<${$foo}>a</${$foo}>`;');\n\t\t});\n\n\t\ttest('dotted component element', () => {\n\t\t\texpect(\n\t\t\t\tcompile('(<a.b.c />);')\n\t\t\t).toBe('html`<${a.b.c}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<a.b.c>a</a.b.c>);')\n\t\t\t).toBe('html`<${a.b.c}>a</${a.b.c}>`;');\n\t\t});\n\n\t\ttest('namespaced element names', () => {\n\t\t\texpect(\n\t\t\t\tcompile('(<a:b/>);')\n\t\t\t).toBe('html`<a:b/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<a:b><x:y/></a:b>);')\n\t\t\t).toBe('html`<a:b><x:y/></a:b>`;');\n\t\t});\n\n\t\ttest('namespaced attributes', () => {\n\t\t\texpect(\n\t\t\t\tcompile('(<a b:c=\"d\"/>);')\n\t\t\t).toBe('html`<a b:c=\"d\"/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<a b:c=\"d\" e:f={1} g>h</a>);')\n\t\t\t).toBe('html`<a b:c=\"d\" e:f=${1} g>h</a>`;');\n\t\t});\n\n\t\ttest('static text', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div>Hello</div>);`)\n\t\t\t).toBe('html`<div>Hello</div>`;');\n\t\t\texpect(\n\t\t\t\tcompile(`(<div>こんにちわ</div>);`)\n\t\t\t).toBe('html`<div>こんにちわ</div>`;');\n\t\t});\n\n\t\ttest('HTML entities get unescaped', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div>&amp;</div>);`)\n\t\t\t).toBe('html`<div>&</div>`;');\n\t\t});\n\n\t\ttest('&lt; gets wrapped into an expression container', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div>a&lt;b&lt;&lt;&lt;c</div>);`)\n\t\t\t).toBe('html`<div>${\"a<b<<<c\"}</div>`;');\n\t\t});\n\t});\n\n\tdescribe('fragments', () => {\n\t\ttest('React.Fragment', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`<React.Fragment><div>Foo</div><div>Bar</div></React.Fragment>`)\n\t\t\t).toBe('html`<div>Foo</div><div>Bar</div>`;');\n\t\t});\n\n\t\ttest('short syntax', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`<><div>Foo</div><div>Bar</div></>`)\n\t\t\t).toBe('html`<div>Foo</div><div>Bar</div>`;');\n\t\t});\n\n\t\ttest('root expressions', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`<React.Fragment>{Foo}{Bar}</React.Fragment>`)\n\t\t\t).toBe('html`${Foo}${Bar}`;');\n\t\t});\n\n\t\ttest('short syntax fragments should not crash due to TemplateLiteral quasi/expression unbalance', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`<><Foo />{Bar}</>`)\n\t\t\t).toBe('html`<${Foo}/>${Bar}`;');\n\t\t});\n\t});\n\n\tdescribe('props', () => {\n\t\ttest('static values', () => {\n\t\t\texpect(\n\t\t\t\tcompile('(<div a=\"a\" b=\"bb\" c d />);')\n\t\t\t).toBe('html`<div a=\"a\" b=\"bb\" c d/>`;');\n\t\t\texpect(\n\t\t\t\tcompile('(<div a=\"こんにちわ\" />);')\n\t\t\t).toBe('html`<div a=\"こんにちわ\"/>`;');\n\t\t});\n\n\t\ttest('HTML entities get unescaped', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div a=\"&amp;\" />);`)\n\t\t\t).toBe('html`<div a=\"&\"/>`;');\n\t\t});\n\n\t\ttest('double quote values with single quotes', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div a=\"'b'\" />);`)\n\t\t\t).toBe(`html\\`<div a=\"'b'\"/>\\`;`);\n\t\t});\n\n\t\ttest('single quote values with double quotes', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div a='\"b\"' />);`)\n\t\t\t).toBe(`html\\`<div a='\"b\"'/>\\`;`);\n\t\t});\n\n\t\ttest('escape values with newlines as expressions', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div a=\"\\n\" />);`)\n\t\t\t).toBe('html`<div a=${\"\\\\n\"}/>`;');\n\t\t});\n\n\t\ttest('escape values with both single and double quotes as expressions', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div a=\"&#34;'\" />);`)\n\t\t\t).toBe('html`<div a=${\"\\\\\"\\'\"}/>`;');\n\t\t});\n\n\t\ttest('expression values', () => {\n\t\t\texpect(\n\t\t\t\tcompile('const Foo = (props, a) => <div a={a} b={\"b\"} c={{}} d={props.d} e />;')\n\t\t\t).toBe('const Foo = (props, a) => html`<div a=${a} b=${\"b\"} c=${{}} d=${props.d} e/>`;');\n\t\t});\n\n\t\ttest('spread', () => {\n\t\t\texpect(\n\t\t\t\tcompile('const Foo = props => <div {...props} />;')\n\t\t\t).toBe('const Foo = props => html`<div ...${props}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<div {...{}} />);')\n\t\t\t).toBe('html`<div ...${{}}/>`;');\n\n\t\t\texpect(\n\t\t\t\tcompile('(<div a {...b} c />);')\n\t\t\t).toBe('html`<div a ...${b} c/>`;');\n\t\t});\n\t});\n\n\tdescribe('nesting', () => {\n\t\ttest('element children are merged into one template', () => {\n\t\t\texpect(\n\t\t\t\tcompile('const Foo = () => <div class=\"foo\" draggable>\\n  <h1>Hello</h1>\\n  <p>world.</p>\\n</div>;')\n\t\t\t).toBe('const Foo = () => html`<div class=\"foo\" draggable><h1>Hello</h1><p>world.</p></div>`;');\n\t\t});\n\n\t\ttest('inter-element whitespace is collapsed similarly to the JSX plugin', () => {\n\t\t\texpect(\n\t\t\t\tcompile('const Foo = props => <div a b> a \\n <em> b \\n B </em> c <strong> d </strong> e </div>;')\n\t\t\t).toBe('const Foo = props => html`<div a b> a<em> b B </em> c <strong> d </strong> e </div>`;');\n\t\t});\n\n\t\ttest('nested JSX Expressions produce nested templates', () => {\n\t\t\texpect(\n\t\t\t\tcompile('const Foo = props => <ul>{props.items.map(item =>\\n  <li>\\n    {item}\\n  </li>\\n)}</ul>;')\n\t\t\t).toBe('const Foo = props => html`<ul>${props.items.map(item => html`<li>${item}</li>`)}</ul>`;');\n\t\t});\n\n\t\ttest('empty expressions are ignored', () => {\n\t\t\texpect(\n\t\t\t\tcompile(`(<div>{/* a comment */}</div>);`)\n\t\t\t).toBe('html`<div/>`;');\n\t\t});\n\t});\n});\n"
  },
  {
    "path": "test/babel.test.mjs",
    "content": "/**\n * @jest-environment node\n */\n\nimport { transform } from '@babel/core';\nimport htmBabelPlugin from 'babel-plugin-htm';\n\nconst options = {\n\tbabelrc: false,\n\tconfigFile: false,\n\tsourceType: 'script',\n\tcompact: true\n};\n\ndescribe('htm/babel', () => {\n\ttest('basic transformation', () => {\n\t\texpect(\n\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\thtmBabelPlugin\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"div\",{id:\"hello\"},\"hello\");`);\n\t});\n\n\ttest('basic transformation with variable', () => {\n\t\texpect(\n\t\t\ttransform('var name=\"world\";html`<div id=hello>hello, ${name}</div>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\thtmBabelPlugin\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`var name=\"world\";h(\"div\",{id:\"hello\"},\"hello, \",name);`);\n\t});\n\n\ttest('basic nested transformation', () => {\n\t\texpect(\n\t\t\ttransform('html`<a b=${2} ...${{ c: 3 }}>d: ${4}</a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",Object.assign({b:2},{c:3}),\"d: \",4);`);\n\n\t\texpect(\n\t\t\ttransform('html`<a b=${2} ...${{ c: 3 }}>d: ${4}</a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:2,...{c:3}},\"d: \",4);`);\n\t});\n\n\ttest('spread a single variable', () => {\n\t\texpect(\n\t\t\ttransform('html`<a ...${foo}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\thtmBabelPlugin\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",foo);`);\n\n\t\texpect(\n\t\t\ttransform('html`<a ...${foo}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",foo);`);\n\t});\n\n\ttest('spread two variables', () => {\n\t\texpect(\n\t\t\ttransform('html`<a ...${foo} ...${bar}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",Object.assign({},foo,bar));`);\n\n\t\texpect(\n\t\t\ttransform('html`<a ...${foo} ...${bar}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{...foo,...bar});`);\n\t});\n\n\ttest('property followed by a spread', () => {\n\t\texpect(\n\t\t\ttransform('html`<a b=\"1\" ...${foo}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",Object.assign({b:\"1\"},foo));`);\n\n\t\texpect(\n\t\t\ttransform('html`<a b=\"1\" ...${foo}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"1\",...foo});`);\n\t});\n\n\ttest('spread followed by a property', () => {\n\t\texpect(\n\t\t\ttransform('html`<a ...${foo} b=\"1\"></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",Object.assign({},foo,{b:\"1\"}));`);\n\n\t\texpect(\n\t\t\ttransform('html`<a ...${foo} b=\"1\"></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{...foo,b:\"1\"});`);\n\t});\n\n\ttest('mix-and-match spreads', () => {\n\t\texpect(\n\t\t\ttransform('html`<a b=\"1\" ...${foo} c=${2} ...${{d:3}}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",Object.assign({b:\"1\"},foo,{c:2},{d:3}));`);\n\n\t\texpect(\n\t\t\ttransform('html`<a b=\"1\" ...${foo} c=${2} ...${{d:3}}></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"1\",...foo,c:2,...{d:3}});`);\n\t});\n\n\ttest('mix-and-match dynamic and static values', () => {\n\t\texpect(\n\t\t\ttransform('html`<a b=\"1${2}${3}\"></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"1\"+2+3});`);\n\n\t\texpect(\n\t\t\ttransform('html`<a b=\"1${2}${3}\"></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"1\"+2+3});`);\n\t});\n\n\ttest('coerces props to strings when needed', () => {\n\t\texpect(\n\t\t\ttransform('html`<a b=\\'${1}${2}${\"3\"}${4}\\'></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"\"+1+2+\"3\"+4});`);\n\n\t\texpect(\n\t\t\ttransform('html`<a b=\\'${1}${2}${\"3\"}${4}\\'></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"\"+1+2+\"3\"+4});`);\n\t});\n\n\ttest('coerces props to strings only when needed', () => {\n\t\texpect(\n\t\t\ttransform('html`<a b=\\'${\"1\"}${2}${\"3\"}${4}\\'></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseBuiltIns: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"1\"+2+\"3\"+4});`);\n\n\t\texpect(\n\t\t\ttransform('html`<a b=\\'${\"1\"}${2}${\"3\"}${4}\\'></a>`;', {\n\t\t\t\t...options,\n\t\t\t\tplugins: [\n\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\tuseNativeSpread: true\n\t\t\t\t\t}]\n\t\t\t\t]\n\t\t\t}).code\n\t\t).toBe(`h(\"a\",{b:\"1\"+2+\"3\"+4});`);\n\t});\n\n\tdescribe('{variableArity:false}', () => {\n\t\ttest('should pass no children as an empty Array', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div />`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tvariableArity: false\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`h(\"div\",null,[]);`);\n\t\t});\n\n\t\ttest('should pass children as an Array', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tvariableArity: false\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`h(\"div\",{id:\"hello\"},[\"hello\"]);`);\n\t\t});\n\t});\n\n\tdescribe('{pragma:false}', () => {\n\t\ttest('should transform to inline vnodes', () => {\n\t\t\texpect(\n\t\t\t\ttransform('var name=\"world\",vnode=html`<div id=hello>hello, ${name}</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tpragma: false\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`var name=\"world\",vnode={tag:\"div\",props:{id:\"hello\"},children:[\"hello, \",name]};`);\n\t\t});\n\t});\n\n\tdescribe('{monomorphic:true}', () => {\n\t\ttest('should transform to monomorphic inline vnodes', () => {\n\t\t\texpect(\n\t\t\t\ttransform('var name=\"world\",vnode=html`<div id=hello>hello, ${name}</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tmonomorphic: true\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`var name=\"world\",vnode={type:1,tag:\"div\",props:{id:\"hello\"},children:[{type:3,tag:null,props:null,children:null,text:\"hello, \"},name],text:null};`);\n\t\t});\n\t});\n\n\tdescribe('{import:\"preact\"}', () => {\n\t\ttest('should do nothing when pragma=false', () => {\n\t\t\texpect(\n\t\t\t\ttransform('var name=\"world\",vnode=html`<div id=hello>hello, ${name}</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tpragma: false,\n\t\t\t\t\t\t\timport: 'preact'\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`var name=\"world\",vnode={tag:\"div\",props:{id:\"hello\"},children:[\"hello, \",name]};`);\n\t\t});\n\t\ttest('should do nothing when tag is not used', () => {\n\t\t\texpect(\n\t\t\t\ttransform('console.log(\"hi\");', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\timport: 'preact'\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`console.log(\"hi\");`);\n\t\t});\n\t\ttest('should add import', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\timport: 'preact'\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`import{h}from\"preact\";h(\"div\",{id:\"hello\"},\"hello\");`);\n\t\t});\n\t\ttest('should add import for pragma', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tpragma: 'createElement',\n\t\t\t\t\t\t\timport: 'react'\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`import{createElement}from\"react\";createElement(\"div\",{id:\"hello\"},\"hello\");`);\n\t\t});\n\t});\n\n\tdescribe('{import:Object}', () => {\n\t\ttest('should add import', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\timport: {\n\t\t\t\t\t\t\t\tmodule: 'preact',\n\t\t\t\t\t\t\t\texport: 'h'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`import{h}from\"preact\";h(\"div\",{id:\"hello\"},\"hello\");`);\n\t\t});\n\t\ttest('should add import as pragma', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tpragma: 'hh',\n\t\t\t\t\t\t\timport: {\n\t\t\t\t\t\t\t\tmodule: 'preact',\n\t\t\t\t\t\t\t\texport: 'h'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`import{h as hh}from\"preact\";hh(\"div\",{id:\"hello\"},\"hello\");`);\n\t\t});\n\t\ttest('should add import default', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tpragma: 'React.createElement',\n\t\t\t\t\t\t\timport: {\n\t\t\t\t\t\t\t\tmodule: 'react',\n\t\t\t\t\t\t\t\texport: 'default'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`import React from\"react\";React.createElement(\"div\",{id:\"hello\"},\"hello\");`);\n\t\t});\n\t\ttest('should add import *', () => {\n\t\t\texpect(\n\t\t\t\ttransform('html`<div id=hello>hello</div>`;', {\n\t\t\t\t\t...options,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[htmBabelPlugin, {\n\t\t\t\t\t\t\tpragma: 'Preact.h',\n\t\t\t\t\t\t\timport: {\n\t\t\t\t\t\t\t\tmodule: 'preact',\n\t\t\t\t\t\t\t\texport: '*'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}]\n\t\t\t\t\t]\n\t\t\t\t}).code\n\t\t\t).toBe(`import*as Preact from\"preact\";Preact.h(\"div\",{id:\"hello\"},\"hello\");`);\n\t\t});\n\t});\n\n\tdescribe('main test suite', () => {\n\t\t// Run all of the main tests against the Babel plugin:\n\t\tconst mod = require('fs').readFileSync(require('path').resolve(__dirname, 'index.test.mjs'), 'utf8').replace(/\\\\0/g, '\\0');\n\t\tconst { code } = transform(mod.replace(/^\\s*import\\s*.+?\\s*from\\s+(['\"]).*?\\1[\\s;]*$/im, 'const htm = function(){};'), {\n\t\t\t...options,\n\t\t\tplugins: [htmBabelPlugin]\n\t\t});\n\t\teval(code);\n\t});\n});\n"
  },
  {
    "path": "test/fixtures/esm/index.js",
    "content": "import assert from 'assert';\nimport htm from 'htm';\nimport * as preact from 'htm/preact';\nimport * as standalone from 'htm/preact/standalone';\n// TODO: Enable once react distro is ESM compatible.\n// import * as react 'htm/react';\n\nassert(typeof htm === 'function', 'import htm from \"htm\"');\n\nassert(typeof preact.html === 'function', 'import { html } from \"preact\"');\n\nassert(typeof standalone.html === 'function', 'import { html } from \"preact/standalone\"');\n\nconsole.log('✅ Dist Tests Passed');\n"
  },
  {
    "path": "test/fixtures/esm/package.json",
    "content": "{\n  \"name\": \"htm_dist_test\",\n  \"type\": \"module\",\n  \"private\": true,\n  \"description\": \"A package to test importing htm as ES modules in Node\",\n  \"dependencies\": {\n    \"htm\": \"file:htm.tgz\",\n    \"preact\": \"^10.4.1\"\n  }\n}\n"
  },
  {
    "path": "test/index.test.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport htm from '../src/index.mjs';\n\nconst h = (tag, props, ...children) => ({ tag, props, children });\nconst html = htm.bind(h);\n\ndescribe('htm', () => {\n\ttest('empty', () => {\n\t\texpect(html``).toEqual(undefined);\n\t});\n\n\ttest('single named elements', () => {\n\t\texpect(html`<div />`).toEqual({ tag: 'div', props: null, children: [] });\n\t\texpect(html`<div/>`).toEqual({ tag: 'div', props: null, children: [] });\n\t\texpect(html`<span />`).toEqual({ tag: 'span', props: null, children: [] });\n\t});\n\t\n\ttest('multiple root elements', () => {\n\t\texpect(html`<a /><b></b><c><//>`).toEqual([\n\t\t\t{ tag: 'a', props: null, children: [] },\n\t\t\t{ tag: 'b', props: null, children: [] },\n\t\t\t{ tag: 'c', props: null, children: [] }\n\t\t]);\n\t});\n\n\ttest('single dynamic tag name', () => {\n\t\texpect(html`<${'foo'} />`).toEqual({ tag: 'foo', props: null, children: [] });\n\t\tfunction Foo () {}\n\t\texpect(html`<${Foo} />`).toEqual({ tag: Foo, props: null, children: [] });\n\t});\n\n\ttest('single boolean prop', () => {\n\t\texpect(html`<a disabled />`).toEqual({ tag: 'a', props: { disabled: true }, children: [] });\n\t});\n\n\ttest('two boolean props', () => {\n\t\texpect(html`<a invisible disabled />`).toEqual({ tag: 'a', props: { invisible: true, disabled: true }, children: [] });\n\t});\n\n\ttest('single prop with empty value', () => {\n\t\texpect(html`<a href=\"\" />`).toEqual({ tag: 'a', props: { href: '' }, children: [] });\n\t});\n\n\ttest('two props with empty values', () => {\n\t\texpect(html`<a href=\"\" foo=\"\" />`).toEqual({ tag: 'a', props: { href: '', foo: '' }, children: [] });\n\t});\n\n\ttest('single prop with empty name', () => {\n\t\texpect(html`<a \"\"=\"foo\" />`).toEqual({ tag: 'a', props: { '': 'foo' }, children: [] });\n\t});\n\n\ttest('single prop with static value', () => {\n\t\texpect(html`<a href=\"/hello\" />`).toEqual({ tag: 'a', props: { href: '/hello' }, children: [] });\n\t});\n\t\n\ttest('single prop with static value followed by a single boolean prop', () => {\n\t\texpect(html`<a href=\"/hello\" b />`).toEqual({ tag: 'a', props: { href: '/hello', b: true }, children: [] });\n\t});\n\n\ttest('two props with static values', () => {\n\t\texpect(html`<a href=\"/hello\" target=\"_blank\" />`).toEqual({ tag: 'a', props: { href: '/hello', target: '_blank' }, children: [] });\n\t});\n\n\ttest('single prop with dynamic value', () => {\n\t\texpect(html`<a href=${'foo'} />`).toEqual({ tag: 'a', props: { href: 'foo' }, children: [] });\n\t});\n\n\ttest('slash in the middle of tag name or property name self-closes the element', () => {\n\t\texpect(html`<ab/ba prop=value>`).toEqual({ tag: 'ab', props: null, children: [] });\n\t\texpect(html`<abba pr/op=value>`).toEqual({ tag: 'abba', props: { pr: true }, children: [] });\n\t});\n\n\ttest('slash in a property value does not self-closes the element, unless followed by >', () => {\n\t\texpect(html`<abba prop=val/ue><//>`).toEqual({ tag: 'abba', props: { prop: 'val/ue' }, children: [] });\n\t\texpect(html`<abba prop=value/>`).toEqual({ tag: 'abba', props: { prop: 'value' }, children: [] });\n\t\texpect(html`<abba prop=value/ ><//>`).toEqual({ tag: 'abba', props: { prop: 'value/' }, children: [] });\n\t});\n\n\ttest('two props with dynamic values', () => {\n\t\tfunction onClick(e) { }\n\t\texpect(html`<a href=${'foo'} onClick=${onClick} />`).toEqual({ tag: 'a', props: { href: 'foo', onClick }, children: [] });\n\t});\n\n\ttest('prop with multiple static and dynamic values get concatenated as strings', () => {\n\t\texpect(html`<a href=\"before${'foo'}after\" />`).toEqual({ tag: 'a', props: { href: 'beforefooafter' }, children: [] });\n\t\texpect(html`<a href=${1}${1} />`).toEqual({ tag: 'a', props: { href: '11' }, children: [] });\n\t\texpect(html`<a href=${1}between${1} />`).toEqual({ tag: 'a', props: { href: '1between1' }, children: [] });\n\t\texpect(html`<a href=/before/${'foo'}/after />`).toEqual({ tag: 'a', props: { href: '/before/foo/after' }, children: [] });\n\t\texpect(html`<a href=/before/${'foo'}/>`).toEqual({ tag: 'a', props: { href: '/before/foo' }, children: [] });\n\t});\n\n\ttest('spread props', () => {\n\t\texpect(html`<a ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { foo: 'bar' }, children: [] });\n\t\texpect(html`<a b ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] });\n\t\texpect(html`<a b c ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, c: true, foo: 'bar' }, children: [] });\n\t\texpect(html`<a ...${{ foo: 'bar' }} b />`).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] });\n\t\texpect(html`<a b=\"1\" ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: '1', foo: 'bar' }, children: [] });\n\t\texpect(html`<a x=\"1\"><b y=\"2\" ...${{ c: 'bar' }}/></a>`).toEqual(h('a', { x: '1' }, h('b', { y: '2', c: 'bar' }) ));\n\t\texpect(html`<a b=${2} ...${{ c: 3 }}>d: ${4}</a>`).toEqual(h('a',{ b: 2, c: 3 }, 'd: ', 4));\n\t\texpect(html`<a ...${{ c: 'bar' }}><b ...${{ d: 'baz' }}/></a>`).toEqual(h('a', { c: 'bar' }, h('b', { d: 'baz' }) ));\n\t});\n\n\ttest('multiple spread props in one element', () => {\n\t\texpect(html`<a ...${{ foo: 'bar' }} ...${{ quux: 'baz' }} />`).toEqual({ tag: 'a', props: { foo: 'bar', quux: 'baz' }, children: [] });\n\t});\n  \n\ttest('mixed spread + static props', () => {\n\t\texpect(html`<a b ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] });\n\t\texpect(html`<a b c ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, c: true, foo: 'bar' }, children: [] });\n\t\texpect(html`<a ...${{ foo: 'bar' }} b />`).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] });\n\t\texpect(html`<a ...${{ foo: 'bar' }} b c />`).toEqual({ tag: 'a', props: { b: true, c: true, foo: 'bar' }, children: [] });\n\t});\n\n\ttest('closing tag', () => {\n\t\texpect(html`<a></a>`).toEqual({ tag: 'a', props: null, children: [] });\n\t\texpect(html`<a b></a>`).toEqual({ tag: 'a', props: { b: true }, children: [] });\n\t});\n\n\ttest('auto-closing tag', () => {\n\t\texpect(html`<a><//>`).toEqual({ tag: 'a', props: null, children: [] });\n\t});\n\n\ttest('non-element roots', () => {\n\t\texpect(html`foo`).toEqual('foo');\n\t\texpect(html`${1}`).toEqual(1);\n\t\texpect(html`foo${1}`).toEqual(['foo', 1]);\n\t\texpect(html`foo${1}bar`).toEqual(['foo', 1, 'bar']);\n\t});\n\n\ttest('text child', () => {\n\t\texpect(html`<a>foo</a>`).toEqual({ tag: 'a', props: null, children: ['foo'] });\n\t\texpect(html`<a>foo bar</a>`).toEqual({ tag: 'a', props: null, children: ['foo bar'] });\n\t\texpect(html`<a>foo \"<b /></a>`).toEqual({ tag: 'a', props: null, children: ['foo \"', { tag: 'b', props: null, children: [] }] });\n\t});\n\n\ttest('dynamic child', () => {\n\t\texpect(html`<a>${'foo'}</a>`).toEqual({ tag: 'a', props: null, children: ['foo'] });\n\t});\n\n\ttest('mixed text + dynamic children', () => {\n\t\texpect(html`<a>${'foo'}bar</a>`).toEqual({ tag: 'a', props: null, children: ['foo', 'bar'] });\n\t\texpect(html`<a>before${'foo'}after</a>`).toEqual({ tag: 'a', props: null, children: ['before', 'foo', 'after'] });\n\t\texpect(html`<a>foo${null}</a>`).toEqual({ tag: 'a', props: null, children: ['foo', null] });\n\t});\n\n\ttest('element child', () => {\n\t\texpect(html`<a><b /></a>`).toEqual(h('a', null, h('b', null)));\n\t});\n\n\ttest('multiple element children', () => {\n\t\texpect(html`<a><b /><c /></a>`).toEqual(h('a', null, h('b', null), h('c', null)));\n\t\texpect(html`<a x><b y /><c z /></a>`).toEqual(h('a', { x: true }, h('b', { y: true }), h('c', { z: true })));\n\t\texpect(html`<a x=1><b y=2 /><c z=3 /></a>`).toEqual(h('a', { x: '1' }, h('b', { y: '2' }), h('c', { z: '3' })));\n\t\texpect(html`<a x=${1}><b y=${2} /><c z=${3} /></a>`).toEqual(h('a', { x: 1 }, h('b', { y: 2 }), h('c', { z: 3 })));\n\t});\n\n\ttest('mixed typed children', () => {\n\t\texpect(html`<a>foo<b /></a>`).toEqual(h('a', null, 'foo', h('b', null)));\n\t\texpect(html`<a><b />bar</a>`).toEqual(h('a', null, h('b', null), 'bar'));\n\t\texpect(html`<a>before<b />after</a>`).toEqual(h('a', null, 'before', h('b', null), 'after'));\n\t\texpect(html`<a>before<b x=1 />after</a>`).toEqual(h('a', null, 'before', h('b', { x: '1' }), 'after'));\n\t\texpect(html`\n\t\t\t<a>\n\t\t\t\tbefore\n\t\t\t\t${'foo'}\n\t\t\t\t<b />\n\t\t\t\t${'bar'}\n\t\t\t\tafter\n\t\t\t</a>\n\t\t`).toEqual(h('a', null, 'before', 'foo', h('b', null), 'bar', 'after'));\n\t});\n\n\ttest('hyphens (-) are allowed in attribute names', () => {\n\t\texpect(html`<a b-c></a>`).toEqual(h('a', { 'b-c': true }));\n\t});\n\t\n\ttest('NUL characters are allowed in attribute values', () => {\n\t\texpect(html`<a b=\"\\0\"></a>`).toEqual(h('a', { b: '\\0' }));\n\t\texpect(html`<a b=\"\\0\" c=${'foo'}></a>`).toEqual(h('a', { b: '\\0', c: 'foo' }));\n\t});\n\t\n\ttest('NUL characters are allowed in text', () => {\n\t\texpect(html`<a>\\0</a>`).toEqual(h('a', null, '\\0'));\n\t\texpect(html`<a>\\0${'foo'}</a>`).toEqual(h('a', null, '\\0', 'foo'));\n\t});\n\t\n\ttest('cache key should be unique', () => {\n\t\thtml`<a b=\"${'foo'}\" />`;\n\t\texpect(html`<a b=\"\\0\" />`).toEqual(h('a', { b: '\\0' }));\n\t\texpect(html`<a>${''}9aaaaaaaaa${''}</a>`).not.toEqual(html`<a>${''}0${''}aaaaaaaaa${''}</a>`);\n\t\texpect(html`<a>${''}0${''}aaaaaaaa${''}</a>`).not.toEqual(html`<a>${''}.8aaaaaaaa${''}</a>`);\n\t});\n\n\ttest('do not mutate spread variables', () => {\n\t\tconst obj = {};\n\t\thtml`<a ...${obj} b=\"1\" />`;\n\t\texpect(obj).toEqual({});\n\t});\n\n\ttest('ignore HTML comments', () => {\n\t\texpect(html`<a><!-- Hello, world! --></a>`).toEqual(h('a', null));\n\t\texpect(html`<a><!-- Hello,\\nworld! --></a>`).toEqual(h('a', null));\n\t\texpect(html`<a><!-- ${'Hello, world!'} --></a>`).toEqual(h('a', null));\n\t\texpect(html`<a><!--> Hello, world <!--></a>`).toEqual(h('a', null));\n\t});\n});\n"
  },
  {
    "path": "test/perf.test.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport htm from '../src/index.mjs';\n\nconst h = (tag, props, ...children) => ({ tag, props, children });\nconst html = htm.bind(h);\n\ndescribe('performance', () => {\n\ttest('creation', () => {\n\t\tconst results = [];\n\t\tconst Foo = ({ name }) => html`<div class=\"foo\">${name}</div>`;\n\t\tlet count = 0;\n\t\tfunction go(count) {\n\t\t\tconst statics = [\n\t\t\t\t'\\n<div id=app'+(++count)+' data-loading=\"true\">\\n\\t<h1>Hello World</h1>\\n\\t<ul class=\"items\" id=', '>\\n\\t',\n\t\t\t\t'\\n\\t</ul>\\n\\t\\n\\t<', ' name=\"foo\" />\\n\\t<', ' name=\"other\">content<//>\\n\\n</div>'\n\t\t\t];\n\t\t\treturn html(\n\t\t\t\tstatics,\n\t\t\t\t`id${count}`,\n\t\t\t\thtml`<li data-id=\"${'i' + count}\">${'some text #' + count}</li>`,\n\t\t\t\tFoo, Foo\n\t\t\t);\n\t\t}\n\t\tlet now = performance.now();\n\t\tconst start = now;\n\t\twhile ((now = performance.now()) < start+1000) {\n\t\t\tcount++;\n\t\t\tif (results.push(String(go(count)))===10) results.length = 0;\n\t\t}\n\t\tconst elapsed = now - start;\n\t\tconst hz = count / elapsed * 1000;\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(`Creation: ${(hz|0).toLocaleString()}/s, average: ${elapsed/count*1000|0}µs`);\n\t\texpect(elapsed).toBeGreaterThan(999);\n\t\texpect(hz).toBeGreaterThan(1000);\n\t});\n\n\ttest('usage', () => {\n\t\tconst results = [];\n\t\tconst Foo = ({ name }) => html`<div class=\"foo\">${name}</div>`;\n\t\tlet count = 0;\n\t\tfunction go(count) {\n\t\t\treturn html`\n\t\t\t\t<div id=\"app\" data-loading=\"true\">\n\t\t\t\t\t<h1>Hello World</h1>\n\t\t\t\t\t<ul class=\"items\" id=${`id${count}`}>\n\t\t\t\t\t\t${html`<li data-id=\"${'i' + count}\">${'some text #' + count}</li>`}\n\t\t\t\t\t</ul>\n\t\t\t\t\t<${Foo} name=\"foo\" />\n\t\t\t\t\t<${Foo} name=\"other\">content<//>\n\t\t\t\t</div>\n\t\t\t`;\n\t\t}\n\t\tlet now = performance.now();\n\t\tconst start = now;\n\t\twhile ((now = performance.now()) < start+1000) {\n\t\t\tcount++;\n\t\t\tif (results.push(String(go(count)))===10) results.length = 0;\n\t\t}\n\t\tconst elapsed = now - start;\n\t\tconst hz = count / elapsed * 1000;\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(`Usage: ${(hz|0).toLocaleString()}/s, average: ${elapsed/count*1000|0}µs`);\n\t\texpect(elapsed).toBeGreaterThan(999);\n\t\texpect(hz).toBeGreaterThan(100000);\n\t});\n});\n"
  },
  {
    "path": "test/preact.test.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport { html, Component, render } from 'htm/preact';\n\nconst sleep = ms => new Promise(r => setTimeout(r, ms));\n\ndescribe('htm/preact', () => {\n\tconst scratch = document.createElement('div');\n\tdocument.body.appendChild(scratch);\n\n\tclass Foo extends Component {\n\t\trender({ name }, { count = 0 }) {\n\t\t\treturn html`\n\t\t\t\t<div class=\"foo\">\n\t\t\t\t\t<h1>Name: ${name}</h1>\n\t\t\t\t\t<p>Hello world!</p>\n\t\t\t\t\t<button onClick=${() => this.setState({ count: ++count })}>Click Me</button>\n\t\t\t\t\t<pre>Count: ${count}</pre>\n\t\t\t\t\txml-style end tags:\n\t\t\t\t\t<${Bar} hello />\n\t\t\t\t\texplicit end tags:\n\t\t\t\t\t<${Bar} hello>some children (count=${count})</${Bar}>\n\t\t\t\t\timplicit end tags: (${'<//>'})\n\t\t\t\t\t<${Bar} hello>some children (count=${count})<//>\n\t\t\t\t\tsome text at the end\n\t\t\t\t</div>\n\t\t\t`;\n\t\t}\n\t}\n\tconst Bar = ({ hello, children }) => html`\n\t<div>\n\t\tValue of hello: ${hello + ''}\n\t\t${children}\n\t</div>\n\t`;\n\n\tconst Baz = ({ myCaseSensitiveProp }) => html`<div>${myCaseSensitiveProp}</div>`;\n\n\tconst fullHtml = '<div class=\"foo\"><h1>Name: jason</h1><p>Hello world!</p><button>Click Me</button><pre>Count: 0</pre>xml-style end tags:<div>Value of hello: true</div>explicit end tags:<div>Value of hello: truesome children (count=0)</div>implicit end tags: (&lt;//&gt;)<div>Value of hello: truesome children (count=0)</div>some text at the end</div>';\n\n\ttest('initial render', () => {\n\t\trender(html`<${Foo} name=jason />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(fullHtml);\n\t});\n\n\ttest('rerenders in-place', () => {\n\t\trender(html`<${Foo} name=tom />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(fullHtml.replace('jason', 'tom'));\n\t});\n\n\ttest('state update re-renders', async () => {\n\t\tdocument.querySelector('button').click();\n\t\tdocument.querySelector('button').click();\n\t\tawait sleep(1);\n\t\texpect(scratch.innerHTML).toBe(fullHtml.replace('jason', 'tom').replace(/\\b0\\b/g, '2'));\n\t});\n\n\ttest('preserves case', () => {\n\t\tscratch.textContent = '';\n\t\trender(html`<${Baz} myCaseSensitiveProp=\"Yay!\" />`, scratch);\n\t\texpect(scratch.innerHTML).toBe('<div>Yay!</div>');\n\t});\n\n\ttest('object spreads', () => {\n\t\tscratch.textContent = '';\n\n\t\tconst props = { a: 1, b: 2, c: 3 };\n\t\tconst other = { d: 4, e: 5, f: 6 };\n\n\t\trender(html`<div ...${props} />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(`<div a=\"1\" b=\"2\" c=\"3\"></div>`);\n\t\tscratch.innerHTML = '';\n\n\t\trender(html`<div is-before=\"blah\" ...${props} />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(`<div a=\"1\" b=\"2\" c=\"3\" is-before=\"blah\"></div>`);\n\t\tscratch.innerHTML = '';\n\n\t\trender(html`<div ...${props} is-after />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(`<div a=\"1\" b=\"2\" c=\"3\" is-after=\"true\"></div>`);\n\t\texpect(JSON.stringify(props)).toBe(`{\"a\":1,\"b\":2,\"c\":3}`);\n\t\tscratch.innerHTML = '';\n\n\t\trender(html`<div is-before ...${props} is-after=\"blah\" />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(`<div a=\"1\" b=\"2\" c=\"3\" is-after=\"blah\" is-before=\"true\"></div>`);\n\t\tscratch.innerHTML = '';\n\n\t\trender(html`<div ...${props} ...${other} />`, scratch);\n\t\texpect(scratch.innerHTML).toBe(`<div a=\"1\" b=\"2\" c=\"3\" d=\"4\" e=\"5\" f=\"6\"></div>`);\n\t\tscratch.innerHTML = '';\n\n\t});\n\n\t// describe('performance', () => {\n\t// \ttest('creation', () => {\n\t// \t\tconst results = [];\n\t// \t\tconst Foo = ({ name }) => html`<div class=\"foo\">${name}</div>`;\n\t// \t\tconst statics = [\n\t// \t\t\t'\\n<div id=app data-loading=\"true\">\\n\\t<h1>Hello World</h1>\\n\\t<ul class=\"items\" id=', '>\\n\\t',\n\t// \t\t\t'\\n\\t</ul>\\n\\t\\n\\t<', ' name=\"foo\" />\\n\\t<', ' name=\"other\">content</', '>\\n\\n</div>'\n\t// \t\t];\n\t// \t\tlet count = 0;\n\t// \t\tfunction go(count) {\n\t// \t\t\treturn html(\n\t// \t\t\t\tstatics.concat(['count:', count]),\n\t// \t\t\t\t`id${count}`,\n\t// \t\t\t\thtml(['<li data-id=\"','\">', '</li>'], 'i'+count, 'some text #'+count),\n\t// \t\t\t\tFoo, Foo, Foo\n\t// \t\t\t);\n\t// \t\t}\n\t// \t\tlet now = performance.now();\n\t// \t\tconst start = now;\n\t// \t\twhile ((now = performance.now()) < start+2000) {\n\t// \t\t\tcount++;\n\t// \t\t\tif (results.push(String(go(count)))===10) results.length = 0;\n\t// \t\t}\n\t// \t\tconst elapsed = now - start;\n\t// \t\tconst hz = count / elapsed * 1000;\n\t// \t\t// eslint-disable-next-line no-console\n\t// \t\tconsole.log(`Creation: ${hz|0}/s, average: ${elapsed/count.toFixed(4)}ms`);\n\t// \t\texpect(elapsed).toBeGreaterThan(999);\n\t// \t\texpect(hz).toBeGreaterThan(10);\n\t// \t});\n\t// });\n});\n"
  },
  {
    "path": "test/statics-caching.test.mjs",
    "content": "/**\n * Copyright 2018 Google Inc. All Rights Reserved.\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 *     http://www.apache.org/licenses/LICENSE-2.0\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 */\n\nimport htm from '../src/index.mjs';\n\nconst h = (tag, props, ...children) => ({ tag, props, children });\nconst html = htm.bind(h);\n\ndescribe('htm', () => {\n\ttest('should cache static subtrees', () => {\n\t\tconst x = () => html`<div>a</div>`;\n\t\tconst a = x();\n\t\tconst b = x();\n\t\texpect(a).toEqual({ tag: 'div', props: null, children: ['a'] });\n\t\texpect(b).toEqual({ tag: 'div', props: null, children: ['a'] });\n\t\texpect(a).toBe(b);\n\t});\n\n\ttest('should have a different cache for each h', () => {\n\t\tlet tmp = htm.bind(() => 1);\n\t\tconst x = () => tmp`<div>a</div>`;\n\t\tconst a = x();\n\t\ttmp = htm.bind(() => 2);\n\t\tconst b = x();\n\n\t\texpect(a).toBe(1);\n\t\texpect(b).toBe(2);\n\t});\n\n\tdescribe('`this` in the h function', () => {\n\t\tconst html = htm.bind(function() {\n\t\t\treturn this;\n\t\t});\n\n\t\ttest('stays the same for each call site)', () => {\n\t\t\tconst x = () => html`<div>a</div>`;\n\t\t\tconst a = x();\n\t\t\tconst b = x();\n\t\t\texpect(a).toBe(b);\n\t\t});\n\n\t\ttest('is different for each call site', () => {\n\t\t\tconst a = html`<div>a</div>`;\n\t\t\tconst b = html`<div>a</div>`;\n\t\t\texpect(a).not.toBe(b);\n\t\t});\n\n\t\ttest('is specific to each h function', () => {\n\t\t\tlet tmp = htm.bind(function() { return this; });\n\t\t\tconst x = () => tmp`<div>a</div>`;\n\t\t\tconst a = x();\n\t\t\ttmp = htm.bind(function() { return this; });\n\t\t\tconst b = x();\n\t\t\texpect(a).not.toBe(b);\n\t\t});\n\t});\n\n\tdescribe('`this[0]` in the h function contains the staticness bits', () => {\n\t\tconst html = htm.bind(function() {\n\t\t\treturn this[0];\n\t\t});\n\n\t\ttest('should be 0 for static subtrees', () => {\n\t\t\texpect(html`<div></div>`).toBe(0);\n\t\t\texpect(html`<div>a</div>`).toBe(0);\n\t\t\texpect(html`<div><a /></div>`).toBe(0);\n\t\t});\n\n\t\ttest('should be 2 for static nodes with some dynamic children', () => {\n\t\t\texpect(html`<div>${'a'}<b /></div>`).toBe(2);\n\t\t\texpect(html`<div><a y=${2} /><b /></div>`).toBe(2);\n\t\t});\n\n\t\ttest('should be 1 for dynamic nodes with all static children', () => {\n\t\t\texpect(html`<div x=${1}><a /><b /></div>`).toBe(1);\n\t\t});\n\n\t\ttest('should be 3 for dynamic nodes with some dynamic children', () => {\n\t\t\texpect(html`<div x=${1}><a y=${2} /><b /></div>`).toBe(3);\n\t\t});\n\t});\n\n\tdescribe('the h function should be able to modify `this[0]`', () => {\n\t\tfunction wrapH(h) {\n\t\t\treturn function(type, props, ...children) {\n\t\t\t\tif (type === '@static') {\n\t\t\t\t\tthis[0] &= ~3;\n\t\t\t\t\treturn children;\n\t\t\t\t}\n\t\t\t\tif (props['@static']) {\n\t\t\t\t\tthis[0] &= ~3;\n\t\t\t\t}\n\t\t\t\treturn h(type, props, ...children);\n\t\t\t};\n\t\t}\n\n\t\ttest('should be able to force subtrees to be static via a prop', () => {\n\t\t\tconst html = htm.bind(wrapH(h));\n\t\t\tconst x = () => html`<div @static>${'a'}</div>`;\n\t\t\tconst a = x();\n\t\t\tconst b = x();\n\t\t\texpect(a).toEqual({ tag: 'div', props: { '@static': true }, children: ['a'] });\n\t\t\texpect(b).toEqual({ tag: 'div', props: { '@static': true }, children: ['a'] });\n\t\t\texpect(a).toBe(b);\n\t\t});\n\n\t\ttest('should be able to force subtrees to be static via a special tag', () => {\n\t\t\tconst html = htm.bind(wrapH(h));\n\t\t\tconst x = () => html`<@static>${'a'}<//>`;\n\t\t\tconst a = x();\n\t\t\tconst b = x();\n\t\t\texpect(a).toEqual(['a']);\n\t\t\texpect(b).toEqual(['a']);\n\t\t\texpect(a).toBe(b);\n\t\t});\n\t});\n});\n"
  }
]