[
  {
    "path": ".github/CODE_OF_CONDUCT.md",
    "content": "# Contributor Code of Conduct\n\nAs contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.\n\nWe are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.\n\nExamples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.\n\nProject maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.\n\nThis Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# Contributing\n\nContributions are welcome and will be fully credited!\n\nWe accept contributions via Pull Requests on [Github](https://github.com/{{ githubAccount }}/{{ name }}).\n\n## Pull Requests\n\nHere are some guidelines to make the process smoother:\n\n- **Add a test** - New features and bugfixes need tests. If you find it difficult to test, please tell us in the pull request and we will try to help you!\n- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.\n- **Run `npm test` locally** - This will allow you to go faster\n- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.\n- **Send coherent history** - Make sure your commits message means something\n- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.\n\n## Creating issues\n\n### Bug reports\n\nAlways try to provide as much information as possible. If you are reporting a bug, try to provide a repro on jsfiddle.net (or anything else) or a stacktrace at the very least. This will help us check the problem quicker.\n\n### Feature requests\n\nLay out the reasoning behind it and propose an API for it. Ideally, you should have a practical example to prove the utility of the feature you're requesting.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "<!--\nIMPORTANT: Please provide as much information as possible:\n\n    - Reporting a bug: if possible provide a repro on jsfiddle.net or a stacktrace at the very least\n\n    - Feature request: lay out the reasoning behind it and propose an API for it\n\n-->\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "<!--\nPlease make sure to read the Pull Request Guidelines:\nhttps://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#Pull-Request\n-->\n\n<!-- PULL REQUEST TEMPLATE -->\n<!-- (Update \"[ ]\" to \"[x]\" to check a box) -->\n\n**What kind of change does this PR introduce?** (check at least one)\n\n- [ ] Bugfix\n- [ ] Feature\n- [ ] Code style update\n- [ ] Refactor\n- [ ] Build-related changes\n- [ ] Other, please describe:\n\n**Does this PR introduce a breaking change?** (check one)\n\n- [ ] Yes\n- [ ] No\n\nIf yes, please describe the impact and migration path for existing applications:\n\n**The PR fulfills these requirements:**\n\n- [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where \"xxx\" is the issue number)\n- [ ] All tests are passing\n- [ ] New/updated tests are included\n\nIf adding a **new feature**, the PR's description includes:\n\n- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)\n\n**Other information:**\n"
  },
  {
    "path": ".github/funding.yml",
    "content": "github: posva\ncustom: https://www.paypal.me/posva\n"
  },
  {
    "path": ".github/settings.yml",
    "content": "labels:\n  - name: bug\n    color: ee0701\n  - name: contribution welcome\n    color: 0e8a16\n  - name: discussion\n    color: 4935ad\n  - name: docs\n    color: 8be281\n  - name: enhancement\n    color: a2eeef\n  - name: good first issue\n    color: 7057ff\n  - name: help wanted\n    color: 008672\n  - name: question\n    color: d876e3\n  - name: wontfix\n    color: ffffff\n  - name: WIP\n    color: ffffff\n  - name: need repro\n    color: c9581c\n  - name: feature request\n    color: fbca04\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\ncoverage\nnpm-debug.log\nyarn-error.log\n.nyc_output\ncoverage.lcov\ndist\npackage-lock.json\n.DS_Store\n.rpt2_cache\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2019 Eduardo San Martin Morote\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# vue-reactive-refs [![Build Status](https://badgen.net/circleci/github/posva/vue-reactive-refs)](https://circleci.com/gh/posva/vue-reactive-refs) [![npm package](https://badgen.net/npm/v/vue-reactive-refs)](https://www.npmjs.com/package/vue-reactive-refs) [![coverage](https://badgen.net/codecov/c/github/posva/vue-reactive-refs)](https://codecov.io/github/posva/vue-reactive-refs) [![thanks](https://badgen.net/badge/thanks/♥/pink)](https://github.com/posva/thanks)\n\n> Make \\$refs reactive so they can be used in computed properties and watchers\n\n**Vue 2 only** as you don't need this in Vue 3\n\nExtremely Light < 0.2kb 🗜\n\n## Installation\n\n```sh\nnpm install vue-reactive-refs\n```\n\n## Usage\n\nThis library exposes two different plugins: `ReactiveRefs` and\n`DynamicReactiveRefs` and you should **only use one of them**\n\n### `ReactiveRefs`\n\nSupports all browsers but requires you to manually declare `refs` in component\noptions.\n\n```js\nimport { ReactiveRefs } from 'vue-reactive-refs'\nimport Vue from 'vue'\n\nVue.use(ReactiveRefs)\n```\n\nMyComponent.vue\n\n```vue\n<template>\n  <div>\n    <input ref=\"input\" />\n    <button v-for=\"button in actions\" ref=\"buttons\">{{ action }}</button>\n  </div>\n</template>\n\n<script>\nexport default {\n  // this is necessary\n  refs: ['input', 'buttons'],\n\n  computed: {\n    // NOTE: this is definitely not what you should use this lib for, but it's\n    // the easiest example\n    inputValue() {\n      return this.$refs.input && this.$refs.input.value\n    },\n    // Same for this example. It's ALWAYS better to mapping your data (the source of truth)\n    // and avoid at all cost mapping information to the DOM\n    buttonsText() {\n      return this.$refs.buttons && this.$refs.buttons.map(b => b.innerText)\n    },\n  },\n}\n</script>\n```\n\n### `DynamicReactiveRefs`\n\nSupports modern browsers (not IE) [that support\n`Proxy`](https://caniuse.com/#search=proxy) and works out of the box:\n\n```js\nimport { DynamicReactiveRefs } from 'vue-reactive-refs'\nimport Vue from 'vue'\n\nVue.use(DynamicReactiveRefs)\n```\n\nMyComponent.vue\n\n```vue\n<template>\n  <div>\n    <input ref=\"input\" />\n    <button v-for=\"button in actions\" ref=\"buttons\">{{ action }}</button>\n  </div>\n</template>\n\n<script>\nexport default {\n  computed: {\n    // NOTE: this is definitely not what you should use this lib for, but it's\n    // the easiest example\n    inputValue() {\n      return this.$refs.input && this.$refs.input.value\n    },\n    // Same for this example. It's ALWAYS better to mapping your data (the source of truth)\n    // and avoid at all cost mapping information to the DOM\n    buttonsText() {\n      return this.$refs.buttons && this.$refs.buttons.map(b => b.innerText)\n    },\n  },\n}\n</script>\n```\n\n## Related\n\n- Vue.js issue: https://github.com/vuejs/vue/issues/3842\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n"
  },
  {
    "path": "__tests__/tsconfig.json",
    "content": "{\n  \"extends\": \"../tsconfig.json\",\n  \"include\": [\"../src\", \".\"]\n}\n"
  },
  {
    "path": "__tests__/with-proxy-array.spec.ts",
    "content": "import { mount, createLocalVue } from '@vue/test-utils'\nimport { DynamicReactiveRefs } from '../src'\n\nconst localVue = createLocalVue()\nlocalVue.use(DynamicReactiveRefs)\n\ndescribe('Reactive Refs with Proxy', () => {\n  // for some reason this fails when run along other tests but works when run alone\n  it('it works with arrays', async () => {\n    const spy = jest.fn()\n    const wrapper = mount(\n      {\n        template: `\n    <div>\n      <p v-for=\"i in n\" ref=\"buttons\" :key=\"i\">Hey</p>\n    </div>\n    `,\n        data: () => ({ n: 5 }),\n        computed: {\n          buttonsRef() {\n            // @ts-ignore\n            return this.$refs.buttons\n          },\n        },\n\n        mounted() {\n          // @ts-ignore\n          this.$watch('$refs.buttons', spy)\n        },\n      },\n      { localVue }\n    )\n\n    expect(wrapper.vm.$refs.buttons).toHaveLength(5)\n    // @ts-ignore\n    expect(wrapper.vm.buttonsRef).toHaveLength(5)\n\n    expect(spy).toHaveBeenCalledTimes(0)\n\n    // @ts-ignore\n    wrapper.vm.n = 3\n\n    await wrapper.vm.$nextTick()\n\n    expect(wrapper.vm.$refs.buttons).toHaveLength(3)\n    // @ts-ignore\n    expect(wrapper.vm.buttonsRef).toHaveLength(3)\n\n    expect(spy).toHaveBeenCalledTimes(1)\n  })\n})\n"
  },
  {
    "path": "__tests__/with-proxy.spec.ts",
    "content": "import { mount, createLocalVue } from '@vue/test-utils'\nimport { DynamicReactiveRefs } from '../src'\n\nconst localVue = createLocalVue()\nlocalVue.use(DynamicReactiveRefs)\n\ndescribe('Reactive Refs with Proxy', () => {\n  it('is reactive for a simple ref', () => {\n    const spy = jest.fn()\n    const wrapper = mount(\n      {\n        template: `\n    <div>\n      <button ref=\"button\" :key=\"n\">Hey</button>\n    </div>\n    `,\n        data: () => ({ n: 0 }),\n        computed: {\n          buttonRef() {\n            // @ts-ignore\n            return this.$refs.button\n          },\n        },\n\n        mounted() {\n          // @ts-ignore\n          this.$watch('$refs.button', spy)\n        },\n      },\n      { localVue }\n    )\n\n    expect(wrapper.vm.$refs.button).toBeTruthy()\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(wrapper.vm.$refs.button)\n\n    expect(spy).toHaveBeenCalledTimes(0)\n\n    // @ts-ignore\n    wrapper.vm.n++\n\n    expect(wrapper.vm.$refs.button).toBeTruthy()\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(wrapper.vm.$refs.button)\n\n    expect(spy).toHaveBeenCalledTimes(1)\n  })\n\n  it('works when reading the ref before it is setted', () => {\n    const spy = jest.fn()\n    const wrapper = mount(\n      {\n        template: `\n    <div>\n      <button v-if=\"n > 0\" ref=\"button\" :key=\"n\">Hey</button>\n    </div>\n    `,\n        data: () => ({ n: 0 }),\n        computed: {\n          buttonRef() {\n            // @ts-ignore\n            return this.$refs.button\n          },\n        },\n\n        mounted() {\n          // @ts-ignore\n          this.$watch('$refs.button', spy)\n        },\n      },\n      { localVue }\n    )\n\n    expect(wrapper.vm.$refs.button).toEqual(undefined)\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(undefined)\n\n    expect(spy).toHaveBeenCalledTimes(0)\n\n    // @ts-ignore\n    wrapper.vm.n++\n\n    expect(wrapper.vm.$refs.button).toBeTruthy()\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(wrapper.vm.$refs.button)\n\n    expect(spy).toHaveBeenCalledTimes(1)\n  })\n})\n"
  },
  {
    "path": "__tests__/without-proxy-array.spec.ts",
    "content": "import { mount, createLocalVue } from '@vue/test-utils'\nimport { ReactiveRefs } from '../src'\n\nconst localVue = createLocalVue()\nlocalVue.use(ReactiveRefs)\n\ndescribe('Reactive Refs with Proxy', () => {\n  // for some reason this fails when run along other tests but works when run alone\n  it('it works with arrays', async () => {\n    const spy = jest.fn()\n    const wrapper = mount(\n      {\n        template: `\n    <div>\n      <p v-for=\"i in n\" ref=\"buttons\" :key=\"i\">Hey</p>\n    </div>\n    `,\n        data: () => ({ n: 5 }),\n        refs: ['buttons'],\n        computed: {\n          buttonsRef() {\n            // @ts-ignore\n            return this.$refs.buttons\n          },\n        },\n\n        mounted() {\n          // @ts-ignore\n          this.$watch('$refs.buttons', spy)\n        },\n      },\n      { localVue }\n    )\n\n    expect(wrapper.vm.$refs.buttons).toHaveLength(5)\n    // @ts-ignore\n    expect(wrapper.vm.buttonsRef).toHaveLength(5)\n\n    expect(spy).toHaveBeenCalledTimes(0)\n\n    // @ts-ignore\n    wrapper.vm.n = 3\n\n    await wrapper.vm.$nextTick()\n\n    expect(wrapper.vm.$refs.buttons).toHaveLength(3)\n    // @ts-ignore\n    expect(wrapper.vm.buttonsRef).toHaveLength(3)\n\n    expect(spy).toHaveBeenCalledTimes(1)\n  })\n})\n"
  },
  {
    "path": "__tests__/without-proxy.spec.ts",
    "content": "import { mount, createLocalVue } from '@vue/test-utils'\nimport { ReactiveRefs } from '../src'\n\nconst localVue = createLocalVue()\nlocalVue.use(ReactiveRefs)\n\ndescribe('Reactive Refs with Proxy', () => {\n  it('is reactive for a simple ref', () => {\n    const spy = jest.fn()\n    const wrapper = mount(\n      {\n        template: `\n    <div>\n      <button ref=\"button\" :key=\"n\">Hey</button>\n    </div>\n    `,\n        data: () => ({ n: 0 }),\n        refs: ['button'],\n        computed: {\n          buttonRef() {\n            // @ts-ignore\n            return this.$refs.button\n          },\n        },\n\n        mounted() {\n          // @ts-ignore\n          this.$watch('$refs.button', spy)\n        },\n      },\n      { localVue }\n    )\n\n    expect(wrapper.vm.$refs.button).toBeTruthy()\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(\n      wrapper.find({ ref: 'button' }).element\n    )\n\n    expect(spy).toHaveBeenCalledTimes(0)\n\n    // @ts-ignore\n    wrapper.vm.n++\n\n    expect(wrapper.vm.$refs.button).toBeTruthy()\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(wrapper.vm.$refs.button)\n\n    expect(spy).toHaveBeenCalledTimes(1)\n  })\n\n  it('works when reading the ref before it is setted', () => {\n    const spy = jest.fn()\n    const wrapper = mount(\n      {\n        template: `\n    <div>\n      <button v-if=\"n > 0\" ref=\"button\" :key=\"n\">Hey</button>\n    </div>\n    `,\n        data: () => ({ n: 0 }),\n        refs: ['button'],\n        computed: {\n          buttonRef() {\n            // @ts-ignore\n            return this.$refs.button\n          },\n        },\n\n        mounted() {\n          // @ts-ignore\n          this.$watch('$refs.button', spy)\n        },\n      },\n      { localVue }\n    )\n\n    expect(wrapper.vm.$refs.button).toEqual(undefined)\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(undefined)\n\n    expect(spy).toHaveBeenCalledTimes(0)\n\n    // @ts-ignore\n    wrapper.vm.n++\n\n    expect(wrapper.vm.$refs.button).toBeTruthy()\n    // @ts-ignore\n    expect(wrapper.vm.buttonRef).toEqual(wrapper.vm.$refs.button)\n\n    expect(spy).toHaveBeenCalledTimes(1)\n  })\n})\n"
  },
  {
    "path": "circle.yml",
    "content": "version: 2\n\njobs:\n  build:\n    docker:\n      - image: circleci/node:10\n\n    working_directory: ~/repo\n\n    steps:\n      - checkout\n\n      - restore_cache:\n          keys:\n            - dependencies-cache-{{ checksum \"yarn.lock\" }}\n            - dependencies-cache-\n\n      - run: yarn install\n\n      - save_cache:\n          paths:\n            - node_modules\n          key: dependencies-cache-{{ checksum \"yarn.lock\" }}\n\n      - run: yarn run test\n\n      - run:\n          name: Send code coverage\n          command: yarn run codecov\n"
  },
  {
    "path": "jest.config.js",
    "content": "module.exports = {\n  preset: 'ts-jest',\n  collectCoverage: true,\n  collectCoverageFrom: ['<rootDir>/src/**/*.ts'],\n  testMatch: ['<rootDir>/__tests__/**/*.spec.ts'],\n  globals: {\n    'ts-jest': {\n      diagnostics: {\n        warnOnly: true,\n      },\n    },\n  },\n  testURL: 'http://localhost/',\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"vue-reactive-refs\",\n  \"version\": \"0.0.2\",\n  \"description\": \"Make $refs reactive so they can be used in computed properties and watchers\",\n  \"main\": \"dist/index.js\",\n  \"module\": \"dist/index.esm.js\",\n  \"browser\": \"dist/index.browser.esm.js\",\n  \"unpkg\": \"dist/index.umd.js\",\n  \"jsdelivr\": \"dist/index.umd.js\",\n  \"types\": \"dist/index.d.ts\",\n  \"sideEffects\": false,\n  \"author\": {\n    \"name\": \"Eduardo San Martin Morote\",\n    \"email\": \"posva13@gmail.com\"\n  },\n  \"scripts\": {\n    \"build\": \"rollup -c rollup.config.js\",\n    \"unit\": \"jest\",\n    \"test\": \"npm run build && npm run unit\",\n    \"prepublishOnly\": \"yarn run build\"\n  },\n  \"files\": [\n    \"dist\",\n    \"README.md\"\n  ],\n  \"keywords\": [\n    \"refs\",\n    \"vue\",\n    \"$refs\",\n    \"computed\",\n    \"watch\",\n    \"reactive\"\n  ],\n  \"license\": \"MIT\",\n  \"devDependencies\": {\n    \"@types/jest\": \"^26.0.0\",\n    \"@vue/test-utils\": \"^1.0.0-beta.29\",\n    \"codecov\": \"^3.5.0\",\n    \"jest\": \"^25.1.0\",\n    \"rollup\": \"^2.1.0\",\n    \"rollup-plugin-alias\": \"^2.0.0\",\n    \"rollup-plugin-commonjs\": \"^10.0.1\",\n    \"rollup-plugin-node-resolve\": \"^5.2.0\",\n    \"rollup-plugin-replace\": \"^2.2.0\",\n    \"rollup-plugin-terser\": \"^7.0.0\",\n    \"rollup-plugin-typescript2\": \"^0.30.0\",\n    \"ts-jest\": \"^25.0.0\",\n    \"typescript\": \"^3.5.3\",\n    \"vue\": \"^2.6.10\",\n    \"vue-template-compiler\": \"^2.6.10\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/posva/vue-reactive-refs.git\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/posva/vue-reactive-refs/issues\"\n  },\n  \"homepage\": \"https://github.com/posva/vue-reactive-refs#readme\"\n}\n"
  },
  {
    "path": "rollup.config.js",
    "content": "import replace from 'rollup-plugin-replace'\nimport resolve from 'rollup-plugin-node-resolve'\nimport commonjs from 'rollup-plugin-commonjs'\nimport ts from 'rollup-plugin-typescript2'\nimport alias from 'rollup-plugin-alias'\nimport { terser } from 'rollup-plugin-terser'\nimport pkg from './package.json'\n\nconst banner = `/*!\n  * ${pkg.name} v${pkg.version}\n  * (c) ${new Date().getFullYear()} Eduardo San Martin Morote\n  * @license MIT\n  */`\n\nconst exportName = 'FocusTrapVue'\nconst defaultExternals = ['focus-trap']\n\nfunction createEntry(\n  {\n    format, // Rollup format (iife, umd, cjs, es)\n    external, // Rollup external option\n    input = 'src/index.ts', // entry point\n    env = 'development', // NODE_ENV variable\n    minify = false,\n    isBrowser = false, // produce a browser module version or not\n  } = {\n    input: 'src/index.ts',\n    env: 'development',\n    minify: false,\n    isBrowser: false,\n  }\n) {\n  // force production mode when minifying\n  if (minify) env = 'production'\n\n  external = external || defaultExternals\n\n  const config = {\n    input,\n    plugins: [\n      replace({\n        __VERSION__: pkg.version,\n        'process.env.NODE_ENV': `'${env}'`,\n      }),\n      alias({\n        resolve: ['ts'],\n      }),\n      resolve(),\n      commonjs(),\n    ],\n    output: {\n      banner,\n      file: 'dist/index.other.js',\n      format,\n    },\n    external,\n  }\n\n  if (format === 'iife') {\n    // config.input = 'src/entries/iife.ts'\n    config.output.file = pkg.unpkg\n    config.output.name = exportName\n  } else if (format === 'es') {\n    config.output.file = isBrowser ? pkg.browser : pkg.module\n  } else if (format === 'cjs') {\n    config.output.file = pkg.main\n  }\n\n  config.plugins.push(\n    ts({\n      // only check once, during the es version with browser (it includes external libs)\n      check: format === 'es' && isBrowser && !minify,\n      tsconfigOverride: {\n        compilerOptions: {\n          // same for d.ts files\n          declaration: format === 'es' && isBrowser && !minify,\n          module: 'esnext', // we need to override it because mocha requires this value to be commonjs\n          target: format === 'es' && !isBrowser ? 'esnext' : 'es5',\n        },\n      },\n    })\n  )\n\n  if (minify) {\n    config.plugins.push(\n      terser({\n        module: format === 'es',\n        output: {\n          preamble: banner,\n        },\n      })\n    )\n    config.output.file = config.output.file.replace(/\\.js$/i, '.min.js')\n  }\n\n  return config\n}\n\nexport default [\n  // browser-friendly UMD build\n  createEntry({ format: 'iife', external: [] }),\n  createEntry({ format: 'iife', minify: true, external: [] }),\n  createEntry({ format: 'cjs' }),\n  createEntry({ format: 'es' }),\n  createEntry({ format: 'es', isBrowser: true, external: [] }),\n  createEntry({ format: 'es', isBrowser: true, minify: true, external: [] }),\n]\n"
  },
  {
    "path": "src/index.ts",
    "content": "export { ReactiveRefs } from './no-proxy'\nexport { DynamicReactiveRefs } from './proxy'\n"
  },
  {
    "path": "src/no-proxy.ts",
    "content": "import Vue, { PluginFunction } from 'vue'\n\ndeclare module 'vue/types/options' {\n  interface ComponentOptions<V extends Vue> {\n    refs?: string[]\n  }\n}\n\nexport const ReactiveRefs: PluginFunction<never> = _Vue => {\n  _Vue.mixin({\n    beforeCreate() {\n      const { refs } = this.$options\n      if (!refs) return\n      // @ts-ignore\n      this.$refs = _Vue.observable(\n        refs.reduce(\n          ($refs, key) => {\n            $refs[key] = undefined\n            return $refs\n          },\n          {} as Record<string, Vue | Element | Vue[] | Element[] | undefined>\n        )\n      )\n    },\n  })\n}\n"
  },
  {
    "path": "src/proxy.ts",
    "content": "/**\n * Because this version uses a Proxy, it will fail on any browser that does not\n * support it\n */\n\nimport { PluginFunction } from 'vue'\n\nexport const DynamicReactiveRefs: PluginFunction<never> = _Vue => {\n  _Vue.mixin({\n    beforeCreate() {\n      const $refs = _Vue.observable({})\n      // @ts-ignore\n      this.$refs = new Proxy($refs, {\n        set(target, key, value) {\n          if (!(key in target)) _Vue.set($refs, key as string, value)\n          return Reflect.set(target, key, value)\n        },\n        get(target, key) {\n          if (!(key in target)) _Vue.set($refs, key as string, undefined)\n          return Reflect.get(target, key)\n        },\n      })\n    },\n  })\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"include\": [\"src\"],\n  \"compilerOptions\": {\n    \"target\": \"esnext\",\n    \"module\": \"esnext\",\n    \"declaration\": true,\n    \"outDir\": \"./dist\",\n    \"strict\": true,\n    \"noUnusedLocals\": true,\n    \"noUnusedParameters\": true,\n    \"removeComments\": false,\n    \"noImplicitReturns\": true,\n    \"moduleResolution\": \"node\",\n    \"esModuleInterop\": true,\n    \"experimentalDecorators\": true\n  }\n}\n"
  }
]