{"name":"vue-demi","version":"0.0.4","author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"license":"MIT","_id":"vue-demi@0.0.4","dist":{"shasum":"b304c8d915e20a577c61801b8960677d2b9ba38f","tarball":"http://registry-npm.ywwl.com/vue-demi/download/vue-demi-0.0.4.tgz","fileCount":17,"integrity":"sha512-zRGS5P0BOL2gxOnkj7EB3tcpYt7EX8wAHaeo1M1jmxm0kXs5XIgQ2Sq5HZOOLp4M/lBvV65BkQbsj45zwJgheQ==","signatures":[{"sig":"MEUCIAYK6uAN8c0AMzaitjqMCRsN9mvQRKkAvqTDhvOs6KzWAiEAzVs0Fm7Y1sWwkoGWJXs+7DuIPc61tGCMzxCPDfrYbF4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3091,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/CNMCRA9TVsSAnZWagAA7YoP+QELF6JdOxkqyJ8bdrvf\nquc91HHsWcgKcEHQL4aDYrPCojgUnzu8uA47MjG1fCJHB0XhxttS4oxpULWJ\nvV3pMPuWSONdtltIIXQ4UilTlXVZ2jKdldC2JBgYLLJrW1ghnh7TVnXPYn8Q\n0dGZDn7oJZeHMntB0NM078VUqK7CFJVBfy5fXdcuqYeRHFvlzDwwjoNm8S/w\n6ZzuvhNASy4DkDqw7uedPBPnMY1gunk+eCgi75ekpTsQaKCK645XHIVmFNMM\nVEQOlXOdfweduYBCdpCDZz4J4mh1BnLwQ8IL0srkJ1xLipMZT2PQuXFPpZL6\nZ5JlbIzRSoFEAfHk9/CabyNJ3qLr9mzkSIJR0jaNJMWek8IOPluU87Ur3EaM\ndx5zoAHo46QPnakivFcT08AfQoKOJeKttB60uq8J50NF7uUsgfyrn60cWEz1\nE6romLeWF+CmigO2UmpjbBIe0lCWUsi6bHHgtZzTVWty8oaxpbkvRbQ35wGs\na+SgWqPjAopCu3xeSVsvEDJ4R+23orqr/QSZKR9RipGnoiK3BvJ+6wU1Ngmi\nb8MfG9CjbiRbo3cqGD4eCaJOOPVeef0oG/5Hymlt0EyoCSBE+sgLyO8tSqyO\n8riw5WY02eLZWB/2pGZfmyH1jkvEcoLnleIptlFD5Py+3PwkWE7opb6Xkcm5\nReva\r\n=TSLW\r\n-----END PGP SIGNATURE-----\r\n","size":1876,"noattachment":false,"key":"/vue-demi/-/vue-demi-0.0.4.tgz"},"main":"lib/index.cjs.js","module":"lib/index.esm.js","typing":"lib/index.d.ts","scripts":{"postinstall":"node ./scripts/postinstall.js"},"_npmUser":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"repository":{"url":"https://github.com/antfu/vue-demi.git","type":"git"},"description":"> WIP","directories":{},"_hasShrinkwrap":false,"devDependencies":{"vue":"^2.6.11","@vue/composition-api":"^1.0.0-beta.1"},"_npmOperationalInternal":{"tmp":"tmp/vue-demi_0.0.4_1593582412165_0.014679643551655852","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":1593582412349,"maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"_cnpm_publish_time":1593582412349,"dist-tags":{"latest":"0.14.10","next":"0.11.0-beta.1","test":"0.6.0-alpha.1"}}