{"name":"vue-demi","version":"0.3.0","author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"license":"MIT","_id":"vue-demi@0.3.0","homepage":"https://github.com/antfu/vue-demi#readme","bugs":{"url":"https://github.com/antfu/vue-demi/issues"},"bin":{"vue-demi-fix":"scripts/postinstall.js"},"dist":{"shasum":"9bd2f662726bf5be8c7d2b94d0c6ad5af396d328","tarball":"http://registry-npm.ywwl.com/vue-demi/download/vue-demi-0.3.0.tgz","fileCount":14,"integrity":"sha512-3wJWfUF6DKBR26APWNvbfKGLZyH/rSjDu3qhfce5uFfEsW3X+T4U7MdAP0HdFPHqmLcR5jrfzSpOvxwDMeuC6A==","signatures":[{"sig":"MEUCIQDHKG/Aux1QsHWx4lVFZ4bWp+zAato3k8tCzwEd37xiUAIgRqQl6qphNhpvv/BuBSXapUORHAluqROiatAmdoEzhJw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5029,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQmc+CRA9TVsSAnZWagAA5aMQAJlvOKjC/XM4B26InJEv\n4PBZX0QDPZQv0gMbFngqnKKQGJLS0UbHdat5i/O3a9IVS62b6VZFMC75rOU+\ncW7q487SpqbSdpwfPd8MDAsdR1mCjZM2awy9DPNpcHfrO0VAxIegnPcuiI0I\nfWbOL6eDLaYfsFqqHIVqJhrIfppsGjdI/bPmIq3D3iJ9HjIgq6jVlD9cfwst\n0gTDI0pHijEyDawQ7yTUoAApLhVw3Pc8MQnYHEZruz//4aJEc0S8E/fFX5F7\nxMxBueTSx5nVyF4bCvMkb47QFrEOQj4MRFp8sZ3XYHjbny9zD/Fdy+MjinXl\nADNA1BvWpg4lXysRH1M79wIJ/6oC6DHtY23jrJFSgZAtA6OI632HlZd0E/GA\nRpVdDGgfUeKsgTZMG5qiKN+87HwJRi880WjWfE8+IVDVZQtl8SjmMAxxMi2U\nhvspaMgxNdzJdq1/yGzzsUNwQ8B4jIV5Nddo4Zk4WFhE2Kj8V3gg88qGDLzu\nnhK/fNj5MWax+02ddVBhiGii8uXqRSYb/ZRSR4GH7K0YniuKD2yHSClIhFIY\nf9R4XtmN+ZqP0WeQPBFEeFEJBuUO32w3NsjFxzIQXAX03To0zLAoCCrXaJUh\n6TBLGkV7T0EYcZCR+mOnCq50Mrct8/hNi/fmMOcVTQYDM6tPrMovj/KxJkPS\nn8wm\r\n=Uud8\r\n-----END PGP SIGNATURE-----\r\n","size":2731,"noattachment":false,"key":"/vue-demi/-/vue-demi-0.3.0.tgz"},"main":"lib/index.cjs.js","unpkg":"lib/index.iffe.js","module":"lib/index.esm.js","gitHead":"6b952108b2b908b2eb3c7eea8b22a85552d7c8d4","scripts":{"postinstall":"node ./scripts/postinstall.js"},"typings":"lib/index.d.ts","_npmUser":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"jsdelivr":"lib/index.iffe.js","repository":{"url":"git+https://github.com/antfu/vue-demi.git","type":"git"},"_npmVersion":"6.14.4","description":"<p align=\"center\"> <br> <img src=\"./assets/banner.png\" width=\"500\"/> <br> <br> <a href='https://www.npmjs.com/package/vue-demi'><img src='https://img.shields.io/npm/v/vue-demi?color=42b883' alt='npm'></a> </p>","directories":{},"_nodeVersion":"12.18.0","_hasShrinkwrap":false,"devDependencies":{"vue":"^2.6.11"},"peerDependencies":{"@vue/composition-api":">=1.0.0-beta.1"},"_npmOperationalInternal":{"tmp":"tmp/vue-demi_0.3.0_1598187325666_0.8479014142545966","host":"s3://npm-registry-packages"},"readme":"<p align=\"center\">\n<img src=\"https://github.com/vueuse/vue-demi/blob/main/assets/banner.png?raw=true\" width=\"600\"/>\n<br>\n<a href='https://www.npmjs.com/package/vue-demi'><img src='https://img.shields.io/npm/v/vue-demi?color=42b883' alt='npm'></a>\n</p>\n\n<p align=\"center\">\n<b>Vue Demi</b> (<i>half</i> in French) is a developing utility<br> allows you to write <b>Universal Vue Libraries</b> for Vue 2 & 3<br>\n<i>See more details in <a href='https://antfu.me/posts/make-libraries-working-with-vue-2-and-3'>this blog post</a></i>\n</p>\n\n<br>\n\n<br>\n\n## Strategies\n\n- `<=2.6`: exports from `vue` + `@vue/composition-api` with plugin auto installing.\n- `2.7`: exports from `vue` (Composition API is built-in in Vue 2.7).\n- `>=3.0`: exports from `vue`, with polyfill of Vue 2's `set` and `del` API.\n\n## Usage\n\nInstall this as your plugin's dependency:\n\n```bash\nnpm i vue-demi\n# or\nyarn add vue-demi\n# or \npnpm i vue-demi\n```\n\nAdd `vue` and `@vue/composition-api` to your plugin's peer dependencies to specify what versions you support.\n\n```jsonc\n{\n  \"dependencies\": {\n    \"vue-demi\": \"latest\"\n  },\n  \"peerDependencies\": {\n    \"@vue/composition-api\": \"^1.0.0-rc.1\",\n    \"vue\": \"^2.0.0 || >=3.0.0\"\n  },\n  \"peerDependenciesMeta\": {\n    \"@vue/composition-api\": {\n      \"optional\": true\n    }\n  },\n  \"devDependencies\": {\n    \"vue\": \"^3.0.0\" // or \"^2.6.0\" base on your preferred working environment\n  },\n}\n```\n\nImport everything related to Vue from it, it will redirect to `vue@2` + `@vue/composition-api` or `vue@3` based on users' environments.\n\n```ts\nimport { ref, reactive, defineComponent } from 'vue-demi'\n```\n\nPublish your plugin and all is done!\n\n> When using with [Vite](https://vitejs.dev), you will need to opt-out the pre-bundling to get `vue-demi` work properly by\n> ```js\n> // vite.config.js\n> export default defineConfig({\n>   optimizeDeps: {\n>     exclude: ['vue-demi']\n>  }\n> })\n> ```\n\n### Extra APIs\n\n`Vue Demi` provides extra APIs to help distinguish users' environments and to do some version-specific logic.\n\n### `isVue2` `isVue3`\n\n```ts\nimport { isVue2, isVue3 } from 'vue-demi'\n\nif (isVue2) {\n  // Vue 2 only\n} else {\n  // Vue 3 only\n}\n```\n\n### `Vue2`\n\nTo avoid bringing in all the tree-shakable modules, we provide a `Vue2` export to support access to Vue 2's global API. (See [#41](https://github.com/vueuse/vue-demi/issues/41).)\n\n```ts\nimport { Vue2 } from 'vue-demi'\n\nif (Vue2) {\n  Vue2.config.ignoredElements.push('x-foo')\n}\n```\n\n### `install()`\n\nComposition API in Vue 2 is provided as a plugin and needs to be installed on the Vue instance before using. Normally, `vue-demi` will try to install it automatically. For some usages where you might need to ensure the plugin gets installed correctly, the `install()` API is exposed to as a safe version of `Vue.use(CompositionAPI)`. `install()` in the Vue 3 environment will be an empty function (no-op).\n\n```ts\nimport { install } from 'vue-demi'\n\ninstall()\n```\n\n## CLI\n\n### Manually Switch Versions\n\nTo explicitly switch the redirecting version, you can use these commands in your project's root.\n\n```bash\nnpx vue-demi-switch 2\n# or\nnpx vue-demi-switch 3\n```\n\n### Package Aliasing\n\nIf you would like to import `vue` under an alias, you can use the following command \n\n```bash\nnpx vue-demi-switch 2 vue2\n# or\nnpx vue-demi-switch 3 vue3\n```\n\nThen `vue-demi` will redirect APIs from the alias name you specified, for example:\n\n```ts\nimport * as Vue from 'vue3'\n\nvar isVue2 = false\nvar isVue3 = true\nvar Vue2 = undefined\n\nexport * from 'vue3'\nexport {\n  Vue,\n  Vue2,\n  isVue2,\n  isVue3,\n}\n```\n\n### Auto Fix\n\nIf the `postinstall` hook doesn't get triggered or you have updated the Vue version, try to run the following command to resolve the redirecting.\n\n```bash\nnpx vue-demi-fix\n```\n\n### Isomorphic Testings\n\nYou can support testing for both versions by adding npm alias in your dev dependencies. For example:\n\n```json\n{\n  \"scripts\": {\n    \"test:2\": \"vue-demi-switch 2 vue2 && jest\",\n    \"test:3\": \"vue-demi-switch 3 && jest\",\n  },\n  \"devDependencies\": {\n    \"vue\": \"^3.0.0\",\n    \"vue2\": \"npm:vue@2\"\n  },\n}\n```\n\nor\n\n```json\n{\n  \"scripts\": {\n    \"test:2\": \"vue-demi-switch 2 && jest\",\n    \"test:3\": \"vue-demi-switch 3 vue3 && jest\",\n  },\n  \"devDependencies\": {\n    \"vue\": \"^2.6.0\",\n    \"vue3\": \"npm:vue@3\"\n  },\n}\n```\n\n## Examples\n\nSee [examples](./examples).\n\n## Who is using this?\n\n- [VueUse](https://github.com/vueuse/vueuse) - Collection of Composition API utils\n- [@vue/apollo-composable](https://github.com/vuejs/vue-apollo/tree/v4/packages/vue-apollo-composable) - Apollo GraphQL functions for Vue Composition API\n- [vuelidate](https://github.com/vuelidate/vuelidate) - Simple, lightweight model-based validation\n- [vue-composition-test-utils](https://github.com/ariesjia/vue-composition-test-utils) - Simple vue composition api unit test utilities\n- [vue-use-stripe](https://github.com/frandiox/vue-use-stripe) - Stripe Elements wrapper for Vue.js\n- [@opd/g2plot-vue](https://github.com/open-data-plan/g2plot-vue) - G2plot for vue\n- [vue-echarts](https://github.com/ecomfe/vue-echarts) - Vue.js component for Apache ECharts.\n- [fluent-vue](https://github.com/Demivan/fluent-vue) - Vue.js integration for [Fluent.js](https://github.com/projectfluent/fluent.js) - JavaScript implementation of [Project Fluent](https://projectfluent.org)  \n- [vue-datatable-url-sync](https://github.com/socotecio/vue-datatable-url-sync) - Synchronize datatable options and filters with the url to keep user preference even after refresh or navigation\n- [vue-insta-stories](https://github.com/UnevenSoftware/vue-insta-stories) - Instagram stories in your vue projects.\n- [vue-tiny-validate](https://github.com/FrontLabsOfficial/vue-tiny-validate) - Tiny Vue Validate Composition\n- [v-perfect-signature](https://github.com/wobsoriano/v-perfect-signature) - Pressure-sensitive signature drawing for Vue 2 and 3\n- [vue-winbox](https://github.com/wobsoriano/vue-winbox) - A wrapper component for WinBox.js that adds the ability to mount Vue components.\n- [vue-word-highlighter](https://github.com/kawamataryo/vue-word-highlighter) - The word highlighter library for Vue 2 and Vue 3\n- [vue-chart-3](https://github.com/victorgarciaesgi/vue-chart-3) - Vue.js component for Chart.js\n- [json-editor-vue](https://github.com/cloydlau/json-editor-vue) - JSON editor & viewer for Vue 2 and 3.\n- [kidar-echarts](https://github.com/kidarjs/kidar-echarts) - A simpler echarts component for Vue 2 and 3.\n- [vue3-sketch-ruler](https://github.com/kakajun/vue3-sketch-ruler) - The zoom operation used for page presentation for Vue 2 and 3( Replace render function with template )\n- [vue-rough-notation](https://github.com/Leecason/vue-rough-notation) - RoughNotation wrapper component for Vue 2 and 3.\n- [vue-request](https://github.com/AttoJS/vue-request) - Vue composition API for data fetching, supports SWR, polling, error retry, cache request, pagination, etc.\n- [vue3-lazyload](https://github.com/murongg/vue3-lazyload) - A vue3.x image lazyload plugin.\n- [vue-codemirror6](https://github.com/logue/vue-codemirror6) - CodeMirror6 component for Vue2 and 3.\n- [@tanstack/vue-query](https://github.com/TanStack/query) - TanStack Query for Vue.\n> open a PR to add your library ;)\n\n## Underhood\n\nSee [the blog post](https://antfu.me/posts/make-libraries-working-with-vue-2-and-3/#-introducing-vue-demi).\n\n## License\n\nMIT License © 2020 [Anthony Fu](https://github.com/antfu)\n","publish_time":1598187325809,"maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"_cnpm_publish_time":1598187325809,"dist-tags":{"latest":"0.14.10","next":"0.11.0-beta.1","test":"0.6.0-alpha.1"}}