{"name":"vue-demi","version":"0.11.2","author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"license":"MIT","_id":"vue-demi@0.11.2","homepage":"https://github.com/antfu/vue-demi#readme","bugs":{"url":"https://github.com/antfu/vue-demi/issues"},"bin":{"vue-demi-fix":"bin/vue-demi-fix.js","vue-demi-switch":"bin/vue-demi-switch.js"},"dist":{"shasum":"faa06da53887c493a695b997f4fcb4784a667990","tarball":"http://registry-npm.ywwl.com/vue-demi/download/vue-demi-0.11.2.tgz","fileCount":18,"integrity":"sha512-J+X8Au6BhQdcej6LY4O986634hZLu55L0ewU2j8my7WIKlu8cK0dqmdUxqVHHMd/cMrKKZ9SywB/id6aLhwCtA==","signatures":[{"sig":"MEUCIQCKgkWWcU3TVryKxj2rzhB1ANE+KXiAk5b8G5lY13yFTAIgLgeqTmWs5SnE7TKtP5sD7I1FPnxLQEyBQLeqZnM/TxQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17076,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8GvlCRA9TVsSAnZWagAAmBEP/R4L90X8zxtzJLLPrnXu\nG1Hcx6831ZePO87tkMNvwycRsqempGeqpnVQULZCzhFmDbWLfeOMLjRleorW\n8YfXDBVuiEnnLe/lREOS2tng7XyKfuViSj3mGjPdJeuO2of/QpxmJ4j3AnAW\n0IsfGZRgwJfuKWsy8/x82yAngJrG6x15azouFHDlwVIJrSfg1ysdNqW0l1Pn\n1cDP0cTa8VQmpG263J5wiA3iKBWLDFRUxp/re4IyzMJ6tqrxpQXVQl7BdZ32\njxKbRnPuKpEoFDA/dyLy0dNxWqqGLjogx+ho8rOrZoGBBV0l8zcwPS0S0ux9\nyC3cKYVA48nll+ZRKBWquoPN9Kdd9T0rG2uunLk7e+jo9aGU2CEh+i4UVljL\nZ4W2EKkOYYandbQNQ0nG4AH8JT4cMuAw+Pa1Ig0pxmyOGhjbjtkbQk2oD6Ug\nVZtrM806uyYUYDFwG64wdoABL/sfwUkR11wkuknG8HSjkQ4i50RfzhgESihy\nU0D8RI/4heFNbdjsrVW+CoHj8UUtUdPkPHD84/IJhSyqB5SP70fF5b5r218d\nPUJ0L6kmh06/SACRPLpypPPa2xTiyI84oiZItIC/0MvcY2k+/0+ahTmPcl4r\n/i78LclMzDud/b4P0VSK3+in0+pWlkR0cWkurC3AgAVoYO0t8YhjqRMOASqc\nJfc0\r\n=GxHL\r\n-----END PGP SIGNATURE-----\r\n","size":5701,"noattachment":false,"key":"/vue-demi/-/vue-demi-0.11.2.tgz"},"main":"lib/index.cjs","types":"lib/index.d.ts","unpkg":"lib/index.iife.js","module":"lib/index.mjs","engines":{"node":">=12"},"exports":{".":{"node":"./lib/index.cjs","import":"./lib/index.mjs","browser":"./lib/index.mjs","require":"./lib/index.cjs"},"./*":"./*"},"funding":"https://github.com/sponsors/antfu","gitHead":"8815cc616f236e156d65433fd2caf8bfb0285a41","scripts":{"release":"npx bumpp --tag --commit --push && npm publish","postinstall":"node ./scripts/postinstall.js"},"_npmUser":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"jsdelivr":"lib/index.iife.js","repository":{"url":"git+https://github.com/antfu/vue-demi.git","type":"git"},"_npmVersion":"7.10.0","description":"<p align=\"center\"> <img src=\"https://github.com/vueuse/vue-demi/blob/master/assets/banner.png?raw=true\" width=\"600\"/> <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":"16.0.0","_hasShrinkwrap":false,"peerDependencies":{"vue":"^3.0.0 || ^2.6.0","@vue/composition-api":"^1.0.0-rc.1"},"peerDependenciesMeta":{"@vue/composition-api":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/vue-demi_0.11.2_1626368997049_0.44195505712219196","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":1626368997172,"maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"_cnpm_publish_time":1626368997172,"dist-tags":{"latest":"0.14.10","next":"0.11.0-beta.1","test":"0.6.0-alpha.1"}}