From 12e5d848c4412bdafa3d2f4d88ad9da3ca9048b6 Mon Sep 17 00:00:00 2001 From: gmono Date: Wed, 18 Sep 2024 14:26:40 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/watch.ts | 63 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/src/watch.ts b/src/watch.ts index f7dd1ef..a527643 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -1,9 +1,10 @@ + /** * @module veact.watch * @author Surmon */ -import { useState as useReactState } from 'react' +import { useCallback, useEffect, useState as useReactState, useRef } from 'react' import { watch as vueWatch } from '@vue/reactivity' import type { ReactiveMarker, @@ -12,7 +13,7 @@ import type { WatchSource, WatchHandle, } from '@vue/reactivity' -import { onBeforeUnmount } from './lifecycle' +import { onBeforeUnmount, onMounted } from './lifecycle' import { logger } from './_logger' // changelog: https://github.com/vuejs/core/blob/main/CHANGELOG.md @@ -32,10 +33,10 @@ export type MultiWatchSources = (WatchSource | object)[] type MaybeUndefined = I extends true ? T | undefined : T type MapSources = { [K in keyof T]: T[K] extends WatchSource - ? MaybeUndefined - : T[K] extends object - ? MaybeUndefined - : never + ? MaybeUndefined + : T[K] extends object + ? MaybeUndefined + : never } /** @@ -97,6 +98,20 @@ export function watch = false>( scheduler: (job) => job(), }) } +/** + * 保证函数只执行一次 后每次返回同样的结果 + * @param func 执行一次并返回结果的函数 + * @returns + */ +export function useOnce(func:()=>T){ + const first=useRef(true) + const data=useRef(undefined) + if(first.current){ + first.current=false; + data.current=func(); + } + return data.current as T; +} /** * Watches one or more reactive data sources and invokes a callback function when the sources change. @@ -114,8 +129,36 @@ export function watch = false>( * }) * ``` */ -export const useWatch: typeof watch = (source: any, callback: any, options = {}) => { - const [watchHandle] = useReactState(() => watch(source as any, callback, options)) - onBeforeUnmount(() => watchHandle.stop()) - return watchHandle +export const useWatch = (source: any, callback: any, options = {}) => { + const watcher = useRef() + //执行watch + const cancelWatch = useCallback(() => { + if (watcher.current) { + watcher.current(); + watcher.current = undefined; + } + }, []) + const doWatch = useCallback(() => { + if (watcher.current) cancelWatch(); + + watcher.current = watch(source as any, () => { + console.log("触发更新") + callback() + }, options) + + }, []) + onMounted(() => { + console.log("执行监听") + doWatch(); + }) + onBeforeUnmount(() => { + console.log("取消监听") + cancelWatch(); + }) + useOnce(()=>{ + console.log("初始监听") + doWatch(); + }) + + return watcher; } From 712271d48c1f4b1df3f451dac917b292cb7588c7 Mon Sep 17 00:00:00 2001 From: gmono Date: Wed, 18 Sep 2024 14:39:13 +0800 Subject: [PATCH 02/12] =?UTF-8?q?setup=E7=BB=84=E4=BB=B6=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=AE=BE=E6=96=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +++- src/index.ts | 1 + src/setup/setupComponents.tsx | 39 +++++++++++++++++++++++++++++++++++ src/useOnce.ts | 16 ++++++++++++++ src/watch.ts | 16 +------------- 5 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 src/setup/setupComponents.tsx create mode 100644 src/useOnce.ts diff --git a/package.json b/package.json index f42ee04..ad30150 100644 --- a/package.json +++ b/package.json @@ -50,12 +50,14 @@ "react-dom": "^16.8.0 || ^17 || ^18 || ^19" }, "dependencies": { - "@vue/reactivity": ">=3.5" + "@vue/reactivity": ">=3.5", + "lodash": "^4.17.21" }, "devDependencies": { "@eslint/js": "^9.x", "@testing-library/react": "^16.x", "@types/eslint": "^9.x", + "@types/lodash": "^4", "@types/react": "^18.x", "@types/react-dom": "^18.x", "@vitejs/plugin-react": "^4.x", diff --git a/src/index.ts b/src/index.ts index c0322ce..4615061 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ // redirect all APIs from @vue/reactivity export * from '@vue/reactivity' +export * from "./setup/setupComponents" export { watch as baseWatch } from '@vue/reactivity' // lifecycle hooks diff --git a/src/setup/setupComponents.tsx b/src/setup/setupComponents.tsx new file mode 100644 index 0000000..aca8688 --- /dev/null +++ b/src/setup/setupComponents.tsx @@ -0,0 +1,39 @@ +import { ReactElement } from "react"; +import { useOnce } from "../useOnce"; +import { isReactive, isRef } from "@vue/reactivity"; +import React from "react"; +import { useReactivity } from "../reactivity"; +import { mapValues } from "lodash"; + +export interface ISetupComponent { + setup(p: P): T; + render(ctx: T): ReactElement; +} + +export function SetupComponentRenderer(p: { + target: ISetupComponent; + props: any; +}) { + const store = useOnce(() => { + let t = p.target.setup(p.props); + return t; + }); + let t = mapValues(store, (v, k) => { + if (isRef(v) || isReactive(v)) { + return useReactivity(() => v); + } else return v; + }); + const RenderComp = p.target.render; + return ; +} + +/** + * 定义一个veact组件 + * @param v 类似vue的定义对象 + * @returns + */ +export function defineSetupComponent(v: ISetupComponent) { + return (props: P) => { + return ; + }; +} diff --git a/src/useOnce.ts b/src/useOnce.ts new file mode 100644 index 0000000..9b67421 --- /dev/null +++ b/src/useOnce.ts @@ -0,0 +1,16 @@ +import { useRef } from "react"; + +/** + * 保证函数只执行一次 后每次返回同样的结果 + * @param func 执行一次并返回结果的函数 + * @returns + */ +export function useOnce(func: () => T) { + const first = useRef(true); + const data = useRef(undefined); + if (first.current) { + first.current = false; + data.current = func(); + } + return data.current as T; +} diff --git a/src/watch.ts b/src/watch.ts index a527643..161839f 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -15,6 +15,7 @@ import type { } from '@vue/reactivity' import { onBeforeUnmount, onMounted } from './lifecycle' import { logger } from './_logger' +import { useOnce } from './useOnce' // changelog: https://github.com/vuejs/core/blob/main/CHANGELOG.md // https://github.com/vuejs/core/blob/main/packages/runtime-core/src/apiWatch.ts @@ -98,21 +99,6 @@ export function watch = false>( scheduler: (job) => job(), }) } -/** - * 保证函数只执行一次 后每次返回同样的结果 - * @param func 执行一次并返回结果的函数 - * @returns - */ -export function useOnce(func:()=>T){ - const first=useRef(true) - const data=useRef(undefined) - if(first.current){ - first.current=false; - data.current=func(); - } - return data.current as T; -} - /** * Watches one or more reactive data sources and invokes a callback function when the sources change. * From 375c0b4db41a2ecd1cbe4111b62e0cfea68c11a2 Mon Sep 17 00:00:00 2001 From: gmono Date: Wed, 18 Sep 2024 20:00:06 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E5=A2=9E=E5=8A=A0batch=E7=9A=84reactive?= =?UTF-8?q?=20object=E7=9B=91=E5=90=AC=20=E6=94=AF=E6=8C=81setupComponent?= =?UTF-8?q?=E5=B9=B6=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- src/reactivity.ts | 31 +++++++++++++++++++++++++++++++ src/setup/setupComponents.tsx | 17 +++++++++-------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index ad30150..674e8dc 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ }, "dependencies": { "@vue/reactivity": ">=3.5", - "lodash": "^4.17.21" + "lodash": "^4.17.21", + "ts-pystyle": "^1.4.4" }, "devDependencies": { "@eslint/js": "^9.x", diff --git a/src/reactivity.ts b/src/reactivity.ts index 4fc2bd5..cb9ccd8 100644 --- a/src/reactivity.ts +++ b/src/reactivity.ts @@ -5,6 +5,10 @@ import { useWatch } from './watch' import { useForceUpdate } from './_utils' +import { useCallback, useMemo } from 'react' +import { mapValues } from 'lodash' +import { list } from 'ts-pystyle' +import { isReactive, isRef } from '@vue/reactivity' /** * Converts some of the 'raw Vue' data, which is not already wrapped in a hook, @@ -40,3 +44,30 @@ export function useReactivity(getter: () => T): T { useWatch(() => getter(), forceUpdate, { deep: true }) return getter() } + +function objToArr(obj:any){ + function *inner(){ + for(let k in obj){ + yield obj[k] + } + } + return list(inner()); +} +/** + * 执行对象内监听 过滤非ref reactive + * 针对构造setupComponent支持 + * @param getter + * @returns + */ +export function useReactivityObject(getter: () => T): T { + const forceUpdate = useForceUpdate() + // deep > watch > traverse(getter()) > ref | array | set | map | plain object(reactive) > force update + const f=useCallback(()=>{ + const t=getter(); + const ar=objToArr(t).filter(v=>isRef(v)||isReactive(v)) + return ar; + },[getter]) + const v=useMemo(()=>f(),[f]) + useWatch(() => v, forceUpdate, { deep: true }) + return getter() +} diff --git a/src/setup/setupComponents.tsx b/src/setup/setupComponents.tsx index aca8688..9194719 100644 --- a/src/setup/setupComponents.tsx +++ b/src/setup/setupComponents.tsx @@ -1,8 +1,8 @@ import { ReactElement } from "react"; import { useOnce } from "../useOnce"; -import { isReactive, isRef } from "@vue/reactivity"; +import { isReactive, isRef, reactive } from "@vue/reactivity"; import React from "react"; -import { useReactivity } from "../reactivity"; +import { useReactivity, useReactivityObject } from "../reactivity"; import { mapValues } from "lodash"; export interface ISetupComponent { @@ -18,13 +18,14 @@ export function SetupComponentRenderer(p: { let t = p.target.setup(p.props); return t; }); - let t = mapValues(store, (v, k) => { - if (isRef(v) || isReactive(v)) { - return useReactivity(() => v); - } else return v; - }); + const tt=useReactivityObject(store) + // let t = mapValues(store, (v, k) => { + // if (isRef(v) || isReactive(v)) { + // return useReactivity(() => v); + // } else return v; + // }); const RenderComp = p.target.render; - return ; + return ; } /** From 180c87205b09ab60ac33673a3a2e869b42d8a81b Mon Sep 17 00:00:00 2001 From: gmono Date: Wed, 18 Sep 2024 20:16:30 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 61 +++++++++++++++++++++++++++++------ "\350\256\241\345\210\222.md" | 7 ++++ 2 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 "\350\256\241\345\210\222.md" diff --git a/README.md b/README.md index 5d1aee5..be8b893 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,25 @@ Veact embodies what I believe is the **“best of both worlds”**—a powerful, #### API & examples -- [API List](#api) -- [Example: Lifecycle](#lifecycle) -- [Example: Ref](#ref) -- [Example: ShallowRef](#shallowref) -- [Example: Reactive](#reactive) -- [Example: Computed](#computed) -- [Example: Watch](#watch) -- [Example: EffectScope](#effectscope) -- [Example: Reactivity](#reactivity) +- [Veact](#veact) + - [Why Veact?](#why-veact) + - [Who is using this library 🔥](#who-is-using-this-library-) + - [API \& examples](#api--examples) + - [Installation](#installation) + - [Usage](#usage) + - [Lifecycle](#lifecycle) + - [Ref](#ref) + - [ShallowRef](#shallowref) + - [Reactive](#reactive) + - [Computed](#computed) + - [Watch](#watch) + - [EffectScope](#effectscope) + - [Reactivity](#reactivity) + - [S](#s) + - [API](#api) + - [Development](#development) + - [Changelog](#changelog) + - [License](#license) ## Installation @@ -276,7 +286,40 @@ export const Component: React.FC = () => { ) } ``` +## SetupComponents +```tsx +//define a setupComponent +const Temp = defineSetupComponent({ + setup(p: { prop1: string }) { + const a = ref(1); + const data = reactive({ + count: 1, + add() { + this.count++; + }, + }); + return { + a, + data, + p: p.prop1, + }; + }, + render(ctx) { + return ( +
+

{ctx.p}

+

{ctx.data.count}

+

{ctx.a.value}

+ + +
+ ); + }, +}); +``` ## API All APIs listed here are implemented and provided by Veact. For additional exported types, please refer to [`index.ts`](/src/index.ts). diff --git "a/\350\256\241\345\210\222.md" "b/\350\256\241\345\210\222.md" new file mode 100644 index 0000000..3f7b54d --- /dev/null +++ "b/\350\256\241\345\210\222.md" @@ -0,0 +1,7 @@ +# 计划 +- [ ] 添加局部监听器支持,添加observe函数与Observer组件,实现可选全组件刷新与可选局部刷新 +- [ ] 添加vite插件支持自动处理template标签并处理其中的style + - [ ] 可选支持属性区分 + - [ ] 可选支持类prefix支持(纯class支持) +- [ ] 获取react的Internal dispatcher中的唯一id进行组件标记 +- [ ] 改为直接链接到memoriedState,避免直接使用hook(待定) From d9e5f6c3598e6b085308b0126c42286191fdadd2 Mon Sep 17 00:00:00 2001 From: gmono Date: Wed, 18 Sep 2024 20:50:45 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/setup/setupComponents.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/setupComponents.tsx b/src/setup/setupComponents.tsx index 9194719..443f63b 100644 --- a/src/setup/setupComponents.tsx +++ b/src/setup/setupComponents.tsx @@ -18,14 +18,14 @@ export function SetupComponentRenderer(p: { let t = p.target.setup(p.props); return t; }); - const tt=useReactivityObject(store) + const t=useReactivityObject(()=>store) // let t = mapValues(store, (v, k) => { // if (isRef(v) || isReactive(v)) { // return useReactivity(() => v); // } else return v; // }); const RenderComp = p.target.render; - return ; + return ; } /** From 3ed268ec1947f86a80edf8bd64624d84787f7ec1 Mon Sep 17 00:00:00 2001 From: gmono Date: Thu, 19 Sep 2024 09:49:14 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8F=90=E4=BA=A4dist?= =?UTF-8?q?=E5=85=81=E8=AE=B8git=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- dist/veact.d.ts | 423 ++++++++++ dist/veact.js | 1819 ++++++++++++++++++++++++++++++++++++++++++++ dist/veact.umd.cjs | 41 + 4 files changed, 2284 insertions(+), 1 deletion(-) create mode 100644 dist/veact.d.ts create mode 100644 dist/veact.js create mode 100644 dist/veact.umd.cjs diff --git a/.gitignore b/.gitignore index 44d7873..f93a576 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ npm-debug.log # output -dist +# dist # Test Relative Folders coverage diff --git a/dist/veact.d.ts b/dist/veact.d.ts new file mode 100644 index 0000000..5963a4c --- /dev/null +++ b/dist/veact.d.ts @@ -0,0 +1,423 @@ +import { watch as baseWatch } from '@vue/reactivity'; +import { ComputedGetter } from '@vue/reactivity'; +import { ComputedRef } from '@vue/reactivity'; +import { CustomRefFactory } from '@vue/reactivity'; +import { DebuggerOptions } from '@vue/reactivity'; +import { DeepReadonly } from '@vue/reactivity'; +import { default as default_2 } from 'react'; +import { EffectScope } from '@vue/reactivity'; +import { effectScope } from '@vue/reactivity'; +import { MutableRefObject } from 'react'; +import { ReactElement } from 'react'; +import { Reactive } from '@vue/reactivity'; +import { ReactiveMarker } from '@vue/reactivity'; +import { Ref } from '@vue/reactivity'; +import { ShallowReactive } from '@vue/reactivity'; +import { ShallowRef } from '@vue/reactivity'; +import { UnwrapNestedRefs } from '@vue/reactivity'; +import { UnwrapRef } from '@vue/reactivity'; +import { WatchCallback } from '@vue/reactivity'; +import { WatchEffect } from '@vue/reactivity'; +import { WatchHandle } from '@vue/reactivity'; +import { WatchSource } from '@vue/reactivity'; +import { WritableComputedOptions } from '@vue/reactivity'; +import { WritableComputedRef } from '@vue/reactivity'; + +/** + * @module veact.utils + * @author Surmon + */ +declare type ArgumentTypes = F extends (...args: infer A) => any ? A : never; + +export { baseWatch } + +/** + * 定义一个veact组件 + * @param v 类似vue的定义对象 + * @returns + */ +export declare function defineSetupComponent(v: ISetupComponent): (props: P) => default_2.JSX.Element; + +declare type IfAny = 0 extends 1 & T ? Y : N; + +export declare interface ISetupComponent { + setup(p: P): T; + render(ctx: T): ReactElement; +} + +declare type MapSources = { + [K in keyof T]: T[K] extends WatchSource ? MaybeUndefined : T[K] extends object ? MaybeUndefined : never; +}; + +declare type MaybeUndefined = I extends true ? T | undefined : T; + +export declare type MultiWatchSources = (WatchSource | object)[]; + +/** + * The function is called right before the component is unmounted. + * + * @param fn + * @see {@link https://react.dev/reference/react/Component#componentwillunmount React `componentWillUnmount()`} + */ +export declare function onBeforeUnmount(fn: () => void): void; + +/** + * @module veact.lifecycle + * @author Surmon + */ +/** + * The function is called right after the component is mounted. + * + * @param fn + * @see {@link https://react.dev/reference/react/Component#componentdidmount React `componentDidMount()`} + */ +export declare function onMounted(fn: () => any): void; + +/** + * The function is called immediately after the component is re-rendered with updated props or state. + * This method is not invoked during the initial render. + * + * @param fn + * @see {@link https://react.dev/reference/react/Component#componentdidupdate React `componentDidUpdate()`} + */ +export declare function onUpdated(fn: () => void): void; + +export declare function SetupComponentRenderer(p: { + target: ISetupComponent; + props: any; +}): default_2.JSX.Element; + +/** + * Takes a getter function and returns a readonly reactive ref object for the + * returned value from the getter. It can also take an object with get and set + * functions to create a writable ref object. + * + * @param getter - Function that produces the next value. + * @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging Vue Computed Debugging}. + * @see {@link https://vuejs.org/api/reactivity-core.html#computed Vue `computed()`} + * + * @example + * ```js + * // Creating a readonly computed ref: + * const count = useRef(1) + * const plusOne = useComputed(() => count.value + 1) + * + * console.log(plusOne.value) // 2 + * plusOne.value++ // error + * ``` + * + * @example + * ```js + * // Creating a writable computed ref: + * const count = useRef(1) + * const plusOne = useComputed({ + * get: () => count.value + 1, + * set: (val) => { + * count.value = val - 1 + * } + * }) + * + * plusOne.value = 1 + * console.log(count.value) // 0 + * ``` + */ +export declare function useComputed(getter: ComputedGetter, debugOptions?: DebuggerOptions): ComputedRef; + +export declare function useComputed(options: WritableComputedOptions, debugOptions?: DebuggerOptions): WritableComputedRef; + +/** + * Creates a customized ref with explicit control over its dependency tracking + * and updates triggering. + * + * @param factory - The function that receives the `track` and `trigger` callbacks. + * @see {@link https://vuejs.org/api/reactivity-advanced.html#customref Vue `customRef()`} + */ +export declare function useCustomRef(factory: CustomRefFactory): Ref; + +/** + * Creates an effect scope object which can capture the reactive effects (i.e. + * computed and watchers) created within it so that these effects can be + * disposed together. For detailed use cases of this API, please consult its + * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}. + * + * @param detached - Can be used to create a "detached" effect scope. + * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope Vue `effectScope()`} + */ +export declare function useEffectScope(...args: ArgumentTypes): EffectScope; + +/** + * Returns a reactive proxy of the object. + * + * The reactive conversion is "deep": it affects all nested properties. A + * reactive object also deeply unwraps any properties that are refs while + * maintaining reactivity. + * + * @param target - The source object. + * @see {@link https://vuejs.org/api/reactivity-core.html#reactive Vue `reactive()`} + * + * @example + * ```js + * const obj = useReactive({ count: 0 }) + * ``` + */ +export declare function useReactive(target: T): Reactive; + +/** + * @module veact.reactivity + * @author Surmon + */ +/** + * Converts some of the 'raw Vue' data, which is not already wrapped in a hook, + * into reactive hook data to ensure proper reactivity within the component. + * + * @param getter - A function that returns the data to be deeply watched. + * @example + * ```tsx + * import React from 'react' + * import { ref, useReactivity } from 'veact' + * + * const countRef = ref(0) + * + * export const Component: React.FC = () => { + * // Convert to a reactivity hook + * const count = useReactivity(() => countRef) + * const increment = () => { + * count.value++ + * } + * + * return ( + *
+ * {count.value} + * + *
+ * ) + * } + * ``` + */ +export declare function useReactivity(getter: () => T): T; + +/** + * Takes an object (reactive or plain) or a ref and returns a readonly proxy to + * the original. + * + * A readonly proxy is deep: any nested property accessed will be readonly as + * well. It also has the same ref-unwrapping behavior as {@link useReactive()}, + * except the unwrapped values will also be made readonly. + * + * @param target - The source object. + * @see {@link https://vuejs.org/api/reactivity-core.html#readonly Vue `readonly()`} + * + * @example + * ```js + * const original = useReactive({ count: 0 }) + * const copy = useReadonly(original) + * + * useWatchEffect(() => { + * // works for reactivity tracking + * console.log(copy.count) + * }) + * + * // mutating original will trigger watchers relying on the copy + * original.count++ + * + * // mutating the copy will fail and result in a warning + * copy.count++ // warning! + * ``` + */ +export declare function useReadonly(target: T): DeepReadonly>; + +/** + * Takes an inner value and returns a reactive and mutable ref object, which + * has a single property `.value` that points to the inner value. + * + * @param value - The object to wrap in the ref. + * @see {@link https://vuejs.org/api/reactivity-core.html#ref Vue `ref()`} + * + * @example + * ```js + * const count = useRef(0) + * console.log(count.value) // 0 + * + * count.value = 1 + * console.log(count.value) // 1 + * ``` + */ +export declare function useRef(value: T): [T] extends [Ref] ? IfAny, T> : Ref, UnwrapRef | T>; + +export declare function useRef(): Ref; + +/** + * Shallow version of {@link useReactive()}. + * + * Unlike {@link useReactive()}, there is no deep conversion: only root-level + * properties are reactive for a shallow reactive object. Property values are + * stored and exposed as-is - this also means properties with ref values will + * not be automatically unwrapped. + * + * @param target - The source object. + * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive Vue `shallowReactive()`} + * + * @example + * ```js + * const state = useShallowReactive({ + * foo: 1, + * nested: { + * bar: 2 + * } + * }) + * + * // mutating state's own properties is reactive + * state.foo++ + * + * // ...but does not convert nested objects + * isReactive(state.nested) // false + * + * // NOT reactive + * state.nested.bar++ + * ``` + */ +export declare function useShallowReactive(target: T): ShallowReactive; + +/** + * Shallow version of {@link useReadonly()}. + * + * Unlike {@link useReadonly()}, there is no deep conversion: only root-level + * properties are made readonly. Property values are stored and exposed as-is - + * this also means properties with ref values will not be automatically + * unwrapped. + * + * @param target - The source object. + * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly Vue `shallowReadonly()`} + * + * @example + * ```js + * const state = useShallowReadonly({ + * foo: 1, + * nested: { + * bar: 2 + * } + * }) + * + * // mutating state's own properties will fail + * state.foo++ + * + * // ...but works on nested objects + * isReadonly(state.nested) // false + * + * // works + * state.nested.bar++ + * ``` + */ +export declare function useShallowReadonly(target: T): Readonly; + +/** + * Shallow version of {@link useRef()}. + * + * @param value - The "inner value" for the shallow ref. + * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref Vue `shallowRef()`} + * + * @example + * ```js + * const state = useShallowRef({ count: 1 }) + * // does NOT trigger change + * state.value.count = 2 + * // does trigger change + * state.value = { count: 2 } + * ``` + */ +export declare function useShallowRef(value: T): Ref extends T ? (T extends Ref ? IfAny, T> : ShallowRef) : ShallowRef; + +export declare function useShallowRef(): ShallowRef; + +/** + * Watches one or more reactive data sources and invokes a callback function when the sources change. + * + * @param source - The watcher's source. + * @param callback - This function will be called when the source is changed. + * @param options - An optional options object that does not support the `flush` option compared to Vue (3.5.0). + * @see {@link https://vuejs.org/api/reactivity-core.html#watch Vue `watch()`} + * + * @example + * ```js + * const count = useRef(0) + * useWatch(count, (count, prevCount) => { + * // ... + * }) + * ``` + */ +export declare const useWatch: (source: any, callback: any, options?: {}) => MutableRefObject; + +/** + * Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed. + * + * @param effect - The effect function to run. + * @param options - An optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies; the `flush` option is not supported compared to Vue (3.5.0). + * @see {@link https://vuejs.org/api/reactivity-core.html#watcheffect Vue `watchEffect()`} + * + * @example + * ```js + * const count = useRef(0) + * useWatchEffect(() => console.log(count.value)) + * // -> logs 0 + * + * count.value++ + * // -> logs 1 + * ``` + */ +export declare const useWatchEffect: typeof watchEffect; + +/** + * Watches one or more reactive data sources and invokes a callback function when the sources change. + * + * @param source - The watcher's source. + * @param callback - This function will be called when the source is changed. + * @param options - An optional options object that does not support the `flush` option compared to Vue (3.5.0). + * @see {@link https://vuejs.org/api/reactivity-core.html#watch Vue `watch()`} + * + * @example + * ```js + * const count = ref(0) + * watch(count, (count, prevCount) => { + * // ... + * }) + * ``` + */ +export declare function watch = false>(source: WatchSource, callback: WatchCallback>, options?: WatchOptions): WatchHandle; + +export declare function watch, Immediate extends Readonly = false>(sources: readonly [...T] | T, callback: [T] extends [ReactiveMarker] ? WatchCallback> : WatchCallback, MapSources>, options?: WatchOptions): WatchHandle; + +export declare function watch = false>(sources: [...T], callback: WatchCallback, MapSources>, options?: WatchOptions): WatchHandle; + +export declare function watch = false>(source: T, callback: WatchCallback>, options?: WatchOptions): WatchHandle; + +/** + * Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed. + * + * @param effectFn - The effect function to run. + * @param options - An optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies; the `flush` option is not supported compared to Vue (3.5.0). + * @see {@link https://vuejs.org/api/reactivity-core.html#watcheffect Vue `watchEffect()`} + * + * @example + * ```js + * const count = ref(0) + * watchEffect(() => console.log(count.value)) + * // -> logs 0 + * + * count.value++ + * // -> logs 1 + * ``` + */ +export declare function watchEffect(effectFn: WatchEffect, options?: WatchEffectOptions): WatchHandle; + +export declare type WatchEffectOptions = DebuggerOptions; + +export declare interface WatchOptions extends DebuggerOptions { + immediate?: Immediate; + deep?: boolean | number; + once?: boolean; +} + + +export * from "@vue/reactivity"; + +export { } diff --git a/dist/veact.js b/dist/veact.js new file mode 100644 index 0000000..ac446c1 --- /dev/null +++ b/dist/veact.js @@ -0,0 +1,1819 @@ +import { watch as sr, isRef as Kr, isReactive as Gr, ref as Xr, shallowRef as Hr, customRef as Zr, reactive as Qr, shallowReactive as et, readonly as rt, shallowReadonly as tt, computed as nt, effectScope as it } from "@vue/reactivity"; +export * from "@vue/reactivity"; +import { watch as vn } from "@vue/reactivity"; +import or, { useRef as ie, useEffect as De, useCallback as be, useReducer as at, useMemo as st, useState as L } from "react"; +/*! + * veact v1.0.0 + * https://github.com/veactjs/veact + * + * Includes @vue/reactivity + * https://github.com/vuejs/core/tree/main/packages/reactivity + * + * (c) 2021-present Surmon and Veact contributors. + * Released under the MIT License. + * + * Date: 2024-09-18T12:50:21.310Z + */ +var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Ce = { exports: {} }, he = {}; +/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var nr; +function ot() { + if (nr) return he; + nr = 1; + var r = or, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, a = { key: !0, ref: !0, __self: !0, __source: !0 }; + function o(l, f, h) { + var d, g = {}, p = null, m = null; + h !== void 0 && (p = "" + h), f.key !== void 0 && (p = "" + f.key), f.ref !== void 0 && (m = f.ref); + for (d in f) i.call(f, d) && !a.hasOwnProperty(d) && (g[d] = f[d]); + if (l && l.defaultProps) for (d in f = l.defaultProps, f) g[d] === void 0 && (g[d] = f[d]); + return { $$typeof: t, type: l, key: p, ref: m, props: g, _owner: s.current }; + } + return he.Fragment = e, he.jsx = o, he.jsxs = o, he; +} +var ve = {}; +/** + * @license React + * react-jsx-runtime.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var ir; +function ut() { + return ir || (ir = 1, process.env.NODE_ENV !== "production" && function() { + var r = or, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), a = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), l = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), h = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), m = Symbol.for("react.offscreen"), A = Symbol.iterator, Y = "@@iterator"; + function J(n) { + if (n === null || typeof n != "object") + return null; + var u = A && n[A] || n[Y]; + return typeof u == "function" ? u : null; + } + var x = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + function k(n) { + { + for (var u = arguments.length, v = new Array(u > 1 ? u - 1 : 0), y = 1; y < u; y++) + v[y - 1] = arguments[y]; + we("error", n, v); + } + } + function we(n, u, v) { + { + var y = x.ReactDebugCurrentFrame, R = y.getStackAddendum(); + R !== "" && (u += "%s", v = v.concat([R])); + var E = v.map(function(w) { + return String(w); + }); + E.unshift("Warning: " + u), Function.prototype.apply.call(console[n], console, E); + } + } + var q = !1, _ = !1, B = !1, O = !1, Z = !1, oe; + oe = Symbol.for("react.module.reference"); + function W(n) { + return !!(typeof n == "string" || typeof n == "function" || n === i || n === a || Z || n === s || n === h || n === d || O || n === m || q || _ || B || typeof n == "object" && n !== null && (n.$$typeof === p || n.$$typeof === g || n.$$typeof === o || n.$$typeof === l || n.$$typeof === f || // This needs to include all possible module reference object + // types supported by any Flight configuration anywhere since + // we don't know which Flight build this will end up being used + // with. + n.$$typeof === oe || n.getModuleId !== void 0)); + } + function ue(n, u, v) { + var y = n.displayName; + if (y) + return y; + var R = u.displayName || u.name || ""; + return R !== "" ? v + "(" + R + ")" : v; + } + function fe(n) { + return n.displayName || "Context"; + } + function M(n) { + if (n == null) + return null; + if (typeof n.tag == "number" && k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof n == "function") + return n.displayName || n.name || null; + if (typeof n == "string") + return n; + switch (n) { + case i: + return "Fragment"; + case e: + return "Portal"; + case a: + return "Profiler"; + case s: + return "StrictMode"; + case h: + return "Suspense"; + case d: + return "SuspenseList"; + } + if (typeof n == "object") + switch (n.$$typeof) { + case l: + var u = n; + return fe(u) + ".Consumer"; + case o: + var v = n; + return fe(v._context) + ".Provider"; + case f: + return ue(n, n.render, "ForwardRef"); + case g: + var y = n.displayName || null; + return y !== null ? y : M(n.type) || "Memo"; + case p: { + var R = n, E = R._payload, w = R._init; + try { + return M(w(E)); + } catch { + return null; + } + } + } + return null; + } + var F = Object.assign, K = 0, Q, G, X, H, de, ze, Ye; + function qe() { + } + qe.__reactDisabledLog = !0; + function wr() { + { + if (K === 0) { + Q = console.log, G = console.info, X = console.warn, H = console.error, de = console.group, ze = console.groupCollapsed, Ye = console.groupEnd; + var n = { + configurable: !0, + enumerable: !0, + value: qe, + writable: !0 + }; + Object.defineProperties(console, { + info: n, + log: n, + warn: n, + error: n, + group: n, + groupCollapsed: n, + groupEnd: n + }); + } + K++; + } + } + function Rr() { + { + if (K--, K === 0) { + var n = { + configurable: !0, + enumerable: !0, + writable: !0 + }; + Object.defineProperties(console, { + log: F({}, n, { + value: Q + }), + info: F({}, n, { + value: G + }), + warn: F({}, n, { + value: X + }), + error: F({}, n, { + value: H + }), + group: F({}, n, { + value: de + }), + groupCollapsed: F({}, n, { + value: ze + }), + groupEnd: F({}, n, { + value: Ye + }) + }); + } + K < 0 && k("disabledDepth fell below zero. This is a bug in React. Please file an issue."); + } + } + var Re = x.ReactCurrentDispatcher, Ee; + function ye(n, u, v) { + { + if (Ee === void 0) + try { + throw Error(); + } catch (R) { + var y = R.stack.trim().match(/\n( *(at )?)/); + Ee = y && y[1] || ""; + } + return ` +` + Ee + n; + } + } + var Oe = !1, pe; + { + var Er = typeof WeakMap == "function" ? WeakMap : Map; + pe = new Er(); + } + function Be(n, u) { + if (!n || Oe) + return ""; + { + var v = pe.get(n); + if (v !== void 0) + return v; + } + var y; + Oe = !0; + var R = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var E; + E = Re.current, Re.current = null, wr(); + try { + if (u) { + var w = function() { + throw Error(); + }; + if (Object.defineProperty(w.prototype, "props", { + set: function() { + throw Error(); + } + }), typeof Reflect == "object" && Reflect.construct) { + try { + Reflect.construct(w, []); + } catch (I) { + y = I; + } + Reflect.construct(n, [], w); + } else { + try { + w.call(); + } catch (I) { + y = I; + } + n.call(w.prototype); + } + } else { + try { + throw Error(); + } catch (I) { + y = I; + } + n(); + } + } catch (I) { + if (I && y && typeof I.stack == "string") { + for (var b = I.stack.split(` +`), D = y.stack.split(` +`), T = b.length - 1, j = D.length - 1; T >= 1 && j >= 0 && b[T] !== D[j]; ) + j--; + for (; T >= 1 && j >= 0; T--, j--) + if (b[T] !== D[j]) { + if (T !== 1 || j !== 1) + do + if (T--, j--, j < 0 || b[T] !== D[j]) { + var U = ` +` + b[T].replace(" at new ", " at "); + return n.displayName && U.includes("") && (U = U.replace("", n.displayName)), typeof n == "function" && pe.set(n, U), U; + } + while (T >= 1 && j >= 0); + break; + } + } + } finally { + Oe = !1, Re.current = E, Rr(), Error.prepareStackTrace = R; + } + var ne = n ? n.displayName || n.name : "", ee = ne ? ye(ne) : ""; + return typeof n == "function" && pe.set(n, ee), ee; + } + function Or(n, u, v) { + return Be(n, !1); + } + function xr(n) { + var u = n.prototype; + return !!(u && u.isReactComponent); + } + function _e(n, u, v) { + if (n == null) + return ""; + if (typeof n == "function") + return Be(n, xr(n)); + if (typeof n == "string") + return ye(n); + switch (n) { + case h: + return ye("Suspense"); + case d: + return ye("SuspenseList"); + } + if (typeof n == "object") + switch (n.$$typeof) { + case f: + return Or(n.render); + case g: + return _e(n.type, u, v); + case p: { + var y = n, R = y._payload, E = y._init; + try { + return _e(E(R), u, v); + } catch { + } + } + } + return ""; + } + var le = Object.prototype.hasOwnProperty, Le = {}, Ve = x.ReactDebugCurrentFrame; + function ge(n) { + if (n) { + var u = n._owner, v = _e(n.type, n._source, u ? u.type : null); + Ve.setExtraStackFrame(v); + } else + Ve.setExtraStackFrame(null); + } + function Sr(n, u, v, y, R) { + { + var E = Function.call.bind(le); + for (var w in n) + if (E(n, w)) { + var b = void 0; + try { + if (typeof n[w] != "function") { + var D = Error((y || "React class") + ": " + v + " type `" + w + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof n[w] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); + throw D.name = "Invariant Violation", D; + } + b = n[w](u, w, y, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); + } catch (T) { + b = T; + } + b && !(b instanceof Error) && (ge(R), k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", y || "React class", v, w, typeof b), ge(null)), b instanceof Error && !(b.message in Le) && (Le[b.message] = !0, ge(R), k("Failed %s type: %s", v, b.message), ge(null)); + } + } + } + var Tr = Array.isArray; + function xe(n) { + return Tr(n); + } + function jr(n) { + { + var u = typeof Symbol == "function" && Symbol.toStringTag, v = u && n[Symbol.toStringTag] || n.constructor.name || "Object"; + return v; + } + } + function kr(n) { + try { + return Ne(n), !1; + } catch { + return !0; + } + } + function Ne(n) { + return "" + n; + } + function Je(n) { + if (kr(n)) + return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", jr(n)), Ne(n); + } + var ce = x.ReactCurrentOwner, Ar = { + key: !0, + ref: !0, + __self: !0, + __source: !0 + }, Ke, Ge, Se; + Se = {}; + function Pr(n) { + if (le.call(n, "ref")) { + var u = Object.getOwnPropertyDescriptor(n, "ref").get; + if (u && u.isReactWarning) + return !1; + } + return n.ref !== void 0; + } + function Cr(n) { + if (le.call(n, "key")) { + var u = Object.getOwnPropertyDescriptor(n, "key").get; + if (u && u.isReactWarning) + return !1; + } + return n.key !== void 0; + } + function Mr(n, u) { + if (typeof n.ref == "string" && ce.current && u && ce.current.stateNode !== u) { + var v = M(ce.current.type); + Se[v] || (k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', M(ce.current.type), n.ref), Se[v] = !0); + } + } + function Dr(n, u) { + { + var v = function() { + Ke || (Ke = !0, k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u)); + }; + v.isReactWarning = !0, Object.defineProperty(n, "key", { + get: v, + configurable: !0 + }); + } + } + function Fr(n, u) { + { + var v = function() { + Ge || (Ge = !0, k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u)); + }; + v.isReactWarning = !0, Object.defineProperty(n, "ref", { + get: v, + configurable: !0 + }); + } + } + var Ir = function(n, u, v, y, R, E, w) { + var b = { + // This tag allows us to uniquely identify this as a React Element + $$typeof: t, + // Built-in properties that belong on the element + type: n, + key: u, + ref: v, + props: w, + // Record the component responsible for creating this element. + _owner: E + }; + return b._store = {}, Object.defineProperty(b._store, "validated", { + configurable: !1, + enumerable: !1, + writable: !0, + value: !1 + }), Object.defineProperty(b, "_self", { + configurable: !1, + enumerable: !1, + writable: !1, + value: y + }), Object.defineProperty(b, "_source", { + configurable: !1, + enumerable: !1, + writable: !1, + value: R + }), Object.freeze && (Object.freeze(b.props), Object.freeze(b)), b; + }; + function Wr(n, u, v, y, R) { + { + var E, w = {}, b = null, D = null; + v !== void 0 && (Je(v), b = "" + v), Cr(u) && (Je(u.key), b = "" + u.key), Pr(u) && (D = u.ref, Mr(u, R)); + for (E in u) + le.call(u, E) && !Ar.hasOwnProperty(E) && (w[E] = u[E]); + if (n && n.defaultProps) { + var T = n.defaultProps; + for (E in T) + w[E] === void 0 && (w[E] = T[E]); + } + if (b || D) { + var j = typeof n == "function" ? n.displayName || n.name || "Unknown" : n; + b && Dr(w, j), D && Fr(w, j); + } + return Ir(n, b, D, R, y, ce.current, w); + } + } + var Te = x.ReactCurrentOwner, Xe = x.ReactDebugCurrentFrame; + function te(n) { + if (n) { + var u = n._owner, v = _e(n.type, n._source, u ? u.type : null); + Xe.setExtraStackFrame(v); + } else + Xe.setExtraStackFrame(null); + } + var je; + je = !1; + function ke(n) { + return typeof n == "object" && n !== null && n.$$typeof === t; + } + function He() { + { + if (Te.current) { + var n = M(Te.current.type); + if (n) + return ` + +Check the render method of \`` + n + "`."; + } + return ""; + } + } + function Ur(n) { + return ""; + } + var Ze = {}; + function $r(n) { + { + var u = He(); + if (!u) { + var v = typeof n == "string" ? n : n.displayName || n.name; + v && (u = ` + +Check the top-level render call using <` + v + ">."); + } + return u; + } + } + function Qe(n, u) { + { + if (!n._store || n._store.validated || n.key != null) + return; + n._store.validated = !0; + var v = $r(u); + if (Ze[v]) + return; + Ze[v] = !0; + var y = ""; + n && n._owner && n._owner !== Te.current && (y = " It was passed a child from " + M(n._owner.type) + "."), te(n), k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, y), te(null); + } + } + function er(n, u) { + { + if (typeof n != "object") + return; + if (xe(n)) + for (var v = 0; v < n.length; v++) { + var y = n[v]; + ke(y) && Qe(y, u); + } + else if (ke(n)) + n._store && (n._store.validated = !0); + else if (n) { + var R = J(n); + if (typeof R == "function" && R !== n.entries) + for (var E = R.call(n), w; !(w = E.next()).done; ) + ke(w.value) && Qe(w.value, u); + } + } + } + function zr(n) { + { + var u = n.type; + if (u == null || typeof u == "string") + return; + var v; + if (typeof u == "function") + v = u.propTypes; + else if (typeof u == "object" && (u.$$typeof === f || // Note: Memo only checks outer props here. + // Inner props are checked in the reconciler. + u.$$typeof === g)) + v = u.propTypes; + else + return; + if (v) { + var y = M(u); + Sr(v, n.props, "prop", y, n); + } else if (u.PropTypes !== void 0 && !je) { + je = !0; + var R = M(u); + k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", R || "Unknown"); + } + typeof u.getDefaultProps == "function" && !u.getDefaultProps.isReactClassApproved && k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); + } + } + function Yr(n) { + { + for (var u = Object.keys(n.props), v = 0; v < u.length; v++) { + var y = u[v]; + if (y !== "children" && y !== "key") { + te(n), k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", y), te(null); + break; + } + } + n.ref !== null && (te(n), k("Invalid attribute `ref` supplied to `React.Fragment`."), te(null)); + } + } + var rr = {}; + function tr(n, u, v, y, R, E) { + { + var w = W(n); + if (!w) { + var b = ""; + (n === void 0 || typeof n == "object" && n !== null && Object.keys(n).length === 0) && (b += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); + var D = Ur(); + D ? b += D : b += He(); + var T; + n === null ? T = "null" : xe(n) ? T = "array" : n !== void 0 && n.$$typeof === t ? (T = "<" + (M(n.type) || "Unknown") + " />", b = " Did you accidentally export a JSX literal instead of a component?") : T = typeof n, k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", T, b); + } + var j = Wr(n, u, v, R, E); + if (j == null) + return j; + if (w) { + var U = u.children; + if (U !== void 0) + if (y) + if (xe(U)) { + for (var ne = 0; ne < U.length; ne++) + er(U[ne], n); + Object.freeze && Object.freeze(U); + } else + k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); + else + er(U, n); + } + if (le.call(u, "key")) { + var ee = M(n), I = Object.keys(u).filter(function(Jr) { + return Jr !== "key"; + }), Ae = I.length > 0 ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}"; + if (!rr[ee + Ae]) { + var Nr = I.length > 0 ? "{" + I.join(": ..., ") + ": ...}" : "{}"; + k(`A props object containing a "key" prop is being spread into JSX: + let props = %s; + <%s {...props} /> +React keys must be passed directly to JSX without using spread: + let props = %s; + <%s key={someKey} {...props} />`, Ae, ee, Nr, ee), rr[ee + Ae] = !0; + } + } + return n === i ? Yr(j) : zr(j), j; + } + } + function qr(n, u, v) { + return tr(n, u, v, !0); + } + function Br(n, u, v) { + return tr(n, u, v, !1); + } + var Lr = Br, Vr = qr; + ve.Fragment = i, ve.jsx = Lr, ve.jsxs = Vr; + }()), ve; +} +process.env.NODE_ENV === "production" ? Ce.exports = ot() : Ce.exports = ut(); +var ur = Ce.exports; +function fr(r) { + const t = ie(!0), e = ie(void 0); + return t.current && (t.current = !1, e.current = r()), e.current; +} +function ft(r) { + De(() => { + r(); + }, []); +} +function lr(r) { + De(() => () => { + r(); + }, []); +} +function Xt(r) { + const t = ie(!1); + De(() => { + t.current ? r() : t.current = !0; + }); +} +const Pe = "veact", cr = { + ...console, + log(...r) { + console.log(`[${Pe}]`, ...r); + }, + warn(...r) { + console.warn(`[${Pe}]`, ...r); + }, + error(...r) { + console.error(`[${Pe}]`, ...r); + } +}; +function lt(r, t, e = {}) { + return sr(r, t, { + ...e, + onWarn: cr.warn, + scheduler: (i) => i() + }); +} +const V = (r, t, e = {}) => { + const i = ie(), s = be(() => { + i.current && (i.current(), i.current = void 0); + }, []), a = be(() => { + i.current && s(), i.current = lt(r, () => { + console.log("触发更新"), t(); + }, e); + }, []); + return ft(() => { + console.log("执行监听"), a(); + }), lr(() => { + console.log("取消监听"), s(); + }), fr(() => { + console.log("初始监听"), a(); + }), i; +}, ct = (r) => r + 1, N = () => at(ct, 0)[1]; +var c = {}; +function S(r, e) { + var e = e || {}; + this._head = 0, this._tail = 0, this._capacity = e.capacity, this._capacityMask = 3, this._list = new Array(4), Array.isArray(r) && this._fromArray(r); +} +S.prototype.peekAt = function(t) { + var e = t; + if (e === (e | 0)) { + var i = this.size(); + if (!(e >= i || e < -i)) + return e < 0 && (e += i), e = this._head + e & this._capacityMask, this._list[e]; + } +}; +S.prototype.get = function(t) { + return this.peekAt(t); +}; +S.prototype.peek = function() { + if (this._head !== this._tail) + return this._list[this._head]; +}; +S.prototype.peekFront = function() { + return this.peek(); +}; +S.prototype.peekBack = function() { + return this.peekAt(-1); +}; +Object.defineProperty(S.prototype, "length", { + get: function() { + return this.size(); + } +}); +S.prototype.size = function() { + return this._head === this._tail ? 0 : this._head < this._tail ? this._tail - this._head : this._capacityMask + 1 - (this._head - this._tail); +}; +S.prototype.unshift = function(t) { + if (t === void 0) return this.size(); + var e = this._list.length; + return this._head = this._head - 1 + e & this._capacityMask, this._list[this._head] = t, this._tail === this._head && this._growArray(), this._capacity && this.size() > this._capacity && this.pop(), this._head < this._tail ? this._tail - this._head : this._capacityMask + 1 - (this._head - this._tail); +}; +S.prototype.shift = function() { + var t = this._head; + if (t !== this._tail) { + var e = this._list[t]; + return this._list[t] = void 0, this._head = t + 1 & this._capacityMask, t < 2 && this._tail > 1e4 && this._tail <= this._list.length >>> 2 && this._shrinkArray(), e; + } +}; +S.prototype.push = function(t) { + if (t === void 0) return this.size(); + var e = this._tail; + return this._list[e] = t, this._tail = e + 1 & this._capacityMask, this._tail === this._head && this._growArray(), this._capacity && this.size() > this._capacity && this.shift(), this._head < this._tail ? this._tail - this._head : this._capacityMask + 1 - (this._head - this._tail); +}; +S.prototype.pop = function() { + var t = this._tail; + if (t !== this._head) { + var e = this._list.length; + this._tail = t - 1 + e & this._capacityMask; + var i = this._list[this._tail]; + return this._list[this._tail] = void 0, this._head < 2 && t > 1e4 && t <= e >>> 2 && this._shrinkArray(), i; + } +}; +S.prototype.removeOne = function(t) { + var e = t; + if (e === (e | 0) && this._head !== this._tail) { + var i = this.size(), s = this._list.length; + if (!(e >= i || e < -i)) { + e < 0 && (e += i), e = this._head + e & this._capacityMask; + var a = this._list[e], o; + if (t < i / 2) { + for (o = t; o > 0; o--) + this._list[e] = this._list[e = e - 1 + s & this._capacityMask]; + this._list[e] = void 0, this._head = this._head + 1 + s & this._capacityMask; + } else { + for (o = i - 1 - t; o > 0; o--) + this._list[e] = this._list[e = e + 1 + s & this._capacityMask]; + this._list[e] = void 0, this._tail = this._tail - 1 + s & this._capacityMask; + } + return a; + } + } +}; +S.prototype.remove = function(t, e) { + var i = t, s, a = e; + if (i === (i | 0) && this._head !== this._tail) { + var o = this.size(), l = this._list.length; + if (!(i >= o || i < -o || e < 1)) { + if (i < 0 && (i += o), e === 1 || !e) + return s = new Array(1), s[0] = this.removeOne(i), s; + if (i === 0 && i + e >= o) + return s = this.toArray(), this.clear(), s; + i + e > o && (e = o - i); + var f; + for (s = new Array(e), f = 0; f < e; f++) + s[f] = this._list[this._head + i + f & this._capacityMask]; + if (i = this._head + i & this._capacityMask, t + e === o) { + for (this._tail = this._tail - e + l & this._capacityMask, f = e; f > 0; f--) + this._list[i = i + 1 + l & this._capacityMask] = void 0; + return s; + } + if (t === 0) { + for (this._head = this._head + e + l & this._capacityMask, f = e - 1; f > 0; f--) + this._list[i = i + 1 + l & this._capacityMask] = void 0; + return s; + } + if (i < o / 2) { + for (this._head = this._head + t + e + l & this._capacityMask, f = t; f > 0; f--) + this.unshift(this._list[i = i - 1 + l & this._capacityMask]); + for (i = this._head - 1 + l & this._capacityMask; a > 0; ) + this._list[i = i - 1 + l & this._capacityMask] = void 0, a--; + t < 0 && (this._tail = i); + } else { + for (this._tail = i, i = i + e + l & this._capacityMask, f = o - (e + t); f > 0; f--) + this.push(this._list[i++]); + for (i = this._tail; a > 0; ) + this._list[i = i + 1 + l & this._capacityMask] = void 0, a--; + } + return this._head < 2 && this._tail > 1e4 && this._tail <= l >>> 2 && this._shrinkArray(), s; + } + } +}; +S.prototype.splice = function(t, e) { + var i = t; + if (i === (i | 0)) { + var s = this.size(); + if (i < 0 && (i += s), !(i > s)) + if (arguments.length > 2) { + var a, o, l, f = arguments.length, h = this._list.length, d = 2; + if (!s || i < s / 2) { + for (o = new Array(i), a = 0; a < i; a++) + o[a] = this._list[this._head + a & this._capacityMask]; + for (e === 0 ? (l = [], i > 0 && (this._head = this._head + i + h & this._capacityMask)) : (l = this.remove(i, e), this._head = this._head + i + h & this._capacityMask); f > d; ) + this.unshift(arguments[--f]); + for (a = i; a > 0; a--) + this.unshift(o[a - 1]); + } else { + o = new Array(s - (i + e)); + var g = o.length; + for (a = 0; a < g; a++) + o[a] = this._list[this._head + i + e + a & this._capacityMask]; + for (e === 0 ? (l = [], i != s && (this._tail = this._head + i + h & this._capacityMask)) : (l = this.remove(i, e), this._tail = this._tail - g + h & this._capacityMask); d < f; ) + this.push(arguments[d++]); + for (a = 0; a < g; a++) + this.push(o[a]); + } + return l; + } else + return this.remove(i, e); + } +}; +S.prototype.clear = function() { + this._head = 0, this._tail = 0; +}; +S.prototype.isEmpty = function() { + return this._head === this._tail; +}; +S.prototype.toArray = function() { + return this._copyArray(!1); +}; +S.prototype._fromArray = function(t) { + for (var e = 0; e < t.length; e++) this.push(t[e]); +}; +S.prototype._copyArray = function(t) { + var e = [], i = this._list, s = i.length, a; + if (t || this._head > this._tail) { + for (a = this._head; a < s; a++) e.push(i[a]); + for (a = 0; a < this._tail; a++) e.push(i[a]); + } else + for (a = this._head; a < this._tail; a++) e.push(i[a]); + return e; +}; +S.prototype._growArray = function() { + this._head && (this._list = this._copyArray(!0), this._head = 0), this._tail = this._list.length, this._list.length <<= 1, this._capacityMask = this._capacityMask << 1 | 1; +}; +S.prototype._shrinkArray = function() { + this._list.length >>>= 1, this._capacityMask >>>= 1; +}; +var ht = S, hr = { exports: {} }; +(function(r) { + var t = function() { + function e(p, m) { + return m != null && p instanceof m; + } + var i; + try { + i = Map; + } catch { + i = function() { + }; + } + var s; + try { + s = Set; + } catch { + s = function() { + }; + } + var a; + try { + a = Promise; + } catch { + a = function() { + }; + } + function o(p, m, A, Y, J) { + typeof m == "object" && (A = m.depth, Y = m.prototype, J = m.includeNonEnumerable, m = m.circular); + var x = [], k = [], we = typeof Buffer < "u"; + typeof m > "u" && (m = !0), typeof A > "u" && (A = 1 / 0); + function q(_, B) { + if (_ === null) + return null; + if (B === 0) + return _; + var O, Z; + if (typeof _ != "object") + return _; + if (e(_, i)) + O = new i(); + else if (e(_, s)) + O = new s(); + else if (e(_, a)) + O = new a(function(G, X) { + _.then(function(H) { + G(q(H, B - 1)); + }, function(H) { + X(q(H, B - 1)); + }); + }); + else if (o.__isArray(_)) + O = []; + else if (o.__isRegExp(_)) + O = new RegExp(_.source, g(_)), _.lastIndex && (O.lastIndex = _.lastIndex); + else if (o.__isDate(_)) + O = new Date(_.getTime()); + else { + if (we && Buffer.isBuffer(_)) + return Buffer.allocUnsafe ? O = Buffer.allocUnsafe(_.length) : O = new Buffer(_.length), _.copy(O), O; + e(_, Error) ? O = Object.create(_) : typeof Y > "u" ? (Z = Object.getPrototypeOf(_), O = Object.create(Z)) : (O = Object.create(Y), Z = Y); + } + if (m) { + var oe = x.indexOf(_); + if (oe != -1) + return k[oe]; + x.push(_), k.push(O); + } + e(_, i) && _.forEach(function(G, X) { + var H = q(X, B - 1), de = q(G, B - 1); + O.set(H, de); + }), e(_, s) && _.forEach(function(G) { + var X = q(G, B - 1); + O.add(X); + }); + for (var W in _) { + var ue; + Z && (ue = Object.getOwnPropertyDescriptor(Z, W)), !(ue && ue.set == null) && (O[W] = q(_[W], B - 1)); + } + if (Object.getOwnPropertySymbols) + for (var fe = Object.getOwnPropertySymbols(_), W = 0; W < fe.length; W++) { + var M = fe[W], F = Object.getOwnPropertyDescriptor(_, M); + F && !F.enumerable && !J || (O[M] = q(_[M], B - 1), F.enumerable || Object.defineProperty(O, M, { + enumerable: !1 + })); + } + if (J) + for (var K = Object.getOwnPropertyNames(_), W = 0; W < K.length; W++) { + var Q = K[W], F = Object.getOwnPropertyDescriptor(_, Q); + F && F.enumerable || (O[Q] = q(_[Q], B - 1), Object.defineProperty(O, Q, { + enumerable: !1 + })); + } + return O; + } + return q(p, A); + } + o.clonePrototype = function(m) { + if (m === null) + return null; + var A = function() { + }; + return A.prototype = m, new A(); + }; + function l(p) { + return Object.prototype.toString.call(p); + } + o.__objToStr = l; + function f(p) { + return typeof p == "object" && l(p) === "[object Date]"; + } + o.__isDate = f; + function h(p) { + return typeof p == "object" && l(p) === "[object Array]"; + } + o.__isArray = h; + function d(p) { + return typeof p == "object" && l(p) === "[object RegExp]"; + } + o.__isRegExp = d; + function g(p) { + var m = ""; + return p.global && (m += "g"), p.ignoreCase && (m += "i"), p.multiline && (m += "m"), m; + } + return o.__getRegExpFlags = g, o; + }(); + r.exports && (r.exports = t); +})(hr); +var vt = hr.exports, dt = function r(t, e) { + if (t === e) return !0; + if (t && e && typeof t == "object" && typeof e == "object") { + if (t.constructor !== e.constructor) return !1; + var i, s, a; + if (Array.isArray(t)) { + if (i = t.length, i != e.length) return !1; + for (s = i; s-- !== 0; ) + if (!r(t[s], e[s])) return !1; + return !0; + } + if (t.constructor === RegExp) return t.source === e.source && t.flags === e.flags; + if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === e.valueOf(); + if (t.toString !== Object.prototype.toString) return t.toString() === e.toString(); + if (a = Object.keys(t), i = a.length, i !== Object.keys(e).length) return !1; + for (s = i; s-- !== 0; ) + if (!Object.prototype.hasOwnProperty.call(e, a[s])) return !1; + for (s = i; s-- !== 0; ) { + var o = a[s]; + if (!r(t[o], e[o])) return !1; + } + return !0; + } + return t !== t && e !== e; +}, yt = $ && $.__awaiter || function(r, t, e, i) { + function s(a) { + return a instanceof e ? a : new e(function(o) { + o(a); + }); + } + return new (e || (e = Promise))(function(a, o) { + function l(d) { + try { + h(i.next(d)); + } catch (g) { + o(g); + } + } + function f(d) { + try { + h(i.throw(d)); + } catch (g) { + o(g); + } + } + function h(d) { + d.done ? a(d.value) : s(d.value).then(l, f); + } + h((i = i.apply(r, t || [])).next()); + }); +}, re = $ && $.__generator || function(r, t) { + var e = { label: 0, sent: function() { + if (a[0] & 1) throw a[1]; + return a[1]; + }, trys: [], ops: [] }, i, s, a, o; + return o = { next: l(0), throw: l(1), return: l(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() { + return this; + }), o; + function l(h) { + return function(d) { + return f([h, d]); + }; + } + function f(h) { + if (i) throw new TypeError("Generator is already executing."); + for (; e; ) try { + if (i = 1, s && (a = h[0] & 2 ? s.return : h[0] ? s.throw || ((a = s.return) && a.call(s), 0) : s.next) && !(a = a.call(s, h[1])).done) return a; + switch (s = 0, a && (h = [h[0] & 2, a.value]), h[0]) { + case 0: + case 1: + a = h; + break; + case 4: + return e.label++, { value: h[1], done: !1 }; + case 5: + e.label++, s = h[1], h = [0]; + continue; + case 7: + h = e.ops.pop(), e.trys.pop(); + continue; + default: + if (a = e.trys, !(a = a.length > 0 && a[a.length - 1]) && (h[0] === 6 || h[0] === 2)) { + e = 0; + continue; + } + if (h[0] === 3 && (!a || h[1] > a[0] && h[1] < a[3])) { + e.label = h[1]; + break; + } + if (h[0] === 6 && e.label < a[1]) { + e.label = a[1], a = h; + break; + } + if (a && e.label < a[2]) { + e.label = a[2], e.ops.push(h); + break; + } + a[2] && e.ops.pop(), e.trys.pop(); + continue; + } + h = t.call(r, e); + } catch (d) { + h = [6, d], s = 0; + } finally { + i = a = 0; + } + if (h[0] & 5) throw h[1]; + return { value: h[0] ? h[1] : void 0, done: !0 }; + } +}, C = $ && $.__values || function(r) { + var t = typeof Symbol == "function" && Symbol.iterator, e = t && r[t], i = 0; + if (e) return e.call(r); + if (r && typeof r.length == "number") return { + next: function() { + return r && i >= r.length && (r = void 0), { value: r && r[i++], done: !r }; + } + }; + throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined."); +}, me = $ && $.__read || function(r, t) { + var e = typeof Symbol == "function" && r[Symbol.iterator]; + if (!e) return r; + var i = e.call(r), s, a = [], o; + try { + for (; (t === void 0 || t-- > 0) && !(s = i.next()).done; ) a.push(s.value); + } catch (l) { + o = { error: l }; + } finally { + try { + s && !s.done && (e = i.return) && e.call(i); + } finally { + if (o) throw o.error; + } + } + return a; +}, ae = $ && $.__spread || function() { + for (var r = [], t = 0; t < arguments.length; t++) r = r.concat(me(arguments[t])); + return r; +}, Fe = $ && $.__importDefault || function(r) { + return r && r.__esModule ? r : { default: r }; +}; +Object.defineProperty(c, "__esModule", { value: !0 }); +c.cached = c.curry = c.call = c.mapToObj = c.len = c.keys = c.set = c.zipToDict = c.dict = _r = c.list = c.isAsyncIter = c.isIter = c.trustType = c.assertType = c.assert = c.parse = c.json = c.float = c.str = c.int = c.insert = c.max = c.min = c.sample = c.extract = c.byIdx = c.sorted = c.shuffle = c.cartesian = c.zip = c.error = c.print = c.equal = c.not = c.all = c.any = c.enumerate = c.range = c.randint = c.delay = void 0; +function pt(r) { + return yt(this, void 0, void 0, function() { + return re(this, function(t) { + return [2, new Promise(function(e) { + setTimeout(function() { + e(); + }, r); + })]; + }); + }); +} +c.delay = pt; +function Ie(r) { + return Math.floor(Math.random() * r) % r; +} +c.randint = Ie; +function se(r, t, e) { + var i; + return re(this, function(s) { + switch (s.label) { + case 0: + return t == null && e == null ? [5, C(se(0, 1, r))] : [3, 2]; + case 1: + return s.sent(), [3, 8]; + case 2: + return e != null ? [3, 4] : [5, C(se(r, 1, t))]; + case 3: + return s.sent(), [3, 8]; + case 4: + i = r, s.label = 5; + case 5: + return i < e ? [4, i] : [3, 8]; + case 6: + s.sent(), s.label = 7; + case 7: + return i += t, [3, 5]; + case 8: + return [2]; + } + }); +} +c.range = se; +function _t(r) { + var t, e, i, s, a, o, l; + return re(this, function(f) { + switch (f.label) { + case 0: + t = 0, f.label = 1; + case 1: + f.trys.push([1, 6, 7, 8]), e = C(r), i = e.next(), f.label = 2; + case 2: + return i.done ? [3, 5] : (s = i.value, [4, [t++, s]]); + case 3: + f.sent(), f.label = 4; + case 4: + return i = e.next(), [3, 2]; + case 5: + return [3, 8]; + case 6: + return a = f.sent(), o = { error: a }, [3, 8]; + case 7: + try { + i && !i.done && (l = e.return) && l.call(e); + } finally { + if (o) throw o.error; + } + return [7]; + case 8: + return [2]; + } + }); +} +c.enumerate = _t; +function We(r) { + var t, e; + try { + for (var i = C(r), s = i.next(); !s.done; s = i.next()) { + var a = s.value; + if (a) + return !0; + } + } catch (o) { + t = { error: o }; + } finally { + try { + s && !s.done && (e = i.return) && e.call(i); + } finally { + if (t) throw t.error; + } + } + return !1; +} +c.any = We; +function gt(r) { + return !We(vr(r)); +} +c.all = gt; +function vr(r) { + var t, e, i = []; + try { + for (var s = C(r), a = s.next(); !a.done; a = s.next()) { + var o = a.value; + i.push(!o); + } + } catch (l) { + t = { error: l }; + } finally { + try { + a && !a.done && (e = s.return) && e.call(s); + } finally { + if (t) throw t.error; + } + } + return i; +} +c.not = vr; +function bt(r, t) { + var e, i, s, a, o = []; + if (Symbol.iterator in t) + try { + for (var l = C(Ue(r, t)), f = l.next(); !f.done; f = l.next()) { + var h = me(f.value, 2), d = h[0], g = h[1]; + o.push(d.__equal__(g)); + } + } catch (A) { + e = { error: A }; + } finally { + try { + f && !f.done && (i = l.return) && i.call(l); + } finally { + if (e) throw e.error; + } + } + else + try { + for (var p = C(r), m = p.next(); !m.done; m = p.next()) { + var d = m.value; + pr(t) && o.push(d.__equal__(t)); + } + } catch (A) { + s = { error: A }; + } finally { + try { + m && !m.done && (a = p.return) && a.call(p); + } finally { + if (s) throw s.error; + } + } + return o; +} +c.equal = bt; +function mt() { + for (var r = [], t = 0; t < arguments.length; t++) + r[t] = arguments[t]; + console.log.apply(console, ae(r)); +} +c.print = mt; +function wt(r) { + throw r === void 0 && (r = ""), new Error(r); +} +c.error = wt; +function Ue() { + var r, t, e, i, s, a, o, l, f = []; + for (r = 0; r < arguments.length; r++) + f[r] = arguments[r]; + return re(this, function(h) { + switch (h.label) { + case 0: + if (P(f) == 0) + return [2]; + P(f) == 1 && (f = f[0]), t = []; + try { + for (e = C(f), i = e.next(); !i.done; i = e.next()) + s = i.value, t.push(s[Symbol.iterator]()); + } catch (d) { + o = { error: d }; + } finally { + try { + i && !i.done && (l = e.return) && l.call(e); + } finally { + if (o) throw o.error; + } + } + h.label = 1; + case 1: + return a = t.map(function(d) { + return d.next(); + }), We(a.map(function(d) { + return d.done; + })) ? [2, void 0] : [3, 2]; + case 2: + return [4, a.map(function(d) { + return d.value; + })]; + case 3: + h.sent(), h.label = 4; + case 4: + return [3, 1]; + case 5: + return [2]; + } + }); +} +c.zip = Ue; +function ar(r, t) { + var e, i, s, a, o, l, f, h, d, g, p, m, A, Y, J; + return re(this, function(x) { + switch (x.label) { + case 0: + e = [], i = !0, x.label = 1; + case 1: + x.trys.push([1, 13, 14, 15]), s = C(r), a = s.next(), x.label = 2; + case 2: + if (a.done) return [3, 12]; + o = a.value, l = i ? t : e, x.label = 3; + case 3: + x.trys.push([3, 8, 9, 10]), f = (Y = void 0, C(l)), h = f.next(), x.label = 4; + case 4: + return h.done ? [3, 7] : (d = h.value, [4, [o, d]]); + case 5: + x.sent(), i && e.push(d), x.label = 6; + case 6: + return h = f.next(), [3, 4]; + case 7: + return [3, 10]; + case 8: + return g = x.sent(), Y = { error: g }, [3, 10]; + case 9: + try { + h && !h.done && (J = f.return) && J.call(f); + } finally { + if (Y) throw Y.error; + } + return [7]; + case 10: + i = !1, x.label = 11; + case 11: + return a = s.next(), [3, 2]; + case 12: + return [3, 15]; + case 13: + return p = x.sent(), m = { error: p }, [3, 15]; + case 14: + try { + a && !a.done && (A = s.return) && A.call(s); + } finally { + if (m) throw m.error; + } + return [7]; + case 15: + return [2]; + } + }); +} +function dr() { + var r, t, e, i, s, a, o, l, f, h = []; + for (r = 0; r < arguments.length; r++) + h[r] = arguments[r]; + return re(this, function(d) { + switch (d.label) { + case 0: + return P(h) != 2 ? [3, 2] : [5, C(ar(h[0], h[1]))]; + case 1: + return d.sent(), [3, 9]; + case 2: + d.trys.push([2, 7, 8, 9]), t = C(ar(h[0], dr.apply(void 0, ae(h.slice(1))))), e = t.next(), d.label = 3; + case 3: + return e.done ? [3, 6] : (i = me(e.value, 2), s = i[0], a = i[1], [4, ae([s], a)]); + case 4: + d.sent(), d.label = 5; + case 5: + return e = t.next(), [3, 3]; + case 6: + return [3, 9]; + case 7: + return o = d.sent(), l = { error: o }, [3, 9]; + case 8: + try { + e && !e.done && (f = t.return) && f.call(t); + } finally { + if (l) throw l.error; + } + return [7]; + case 9: + return [2]; + } + }); +} +c.cartesian = dr; +var Rt = Fe(ht); +function yr(r) { + var t, e, i = new Rt.default(), s = z(r), a = z(se(P(s))); + a.forEach(function(p) { + return i.push(p); + }); + var o = new Array(P(s)); + try { + for (var l = C(s), f = l.next(); !f.done; f = l.next()) { + var h = f.value, d = Ie(P(i)), g = i.get(d); + i.removeOne(d), o[g] = h; + } + } catch (p) { + t = { error: p }; + } finally { + try { + f && !f.done && (e = l.return) && e.call(l); + } finally { + if (t) throw t.error; + } + } + return o; +} +c.shuffle = yr; +function Et(r, t, e) { + t === void 0 && (t = null); + var i = z(r).sort(function(s, a) { + var o = me([-t(s), -t(a)], 2), l = o[0], f = o[1]; + return l - f; + }); + return i; +} +c.sorted = Et; +function $e(r, t) { + var e = z(r), i = t.map(function(s) { + return e[s]; + }); + return i; +} +c.byIdx = $e; +function Ot(r, t) { + var e = z(r), i = yr(se(P(e))).slice(0, t); + return $e(e, i); +} +c.extract = Ot; +function xt(r, t) { + var e = z(r), i = z(se(P(e))).map(function(s) { + return Ie(P(e)); + }); + return $e(e, i); +} +c.sample = xt; +c.min = Math.min; +c.max = Math.max; +function St(r, t, e) { + var i = [], s = z(r); + return s.forEach(function(a, o) { + t == o && i.push(e), i.push(a); + }), P(s) == t && i.push(e), i; +} +c.insert = St; +function Tt(r) { + return typeof r == "string" ? parseInt(r) : typeof r == "number" ? r | 0 : "toInt" in r ? r.toInt() : 0; +} +c.int = Tt; +function jt(r) { + return Me(r, "object") ? r.toString() : Me(r, "string") ? r : new Number(r).toString(); +} +c.str = jt; +function kt(r) { + return typeof r == "string" ? parseFloat(r) : typeof r == "number" ? r : "toFloat" in r ? r.toFloat() : 0; +} +c.float = kt; +function At(r) { + return JSON.stringify(r); +} +c.json = At; +function Pt(r) { + return JSON.parse(r); +} +c.parse = Pt; +function Ct(r, t) { + if (!r) + throw new Error(t ?? "错误"); +} +c.assert = Ct; +function Me(r, t) { + if (typeof t == "string") + return typeof r == t; + if (typeof t == "function") + return r instanceof t; +} +c.assertType = Me; +function pr(r) { + return !0; +} +c.trustType = pr; +function Mt(r) { + return Symbol.iterator in r; +} +c.isIter = Mt; +function Dt(r) { + return Symbol.asyncIterator in r && !(Symbol.iterator in r); +} +c.isAsyncIter = Dt; +function z(r) { + var t, e; + if (r == null) + return z([]); + var i = []; + try { + for (var s = C(r), a = s.next(); !a.done; a = s.next()) { + var o = a.value; + i.push(o); + } + } catch (l) { + t = { error: l }; + } finally { + try { + a && !a.done && (e = s.return) && e.call(s); + } finally { + if (t) throw t.error; + } + } + return i; +} +var _r = c.list = z; +function gr(r) { + return new Map(r); +} +c.dict = gr; +function Ft(r, t) { + return gr(Ue(r, t)); +} +c.zipToDict = Ft; +function It(r) { + return new Set(r); +} +c.set = It; +function Wt(r) { + var t, e, i, s, a, o, l, f, h, d; + return re(this, function(g) { + switch (g.label) { + case 0: + if (!(r instanceof Map)) return [3, 9]; + g.label = 1; + case 1: + g.trys.push([1, 6, 7, 8]), t = C(r.keys()), e = t.next(), g.label = 2; + case 2: + return e.done ? [3, 5] : (i = e.value, [4, i]); + case 3: + g.sent(), g.label = 4; + case 4: + return e = t.next(), [3, 2]; + case 5: + return [3, 8]; + case 6: + return s = g.sent(), h = { error: s }, [3, 8]; + case 7: + try { + e && !e.done && (d = t.return) && d.call(t); + } finally { + if (h) throw h.error; + } + return [7]; + case 8: + return [3, 13]; + case 9: + if (typeof r != "object") return [3, 13]; + a = []; + for (o in r) + a.push(o); + l = 0, g.label = 10; + case 10: + return l < a.length ? (f = a[l], [4, f]) : [3, 13]; + case 11: + g.sent(), g.label = 12; + case 12: + return l++, [3, 10]; + case 13: + return [2]; + } + }); +} +c.keys = Wt; +function P(r) { + if ("length" in r) + return r.length; + if ("size" in r) + return r.size; + if ("count" in r) + return r.count; + if ("__len__" in r) + return r.__len__(); + if (Symbol.iterator in r) + return P(z(r)); + if (typeof r == "object") { + var t = 0; + for (var e in r) + t++; + return t; + } +} +c.len = P; +function Ut(r) { + r === void 0 && (r = /* @__PURE__ */ new Map()); + var t = new Proxy({}, { + get: function(e, i, s) { + return r.get(i); + }, + set: function(e, i, s, a) { + return r.set(i, s), !0; + }, + has: function(e, i) { + return r.has(i); + }, + deleteProperty: function(e, i) { + return r.delete(i); + }, + defineProperty: function(e, i, s) { + return r.set(i, s.value), !0; + }, + ownKeys: function(e) { + return z(r.keys()); + } + }); + return t; +} +c.mapToObj = Ut; +function $t(r) { + r(); +} +c.call = $t; +function br(r, t) { + return t === void 0 && (t = []), function(e) { + var i = P(t) + 1, s = t.concat([e]); + return i == P(r) ? r.apply(void 0, ae(s)) : br(r, s); + }; +} +function zt(r) { + function t() { + for (var e, i, s = [], a = 0; a < arguments.length; a++) + s[a] = arguments[a]; + var o = r; + try { + for (var l = C(s), f = l.next(); !f.done; f = l.next()) { + var h = f.value; + o = o(h); + } + } catch (d) { + e = { error: d }; + } finally { + try { + f && !f.done && (i = l.return) && i.call(l); + } finally { + if (e) throw e.error; + } + } + return o; + } + return t; +} +function mr(r, t, e) { + t === void 0 && (t = 0), e === void 0 && (e = null), e == null && (e = r); + var i = br(r), s = zt(i), a = function() { + for (var o = [], l = 0; l < arguments.length; l++) + o[l] = arguments[l]; + var f = s.apply(void 0, ae(o)); + if (t + P(o) == P(e)) + return f; + var h = mr(f, t + P(o), e); + return h; + }; + return a; +} +c.curry = mr; +var Yt = Fe(vt), qt = Fe(dt); +function Bt(r) { + var t = !1, e = null, i = null; + return function() { + for (var s = [], a = 0; a < arguments.length; a++) + s[a] = arguments[a]; + if (!t || i !== s || !qt.default(s, i)) + return t = !0, e = r.apply(void 0, ae(s)), i = Yt.default(s), e; + }; +} +c.cached = Bt; +function Ht(r) { + const t = N(); + return V(() => r(), t, { deep: !0 }), r(); +} +function Lt(r) { + function* t() { + for (let e in r) + yield r[e]; + } + return _r(t()); +} +function Vt(r) { + const t = N(), e = be(() => { + const s = r(); + return Lt(s).filter((o) => Kr(o) || Gr(o)); + }, [r]), i = st(() => e(), [e]); + return V(() => i, t, { deep: !0 }), r(); +} +function Nt(r) { + const t = fr(() => r.target.setup(r.props)), e = Vt(() => t), i = r.target.render; + return /* @__PURE__ */ ur.jsx(i, { ...e }); +} +function Zt(r) { + return (t) => /* @__PURE__ */ ur.jsx(Nt, { target: r, props: t }); +} +function Qt(r) { + const [t] = L(() => Xr(r)), e = N(); + return V(t, e, { deep: !0 }), t; +} +function en(r) { + const [t] = L(() => Hr(r)), e = N(); + return V(t, e), t; +} +function rn(r) { + const [t] = L(() => Zr(r)), e = N(); + return V(t, e), t; +} +function tn(r) { + const [t] = L(() => Qr(r)), e = N(); + return V(t, e), t; +} +function nn(r) { + const [t] = L(() => et(r)), e = N(); + return V(t, e), t; +} +function an(r) { + const [t] = L(() => rt(r)), e = N(); + return V(t, e), t; +} +function sn(r) { + const [t] = L(() => tt(r)), e = N(); + return V(t, e), t; +} +function on(r, t) { + const [e] = L(() => nt(r, t)), i = N(); + return V(e, i), e; +} +function Jt(r, t = {}) { + return sr(r, null, { + ...t, + onWarn: cr.warn, + scheduler: (e) => e() + }); +} +const un = (r, t) => { + const [e] = L(() => Jt(r, t)); + return lr(() => e.stop()), e; +}; +function fn(...r) { + const t = ie(!1), [e] = L(() => it(...r)), i = ie(e.run), s = be((a) => { + if (!t.current) + return t.current = !0, i.current.bind(e)(a); + }, []); + return e.run = s, e; +} +export { + Nt as SetupComponentRenderer, + vn as baseWatch, + Zt as defineSetupComponent, + lr as onBeforeUnmount, + ft as onMounted, + Xt as onUpdated, + on as useComputed, + rn as useCustomRef, + fn as useEffectScope, + tn as useReactive, + Ht as useReactivity, + an as useReadonly, + Qt as useRef, + nn as useShallowReactive, + sn as useShallowReadonly, + en as useShallowRef, + V as useWatch, + un as useWatchEffect, + lt as watch, + Jt as watchEffect +}; diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs new file mode 100644 index 0000000..7845e72 --- /dev/null +++ b/dist/veact.umd.cjs @@ -0,0 +1,41 @@ +(function(E,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("@vue/reactivity"),require("react")):typeof define=="function"&&define.amd?define(["exports","@vue/reactivity","react"],P):(E=typeof globalThis<"u"?globalThis:E||self,P(E.veact={},E.VueReactivity,E.React))})(this,function(E,P,O){"use strict";/*! + * veact v1.0.0 + * https://github.com/veactjs/veact + * + * Includes @vue/reactivity + * https://github.com/vuejs/core/tree/main/packages/reactivity + * + * (c) 2021-present Surmon and Veact contributors. + * Released under the MIT License. + * + * Date: 2024-09-18T12:50:21.310Z + */var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},we={exports:{}},ue={};/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ye;function Rt(){if(Ye)return ue;Ye=1;var t=O,r=Symbol.for("react.element"),e=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,f,h){var v,g={},p=null,m=null;h!==void 0&&(p=""+h),f.key!==void 0&&(p=""+f.key),f.ref!==void 0&&(m=f.ref);for(v in f)a.call(f,v)&&!i.hasOwnProperty(v)&&(g[v]=f[v]);if(l&&l.defaultProps)for(v in f=l.defaultProps,f)g[v]===void 0&&(g[v]=f[v]);return{$$typeof:r,type:l,key:p,ref:m,props:g,_owner:s.current}}return ue.Fragment=e,ue.jsx=o,ue.jsxs=o,ue}var fe={};/** + * @license React + * react-jsx-runtime.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Be;function Et(){return Be||(Be=1,process.env.NODE_ENV!=="production"&&function(){var t=O,r=Symbol.for("react.element"),e=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),D=Symbol.iterator,J="@@iterator";function H(n){if(n===null||typeof n!="object")return null;var u=D&&n[D]||n[J];return typeof u=="function"?u:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function A(n){{for(var u=arguments.length,d=new Array(u>1?u-1:0),y=1;y=1&&C>=0&&b[x]!==W[C];)C--;for(;x>=1&&C>=0;x--,C--)if(b[x]!==W[C]){if(x!==1||C!==1)do if(x--,C--,C<0||b[x]!==W[C]){var L=` +`+b[x].replace(" at new "," at ");return n.displayName&&L.includes("")&&(L=L.replace("",n.displayName)),typeof n=="function"&&ge.set(n,L),L}while(x>=1&&C>=0);break}}}finally{Me=!1,Ce.current=S,br(),Error.prepareStackTrace=R}var oe=n?n.displayName||n.name:"",ne=oe?_e(oe):"";return typeof n=="function"&&ge.set(n,ne),ne}function wr(n,u,d){return ut(n,!1)}function Rr(n){var u=n.prototype;return!!(u&&u.isReactComponent)}function be(n,u,d){if(n==null)return"";if(typeof n=="function")return ut(n,Rr(n));if(typeof n=="string")return _e(n);switch(n){case h:return _e("Suspense");case v:return _e("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case f:return wr(n.render);case g:return be(n.type,u,d);case p:{var y=n,R=y._payload,S=y._init;try{return be(S(R),u,d)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,ft={},lt=k.ReactDebugCurrentFrame;function me(n){if(n){var u=n._owner,d=be(n.type,n._source,u?u.type:null);lt.setExtraStackFrame(d)}else lt.setExtraStackFrame(null)}function Er(n,u,d,y,R){{var S=Function.call.bind(de);for(var w in n)if(S(n,w)){var b=void 0;try{if(typeof n[w]!="function"){var W=Error((y||"React class")+": "+d+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}b=n[w](u,w,y,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){b=x}b&&!(b instanceof Error)&&(me(R),A("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",d,w,typeof b),me(null)),b instanceof Error&&!(b.message in ft)&&(ft[b.message]=!0,me(R),A("Failed %s type: %s",d,b.message),me(null))}}}var Or=Array.isArray;function De(n){return Or(n)}function Sr(n){{var u=typeof Symbol=="function"&&Symbol.toStringTag,d=u&&n[Symbol.toStringTag]||n.constructor.name||"Object";return d}}function Tr(n){try{return ct(n),!1}catch{return!0}}function ct(n){return""+n}function ht(n){if(Tr(n))return A("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Sr(n)),ct(n)}var ve=k.ReactCurrentOwner,jr={key:!0,ref:!0,__self:!0,__source:!0},dt,vt,Fe;Fe={};function kr(n){if(de.call(n,"ref")){var u=Object.getOwnPropertyDescriptor(n,"ref").get;if(u&&u.isReactWarning)return!1}return n.ref!==void 0}function xr(n){if(de.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function Pr(n,u){if(typeof n.ref=="string"&&ve.current&&u&&ve.current.stateNode!==u){var d=I(ve.current.type);Fe[d]||(A('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',I(ve.current.type),n.ref),Fe[d]=!0)}}function Cr(n,u){{var d=function(){dt||(dt=!0,A("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"key",{get:d,configurable:!0})}}function Ar(n,u){{var d=function(){vt||(vt=!0,A("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"ref",{get:d,configurable:!0})}}var Mr=function(n,u,d,y,R,S,w){var b={$$typeof:r,type:n,key:u,ref:d,props:w,_owner:S};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function Dr(n,u,d,y,R){{var S,w={},b=null,W=null;d!==void 0&&(ht(d),b=""+d),xr(u)&&(ht(u.key),b=""+u.key),kr(u)&&(W=u.ref,Pr(u,R));for(S in u)de.call(u,S)&&!jr.hasOwnProperty(S)&&(w[S]=u[S]);if(n&&n.defaultProps){var x=n.defaultProps;for(S in x)w[S]===void 0&&(w[S]=x[S])}if(b||W){var C=typeof n=="function"?n.displayName||n.name||"Unknown":n;b&&Cr(w,C),W&&Ar(w,C)}return Mr(n,b,W,R,y,ve.current,w)}}var Ie=k.ReactCurrentOwner,yt=k.ReactDebugCurrentFrame;function se(n){if(n){var u=n._owner,d=be(n.type,n._source,u?u.type:null);yt.setExtraStackFrame(d)}else yt.setExtraStackFrame(null)}var We;We=!1;function Ue(n){return typeof n=="object"&&n!==null&&n.$$typeof===r}function pt(){{if(Ie.current){var n=I(Ie.current.type);if(n)return` + +Check the render method of \``+n+"`."}return""}}function Fr(n){return""}var _t={};function Ir(n){{var u=pt();if(!u){var d=typeof n=="string"?n:n.displayName||n.name;d&&(u=` + +Check the top-level render call using <`+d+">.")}return u}}function gt(n,u){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var d=Ir(u);if(_t[d])return;_t[d]=!0;var y="";n&&n._owner&&n._owner!==Ie.current&&(y=" It was passed a child from "+I(n._owner.type)+"."),se(n),A('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,y),se(null)}}function bt(n,u){{if(typeof n!="object")return;if(De(n))for(var d=0;d",b=" Did you accidentally export a JSX literal instead of a component?"):x=typeof n,A("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,b)}var C=Dr(n,u,d,R,S);if(C==null)return C;if(w){var L=u.children;if(L!==void 0)if(y)if(De(L)){for(var oe=0;oe0?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}";if(!mt[ne+ze]){var Lr=z.length>0?"{"+z.join(": ..., ")+": ...}":"{}";A(`A props object containing a "key" prop is being spread into JSX: + let props = %s; + <%s {...props} /> +React keys must be passed directly to JSX without using spread: + let props = %s; + <%s key={someKey} {...props} />`,ze,ne,Lr,ne),mt[ne+ze]=!0}}return n===a?Ur(C):Wr(C),C}}function zr(n,u,d){return wt(n,u,d,!0)}function Yr(n,u,d){return wt(n,u,d,!1)}var Br=Yr,Vr=zr;fe.Fragment=a,fe.jsx=Br,fe.jsxs=Vr}()),fe}process.env.NODE_ENV==="production"?we.exports=Rt():we.exports=Et();var Ve=we.exports;function Le(t){const r=O.useRef(!0),e=O.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}function Ne(t){O.useEffect(()=>{t()},[])}function Re(t){O.useEffect(()=>()=>{t()},[])}function Ot(t){const r=O.useRef(!1);O.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Je={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Ke(t,r,e={}){return P.watch(t,r,{...e,onWarn:Je.warn,scheduler:a=>a()})}const N=(t,r,e={})=>{const a=O.useRef(),s=O.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=O.useCallback(()=>{a.current&&s(),a.current=Ke(t,()=>{console.log("触发更新"),r()},e)},[]);return Ne(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a},St=t=>t+1,X=()=>O.useReducer(St,0)[1];var c={};function j(t,e){var e=e||{};this._head=0,this._tail=0,this._capacity=e.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(t)&&this._fromArray(t)}j.prototype.peekAt=function(r){var e=r;if(e===(e|0)){var a=this.size();if(!(e>=a||e<-a))return e<0&&(e+=a),e=this._head+e&this._capacityMask,this._list[e]}},j.prototype.get=function(r){return this.peekAt(r)},j.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},j.prototype.peekFront=function(){return this.peek()},j.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(j.prototype,"length",{get:function(){return this.size()}}),j.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),e}},j.prototype.push=function(r){if(r===void 0)return this.size();var e=this._tail;return this._list[e]=r,this._tail=e+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&r<=e>>>2&&this._shrinkArray(),a}},j.prototype.removeOne=function(r){var e=r;if(e===(e|0)&&this._head!==this._tail){var a=this.size(),s=this._list.length;if(!(e>=a||e<-a)){e<0&&(e+=a),e=this._head+e&this._capacityMask;var i=this._list[e],o;if(r0;o--)this._list[e]=this._list[e=e-1+s&this._capacityMask];this._list[e]=void 0,this._head=this._head+1+s&this._capacityMask}else{for(o=a-1-r;o>0;o--)this._list[e]=this._list[e=e+1+s&this._capacityMask];this._list[e]=void 0,this._tail=this._tail-1+s&this._capacityMask}return i}}},j.prototype.remove=function(r,e){var a=r,s,i=e;if(a===(a|0)&&this._head!==this._tail){var o=this.size(),l=this._list.length;if(!(a>=o||a<-o||e<1)){if(a<0&&(a+=o),e===1||!e)return s=new Array(1),s[0]=this.removeOne(a),s;if(a===0&&a+e>=o)return s=this.toArray(),this.clear(),s;a+e>o&&(e=o-a);var f;for(s=new Array(e),f=0;f0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(r===0){for(this._head=this._head+e+l&this._capacityMask,f=e-1;f>0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(a0;f--)this.unshift(this._list[a=a-1+l&this._capacityMask]);for(a=this._head-1+l&this._capacityMask;i>0;)this._list[a=a-1+l&this._capacityMask]=void 0,i--;r<0&&(this._tail=a)}else{for(this._tail=a,a=a+e+l&this._capacityMask,f=o-(e+r);f>0;f--)this.push(this._list[a++]);for(a=this._tail;i>0;)this._list[a=a+1+l&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=l>>>2&&this._shrinkArray(),s}}},j.prototype.splice=function(r,e){var a=r;if(a===(a|0)){var s=this.size();if(a<0&&(a+=s),!(a>s))if(arguments.length>2){var i,o,l,f=arguments.length,h=this._list.length,v=2;if(!s||a0&&(this._head=this._head+a+h&this._capacityMask)):(l=this.remove(a,e),this._head=this._head+a+h&this._capacityMask);f>v;)this.unshift(arguments[--f]);for(i=a;i>0;i--)this.unshift(o[i-1])}else{o=new Array(s-(a+e));var g=o.length;for(i=0;ithis._tail){for(i=this._head;i>>=1,this._capacityMask>>>=1};var Tt=j,Ge={exports:{}};(function(t){var r=function(){function e(p,m){return m!=null&&p instanceof m}var a;try{a=Map}catch{a=function(){}}var s;try{s=Set}catch{s=function(){}}var i;try{i=Promise}catch{i=function(){}}function o(p,m,D,J,H){typeof m=="object"&&(D=m.depth,J=m.prototype,H=m.includeNonEnumerable,m=m.circular);var k=[],A=[],Pe=typeof Buffer<"u";typeof m>"u"&&(m=!0),typeof D>"u"&&(D=1/0);function K(_,G){if(_===null)return null;if(G===0)return _;var T,te;if(typeof _!="object")return _;if(e(_,a))T=new a;else if(e(_,s))T=new s;else if(e(_,i))T=new i(function(Q,q){_.then(function($){Q(K($,G-1))},function($){q(K($,G-1))})});else if(o.__isArray(_))T=[];else if(o.__isRegExp(_))T=new RegExp(_.source,g(_)),_.lastIndex&&(T.lastIndex=_.lastIndex);else if(o.__isDate(_))T=new Date(_.getTime());else{if(Pe&&Buffer.isBuffer(_))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(_.length):T=new Buffer(_.length),_.copy(T),T;e(_,Error)?T=Object.create(_):typeof J>"u"?(te=Object.getPrototypeOf(_),T=Object.create(te)):(T=Object.create(J),te=J)}if(m){var le=k.indexOf(_);if(le!=-1)return A[le];k.push(_),A.push(T)}e(_,a)&&_.forEach(function(Q,q){var $=K(q,G-1),pe=K(Q,G-1);T.set($,pe)}),e(_,s)&&_.forEach(function(Q){var q=K(Q,G-1);T.add(q)});for(var Y in _){var ce;te&&(ce=Object.getOwnPropertyDescriptor(te,Y)),!(ce&&ce.set==null)&&(T[Y]=K(_[Y],G-1))}if(Object.getOwnPropertySymbols)for(var he=Object.getOwnPropertySymbols(_),Y=0;Y0&&i[i.length-1])&&(h[0]===6||h[0]===2)){e=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},ye=B&&B.__read||function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var a=e.call(t),s,i=[],o;try{for(;(r===void 0||r-- >0)&&!(s=a.next()).done;)i.push(s.value)}catch(l){o={error:l}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(o)throw o.error}}return i},ae=B&&B.__spread||function(){for(var t=[],r=0;rt(),r,{deep:!0}),t()}function ir(t){function*r(){for(let e in t)yield t[e]}return $e(r())}function sr(t){const r=X(),e=O.useCallback(()=>{const s=t();return ir(s).filter(o=>P.isRef(o)||P.isReactive(o))},[t]),a=O.useMemo(()=>e(),[e]);return N(()=>a,r,{deep:!0}),t()}function nt(t){const r=Le(()=>t.target.setup(t.props)),e=sr(()=>r),a=t.target.render;return Ve.jsx(a,{...e})}function or(t){return r=>Ve.jsx(nt,{target:t,props:r})}function ur(t){const[r]=O.useState(()=>P.ref(t)),e=X();return N(r,e,{deep:!0}),r}function fr(t){const[r]=O.useState(()=>P.shallowRef(t)),e=X();return N(r,e),r}function lr(t){const[r]=O.useState(()=>P.customRef(t)),e=X();return N(r,e),r}function cr(t){const[r]=O.useState(()=>P.reactive(t)),e=X();return N(r,e),r}function hr(t){const[r]=O.useState(()=>P.shallowReactive(t)),e=X();return N(r,e),r}function dr(t){const[r]=O.useState(()=>P.readonly(t)),e=X();return N(r,e),r}function vr(t){const[r]=O.useState(()=>P.shallowReadonly(t)),e=X();return N(r,e),r}function yr(t,r){const[e]=O.useState(()=>P.computed(t,r)),a=X();return N(e,a),e}function at(t,r={}){return P.watch(t,null,{...r,onWarn:Je.warn,scheduler:e=>e()})}const pr=(t,r)=>{const[e]=O.useState(()=>at(t,r));return Re(()=>e.stop()),e};function _r(...t){const r=O.useRef(!1),[e]=O.useState(()=>P.effectScope(...t)),a=O.useRef(e.run),s=O.useCallback(i=>{if(!r.current)return r.current=!0,a.current.bind(e)(i)},[]);return e.run=s,e}Object.defineProperty(E,"baseWatch",{enumerable:!0,get:()=>P.watch}),E.SetupComponentRenderer=nt,E.defineSetupComponent=or,E.onBeforeUnmount=Re,E.onMounted=Ne,E.onUpdated=Ot,E.useComputed=yr,E.useCustomRef=lr,E.useEffectScope=_r,E.useReactive=cr,E.useReactivity=ar,E.useReadonly=dr,E.useRef=ur,E.useShallowReactive=hr,E.useShallowReadonly=vr,E.useShallowRef=fr,E.useWatch=N,E.useWatchEffect=pr,E.watch=Ke,E.watchEffect=at,Object.keys(P).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(E,t)&&Object.defineProperty(E,t,{enumerable:!0,get:()=>P[t]})}),Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}); From 2a3a1131942fb5a2c1192ce369c50a5720845563 Mon Sep 17 00:00:00 2001 From: gmono Date: Thu, 19 Sep 2024 10:19:16 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E6=94=B9=E9=80=A0watch=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/veact.d.ts | 76 +++--- dist/veact.js | 634 +++++++++++++++++++++++---------------------- dist/veact.umd.cjs | 22 +- src/index.ts | 8 +- src/watch.ts | 98 +++---- 5 files changed, 433 insertions(+), 405 deletions(-) diff --git a/dist/veact.d.ts b/dist/veact.d.ts index 5963a4c..ed13493 100644 --- a/dist/veact.d.ts +++ b/dist/veact.d.ts @@ -329,42 +329,54 @@ export declare function useShallowRef(value: T): Ref extends T ? (T extends R export declare function useShallowRef(): ShallowRef; +export declare const useWatch: (InstanceType>>)["watch"]; + /** - * Watches one or more reactive data sources and invokes a callback function when the sources change. + * Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed. * - * @param source - The watcher's source. - * @param callback - This function will be called when the source is changed. - * @param options - An optional options object that does not support the `flush` option compared to Vue (3.5.0). - * @see {@link https://vuejs.org/api/reactivity-core.html#watch Vue `watch()`} + * @param effect - The effect function to run. + * @param options - An optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies; the `flush` option is not supported compared to Vue (3.5.0). + * @see {@link https://vuejs.org/api/reactivity-core.html#watcheffect Vue `watchEffect()`} * * @example * ```js * const count = useRef(0) - * useWatch(count, (count, prevCount) => { - * // ... - * }) + * useWatchEffect(() => console.log(count.value)) + * // -> logs 0 + * + * count.value++ + * // -> logs 1 * ``` */ -export declare const useWatch: (source: any, callback: any, options?: {}) => MutableRefObject; +export declare const useWatchEffect: typeof watchEffect; + +export declare const watch: { + = false>(source: WatchSource, callback: WatchCallback, options?: WatchOptions | undefined): WatchHandle; + , Immediate extends Readonly = false>(sources: T | readonly [...T], callback: [T] extends [ReactiveMarker] ? WatchCallback : WatchCallback< { [K in keyof T]: T[K] extends WatchSource ? V : T[K] extends object ? T[K] : never; }, { [K_1 in keyof T]: T[K_1] extends WatchSource ? Immediate extends true ? V | undefined : V : T[K_1] extends object ? Immediate extends true ? T[K_1] | undefined : T[K_1] : never; }>, options?: WatchOptions | undefined): WatchHandle; + = false>(sources: [...T], callback: WatchCallback< { [K in keyof T]: T[K] extends WatchSource ? V : T[K] extends object ? T[K] : never; }, { [K_1 in keyof T]: T[K_1] extends WatchSource ? Immediate extends true ? V | undefined : V : T[K_1] extends object ? Immediate extends true ? T[K_1] | undefined : T[K_1] : never; }>, options?: WatchOptions | undefined): WatchHandle; + = false>(source: T, callback: WatchCallback, options?: WatchOptions | undefined): WatchHandle; +}; /** * Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed. * - * @param effect - The effect function to run. + * @param effectFn - The effect function to run. * @param options - An optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies; the `flush` option is not supported compared to Vue (3.5.0). * @see {@link https://vuejs.org/api/reactivity-core.html#watcheffect Vue `watchEffect()`} * * @example * ```js - * const count = useRef(0) - * useWatchEffect(() => console.log(count.value)) + * const count = ref(0) + * watchEffect(() => console.log(count.value)) * // -> logs 0 * * count.value++ * // -> logs 1 * ``` */ -export declare const useWatchEffect: typeof watchEffect; +export declare function watchEffect(effectFn: WatchEffect, options?: WatchEffectOptions): WatchHandle; + +export declare type WatchEffectOptions = DebuggerOptions; /** * Watches one or more reactive data sources and invokes a callback function when the sources change. @@ -376,40 +388,36 @@ export declare const useWatchEffect: typeof watchEffect; * * @example * ```js - * const count = ref(0) - * watch(count, (count, prevCount) => { + * const count = useRef(0) + * useWatch(count, (count, prevCount) => { * // ... * }) * ``` */ -export declare function watch = false>(source: WatchSource, callback: WatchCallback>, options?: WatchOptions): WatchHandle; - -export declare function watch, Immediate extends Readonly = false>(sources: readonly [...T] | T, callback: [T] extends [ReactiveMarker] ? WatchCallback> : WatchCallback, MapSources>, options?: WatchOptions): WatchHandle; - -export declare function watch = false>(sources: [...T], callback: WatchCallback, MapSources>, options?: WatchOptions): WatchHandle; - -export declare function watch = false>(source: T, callback: WatchCallback>, options?: WatchOptions): WatchHandle; +export declare const watcherInstance: WatchHelper; /** - * Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed. + * Watches one or more reactive data sources and invokes a callback function when the sources change. * - * @param effectFn - The effect function to run. - * @param options - An optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies; the `flush` option is not supported compared to Vue (3.5.0). - * @see {@link https://vuejs.org/api/reactivity-core.html#watcheffect Vue `watchEffect()`} + * @param source - The watcher's source. + * @param callback - This function will be called when the source is changed. + * @param options - An optional options object that does not support the `flush` option compared to Vue (3.5.0). + * @see {@link https://vuejs.org/api/reactivity-core.html#watch Vue `watch()`} * * @example * ```js * const count = ref(0) - * watchEffect(() => console.log(count.value)) - * // -> logs 0 - * - * count.value++ - * // -> logs 1 + * watch(count, (count, prevCount) => { + * // ... + * }) * ``` */ -export declare function watchEffect(effectFn: WatchEffect, options?: WatchEffectOptions): WatchHandle; - -export declare type WatchEffectOptions = DebuggerOptions; +declare class WatchHelper { + watch = false>(source: WatchSource, callback: WatchCallback>, options?: WatchOptions): R; + watch, Immediate extends Readonly = false>(sources: readonly [...T] | T, callback: [T] extends [ReactiveMarker] ? WatchCallback> : WatchCallback, MapSources>, options?: WatchOptions): R; + watch = false>(sources: [...T], callback: WatchCallback, MapSources>, options?: WatchOptions): R; + watch = false>(source: T, callback: WatchCallback>, options?: WatchOptions): R; +} export declare interface WatchOptions extends DebuggerOptions { immediate?: Immediate; diff --git a/dist/veact.js b/dist/veact.js index ac446c1..f8469b8 100644 --- a/dist/veact.js +++ b/dist/veact.js @@ -1,7 +1,7 @@ -import { watch as sr, isRef as Kr, isReactive as Gr, ref as Xr, shallowRef as Hr, customRef as Zr, reactive as Qr, shallowReactive as et, readonly as rt, shallowReadonly as tt, computed as nt, effectScope as it } from "@vue/reactivity"; +import or, { useEffect as Fe, useRef as ie, useCallback as be, useReducer as Gr, useMemo as Hr, useState as L } from "react"; +import { watch as ur, isRef as Xr, isReactive as Zr, ref as Qr, shallowRef as et, customRef as rt, reactive as tt, shallowReactive as nt, readonly as it, shallowReadonly as at, computed as st, effectScope as ot } from "@vue/reactivity"; export * from "@vue/reactivity"; -import { watch as vn } from "@vue/reactivity"; -import or, { useRef as ie, useEffect as De, useCallback as be, useReducer as at, useMemo as st, useState as L } from "react"; +import { watch as yn } from "@vue/reactivity"; /*! * veact v1.0.0 * https://github.com/veactjs/veact @@ -12,9 +12,67 @@ import or, { useRef as ie, useEffect as De, useCallback as be, useReducer as at, * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-18T12:50:21.310Z + * Date: 2024-09-19T02:18:20.013Z */ -var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Ce = { exports: {} }, he = {}; +function ut(r) { + Fe(() => { + r(); + }, []); +} +function fr(r) { + Fe(() => () => { + r(); + }, []); +} +function Xt(r) { + const t = ie(!1); + Fe(() => { + t.current ? r() : t.current = !0; + }); +} +const Pe = "veact", lr = { + ...console, + log(...r) { + console.log(`[${Pe}]`, ...r); + }, + warn(...r) { + console.warn(`[${Pe}]`, ...r); + }, + error(...r) { + console.error(`[${Pe}]`, ...r); + } +}; +function cr(r) { + const t = ie(!0), e = ie(void 0); + return t.current && (t.current = !1, e.current = r()), e.current; +} +class ft { + // implementation + watch(t, e, i = {}) { + return ur(t, e, { + ...i, + onWarn: lr.warn, + scheduler: (s) => s() + }); + } +} +const Ce = new ft(), V = (r, t, e = {}) => { + const i = ie(), s = be(() => { + i.current && (i.current(), i.current = void 0); + }, []), a = be(() => { + i.current && s(), i.current = Ce.watch(r, () => { + console.log("触发更新"), t(); + }, e); + }, []); + return ut(() => { + console.log("执行监听"), a(); + }), fr(() => { + console.log("取消监听"), s(); + }), cr(() => { + console.log("初始监听"), a(); + }), i; +}; +var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Me = { exports: {} }, he = {}; /** * @license React * react-jsx-runtime.production.min.js @@ -24,10 +82,10 @@ var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : ty * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -var nr; -function ot() { - if (nr) return he; - nr = 1; +var ir; +function lt() { + if (ir) return he; + ir = 1; var r = or, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, a = { key: !0, ref: !0, __self: !0, __source: !0 }; function o(l, f, h) { var d, g = {}, p = null, m = null; @@ -48,9 +106,9 @@ var ve = {}; * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -var ir; -function ut() { - return ir || (ir = 1, process.env.NODE_ENV !== "production" && function() { +var ar; +function ct() { + return ar || (ar = 1, process.env.NODE_ENV !== "production" && function() { var r = or, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), a = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), l = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), h = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), m = Symbol.for("react.offscreen"), A = Symbol.iterator, Y = "@@iterator"; function J(n) { if (n === null || typeof n != "object") @@ -140,18 +198,18 @@ function ut() { } return null; } - var F = Object.assign, K = 0, Q, G, X, H, de, ze, Ye; - function qe() { + var F = Object.assign, K = 0, Q, G, H, X, de, Ye, qe; + function Be() { } - qe.__reactDisabledLog = !0; - function wr() { + Be.__reactDisabledLog = !0; + function Rr() { { if (K === 0) { - Q = console.log, G = console.info, X = console.warn, H = console.error, de = console.group, ze = console.groupCollapsed, Ye = console.groupEnd; + Q = console.log, G = console.info, H = console.warn, X = console.error, de = console.group, Ye = console.groupCollapsed, qe = console.groupEnd; var n = { configurable: !0, enumerable: !0, - value: qe, + value: Be, writable: !0 }; Object.defineProperties(console, { @@ -167,7 +225,7 @@ function ut() { K++; } } - function Rr() { + function Er() { { if (K--, K === 0) { var n = { @@ -183,19 +241,19 @@ function ut() { value: G }), warn: F({}, n, { - value: X + value: H }), error: F({}, n, { - value: H + value: X }), group: F({}, n, { value: de }), groupCollapsed: F({}, n, { - value: ze + value: Ye }), groupEnd: F({}, n, { - value: Ye + value: qe }) }); } @@ -218,10 +276,10 @@ function ut() { } var Oe = !1, pe; { - var Er = typeof WeakMap == "function" ? WeakMap : Map; - pe = new Er(); + var Or = typeof WeakMap == "function" ? WeakMap : Map; + pe = new Or(); } - function Be(n, u) { + function Le(n, u) { if (!n || Oe) return ""; { @@ -234,7 +292,7 @@ function ut() { var R = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var E; - E = Re.current, Re.current = null, wr(); + E = Re.current, Re.current = null, Rr(); try { if (u) { var w = function() { @@ -287,15 +345,15 @@ function ut() { } } } finally { - Oe = !1, Re.current = E, Rr(), Error.prepareStackTrace = R; + Oe = !1, Re.current = E, Er(), Error.prepareStackTrace = R; } var ne = n ? n.displayName || n.name : "", ee = ne ? ye(ne) : ""; return typeof n == "function" && pe.set(n, ee), ee; } - function Or(n, u, v) { - return Be(n, !1); + function xr(n, u, v) { + return Le(n, !1); } - function xr(n) { + function Sr(n) { var u = n.prototype; return !!(u && u.isReactComponent); } @@ -303,7 +361,7 @@ function ut() { if (n == null) return ""; if (typeof n == "function") - return Be(n, xr(n)); + return Le(n, Sr(n)); if (typeof n == "string") return ye(n); switch (n) { @@ -315,7 +373,7 @@ function ut() { if (typeof n == "object") switch (n.$$typeof) { case f: - return Or(n.render); + return xr(n.render); case g: return _e(n.type, u, v); case p: { @@ -328,15 +386,15 @@ function ut() { } return ""; } - var le = Object.prototype.hasOwnProperty, Le = {}, Ve = x.ReactDebugCurrentFrame; + var le = Object.prototype.hasOwnProperty, Ve = {}, Ne = x.ReactDebugCurrentFrame; function ge(n) { if (n) { var u = n._owner, v = _e(n.type, n._source, u ? u.type : null); - Ve.setExtraStackFrame(v); + Ne.setExtraStackFrame(v); } else - Ve.setExtraStackFrame(null); + Ne.setExtraStackFrame(null); } - function Sr(n, u, v, y, R) { + function Tr(n, u, v, y, R) { { var E = Function.call.bind(le); for (var w in n) @@ -351,42 +409,42 @@ function ut() { } catch (T) { b = T; } - b && !(b instanceof Error) && (ge(R), k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", y || "React class", v, w, typeof b), ge(null)), b instanceof Error && !(b.message in Le) && (Le[b.message] = !0, ge(R), k("Failed %s type: %s", v, b.message), ge(null)); + b && !(b instanceof Error) && (ge(R), k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", y || "React class", v, w, typeof b), ge(null)), b instanceof Error && !(b.message in Ve) && (Ve[b.message] = !0, ge(R), k("Failed %s type: %s", v, b.message), ge(null)); } } } - var Tr = Array.isArray; + var jr = Array.isArray; function xe(n) { - return Tr(n); + return jr(n); } - function jr(n) { + function kr(n) { { var u = typeof Symbol == "function" && Symbol.toStringTag, v = u && n[Symbol.toStringTag] || n.constructor.name || "Object"; return v; } } - function kr(n) { + function Ar(n) { try { - return Ne(n), !1; + return Je(n), !1; } catch { return !0; } } - function Ne(n) { + function Je(n) { return "" + n; } - function Je(n) { - if (kr(n)) - return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", jr(n)), Ne(n); + function Ke(n) { + if (Ar(n)) + return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", kr(n)), Je(n); } - var ce = x.ReactCurrentOwner, Ar = { + var ce = x.ReactCurrentOwner, Pr = { key: !0, ref: !0, __self: !0, __source: !0 - }, Ke, Ge, Se; + }, Ge, He, Se; Se = {}; - function Pr(n) { + function Cr(n) { if (le.call(n, "ref")) { var u = Object.getOwnPropertyDescriptor(n, "ref").get; if (u && u.isReactWarning) @@ -394,7 +452,7 @@ function ut() { } return n.ref !== void 0; } - function Cr(n) { + function Mr(n) { if (le.call(n, "key")) { var u = Object.getOwnPropertyDescriptor(n, "key").get; if (u && u.isReactWarning) @@ -402,16 +460,16 @@ function ut() { } return n.key !== void 0; } - function Mr(n, u) { + function Dr(n, u) { if (typeof n.ref == "string" && ce.current && u && ce.current.stateNode !== u) { var v = M(ce.current.type); Se[v] || (k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', M(ce.current.type), n.ref), Se[v] = !0); } } - function Dr(n, u) { + function Fr(n, u) { { var v = function() { - Ke || (Ke = !0, k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u)); + Ge || (Ge = !0, k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u)); }; v.isReactWarning = !0, Object.defineProperty(n, "key", { get: v, @@ -419,10 +477,10 @@ function ut() { }); } } - function Fr(n, u) { + function Ir(n, u) { { var v = function() { - Ge || (Ge = !0, k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u)); + He || (He = !0, k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u)); }; v.isReactWarning = !0, Object.defineProperty(n, "ref", { get: v, @@ -430,7 +488,7 @@ function ut() { }); } } - var Ir = function(n, u, v, y, R, E, w) { + var Wr = function(n, u, v, y, R, E, w) { var b = { // This tag allows us to uniquely identify this as a React Element $$typeof: t, @@ -459,12 +517,12 @@ function ut() { value: R }), Object.freeze && (Object.freeze(b.props), Object.freeze(b)), b; }; - function Wr(n, u, v, y, R) { + function Ur(n, u, v, y, R) { { var E, w = {}, b = null, D = null; - v !== void 0 && (Je(v), b = "" + v), Cr(u) && (Je(u.key), b = "" + u.key), Pr(u) && (D = u.ref, Mr(u, R)); + v !== void 0 && (Ke(v), b = "" + v), Mr(u) && (Ke(u.key), b = "" + u.key), Cr(u) && (D = u.ref, Dr(u, R)); for (E in u) - le.call(u, E) && !Ar.hasOwnProperty(E) && (w[E] = u[E]); + le.call(u, E) && !Pr.hasOwnProperty(E) && (w[E] = u[E]); if (n && n.defaultProps) { var T = n.defaultProps; for (E in T) @@ -472,9 +530,9 @@ function ut() { } if (b || D) { var j = typeof n == "function" ? n.displayName || n.name || "Unknown" : n; - b && Dr(w, j), D && Fr(w, j); + b && Fr(w, j), D && Ir(w, j); } - return Ir(n, b, D, R, y, ce.current, w); + return Wr(n, b, D, R, y, ce.current, w); } } var Te = x.ReactCurrentOwner, Xe = x.ReactDebugCurrentFrame; @@ -490,7 +548,7 @@ function ut() { function ke(n) { return typeof n == "object" && n !== null && n.$$typeof === t; } - function He() { + function Ze() { { if (Te.current) { var n = M(Te.current.type); @@ -502,13 +560,13 @@ Check the render method of \`` + n + "`."; return ""; } } - function Ur(n) { + function $r(n) { return ""; } - var Ze = {}; - function $r(n) { + var Qe = {}; + function zr(n) { { - var u = He(); + var u = Ze(); if (!u) { var v = typeof n == "string" ? n : n.displayName || n.name; v && (u = ` @@ -518,27 +576,27 @@ Check the top-level render call using <` + v + ">."); return u; } } - function Qe(n, u) { + function er(n, u) { { if (!n._store || n._store.validated || n.key != null) return; n._store.validated = !0; - var v = $r(u); - if (Ze[v]) + var v = zr(u); + if (Qe[v]) return; - Ze[v] = !0; + Qe[v] = !0; var y = ""; n && n._owner && n._owner !== Te.current && (y = " It was passed a child from " + M(n._owner.type) + "."), te(n), k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, y), te(null); } } - function er(n, u) { + function rr(n, u) { { if (typeof n != "object") return; if (xe(n)) for (var v = 0; v < n.length; v++) { var y = n[v]; - ke(y) && Qe(y, u); + ke(y) && er(y, u); } else if (ke(n)) n._store && (n._store.validated = !0); @@ -546,11 +604,11 @@ Check the top-level render call using <` + v + ">."); var R = J(n); if (typeof R == "function" && R !== n.entries) for (var E = R.call(n), w; !(w = E.next()).done; ) - ke(w.value) && Qe(w.value, u); + ke(w.value) && er(w.value, u); } } } - function zr(n) { + function Yr(n) { { var u = n.type; if (u == null || typeof u == "string") @@ -566,7 +624,7 @@ Check the top-level render call using <` + v + ">."); return; if (v) { var y = M(u); - Sr(v, n.props, "prop", y, n); + Tr(v, n.props, "prop", y, n); } else if (u.PropTypes !== void 0 && !je) { je = !0; var R = M(u); @@ -575,7 +633,7 @@ Check the top-level render call using <` + v + ">."); typeof u.getDefaultProps == "function" && !u.getDefaultProps.isReactClassApproved && k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } - function Yr(n) { + function qr(n) { { for (var u = Object.keys(n.props), v = 0; v < u.length; v++) { var y = u[v]; @@ -587,19 +645,19 @@ Check the top-level render call using <` + v + ">."); n.ref !== null && (te(n), k("Invalid attribute `ref` supplied to `React.Fragment`."), te(null)); } } - var rr = {}; - function tr(n, u, v, y, R, E) { + var tr = {}; + function nr(n, u, v, y, R, E) { { var w = W(n); if (!w) { var b = ""; (n === void 0 || typeof n == "object" && n !== null && Object.keys(n).length === 0) && (b += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); - var D = Ur(); - D ? b += D : b += He(); + var D = $r(); + D ? b += D : b += Ze(); var T; n === null ? T = "null" : xe(n) ? T = "array" : n !== void 0 && n.$$typeof === t ? (T = "<" + (M(n.type) || "Unknown") + " />", b = " Did you accidentally export a JSX literal instead of a component?") : T = typeof n, k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", T, b); } - var j = Wr(n, u, v, R, E); + var j = Ur(n, u, v, R, E); if (j == null) return j; if (w) { @@ -608,97 +666,43 @@ Check the top-level render call using <` + v + ">."); if (y) if (xe(U)) { for (var ne = 0; ne < U.length; ne++) - er(U[ne], n); + rr(U[ne], n); Object.freeze && Object.freeze(U); } else k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else - er(U, n); + rr(U, n); } if (le.call(u, "key")) { - var ee = M(n), I = Object.keys(u).filter(function(Jr) { - return Jr !== "key"; + var ee = M(n), I = Object.keys(u).filter(function(Kr) { + return Kr !== "key"; }), Ae = I.length > 0 ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}"; - if (!rr[ee + Ae]) { - var Nr = I.length > 0 ? "{" + I.join(": ..., ") + ": ...}" : "{}"; + if (!tr[ee + Ae]) { + var Jr = I.length > 0 ? "{" + I.join(": ..., ") + ": ...}" : "{}"; k(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; - <%s key={someKey} {...props} />`, Ae, ee, Nr, ee), rr[ee + Ae] = !0; + <%s key={someKey} {...props} />`, Ae, ee, Jr, ee), tr[ee + Ae] = !0; } } - return n === i ? Yr(j) : zr(j), j; + return n === i ? qr(j) : Yr(j), j; } } - function qr(n, u, v) { - return tr(n, u, v, !0); - } function Br(n, u, v) { - return tr(n, u, v, !1); + return nr(n, u, v, !0); } - var Lr = Br, Vr = qr; - ve.Fragment = i, ve.jsx = Lr, ve.jsxs = Vr; + function Lr(n, u, v) { + return nr(n, u, v, !1); + } + var Vr = Lr, Nr = Br; + ve.Fragment = i, ve.jsx = Vr, ve.jsxs = Nr; }()), ve; } -process.env.NODE_ENV === "production" ? Ce.exports = ot() : Ce.exports = ut(); -var ur = Ce.exports; -function fr(r) { - const t = ie(!0), e = ie(void 0); - return t.current && (t.current = !1, e.current = r()), e.current; -} -function ft(r) { - De(() => { - r(); - }, []); -} -function lr(r) { - De(() => () => { - r(); - }, []); -} -function Xt(r) { - const t = ie(!1); - De(() => { - t.current ? r() : t.current = !0; - }); -} -const Pe = "veact", cr = { - ...console, - log(...r) { - console.log(`[${Pe}]`, ...r); - }, - warn(...r) { - console.warn(`[${Pe}]`, ...r); - }, - error(...r) { - console.error(`[${Pe}]`, ...r); - } -}; -function lt(r, t, e = {}) { - return sr(r, t, { - ...e, - onWarn: cr.warn, - scheduler: (i) => i() - }); -} -const V = (r, t, e = {}) => { - const i = ie(), s = be(() => { - i.current && (i.current(), i.current = void 0); - }, []), a = be(() => { - i.current && s(), i.current = lt(r, () => { - console.log("触发更新"), t(); - }, e); - }, []); - return ft(() => { - console.log("执行监听"), a(); - }), lr(() => { - console.log("取消监听"), s(); - }), fr(() => { - console.log("初始监听"), a(); - }), i; -}, ct = (r) => r + 1, N = () => at(ct, 0)[1]; +process.env.NODE_ENV === "production" ? Me.exports = lt() : Me.exports = ct(); +var hr = Me.exports; +const ht = (r) => r + 1, N = () => Gr(ht, 0)[1]; var c = {}; function S(r, e) { var e = e || {}; @@ -874,7 +878,7 @@ S.prototype._growArray = function() { S.prototype._shrinkArray = function() { this._list.length >>>= 1, this._capacityMask >>>= 1; }; -var ht = S, hr = { exports: {} }; +var vt = S, vr = { exports: {} }; (function(r) { var t = function() { function e(p, m) { @@ -918,11 +922,11 @@ var ht = S, hr = { exports: {} }; else if (e(_, s)) O = new s(); else if (e(_, a)) - O = new a(function(G, X) { - _.then(function(H) { - G(q(H, B - 1)); - }, function(H) { - X(q(H, B - 1)); + O = new a(function(G, H) { + _.then(function(X) { + G(q(X, B - 1)); + }, function(X) { + H(q(X, B - 1)); }); }); else if (o.__isArray(_)) @@ -942,12 +946,12 @@ var ht = S, hr = { exports: {} }; return k[oe]; x.push(_), k.push(O); } - e(_, i) && _.forEach(function(G, X) { - var H = q(X, B - 1), de = q(G, B - 1); - O.set(H, de); + e(_, i) && _.forEach(function(G, H) { + var X = q(H, B - 1), de = q(G, B - 1); + O.set(X, de); }), e(_, s) && _.forEach(function(G) { - var X = q(G, B - 1); - O.add(X); + var H = q(G, B - 1); + O.add(H); }); for (var W in _) { var ue; @@ -1001,8 +1005,8 @@ var ht = S, hr = { exports: {} }; return o.__getRegExpFlags = g, o; }(); r.exports && (r.exports = t); -})(hr); -var vt = hr.exports, dt = function r(t, e) { +})(vr); +var dt = vr.exports, yt = function r(t, e) { if (t === e) return !0; if (t && e && typeof t == "object" && typeof e == "object") { if (t.constructor !== e.constructor) return !1; @@ -1026,7 +1030,7 @@ var vt = hr.exports, dt = function r(t, e) { return !0; } return t !== t && e !== e; -}, yt = $ && $.__awaiter || function(r, t, e, i) { +}, pt = $ && $.__awaiter || function(r, t, e, i) { function s(a) { return a instanceof e ? a : new e(function(o) { o(a); @@ -1139,13 +1143,13 @@ var vt = hr.exports, dt = function r(t, e) { }, ae = $ && $.__spread || function() { for (var r = [], t = 0; t < arguments.length; t++) r = r.concat(me(arguments[t])); return r; -}, Fe = $ && $.__importDefault || function(r) { +}, Ie = $ && $.__importDefault || function(r) { return r && r.__esModule ? r : { default: r }; }; Object.defineProperty(c, "__esModule", { value: !0 }); -c.cached = c.curry = c.call = c.mapToObj = c.len = c.keys = c.set = c.zipToDict = c.dict = _r = c.list = c.isAsyncIter = c.isIter = c.trustType = c.assertType = c.assert = c.parse = c.json = c.float = c.str = c.int = c.insert = c.max = c.min = c.sample = c.extract = c.byIdx = c.sorted = c.shuffle = c.cartesian = c.zip = c.error = c.print = c.equal = c.not = c.all = c.any = c.enumerate = c.range = c.randint = c.delay = void 0; -function pt(r) { - return yt(this, void 0, void 0, function() { +c.cached = c.curry = c.call = c.mapToObj = c.len = c.keys = c.set = c.zipToDict = c.dict = gr = c.list = c.isAsyncIter = c.isIter = c.trustType = c.assertType = c.assert = c.parse = c.json = c.float = c.str = c.int = c.insert = c.max = c.min = c.sample = c.extract = c.byIdx = c.sorted = c.shuffle = c.cartesian = c.zip = c.error = c.print = c.equal = c.not = c.all = c.any = c.enumerate = c.range = c.randint = c.delay = void 0; +function _t(r) { + return pt(this, void 0, void 0, function() { return re(this, function(t) { return [2, new Promise(function(e) { setTimeout(function() { @@ -1155,11 +1159,11 @@ function pt(r) { }); }); } -c.delay = pt; -function Ie(r) { +c.delay = _t; +function We(r) { return Math.floor(Math.random() * r) % r; } -c.randint = Ie; +c.randint = We; function se(r, t, e) { var i; return re(this, function(s) { @@ -1186,7 +1190,7 @@ function se(r, t, e) { }); } c.range = se; -function _t(r) { +function gt(r) { var t, e, i, s, a, o, l; return re(this, function(f) { switch (f.label) { @@ -1216,8 +1220,8 @@ function _t(r) { } }); } -c.enumerate = _t; -function We(r) { +c.enumerate = gt; +function Ue(r) { var t, e; try { for (var i = C(r), s = i.next(); !s.done; s = i.next()) { @@ -1236,12 +1240,12 @@ function We(r) { } return !1; } -c.any = We; -function gt(r) { - return !We(vr(r)); +c.any = Ue; +function bt(r) { + return !Ue(dr(r)); } -c.all = gt; -function vr(r) { +c.all = bt; +function dr(r) { var t, e, i = []; try { for (var s = C(r), a = s.next(); !a.done; a = s.next()) { @@ -1259,12 +1263,12 @@ function vr(r) { } return i; } -c.not = vr; -function bt(r, t) { +c.not = dr; +function mt(r, t) { var e, i, s, a, o = []; if (Symbol.iterator in t) try { - for (var l = C(Ue(r, t)), f = l.next(); !f.done; f = l.next()) { + for (var l = C($e(r, t)), f = l.next(); !f.done; f = l.next()) { var h = me(f.value, 2), d = h[0], g = h[1]; o.push(d.__equal__(g)); } @@ -1281,7 +1285,7 @@ function bt(r, t) { try { for (var p = C(r), m = p.next(); !m.done; m = p.next()) { var d = m.value; - pr(t) && o.push(d.__equal__(t)); + _r(t) && o.push(d.__equal__(t)); } } catch (A) { s = { error: A }; @@ -1294,18 +1298,18 @@ function bt(r, t) { } return o; } -c.equal = bt; -function mt() { +c.equal = mt; +function wt() { for (var r = [], t = 0; t < arguments.length; t++) r[t] = arguments[t]; console.log.apply(console, ae(r)); } -c.print = mt; -function wt(r) { +c.print = wt; +function Rt(r) { throw r === void 0 && (r = ""), new Error(r); } -c.error = wt; -function Ue() { +c.error = Rt; +function $e() { var r, t, e, i, s, a, o, l, f = []; for (r = 0; r < arguments.length; r++) f[r] = arguments[r]; @@ -1331,7 +1335,7 @@ function Ue() { case 1: return a = t.map(function(d) { return d.next(); - }), We(a.map(function(d) { + }), Ue(a.map(function(d) { return d.done; })) ? [2, void 0] : [3, 2]; case 2: @@ -1347,8 +1351,8 @@ function Ue() { } }); } -c.zip = Ue; -function ar(r, t) { +c.zip = $e; +function sr(r, t) { var e, i, s, a, o, l, f, h, d, g, p, m, A, Y, J; return re(this, function(x) { switch (x.label) { @@ -1398,18 +1402,18 @@ function ar(r, t) { } }); } -function dr() { +function yr() { var r, t, e, i, s, a, o, l, f, h = []; for (r = 0; r < arguments.length; r++) h[r] = arguments[r]; return re(this, function(d) { switch (d.label) { case 0: - return P(h) != 2 ? [3, 2] : [5, C(ar(h[0], h[1]))]; + return P(h) != 2 ? [3, 2] : [5, C(sr(h[0], h[1]))]; case 1: return d.sent(), [3, 9]; case 2: - d.trys.push([2, 7, 8, 9]), t = C(ar(h[0], dr.apply(void 0, ae(h.slice(1))))), e = t.next(), d.label = 3; + d.trys.push([2, 7, 8, 9]), t = C(sr(h[0], yr.apply(void 0, ae(h.slice(1))))), e = t.next(), d.label = 3; case 3: return e.done ? [3, 6] : (i = me(e.value, 2), s = i[0], a = i[1], [4, ae([s], a)]); case 4: @@ -1432,17 +1436,17 @@ function dr() { } }); } -c.cartesian = dr; -var Rt = Fe(ht); -function yr(r) { - var t, e, i = new Rt.default(), s = z(r), a = z(se(P(s))); +c.cartesian = yr; +var Et = Ie(vt); +function pr(r) { + var t, e, i = new Et.default(), s = z(r), a = z(se(P(s))); a.forEach(function(p) { return i.push(p); }); var o = new Array(P(s)); try { for (var l = C(s), f = l.next(); !f.done; f = l.next()) { - var h = f.value, d = Ie(P(i)), g = i.get(d); + var h = f.value, d = We(P(i)), g = i.get(d); i.removeOne(d), o[g] = h; } } catch (p) { @@ -1456,8 +1460,8 @@ function yr(r) { } return o; } -c.shuffle = yr; -function Et(r, t, e) { +c.shuffle = pr; +function Ot(r, t, e) { t === void 0 && (t = null); var i = z(r).sort(function(s, a) { var o = me([-t(s), -t(a)], 2), l = o[0], f = o[1]; @@ -1465,79 +1469,79 @@ function Et(r, t, e) { }); return i; } -c.sorted = Et; -function $e(r, t) { +c.sorted = Ot; +function ze(r, t) { var e = z(r), i = t.map(function(s) { return e[s]; }); return i; } -c.byIdx = $e; -function Ot(r, t) { - var e = z(r), i = yr(se(P(e))).slice(0, t); - return $e(e, i); -} -c.extract = Ot; +c.byIdx = ze; function xt(r, t) { + var e = z(r), i = pr(se(P(e))).slice(0, t); + return ze(e, i); +} +c.extract = xt; +function St(r, t) { var e = z(r), i = z(se(P(e))).map(function(s) { - return Ie(P(e)); + return We(P(e)); }); - return $e(e, i); + return ze(e, i); } -c.sample = xt; +c.sample = St; c.min = Math.min; c.max = Math.max; -function St(r, t, e) { +function Tt(r, t, e) { var i = [], s = z(r); return s.forEach(function(a, o) { t == o && i.push(e), i.push(a); }), P(s) == t && i.push(e), i; } -c.insert = St; -function Tt(r) { - return typeof r == "string" ? parseInt(r) : typeof r == "number" ? r | 0 : "toInt" in r ? r.toInt() : 0; -} -c.int = Tt; +c.insert = Tt; function jt(r) { - return Me(r, "object") ? r.toString() : Me(r, "string") ? r : new Number(r).toString(); + return typeof r == "string" ? parseInt(r) : typeof r == "number" ? r | 0 : "toInt" in r ? r.toInt() : 0; } -c.str = jt; +c.int = jt; function kt(r) { - return typeof r == "string" ? parseFloat(r) : typeof r == "number" ? r : "toFloat" in r ? r.toFloat() : 0; + return De(r, "object") ? r.toString() : De(r, "string") ? r : new Number(r).toString(); } -c.float = kt; +c.str = kt; function At(r) { - return JSON.stringify(r); + return typeof r == "string" ? parseFloat(r) : typeof r == "number" ? r : "toFloat" in r ? r.toFloat() : 0; } -c.json = At; +c.float = At; function Pt(r) { + return JSON.stringify(r); +} +c.json = Pt; +function Ct(r) { return JSON.parse(r); } -c.parse = Pt; -function Ct(r, t) { +c.parse = Ct; +function Mt(r, t) { if (!r) throw new Error(t ?? "错误"); } -c.assert = Ct; -function Me(r, t) { +c.assert = Mt; +function De(r, t) { if (typeof t == "string") return typeof r == t; if (typeof t == "function") return r instanceof t; } -c.assertType = Me; -function pr(r) { +c.assertType = De; +function _r(r) { return !0; } -c.trustType = pr; -function Mt(r) { +c.trustType = _r; +function Dt(r) { return Symbol.iterator in r; } -c.isIter = Mt; -function Dt(r) { +c.isIter = Dt; +function Ft(r) { return Symbol.asyncIterator in r && !(Symbol.iterator in r); } -c.isAsyncIter = Dt; +c.isAsyncIter = Ft; function z(r) { var t, e; if (r == null) @@ -1559,20 +1563,20 @@ function z(r) { } return i; } -var _r = c.list = z; -function gr(r) { +var gr = c.list = z; +function br(r) { return new Map(r); } -c.dict = gr; -function Ft(r, t) { - return gr(Ue(r, t)); +c.dict = br; +function It(r, t) { + return br($e(r, t)); } -c.zipToDict = Ft; -function It(r) { +c.zipToDict = It; +function Wt(r) { return new Set(r); } -c.set = It; -function Wt(r) { +c.set = Wt; +function Ut(r) { var t, e, i, s, a, o, l, f, h, d; return re(this, function(g) { switch (g.label) { @@ -1617,7 +1621,7 @@ function Wt(r) { } }); } -c.keys = Wt; +c.keys = Ut; function P(r) { if ("length" in r) return r.length; @@ -1637,7 +1641,7 @@ function P(r) { } } c.len = P; -function Ut(r) { +function $t(r) { r === void 0 && (r = /* @__PURE__ */ new Map()); var t = new Proxy({}, { get: function(e, i, s) { @@ -1661,18 +1665,18 @@ function Ut(r) { }); return t; } -c.mapToObj = Ut; -function $t(r) { +c.mapToObj = $t; +function zt(r) { r(); } -c.call = $t; -function br(r, t) { +c.call = zt; +function mr(r, t) { return t === void 0 && (t = []), function(e) { var i = P(t) + 1, s = t.concat([e]); - return i == P(r) ? r.apply(void 0, ae(s)) : br(r, s); + return i == P(r) ? r.apply(void 0, ae(s)) : mr(r, s); }; } -function zt(r) { +function Yt(r) { function t() { for (var e, i, s = [], a = 0; a < arguments.length; a++) s[a] = arguments[a]; @@ -1695,125 +1699,127 @@ function zt(r) { } return t; } -function mr(r, t, e) { +function wr(r, t, e) { t === void 0 && (t = 0), e === void 0 && (e = null), e == null && (e = r); - var i = br(r), s = zt(i), a = function() { + var i = mr(r), s = Yt(i), a = function() { for (var o = [], l = 0; l < arguments.length; l++) o[l] = arguments[l]; var f = s.apply(void 0, ae(o)); if (t + P(o) == P(e)) return f; - var h = mr(f, t + P(o), e); + var h = wr(f, t + P(o), e); return h; }; return a; } -c.curry = mr; -var Yt = Fe(vt), qt = Fe(dt); -function Bt(r) { +c.curry = wr; +var qt = Ie(dt), Bt = Ie(yt); +function Lt(r) { var t = !1, e = null, i = null; return function() { for (var s = [], a = 0; a < arguments.length; a++) s[a] = arguments[a]; - if (!t || i !== s || !qt.default(s, i)) - return t = !0, e = r.apply(void 0, ae(s)), i = Yt.default(s), e; + if (!t || i !== s || !Bt.default(s, i)) + return t = !0, e = r.apply(void 0, ae(s)), i = qt.default(s), e; }; } -c.cached = Bt; -function Ht(r) { +c.cached = Lt; +function Zt(r) { const t = N(); return V(() => r(), t, { deep: !0 }), r(); } -function Lt(r) { +function Vt(r) { function* t() { for (let e in r) yield r[e]; } - return _r(t()); + return gr(t()); } -function Vt(r) { +function Nt(r) { const t = N(), e = be(() => { const s = r(); - return Lt(s).filter((o) => Kr(o) || Gr(o)); - }, [r]), i = st(() => e(), [e]); + return Vt(s).filter((o) => Xr(o) || Zr(o)); + }, [r]), i = Hr(() => e(), [e]); return V(() => i, t, { deep: !0 }), r(); } -function Nt(r) { - const t = fr(() => r.target.setup(r.props)), e = Vt(() => t), i = r.target.render; - return /* @__PURE__ */ ur.jsx(i, { ...e }); -} -function Zt(r) { - return (t) => /* @__PURE__ */ ur.jsx(Nt, { target: r, props: t }); +function Jt(r) { + const t = cr(() => r.target.setup(r.props)), e = Nt(() => t), i = r.target.render; + return /* @__PURE__ */ hr.jsx(i, { ...e }); } function Qt(r) { - const [t] = L(() => Xr(r)), e = N(); - return V(t, e, { deep: !0 }), t; + return (t) => /* @__PURE__ */ hr.jsx(Jt, { target: r, props: t }); } function en(r) { - const [t] = L(() => Hr(r)), e = N(); - return V(t, e), t; + const [t] = L(() => Qr(r)), e = N(); + return V(t, e, { deep: !0 }), t; } function rn(r) { - const [t] = L(() => Zr(r)), e = N(); + const [t] = L(() => et(r)), e = N(); return V(t, e), t; } function tn(r) { - const [t] = L(() => Qr(r)), e = N(); + const [t] = L(() => rt(r)), e = N(); return V(t, e), t; } function nn(r) { - const [t] = L(() => et(r)), e = N(); + const [t] = L(() => tt(r)), e = N(); return V(t, e), t; } function an(r) { - const [t] = L(() => rt(r)), e = N(); + const [t] = L(() => nt(r)), e = N(); return V(t, e), t; } function sn(r) { - const [t] = L(() => tt(r)), e = N(); + const [t] = L(() => it(r)), e = N(); + return V(t, e), t; +} +function on(r) { + const [t] = L(() => at(r)), e = N(); return V(t, e), t; } -function on(r, t) { - const [e] = L(() => nt(r, t)), i = N(); +function un(r, t) { + const [e] = L(() => st(r, t)), i = N(); return V(e, i), e; } -function Jt(r, t = {}) { - return sr(r, null, { +function Kt(r, t = {}) { + return ur(r, null, { ...t, - onWarn: cr.warn, + onWarn: lr.warn, scheduler: (e) => e() }); } -const un = (r, t) => { - const [e] = L(() => Jt(r, t)); - return lr(() => e.stop()), e; +const fn = (r, t) => { + const [e] = L(() => Kt(r, t)); + return fr(() => e.stop()), e; }; -function fn(...r) { - const t = ie(!1), [e] = L(() => it(...r)), i = ie(e.run), s = be((a) => { +function ln(...r) { + const t = ie(!1), [e] = L(() => ot(...r)), i = ie(e.run), s = be((a) => { if (!t.current) return t.current = !0, i.current.bind(e)(a); }, []); return e.run = s, e; } +const cn = Ce.watch.bind(Ce); export { - Nt as SetupComponentRenderer, - vn as baseWatch, - Zt as defineSetupComponent, - lr as onBeforeUnmount, - ft as onMounted, + Jt as SetupComponentRenderer, + yn as baseWatch, + Qt as defineSetupComponent, + fr as onBeforeUnmount, + ut as onMounted, Xt as onUpdated, - on as useComputed, - rn as useCustomRef, - fn as useEffectScope, - tn as useReactive, - Ht as useReactivity, - an as useReadonly, - Qt as useRef, - nn as useShallowReactive, - sn as useShallowReadonly, - en as useShallowRef, + un as useComputed, + tn as useCustomRef, + ln as useEffectScope, + nn as useReactive, + Zt as useReactivity, + sn as useReadonly, + en as useRef, + an as useShallowReactive, + on as useShallowReadonly, + rn as useShallowRef, V as useWatch, - un as useWatchEffect, - lt as watch, - Jt as watchEffect + fn as useWatchEffect, + cn as watch, + Kt as watchEffect, + Ce as watcherInstance }; diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs index 7845e72..b425935 100644 --- a/dist/veact.umd.cjs +++ b/dist/veact.umd.cjs @@ -1,4 +1,4 @@ -(function(E,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("@vue/reactivity"),require("react")):typeof define=="function"&&define.amd?define(["exports","@vue/reactivity","react"],P):(E=typeof globalThis<"u"?globalThis:E||self,P(E.veact={},E.VueReactivity,E.React))})(this,function(E,P,O){"use strict";/*! +(function(E,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react"),require("@vue/reactivity")):typeof define=="function"&&define.amd?define(["exports","react","@vue/reactivity"],R):(E=typeof globalThis<"u"?globalThis:E||self,R(E.veact={},E.React,E.VueReactivity))})(this,function(E,R,D){"use strict";/*! * veact v1.0.0 * https://github.com/veactjs/veact * @@ -8,8 +8,8 @@ * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-18T12:50:21.310Z - */var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},we={exports:{}},ue={};/** + * Date: 2024-09-19T02:18:20.013Z + */function Be(t){R.useEffect(()=>{t()},[])}function Re(t){R.useEffect(()=>()=>{t()},[])}function Rt(t){const r=R.useRef(!1);R.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Ve={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Le(t){const r=R.useRef(!0),e=R.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}class Et{watch(r,e,a={}){return D.watch(r,e,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Et,N=(t,r,e={})=>{const a=R.useRef(),s=R.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=R.useCallback(()=>{a.current&&s(),a.current=ye.watch(t,()=>{console.log("触发更新"),r()},e)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** * @license React * react-jsx-runtime.production.min.js * @@ -17,7 +17,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ye;function Rt(){if(Ye)return ue;Ye=1;var t=O,r=Symbol.for("react.element"),e=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,f,h){var v,g={},p=null,m=null;h!==void 0&&(p=""+h),f.key!==void 0&&(p=""+f.key),f.ref!==void 0&&(m=f.ref);for(v in f)a.call(f,v)&&!i.hasOwnProperty(v)&&(g[v]=f[v]);if(l&&l.defaultProps)for(v in f=l.defaultProps,f)g[v]===void 0&&(g[v]=f[v]);return{$$typeof:r,type:l,key:p,ref:m,props:g,_owner:s.current}}return ue.Fragment=e,ue.jsx=o,ue.jsxs=o,ue}var fe={};/** + */var Ne;function Ot(){if(Ne)return ue;Ne=1;var t=R,r=Symbol.for("react.element"),e=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,f,h){var v,g={},p=null,m=null;h!==void 0&&(p=""+h),f.key!==void 0&&(p=""+f.key),f.ref!==void 0&&(m=f.ref);for(v in f)a.call(f,v)&&!i.hasOwnProperty(v)&&(g[v]=f[v]);if(l&&l.defaultProps)for(v in f=l.defaultProps,f)g[v]===void 0&&(g[v]=f[v]);return{$$typeof:r,type:l,key:p,ref:m,props:g,_owner:s.current}}return ue.Fragment=e,ue.jsx=o,ue.jsxs=o,ue}var fe={};/** * @license React * react-jsx-runtime.development.js * @@ -25,17 +25,17 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Be;function Et(){return Be||(Be=1,process.env.NODE_ENV!=="production"&&function(){var t=O,r=Symbol.for("react.element"),e=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),D=Symbol.iterator,J="@@iterator";function H(n){if(n===null||typeof n!="object")return null;var u=D&&n[D]||n[J];return typeof u=="function"?u:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function A(n){{for(var u=arguments.length,d=new Array(u>1?u-1:0),y=1;y1?u-1:0),y=1;y=1&&C>=0&&b[x]!==W[C];)C--;for(;x>=1&&C>=0;x--,C--)if(b[x]!==W[C]){if(x!==1||C!==1)do if(x--,C--,C<0||b[x]!==W[C]){var L=` -`+b[x].replace(" at new "," at ");return n.displayName&&L.includes("")&&(L=L.replace("",n.displayName)),typeof n=="function"&&ge.set(n,L),L}while(x>=1&&C>=0);break}}}finally{Me=!1,Ce.current=S,br(),Error.prepareStackTrace=R}var oe=n?n.displayName||n.name:"",ne=oe?_e(oe):"";return typeof n=="function"&&ge.set(n,ne),ne}function wr(n,u,d){return ut(n,!1)}function Rr(n){var u=n.prototype;return!!(u&&u.isReactComponent)}function be(n,u,d){if(n==null)return"";if(typeof n=="function")return ut(n,Rr(n));if(typeof n=="string")return _e(n);switch(n){case h:return _e("Suspense");case v:return _e("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case f:return wr(n.render);case g:return be(n.type,u,d);case p:{var y=n,R=y._payload,S=y._init;try{return be(S(R),u,d)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,ft={},lt=k.ReactDebugCurrentFrame;function me(n){if(n){var u=n._owner,d=be(n.type,n._source,u?u.type:null);lt.setExtraStackFrame(d)}else lt.setExtraStackFrame(null)}function Er(n,u,d,y,R){{var S=Function.call.bind(de);for(var w in n)if(S(n,w)){var b=void 0;try{if(typeof n[w]!="function"){var W=Error((y||"React class")+": "+d+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}b=n[w](u,w,y,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){b=x}b&&!(b instanceof Error)&&(me(R),A("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",d,w,typeof b),me(null)),b instanceof Error&&!(b.message in ft)&&(ft[b.message]=!0,me(R),A("Failed %s type: %s",d,b.message),me(null))}}}var Or=Array.isArray;function De(n){return Or(n)}function Sr(n){{var u=typeof Symbol=="function"&&Symbol.toStringTag,d=u&&n[Symbol.toStringTag]||n.constructor.name||"Object";return d}}function Tr(n){try{return ct(n),!1}catch{return!0}}function ct(n){return""+n}function ht(n){if(Tr(n))return A("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Sr(n)),ct(n)}var ve=k.ReactCurrentOwner,jr={key:!0,ref:!0,__self:!0,__source:!0},dt,vt,Fe;Fe={};function kr(n){if(de.call(n,"ref")){var u=Object.getOwnPropertyDescriptor(n,"ref").get;if(u&&u.isReactWarning)return!1}return n.ref!==void 0}function xr(n){if(de.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function Pr(n,u){if(typeof n.ref=="string"&&ve.current&&u&&ve.current.stateNode!==u){var d=I(ve.current.type);Fe[d]||(A('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',I(ve.current.type),n.ref),Fe[d]=!0)}}function Cr(n,u){{var d=function(){dt||(dt=!0,A("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"key",{get:d,configurable:!0})}}function Ar(n,u){{var d=function(){vt||(vt=!0,A("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"ref",{get:d,configurable:!0})}}var Mr=function(n,u,d,y,R,S,w){var b={$$typeof:r,type:n,key:u,ref:d,props:w,_owner:S};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function Dr(n,u,d,y,R){{var S,w={},b=null,W=null;d!==void 0&&(ht(d),b=""+d),xr(u)&&(ht(u.key),b=""+u.key),kr(u)&&(W=u.ref,Pr(u,R));for(S in u)de.call(u,S)&&!jr.hasOwnProperty(S)&&(w[S]=u[S]);if(n&&n.defaultProps){var x=n.defaultProps;for(S in x)w[S]===void 0&&(w[S]=x[S])}if(b||W){var C=typeof n=="function"?n.displayName||n.name||"Unknown":n;b&&Cr(w,C),W&&Ar(w,C)}return Mr(n,b,W,R,y,ve.current,w)}}var Ie=k.ReactCurrentOwner,yt=k.ReactDebugCurrentFrame;function se(n){if(n){var u=n._owner,d=be(n.type,n._source,u?u.type:null);yt.setExtraStackFrame(d)}else yt.setExtraStackFrame(null)}var We;We=!1;function Ue(n){return typeof n=="object"&&n!==null&&n.$$typeof===r}function pt(){{if(Ie.current){var n=I(Ie.current.type);if(n)return` +`),x=b.length-1,P=W.length-1;x>=1&&P>=0&&b[x]!==W[P];)P--;for(;x>=1&&P>=0;x--,P--)if(b[x]!==W[P]){if(x!==1||P!==1)do if(x--,P--,P<0||b[x]!==W[P]){var L=` +`+b[x].replace(" at new "," at ");return n.displayName&&L.includes("")&&(L=L.replace("",n.displayName)),typeof n=="function"&&be.set(n,L),L}while(x>=1&&P>=0);break}}}finally{De=!1,Ae.current=S,wr(),Error.prepareStackTrace=O}var oe=n?n.displayName||n.name:"",ne=oe?ge(oe):"";return typeof n=="function"&&be.set(n,ne),ne}function Er(n,u,d){return ut(n,!1)}function Or(n){var u=n.prototype;return!!(u&&u.isReactComponent)}function me(n,u,d){if(n==null)return"";if(typeof n=="function")return ut(n,Or(n));if(typeof n=="string")return ge(n);switch(n){case h:return ge("Suspense");case v:return ge("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case f:return Er(n.render);case g:return me(n.type,u,d);case p:{var y=n,O=y._payload,S=y._init;try{return me(S(O),u,d)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,ft={},lt=k.ReactDebugCurrentFrame;function we(n){if(n){var u=n._owner,d=me(n.type,n._source,u?u.type:null);lt.setExtraStackFrame(d)}else lt.setExtraStackFrame(null)}function Sr(n,u,d,y,O){{var S=Function.call.bind(de);for(var w in n)if(S(n,w)){var b=void 0;try{if(typeof n[w]!="function"){var W=Error((y||"React class")+": "+d+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}b=n[w](u,w,y,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){b=x}b&&!(b instanceof Error)&&(we(O),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",d,w,typeof b),we(null)),b instanceof Error&&!(b.message in ft)&&(ft[b.message]=!0,we(O),C("Failed %s type: %s",d,b.message),we(null))}}}var Tr=Array.isArray;function Ie(n){return Tr(n)}function jr(n){{var u=typeof Symbol=="function"&&Symbol.toStringTag,d=u&&n[Symbol.toStringTag]||n.constructor.name||"Object";return d}}function kr(n){try{return ct(n),!1}catch{return!0}}function ct(n){return""+n}function ht(n){if(kr(n))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",jr(n)),ct(n)}var ve=k.ReactCurrentOwner,xr={key:!0,ref:!0,__self:!0,__source:!0},dt,vt,Fe;Fe={};function Pr(n){if(de.call(n,"ref")){var u=Object.getOwnPropertyDescriptor(n,"ref").get;if(u&&u.isReactWarning)return!1}return n.ref!==void 0}function Cr(n){if(de.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function Ar(n,u){if(typeof n.ref=="string"&&ve.current&&u&&ve.current.stateNode!==u){var d=F(ve.current.type);Fe[d]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(ve.current.type),n.ref),Fe[d]=!0)}}function Mr(n,u){{var d=function(){dt||(dt=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"key",{get:d,configurable:!0})}}function Dr(n,u){{var d=function(){vt||(vt=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"ref",{get:d,configurable:!0})}}var Ir=function(n,u,d,y,O,S,w){var b={$$typeof:r,type:n,key:u,ref:d,props:w,_owner:S};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function Fr(n,u,d,y,O){{var S,w={},b=null,W=null;d!==void 0&&(ht(d),b=""+d),Cr(u)&&(ht(u.key),b=""+u.key),Pr(u)&&(W=u.ref,Ar(u,O));for(S in u)de.call(u,S)&&!xr.hasOwnProperty(S)&&(w[S]=u[S]);if(n&&n.defaultProps){var x=n.defaultProps;for(S in x)w[S]===void 0&&(w[S]=x[S])}if(b||W){var P=typeof n=="function"?n.displayName||n.name||"Unknown":n;b&&Mr(w,P),W&&Dr(w,P)}return Ir(n,b,W,O,y,ve.current,w)}}var We=k.ReactCurrentOwner,yt=k.ReactDebugCurrentFrame;function se(n){if(n){var u=n._owner,d=me(n.type,n._source,u?u.type:null);yt.setExtraStackFrame(d)}else yt.setExtraStackFrame(null)}var Ue;Ue=!1;function ze(n){return typeof n=="object"&&n!==null&&n.$$typeof===r}function pt(){{if(We.current){var n=F(We.current.type);if(n)return` -Check the render method of \``+n+"`."}return""}}function Fr(n){return""}var _t={};function Ir(n){{var u=pt();if(!u){var d=typeof n=="string"?n:n.displayName||n.name;d&&(u=` +Check the render method of \``+n+"`."}return""}}function Wr(n){return""}var _t={};function Ur(n){{var u=pt();if(!u){var d=typeof n=="string"?n:n.displayName||n.name;d&&(u=` -Check the top-level render call using <`+d+">.")}return u}}function gt(n,u){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var d=Ir(u);if(_t[d])return;_t[d]=!0;var y="";n&&n._owner&&n._owner!==Ie.current&&(y=" It was passed a child from "+I(n._owner.type)+"."),se(n),A('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,y),se(null)}}function bt(n,u){{if(typeof n!="object")return;if(De(n))for(var d=0;d",b=" Did you accidentally export a JSX literal instead of a component?"):x=typeof n,A("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,b)}var C=Dr(n,u,d,R,S);if(C==null)return C;if(w){var L=u.children;if(L!==void 0)if(y)if(De(L)){for(var oe=0;oe0?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}";if(!mt[ne+ze]){var Lr=z.length>0?"{"+z.join(": ..., ")+": ...}":"{}";A(`A props object containing a "key" prop is being spread into JSX: +Check the top-level render call using <`+d+">.")}return u}}function gt(n,u){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var d=Ur(u);if(_t[d])return;_t[d]=!0;var y="";n&&n._owner&&n._owner!==We.current&&(y=" It was passed a child from "+F(n._owner.type)+"."),se(n),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,y),se(null)}}function bt(n,u){{if(typeof n!="object")return;if(Ie(n))for(var d=0;d",b=" Did you accidentally export a JSX literal instead of a component?"):x=typeof n,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,b)}var P=Fr(n,u,d,O,S);if(P==null)return P;if(w){var L=u.children;if(L!==void 0)if(y)if(Ie(L)){for(var oe=0;oe0?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}";if(!mt[ne+Ye]){var Jr=z.length>0?"{"+z.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; - <%s key={someKey} {...props} />`,ze,ne,Lr,ne),mt[ne+ze]=!0}}return n===a?Ur(C):Wr(C),C}}function zr(n,u,d){return wt(n,u,d,!0)}function Yr(n,u,d){return wt(n,u,d,!1)}var Br=Yr,Vr=zr;fe.Fragment=a,fe.jsx=Br,fe.jsxs=Vr}()),fe}process.env.NODE_ENV==="production"?we.exports=Rt():we.exports=Et();var Ve=we.exports;function Le(t){const r=O.useRef(!0),e=O.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}function Ne(t){O.useEffect(()=>{t()},[])}function Re(t){O.useEffect(()=>()=>{t()},[])}function Ot(t){const r=O.useRef(!1);O.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Je={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Ke(t,r,e={}){return P.watch(t,r,{...e,onWarn:Je.warn,scheduler:a=>a()})}const N=(t,r,e={})=>{const a=O.useRef(),s=O.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=O.useCallback(()=>{a.current&&s(),a.current=Ke(t,()=>{console.log("触发更新"),r()},e)},[]);return Ne(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a},St=t=>t+1,X=()=>O.useReducer(St,0)[1];var c={};function j(t,e){var e=e||{};this._head=0,this._tail=0,this._capacity=e.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(t)&&this._fromArray(t)}j.prototype.peekAt=function(r){var e=r;if(e===(e|0)){var a=this.size();if(!(e>=a||e<-a))return e<0&&(e+=a),e=this._head+e&this._capacityMask,this._list[e]}},j.prototype.get=function(r){return this.peekAt(r)},j.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},j.prototype.peekFront=function(){return this.peek()},j.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(j.prototype,"length",{get:function(){return this.size()}}),j.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),e}},j.prototype.push=function(r){if(r===void 0)return this.size();var e=this._tail;return this._list[e]=r,this._tail=e+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&r<=e>>>2&&this._shrinkArray(),a}},j.prototype.removeOne=function(r){var e=r;if(e===(e|0)&&this._head!==this._tail){var a=this.size(),s=this._list.length;if(!(e>=a||e<-a)){e<0&&(e+=a),e=this._head+e&this._capacityMask;var i=this._list[e],o;if(r0;o--)this._list[e]=this._list[e=e-1+s&this._capacityMask];this._list[e]=void 0,this._head=this._head+1+s&this._capacityMask}else{for(o=a-1-r;o>0;o--)this._list[e]=this._list[e=e+1+s&this._capacityMask];this._list[e]=void 0,this._tail=this._tail-1+s&this._capacityMask}return i}}},j.prototype.remove=function(r,e){var a=r,s,i=e;if(a===(a|0)&&this._head!==this._tail){var o=this.size(),l=this._list.length;if(!(a>=o||a<-o||e<1)){if(a<0&&(a+=o),e===1||!e)return s=new Array(1),s[0]=this.removeOne(a),s;if(a===0&&a+e>=o)return s=this.toArray(),this.clear(),s;a+e>o&&(e=o-a);var f;for(s=new Array(e),f=0;f0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(r===0){for(this._head=this._head+e+l&this._capacityMask,f=e-1;f>0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(a0;f--)this.unshift(this._list[a=a-1+l&this._capacityMask]);for(a=this._head-1+l&this._capacityMask;i>0;)this._list[a=a-1+l&this._capacityMask]=void 0,i--;r<0&&(this._tail=a)}else{for(this._tail=a,a=a+e+l&this._capacityMask,f=o-(e+r);f>0;f--)this.push(this._list[a++]);for(a=this._tail;i>0;)this._list[a=a+1+l&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=l>>>2&&this._shrinkArray(),s}}},j.prototype.splice=function(r,e){var a=r;if(a===(a|0)){var s=this.size();if(a<0&&(a+=s),!(a>s))if(arguments.length>2){var i,o,l,f=arguments.length,h=this._list.length,v=2;if(!s||a0&&(this._head=this._head+a+h&this._capacityMask)):(l=this.remove(a,e),this._head=this._head+a+h&this._capacityMask);f>v;)this.unshift(arguments[--f]);for(i=a;i>0;i--)this.unshift(o[i-1])}else{o=new Array(s-(a+e));var g=o.length;for(i=0;ithis._tail){for(i=this._head;i>>=1,this._capacityMask>>>=1};var Tt=j,Ge={exports:{}};(function(t){var r=function(){function e(p,m){return m!=null&&p instanceof m}var a;try{a=Map}catch{a=function(){}}var s;try{s=Set}catch{s=function(){}}var i;try{i=Promise}catch{i=function(){}}function o(p,m,D,J,H){typeof m=="object"&&(D=m.depth,J=m.prototype,H=m.includeNonEnumerable,m=m.circular);var k=[],A=[],Pe=typeof Buffer<"u";typeof m>"u"&&(m=!0),typeof D>"u"&&(D=1/0);function K(_,G){if(_===null)return null;if(G===0)return _;var T,te;if(typeof _!="object")return _;if(e(_,a))T=new a;else if(e(_,s))T=new s;else if(e(_,i))T=new i(function(Q,q){_.then(function($){Q(K($,G-1))},function($){q(K($,G-1))})});else if(o.__isArray(_))T=[];else if(o.__isRegExp(_))T=new RegExp(_.source,g(_)),_.lastIndex&&(T.lastIndex=_.lastIndex);else if(o.__isDate(_))T=new Date(_.getTime());else{if(Pe&&Buffer.isBuffer(_))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(_.length):T=new Buffer(_.length),_.copy(T),T;e(_,Error)?T=Object.create(_):typeof J>"u"?(te=Object.getPrototypeOf(_),T=Object.create(te)):(T=Object.create(J),te=J)}if(m){var le=k.indexOf(_);if(le!=-1)return A[le];k.push(_),A.push(T)}e(_,a)&&_.forEach(function(Q,q){var $=K(q,G-1),pe=K(Q,G-1);T.set($,pe)}),e(_,s)&&_.forEach(function(Q){var q=K(Q,G-1);T.add(q)});for(var Y in _){var ce;te&&(ce=Object.getOwnPropertyDescriptor(te,Y)),!(ce&&ce.set==null)&&(T[Y]=K(_[Y],G-1))}if(Object.getOwnPropertySymbols)for(var he=Object.getOwnPropertySymbols(_),Y=0;Y0&&i[i.length-1])&&(h[0]===6||h[0]===2)){e=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},ye=B&&B.__read||function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var a=e.call(t),s,i=[],o;try{for(;(r===void 0||r-- >0)&&!(s=a.next()).done;)i.push(s.value)}catch(l){o={error:l}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(o)throw o.error}}return i},ae=B&&B.__spread||function(){for(var t=[],r=0;rt(),r,{deep:!0}),t()}function ir(t){function*r(){for(let e in t)yield t[e]}return $e(r())}function sr(t){const r=X(),e=O.useCallback(()=>{const s=t();return ir(s).filter(o=>P.isRef(o)||P.isReactive(o))},[t]),a=O.useMemo(()=>e(),[e]);return N(()=>a,r,{deep:!0}),t()}function nt(t){const r=Le(()=>t.target.setup(t.props)),e=sr(()=>r),a=t.target.render;return Ve.jsx(a,{...e})}function or(t){return r=>Ve.jsx(nt,{target:t,props:r})}function ur(t){const[r]=O.useState(()=>P.ref(t)),e=X();return N(r,e,{deep:!0}),r}function fr(t){const[r]=O.useState(()=>P.shallowRef(t)),e=X();return N(r,e),r}function lr(t){const[r]=O.useState(()=>P.customRef(t)),e=X();return N(r,e),r}function cr(t){const[r]=O.useState(()=>P.reactive(t)),e=X();return N(r,e),r}function hr(t){const[r]=O.useState(()=>P.shallowReactive(t)),e=X();return N(r,e),r}function dr(t){const[r]=O.useState(()=>P.readonly(t)),e=X();return N(r,e),r}function vr(t){const[r]=O.useState(()=>P.shallowReadonly(t)),e=X();return N(r,e),r}function yr(t,r){const[e]=O.useState(()=>P.computed(t,r)),a=X();return N(e,a),e}function at(t,r={}){return P.watch(t,null,{...r,onWarn:Je.warn,scheduler:e=>e()})}const pr=(t,r)=>{const[e]=O.useState(()=>at(t,r));return Re(()=>e.stop()),e};function _r(...t){const r=O.useRef(!1),[e]=O.useState(()=>P.effectScope(...t)),a=O.useRef(e.run),s=O.useCallback(i=>{if(!r.current)return r.current=!0,a.current.bind(e)(i)},[]);return e.run=s,e}Object.defineProperty(E,"baseWatch",{enumerable:!0,get:()=>P.watch}),E.SetupComponentRenderer=nt,E.defineSetupComponent=or,E.onBeforeUnmount=Re,E.onMounted=Ne,E.onUpdated=Ot,E.useComputed=yr,E.useCustomRef=lr,E.useEffectScope=_r,E.useReactive=cr,E.useReactivity=ar,E.useReadonly=dr,E.useRef=ur,E.useShallowReactive=hr,E.useShallowReadonly=vr,E.useShallowRef=fr,E.useWatch=N,E.useWatchEffect=pr,E.watch=Ke,E.watchEffect=at,Object.keys(P).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(E,t)&&Object.defineProperty(E,t,{enumerable:!0,get:()=>P[t]})}),Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}); + <%s key={someKey} {...props} />`,Ye,ne,Jr,ne),mt[ne+Ye]=!0}}return n===a?Yr(P):zr(P),P}}function Br(n,u,d){return wt(n,u,d,!0)}function Vr(n,u,d){return wt(n,u,d,!1)}var Lr=Vr,Nr=Br;fe.Fragment=a,fe.jsx=Lr,fe.jsxs=Nr}()),fe}process.env.NODE_ENV==="production"?Oe.exports=Ot():Oe.exports=St();var Ke=Oe.exports;const Tt=t=>t+1,H=()=>R.useReducer(Tt,0)[1];var c={};function j(t,e){var e=e||{};this._head=0,this._tail=0,this._capacity=e.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(t)&&this._fromArray(t)}j.prototype.peekAt=function(r){var e=r;if(e===(e|0)){var a=this.size();if(!(e>=a||e<-a))return e<0&&(e+=a),e=this._head+e&this._capacityMask,this._list[e]}},j.prototype.get=function(r){return this.peekAt(r)},j.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},j.prototype.peekFront=function(){return this.peek()},j.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(j.prototype,"length",{get:function(){return this.size()}}),j.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),e}},j.prototype.push=function(r){if(r===void 0)return this.size();var e=this._tail;return this._list[e]=r,this._tail=e+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&r<=e>>>2&&this._shrinkArray(),a}},j.prototype.removeOne=function(r){var e=r;if(e===(e|0)&&this._head!==this._tail){var a=this.size(),s=this._list.length;if(!(e>=a||e<-a)){e<0&&(e+=a),e=this._head+e&this._capacityMask;var i=this._list[e],o;if(r0;o--)this._list[e]=this._list[e=e-1+s&this._capacityMask];this._list[e]=void 0,this._head=this._head+1+s&this._capacityMask}else{for(o=a-1-r;o>0;o--)this._list[e]=this._list[e=e+1+s&this._capacityMask];this._list[e]=void 0,this._tail=this._tail-1+s&this._capacityMask}return i}}},j.prototype.remove=function(r,e){var a=r,s,i=e;if(a===(a|0)&&this._head!==this._tail){var o=this.size(),l=this._list.length;if(!(a>=o||a<-o||e<1)){if(a<0&&(a+=o),e===1||!e)return s=new Array(1),s[0]=this.removeOne(a),s;if(a===0&&a+e>=o)return s=this.toArray(),this.clear(),s;a+e>o&&(e=o-a);var f;for(s=new Array(e),f=0;f0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(r===0){for(this._head=this._head+e+l&this._capacityMask,f=e-1;f>0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(a0;f--)this.unshift(this._list[a=a-1+l&this._capacityMask]);for(a=this._head-1+l&this._capacityMask;i>0;)this._list[a=a-1+l&this._capacityMask]=void 0,i--;r<0&&(this._tail=a)}else{for(this._tail=a,a=a+e+l&this._capacityMask,f=o-(e+r);f>0;f--)this.push(this._list[a++]);for(a=this._tail;i>0;)this._list[a=a+1+l&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=l>>>2&&this._shrinkArray(),s}}},j.prototype.splice=function(r,e){var a=r;if(a===(a|0)){var s=this.size();if(a<0&&(a+=s),!(a>s))if(arguments.length>2){var i,o,l,f=arguments.length,h=this._list.length,v=2;if(!s||a0&&(this._head=this._head+a+h&this._capacityMask)):(l=this.remove(a,e),this._head=this._head+a+h&this._capacityMask);f>v;)this.unshift(arguments[--f]);for(i=a;i>0;i--)this.unshift(o[i-1])}else{o=new Array(s-(a+e));var g=o.length;for(i=0;ithis._tail){for(i=this._head;i>>=1,this._capacityMask>>>=1};var jt=j,Ge={exports:{}};(function(t){var r=function(){function e(p,m){return m!=null&&p instanceof m}var a;try{a=Map}catch{a=function(){}}var s;try{s=Set}catch{s=function(){}}var i;try{i=Promise}catch{i=function(){}}function o(p,m,M,J,X){typeof m=="object"&&(M=m.depth,J=m.prototype,X=m.includeNonEnumerable,m=m.circular);var k=[],C=[],Ce=typeof Buffer<"u";typeof m>"u"&&(m=!0),typeof M>"u"&&(M=1/0);function K(_,G){if(_===null)return null;if(G===0)return _;var T,te;if(typeof _!="object")return _;if(e(_,a))T=new a;else if(e(_,s))T=new s;else if(e(_,i))T=new i(function(Q,q){_.then(function($){Q(K($,G-1))},function($){q(K($,G-1))})});else if(o.__isArray(_))T=[];else if(o.__isRegExp(_))T=new RegExp(_.source,g(_)),_.lastIndex&&(T.lastIndex=_.lastIndex);else if(o.__isDate(_))T=new Date(_.getTime());else{if(Ce&&Buffer.isBuffer(_))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(_.length):T=new Buffer(_.length),_.copy(T),T;e(_,Error)?T=Object.create(_):typeof J>"u"?(te=Object.getPrototypeOf(_),T=Object.create(te)):(T=Object.create(J),te=J)}if(m){var le=k.indexOf(_);if(le!=-1)return C[le];k.push(_),C.push(T)}e(_,a)&&_.forEach(function(Q,q){var $=K(q,G-1),_e=K(Q,G-1);T.set($,_e)}),e(_,s)&&_.forEach(function(Q){var q=K(Q,G-1);T.add(q)});for(var Y in _){var ce;te&&(ce=Object.getOwnPropertyDescriptor(te,Y)),!(ce&&ce.set==null)&&(T[Y]=K(_[Y],G-1))}if(Object.getOwnPropertySymbols)for(var he=Object.getOwnPropertySymbols(_),Y=0;Y0&&i[i.length-1])&&(h[0]===6||h[0]===2)){e=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},pe=B&&B.__read||function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var a=e.call(t),s,i=[],o;try{for(;(r===void 0||r-- >0)&&!(s=a.next()).done;)i.push(s.value)}catch(l){o={error:l}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(o)throw o.error}}return i},ae=B&&B.__spread||function(){for(var t=[],r=0;rt(),r,{deep:!0}),t()}function sr(t){function*r(){for(let e in t)yield t[e]}return $e(r())}function or(t){const r=H(),e=R.useCallback(()=>{const s=t();return sr(s).filter(o=>D.isRef(o)||D.isReactive(o))},[t]),a=R.useMemo(()=>e(),[e]);return N(()=>a,r,{deep:!0}),t()}function nt(t){const r=Le(()=>t.target.setup(t.props)),e=or(()=>r),a=t.target.render;return Ke.jsx(a,{...e})}function ur(t){return r=>Ke.jsx(nt,{target:t,props:r})}function fr(t){const[r]=R.useState(()=>D.ref(t)),e=H();return N(r,e,{deep:!0}),r}function lr(t){const[r]=R.useState(()=>D.shallowRef(t)),e=H();return N(r,e),r}function cr(t){const[r]=R.useState(()=>D.customRef(t)),e=H();return N(r,e),r}function hr(t){const[r]=R.useState(()=>D.reactive(t)),e=H();return N(r,e),r}function dr(t){const[r]=R.useState(()=>D.shallowReactive(t)),e=H();return N(r,e),r}function vr(t){const[r]=R.useState(()=>D.readonly(t)),e=H();return N(r,e),r}function yr(t){const[r]=R.useState(()=>D.shallowReadonly(t)),e=H();return N(r,e),r}function pr(t,r){const[e]=R.useState(()=>D.computed(t,r)),a=H();return N(e,a),e}function at(t,r={}){return D.watch(t,null,{...r,onWarn:Ve.warn,scheduler:e=>e()})}const _r=(t,r)=>{const[e]=R.useState(()=>at(t,r));return Re(()=>e.stop()),e};function gr(...t){const r=R.useRef(!1),[e]=R.useState(()=>D.effectScope(...t)),a=R.useRef(e.run),s=R.useCallback(i=>{if(!r.current)return r.current=!0,a.current.bind(e)(i)},[]);return e.run=s,e}const br=ye.watch.bind(ye);Object.defineProperty(E,"baseWatch",{enumerable:!0,get:()=>D.watch}),E.SetupComponentRenderer=nt,E.defineSetupComponent=ur,E.onBeforeUnmount=Re,E.onMounted=Be,E.onUpdated=Rt,E.useComputed=pr,E.useCustomRef=cr,E.useEffectScope=gr,E.useReactive=hr,E.useReactivity=ir,E.useReadonly=vr,E.useRef=fr,E.useShallowReactive=dr,E.useShallowReadonly=yr,E.useShallowRef=lr,E.useWatch=N,E.useWatchEffect=_r,E.watch=br,E.watchEffect=at,E.watcherInstance=ye,Object.keys(D).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(E,t)&&Object.defineProperty(E,t,{enumerable:!0,get:()=>D[t]})}),Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}); diff --git a/src/index.ts b/src/index.ts index 4615061..8715862 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,8 @@ * @author Surmon */ +import { watcherInstance } from './watch' + // redirect all APIs from @vue/reactivity export * from '@vue/reactivity' export * from "./setup/setupComponents" @@ -24,7 +26,11 @@ export { useReadonly, useShallowReadonly } from './readonly' export { useComputed } from './computed' // watch and hooks -export { watch, useWatch } from './watch' +export { watcherInstance, useWatch } from './watch' +//兼容处理 +const watch=watcherInstance.watch.bind(watcherInstance); +export {watch}; + export type { WatchOptions, MultiWatchSources } from './watch' // watchEffect and hooks diff --git a/src/watch.ts b/src/watch.ts index 161839f..7f3d8c2 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -4,7 +4,7 @@ * @author Surmon */ -import { useCallback, useEffect, useState as useReactState, useRef } from 'react' +import { MutableRefObject, useCallback, useEffect, useState as useReactState, useRef } from 'react' import { watch as vueWatch } from '@vue/reactivity' import type { ReactiveMarker, @@ -56,49 +56,53 @@ type MapSources = { * }) * ``` */ +export class WatchHelper { -// overload: single source + cb -export function watch = false>( - source: WatchSource, - callback: WatchCallback>, - options?: WatchOptions, -): WatchHandle - -// overload: reactive array or tuple of multiple sources + cb -export function watch, Immediate extends Readonly = false>( - sources: readonly [...T] | T, - callback: [T] extends [ReactiveMarker] - ? WatchCallback> - : WatchCallback, MapSources>, - options?: WatchOptions, -): WatchHandle - -// overload: array of multiple sources + cb -export function watch = false>( - sources: [...T], - callback: WatchCallback, MapSources>, - options?: WatchOptions, -): WatchHandle - -// overload: watching reactive object w/ cb -export function watch = false>( - source: T, - callback: WatchCallback>, - options?: WatchOptions, -): WatchHandle - -// implementation -export function watch = false>( - source: T | WatchSource, - callback: WatchCallback, - options: WatchOptions = {}, -): WatchHandle { - return vueWatch(source as any, callback, { - ...options, - onWarn: logger.warn, - scheduler: (job) => job(), - }) + //type tricky + // overload: single source + cb + watch = false, >( + source: WatchSource, + callback: WatchCallback>, + options?: WatchOptions, + ): R + + // overload: reactive array or tuple of multiple sources + cb + watch, Immediate extends Readonly = false>( + sources: readonly [...T] | T, + callback: [T] extends [ReactiveMarker] + ? WatchCallback> + : WatchCallback, MapSources>, + options?: WatchOptions, + ): R + + // overload: array of multiple sources + cb + watch = false>( + sources: [...T], + callback: WatchCallback, MapSources>, + options?: WatchOptions, + ): R + + // overload: watching reactive object w/ cb + watch = false>( + source: T, + callback: WatchCallback>, + options?: WatchOptions, + ): R + + // implementation + watch = false>( + source: T | WatchSource, + callback: WatchCallback, + options: WatchOptions = {}, + ): R { + return vueWatch(source as any, callback, { + ...options, + onWarn: logger.warn, + scheduler: (job) => job(), + }) as any + } } + /** * Watches one or more reactive data sources and invokes a callback function when the sources change. * @@ -115,7 +119,9 @@ export function watch = false>( * }) * ``` */ -export const useWatch = (source: any, callback: any, options = {}) => { + +export const watcherInstance=new WatchHelper(); +export const useWatch: (InstanceType>>)["watch"] = (source: any, callback: any, options = {}) => { const watcher = useRef() //执行watch const cancelWatch = useCallback(() => { @@ -127,7 +133,7 @@ export const useWatch = (source: any, callback: any, options = {}) => { const doWatch = useCallback(() => { if (watcher.current) cancelWatch(); - watcher.current = watch(source as any, () => { + watcher.current = watcherInstance.watch(source as any, () => { console.log("触发更新") callback() }, options) @@ -141,10 +147,12 @@ export const useWatch = (source: any, callback: any, options = {}) => { console.log("取消监听") cancelWatch(); }) - useOnce(()=>{ + useOnce(() => { console.log("初始监听") doWatch(); }) return watcher; } + + From 45e5cfc2a6ebfd90789b7cf073adbe852a1e7d8d Mon Sep 17 00:00:00 2001 From: gmono Date: Thu, 19 Sep 2024 10:31:24 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E5=AE=8C=E5=96=84watch=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/veact.js | 6 +++--- dist/veact.umd.cjs | 4 ++-- src/watch.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/veact.js b/dist/veact.js index f8469b8..53334cf 100644 --- a/dist/veact.js +++ b/dist/veact.js @@ -12,7 +12,7 @@ import { watch as yn } from "@vue/reactivity"; * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:18:20.013Z + * Date: 2024-09-19T02:31:02.029Z */ function ut(r) { Fe(() => { @@ -60,8 +60,8 @@ const Ce = new ft(), V = (r, t, e = {}) => { const i = ie(), s = be(() => { i.current && (i.current(), i.current = void 0); }, []), a = be(() => { - i.current && s(), i.current = Ce.watch(r, () => { - console.log("触发更新"), t(); + i.current && s(), i.current = Ce.watch(r, (...o) => { + console.log("触发更新"), t(...o); }, e); }, []); return ut(() => { diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs index b425935..0255f28 100644 --- a/dist/veact.umd.cjs +++ b/dist/veact.umd.cjs @@ -8,8 +8,8 @@ * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:18:20.013Z - */function Be(t){R.useEffect(()=>{t()},[])}function Re(t){R.useEffect(()=>()=>{t()},[])}function Rt(t){const r=R.useRef(!1);R.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Ve={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Le(t){const r=R.useRef(!0),e=R.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}class Et{watch(r,e,a={}){return D.watch(r,e,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Et,N=(t,r,e={})=>{const a=R.useRef(),s=R.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=R.useCallback(()=>{a.current&&s(),a.current=ye.watch(t,()=>{console.log("触发更新"),r()},e)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** + * Date: 2024-09-19T02:31:02.029Z + */function Be(t){R.useEffect(()=>{t()},[])}function Re(t){R.useEffect(()=>()=>{t()},[])}function Rt(t){const r=R.useRef(!1);R.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Ve={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Le(t){const r=R.useRef(!0),e=R.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}class Et{watch(r,e,a={}){return D.watch(r,e,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Et,N=(t,r,e={})=>{const a=R.useRef(),s=R.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=R.useCallback(()=>{a.current&&s(),a.current=ye.watch(t,(...o)=>{console.log("触发更新"),r(...o)},e)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** * @license React * react-jsx-runtime.production.min.js * diff --git a/src/watch.ts b/src/watch.ts index 7f3d8c2..b9d5eec 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -121,6 +121,7 @@ export class WatchHelper { */ export const watcherInstance=new WatchHelper(); + export const useWatch: (InstanceType>>)["watch"] = (source: any, callback: any, options = {}) => { const watcher = useRef() //执行watch @@ -133,9 +134,9 @@ export const useWatch: (InstanceType { if (watcher.current) cancelWatch(); - watcher.current = watcherInstance.watch(source as any, () => { + watcher.current = watcherInstance.watch(source as any, (...args) => { console.log("触发更新") - callback() + callback(...args) }, options) }, []) @@ -155,4 +156,3 @@ export const useWatch: (InstanceType Date: Thu, 19 Sep 2024 10:38:50 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E7=BB=99callback=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/veact.js | 2 +- dist/veact.umd.cjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/veact.js b/dist/veact.js index 53334cf..a82e42f 100644 --- a/dist/veact.js +++ b/dist/veact.js @@ -12,7 +12,7 @@ import { watch as yn } from "@vue/reactivity"; * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:31:02.029Z + * Date: 2024-09-19T02:37:50.654Z */ function ut(r) { Fe(() => { diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs index 0255f28..86ce0b0 100644 --- a/dist/veact.umd.cjs +++ b/dist/veact.umd.cjs @@ -8,7 +8,7 @@ * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:31:02.029Z + * Date: 2024-09-19T02:37:50.654Z */function Be(t){R.useEffect(()=>{t()},[])}function Re(t){R.useEffect(()=>()=>{t()},[])}function Rt(t){const r=R.useRef(!1);R.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Ve={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Le(t){const r=R.useRef(!0),e=R.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}class Et{watch(r,e,a={}){return D.watch(r,e,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Et,N=(t,r,e={})=>{const a=R.useRef(),s=R.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=R.useCallback(()=>{a.current&&s(),a.current=ye.watch(t,(...o)=>{console.log("触发更新"),r(...o)},e)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** * @license React * react-jsx-runtime.production.min.js From 65d28f643ca7fb9a3ee56e0505ccfbf45a53fc68 Mon Sep 17 00:00:00 2001 From: gmono Date: Thu, 19 Sep 2024 11:08:56 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/veact.js | 2 +- dist/veact.umd.cjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/veact.js b/dist/veact.js index a82e42f..4bd918e 100644 --- a/dist/veact.js +++ b/dist/veact.js @@ -12,7 +12,7 @@ import { watch as yn } from "@vue/reactivity"; * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:37:50.654Z + * Date: 2024-09-19T02:48:01.418Z */ function ut(r) { Fe(() => { diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs index 86ce0b0..b621d59 100644 --- a/dist/veact.umd.cjs +++ b/dist/veact.umd.cjs @@ -8,7 +8,7 @@ * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:37:50.654Z + * Date: 2024-09-19T02:48:01.418Z */function Be(t){R.useEffect(()=>{t()},[])}function Re(t){R.useEffect(()=>()=>{t()},[])}function Rt(t){const r=R.useRef(!1);R.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Ve={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Le(t){const r=R.useRef(!0),e=R.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}class Et{watch(r,e,a={}){return D.watch(r,e,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Et,N=(t,r,e={})=>{const a=R.useRef(),s=R.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=R.useCallback(()=>{a.current&&s(),a.current=ye.watch(t,(...o)=>{console.log("触发更新"),r(...o)},e)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** * @license React * react-jsx-runtime.production.min.js From 8c088956b7e36fdde7098c128b9aac53ea45b84e Mon Sep 17 00:00:00 2001 From: gmono Date: Thu, 19 Sep 2024 12:18:38 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Observer=E5=B1=80?= =?UTF-8?q?=E9=83=A8=E7=9B=91=E5=90=AC=E7=BB=84=E4=BB=B6=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=87=AA=E5=8A=A8=E7=9B=91=E5=90=AC=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E5=93=8D=E5=BA=94=E5=BC=8F=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/veact.d.ts | 8 +++++ dist/veact.js | 72 ++++++++++++++++++++++-------------------- dist/veact.umd.cjs | 20 ++++++------ src/index.ts | 2 +- src/observer/index.tsx | 40 +++++++++++++++++++++++ src/useImState.ts | 7 ++++ 6 files changed, 104 insertions(+), 45 deletions(-) create mode 100644 src/observer/index.tsx create mode 100644 src/useImState.ts diff --git a/dist/veact.d.ts b/dist/veact.d.ts index ed13493..3075c1f 100644 --- a/dist/veact.d.ts +++ b/dist/veact.d.ts @@ -53,6 +53,14 @@ declare type MaybeUndefined = I extends true ? T | undefined : T; export declare type MultiWatchSources = (WatchSource | object)[]; +/** + * 对应mobx的组件 + * 函数中不能调用hook + */ +export declare function Observer({ children }: { + children: () => ReactElement; +}): ReactElement>; + /** * The function is called right before the component is unmounted. * diff --git a/dist/veact.js b/dist/veact.js index 4bd918e..c14d6e7 100644 --- a/dist/veact.js +++ b/dist/veact.js @@ -1,7 +1,7 @@ import or, { useEffect as Fe, useRef as ie, useCallback as be, useReducer as Gr, useMemo as Hr, useState as L } from "react"; import { watch as ur, isRef as Xr, isReactive as Zr, ref as Qr, shallowRef as et, customRef as rt, reactive as tt, shallowReactive as nt, readonly as it, shallowReadonly as at, computed as st, effectScope as ot } from "@vue/reactivity"; export * from "@vue/reactivity"; -import { watch as yn } from "@vue/reactivity"; +import { watch as pn } from "@vue/reactivity"; /*! * veact v1.0.0 * https://github.com/veactjs/veact @@ -12,7 +12,7 @@ import { watch as yn } from "@vue/reactivity"; * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:48:01.418Z + * Date: 2024-09-19T04:18:04.894Z */ function ut(r) { Fe(() => { @@ -24,7 +24,7 @@ function fr(r) { r(); }, []); } -function Xt(r) { +function Zt(r) { const t = ie(!1); Fe(() => { t.current ? r() : t.current = !0; @@ -1724,7 +1724,7 @@ function Lt(r) { }; } c.cached = Lt; -function Zt(r) { +function Qt(r) { const t = N(); return V(() => r(), t, { deep: !0 }), r(); } @@ -1746,80 +1746,84 @@ function Jt(r) { const t = cr(() => r.target.setup(r.props)), e = Nt(() => t), i = r.target.render; return /* @__PURE__ */ hr.jsx(i, { ...e }); } -function Qt(r) { +function en(r) { return (t) => /* @__PURE__ */ hr.jsx(Jt, { target: r, props: t }); } -function en(r) { +function rn(r) { const [t] = L(() => Qr(r)), e = N(); return V(t, e, { deep: !0 }), t; } -function rn(r) { +function tn(r) { const [t] = L(() => et(r)), e = N(); return V(t, e), t; } -function tn(r) { +function nn(r) { const [t] = L(() => rt(r)), e = N(); return V(t, e), t; } -function nn(r) { +function an(r) { const [t] = L(() => tt(r)), e = N(); return V(t, e), t; } -function an(r) { +function sn(r) { const [t] = L(() => nt(r)), e = N(); return V(t, e), t; } -function sn(r) { +function on(r) { const [t] = L(() => it(r)), e = N(); return V(t, e), t; } -function on(r) { +function un(r) { const [t] = L(() => at(r)), e = N(); return V(t, e), t; } -function un(r, t) { +function Kt(r, t) { const [e] = L(() => st(r, t)), i = N(); return V(e, i), e; } -function Kt(r, t = {}) { +function fn({ children: r }) { + return Kt(() => r()).value; +} +function Gt(r, t = {}) { return ur(r, null, { ...t, onWarn: lr.warn, scheduler: (e) => e() }); } -const fn = (r, t) => { - const [e] = L(() => Kt(r, t)); +const ln = (r, t) => { + const [e] = L(() => Gt(r, t)); return fr(() => e.stop()), e; }; -function ln(...r) { +function cn(...r) { const t = ie(!1), [e] = L(() => ot(...r)), i = ie(e.run), s = be((a) => { if (!t.current) return t.current = !0, i.current.bind(e)(a); }, []); return e.run = s, e; } -const cn = Ce.watch.bind(Ce); +const hn = Ce.watch.bind(Ce); export { + fn as Observer, Jt as SetupComponentRenderer, - yn as baseWatch, - Qt as defineSetupComponent, + pn as baseWatch, + en as defineSetupComponent, fr as onBeforeUnmount, ut as onMounted, - Xt as onUpdated, - un as useComputed, - tn as useCustomRef, - ln as useEffectScope, - nn as useReactive, - Zt as useReactivity, - sn as useReadonly, - en as useRef, - an as useShallowReactive, - on as useShallowReadonly, - rn as useShallowRef, + Zt as onUpdated, + Kt as useComputed, + nn as useCustomRef, + cn as useEffectScope, + an as useReactive, + Qt as useReactivity, + on as useReadonly, + rn as useRef, + sn as useShallowReactive, + un as useShallowReadonly, + tn as useShallowRef, V as useWatch, - fn as useWatchEffect, - cn as watch, - Kt as watchEffect, + ln as useWatchEffect, + hn as watch, + Gt as watchEffect, Ce as watcherInstance }; diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs index b621d59..a98966c 100644 --- a/dist/veact.umd.cjs +++ b/dist/veact.umd.cjs @@ -1,4 +1,4 @@ -(function(E,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react"),require("@vue/reactivity")):typeof define=="function"&&define.amd?define(["exports","react","@vue/reactivity"],R):(E=typeof globalThis<"u"?globalThis:E||self,R(E.veact={},E.React,E.VueReactivity))})(this,function(E,R,D){"use strict";/*! +(function(R,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react"),require("@vue/reactivity")):typeof define=="function"&&define.amd?define(["exports","react","@vue/reactivity"],E):(R=typeof globalThis<"u"?globalThis:R||self,E(R.veact={},R.React,R.VueReactivity))})(this,function(R,E,D){"use strict";/*! * veact v1.0.0 * https://github.com/veactjs/veact * @@ -8,8 +8,8 @@ * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T02:48:01.418Z - */function Be(t){R.useEffect(()=>{t()},[])}function Re(t){R.useEffect(()=>()=>{t()},[])}function Rt(t){const r=R.useRef(!1);R.useEffect(()=>{r.current?t():r.current=!0})}const Ee="veact",Ve={...console,log(...t){console.log(`[${Ee}]`,...t)},warn(...t){console.warn(`[${Ee}]`,...t)},error(...t){console.error(`[${Ee}]`,...t)}};function Le(t){const r=R.useRef(!0),e=R.useRef(void 0);return r.current&&(r.current=!1,e.current=t()),e.current}class Et{watch(r,e,a={}){return D.watch(r,e,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Et,N=(t,r,e={})=>{const a=R.useRef(),s=R.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=R.useCallback(()=>{a.current&&s(),a.current=ye.watch(t,(...o)=>{console.log("触发更新"),r(...o)},e)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** + * Date: 2024-09-19T04:18:04.894Z + */function Be(e){E.useEffect(()=>{e()},[])}function Re(e){E.useEffect(()=>()=>{e()},[])}function Et(e){const r=E.useRef(!1);E.useEffect(()=>{r.current?e():r.current=!0})}const Ee="veact",Ve={...console,log(...e){console.log(`[${Ee}]`,...e)},warn(...e){console.warn(`[${Ee}]`,...e)},error(...e){console.error(`[${Ee}]`,...e)}};function Le(e){const r=E.useRef(!0),t=E.useRef(void 0);return r.current&&(r.current=!1,t.current=e()),t.current}class Ot{watch(r,t,a={}){return D.watch(r,t,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Ot,N=(e,r,t={})=>{const a=E.useRef(),s=E.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=E.useCallback(()=>{a.current&&s(),a.current=ye.watch(e,(...o)=>{console.log("触发更新"),r(...o)},t)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** * @license React * react-jsx-runtime.production.min.js * @@ -17,7 +17,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ne;function Ot(){if(Ne)return ue;Ne=1;var t=R,r=Symbol.for("react.element"),e=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,f,h){var v,g={},p=null,m=null;h!==void 0&&(p=""+h),f.key!==void 0&&(p=""+f.key),f.ref!==void 0&&(m=f.ref);for(v in f)a.call(f,v)&&!i.hasOwnProperty(v)&&(g[v]=f[v]);if(l&&l.defaultProps)for(v in f=l.defaultProps,f)g[v]===void 0&&(g[v]=f[v]);return{$$typeof:r,type:l,key:p,ref:m,props:g,_owner:s.current}}return ue.Fragment=e,ue.jsx=o,ue.jsxs=o,ue}var fe={};/** + */var Ne;function St(){if(Ne)return ue;Ne=1;var e=E,r=Symbol.for("react.element"),t=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,f,h){var d,g={},p=null,m=null;h!==void 0&&(p=""+h),f.key!==void 0&&(p=""+f.key),f.ref!==void 0&&(m=f.ref);for(d in f)a.call(f,d)&&!i.hasOwnProperty(d)&&(g[d]=f[d]);if(l&&l.defaultProps)for(d in f=l.defaultProps,f)g[d]===void 0&&(g[d]=f[d]);return{$$typeof:r,type:l,key:p,ref:m,props:g,_owner:s.current}}return ue.Fragment=t,ue.jsx=o,ue.jsxs=o,ue}var fe={};/** * @license React * react-jsx-runtime.development.js * @@ -25,17 +25,17 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Je;function St(){return Je||(Je=1,process.env.NODE_ENV!=="production"&&function(){var t=R,r=Symbol.for("react.element"),e=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),M=Symbol.iterator,J="@@iterator";function X(n){if(n===null||typeof n!="object")return null;var u=M&&n[M]||n[J];return typeof u=="function"?u:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(n){{for(var u=arguments.length,d=new Array(u>1?u-1:0),y=1;y1?u-1:0),y=1;y=1&&P>=0&&b[x]!==W[P];)P--;for(;x>=1&&P>=0;x--,P--)if(b[x]!==W[P]){if(x!==1||P!==1)do if(x--,P--,P<0||b[x]!==W[P]){var L=` -`+b[x].replace(" at new "," at ");return n.displayName&&L.includes("")&&(L=L.replace("",n.displayName)),typeof n=="function"&&be.set(n,L),L}while(x>=1&&P>=0);break}}}finally{De=!1,Ae.current=S,wr(),Error.prepareStackTrace=O}var oe=n?n.displayName||n.name:"",ne=oe?ge(oe):"";return typeof n=="function"&&be.set(n,ne),ne}function Er(n,u,d){return ut(n,!1)}function Or(n){var u=n.prototype;return!!(u&&u.isReactComponent)}function me(n,u,d){if(n==null)return"";if(typeof n=="function")return ut(n,Or(n));if(typeof n=="string")return ge(n);switch(n){case h:return ge("Suspense");case v:return ge("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case f:return Er(n.render);case g:return me(n.type,u,d);case p:{var y=n,O=y._payload,S=y._init;try{return me(S(O),u,d)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,ft={},lt=k.ReactDebugCurrentFrame;function we(n){if(n){var u=n._owner,d=me(n.type,n._source,u?u.type:null);lt.setExtraStackFrame(d)}else lt.setExtraStackFrame(null)}function Sr(n,u,d,y,O){{var S=Function.call.bind(de);for(var w in n)if(S(n,w)){var b=void 0;try{if(typeof n[w]!="function"){var W=Error((y||"React class")+": "+d+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}b=n[w](u,w,y,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){b=x}b&&!(b instanceof Error)&&(we(O),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",d,w,typeof b),we(null)),b instanceof Error&&!(b.message in ft)&&(ft[b.message]=!0,we(O),C("Failed %s type: %s",d,b.message),we(null))}}}var Tr=Array.isArray;function Ie(n){return Tr(n)}function jr(n){{var u=typeof Symbol=="function"&&Symbol.toStringTag,d=u&&n[Symbol.toStringTag]||n.constructor.name||"Object";return d}}function kr(n){try{return ct(n),!1}catch{return!0}}function ct(n){return""+n}function ht(n){if(kr(n))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",jr(n)),ct(n)}var ve=k.ReactCurrentOwner,xr={key:!0,ref:!0,__self:!0,__source:!0},dt,vt,Fe;Fe={};function Pr(n){if(de.call(n,"ref")){var u=Object.getOwnPropertyDescriptor(n,"ref").get;if(u&&u.isReactWarning)return!1}return n.ref!==void 0}function Cr(n){if(de.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function Ar(n,u){if(typeof n.ref=="string"&&ve.current&&u&&ve.current.stateNode!==u){var d=F(ve.current.type);Fe[d]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(ve.current.type),n.ref),Fe[d]=!0)}}function Mr(n,u){{var d=function(){dt||(dt=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"key",{get:d,configurable:!0})}}function Dr(n,u){{var d=function(){vt||(vt=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};d.isReactWarning=!0,Object.defineProperty(n,"ref",{get:d,configurable:!0})}}var Ir=function(n,u,d,y,O,S,w){var b={$$typeof:r,type:n,key:u,ref:d,props:w,_owner:S};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function Fr(n,u,d,y,O){{var S,w={},b=null,W=null;d!==void 0&&(ht(d),b=""+d),Cr(u)&&(ht(u.key),b=""+u.key),Pr(u)&&(W=u.ref,Ar(u,O));for(S in u)de.call(u,S)&&!xr.hasOwnProperty(S)&&(w[S]=u[S]);if(n&&n.defaultProps){var x=n.defaultProps;for(S in x)w[S]===void 0&&(w[S]=x[S])}if(b||W){var P=typeof n=="function"?n.displayName||n.name||"Unknown":n;b&&Mr(w,P),W&&Dr(w,P)}return Ir(n,b,W,O,y,ve.current,w)}}var We=k.ReactCurrentOwner,yt=k.ReactDebugCurrentFrame;function se(n){if(n){var u=n._owner,d=me(n.type,n._source,u?u.type:null);yt.setExtraStackFrame(d)}else yt.setExtraStackFrame(null)}var Ue;Ue=!1;function ze(n){return typeof n=="object"&&n!==null&&n.$$typeof===r}function pt(){{if(We.current){var n=F(We.current.type);if(n)return` +`+b[x].replace(" at new "," at ");return n.displayName&&L.includes("")&&(L=L.replace("",n.displayName)),typeof n=="function"&&be.set(n,L),L}while(x>=1&&P>=0);break}}}finally{De=!1,Ae.current=S,Rr(),Error.prepareStackTrace=O}var oe=n?n.displayName||n.name:"",ne=oe?ge(oe):"";return typeof n=="function"&&be.set(n,ne),ne}function Or(n,u,v){return ft(n,!1)}function Sr(n){var u=n.prototype;return!!(u&&u.isReactComponent)}function me(n,u,v){if(n==null)return"";if(typeof n=="function")return ft(n,Sr(n));if(typeof n=="string")return ge(n);switch(n){case h:return ge("Suspense");case d:return ge("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case f:return Or(n.render);case g:return me(n.type,u,v);case p:{var y=n,O=y._payload,S=y._init;try{return me(S(O),u,v)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,lt={},ct=k.ReactDebugCurrentFrame;function we(n){if(n){var u=n._owner,v=me(n.type,n._source,u?u.type:null);ct.setExtraStackFrame(v)}else ct.setExtraStackFrame(null)}function Tr(n,u,v,y,O){{var S=Function.call.bind(ve);for(var w in n)if(S(n,w)){var b=void 0;try{if(typeof n[w]!="function"){var W=Error((y||"React class")+": "+v+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}b=n[w](u,w,y,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){b=x}b&&!(b instanceof Error)&&(we(O),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",v,w,typeof b),we(null)),b instanceof Error&&!(b.message in lt)&&(lt[b.message]=!0,we(O),C("Failed %s type: %s",v,b.message),we(null))}}}var jr=Array.isArray;function Ie(n){return jr(n)}function kr(n){{var u=typeof Symbol=="function"&&Symbol.toStringTag,v=u&&n[Symbol.toStringTag]||n.constructor.name||"Object";return v}}function xr(n){try{return ht(n),!1}catch{return!0}}function ht(n){return""+n}function vt(n){if(xr(n))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kr(n)),ht(n)}var de=k.ReactCurrentOwner,Pr={key:!0,ref:!0,__self:!0,__source:!0},dt,yt,Fe;Fe={};function Cr(n){if(ve.call(n,"ref")){var u=Object.getOwnPropertyDescriptor(n,"ref").get;if(u&&u.isReactWarning)return!1}return n.ref!==void 0}function Ar(n){if(ve.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function Mr(n,u){if(typeof n.ref=="string"&&de.current&&u&&de.current.stateNode!==u){var v=F(de.current.type);Fe[v]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(de.current.type),n.ref),Fe[v]=!0)}}function Dr(n,u){{var v=function(){dt||(dt=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};v.isReactWarning=!0,Object.defineProperty(n,"key",{get:v,configurable:!0})}}function Ir(n,u){{var v=function(){yt||(yt=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};v.isReactWarning=!0,Object.defineProperty(n,"ref",{get:v,configurable:!0})}}var Fr=function(n,u,v,y,O,S,w){var b={$$typeof:r,type:n,key:u,ref:v,props:w,_owner:S};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function Wr(n,u,v,y,O){{var S,w={},b=null,W=null;v!==void 0&&(vt(v),b=""+v),Ar(u)&&(vt(u.key),b=""+u.key),Cr(u)&&(W=u.ref,Mr(u,O));for(S in u)ve.call(u,S)&&!Pr.hasOwnProperty(S)&&(w[S]=u[S]);if(n&&n.defaultProps){var x=n.defaultProps;for(S in x)w[S]===void 0&&(w[S]=x[S])}if(b||W){var P=typeof n=="function"?n.displayName||n.name||"Unknown":n;b&&Dr(w,P),W&&Ir(w,P)}return Fr(n,b,W,O,y,de.current,w)}}var We=k.ReactCurrentOwner,pt=k.ReactDebugCurrentFrame;function se(n){if(n){var u=n._owner,v=me(n.type,n._source,u?u.type:null);pt.setExtraStackFrame(v)}else pt.setExtraStackFrame(null)}var Ue;Ue=!1;function ze(n){return typeof n=="object"&&n!==null&&n.$$typeof===r}function _t(){{if(We.current){var n=F(We.current.type);if(n)return` -Check the render method of \``+n+"`."}return""}}function Wr(n){return""}var _t={};function Ur(n){{var u=pt();if(!u){var d=typeof n=="string"?n:n.displayName||n.name;d&&(u=` +Check the render method of \``+n+"`."}return""}}function Ur(n){return""}var gt={};function zr(n){{var u=_t();if(!u){var v=typeof n=="string"?n:n.displayName||n.name;v&&(u=` -Check the top-level render call using <`+d+">.")}return u}}function gt(n,u){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var d=Ur(u);if(_t[d])return;_t[d]=!0;var y="";n&&n._owner&&n._owner!==We.current&&(y=" It was passed a child from "+F(n._owner.type)+"."),se(n),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,y),se(null)}}function bt(n,u){{if(typeof n!="object")return;if(Ie(n))for(var d=0;d",b=" Did you accidentally export a JSX literal instead of a component?"):x=typeof n,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,b)}var P=Fr(n,u,d,O,S);if(P==null)return P;if(w){var L=u.children;if(L!==void 0)if(y)if(Ie(L)){for(var oe=0;oe0?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}";if(!mt[ne+Ye]){var Jr=z.length>0?"{"+z.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX: +Check the top-level render call using <`+v+">.")}return u}}function bt(n,u){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var v=zr(u);if(gt[v])return;gt[v]=!0;var y="";n&&n._owner&&n._owner!==We.current&&(y=" It was passed a child from "+F(n._owner.type)+"."),se(n),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,y),se(null)}}function mt(n,u){{if(typeof n!="object")return;if(Ie(n))for(var v=0;v",b=" Did you accidentally export a JSX literal instead of a component?"):x=typeof n,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,b)}var P=Wr(n,u,v,O,S);if(P==null)return P;if(w){var L=u.children;if(L!==void 0)if(y)if(Ie(L)){for(var oe=0;oe0?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}";if(!wt[ne+Ye]){var Kr=z.length>0?"{"+z.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; - <%s key={someKey} {...props} />`,Ye,ne,Jr,ne),mt[ne+Ye]=!0}}return n===a?Yr(P):zr(P),P}}function Br(n,u,d){return wt(n,u,d,!0)}function Vr(n,u,d){return wt(n,u,d,!1)}var Lr=Vr,Nr=Br;fe.Fragment=a,fe.jsx=Lr,fe.jsxs=Nr}()),fe}process.env.NODE_ENV==="production"?Oe.exports=Ot():Oe.exports=St();var Ke=Oe.exports;const Tt=t=>t+1,H=()=>R.useReducer(Tt,0)[1];var c={};function j(t,e){var e=e||{};this._head=0,this._tail=0,this._capacity=e.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(t)&&this._fromArray(t)}j.prototype.peekAt=function(r){var e=r;if(e===(e|0)){var a=this.size();if(!(e>=a||e<-a))return e<0&&(e+=a),e=this._head+e&this._capacityMask,this._list[e]}},j.prototype.get=function(r){return this.peekAt(r)},j.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},j.prototype.peekFront=function(){return this.peek()},j.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(j.prototype,"length",{get:function(){return this.size()}}),j.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),e}},j.prototype.push=function(r){if(r===void 0)return this.size();var e=this._tail;return this._list[e]=r,this._tail=e+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&r<=e>>>2&&this._shrinkArray(),a}},j.prototype.removeOne=function(r){var e=r;if(e===(e|0)&&this._head!==this._tail){var a=this.size(),s=this._list.length;if(!(e>=a||e<-a)){e<0&&(e+=a),e=this._head+e&this._capacityMask;var i=this._list[e],o;if(r0;o--)this._list[e]=this._list[e=e-1+s&this._capacityMask];this._list[e]=void 0,this._head=this._head+1+s&this._capacityMask}else{for(o=a-1-r;o>0;o--)this._list[e]=this._list[e=e+1+s&this._capacityMask];this._list[e]=void 0,this._tail=this._tail-1+s&this._capacityMask}return i}}},j.prototype.remove=function(r,e){var a=r,s,i=e;if(a===(a|0)&&this._head!==this._tail){var o=this.size(),l=this._list.length;if(!(a>=o||a<-o||e<1)){if(a<0&&(a+=o),e===1||!e)return s=new Array(1),s[0]=this.removeOne(a),s;if(a===0&&a+e>=o)return s=this.toArray(),this.clear(),s;a+e>o&&(e=o-a);var f;for(s=new Array(e),f=0;f0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(r===0){for(this._head=this._head+e+l&this._capacityMask,f=e-1;f>0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(a0;f--)this.unshift(this._list[a=a-1+l&this._capacityMask]);for(a=this._head-1+l&this._capacityMask;i>0;)this._list[a=a-1+l&this._capacityMask]=void 0,i--;r<0&&(this._tail=a)}else{for(this._tail=a,a=a+e+l&this._capacityMask,f=o-(e+r);f>0;f--)this.push(this._list[a++]);for(a=this._tail;i>0;)this._list[a=a+1+l&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=l>>>2&&this._shrinkArray(),s}}},j.prototype.splice=function(r,e){var a=r;if(a===(a|0)){var s=this.size();if(a<0&&(a+=s),!(a>s))if(arguments.length>2){var i,o,l,f=arguments.length,h=this._list.length,v=2;if(!s||a0&&(this._head=this._head+a+h&this._capacityMask)):(l=this.remove(a,e),this._head=this._head+a+h&this._capacityMask);f>v;)this.unshift(arguments[--f]);for(i=a;i>0;i--)this.unshift(o[i-1])}else{o=new Array(s-(a+e));var g=o.length;for(i=0;ithis._tail){for(i=this._head;i>>=1,this._capacityMask>>>=1};var jt=j,Ge={exports:{}};(function(t){var r=function(){function e(p,m){return m!=null&&p instanceof m}var a;try{a=Map}catch{a=function(){}}var s;try{s=Set}catch{s=function(){}}var i;try{i=Promise}catch{i=function(){}}function o(p,m,M,J,X){typeof m=="object"&&(M=m.depth,J=m.prototype,X=m.includeNonEnumerable,m=m.circular);var k=[],C=[],Ce=typeof Buffer<"u";typeof m>"u"&&(m=!0),typeof M>"u"&&(M=1/0);function K(_,G){if(_===null)return null;if(G===0)return _;var T,te;if(typeof _!="object")return _;if(e(_,a))T=new a;else if(e(_,s))T=new s;else if(e(_,i))T=new i(function(Q,q){_.then(function($){Q(K($,G-1))},function($){q(K($,G-1))})});else if(o.__isArray(_))T=[];else if(o.__isRegExp(_))T=new RegExp(_.source,g(_)),_.lastIndex&&(T.lastIndex=_.lastIndex);else if(o.__isDate(_))T=new Date(_.getTime());else{if(Ce&&Buffer.isBuffer(_))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(_.length):T=new Buffer(_.length),_.copy(T),T;e(_,Error)?T=Object.create(_):typeof J>"u"?(te=Object.getPrototypeOf(_),T=Object.create(te)):(T=Object.create(J),te=J)}if(m){var le=k.indexOf(_);if(le!=-1)return C[le];k.push(_),C.push(T)}e(_,a)&&_.forEach(function(Q,q){var $=K(q,G-1),_e=K(Q,G-1);T.set($,_e)}),e(_,s)&&_.forEach(function(Q){var q=K(Q,G-1);T.add(q)});for(var Y in _){var ce;te&&(ce=Object.getOwnPropertyDescriptor(te,Y)),!(ce&&ce.set==null)&&(T[Y]=K(_[Y],G-1))}if(Object.getOwnPropertySymbols)for(var he=Object.getOwnPropertySymbols(_),Y=0;Y0&&i[i.length-1])&&(h[0]===6||h[0]===2)){e=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},pe=B&&B.__read||function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var a=e.call(t),s,i=[],o;try{for(;(r===void 0||r-- >0)&&!(s=a.next()).done;)i.push(s.value)}catch(l){o={error:l}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(o)throw o.error}}return i},ae=B&&B.__spread||function(){for(var t=[],r=0;rt(),r,{deep:!0}),t()}function sr(t){function*r(){for(let e in t)yield t[e]}return $e(r())}function or(t){const r=H(),e=R.useCallback(()=>{const s=t();return sr(s).filter(o=>D.isRef(o)||D.isReactive(o))},[t]),a=R.useMemo(()=>e(),[e]);return N(()=>a,r,{deep:!0}),t()}function nt(t){const r=Le(()=>t.target.setup(t.props)),e=or(()=>r),a=t.target.render;return Ke.jsx(a,{...e})}function ur(t){return r=>Ke.jsx(nt,{target:t,props:r})}function fr(t){const[r]=R.useState(()=>D.ref(t)),e=H();return N(r,e,{deep:!0}),r}function lr(t){const[r]=R.useState(()=>D.shallowRef(t)),e=H();return N(r,e),r}function cr(t){const[r]=R.useState(()=>D.customRef(t)),e=H();return N(r,e),r}function hr(t){const[r]=R.useState(()=>D.reactive(t)),e=H();return N(r,e),r}function dr(t){const[r]=R.useState(()=>D.shallowReactive(t)),e=H();return N(r,e),r}function vr(t){const[r]=R.useState(()=>D.readonly(t)),e=H();return N(r,e),r}function yr(t){const[r]=R.useState(()=>D.shallowReadonly(t)),e=H();return N(r,e),r}function pr(t,r){const[e]=R.useState(()=>D.computed(t,r)),a=H();return N(e,a),e}function at(t,r={}){return D.watch(t,null,{...r,onWarn:Ve.warn,scheduler:e=>e()})}const _r=(t,r)=>{const[e]=R.useState(()=>at(t,r));return Re(()=>e.stop()),e};function gr(...t){const r=R.useRef(!1),[e]=R.useState(()=>D.effectScope(...t)),a=R.useRef(e.run),s=R.useCallback(i=>{if(!r.current)return r.current=!0,a.current.bind(e)(i)},[]);return e.run=s,e}const br=ye.watch.bind(ye);Object.defineProperty(E,"baseWatch",{enumerable:!0,get:()=>D.watch}),E.SetupComponentRenderer=nt,E.defineSetupComponent=ur,E.onBeforeUnmount=Re,E.onMounted=Be,E.onUpdated=Rt,E.useComputed=pr,E.useCustomRef=cr,E.useEffectScope=gr,E.useReactive=hr,E.useReactivity=ir,E.useReadonly=vr,E.useRef=fr,E.useShallowReactive=dr,E.useShallowReadonly=yr,E.useShallowRef=lr,E.useWatch=N,E.useWatchEffect=_r,E.watch=br,E.watchEffect=at,E.watcherInstance=ye,Object.keys(D).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(E,t)&&Object.defineProperty(E,t,{enumerable:!0,get:()=>D[t]})}),Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}); + <%s key={someKey} {...props} />`,Ye,ne,Kr,ne),wt[ne+Ye]=!0}}return n===a?Br(P):Yr(P),P}}function Vr(n,u,v){return Rt(n,u,v,!0)}function Lr(n,u,v){return Rt(n,u,v,!1)}var Nr=Lr,Jr=Vr;fe.Fragment=a,fe.jsx=Nr,fe.jsxs=Jr}()),fe}process.env.NODE_ENV==="production"?Oe.exports=St():Oe.exports=Tt();var Ke=Oe.exports;const jt=e=>e+1,H=()=>E.useReducer(jt,0)[1];var c={};function j(e,t){var t=t||{};this._head=0,this._tail=0,this._capacity=t.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(e)&&this._fromArray(e)}j.prototype.peekAt=function(r){var t=r;if(t===(t|0)){var a=this.size();if(!(t>=a||t<-a))return t<0&&(t+=a),t=this._head+t&this._capacityMask,this._list[t]}},j.prototype.get=function(r){return this.peekAt(r)},j.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},j.prototype.peekFront=function(){return this.peek()},j.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(j.prototype,"length",{get:function(){return this.size()}}),j.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},j.prototype.push=function(r){if(r===void 0)return this.size();var t=this._tail;return this._list[t]=r,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&r<=t>>>2&&this._shrinkArray(),a}},j.prototype.removeOne=function(r){var t=r;if(t===(t|0)&&this._head!==this._tail){var a=this.size(),s=this._list.length;if(!(t>=a||t<-a)){t<0&&(t+=a),t=this._head+t&this._capacityMask;var i=this._list[t],o;if(r0;o--)this._list[t]=this._list[t=t-1+s&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+s&this._capacityMask}else{for(o=a-1-r;o>0;o--)this._list[t]=this._list[t=t+1+s&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+s&this._capacityMask}return i}}},j.prototype.remove=function(r,t){var a=r,s,i=t;if(a===(a|0)&&this._head!==this._tail){var o=this.size(),l=this._list.length;if(!(a>=o||a<-o||t<1)){if(a<0&&(a+=o),t===1||!t)return s=new Array(1),s[0]=this.removeOne(a),s;if(a===0&&a+t>=o)return s=this.toArray(),this.clear(),s;a+t>o&&(t=o-a);var f;for(s=new Array(t),f=0;f0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(r===0){for(this._head=this._head+t+l&this._capacityMask,f=t-1;f>0;f--)this._list[a=a+1+l&this._capacityMask]=void 0;return s}if(a0;f--)this.unshift(this._list[a=a-1+l&this._capacityMask]);for(a=this._head-1+l&this._capacityMask;i>0;)this._list[a=a-1+l&this._capacityMask]=void 0,i--;r<0&&(this._tail=a)}else{for(this._tail=a,a=a+t+l&this._capacityMask,f=o-(t+r);f>0;f--)this.push(this._list[a++]);for(a=this._tail;i>0;)this._list[a=a+1+l&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=l>>>2&&this._shrinkArray(),s}}},j.prototype.splice=function(r,t){var a=r;if(a===(a|0)){var s=this.size();if(a<0&&(a+=s),!(a>s))if(arguments.length>2){var i,o,l,f=arguments.length,h=this._list.length,d=2;if(!s||a0&&(this._head=this._head+a+h&this._capacityMask)):(l=this.remove(a,t),this._head=this._head+a+h&this._capacityMask);f>d;)this.unshift(arguments[--f]);for(i=a;i>0;i--)this.unshift(o[i-1])}else{o=new Array(s-(a+t));var g=o.length;for(i=0;ithis._tail){for(i=this._head;i>>=1,this._capacityMask>>>=1};var kt=j,Ge={exports:{}};(function(e){var r=function(){function t(p,m){return m!=null&&p instanceof m}var a;try{a=Map}catch{a=function(){}}var s;try{s=Set}catch{s=function(){}}var i;try{i=Promise}catch{i=function(){}}function o(p,m,M,J,X){typeof m=="object"&&(M=m.depth,J=m.prototype,X=m.includeNonEnumerable,m=m.circular);var k=[],C=[],Ce=typeof Buffer<"u";typeof m>"u"&&(m=!0),typeof M>"u"&&(M=1/0);function K(_,G){if(_===null)return null;if(G===0)return _;var T,te;if(typeof _!="object")return _;if(t(_,a))T=new a;else if(t(_,s))T=new s;else if(t(_,i))T=new i(function(Q,q){_.then(function($){Q(K($,G-1))},function($){q(K($,G-1))})});else if(o.__isArray(_))T=[];else if(o.__isRegExp(_))T=new RegExp(_.source,g(_)),_.lastIndex&&(T.lastIndex=_.lastIndex);else if(o.__isDate(_))T=new Date(_.getTime());else{if(Ce&&Buffer.isBuffer(_))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(_.length):T=new Buffer(_.length),_.copy(T),T;t(_,Error)?T=Object.create(_):typeof J>"u"?(te=Object.getPrototypeOf(_),T=Object.create(te)):(T=Object.create(J),te=J)}if(m){var le=k.indexOf(_);if(le!=-1)return C[le];k.push(_),C.push(T)}t(_,a)&&_.forEach(function(Q,q){var $=K(q,G-1),_e=K(Q,G-1);T.set($,_e)}),t(_,s)&&_.forEach(function(Q){var q=K(Q,G-1);T.add(q)});for(var Y in _){var ce;te&&(ce=Object.getOwnPropertyDescriptor(te,Y)),!(ce&&ce.set==null)&&(T[Y]=K(_[Y],G-1))}if(Object.getOwnPropertySymbols)for(var he=Object.getOwnPropertySymbols(_),Y=0;Y0&&i[i.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},pe=B&&B.__read||function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var a=t.call(e),s,i=[],o;try{for(;(r===void 0||r-- >0)&&!(s=a.next()).done;)i.push(s.value)}catch(l){o={error:l}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i},ae=B&&B.__spread||function(){for(var e=[],r=0;re(),r,{deep:!0}),e()}function or(e){function*r(){for(let t in e)yield e[t]}return $e(r())}function ur(e){const r=H(),t=E.useCallback(()=>{const s=e();return or(s).filter(o=>D.isRef(o)||D.isReactive(o))},[e]),a=E.useMemo(()=>t(),[t]);return N(()=>a,r,{deep:!0}),e()}function nt(e){const r=Le(()=>e.target.setup(e.props)),t=ur(()=>r),a=e.target.render;return Ke.jsx(a,{...t})}function fr(e){return r=>Ke.jsx(nt,{target:e,props:r})}function lr(e){const[r]=E.useState(()=>D.ref(e)),t=H();return N(r,t,{deep:!0}),r}function cr(e){const[r]=E.useState(()=>D.shallowRef(e)),t=H();return N(r,t),r}function hr(e){const[r]=E.useState(()=>D.customRef(e)),t=H();return N(r,t),r}function vr(e){const[r]=E.useState(()=>D.reactive(e)),t=H();return N(r,t),r}function dr(e){const[r]=E.useState(()=>D.shallowReactive(e)),t=H();return N(r,t),r}function yr(e){const[r]=E.useState(()=>D.readonly(e)),t=H();return N(r,t),r}function pr(e){const[r]=E.useState(()=>D.shallowReadonly(e)),t=H();return N(r,t),r}function at(e,r){const[t]=E.useState(()=>D.computed(e,r)),a=H();return N(t,a),t}function _r({children:e}){return at(()=>e()).value}function it(e,r={}){return D.watch(e,null,{...r,onWarn:Ve.warn,scheduler:t=>t()})}const gr=(e,r)=>{const[t]=E.useState(()=>it(e,r));return Re(()=>t.stop()),t};function br(...e){const r=E.useRef(!1),[t]=E.useState(()=>D.effectScope(...e)),a=E.useRef(t.run),s=E.useCallback(i=>{if(!r.current)return r.current=!0,a.current.bind(t)(i)},[]);return t.run=s,t}const mr=ye.watch.bind(ye);Object.defineProperty(R,"baseWatch",{enumerable:!0,get:()=>D.watch}),R.Observer=_r,R.SetupComponentRenderer=nt,R.defineSetupComponent=fr,R.onBeforeUnmount=Re,R.onMounted=Be,R.onUpdated=Et,R.useComputed=at,R.useCustomRef=hr,R.useEffectScope=br,R.useReactive=vr,R.useReactivity=sr,R.useReadonly=yr,R.useRef=lr,R.useShallowReactive=dr,R.useShallowReadonly=pr,R.useShallowRef=cr,R.useWatch=N,R.useWatchEffect=gr,R.watch=mr,R.watchEffect=it,R.watcherInstance=ye,Object.keys(D).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(R,e)&&Object.defineProperty(R,e,{enumerable:!0,get:()=>D[e]})}),Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}); diff --git a/src/index.ts b/src/index.ts index 8715862..da2215b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,7 +30,7 @@ export { watcherInstance, useWatch } from './watch' //兼容处理 const watch=watcherInstance.watch.bind(watcherInstance); export {watch}; - +export * from "./observer" export type { WatchOptions, MultiWatchSources } from './watch' // watchEffect and hooks diff --git a/src/observer/index.tsx b/src/observer/index.tsx new file mode 100644 index 0000000..6c6ffc0 --- /dev/null +++ b/src/observer/index.tsx @@ -0,0 +1,40 @@ +import { FunctionComponent, ReactElement, useMemo } from "react"; +import { useComputed } from "../computed"; +import React from "react"; +import { useOnce } from "../useOnce"; + +//允许组件直接对外部响应式容器进行反应 +//自动缓存dom +/** + * 对应mobx的observe + * 全函数监听 + * 让func在另一个组件的上下文中执行 + */ +function observe

(Func:(p:P)=>ReactElement){ + const t:FunctionComponent=(p)=>{ + + //todo:设法让执行过程在computed上下文中 同时保持函数上下文不变 + return Func(p); + } + return t; +} + +// let Comp=observe((p:{ +// aaa:number +// })=>{ +// return

+// }) +// let a= + + + +/** + * 对应mobx的组件 + * 函数中不能调用hook + */ +export function Observer({children}:{ + children:()=>ReactElement +}){ + const v=useComputed(()=>children()) + return v.value; +} diff --git a/src/useImState.ts b/src/useImState.ts new file mode 100644 index 0000000..c7fed6b --- /dev/null +++ b/src/useImState.ts @@ -0,0 +1,7 @@ +/** + * 立即执行state + */ + +export default function useImState(init:()=>T){ + +} From f2317cdbf1487305a8fea06119dc92bac3a70902 Mon Sep 17 00:00:00 2001 From: gmono Date: Thu, 19 Sep 2024 12:34:23 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B01.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/veact.js | 4 ++-- dist/veact.umd.cjs | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/veact.js b/dist/veact.js index c14d6e7..b3f9d33 100644 --- a/dist/veact.js +++ b/dist/veact.js @@ -3,7 +3,7 @@ import { watch as ur, isRef as Xr, isReactive as Zr, ref as Qr, shallowRef as et export * from "@vue/reactivity"; import { watch as pn } from "@vue/reactivity"; /*! - * veact v1.0.0 + * veact v1.1.0 * https://github.com/veactjs/veact * * Includes @vue/reactivity @@ -12,7 +12,7 @@ import { watch as pn } from "@vue/reactivity"; * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T04:18:04.894Z + * Date: 2024-09-19T04:33:55.899Z */ function ut(r) { Fe(() => { diff --git a/dist/veact.umd.cjs b/dist/veact.umd.cjs index a98966c..735f3bd 100644 --- a/dist/veact.umd.cjs +++ b/dist/veact.umd.cjs @@ -1,5 +1,5 @@ (function(R,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react"),require("@vue/reactivity")):typeof define=="function"&&define.amd?define(["exports","react","@vue/reactivity"],E):(R=typeof globalThis<"u"?globalThis:R||self,E(R.veact={},R.React,R.VueReactivity))})(this,function(R,E,D){"use strict";/*! - * veact v1.0.0 + * veact v1.1.0 * https://github.com/veactjs/veact * * Includes @vue/reactivity @@ -8,7 +8,7 @@ * (c) 2021-present Surmon and Veact contributors. * Released under the MIT License. * - * Date: 2024-09-19T04:18:04.894Z + * Date: 2024-09-19T04:33:55.899Z */function Be(e){E.useEffect(()=>{e()},[])}function Re(e){E.useEffect(()=>()=>{e()},[])}function Et(e){const r=E.useRef(!1);E.useEffect(()=>{r.current?e():r.current=!0})}const Ee="veact",Ve={...console,log(...e){console.log(`[${Ee}]`,...e)},warn(...e){console.warn(`[${Ee}]`,...e)},error(...e){console.error(`[${Ee}]`,...e)}};function Le(e){const r=E.useRef(!0),t=E.useRef(void 0);return r.current&&(r.current=!1,t.current=e()),t.current}class Ot{watch(r,t,a={}){return D.watch(r,t,{...a,onWarn:Ve.warn,scheduler:s=>s()})}}const ye=new Ot,N=(e,r,t={})=>{const a=E.useRef(),s=E.useCallback(()=>{a.current&&(a.current(),a.current=void 0)},[]),i=E.useCallback(()=>{a.current&&s(),a.current=ye.watch(e,(...o)=>{console.log("触发更新"),r(...o)},t)},[]);return Be(()=>{console.log("执行监听"),i()}),Re(()=>{console.log("取消监听"),s()}),Le(()=>{console.log("初始监听"),i()}),a};var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}},ue={};/** * @license React * react-jsx-runtime.production.min.js diff --git a/package.json b/package.json index 674e8dc..07134fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "veact", - "version": "1.0.0", + "version": "1.1.0", "description": "Mutable state enhancer library for React by @vue/reactivity", "keywords": [ "React",