{"name":"vue-demi","version":"0.13.3","author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"license":"MIT","_id":"vue-demi@0.13.3","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":"6f761ecf72c6a6858407b22c0a8bfc24a26d2915","tarball":"http://registry-npm.ywwl.com/vue-demi/download/vue-demi-0.13.3.tgz","fileCount":21,"integrity":"sha512-t0WemjxNSrrQPP1N5Aido5oLdpHdTh9Z4QS+iIHMeG7318N5FF6y1zb48umb5Wh0Tq68fCM0vH2RrYioA7l1eg==","signatures":[{"sig":"MEUCIQC7zlKWsUgvfyl/q9t2cRVPXt4RfFLSEDYTYkLH7nHrWwIgUKxQW1WiKIPRrqxNlaNeVE/dJFFF7ngAaz6QQhpY2e8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24037,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizPnjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrOPw/+K4p8iJyff3vllFwKyU7iP/3oBnvAW9XQKREHOZ4VRthy+YLH\r\n8umKJo7xViuJ7lcWGVzgCH2JSFYvAnHPktWKJb6aL31SHPS5CsBeot5kfPHK\r\nyPFhBTsnDOj27nQRcrtOzPWdeT+gJsyP1pmlYOiuo+DAxEMIpL17ONyQy2ye\r\niIvxjSJ7v9W5/iqgeXgWcYPYi/wMksl4xAfoUkXemB5KZsBGTx02qjp94r3u\r\npXdCeCndYH3uJIg61ksGaNYiLqf0wuZHJ+PoNcSRwmkk/imcCfXcvIwk9/TI\r\nxVZzbLzlBuCGh3bhhGgr63U3zdVZk68uQ3lt+aITRU/8FJelQkOHP/ofyZMp\r\nud/1T2hsdNSO6CIt0hsHx0O82K68Sp4pTebdIVb0D5V9hqJYT8i/iET/llcA\r\nEF6tN87PTJakGTU4KKJ556Ebv/QnB0vDoIF5Oh9lfzmsHCJ3OnLpHgyqNxSY\r\nWdr+y9iYc0/5UxWlWLWGJffwnmMpR4G4/5Acms+FRLg7lTVTrBafgj6qgLx6\r\n4AsO2YWkhHTVlnKj6QgKAcoV1BasFMaV6PgJXwmCdQsTuiHtxg0j6iKNiGYu\r\nYoRaxbbwOzgdzUQywWdDUh6BGKUr+lc4yVafcLAAqyGYThxx7Mn+w5rNG2Y6\r\nNn/+bRC7KcuQMZbM1fz0YkcF6KBdwOwrlFM=\r\n=XmMl\r\n-----END PGP SIGNATURE-----\r\n","size":7325,"noattachment":false,"key":"/vue-demi/-/vue-demi-0.13.3.tgz"},"main":"lib/index.cjs","types":"lib/index.d.ts","unpkg":"lib/index.iife.js","module":"lib/index.mjs","engines":{"node":">=12"},"exports":{".":{"import":"./lib/index.mjs","browser":"./lib/index.mjs","require":"./lib/index.cjs"},"./*":"./*"},"funding":"https://github.com/sponsors/antfu","gitHead":"930e6d5053e7ed82f12258e2014cbd4e81bbb263","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":"8.8.0","description":"<p align=\"center\"> <img src=\"https://github.com/vueuse/vue-demi/blob/main/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.14.2","_hasShrinkwrap":false,"peerDependencies":{"vue":"^3.0.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.13.3_1657600482829_0.3215770351223286","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":1657600483004,"maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"_cnpm_publish_time":1657600483004,"dist-tags":{"latest":"0.14.10","next":"0.11.0-beta.1","test":"0.6.0-alpha.1"}}