From 93e3b9ff6bb92a990b34226d66a773038efe9dfd Mon Sep 17 00:00:00 2001 From: qiang Date: Tue, 27 Sep 2022 21:10:23 +0800 Subject: [PATCH] feat: add @vue/composition-api with exported createLifeCycle --- .../lib/configure-webpack.js | 3 +- .../packages/@vue/composition-api/LICENSE | 21 + .../packages/@vue/composition-api/README.md | 558 ++++ .../@vue/composition-api/README.zh-CN.md | 568 ++++ .../dist/vue-composition-api.common.js | 2297 ++++++++++++++++ .../dist/vue-composition-api.common.prod.js | 1 + .../dist/vue-composition-api.d.ts | 518 ++++ .../dist/vue-composition-api.esm.js | 2253 ++++++++++++++++ .../dist/vue-composition-api.js | 2303 +++++++++++++++++ .../dist/vue-composition-api.mjs | 2253 ++++++++++++++++ .../dist/vue-composition-api.prod.js | 1 + .../packages/@vue/composition-api/index.js | 7 + .../@vue/composition-api/package.json | 119 + 13 files changed, 10901 insertions(+), 1 deletion(-) create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/index.js create mode 100644 packages/vue-cli-plugin-uni/packages/@vue/composition-api/package.json diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js index 307619935..40c0eaf89 100644 --- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js @@ -383,7 +383,8 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt JSON.stringify({ type: 'stat' }), - vuex: require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vuex3') + vuex: require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vuex3'), + '@vue/composition-api': require.resolve('@dcloudio/vue-cli-plugin-uni/packages/@vue/composition-api') }, modules: [ process.env.UNI_INPUT_DIR, diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE new file mode 100644 index 000000000..1c4bdb5dc --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present, liximomo(X.L) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md new file mode 100644 index 000000000..79908ab5c --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md @@ -0,0 +1,558 @@ +# @vue/composition-api + +Vue 2 plugin for **Composition API** + +[![npm](https://img.shields.io/npm/v/@vue/composition-api)](https://www.npmjs.com/package/@vue/composition-api) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vuejs/composition-api/Build%20&%20Test)](https://github.com/vuejs/composition-api/actions?query=workflow%3A%22Build+%26+Test%22) +[![Minzipped size](https://badgen.net/bundlephobia/minzip/@vue/composition-api)](https://bundlephobia.com/result?p=@vue/composition-api) + +English | [中文](./README.zh-CN.md) ・ [**Composition API Docs**](https://v3.vuejs.org/guide/composition-api-introduction.html) + + +> ⚠️ With the release of [Vue 2.7](https://blog.vuejs.org/posts/vue-2-7-naruto.html), which has Composition API built-in, **you no longer need this plugin**. Thereby this plugin has entered maintenance mode and will only support Vue 2.6 or earlier. This project will reach End of Life by the end of 2022. + +## Installation + +### NPM + +```bash +npm install @vue/composition-api +# or +yarn add @vue/composition-api +``` + +You must install `@vue/composition-api` as a plugin via `Vue.use()` before you can use the [Composition API](https://composition-api.vuejs.org/) to compose your component. + +```js +import Vue from 'vue' +import VueCompositionAPI from '@vue/composition-api' + +Vue.use(VueCompositionAPI) +``` + +```js +// use the APIs +import { ref, reactive } from '@vue/composition-api' +``` + +> :bulb: When you migrate to Vue 3, just replacing `@vue/composition-api` to `vue` and your code should just work. + +### CDN + +Include `@vue/composition-api` after Vue and it will install itself automatically. + + +```html + + +``` + + +`@vue/composition-api` will be exposed to global variable `window.VueCompositionAPI`. + +```ts +const { ref, reactive } = VueCompositionAPI +``` + +## TypeScript Support + +> TypeScript version **>4.2** is required + +To let TypeScript properly infer types inside Vue component options, you need to define components with `defineComponent` + +```ts +import { defineComponent } from '@vue/composition-api' + +export default defineComponent({ + // type inference enabled +}) +``` + +### JSX/TSX + +JSX is now officially supported on [vuejs/jsx](https://github.com/vuejs/jsx). You can enable it by following [this document](https://github.com/vuejs/jsx/tree/dev/packages/babel-preset-jsx#usage). A community maintained version can be found at [babel-preset-vca-jsx](https://github.com/luwanquan/babel-preset-vca-jsx) by [@luwanquan](https://github.com/luwanquan). + +To support TSX, create a declaration file with the following content in your project. + +```ts +// file: shim-tsx.d.ts +import Vue, { VNode } from 'vue'; +import { ComponentRenderProxy } from '@vue/composition-api'; + +declare global { + namespace JSX { + interface Element extends VNode {} + interface ElementClass extends ComponentRenderProxy {} + interface ElementAttributesProperty { + $props: any; // specify the property name to use + } + interface IntrinsicElements { + [elem: string]: any; + } + } +} +``` + +## SSR + +Even if there is no definitive Vue 3 API for SSR yet, this plugin implements the `onServerPrefetch` lifecycle hook that allows you to use the `serverPrefetch` hook found in the classic API. + +```js +import { onServerPrefetch } from '@vue/composition-api' + +export default { + setup(props, { ssrContext }) { + const result = ref() + + onServerPrefetch(async () => { + result.value = await callApi(ssrContext.someId) + }) + + return { + result, + } + } +} +``` + +## Browser Compatibility + +`@vue/composition-api` supports all modern browsers and IE11+. For lower versions IE you should install `WeakMap` polyfill (for example from `core-js` package). + +## Limitations + +> :white_check_mark: Support     :x: Not Supported + +### `Ref` Unwrap + +
+ +❌ Should NOT use ref in a plain object when working with Array + + +```js +const a = { + count: ref(0), +} +const b = reactive({ + list: [a], // `a.count` will not unwrap!! +}) + +// no unwrap for `count`, `.value` is required +b.list[0].count.value === 0 // true +``` + +```js +const b = reactive({ + list: [ + { + count: ref(0), // no unwrap!! + }, + ], +}) + +// no unwrap for `count`, `.value` is required +b.list[0].count.value === 0 // true +``` + +
+ +
+ +✅ Should always use ref in a reactive when working with Array + + +```js +const a = reactive({ + list: [ + reactive({ + count: ref(0), + }), + ] +}) +// unwrapped +a.list[0].count === 0 // true + +a.list.push( + reactive({ + count: ref(1), + }) +) +// unwrapped +a.list[1].count === 1 // true +``` + +
+ +### Template Refs + +
+ +✅ String ref && return it from setup() + + +```html + + + +``` + +
+ +
+ +✅ String ref && return it from setup() && Render Function / JSX + + +```jsx +export default { + setup() { + const root = ref(null) + + onMounted(() => { + // the DOM element will be assigned to the ref after initial render + console.log(root.value) //
+ }) + + return { + root, + } + }, + render() { + // with JSX + return () =>
+ }, +} +``` + +
+ +
+ +❌ Function ref + + +```html + + + +``` + +
+ +
+ +❌ Render Function / JSX in setup() + + +```jsx +export default { + setup() { + const root = ref(null) + + return () => + h('div', { + ref: root, + }) + + // with JSX + return () =>
+ }, +} +``` + +
+ +
+ +⚠️ $refs accessing workaround + + +
+ +> :warning: **Warning**: The `SetupContext.refs` won't exist in `Vue 3.0`. `@vue/composition-api` provide it as a workaround here. + +If you really want to use template refs in this case, you can access `vm.$refs` via `SetupContext.refs` + +```jsx +export default { + setup(initProps, setupContext) { + const refs = setupContext.refs + onMounted(() => { + // the DOM element will be assigned to the ref after initial render + console.log(refs.root) //
+ }) + + return () => + h('div', { + ref: 'root', + }) + + // with JSX + return () =>
+ }, +} +``` + +
+ +### Reactive + +
+ +⚠️ reactive() mutates the original object + + +`reactive` uses `Vue.observable` underneath which will ***mutate*** the original object. + +> :bulb: In Vue 3, it will return an new proxy object. + +
+ +
+ +⚠️ set and del workaround for adding and deleting reactive properties + + +> ⚠️ Warning: `set` and `del` do NOT exist in Vue 3. We provide them as a workaround here, due to the limitation of [Vue 2.x reactivity system](https://vuejs.org/v2/guide/reactivity.html#For-Objects). +> +> In Vue 2, you will need to call `set` to track new keys on an `object`(similar to `Vue.set` but for `reactive objects` created by the Composition API). In Vue 3, you can just assign them like normal objects. +> +> Similarly, in Vue 2 you will need to call `del` to [ensure a key deletion triggers view updates](https://vuejs.org/v2/api/#Vue-delete) in reactive objects (similar to `Vue.delete` but for `reactive objects` created by the Composition API). In Vue 3 you can just delete them by calling `delete foo.bar`. + +```ts +import { reactive, set, del } from '@vue/composition-api' + +const a = reactive({ + foo: 1 +}) + +// add new reactive key +set(a, 'bar', 1) + +// remove a key and trigger reactivity +del(a, 'bar') +``` + +
+ +### Watch + +
+ +❌ onTrack and onTrigger are not available in WatchOptions + + +```js +watch(() => { + /* ... */ +}, { + immediate: true, + onTrack() {}, // not available + onTrigger() {}, // not available +}) +``` + +
+ +### `createApp` + +
+ +⚠️ createApp() is global + + +In Vue 3, `createApp()` is introduced to provide context(plugin, components, etc.) isolation between app instances. Due the the design of Vue 2, in this plugin, we provide `createApp()` as a forward compatible API which is just an alias of the global. + +```ts +const app1 = createApp(RootComponent1) +app1.component('Foo', Foo) // equivalent to Vue.component('Foo', Foo) +app1.use(VueRouter) // equivalent to Vue.use(VueRouter) + +const app2 = createApp(RootComponent2) +app2.component('Bar', Bar) // equivalent to Vue.use('Bar', Bar) +``` + +
+ +### `createElement` / `h` + +
+ +⚠️ createElement / h workaround + + +
+ +`createElement` / `h` in Vue 2 is only accessable in `render()` function. To use it outside of `render()`, you can explicitly bind a component instance to it. + +> :warning: **Warning**: This ability is provided as a workaround Vue 2, it's not part of the Vue 3 API. + +```jsx +import { h as _h } from '@vue/composition-api' + +export default { + setup() { + const vm = getCurrentInstance() + const h = _h.bind(vm) + + return () => + h('div', { + ref: 'root', + }) + }, +} +``` + +
+ + +### `shallowReadonly` + +
+ +⚠️ shallowReadonly() will create a new object and with the same root properties, new properties added will not be readonly or reactive. + + +> :bulb: In Vue 3, it will return an new proxy object. + +
+ +### `readonly` + +
+ +⚠️ readonly() provides only type-level readonly check. + + +`readonly()` is provided as API alignment with Vue 3 on type-level only. Use isReadonly() on it or it's properties can not be guaranteed. + +
+ +### `props` + +
+ +⚠️ toRefs(props.foo) will incorrectly warn when accessing nested levels of props.
+    ⚠️ isReactive(props.foo) will return false. +
+ +```ts +defineComponent({ + setup(props) { + const { bar } = toRefs(props.foo) // it will `warn` + + // use this instead + const { foo } = toRefs(props) + const a = foo.value.bar + } +}) +``` + +
+ +### `computed().effect` + +
+ +⚠️ computed() has a property effect set to true instead of a ReactiveEffect. + + +Due to the difference in implementation, there is no such concept as a `ReactiveEffect` in `@vue/composition-api`. Therefore, `effect` is merely `true` to enable differentiating computed from refs: + +```ts +function isComputed(o: ComputedRef | unknown): o is ComputedRef +function isComputed(o: any): o is ComputedRef { + return !!(isRef(o) && o.effect) +} +``` + +
+ +### Missing APIs + +The following APIs introduced in Vue 3 are not available in this plugin. + +- `onRenderTracked` +- `onRenderTriggered` +- `isProxy` + +### Reactive APIs in `data()` + +
+ +❌ Passing ref, reactive or other reactive apis to data() would not work. + + +```jsx +export default { + data() { + return { + // will result { a: { value: 1 } } in template + a: ref(1), + } + }, +} +``` + +
+ +### `emits` Options + +
+ +❌ emits option is provided in type-level only, in order to align with Vue 3's type interface. Does NOT have actual effects on the code. + + +```ts +defineComponent({ + emits: { + // has no effects + submit: (eventOption) => { + if (...) { + return true + } else { + console.warn('Invalid submit event payload!') + return false + } + } + } +}) +``` + +
+ +### Performance Impact + +Due the the limitation of Vue2's public API. `@vue/composition-api` inevitably introduces some performance overhead. Note that in most scenarios, this shouldn't be the source of performance issues. + +You can check the [benchmark results](https://antfu.github.io/vue-composition-api-benchmark-results/) for more details. diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md new file mode 100644 index 000000000..95fe59e51 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md @@ -0,0 +1,568 @@ +# @vue/composition-api + +用于提供 **组合式 API** 的 Vue 2 插件. + +[![npm](https://img.shields.io/npm/v/@vue/composition-api)](https://www.npmjs.com/package/@vue/composition-api) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vuejs/composition-api/Build%20&%20Test)](https://github.com/vuejs/composition-api/actions?query=workflow%3A%22Build+%26+Test%22) + +[English](./README.md) | 中文 ・ [**组合式 API 文档**](https://v3.cn.vuejs.org/guide/composition-api-introduction.html) + + +> ⚠️ 随着 [Vue 2.7](https://blog.vuejs.org/posts/vue-2-7-naruto.html)的发布,它内置了Composition API,**你不再需要这个插件了**。因此,这个插件已经进入维护模式,将只支持Vue 2.6 或更早的版本。本项目将在 2022 年底达到生命终点(EOL)。 + +## 安装 + +### NPM + +```bash +npm install @vue/composition-api +# or +yarn add @vue/composition-api +``` + +在使用 `@vue/composition-api` 前,必须先通过 `Vue.use()` 进行安装。之后才可使用新的 [**组合式 API**](https://composition-api.vuejs.org/zh) 进行组件开发。 + +```js +import Vue from 'vue' +import VueCompositionAPI from '@vue/composition-api' + +Vue.use(VueCompositionAPI) +``` + +```js +// 使用 API +import { ref, reactive } from '@vue/composition-api' +``` + +> :bulb: 当迁移到 Vue 3 时,只需简单的将 `@vue/composition-api` 替换成 `vue` 即可。你现有的代码几乎无需进行额外的改动。 + +### CDN + +在 Vue 之后引入 `@vue/composition-api` ,插件将会自动完成安装。 + + +```html + + +``` + + +`@vue/composition-api` 将会暴露在全局变量 `window.VueCompositionAPI` 中。 + +```ts +const { ref, reactive } = VueCompositionAPI +``` + +## TypeScript 支持 + +> 本插件要求使用 TypeScript **4.2** 或以上版本 + +为了让 TypeScript 在 Vue 组件选项中正确地进行类型推导,我们必须使用 `defineComponent` 来定义组件: + +```ts +import { defineComponent } from '@vue/composition-api' + +export default defineComponent({ + // 类型推断启用 +}) +``` + +### JSX/TSX + +JSX 现已在 [vuejs/jsx](https://github.com/vuejs/jsx) 中官方支持。你可以根据[这篇文档](https://github.com/vuejs/jsx/tree/dev/packages/babel-preset-jsx#usage)开启支持。你也可以使用由 [@luwanquan](https://github.com/luwanquan) 维护的社区版本 [babel-preset-vca-jsx](https://github.com/luwanquan/babel-preset-vca-jsx)。 + +对于 TSX 支持,请在你的项目中创建如下声明文件: + +```ts +// file: shim-tsx.d.ts +import Vue, { VNode } from 'vue'; +import { ComponentRenderProxy } from '@vue/composition-api'; + +declare global { + namespace JSX { + interface Element extends VNode {} + interface ElementClass extends ComponentRenderProxy {} + interface ElementAttributesProperty { + $props: any; // specify the property name to use + } + interface IntrinsicElements { + [elem: string]: any; + } + } +} +``` + +## SSR + +尽管 Vue 3 暂时没有给出确定的 SSR 的 API,这个插件实现了 `onServerPrefetch` 生命周期钩子函数。这个钩子允许你使用传统 API 中的 `serverPrefetch` 函数。 + +```js +import { onServerPrefetch } from '@vue/composition-api' + +export default { + setup(props, { ssrContext }) { + const result = ref() + + onServerPrefetch(async () => { + result.value = await callApi(ssrContext.someId) + }) + + return { + result, + } + }, +} +``` + +## 浏览器兼容性 + +`@vue/composition-api` 支持所有现代浏览器以及IE11+。对于更低版本的IE浏览器你需要安装`WeakMap` polyfill (例如使用 `core-js`库)。 + +## 限制 + +> :white_check_mark: 支持     :x: 不支持 + +### `Ref` 自动展开 (unwrap) + +
+ +❌ 不要 在数组中使用含有 ref 的普通对象 + + +```js +const a = { + count: ref(0), +} +const b = reactive({ + list: [a], // `a.count` 不会自动展开!! +}) + +// `count` 不会自动展开, 须使用 `.value` +b.list[0].count.value === 0 // true +``` + +```js +const b = reactive({ + list: [ + { + count: ref(0), // 不会自动展开!! + }, + ], +}) + +// `count` 不会自动展开, 须使用 `.value` +b.list[0].count.value === 0 // true +``` + +
+ +
+ +✅ 在数组中,应该 总是将 ref 存放到 reactive 对象中 + + +```js +const a = reactive({ + count: ref(0), +}) +const b = reactive({ + list: [a], +}) +// 自动展开 +b.list[0].count === 0 // true + +b.list.push( + reactive({ + count: ref(1), + }) +) +// 自动展开 +b.list[1].count === 1 // true +``` + +
+ +### 模板 Refs + +
+ +✅ 字符串 ref && 从 setup() 返回 ref + + +```html + + + +``` + +
+ +
+ +✅ 字符串 ref && 从 setup() 返回 ref && 渲染函数 / JSX + + +```jsx +export default { + setup() { + const root = ref(null) + + onMounted(() => { + // 在初次渲染后 DOM 元素会被赋值给 ref + console.log(root.value) //
+ }) + + return { + root, + } + }, + render() { + // 使用 JSX + return () =>
+ }, +} +``` + +
+ +
+ +❌ 函数 ref + + +```html + + + +``` + +
+ +
+ +❌ 在 setup() 中的渲染函数 / JSX + + +```jsx +export default { + setup() { + const root = ref(null) + + return () => + h('div', { + ref: root, + }) + + // 使用 JSX + return () =>
+ }, +} +``` + +
+ +
+ +⚠️ $refs 访问的变通方案 + + +> :warning: **警告**: `SetupContext.refs` 并非 `Vue 3.0` 的一部分, `@vue/composition-api` 将其暴露在 `SetupContext` 中只是临时提供一种变通方案。 + +如果你依然选择在 `setup()` 中写 `render` 函数,那么你可以使用 `SetupContext.refs` 来访问模板引用,它等价于 Vue 2.x 中的 `this.$refs`: + +```js +export default { + setup(initProps, setupContext) { + const refs = setupContext.refs + onMounted(() => { + // 在初次渲染后 DOM 元素会被赋值给 ref + console.log(refs.root) //
+ }) + + return () => + h('div', { + ref: 'root', + }) + + // 使用 JSX + return () =>
+ }, +} +``` + +如果项目使用了 TypeScript,你还需要扩展 `SetupContext` 类型: + +```ts +import Vue from 'vue' + +declare module '@vue/composition-api' { + interface SetupContext { + readonly refs: { [key: string]: Vue | Element | Vue[] | Element[] } + } +} +``` + +
+ +### Reactive + +
+ +⚠️ reactive() 会返回一个修改过的原始的对象 + + +此行为与 Vue 2 中的 `Vue.observable` 一致 + +> :bulb: 在 Vue 3 中,`reactive()` 会返回一个新的的代理对象 + +
+ +
+ +⚠️ setdel 添加与刪除响应式属性变通方案 + + +> ⚠️ 警告: `set` 和 `del` 并非 Vue 3 的一部分。由于 [Vue 2.x 响应式系统的限制](https://vuejs.org/v2/guide/reactivity.html#For-Objects), 我们在这里提供它们作为一种变通方案。 +> 在 Vue 2中,你将需要调用`set` 去追踪`object`上新的属性 (与`Vue.set`类似,但用于由 Composition API 创建的`reactive objects`)。在 Vue 3 中,你只需要像对待普通对象一样直接为属性赋值即可。 +> +> 同样地, 在 Vue 2 中你将需要调用`del`去 [确保响应式对象中属性的删除将触发视图更新](https://vuejs.org/v2/api/#Vue-delete) (与`Vue.delete`类似,但用于由 Composition API 创建的`reactive objects`)。在Vue3中,你只需要通过调用 `delete foo.bar` 来删除它们。 + +```ts +import { reactive, set, del } from '@vue/composition-api' + +const a = reactive({ + foo: 1 +}) + +// 添加新的响应式属性 +set(a, 'bar', 1) + +// 刪除属性并触发响应式更新 +del(a, 'bar') +``` + +
+ +### Watch + +
+ +❌ 不支持 onTrackonTrigger 选项 + + +```js +watch( + () => { + /* ... */ + }, + { + immediate: true, + onTrack() {}, // 不可用 + onTrigger() {}, // 不可用 + } +) +``` + +
+ +### `createApp` + +
+ +⚠️ createApp() 是全局的 + + +在 Vue3 中,引入了 `createApp()` 来隔离不同应用实例的上下文(plugin, components 等)。 由于 Vue2 的设计,在这个插件中,我们提供 `createApp()` 作为一个向前兼容的 API ,它只是全局的一个别名。 + +```ts +const app1 = createApp(RootComponent1) +app1.component('Foo', Foo) // 相当于 Vue.component('Foo', Foo) +app1.use(VueRouter) // 相当于 Vue.use(VueRouter) + +const app2 = createApp(RootComponent2) +app2.component('Bar', Bar) // 相当于 Vue.use('Bar', Bar) +``` + +
+ +### `createElement` / `h` + +
+ +⚠️ createElement / h 变通方案 + + +
+ +在 Vue2中 `createElement` / `h` 只能通过 `render()` 函数访问。要在 `render()`之外使用它, 你可以显式地给它绑定一个组件实例。 + +> :warning: **警告**: 此功能是作为 Vue 2 的变通方法提供的,它不是 Vue 3 API 的一部分。 + +```jsx +import { h as _h } from '@vue/composition-api' + +export default { + setup() { + const vm = getCurrentInstance() + const h = _h.bind(vm) + + return () => + h('div', { + ref: 'root', + }) + }, +} +``` + +
+ + +### `shallowReadonly` + +
+ +⚠️ shallowReadonly() 会返回一个新的浅拷贝对象,在此之后新加的字段将不会获得只读或响应式状态。 + + +> :bulb: 在 Vue 3 中,`shallowReadonly()` 会返回一个新的的代理对象 + +
+ +### `readonly` + +
+ +⚠️ readonly() 只提供类型层面的只读。 + + +`readonly()` 只在类型层面提供和 Vue 3 的对齐。在其返回值或其属性上使用 isReadonly() 检查的结果将无法保证。 + +
+ +### `props` + +
+ +⚠️ 当使用 toRefs 访问深层属性对象 (如 toRefs(props.foo) 时将会得到不正确的警告。
+     ⚠️ isReactive(props.foo) 将会返回 false。 +
+ +```ts +defineComponent({ + setup(props) { + const { bar } = toRefs(props.foo) // it will `warn` + + // use this instead + const { foo } = toRefs(props) + const a = foo.value.bar + } +}) +``` + +
+ +### `computed().effect` + +
+ +⚠️ computed() 拥有一个被设置为 trueeffect 属性,用来代替 ReactiveEffect。 + + +由于实现上的不同, 在 `@vue/composition-api` 中没有 `ReactiveEffect` 这种概念。 因此, `effect` 为 `true` 只是为了能够区分 computed 和 refs: + +```ts +function isComputed(o: ComputedRef | unknown): o is ComputedRef +function isComputed(o: any): o is ComputedRef { + return !!(isRef(o) && o.effect) +} +``` + +
+ +### 缺失的 API + +以下在 Vue 3 新引入的 API ,在本插件中暂不适用: + +- `onRenderTracked` +- `onRenderTriggered` +- `isProxy` + +### 在 `data()` 中使用组合式 API + +
+ +❌ 在 data() 中使用 ref, reactive 或其他组合式 API 将不会生效 + + +```jsx +export default { + data() { + return { + // 在模版中会成为 { a: { value: 1 } } + a: ref(1), + } + }, +} +``` + +
+ +### `emit` 选项 + +
+ +❌ emit 仅因在类型定义中对齐 Vue3 的选项而提供,不会有任何效果。 + + +```ts +defineComponent({ + emit: { + // 无效 + submit: (eventOption) => { + if (...) { + return true + } else { + console.warn('Invalid submit event payload!') + return false + } + } + } +}) +``` + +
+ +### 性能影响 + +由于 Vue 2 的公共 API 的限制,`@vue/composition-api` 不可避免地引入了额外的性能开销。除非在极端情况下,否则这并不会对你造成影响。 + +你可以查看这个 [跑分结果](https://antfu.github.io/vue-composition-api-benchmark-results/) 了解更多信息。 diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js new file mode 100644 index 000000000..f3347a95d --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js @@ -0,0 +1,2297 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); +} + +var activeEffectScope; +var effectScopeStack = []; +var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; +}()); +var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; +}(EffectScopeImpl)); +function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); +} +function effectScope(detached) { + return new EffectScope(detached); +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } +} +/** + * @internal + **/ +function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); +} +/** + * @internal + **/ +function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; +} + +var vueDependency = undefined; +try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } +} +catch (_a) { + // not available +} +var vueConstructor = null; +var currentInstance = null; +var currentInstanceTracking = true; +var PluginInstalledFlag = '__composition_api_installed__'; +function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; +} +function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); +} +function getVueConstructor() { + { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; +} +// returns registered vue or `vue` dependency +function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + { + assert(constructor, "No vue dependency found."); + } + return constructor; +} +function setVueConstructor(Vue) { + // @ts-ignore + if (vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); +} +/** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ +function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } +} +function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); +} +function getCurrentInstance() { + return currentInstance; +} +var instanceMapCache = new WeakMap(); +function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; +} + +var toString = function (x) { return Object.prototype.toString.call(x); }; +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +var noopFn = function (_) { return _; }; +function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); +} +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); +} +function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); +} +function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } +} +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isArray(x) { + return Array.isArray(x); +} +var objectToString = Object.prototype.toString; +var toTypeString = function (value) { + return objectToString.call(value); +}; +var isMap = function (val) { + return toTypeString(val) === '[object Map]'; +}; +var isSet = function (val) { + return toTypeString(val) === '[object Set]'; +}; +var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 +function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); +} +function isObject(val) { + return val !== null && typeof val === 'object'; +} +function isPlainObject(x) { + return toString(x) === '[object Object]'; +} +function isFunction(x) { + return typeof x === 'function'; +} +function isUndef(v) { + return v === undefined || v === null; +} +function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); +} +function logError(err, vm, info) { + { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } +} +/** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ +function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } +} + +function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if (!target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; +} +function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; +} +function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; +} +function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); +} +function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; +} +var vueInternalClasses; +var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; +}; + +function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; +} +var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); +var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); +// must be a string, symbol key is ignored in reactive +var RefKey = 'composition-api.refKey'; + +var accessModifiedSet = new WeakMap(); +var rawSet = new WeakMap(); +var readonlySet = new WeakMap(); + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; +} + +var _isForceTrigger = false; +function isForceTrigger() { + return _isForceTrigger; +} +function setForceTrigger(v) { + _isForceTrigger = v; +} + +var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; +}()); +function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; +} +function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function isRef(value) { + return value instanceof RefImpl; +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function toRefs(obj) { + if (!isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; +} +function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); +} +function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); +} +function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); +} +function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; +} + +var SKIPFLAG = '__v_skip'; +function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +/** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ +function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } +} +/** + * Auto unwrapping when access property + */ +function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); +} +function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; +} +/** + * Mock __ob__ for object recursively + */ +function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; +} +function createObserver() { + return observe({}).__ob__; +} +function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; +} +/** + * Make obj reactivity + */ +function reactive(obj) { + if (!isObject(obj)) { + { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; +} +/** + * Make sure obj can't be a reactive + */ +function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; +} +function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; +} + +function isReadonly(obj) { + return readonlySet.has(obj); +} +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +function readonly(target) { + if (!isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; +} +function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; +} + +/** + * Delete a property and trigger change if necessary. + */ +function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); +} + +var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; +function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; +} +function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; +} +function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; +} +var onBeforeMount = createLifeCycle('beforeMount'); +var onMounted = createLifeCycle('mounted'); +var onBeforeUpdate = createLifeCycle('beforeUpdate'); +var onUpdated = createLifeCycle('updated'); +var onBeforeUnmount = createLifeCycle('beforeDestroy'); +var onUnmounted = createLifeCycle('destroyed'); +var onErrorCaptured = createLifeCycle('errorCaptured'); +var onActivated = createLifeCycle('activated'); +var onDeactivated = createLifeCycle('deactivated'); +var onServerPrefetch = createLifeCycle('serverPrefetch'); + +var fallbackVM; +function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); +} +function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); +} +function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; +} +function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); +} +function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); +} +function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); +} +function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; +} +function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; +} +function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } +} +function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; +} +// We have to monkeypatch the teardown function so Vue will run +// runCleanup() when it tears down the watcher on unmounted. +function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; +} +function createWatcher(vm, source, cb, options) { + var _a; + if (!cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; +} +function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); +} +function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); +} +function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); +} +// implementation +function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); +} +function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; +} + +// implement +function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); +} + +var NOT_FOUND = {}; +function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; +} +function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; +} +function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } +} + +var EMPTY_OBJ = Object.freeze({}) + ; +var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; +}; +/** + * @deprecated use `useCssModule` instead. + */ +var useCSSModule = useCssModule; + +function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; +} + +var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); +}; + +var fallbackCreateElement; +var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); +}; + +function useSlots() { + return getContext().slots; +} +function useAttrs() { + return getContext().attrs; +} +function getContext() { + var i = getCurrentInstance(); + if (!i) { + warn("useContext() called without active instance."); + } + return i.setupContext; +} + +function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; +} +function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; +} +var vmStateManager = { + set: set, + get: get, +}; + +function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } +} +function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); +} +function afterRender(vm) { + var stack = [vm._vnode]; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) + updateTemplateRef(vnode.context); + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } +} +function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); +} +function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } +} + +function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + return ctx; + } +} + +/** + * Helper that recursively merges two data objects together. + */ +function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; +} +function install(Vue) { + if (isVueRegistered(Vue)) { + { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); +} +var Plugin = { + install: function (Vue) { return install(Vue); }, +}; + +// implementation, close to no-op +function defineComponent(options) { + return options; +} + +function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if (suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if (!comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if (comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; +} + +var version = "1.7.0"; +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); +} + +exports.EffectScope = EffectScope; +exports.computed = computed; +exports.createApp = createApp; +exports.createLifeCycle = createLifeCycle; +exports.createRef = createRef; +exports.customRef = customRef; +exports["default"] = Plugin; +exports.defineAsyncComponent = defineAsyncComponent; +exports.defineComponent = defineComponent; +exports.del = del; +exports.effectScope = effectScope; +exports.getCurrentInstance = getCurrentInstance; +exports.getCurrentScope = getCurrentScope; +exports.h = createElement; +exports.inject = inject; +exports.isRaw = isRaw; +exports.isReactive = isReactive; +exports.isReadonly = isReadonly; +exports.isRef = isRef; +exports.markRaw = markRaw; +exports.nextTick = nextTick; +exports.onActivated = onActivated; +exports.onBeforeMount = onBeforeMount; +exports.onBeforeUnmount = onBeforeUnmount; +exports.onBeforeUpdate = onBeforeUpdate; +exports.onDeactivated = onDeactivated; +exports.onErrorCaptured = onErrorCaptured; +exports.onMounted = onMounted; +exports.onScopeDispose = onScopeDispose; +exports.onServerPrefetch = onServerPrefetch; +exports.onUnmounted = onUnmounted; +exports.onUpdated = onUpdated; +exports.provide = provide; +exports.proxyRefs = proxyRefs; +exports.reactive = reactive; +exports.readonly = readonly; +exports.ref = ref; +exports.set = set$1; +exports.shallowReactive = shallowReactive; +exports.shallowReadonly = shallowReadonly; +exports.shallowRef = shallowRef; +exports.toRaw = toRaw; +exports.toRef = toRef; +exports.toRefs = toRefs; +exports.triggerRef = triggerRef; +exports.unref = unref; +exports.useAttrs = useAttrs; +exports.useCSSModule = useCSSModule; +exports.useCssModule = useCssModule; +exports.useSlots = useSlots; +exports.version = version; +exports.warn = warn$1; +exports.watch = watch; +exports.watchEffect = watchEffect; +exports.watchPostEffect = watchPostEffect; +exports.watchSyncEffect = watchSyncEffect; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js new file mode 100644 index 000000000..731978101 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};var n,e=function(){return e=Object.assign||function(t){for(var n,e=1,r=arguments.length;e=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function i(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o=0&&Math.floor(n)===n&&isFinite(t)&&n<=4294967295}function U(t){return null!==t&&"object"==typeof t}function A(t){return"[object Object]"===function(t){return Object.prototype.toString.call(t)}(t)}function B(t){return"function"==typeof t}function W(t,n){return n=n||x()}function T(t,n){void 0===n&&(n={});var e=t.config.silent;t.config.silent=!0;var r=new t(n);return t.config.silent=e,r}function V(t,n){return function(){for(var e=[],r=0;r1?e&&B(n)?n():n:void 0}},exports.isRaw=rt,exports.isReactive=ot,exports.isReadonly=function(t){return L.has(t)},exports.isRef=Z,exports.markRaw=function(t){if(!A(t)&&!R(t)||!Object.isExtensible(t))return t;var n=ct();return n.__v_skip=!0,k(t,"__ob__",n),q.set(t,!0),t},exports.nextTick=function(){for(var t,n=[],e=0;e = ComponentObjectPropsOptions

| string[]; +declare type ComponentObjectPropsOptions

= { + [K in keyof P]: Prop | null; +}; +declare type Prop = PropOptions | PropType; +declare type DefaultFactory = () => T | null | undefined; +interface PropOptions { + type?: PropType | true | null; + required?: boolean; + default?: D | DefaultFactory | null | undefined | object; + validator?(value: unknown): boolean; +} +declare type PropType = PropConstructor | PropConstructor[]; +declare type PropConstructor = { + new (...args: any[]): T & object; +} | { + (): T; +} | { + new (...args: string[]): Function; +}; +declare type RequiredKeys = { + [K in keyof T]: T[K] extends { + required: true; + } | { + default: any; + } | BooleanConstructor | { + type: BooleanConstructor; + } ? K : never; +}[keyof T]; +declare type OptionalKeys = Exclude>; +declare type ExtractFunctionPropType = any[], TResult = any> = T extends (...args: TArgs) => TResult ? T : never; +declare type ExtractCorrectPropType = T extends Function ? ExtractFunctionPropType : Exclude; +declare type InferPropType = T extends null ? any : T extends { + type: null | true; +} ? any : T extends ObjectConstructor | { + type: ObjectConstructor; +} ? Record : T extends BooleanConstructor | { + type: BooleanConstructor; +} ? boolean : T extends DateConstructor | { + type: DateConstructor; +} ? Date : T extends FunctionConstructor ? Function : T extends Prop ? unknown extends V ? D extends null | undefined ? V : D : ExtractCorrectPropType : T; +declare type ExtractPropTypes = { + [K in keyof Pick>]: InferPropType; +} & { + [K in keyof Pick>]?: InferPropType; +}; +declare type DefaultKeys = { + [K in keyof T]: T[K] extends { + default: any; + } | BooleanConstructor | { + type: BooleanConstructor; + } ? T[K] extends { + type: BooleanConstructor; + required: true; + } ? never : K : never; +}[keyof T]; +declare type ExtractDefaultPropTypes = O extends object ? { + [K in keyof Pick>]: InferPropType; +} : {}; + +declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; + +declare type Slot = (...args: any[]) => VNode[]; +declare type InternalSlots = { + [name: string]: Slot | undefined; +}; +declare type ObjectEmitsOptions = Record any) | null>; +declare type EmitsOptions = ObjectEmitsOptions | string[]; +declare type EmitFn = Options extends Array ? (event: V, ...args: any[]) => ReturnType : {} extends Options ? (event: string, ...args: any[]) => ReturnType : UnionToIntersection<{ + [key in Event]: Options[key] extends (...args: infer Args) => any ? (event: key, ...args: Args) => ReturnType : (event: key, ...args: any[]) => ReturnType; +}[Event]>; +declare type ComponentRenderEmitFn = EmitFn; +declare type Slots = Readonly; +interface SetupContext { + attrs: Data; + slots: Slots; + emit: EmitFn; + /** + * @deprecated not available in Vue 2 + */ + expose: (exposed?: Record) => void; + /** + * @deprecated not available in Vue 3 + */ + readonly parent: ComponentInstance | null; + /** + * @deprecated not available in Vue 3 + */ + readonly root: ComponentInstance; + /** + * @deprecated not available in Vue 3 + */ + readonly listeners: { + [key in string]?: Function; + }; + /** + * @deprecated not available in Vue 3 + */ + readonly refs: { + [key: string]: Vue | Element | Vue[] | Element[]; + }; +} +/** + * We expose a subset of properties on the internal instance as they are + * useful for advanced external libraries and tools. + */ +declare interface ComponentInternalInstance { + uid: number; + type: Record; + parent: ComponentInternalInstance | null; + root: ComponentInternalInstance; + /** + * Vnode representing this component in its parent's vdom tree + */ + vnode: VNode; + /** + * Root vnode of this component's own vdom tree + */ + /** + * The reactive effect for rendering and patching the component. Callable. + */ + update: Function; + data: Data; + props: Data; + attrs: Data; + refs: Data; + emit: EmitFn; + slots: InternalSlots; + emitted: Record | null; + proxy: ComponentInstance; + isMounted: boolean; + isUnmounted: boolean; + isDeactivated: boolean; +} +declare function getCurrentInstance(): ComponentInternalInstance | null; + +declare type EmitsToProps = T extends string[] ? { + [K in string & `on${Capitalize}`]?: (...args: any[]) => any; +} : T extends ObjectEmitsOptions ? { + [K in string & `on${Capitalize}`]?: K extends `on${infer C}` ? T[Uncapitalize] extends null ? (...args: any[]) => any : (...args: T[Uncapitalize] extends (...args: infer P) => any ? P : never) => any : never; +} : {}; +declare type ComponentInstance = InstanceType; +declare type ComponentRenderProxy

= { + $data: D; + $props: Readonly & Omit

: P & PublicProps>; + $attrs: Record; + $emit: ComponentRenderEmitFn>; +} & Readonly

& ShallowUnwrapRef & D & M & ExtractComputedReturns & Omit; +declare type VueConstructorProxy & ({} extends Emits ? {} : EmitsToProps)> = Omit & { + new (...args: any[]): ComponentRenderProxy, Data, Computed, Methods, Mixin, Extends, Emits, Props, ExtractDefaultPropTypes, true>; +}; +declare type DefaultData = object | ((this: V) => object); +declare type DefaultMethods = { + [key: string]: (this: V, ...args: any[]) => any; +}; +declare type DefaultComputed = { + [key: string]: any; +}; +declare type VueProxy, Computed extends ComputedOptions = DefaultComputed, Methods extends MethodOptions = DefaultMethods, Mixin = {}, Extends = {}, Emits extends EmitsOptions = {}> = ComponentOptions & Data, Methods, Computed, PropsOptions, ExtractPropTypes> & VueConstructorProxy; +declare type ComponentPublicInstance

= { + $: ComponentInternalInstance; + $data: D; + $props: MakeDefaultsOptional extends true ? Partial & Omit

: P & PublicProps; + $attrs: Data; + $refs: Data; + $slots: Slots; + $root: ComponentPublicInstance | null; + $parent: ComponentPublicInstance | null; + $emit: EmitFn; + $el: any; + $forceUpdate: () => void; + $nextTick: typeof nextTick; + $watch(source: string | Function, cb: Function, options?: WatchOptions): WatchStopHandle; +} & P & ShallowUnwrapRef & UnwrapNestedRefs & ExtractComputedReturns & M; + +declare type ComputedGetter$1 = (ctx?: any) => T; +declare type ComputedSetter$1 = (v: T) => void; +interface WritableComputedOptions$1 { + get: ComputedGetter$1; + set: ComputedSetter$1; +} +declare type ComputedOptions = Record | WritableComputedOptions$1>; +interface MethodOptions { + [key: string]: Function; +} +declare type SetupFunction = (this: void, props: Readonly, ctx: SetupContext) => RawBindings | (() => VNode | null) | void; +interface ComponentOptionsBase extends Omit, 'data' | 'computed' | 'method' | 'setup' | 'props'> { + [key: string]: any; + data?: (this: Props & Vue$1, vm: Props) => D; + computed?: C; + methods?: M; +} +declare type ExtractComputedReturns = { + [key in keyof T]: T[key] extends { + get: (...args: any[]) => infer TReturn; + } ? TReturn : T[key] extends (...args: any[]) => infer TReturn ? TReturn : never; +}; +declare type ComponentOptionsWithProps> = ComponentOptionsBase & { + props?: PropsOptions; + emits?: Emits & ThisType; + setup?: SetupFunction; +} & ThisType>; +declare type ComponentOptionsWithArrayProps> = ComponentOptionsBase & { + props?: PropNames[]; + emits?: Emits & ThisType; + setup?: SetupFunction; +} & ThisType>; +declare type ComponentOptionsWithoutProps = ComponentOptionsBase & { + props?: undefined; + emits?: Emits & ThisType; + setup?: SetupFunction; +} & ThisType>; + +declare type AnyObject = Record; +declare type Equal = (() => U extends Left ? 1 : 0) extends (() => U extends Right ? 1 : 0) ? true : false; +declare type HasDefined = Equal extends true ? false : true; + +/** + * overload 1: object format with no props + */ +declare function defineComponent(options: ComponentOptionsWithoutProps<{}, RawBindings, D, C, M, Mixin, Extends, Emits>): VueProxy<{}, RawBindings, D, C, M, Mixin, Extends, Emits>; +/** + * overload 2: object format with array props declaration + * props inferred as `{ [key in PropNames]?: any }` + * + * return type is for Vetur and TSX support + */ +declare function defineComponent(options: ComponentOptionsWithArrayProps): VueProxy, RawBindings, D, C, M, Mixin, Extends, Emits>; +/** + * overload 3: object format with object props declaration + * + * see `ExtractPropTypes` in './componentProps.ts' + */ +declare function defineComponent(options: HasDefined extends true ? ComponentOptionsWithProps : ComponentOptionsWithProps): VueProxy; + +declare type Component = VueProxy; +declare type ComponentOrComponentOptions = Component | ComponentOptionsWithoutProps | ComponentOptionsWithArrayProps | ComponentOptionsWithProps; +declare type AsyncComponentResolveResult = T | { + default: T; +}; +declare type AsyncComponentLoader = () => Promise; +interface AsyncComponentOptions { + loader: AsyncComponentLoader; + loadingComponent?: ComponentOrComponentOptions; + errorComponent?: ComponentOrComponentOptions; + delay?: number; + timeout?: number; + suspensible?: boolean; + onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => any; +} +declare function defineAsyncComponent(source: AsyncComponentLoader | AsyncComponentOptions): AsyncComponent; + +declare type DirectiveModifiers = Record; +interface DirectiveBinding extends Readonly { + readonly modifiers: DirectiveModifiers; + readonly value: V; + readonly oldValue: V | null; +} +declare type DirectiveHook = (el: T, binding: DirectiveBinding, vnode: VNode, prevVNode: Prev) => void; +interface ObjectDirective { + bind?: DirectiveHook; + inserted?: DirectiveHook; + update?: DirectiveHook; + componentUpdated?: DirectiveHook; + unbind?: DirectiveHook; +} +declare type FunctionDirective = DirectiveHook; +declare type Directive = ObjectDirective | FunctionDirective; + +declare const Plugin: { + install: (Vue: VueConstructor) => void; +}; + +declare const _refBrand: unique symbol; +interface Ref { + readonly [_refBrand]: true; + value: T; +} +interface WritableComputedRef extends Ref { + /** + * `effect` is added to be able to differentiate refs from computed properties. + * **Differently from Vue 3, it's just `true`**. This is because there is no equivalent + * of `ReactiveEffect` in `@vue/composition-api`. + */ + effect: true; +} +interface ComputedRef extends WritableComputedRef { + readonly value: T; +} +declare type ToRefs = { + [K in keyof T]: Ref; +}; +declare type CollectionTypes = IterableCollections | WeakCollections; +declare type IterableCollections = Map | Set; +declare type WeakCollections = WeakMap | WeakSet; +declare type BaseTypes = string | number | boolean | Node | Window; +declare type ShallowUnwrapRef = { + [K in keyof T]: T[K] extends Ref ? V : T[K]; +}; +declare type UnwrapRef = T extends Ref ? UnwrapRefSimple : UnwrapRefSimple; +declare type UnwrapRefSimple = T extends Function | CollectionTypes | BaseTypes | Ref ? T : T extends Array ? { + [K in keyof T]: UnwrapRefSimple; +} : T extends object ? { + [P in keyof T]: P extends symbol ? T[P] : UnwrapRef; +} : T; +interface RefOption { + get(): T; + set?(x: T): void; +} +declare class RefImpl implements Ref { + readonly [_refBrand]: true; + value: T; + constructor({ get, set }: RefOption); +} +declare function createRef(options: RefOption, isReadonly?: boolean, isComputed?: boolean): RefImpl; +declare function ref(raw: T): T extends Ref ? T : Ref>; +declare function ref(raw: T): Ref>; +declare function ref(): Ref; +declare function isRef(value: any): value is Ref; +declare function unref(ref: T | Ref): T; +declare function toRefs(obj: T): ToRefs; +declare type CustomRefFactory = (track: () => void, trigger: () => void) => { + get: () => T; + set: (value: T) => void; +}; +declare function customRef(factory: CustomRefFactory): Ref; +declare function toRef(object: T, key: K): Ref; +declare function shallowRef(value: T): T extends Ref ? T : Ref; +declare function shallowRef(value: T): Ref; +declare function shallowRef(): Ref; +declare function triggerRef(value: any): void; +declare function proxyRefs(objectWithRefs: T): ShallowUnwrapRef; + +declare function isRaw(obj: any): boolean; +declare function isReactive(obj: any): boolean; +declare function shallowReactive(obj: T): T; +/** + * Make obj reactivity + */ +declare function reactive(obj: T): UnwrapRef; +/** + * Make sure obj can't be a reactive + */ +declare function markRaw(obj: T): T; +declare function toRaw(observed: T): T; + +declare function isReadonly(obj: any): boolean; +declare type Primitive = string | number | boolean | bigint | symbol | undefined | null; +declare type Builtin = Primitive | Function | Date | Error | RegExp; +declare type DeepReadonly = T extends Builtin ? T : T extends Map ? ReadonlyMap, DeepReadonly> : T extends ReadonlyMap ? ReadonlyMap, DeepReadonly> : T extends WeakMap ? WeakMap, DeepReadonly> : T extends Set ? ReadonlySet> : T extends ReadonlySet ? ReadonlySet> : T extends WeakSet ? WeakSet> : T extends Promise ? Promise> : T extends {} ? { + readonly [K in keyof T]: DeepReadonly; +} : Readonly; +declare type UnwrapNestedRefs = T extends Ref ? T : UnwrapRefSimple; +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +declare function readonly(target: T): DeepReadonly>; +declare function shallowReadonly(obj: T): Readonly; + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +declare function set(target: AnyObject, key: any, val: T): T; + +/** + * Delete a property and trigger change if necessary. + */ +declare function del(target: AnyObject, key: any): void; + +declare function createLifeCycle(lifeCyclehook: string): (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onBeforeMount: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onMounted: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onBeforeUpdate: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onUpdated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onBeforeUnmount: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onUnmounted: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onErrorCaptured: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onActivated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onDeactivated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onServerPrefetch: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; + +declare type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void; +declare type WatchSource = Ref | ComputedRef | (() => T); +declare type WatchCallback = (value: V, oldValue: OV, onInvalidate: InvalidateCbRegistrator) => any; +declare type MapSources = { + [K in keyof T]: T[K] extends WatchSource ? Immediate extends true ? V | undefined : V : never; +}; +declare type MultiWatchSources = (WatchSource | object)[]; +interface WatchOptionsBase { + flush?: FlushMode; +} +declare type InvalidateCbRegistrator = (cb: () => void) => void; +declare type FlushMode = 'pre' | 'post' | 'sync'; +interface WatchOptions extends WatchOptionsBase { + immediate?: Immediate; + deep?: boolean; +} +interface VueWatcher { + lazy: boolean; + get(): any; + teardown(): void; + run(): void; + value: any; +} +declare type WatchStopHandle = () => void; +declare function watchEffect(effect: WatchEffect, options?: WatchOptionsBase): WatchStopHandle; +declare function watchPostEffect(effect: WatchEffect): WatchStopHandle; +declare function watchSyncEffect(effect: WatchEffect): WatchStopHandle; +declare function watch, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle; +declare function watch, Immediate extends Readonly = false>(sources: T, cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle; +declare function watch = false>(sources: [...T], cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle; +declare function watch = false>(source: WatchSource, cb: WatchCallback, options?: WatchOptions): WatchStopHandle; +declare function watch = false>(source: T, cb: WatchCallback, options?: WatchOptions): WatchStopHandle; + +declare type ComputedGetter = (ctx?: any) => T; +declare type ComputedSetter = (v: T) => void; +interface WritableComputedOptions { + get: ComputedGetter; + set: ComputedSetter; +} +declare function computed(getter: ComputedGetter): ComputedRef; +declare function computed(options: WritableComputedOptions): WritableComputedRef; + +interface InjectionKey extends Symbol { +} +declare function provide(key: InjectionKey | string, value: T): void; +declare function inject(key: InjectionKey | string): T | undefined; +declare function inject(key: InjectionKey | string, defaultValue: T, treatDefaultAsFactory?: false): T; +declare function inject(key: InjectionKey | string, defaultValue: T | (() => T), treatDefaultAsFactory?: true): T; + +declare const useCssModule: (name?: string) => Record; +/** + * @deprecated use `useCssModule` instead. + */ +declare const useCSSModule: (name?: string) => Record; + +interface App { + config: VueConstructor['config']; + use: VueConstructor['use']; + mixin: VueConstructor['mixin']; + component: VueConstructor['component']; + directive(name: string): Directive | undefined; + directive(name: string, directive: Directive): this; + provide(key: InjectionKey | symbol | string, value: T): this; + mount: Vue$1['$mount']; + unmount: Vue$1['$destroy']; +} +declare function createApp(rootComponent: any, rootProps?: any): App; + +declare type NextTick = Vue$1['$nextTick']; +declare const nextTick: NextTick; + +interface H extends CreateElement { + (this: ComponentInternalInstance | null | undefined, tag?: string | Component$1 | AsyncComponent$1 | (() => Component$1), children?: VNodeChildren): VNode$1; + (this: ComponentInternalInstance | null | undefined, tag?: string | Component$1 | AsyncComponent$1 | (() => Component$1), data?: VNodeData, children?: VNodeChildren): VNode$1; +} +declare const createElement: H; + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +declare function warn(message: string): void; + +declare class EffectScopeImpl { + active: boolean; + effects: EffectScope[]; + cleanups: (() => void)[]; + constructor(vm: Vue); + run(fn: () => T): T | undefined; + on(): void; + off(): void; + stop(): void; +} +declare class EffectScope extends EffectScopeImpl { + constructor(detached?: boolean); +} +declare function effectScope(detached?: boolean): EffectScope; +declare function getCurrentScope(): EffectScope | undefined; +declare function onScopeDispose(fn: () => void): void; + +declare function useSlots(): SetupContext['slots']; +declare function useAttrs(): SetupContext['attrs']; + +declare const version: string; + +declare module 'vue/types/options' { + interface ComponentOptions { + setup?: SetupFunction; + } +} + +export { App, ComponentInstance, ComponentInternalInstance, ComponentPropsOptions, ComponentPublicInstance, ComponentRenderProxy, ComputedGetter, ComputedOptions, ComputedRef, ComputedSetter, Data, DeepReadonly, Directive, DirectiveBinding, DirectiveHook, DirectiveModifiers, EffectScope, ExtractDefaultPropTypes, ExtractPropTypes, FlushMode, FunctionDirective, InjectionKey, MethodOptions, ObjectDirective, PropOptions, PropType, Ref, SetupContext, SetupFunction, ShallowUnwrapRef, ToRefs, UnwrapNestedRefs, UnwrapRef, UnwrapRefSimple, VueWatcher, WatchCallback, WatchEffect, WatchOptions, WatchOptionsBase, WatchSource, WatchStopHandle, WritableComputedOptions, WritableComputedRef, computed, createApp, createLifeCycle, createRef, customRef, Plugin as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, createElement as h, inject, isRaw, isReactive, isReadonly, isRef, markRaw, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCSSModule, useCssModule, useSlots, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect }; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js new file mode 100644 index 000000000..26b371ef5 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js @@ -0,0 +1,2253 @@ +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); +} + +var activeEffectScope; +var effectScopeStack = []; +var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; +}()); +var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; +}(EffectScopeImpl)); +function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); +} +function effectScope(detached) { + return new EffectScope(detached); +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } +} +/** + * @internal + **/ +function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); +} +/** + * @internal + **/ +function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; +} + +var vueDependency = undefined; +try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } +} +catch (_a) { + // not available +} +var vueConstructor = null; +var currentInstance = null; +var currentInstanceTracking = true; +var PluginInstalledFlag = '__composition_api_installed__'; +function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; +} +function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); +} +function getVueConstructor() { + if ((process.env.NODE_ENV !== 'production')) { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; +} +// returns registered vue or `vue` dependency +function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + if ((process.env.NODE_ENV !== 'production')) { + assert(constructor, "No vue dependency found."); + } + return constructor; +} +function setVueConstructor(Vue) { + // @ts-ignore + if ((process.env.NODE_ENV !== 'production') && vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); +} +/** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ +function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } +} +function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); +} +function getCurrentInstance() { + return currentInstance; +} +var instanceMapCache = new WeakMap(); +function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; +} + +var toString = function (x) { return Object.prototype.toString.call(x); }; +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +var noopFn = function (_) { return _; }; +function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); +} +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); +} +function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); +} +function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } +} +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isArray(x) { + return Array.isArray(x); +} +var objectToString = Object.prototype.toString; +var toTypeString = function (value) { + return objectToString.call(value); +}; +var isMap = function (val) { + return toTypeString(val) === '[object Map]'; +}; +var isSet = function (val) { + return toTypeString(val) === '[object Set]'; +}; +var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 +function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); +} +function isObject(val) { + return val !== null && typeof val === 'object'; +} +function isPlainObject(x) { + return toString(x) === '[object Object]'; +} +function isFunction(x) { + return typeof x === 'function'; +} +function isUndef(v) { + return v === undefined || v === null; +} +function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); +} +function logError(err, vm, info) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } +} +/** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ +function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } +} + +function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; +} +function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; +} +function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; +} +function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + if ((process.env.NODE_ENV !== 'production')) + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + return; + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); +} +function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; +} +var vueInternalClasses; +var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; +}; + +function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; +} +var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); +var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); +// must be a string, symbol key is ignored in reactive +var RefKey = 'composition-api.refKey'; + +var accessModifiedSet = new WeakMap(); +var rawSet = new WeakMap(); +var readonlySet = new WeakMap(); + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; +} + +var _isForceTrigger = false; +function isForceTrigger() { + return _isForceTrigger; +} +function setForceTrigger(v) { + _isForceTrigger = v; +} + +var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; +}()); +function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; +} +function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function isRef(value) { + return value instanceof RefImpl; +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function toRefs(obj) { + if ((process.env.NODE_ENV !== 'production') && !isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; +} +function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); +} +function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); +} +function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); +} +function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; +} + +var SKIPFLAG = '__v_skip'; +function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +/** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ +function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } +} +/** + * Auto unwrapping when access property + */ +function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); +} +function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; +} +/** + * Mock __ob__ for object recursively + */ +function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; +} +function createObserver() { + return observe({}).__ob__; +} +function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; +} +/** + * Make obj reactivity + */ +function reactive(obj) { + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; +} +/** + * Make sure obj can't be a reactive + */ +function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; +} +function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; +} + +function isReadonly(obj) { + return readonlySet.has(obj); +} +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +function readonly(target) { + if ((process.env.NODE_ENV !== 'production') && !isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; +} +function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; +} + +/** + * Delete a property and trigger change if necessary. + */ +function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); +} + +var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; +function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; +} +function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; +} +function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; +} +var onBeforeMount = createLifeCycle('beforeMount'); +var onMounted = createLifeCycle('mounted'); +var onBeforeUpdate = createLifeCycle('beforeUpdate'); +var onUpdated = createLifeCycle('updated'); +var onBeforeUnmount = createLifeCycle('beforeDestroy'); +var onUnmounted = createLifeCycle('destroyed'); +var onErrorCaptured = createLifeCycle('errorCaptured'); +var onActivated = createLifeCycle('activated'); +var onDeactivated = createLifeCycle('deactivated'); +var onServerPrefetch = createLifeCycle('serverPrefetch'); + +var fallbackVM; +function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); +} +function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); +} +function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; +} +function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); +} +function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); +} +function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); +} +function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; +} +function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; +} +function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } +} +function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; +} +// We have to monkeypatch the teardown function so Vue will run +// runCleanup() when it tears down the watcher on unmounted. +function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; +} +function createWatcher(vm, source, cb, options) { + var _a; + if ((process.env.NODE_ENV !== 'production') && !cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; +} +function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); +} +function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); +} +function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); +} +// implementation +function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + if ((process.env.NODE_ENV !== 'production')) { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); +} +function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; +} + +// implement +function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); +} + +var NOT_FOUND = {}; +function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; +} +function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; +} +function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + (process.env.NODE_ENV !== 'production') && + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + (process.env.NODE_ENV !== 'production') && warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } +} + +var EMPTY_OBJ = (process.env.NODE_ENV !== 'production') + ? Object.freeze({}) + : {}; +var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + (process.env.NODE_ENV !== 'production') && warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + (process.env.NODE_ENV !== 'production') && + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; +}; +/** + * @deprecated use `useCssModule` instead. + */ +var useCSSModule = useCssModule; + +function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + if ((process.env.NODE_ENV !== 'production')) { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; +} + +var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); +}; + +var fallbackCreateElement; +var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + (process.env.NODE_ENV !== 'production') && + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); +}; + +function useSlots() { + return getContext().slots; +} +function useAttrs() { + return getContext().attrs; +} +function getContext() { + var i = getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !i) { + warn("useContext() called without active instance."); + } + return i.setupContext; +} + +function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; +} +function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; +} +var vmStateManager = { + set: set, + get: get, +}; + +function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + if ((process.env.NODE_ENV !== 'production')) { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } +} +function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); +} +function afterRender(vm) { + var stack = [vm._vnode]; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) + updateTemplateRef(vnode.context); + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } +} +function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); +} +function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } +} + +function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + if ((process.env.NODE_ENV !== 'production')) { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + if (process.env.NODE_ENV === 'test') { + ctx._vm = vm; + } + return ctx; + } +} + +/** + * Helper that recursively merges two data objects together. + */ +function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; +} +function install(Vue) { + if (isVueRegistered(Vue)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + if ((process.env.NODE_ENV !== 'production')) { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); +} +var Plugin = { + install: function (Vue) { return install(Vue); }, +}; + +// implementation, close to no-op +function defineComponent(options) { + return options; +} + +function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if ((process.env.NODE_ENV !== 'production') && suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if ((process.env.NODE_ENV !== 'production') && !comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if ((process.env.NODE_ENV !== 'production') && comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; +} + +var version = "1.7.0"; +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); +} + +export { EffectScope, computed, createApp, createLifeCycle, createRef, customRef, Plugin as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, createElement as h, inject, isRaw, isReactive, isReadonly, isRef, markRaw, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref, set$1 as set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCSSModule, useCssModule, useSlots, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect }; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js new file mode 100644 index 000000000..8967d4e43 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js @@ -0,0 +1,2303 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueCompositionAPI = {})); +})(this, (function (exports) { 'use strict'; + + /****************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + /* global Reflect, Promise */ + + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + + function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + + function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + + function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + } + + function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + } + + /** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ + function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + } + + var activeEffectScope; + var effectScopeStack = []; + var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; + }()); + var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; + }(EffectScopeImpl)); + function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); + } + function effectScope(detached) { + return new EffectScope(detached); + } + function getCurrentScope() { + return activeEffectScope; + } + function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } + } + /** + * @internal + **/ + function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); + } + /** + * @internal + **/ + function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; + } + + var vueDependency = undefined; + try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } + } + catch (_a) { + // not available + } + var vueConstructor = null; + var currentInstance = null; + var currentInstanceTracking = true; + var PluginInstalledFlag = '__composition_api_installed__'; + function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; + } + function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); + } + function getVueConstructor() { + { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; + } + // returns registered vue or `vue` dependency + function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + { + assert(constructor, "No vue dependency found."); + } + return constructor; + } + function setVueConstructor(Vue) { + // @ts-ignore + if (vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); + } + /** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ + function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } + } + function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); + } + function getCurrentInstance() { + return currentInstance; + } + var instanceMapCache = new WeakMap(); + function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; + } + + var toString = function (x) { return Object.prototype.toString.call(x); }; + function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); + } + var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); + var noopFn = function (_) { return _; }; + function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); + } + function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); + } + function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); + } + function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } + } + function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); + } + function isArray(x) { + return Array.isArray(x); + } + var objectToString = Object.prototype.toString; + var toTypeString = function (value) { + return objectToString.call(value); + }; + var isMap = function (val) { + return toTypeString(val) === '[object Map]'; + }; + var isSet = function (val) { + return toTypeString(val) === '[object Set]'; + }; + var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 + function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); + } + function isObject(val) { + return val !== null && typeof val === 'object'; + } + function isPlainObject(x) { + return toString(x) === '[object Object]'; + } + function isFunction(x) { + return typeof x === 'function'; + } + function isUndef(v) { + return v === undefined || v === null; + } + function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); + } + function logError(err, vm, info) { + { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } + } + /** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ + function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } + } + + function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if (!target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; + } + function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; + } + function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; + } + function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); + } + function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; + } + var vueInternalClasses; + var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; + }; + + function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; + } + var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); + var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); + // must be a string, symbol key is ignored in reactive + var RefKey = 'composition-api.refKey'; + + var accessModifiedSet = new WeakMap(); + var rawSet = new WeakMap(); + var readonlySet = new WeakMap(); + + /** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ + function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; + } + + var _isForceTrigger = false; + function isForceTrigger() { + return _isForceTrigger; + } + function setForceTrigger(v) { + _isForceTrigger = v; + } + + var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; + }()); + function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; + } + function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); + } + function isRef(value) { + return value instanceof RefImpl; + } + function unref(ref) { + return isRef(ref) ? ref.value : ref; + } + function toRefs(obj) { + if (!isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; + } + function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); + } + function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); + } + function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); + } + function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); + } + function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; + } + + var SKIPFLAG = '__v_skip'; + function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); + } + function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); + } + /** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ + function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } + } + /** + * Auto unwrapping when access property + */ + function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); + } + function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; + } + /** + * Mock __ob__ for object recursively + */ + function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + } + function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; + } + function createObserver() { + return observe({}).__ob__; + } + function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; + } + /** + * Make obj reactivity + */ + function reactive(obj) { + if (!isObject(obj)) { + { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; + } + /** + * Make sure obj can't be a reactive + */ + function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; + } + function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; + } + + function isReadonly(obj) { + return readonlySet.has(obj); + } + /** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ + function readonly(target) { + if (!isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; + } + function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; + } + + /** + * Delete a property and trigger change if necessary. + */ + function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); + } + + var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; + function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; + } + function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; + } + function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; + } + var onBeforeMount = createLifeCycle('beforeMount'); + var onMounted = createLifeCycle('mounted'); + var onBeforeUpdate = createLifeCycle('beforeUpdate'); + var onUpdated = createLifeCycle('updated'); + var onBeforeUnmount = createLifeCycle('beforeDestroy'); + var onUnmounted = createLifeCycle('destroyed'); + var onErrorCaptured = createLifeCycle('errorCaptured'); + var onActivated = createLifeCycle('activated'); + var onDeactivated = createLifeCycle('deactivated'); + var onServerPrefetch = createLifeCycle('serverPrefetch'); + + var fallbackVM; + function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); + } + function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); + } + function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; + } + function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); + } + function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); + } + function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); + } + function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; + } + function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; + } + function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } + } + function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; + } + // We have to monkeypatch the teardown function so Vue will run + // runCleanup() when it tears down the watcher on unmounted. + function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; + } + function createWatcher(vm, source, cb, options) { + var _a; + if (!cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; + } + function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); + } + function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); + } + function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); + } + // implementation + function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); + } + function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; + } + + // implement + function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); + } + + var NOT_FOUND = {}; + function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; + } + function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; + } + function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } + } + + var EMPTY_OBJ = Object.freeze({}) + ; + var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; + }; + /** + * @deprecated use `useCssModule` instead. + */ + var useCSSModule = useCssModule; + + function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; + } + + var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); + }; + + var fallbackCreateElement; + var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); + }; + + function useSlots() { + return getContext().slots; + } + function useAttrs() { + return getContext().attrs; + } + function getContext() { + var i = getCurrentInstance(); + if (!i) { + warn("useContext() called without active instance."); + } + return i.setupContext; + } + + function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; + } + function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; + } + var vmStateManager = { + set: set, + get: get, + }; + + function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } + } + function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); + } + function afterRender(vm) { + var stack = [vm._vnode]; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) + updateTemplateRef(vnode.context); + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } + } + function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + } + function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); + } + function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } + } + + function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + return ctx; + } + } + + /** + * Helper that recursively merges two data objects together. + */ + function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; + } + function install(Vue) { + if (isVueRegistered(Vue)) { + { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); + } + var Plugin = { + install: function (Vue) { return install(Vue); }, + }; + + // implementation, close to no-op + function defineComponent(options) { + return options; + } + + function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if (suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if (!comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if (comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; + } + + var version = "1.7.0"; + // auto install when using CDN + if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); + } + + exports.EffectScope = EffectScope; + exports.computed = computed; + exports.createApp = createApp; + exports.createLifeCycle = createLifeCycle; + exports.createRef = createRef; + exports.customRef = customRef; + exports["default"] = Plugin; + exports.defineAsyncComponent = defineAsyncComponent; + exports.defineComponent = defineComponent; + exports.del = del; + exports.effectScope = effectScope; + exports.getCurrentInstance = getCurrentInstance; + exports.getCurrentScope = getCurrentScope; + exports.h = createElement; + exports.inject = inject; + exports.isRaw = isRaw; + exports.isReactive = isReactive; + exports.isReadonly = isReadonly; + exports.isRef = isRef; + exports.markRaw = markRaw; + exports.nextTick = nextTick; + exports.onActivated = onActivated; + exports.onBeforeMount = onBeforeMount; + exports.onBeforeUnmount = onBeforeUnmount; + exports.onBeforeUpdate = onBeforeUpdate; + exports.onDeactivated = onDeactivated; + exports.onErrorCaptured = onErrorCaptured; + exports.onMounted = onMounted; + exports.onScopeDispose = onScopeDispose; + exports.onServerPrefetch = onServerPrefetch; + exports.onUnmounted = onUnmounted; + exports.onUpdated = onUpdated; + exports.provide = provide; + exports.proxyRefs = proxyRefs; + exports.reactive = reactive; + exports.readonly = readonly; + exports.ref = ref; + exports.set = set$1; + exports.shallowReactive = shallowReactive; + exports.shallowReadonly = shallowReadonly; + exports.shallowRef = shallowRef; + exports.toRaw = toRaw; + exports.toRef = toRef; + exports.toRefs = toRefs; + exports.triggerRef = triggerRef; + exports.unref = unref; + exports.useAttrs = useAttrs; + exports.useCSSModule = useCSSModule; + exports.useCssModule = useCssModule; + exports.useSlots = useSlots; + exports.version = version; + exports.warn = warn$1; + exports.watch = watch; + exports.watchEffect = watchEffect; + exports.watchPostEffect = watchPostEffect; + exports.watchSyncEffect = watchSyncEffect; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs new file mode 100644 index 000000000..26b371ef5 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs @@ -0,0 +1,2253 @@ +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); +} + +var activeEffectScope; +var effectScopeStack = []; +var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; +}()); +var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; +}(EffectScopeImpl)); +function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); +} +function effectScope(detached) { + return new EffectScope(detached); +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } +} +/** + * @internal + **/ +function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); +} +/** + * @internal + **/ +function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; +} + +var vueDependency = undefined; +try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } +} +catch (_a) { + // not available +} +var vueConstructor = null; +var currentInstance = null; +var currentInstanceTracking = true; +var PluginInstalledFlag = '__composition_api_installed__'; +function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; +} +function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); +} +function getVueConstructor() { + if ((process.env.NODE_ENV !== 'production')) { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; +} +// returns registered vue or `vue` dependency +function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + if ((process.env.NODE_ENV !== 'production')) { + assert(constructor, "No vue dependency found."); + } + return constructor; +} +function setVueConstructor(Vue) { + // @ts-ignore + if ((process.env.NODE_ENV !== 'production') && vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); +} +/** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ +function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } +} +function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); +} +function getCurrentInstance() { + return currentInstance; +} +var instanceMapCache = new WeakMap(); +function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; +} + +var toString = function (x) { return Object.prototype.toString.call(x); }; +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +var noopFn = function (_) { return _; }; +function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); +} +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); +} +function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); +} +function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } +} +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isArray(x) { + return Array.isArray(x); +} +var objectToString = Object.prototype.toString; +var toTypeString = function (value) { + return objectToString.call(value); +}; +var isMap = function (val) { + return toTypeString(val) === '[object Map]'; +}; +var isSet = function (val) { + return toTypeString(val) === '[object Set]'; +}; +var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 +function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); +} +function isObject(val) { + return val !== null && typeof val === 'object'; +} +function isPlainObject(x) { + return toString(x) === '[object Object]'; +} +function isFunction(x) { + return typeof x === 'function'; +} +function isUndef(v) { + return v === undefined || v === null; +} +function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); +} +function logError(err, vm, info) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } +} +/** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ +function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } +} + +function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; +} +function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; +} +function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; +} +function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + if ((process.env.NODE_ENV !== 'production')) + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + return; + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); +} +function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; +} +var vueInternalClasses; +var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; +}; + +function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; +} +var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); +var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); +// must be a string, symbol key is ignored in reactive +var RefKey = 'composition-api.refKey'; + +var accessModifiedSet = new WeakMap(); +var rawSet = new WeakMap(); +var readonlySet = new WeakMap(); + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; +} + +var _isForceTrigger = false; +function isForceTrigger() { + return _isForceTrigger; +} +function setForceTrigger(v) { + _isForceTrigger = v; +} + +var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; +}()); +function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; +} +function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function isRef(value) { + return value instanceof RefImpl; +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function toRefs(obj) { + if ((process.env.NODE_ENV !== 'production') && !isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; +} +function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); +} +function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); +} +function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); +} +function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; +} + +var SKIPFLAG = '__v_skip'; +function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +/** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ +function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } +} +/** + * Auto unwrapping when access property + */ +function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); +} +function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; +} +/** + * Mock __ob__ for object recursively + */ +function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; +} +function createObserver() { + return observe({}).__ob__; +} +function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; +} +/** + * Make obj reactivity + */ +function reactive(obj) { + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; +} +/** + * Make sure obj can't be a reactive + */ +function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; +} +function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; +} + +function isReadonly(obj) { + return readonlySet.has(obj); +} +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +function readonly(target) { + if ((process.env.NODE_ENV !== 'production') && !isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; +} +function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; +} + +/** + * Delete a property and trigger change if necessary. + */ +function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); +} + +var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; +function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; +} +function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; +} +function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; +} +var onBeforeMount = createLifeCycle('beforeMount'); +var onMounted = createLifeCycle('mounted'); +var onBeforeUpdate = createLifeCycle('beforeUpdate'); +var onUpdated = createLifeCycle('updated'); +var onBeforeUnmount = createLifeCycle('beforeDestroy'); +var onUnmounted = createLifeCycle('destroyed'); +var onErrorCaptured = createLifeCycle('errorCaptured'); +var onActivated = createLifeCycle('activated'); +var onDeactivated = createLifeCycle('deactivated'); +var onServerPrefetch = createLifeCycle('serverPrefetch'); + +var fallbackVM; +function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); +} +function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); +} +function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; +} +function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); +} +function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); +} +function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); +} +function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; +} +function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; +} +function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } +} +function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; +} +// We have to monkeypatch the teardown function so Vue will run +// runCleanup() when it tears down the watcher on unmounted. +function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; +} +function createWatcher(vm, source, cb, options) { + var _a; + if ((process.env.NODE_ENV !== 'production') && !cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; +} +function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); +} +function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); +} +function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); +} +// implementation +function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + if ((process.env.NODE_ENV !== 'production')) { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); +} +function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; +} + +// implement +function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); +} + +var NOT_FOUND = {}; +function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; +} +function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; +} +function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + (process.env.NODE_ENV !== 'production') && + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + (process.env.NODE_ENV !== 'production') && warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } +} + +var EMPTY_OBJ = (process.env.NODE_ENV !== 'production') + ? Object.freeze({}) + : {}; +var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + (process.env.NODE_ENV !== 'production') && warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + (process.env.NODE_ENV !== 'production') && + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; +}; +/** + * @deprecated use `useCssModule` instead. + */ +var useCSSModule = useCssModule; + +function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + if ((process.env.NODE_ENV !== 'production')) { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; +} + +var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); +}; + +var fallbackCreateElement; +var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + (process.env.NODE_ENV !== 'production') && + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); +}; + +function useSlots() { + return getContext().slots; +} +function useAttrs() { + return getContext().attrs; +} +function getContext() { + var i = getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !i) { + warn("useContext() called without active instance."); + } + return i.setupContext; +} + +function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; +} +function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; +} +var vmStateManager = { + set: set, + get: get, +}; + +function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + if ((process.env.NODE_ENV !== 'production')) { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } +} +function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); +} +function afterRender(vm) { + var stack = [vm._vnode]; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) + updateTemplateRef(vnode.context); + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } +} +function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); +} +function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } +} + +function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + if ((process.env.NODE_ENV !== 'production')) { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + if (process.env.NODE_ENV === 'test') { + ctx._vm = vm; + } + return ctx; + } +} + +/** + * Helper that recursively merges two data objects together. + */ +function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; +} +function install(Vue) { + if (isVueRegistered(Vue)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + if ((process.env.NODE_ENV !== 'production')) { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); +} +var Plugin = { + install: function (Vue) { return install(Vue); }, +}; + +// implementation, close to no-op +function defineComponent(options) { + return options; +} + +function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if ((process.env.NODE_ENV !== 'production') && suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if ((process.env.NODE_ENV !== 'production') && !comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if ((process.env.NODE_ENV !== 'production') && comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; +} + +var version = "1.7.0"; +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); +} + +export { EffectScope, computed, createApp, createLifeCycle, createRef, customRef, Plugin as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, createElement as h, inject, isRaw, isReactive, isReadonly, isRef, markRaw, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref, set$1 as set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCSSModule, useCssModule, useSlots, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect }; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js new file mode 100644 index 000000000..401206cea --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js @@ -0,0 +1 @@ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).VueCompositionAPI={})}(this,(function(n){"use strict";var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])},t(n,e)};var e,r=function(){return r=Object.assign||function(n){for(var t,e=1,r=arguments.length;e=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!e)return n;var r,o,i=e.call(n),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(n){o={error:n}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function u(n,t,e){if(e||2===arguments.length)for(var r,o=0,i=t.length;o=0&&Math.floor(t)===t&&isFinite(n)&&t<=4294967295}function B(n){return null!==n&&"object"==typeof n}function T(n){return"[object Object]"===function(n){return Object.prototype.toString.call(n)}(n)}function V(n){return"function"==typeof n}function W(n,t){return t=t||$()}function z(n,t){void 0===t&&(t={});var e=n.config.silent;n.config.silent=!0;var r=new n(t);return n.config.silent=e,r}function F(n,t){return function(){for(var e=[],r=0;r1?e&&V(t)?t():t:void 0}},n.isRaw=un,n.isReactive=fn,n.isReadonly=function(n){return H.has(n)},n.isRef=tn,n.markRaw=function(n){if(!T(n)&&!M(n)||!Object.isExtensible(n))return n;var t=vn();return t.__v_skip=!0,C(n,"__ob__",t),G.set(n,!0),n},n.nextTick=function(){for(var n,t=[],e=0;e= 2.5 < 2.7" + }, + "devDependencies": { + "@rollup/plugin-node-resolve": "^13.3.0", + "@rollup/plugin-replace": "^4.0.0", + "@types/jest": "^26.0.24", + "@types/node": "^17.0.31", + "bumpp": "^7.1.1", + "conventional-changelog-cli": "^2.2.2", + "conventional-github-releaser": "^3.1.5", + "cross-env": "^7.0.3", + "jest": "^26.6.3", + "lint-staged": "^12.4.1", + "prettier": "^2.6.2", + "rimraf": "^3.0.2", + "rollup": "^2.72.0", + "rollup-plugin-dts": "^4.2.1", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-typescript2": "^0.31.2", + "simple-git-hooks": "^2.7.0", + "ts-jest": "^26.5.6", + "tslib": "^2.4.0", + "typescript": "^4.6.4", + "vue": "^2.6.14", + "vue-router": "^3.5.3", + "vue-server-renderer": "^2.6.14", + "vue3": "npm:vue@3.2.21" + }, + "simple-git-hooks": { + "pre-commit": "lint-staged" + }, + "lint-staged": { + "*.js": [ + "prettier --write" + ], + "*.ts?(x)": [ + "prettier --parser=typescript --write" + ] + }, + "jest": { + "verbose": true, + "globals": { + "__DEV__": true, + "__VERSION__": "0.0.0" + }, + "setupFiles": [ + "/test/setupTest.js" + ], + "setupFilesAfterEnv": [ + "/test/helpers/wait-for-update.js" + ], + "moduleFileExtensions": [ + "ts", + "js" + ], + "testMatch": [ + "/test/**/*.spec.{js,ts}" + ], + "preset": "ts-jest" + }, + "prettier": { + "semi": false, + "singleQuote": true, + "printWidth": 80 + } +} -- GitLab