@kdujs/reactivity-canary
Advanced tools
Comparing version 3.20240115.0-minor.0 to 3.20240115.0
@@ -301,3 +301,3 @@ 'use strict'; | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 >= newLength) { | ||
if (key2 === "length" || !shared.isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
@@ -698,3 +698,3 @@ } | ||
} | ||
return type === "delete" ? false : this; | ||
return type === "delete" ? false : type === "clear" ? void 0 : this; | ||
}; | ||
@@ -701,0 +701,0 @@ } |
@@ -280,3 +280,3 @@ 'use strict'; | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 >= newLength) { | ||
if (key2 === "length" || !shared.isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
@@ -649,3 +649,3 @@ } | ||
return function(...args) { | ||
return type === "delete" ? false : this; | ||
return type === "delete" ? false : type === "clear" ? void 0 : this; | ||
}; | ||
@@ -652,0 +652,0 @@ } |
import { IfAny } from '@kdujs/shared'; | ||
export declare const enum TrackOpTypes { | ||
GET = "get", | ||
HAS = "has", | ||
ITERATE = "iterate" | ||
} | ||
export declare const enum TriggerOpTypes { | ||
SET = "set", | ||
ADD = "add", | ||
DELETE = "delete", | ||
CLEAR = "clear" | ||
} | ||
export declare class EffectScope { | ||
detached: boolean; | ||
constructor(detached?: boolean); | ||
get active(): boolean; | ||
run<T>(fn: () => T): T | undefined; | ||
stop(fromParent?: boolean): void; | ||
} | ||
/** | ||
* 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. | ||
* | ||
* @param detached - Can be used to create a "detached" effect scope. | ||
* @see {@link https://kdu-js.web.app/api/reactivity-advanced.html#effectscope} | ||
*/ | ||
export declare function effectScope(detached?: boolean): EffectScope; | ||
/** | ||
* Returns the current active effect scope if there is one. | ||
* | ||
* @see {@link https://kdu-js.web.app/api/reactivity-advanced.html#getcurrentscope} | ||
*/ | ||
export declare function getCurrentScope(): EffectScope | undefined; | ||
/** | ||
* Registers a dispose callback on the current active effect scope. The | ||
* callback will be invoked when the associated effect scope is stopped. | ||
* | ||
* @param fn - The callback function to attach to the scope's cleanup. | ||
* @see {@link https://kdu-js.web.app/api/reactivity-advanced.html#onscopedispose} | ||
*/ | ||
export declare function onScopeDispose(fn: () => void): void; | ||
type Dep = Set<ReactiveEffect> & TrackedMarkers; | ||
/** | ||
* wasTracked and newTracked maintain the status for several levels of effect | ||
* tracking recursion. One bit per level is used to define whether the dependency | ||
* was/is tracked. | ||
*/ | ||
type TrackedMarkers = { | ||
/** | ||
* wasTracked | ||
*/ | ||
w: number; | ||
/** | ||
* newTracked | ||
*/ | ||
n: number; | ||
}; | ||
export type EffectScheduler = (...args: any[]) => any; | ||
export type DebuggerEvent = { | ||
effect: ReactiveEffect; | ||
} & DebuggerEventExtraInfo; | ||
export type DebuggerEventExtraInfo = { | ||
target: object; | ||
type: TrackOpTypes | TriggerOpTypes; | ||
key: any; | ||
newValue?: any; | ||
oldValue?: any; | ||
oldTarget?: Map<any, any> | Set<any>; | ||
}; | ||
export declare const ITERATE_KEY: unique symbol; | ||
export declare class ReactiveEffect<T = any> { | ||
fn: () => T; | ||
scheduler: EffectScheduler | null; | ||
active: boolean; | ||
deps: Dep[]; | ||
parent: ReactiveEffect | undefined; | ||
onStop?: () => void; | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
constructor(fn: () => T, scheduler?: EffectScheduler | null, scope?: EffectScope); | ||
run(): T | undefined; | ||
stop(): void; | ||
} | ||
export interface DebuggerOptions { | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
} | ||
export interface ReactiveEffectOptions extends DebuggerOptions { | ||
lazy?: boolean; | ||
scheduler?: EffectScheduler; | ||
scope?: EffectScope; | ||
allowRecurse?: boolean; | ||
onStop?: () => void; | ||
} | ||
export interface ReactiveEffectRunner<T = any> { | ||
(): T; | ||
effect: ReactiveEffect; | ||
} | ||
/** | ||
* Registers the given function to track reactive updates. | ||
* | ||
* The given function will be run once immediately. Every time any reactive | ||
* property that's accessed within it gets updated, the function will run again. | ||
* | ||
* @param fn - The function that will track reactive updates. | ||
* @param options - Allows to control the effect's behaviour. | ||
* @returns A runner that can be used to control the effect after creation. | ||
*/ | ||
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner; | ||
/** | ||
* Stops the effect associated with the given runner. | ||
* | ||
* @param runner - Association with the effect to stop tracking. | ||
*/ | ||
export declare function stop(runner: ReactiveEffectRunner): void; | ||
/** | ||
* Temporarily pauses tracking. | ||
*/ | ||
export declare function pauseTracking(): void; | ||
/** | ||
* Re-enables effect tracking (if it was paused). | ||
*/ | ||
export declare function enableTracking(): void; | ||
/** | ||
* Resets the previous global effect tracking state. | ||
*/ | ||
export declare function resetTracking(): void; | ||
/** | ||
* Tracks access to a reactive property. | ||
* | ||
* This will check which effect is running at the moment and record it as dep | ||
* which records all effects that depend on the reactive property. | ||
* | ||
* @param target - Object holding the reactive property. | ||
* @param type - Defines the type of access to the reactive property. | ||
* @param key - Identifier of the reactive property to track. | ||
*/ | ||
export declare function track(target: object, type: TrackOpTypes, key: unknown): void; | ||
/** | ||
* Finds all deps associated with the target (or a specific property) and | ||
* triggers the effects stored within. | ||
* | ||
* @param target - The reactive object. | ||
* @param type - Defines the type of the operation that needs to trigger effects. | ||
* @param key - Can be used to target a specific reactive property in the target object. | ||
*/ | ||
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void; | ||
export declare const enum ReactiveFlags { | ||
@@ -219,156 +370,55 @@ SKIP = "__k_skip", | ||
type CollectionTypes = IterableCollections | WeakCollections; | ||
type IterableCollections = Map<any, any> | Set<any>; | ||
type WeakCollections = WeakMap<any, any> | WeakSet<any>; | ||
export declare const enum TrackOpTypes { | ||
GET = "get", | ||
HAS = "has", | ||
ITERATE = "iterate" | ||
declare const ComputedRefSymbol: unique symbol; | ||
export interface ComputedRef<T = any> extends WritableComputedRef<T> { | ||
readonly value: T; | ||
[ComputedRefSymbol]: true; | ||
} | ||
export declare const enum TriggerOpTypes { | ||
SET = "set", | ||
ADD = "add", | ||
DELETE = "delete", | ||
CLEAR = "clear" | ||
export interface WritableComputedRef<T> extends Ref<T> { | ||
readonly effect: ReactiveEffect<T>; | ||
} | ||
export declare class EffectScope { | ||
detached: boolean; | ||
constructor(detached?: boolean); | ||
get active(): boolean; | ||
run<T>(fn: () => T): T | undefined; | ||
stop(fromParent?: boolean): void; | ||
export type ComputedGetter<T> = (...args: any[]) => T; | ||
export type ComputedSetter<T> = (v: T) => void; | ||
export interface WritableComputedOptions<T> { | ||
get: ComputedGetter<T>; | ||
set: ComputedSetter<T>; | ||
} | ||
/** | ||
* 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. | ||
* 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 detached - Can be used to create a "detached" effect scope. | ||
* @see {@link https://kdu-js.web.app/api/reactivity-advanced.html#effectscope} | ||
*/ | ||
export declare function effectScope(detached?: boolean): EffectScope; | ||
/** | ||
* Returns the current active effect scope if there is one. | ||
* @example | ||
* ```js | ||
* // Creating a readonly computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed(() => count.value + 1) | ||
* | ||
* @see {@link https://kdu-js.web.app/api/reactivity-advanced.html#getcurrentscope} | ||
*/ | ||
export declare function getCurrentScope(): EffectScope | undefined; | ||
/** | ||
* Registers a dispose callback on the current active effect scope. The | ||
* callback will be invoked when the associated effect scope is stopped. | ||
* console.log(plusOne.value) // 2 | ||
* plusOne.value++ // error | ||
* ``` | ||
* | ||
* @param fn - The callback function to attach to the scope's cleanup. | ||
* @see {@link https://kdu-js.web.app/api/reactivity-advanced.html#onscopedispose} | ||
*/ | ||
export declare function onScopeDispose(fn: () => void): void; | ||
export type EffectScheduler = (...args: any[]) => any; | ||
export type DebuggerEvent = { | ||
effect: ReactiveEffect; | ||
} & DebuggerEventExtraInfo; | ||
export type DebuggerEventExtraInfo = { | ||
target: object; | ||
type: TrackOpTypes | TriggerOpTypes; | ||
key: any; | ||
newValue?: any; | ||
oldValue?: any; | ||
oldTarget?: Map<any, any> | Set<any>; | ||
}; | ||
export declare const ITERATE_KEY: unique symbol; | ||
export declare class ReactiveEffect<T = any> { | ||
fn: () => T; | ||
scheduler: EffectScheduler | null; | ||
active: boolean; | ||
deps: Dep[]; | ||
parent: ReactiveEffect | undefined; | ||
onStop?: () => void; | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
constructor(fn: () => T, scheduler?: EffectScheduler | null, scope?: EffectScope); | ||
run(): T | undefined; | ||
stop(): void; | ||
} | ||
export interface DebuggerOptions { | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
} | ||
export interface ReactiveEffectOptions extends DebuggerOptions { | ||
lazy?: boolean; | ||
scheduler?: EffectScheduler; | ||
scope?: EffectScope; | ||
allowRecurse?: boolean; | ||
onStop?: () => void; | ||
} | ||
export interface ReactiveEffectRunner<T = any> { | ||
(): T; | ||
effect: ReactiveEffect; | ||
} | ||
/** | ||
* Registers the given function to track reactive updates. | ||
* ```js | ||
* // Creating a writable computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed({ | ||
* get: () => count.value + 1, | ||
* set: (val) => { | ||
* count.value = val - 1 | ||
* } | ||
* }) | ||
* | ||
* The given function will be run once immediately. Every time any reactive | ||
* property that's accessed within it gets updated, the function will run again. | ||
* plusOne.value = 1 | ||
* console.log(count.value) // 0 | ||
* ``` | ||
* | ||
* @param fn - The function that will track reactive updates. | ||
* @param options - Allows to control the effect's behaviour. | ||
* @returns A runner that can be used to control the effect after creation. | ||
* @param getter - Function that produces the next value. | ||
* @param debugOptions - For debugging. See {@link https://kdu-js.web.app/guide/extras/reactivity-in-depth.html#computed-debugging}. | ||
* @see {@link https://kdu-js.web.app/api/reactivity-core.html#computed} | ||
*/ | ||
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner; | ||
/** | ||
* Stops the effect associated with the given runner. | ||
* | ||
* @param runner - Association with the effect to stop tracking. | ||
*/ | ||
export declare function stop(runner: ReactiveEffectRunner): void; | ||
/** | ||
* Temporarily pauses tracking. | ||
*/ | ||
export declare function pauseTracking(): void; | ||
/** | ||
* Re-enables effect tracking (if it was paused). | ||
*/ | ||
export declare function enableTracking(): void; | ||
/** | ||
* Resets the previous global effect tracking state. | ||
*/ | ||
export declare function resetTracking(): void; | ||
/** | ||
* Tracks access to a reactive property. | ||
* | ||
* This will check which effect is running at the moment and record it as dep | ||
* which records all effects that depend on the reactive property. | ||
* | ||
* @param target - Object holding the reactive property. | ||
* @param type - Defines the type of access to the reactive property. | ||
* @param key - Identifier of the reactive property to track. | ||
*/ | ||
export declare function track(target: object, type: TrackOpTypes, key: unknown): void; | ||
/** | ||
* Finds all deps associated with the target (or a specific property) and | ||
* triggers the effects stored within. | ||
* | ||
* @param target - The reactive object. | ||
* @param type - Defines the type of the operation that needs to trigger effects. | ||
* @param key - Can be used to target a specific reactive property in the target object. | ||
*/ | ||
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void; | ||
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>; | ||
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>; | ||
type Dep = Set<ReactiveEffect> & TrackedMarkers; | ||
/** | ||
* wasTracked and newTracked maintain the status for several levels of effect | ||
* tracking recursion. One bit per level is used to define whether the dependency | ||
* was/is tracked. | ||
*/ | ||
type TrackedMarkers = { | ||
/** | ||
* wasTracked | ||
*/ | ||
w: number; | ||
/** | ||
* newTracked | ||
*/ | ||
n: number; | ||
}; | ||
type CollectionTypes = IterableCollections | WeakCollections; | ||
type IterableCollections = Map<any, any> | Set<any>; | ||
type WeakCollections = WeakMap<any, any> | WeakSet<any>; | ||
@@ -424,3 +474,4 @@ declare const RefSymbol: unique symbol; | ||
*/ | ||
export declare function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>; | ||
export declare function shallowRef<T>(value: MaybeRef<T>): Ref<T> | ShallowRef<T>; | ||
export declare function shallowRef<T extends Ref>(value: T): T; | ||
export declare function shallowRef<T>(value: T): ShallowRef<T>; | ||
@@ -472,3 +523,3 @@ export declare function shallowRef<T = any>(): ShallowRef<T | undefined>; | ||
*/ | ||
export declare function unref<T>(ref: MaybeRef<T>): T; | ||
export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T; | ||
/** | ||
@@ -490,3 +541,3 @@ * Normalizes values / refs / getters to values. | ||
*/ | ||
export declare function toValue<T>(source: MaybeRefOrGetter<T>): T; | ||
export declare function toValue<T>(source: MaybeRefOrGetter<T> | ComputedRef<T>): T; | ||
/** | ||
@@ -604,53 +655,3 @@ * Returns a reactive proxy for the given object. | ||
declare const ComputedRefSymbol: unique symbol; | ||
export interface ComputedRef<T = any> extends WritableComputedRef<T> { | ||
readonly value: T; | ||
[ComputedRefSymbol]: true; | ||
} | ||
export interface WritableComputedRef<T> extends Ref<T> { | ||
readonly effect: ReactiveEffect<T>; | ||
} | ||
export type ComputedGetter<T> = (...args: any[]) => T; | ||
export type ComputedSetter<T> = (v: T) => void; | ||
export interface WritableComputedOptions<T> { | ||
get: ComputedGetter<T>; | ||
set: ComputedSetter<T>; | ||
} | ||
/** | ||
* 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. | ||
* | ||
* @example | ||
* ```js | ||
* // Creating a readonly computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed(() => count.value + 1) | ||
* | ||
* console.log(plusOne.value) // 2 | ||
* plusOne.value++ // error | ||
* ``` | ||
* | ||
* ```js | ||
* // Creating a writable computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed({ | ||
* get: () => count.value + 1, | ||
* set: (val) => { | ||
* count.value = val - 1 | ||
* } | ||
* }) | ||
* | ||
* plusOne.value = 1 | ||
* console.log(count.value) // 0 | ||
* ``` | ||
* | ||
* @param getter - Function that produces the next value. | ||
* @param debugOptions - For debugging. See {@link https://kdu-js.web.app/guide/extras/reactivity-in-depth.html#computed-debugging}. | ||
* @see {@link https://kdu-js.web.app/api/reactivity-core.html#computed} | ||
*/ | ||
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>; | ||
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>; | ||
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>; | ||
@@ -338,3 +338,3 @@ function makeMap(str, expectsLowerCase) { | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 >= newLength) { | ||
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
@@ -735,3 +735,3 @@ } | ||
} | ||
return type === "delete" ? false : this; | ||
return type === "delete" ? false : type === "clear" ? void 0 : this; | ||
}; | ||
@@ -738,0 +738,0 @@ } |
@@ -1,1 +0,1 @@ | ||
function t(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>l(t).slice(8,-1),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class g{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function v(t){return new g(t)}function y(t,e=p){e&&e.active&&e.effects.push(t)}function w(){return p}function k(t){p&&p.cleanups.push(t)}const b=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&j)>0,m=t=>(t.n&j)>0,S=new WeakMap;let O=0,j=1;const x=30;let P;const E=Symbol(""),M=Symbol("");class z{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=P,e=A;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=P,P=this,A=!0,j=1<<++O,O<=x?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=j})(this):W(this),this.fn()}finally{O<=x&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];R(i)&&!m(i)?i.delete(t):e[s++]=i,i.w&=~j,i.n&=~j}e.length=s}})(this),j=1<<--O,P=this.parent,A=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){P===this?this.deferStop=!0:this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}function N(t,e){t.effect instanceof z&&(t=t.effect.fn);const n=new z(t);e&&(s(n,e),e.scope&&y(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}function V(t){t.effect.stop()}let A=!0;const K=[];function I(){K.push(A),A=!1}function C(){K.push(A),A=!0}function L(){const t=K.pop();A=void 0===t||t}function q(t,e,s){if(A&&P){let e=S.get(t);e||S.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=b()),B(n)}}function B(t,e){let s=!1;O<=x?m(t)||(t.n|=j,s=!R(t)):s=!t.has(P),s&&(t.add(P),P.deps.push(t))}function D(t,e,s,n,i,o){const u=S.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===s&&r(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||s>=t)&&h.push(e)}))}else switch(void 0!==s&&h.push(u.get(s)),e){case"add":r(t)?_(s)&&h.push(u.get("length")):(h.push(u.get(E)),c(t)&&h.push(u.get(M)));break;case"delete":r(t)||(h.push(u.get(E)),c(t)&&h.push(u.get(M)));break;case"set":c(t)&&h.push(u.get(E))}if(1===h.length)h[0]&&F(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);F(b(t))}}function F(t,e){const s=r(t)?t:[...t];for(const n of s)n.computed&&G(n);for(const n of s)n.computed||G(n)}function G(t,e){(t!==P||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const H=t("__proto__,__k_isRef,__isKdu"),J=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),Q=T();function T(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Ct(this);for(let e=0,i=this.length;e<i;e++)q(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Ct)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){I();const s=Ct(this)[e].apply(this,t);return L(),s}})),t}function U(t){const e=Ct(this);return q(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,c=this._shallow;if("__k_isReactive"===e)return!n;if("__k_isReadonly"===e)return n;if("__k_isShallow"===e)return c;if("__k_raw"===e&&s===(n?c?Pt:xt:c?jt:Ot).get(t))return t;const o=r(t);if(!n){if(o&&i(Q,e))return Reflect.get(Q,e,s);if("hasOwnProperty"===e)return U}const a=Reflect.get(t,e,s);return(u(e)?J.has(e):H(e))?a:(n||q(t,0,e),c?a:Gt(a)?o&&_(e)?a:a.value:h(a)?n?zt(a):Et(a):a)}}class Y extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(At(c)&&Gt(c)&&!Gt(s))return!1;if(!this._shallow&&(Kt(s)||At(s)||(c=Ct(c),s=Ct(s)),!r(t)&&Gt(c)&&!Gt(s)))return c.value=s,!0;const o=r(t)&&_(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Ct(n)&&(o?d(s,c)&&D(t,"set",e,s):D(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&D(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&J.has(e)||q(t,0,e),s}ownKeys(t){return q(t,0,r(t)?"length":E),Reflect.ownKeys(t)}}class Z extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const $=new Y,tt=new Z,et=new Y(!0),st=new Z(!0),nt=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,s=!1,n=!1){const i=Ct(t=t.__k_raw),r=Ct(e);s||(d(e,r)&&q(i,0,e),q(i,0,r));const{has:c}=it(i),o=n?nt:s?Bt:qt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ct(t,e=!1){const s=this.__k_raw,n=Ct(s),i=Ct(t);return e||(d(t,i)&&q(n,0,t),q(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ot(t,e=!1){return t=t.__k_raw,!e&&q(Ct(t),0,E),Reflect.get(t,"size",t)}function ut(t){t=Ct(t);const e=Ct(this);return it(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function ht(t,e){e=Ct(e);const s=Ct(this),{has:n,get:i}=it(s);let r=n.call(s,t);r||(t=Ct(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&D(s,"set",t,e):D(s,"add",t,e),this}function at(t){const e=Ct(this),{has:s,get:n}=it(e);let i=s.call(e,t);i||(t=Ct(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&D(e,"delete",t,void 0),r}function lt(){const t=Ct(this),e=0!==t.size,s=t.clear();return e&&D(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__k_raw,c=Ct(r),o=e?nt:t?Bt:qt;return!t&&q(c,0,E),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function _t(t,e,s){return function(...n){const i=this.__k_raw,r=Ct(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...n),l=s?nt:e?Bt:qt;return!e&&q(r,0,h?M:E),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function dt(t){return function(...e){return"delete"!==t&&this}}function pt(){const t={get(t){return rt(this,t)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!1)},e={get(t){return rt(this,t,!1,!0)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!0)},s={get(t){return rt(this,t,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!1)},n={get(t){return rt(this,t,!0,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=_t(i,!1,!1),s[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),n[i]=_t(i,!0,!0)})),[t,s,e,n]}const[gt,vt,yt,wt]=pt();function kt(t,e){const s=e?t?wt:yt:t?vt:gt;return(e,n,r)=>"__k_isReactive"===n?!t:"__k_isReadonly"===n?t:"__k_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const bt={get:kt(!1,!1)},Rt={get:kt(!1,!0)},mt={get:kt(!0,!1)},St={get:kt(!0,!0)},Ot=new WeakMap,jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Et(t){return At(t)?t:Nt(t,!1,$,bt,Ot)}function Mt(t){return Nt(t,!1,et,Rt,jt)}function zt(t){return Nt(t,!0,tt,mt,xt)}function Wt(t){return Nt(t,!0,st,St,Pt)}function Nt(t,e,s,n,i){if(!h(t))return t;if(t.__k_raw&&(!e||!t.__k_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__k_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function Vt(t){return At(t)?Vt(t.__k_raw):!(!t||!t.__k_isReactive)}function At(t){return!(!t||!t.__k_isReadonly)}function Kt(t){return!(!t||!t.__k_isShallow)}function It(t){return Vt(t)||At(t)}function Ct(t){const e=t&&t.__k_raw;return e?Ct(e):t}function Lt(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__k_skip",!0),t}const qt=t=>h(t)?Et(t):t,Bt=t=>h(t)?zt(t):t;function Dt(t){A&&P&&B((t=Ct(t)).dep||(t.dep=b()))}function Ft(t,e){const s=(t=Ct(t)).dep;s&&F(s)}function Gt(t){return!(!t||!0!==t.__k_isRef)}function Ht(t){return Qt(t,!1)}function Jt(t){return Qt(t,!0)}function Qt(t,e){return Gt(t)?t:new Tt(t,e)}class Tt{constructor(t,e){this.__k_isShallow=e,this.dep=void 0,this.__k_isRef=!0,this._rawValue=e?t:Ct(t),this._value=e?t:qt(t)}get value(){return Dt(this),this._value}set value(t){const e=this.__k_isShallow||Kt(t)||At(t);t=e?t:Ct(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:qt(t),Ft(this))}}function Ut(t){Ft(t)}function Xt(t){return Gt(t)?t.value:t}function Yt(t){return o(t)?t():Xt(t)}const Zt={get:(t,e,s)=>Xt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Gt(i)&&!Gt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function $t(t){return Vt(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__k_isRef=!0;const{get:e,set:s}=t((()=>Dt(this)),(()=>Ft(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function se(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=ce(t,s);return e}class ne{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__k_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Ct(this._object),e=this._key,null==(s=S.get(t))?void 0:s.get(e);var t,e,s}}class ie{constructor(t){this._getter=t,this.__k_isRef=!0,this.__k_isReadonly=!0}get value(){return this._getter()}}function re(t,e,s){return Gt(t)?t:o(t)?new ie(t):h(t)&&arguments.length>1?ce(t,e,s):Ht(t)}function ce(t,e,s){const n=t[e];return Gt(n)?n:new ne(t,e,s)}class oe{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__k_isRef=!0,this.__k_isReadonly=!1,this._dirty=!0,this.effect=new z(t,(()=>{this._dirty||(this._dirty=!0,Ft(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__k_isReadonly=s}get value(){const t=Ct(this);return Dt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new oe(i,r,c||!r,n)}const he=Promise.resolve(),ae=[];let le=!1;const fe=()=>{for(let t=0;t<ae.length;t++)ae[t]();ae.length=0,le=!1};class _e{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__k_isRef=!0,this.__k_isReadonly=!0;let s=!1,n=!1;this.effect=new z(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,ae.push((()=>{this.effect.active&&this._get()!==t&&Ft(this),n=!1})),le||(le=!0,he.then(fe))}for(const t of this.dep)t.computed instanceof _e&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Dt(this),Ct(this)._get()}}function de(t){return new _e(t)}export{g as EffectScope,E as ITERATE_KEY,z as ReactiveEffect,ue as computed,ee as customRef,de as deferredComputed,N as effect,v as effectScope,C as enableTracking,w as getCurrentScope,It as isProxy,Vt as isReactive,At as isReadonly,Gt as isRef,Kt as isShallow,Lt as markRaw,k as onScopeDispose,I as pauseTracking,$t as proxyRefs,Et as reactive,zt as readonly,Ht as ref,L as resetTracking,Mt as shallowReactive,Wt as shallowReadonly,Jt as shallowRef,V as stop,Ct as toRaw,re as toRef,se as toRefs,Yt as toValue,q as track,D as trigger,Ut as triggerRef,Xt as unref}; | ||
function t(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>l(t).slice(8,-1),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class g{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function v(t){return new g(t)}function y(t,e=p){e&&e.active&&e.effects.push(t)}function w(){return p}function k(t){p&&p.cleanups.push(t)}const b=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&j)>0,m=t=>(t.n&j)>0,S=new WeakMap;let O=0,j=1;const x=30;let P;const E=Symbol(""),M=Symbol("");class z{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=P,e=A;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=P,P=this,A=!0,j=1<<++O,O<=x?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=j})(this):W(this),this.fn()}finally{O<=x&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];R(i)&&!m(i)?i.delete(t):e[s++]=i,i.w&=~j,i.n&=~j}e.length=s}})(this),j=1<<--O,P=this.parent,A=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){P===this?this.deferStop=!0:this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}function N(t,e){t.effect instanceof z&&(t=t.effect.fn);const n=new z(t);e&&(s(n,e),e.scope&&y(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}function V(t){t.effect.stop()}let A=!0;const K=[];function I(){K.push(A),A=!1}function C(){K.push(A),A=!0}function L(){const t=K.pop();A=void 0===t||t}function q(t,e,s){if(A&&P){let e=S.get(t);e||S.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=b()),B(n)}}function B(t,e){let s=!1;O<=x?m(t)||(t.n|=j,s=!R(t)):s=!t.has(P),s&&(t.add(P),P.deps.push(t))}function D(t,e,s,n,i,o){const h=S.get(t);if(!h)return;let a=[];if("clear"===e)a=[...h.values()];else if("length"===s&&r(t)){const t=Number(n);h.forEach(((e,s)=>{("length"===s||!u(s)&&s>=t)&&a.push(e)}))}else switch(void 0!==s&&a.push(h.get(s)),e){case"add":r(t)?_(s)&&a.push(h.get("length")):(a.push(h.get(E)),c(t)&&a.push(h.get(M)));break;case"delete":r(t)||(a.push(h.get(E)),c(t)&&a.push(h.get(M)));break;case"set":c(t)&&a.push(h.get(E))}if(1===a.length)a[0]&&F(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);F(b(t))}}function F(t,e){const s=r(t)?t:[...t];for(const n of s)n.computed&&G(n);for(const n of s)n.computed||G(n)}function G(t,e){(t!==P||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const H=t("__proto__,__k_isRef,__isKdu"),J=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),Q=T();function T(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Ct(this);for(let e=0,i=this.length;e<i;e++)q(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Ct)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){I();const s=Ct(this)[e].apply(this,t);return L(),s}})),t}function U(t){const e=Ct(this);return q(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,c=this._shallow;if("__k_isReactive"===e)return!n;if("__k_isReadonly"===e)return n;if("__k_isShallow"===e)return c;if("__k_raw"===e&&s===(n?c?Pt:xt:c?jt:Ot).get(t))return t;const o=r(t);if(!n){if(o&&i(Q,e))return Reflect.get(Q,e,s);if("hasOwnProperty"===e)return U}const a=Reflect.get(t,e,s);return(u(e)?J.has(e):H(e))?a:(n||q(t,0,e),c?a:Gt(a)?o&&_(e)?a:a.value:h(a)?n?zt(a):Et(a):a)}}class Y extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(At(c)&&Gt(c)&&!Gt(s))return!1;if(!this._shallow&&(Kt(s)||At(s)||(c=Ct(c),s=Ct(s)),!r(t)&&Gt(c)&&!Gt(s)))return c.value=s,!0;const o=r(t)&&_(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Ct(n)&&(o?d(s,c)&&D(t,"set",e,s):D(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&D(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&J.has(e)||q(t,0,e),s}ownKeys(t){return q(t,0,r(t)?"length":E),Reflect.ownKeys(t)}}class Z extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const $=new Y,tt=new Z,et=new Y(!0),st=new Z(!0),nt=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,s=!1,n=!1){const i=Ct(t=t.__k_raw),r=Ct(e);s||(d(e,r)&&q(i,0,e),q(i,0,r));const{has:c}=it(i),o=n?nt:s?Bt:qt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ct(t,e=!1){const s=this.__k_raw,n=Ct(s),i=Ct(t);return e||(d(t,i)&&q(n,0,t),q(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ot(t,e=!1){return t=t.__k_raw,!e&&q(Ct(t),0,E),Reflect.get(t,"size",t)}function ut(t){t=Ct(t);const e=Ct(this);return it(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function ht(t,e){e=Ct(e);const s=Ct(this),{has:n,get:i}=it(s);let r=n.call(s,t);r||(t=Ct(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&D(s,"set",t,e):D(s,"add",t,e),this}function at(t){const e=Ct(this),{has:s,get:n}=it(e);let i=s.call(e,t);i||(t=Ct(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&D(e,"delete",t,void 0),r}function lt(){const t=Ct(this),e=0!==t.size,s=t.clear();return e&&D(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__k_raw,c=Ct(r),o=e?nt:t?Bt:qt;return!t&&q(c,0,E),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function _t(t,e,s){return function(...n){const i=this.__k_raw,r=Ct(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...n),l=s?nt:e?Bt:qt;return!e&&q(r,0,h?M:E),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function dt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function pt(){const t={get(t){return rt(this,t)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!1)},e={get(t){return rt(this,t,!1,!0)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!0)},s={get(t){return rt(this,t,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!1)},n={get(t){return rt(this,t,!0,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=_t(i,!1,!1),s[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),n[i]=_t(i,!0,!0)})),[t,s,e,n]}const[gt,vt,yt,wt]=pt();function kt(t,e){const s=e?t?wt:yt:t?vt:gt;return(e,n,r)=>"__k_isReactive"===n?!t:"__k_isReadonly"===n?t:"__k_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const bt={get:kt(!1,!1)},Rt={get:kt(!1,!0)},mt={get:kt(!0,!1)},St={get:kt(!0,!0)},Ot=new WeakMap,jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Et(t){return At(t)?t:Nt(t,!1,$,bt,Ot)}function Mt(t){return Nt(t,!1,et,Rt,jt)}function zt(t){return Nt(t,!0,tt,mt,xt)}function Wt(t){return Nt(t,!0,st,St,Pt)}function Nt(t,e,s,n,i){if(!h(t))return t;if(t.__k_raw&&(!e||!t.__k_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__k_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function Vt(t){return At(t)?Vt(t.__k_raw):!(!t||!t.__k_isReactive)}function At(t){return!(!t||!t.__k_isReadonly)}function Kt(t){return!(!t||!t.__k_isShallow)}function It(t){return Vt(t)||At(t)}function Ct(t){const e=t&&t.__k_raw;return e?Ct(e):t}function Lt(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__k_skip",!0),t}const qt=t=>h(t)?Et(t):t,Bt=t=>h(t)?zt(t):t;function Dt(t){A&&P&&B((t=Ct(t)).dep||(t.dep=b()))}function Ft(t,e){const s=(t=Ct(t)).dep;s&&F(s)}function Gt(t){return!(!t||!0!==t.__k_isRef)}function Ht(t){return Qt(t,!1)}function Jt(t){return Qt(t,!0)}function Qt(t,e){return Gt(t)?t:new Tt(t,e)}class Tt{constructor(t,e){this.__k_isShallow=e,this.dep=void 0,this.__k_isRef=!0,this._rawValue=e?t:Ct(t),this._value=e?t:qt(t)}get value(){return Dt(this),this._value}set value(t){const e=this.__k_isShallow||Kt(t)||At(t);t=e?t:Ct(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:qt(t),Ft(this))}}function Ut(t){Ft(t)}function Xt(t){return Gt(t)?t.value:t}function Yt(t){return o(t)?t():Xt(t)}const Zt={get:(t,e,s)=>Xt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Gt(i)&&!Gt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function $t(t){return Vt(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__k_isRef=!0;const{get:e,set:s}=t((()=>Dt(this)),(()=>Ft(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function se(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=ce(t,s);return e}class ne{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__k_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Ct(this._object),e=this._key,null==(s=S.get(t))?void 0:s.get(e);var t,e,s}}class ie{constructor(t){this._getter=t,this.__k_isRef=!0,this.__k_isReadonly=!0}get value(){return this._getter()}}function re(t,e,s){return Gt(t)?t:o(t)?new ie(t):h(t)&&arguments.length>1?ce(t,e,s):Ht(t)}function ce(t,e,s){const n=t[e];return Gt(n)?n:new ne(t,e,s)}class oe{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__k_isRef=!0,this.__k_isReadonly=!1,this._dirty=!0,this.effect=new z(t,(()=>{this._dirty||(this._dirty=!0,Ft(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__k_isReadonly=s}get value(){const t=Ct(this);return Dt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new oe(i,r,c||!r,n)}const he=Promise.resolve(),ae=[];let le=!1;const fe=()=>{for(let t=0;t<ae.length;t++)ae[t]();ae.length=0,le=!1};class _e{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__k_isRef=!0,this.__k_isReadonly=!0;let s=!1,n=!1;this.effect=new z(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,ae.push((()=>{this.effect.active&&this._get()!==t&&Ft(this),n=!1})),le||(le=!0,he.then(fe))}for(const t of this.dep)t.computed instanceof _e&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Dt(this),Ct(this)._get()}}function de(t){return new _e(t)}export{g as EffectScope,E as ITERATE_KEY,z as ReactiveEffect,ue as computed,ee as customRef,de as deferredComputed,N as effect,v as effectScope,C as enableTracking,w as getCurrentScope,It as isProxy,Vt as isReactive,At as isReadonly,Gt as isRef,Kt as isShallow,Lt as markRaw,k as onScopeDispose,I as pauseTracking,$t as proxyRefs,Et as reactive,zt as readonly,Ht as ref,L as resetTracking,Mt as shallowReactive,Wt as shallowReadonly,Jt as shallowRef,V as stop,Ct as toRaw,re as toRef,se as toRefs,Yt as toValue,q as track,D as trigger,Ut as triggerRef,Xt as unref}; |
@@ -1,2 +0,2 @@ | ||
import { extend, isArray, isMap, isIntegerKey, isSymbol, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@kdujs/shared'; | ||
import { extend, isArray, isSymbol, isMap, isIntegerKey, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@kdujs/shared'; | ||
@@ -297,3 +297,3 @@ function warn(msg, ...args) { | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 >= newLength) { | ||
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
@@ -698,3 +698,3 @@ } | ||
} | ||
return type === "delete" ? false : this; | ||
return type === "delete" ? false : type === "clear" ? void 0 : this; | ||
}; | ||
@@ -701,0 +701,0 @@ } |
@@ -341,3 +341,3 @@ var KduReactivity = (function (exports) { | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 >= newLength) { | ||
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
@@ -738,3 +738,3 @@ } | ||
} | ||
return type === "delete" ? false : this; | ||
return type === "delete" ? false : type === "clear" ? void 0 : this; | ||
}; | ||
@@ -741,0 +741,0 @@ } |
@@ -1,1 +0,1 @@ | ||
var KduReactivity=function(t){"use strict";function e(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const s=()=>{},n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),_=t=>f(t).slice(8,-1),d=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,p=(t,e)=>!Object.is(t,e);let g;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=g,!t&&g&&(this.index=(g.scopes||(g.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=g;try{return g=this,t()}finally{g=e}}}on(){g=this}off(){g=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function y(t,e=g){e&&e.active&&e.effects.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},k=t=>(t.w&S)>0,R=t=>(t.n&S)>0,b=new WeakMap;let m=0,S=1;const O=30;let j;const x=Symbol(""),E=Symbol("");class P{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=j,e=z;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,z=!0,S=1<<++m,m<=O?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=S})(this):M(this),this.fn()}finally{m<=O&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];k(i)&&!R(i)?i.delete(t):e[s++]=i,i.w&=~S,i.n&=~S}e.length=s}})(this),S=1<<--m,j=this.parent,z=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(M(this),this.onStop&&this.onStop(),this.active=!1)}}function M(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let z=!0;const W=[];function V(){W.push(z),z=!1}function A(){const t=W.pop();z=void 0===t||t}function K(t,e,s){if(z&&j){let e=b.get(t);e||b.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=w()),N(n)}}function N(t,e){let s=!1;m<=O?R(t)||(t.n|=S,s=!k(t)):s=!t.has(j),s&&(t.add(j),j.deps.push(t))}function T(t,e,s,n,i,r){const u=b.get(t);if(!u)return;let a=[];if("clear"===e)a=[...u.values()];else if("length"===s&&c(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||s>=t)&&a.push(e)}))}else switch(void 0!==s&&a.push(u.get(s)),e){case"add":c(t)?d(s)&&a.push(u.get("length")):(a.push(u.get(x)),o(t)&&a.push(u.get(E)));break;case"delete":c(t)||(a.push(u.get(x)),o(t)&&a.push(u.get(E)));break;case"set":o(t)&&a.push(u.get(x))}if(1===a.length)a[0]&&C(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);C(w(t))}}function C(t,e){const s=c(t)?t:[...t];for(const n of s)n.computed&&I(n);for(const n of s)n.computed||I(n)}function I(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const D=e("__proto__,__k_isRef,__isKdu"),L=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),Y=q();function q(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Mt(this);for(let e=0,i=this.length;e<i;e++)K(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Mt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){V();const s=Mt(this)[e].apply(this,t);return A(),s}})),t}function B(t){const e=Mt(this);return K(e,0,t),e.hasOwnProperty(t)}class F{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,i=this._shallow;if("__k_isReactive"===e)return!n;if("__k_isReadonly"===e)return n;if("__k_isShallow"===e)return i;if("__k_raw"===e&&s===(n?i?mt:bt:i?Rt:kt).get(t))return t;const o=c(t);if(!n){if(o&&r(Y,e))return Reflect.get(Y,e,s);if("hasOwnProperty"===e)return B}const u=Reflect.get(t,e,s);return(a(e)?L.has(e):D(e))?u:(n||K(t,0,e),i?u:Kt(u)?o&&d(e)?u:u.value:h(u)?n?Ot(u):St(u):u)}}class G extends F{constructor(t=!1){super(!1,t)}set(t,e,s,n){let i=t[e];if(Et(i)&&Kt(i)&&!Kt(s))return!1;if(!this._shallow&&(Pt(s)||Et(s)||(i=Mt(i),s=Mt(s)),!c(t)&&Kt(i)&&!Kt(s)))return i.value=s,!0;const o=c(t)&&d(e)?Number(e)<t.length:r(t,e),u=Reflect.set(t,e,s,n);return t===Mt(n)&&(o?p(s,i)&&T(t,"set",e,s):T(t,"add",e,s)),u}deleteProperty(t,e){const s=r(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&T(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return a(e)&&L.has(e)||K(t,0,e),s}ownKeys(t){return K(t,0,c(t)?"length":x),Reflect.ownKeys(t)}}class H extends F{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const J=new G,Q=new H,U=new G(!0),X=new H(!0),Z=t=>t,$=t=>Reflect.getPrototypeOf(t);function tt(t,e,s=!1,n=!1){const i=Mt(t=t.__k_raw),r=Mt(e);s||(p(e,r)&&K(i,0,e),K(i,0,r));const{has:c}=$(i),o=n?Z:s?Wt:zt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function et(t,e=!1){const s=this.__k_raw,n=Mt(s),i=Mt(t);return e||(p(t,i)&&K(n,0,t),K(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function st(t,e=!1){return t=t.__k_raw,!e&&K(Mt(t),0,x),Reflect.get(t,"size",t)}function nt(t){t=Mt(t);const e=Mt(this);return $(e).has.call(e,t)||(e.add(t),T(e,"add",t,t)),this}function it(t,e){e=Mt(e);const s=Mt(this),{has:n,get:i}=$(s);let r=n.call(s,t);r||(t=Mt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?p(e,c)&&T(s,"set",t,e):T(s,"add",t,e),this}function rt(t){const e=Mt(this),{has:s,get:n}=$(e);let i=s.call(e,t);i||(t=Mt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&T(e,"delete",t,void 0),r}function ct(){const t=Mt(this),e=0!==t.size,s=t.clear();return e&&T(t,"clear",void 0,void 0),s}function ot(t,e){return function(s,n){const i=this,r=i.__k_raw,c=Mt(r),o=e?Z:t?Wt:zt;return!t&&K(c,0,x),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function ut(t,e,s){return function(...n){const i=this.__k_raw,r=Mt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,h=i[t](...n),l=s?Z:e?Wt:zt;return!e&&K(r,0,a?E:x),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function at(t){return function(...e){return"delete"!==t&&this}}function ht(){const t={get(t){return tt(this,t)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!1)},e={get(t){return tt(this,t,!1,!0)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!0)},s={get(t){return tt(this,t,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!1)},n={get(t){return tt(this,t,!0,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=ut(i,!1,!1),s[i]=ut(i,!0,!1),e[i]=ut(i,!1,!0),n[i]=ut(i,!0,!0)})),[t,s,e,n]}const[lt,ft,_t,dt]=ht();function pt(t,e){const s=e?t?dt:_t:t?ft:lt;return(e,n,i)=>"__k_isReactive"===n?!t:"__k_isReadonly"===n?t:"__k_raw"===n?e:Reflect.get(r(s,n)&&n in e?s:e,n,i)}const gt={get:pt(!1,!1)},vt={get:pt(!1,!0)},yt={get:pt(!0,!1)},wt={get:pt(!0,!0)},kt=new WeakMap,Rt=new WeakMap,bt=new WeakMap,mt=new WeakMap;function St(t){return Et(t)?t:jt(t,!1,J,gt,kt)}function Ot(t){return jt(t,!0,Q,yt,bt)}function jt(t,e,s,n,i){if(!h(t))return t;if(t.__k_raw&&(!e||!t.__k_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__k_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(_(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function xt(t){return Et(t)?xt(t.__k_raw):!(!t||!t.__k_isReactive)}function Et(t){return!(!t||!t.__k_isReadonly)}function Pt(t){return!(!t||!t.__k_isShallow)}function Mt(t){const e=t&&t.__k_raw;return e?Mt(e):t}const zt=t=>h(t)?St(t):t,Wt=t=>h(t)?Ot(t):t;function Vt(t){z&&j&&N((t=Mt(t)).dep||(t.dep=w()))}function At(t,e){const s=(t=Mt(t)).dep;s&&C(s)}function Kt(t){return!(!t||!0!==t.__k_isRef)}function Nt(t){return Tt(t,!1)}function Tt(t,e){return Kt(t)?t:new Ct(t,e)}class Ct{constructor(t,e){this.__k_isShallow=e,this.dep=void 0,this.__k_isRef=!0,this._rawValue=e?t:Mt(t),this._value=e?t:zt(t)}get value(){return Vt(this),this._value}set value(t){const e=this.__k_isShallow||Pt(t)||Et(t);t=e?t:Mt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:zt(t),At(this))}}function It(t){return Kt(t)?t.value:t}const Dt={get:(t,e,s)=>It(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Kt(i)&&!Kt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};class Lt{constructor(t){this.dep=void 0,this.__k_isRef=!0;const{get:e,set:s}=t((()=>Vt(this)),(()=>At(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}class Yt{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__k_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Mt(this._object),e=this._key,null==(s=b.get(t))?void 0:s.get(e);var t,e,s}}class qt{constructor(t){this._getter=t,this.__k_isRef=!0,this.__k_isReadonly=!0}get value(){return this._getter()}}function Bt(t,e,s){const n=t[e];return Kt(n)?n:new Yt(t,e,s)}class Ft{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__k_isRef=!0,this.__k_isReadonly=!1,this._dirty=!0,this.effect=new P(t,(()=>{this._dirty||(this._dirty=!0,At(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__k_isReadonly=s}get value(){const t=Mt(this);return Vt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const Gt=Promise.resolve(),Ht=[];let Jt=!1;const Qt=()=>{for(let t=0;t<Ht.length;t++)Ht[t]();Ht.length=0,Jt=!1};class Ut{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__k_isRef=!0,this.__k_isReadonly=!0;let s=!1,n=!1;this.effect=new P(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,Ht.push((()=>{this.effect.active&&this._get()!==t&&At(this),n=!1})),Jt||(Jt=!0,Gt.then(Qt))}for(const t of this.dep)t.computed instanceof Ut&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Vt(this),Mt(this)._get()}}return t.EffectScope=v,t.ITERATE_KEY=x,t.ReactiveEffect=P,t.computed=function(t,e,n=!1){let i,r;const c=u(t);return c?(i=t,r=s):(i=t.get,r=t.set),new Ft(i,r,c||!r,n)},t.customRef=function(t){return new Lt(t)},t.deferredComputed=function(t){return new Ut(t)},t.effect=function(t,e){t.effect instanceof P&&(t=t.effect.fn);const s=new P(t);e&&(n(s,e),e.scope&&y(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i},t.effectScope=function(t){return new v(t)},t.enableTracking=function(){W.push(z),z=!0},t.getCurrentScope=function(){return g},t.isProxy=function(t){return xt(t)||Et(t)},t.isReactive=xt,t.isReadonly=Et,t.isRef=Kt,t.isShallow=Pt,t.markRaw=function(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__k_skip",!0),t},t.onScopeDispose=function(t){g&&g.cleanups.push(t)},t.pauseTracking=V,t.proxyRefs=function(t){return xt(t)?t:new Proxy(t,Dt)},t.reactive=St,t.readonly=Ot,t.ref=Nt,t.resetTracking=A,t.shallowReactive=function(t){return jt(t,!1,U,vt,Rt)},t.shallowReadonly=function(t){return jt(t,!0,X,wt,mt)},t.shallowRef=function(t){return Tt(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Mt,t.toRef=function(t,e,s){return Kt(t)?t:u(t)?new qt(t):h(t)&&arguments.length>1?Bt(t,e,s):Nt(t)},t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const s in t)e[s]=Bt(t,s);return e},t.toValue=function(t){return u(t)?t():It(t)},t.track=K,t.trigger=T,t.triggerRef=function(t){At(t)},t.unref=It,t}({}); | ||
var KduReactivity=function(t){"use strict";function e(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const s=()=>{},n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),_=t=>f(t).slice(8,-1),d=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,p=(t,e)=>!Object.is(t,e);let g;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=g,!t&&g&&(this.index=(g.scopes||(g.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=g;try{return g=this,t()}finally{g=e}}}on(){g=this}off(){g=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function y(t,e=g){e&&e.active&&e.effects.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},k=t=>(t.w&S)>0,R=t=>(t.n&S)>0,b=new WeakMap;let m=0,S=1;const O=30;let j;const x=Symbol(""),E=Symbol("");class P{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=j,e=z;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,z=!0,S=1<<++m,m<=O?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=S})(this):M(this),this.fn()}finally{m<=O&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];k(i)&&!R(i)?i.delete(t):e[s++]=i,i.w&=~S,i.n&=~S}e.length=s}})(this),S=1<<--m,j=this.parent,z=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(M(this),this.onStop&&this.onStop(),this.active=!1)}}function M(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let z=!0;const W=[];function V(){W.push(z),z=!1}function A(){const t=W.pop();z=void 0===t||t}function K(t,e,s){if(z&&j){let e=b.get(t);e||b.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=w()),N(n)}}function N(t,e){let s=!1;m<=O?R(t)||(t.n|=S,s=!k(t)):s=!t.has(j),s&&(t.add(j),j.deps.push(t))}function T(t,e,s,n,i,r){const u=b.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===s&&c(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||!a(s)&&s>=t)&&h.push(e)}))}else switch(void 0!==s&&h.push(u.get(s)),e){case"add":c(t)?d(s)&&h.push(u.get("length")):(h.push(u.get(x)),o(t)&&h.push(u.get(E)));break;case"delete":c(t)||(h.push(u.get(x)),o(t)&&h.push(u.get(E)));break;case"set":o(t)&&h.push(u.get(x))}if(1===h.length)h[0]&&C(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);C(w(t))}}function C(t,e){const s=c(t)?t:[...t];for(const n of s)n.computed&&I(n);for(const n of s)n.computed||I(n)}function I(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const D=e("__proto__,__k_isRef,__isKdu"),L=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),Y=q();function q(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Mt(this);for(let e=0,i=this.length;e<i;e++)K(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Mt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){V();const s=Mt(this)[e].apply(this,t);return A(),s}})),t}function B(t){const e=Mt(this);return K(e,0,t),e.hasOwnProperty(t)}class F{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,i=this._shallow;if("__k_isReactive"===e)return!n;if("__k_isReadonly"===e)return n;if("__k_isShallow"===e)return i;if("__k_raw"===e&&s===(n?i?mt:bt:i?Rt:kt).get(t))return t;const o=c(t);if(!n){if(o&&r(Y,e))return Reflect.get(Y,e,s);if("hasOwnProperty"===e)return B}const u=Reflect.get(t,e,s);return(a(e)?L.has(e):D(e))?u:(n||K(t,0,e),i?u:Kt(u)?o&&d(e)?u:u.value:h(u)?n?Ot(u):St(u):u)}}class G extends F{constructor(t=!1){super(!1,t)}set(t,e,s,n){let i=t[e];if(Et(i)&&Kt(i)&&!Kt(s))return!1;if(!this._shallow&&(Pt(s)||Et(s)||(i=Mt(i),s=Mt(s)),!c(t)&&Kt(i)&&!Kt(s)))return i.value=s,!0;const o=c(t)&&d(e)?Number(e)<t.length:r(t,e),u=Reflect.set(t,e,s,n);return t===Mt(n)&&(o?p(s,i)&&T(t,"set",e,s):T(t,"add",e,s)),u}deleteProperty(t,e){const s=r(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&T(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return a(e)&&L.has(e)||K(t,0,e),s}ownKeys(t){return K(t,0,c(t)?"length":x),Reflect.ownKeys(t)}}class H extends F{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const J=new G,Q=new H,U=new G(!0),X=new H(!0),Z=t=>t,$=t=>Reflect.getPrototypeOf(t);function tt(t,e,s=!1,n=!1){const i=Mt(t=t.__k_raw),r=Mt(e);s||(p(e,r)&&K(i,0,e),K(i,0,r));const{has:c}=$(i),o=n?Z:s?Wt:zt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function et(t,e=!1){const s=this.__k_raw,n=Mt(s),i=Mt(t);return e||(p(t,i)&&K(n,0,t),K(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function st(t,e=!1){return t=t.__k_raw,!e&&K(Mt(t),0,x),Reflect.get(t,"size",t)}function nt(t){t=Mt(t);const e=Mt(this);return $(e).has.call(e,t)||(e.add(t),T(e,"add",t,t)),this}function it(t,e){e=Mt(e);const s=Mt(this),{has:n,get:i}=$(s);let r=n.call(s,t);r||(t=Mt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?p(e,c)&&T(s,"set",t,e):T(s,"add",t,e),this}function rt(t){const e=Mt(this),{has:s,get:n}=$(e);let i=s.call(e,t);i||(t=Mt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&T(e,"delete",t,void 0),r}function ct(){const t=Mt(this),e=0!==t.size,s=t.clear();return e&&T(t,"clear",void 0,void 0),s}function ot(t,e){return function(s,n){const i=this,r=i.__k_raw,c=Mt(r),o=e?Z:t?Wt:zt;return!t&&K(c,0,x),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function ut(t,e,s){return function(...n){const i=this.__k_raw,r=Mt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,h=i[t](...n),l=s?Z:e?Wt:zt;return!e&&K(r,0,a?E:x),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function at(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function ht(){const t={get(t){return tt(this,t)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!1)},e={get(t){return tt(this,t,!1,!0)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!0)},s={get(t){return tt(this,t,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!1)},n={get(t){return tt(this,t,!0,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=ut(i,!1,!1),s[i]=ut(i,!0,!1),e[i]=ut(i,!1,!0),n[i]=ut(i,!0,!0)})),[t,s,e,n]}const[lt,ft,_t,dt]=ht();function pt(t,e){const s=e?t?dt:_t:t?ft:lt;return(e,n,i)=>"__k_isReactive"===n?!t:"__k_isReadonly"===n?t:"__k_raw"===n?e:Reflect.get(r(s,n)&&n in e?s:e,n,i)}const gt={get:pt(!1,!1)},vt={get:pt(!1,!0)},yt={get:pt(!0,!1)},wt={get:pt(!0,!0)},kt=new WeakMap,Rt=new WeakMap,bt=new WeakMap,mt=new WeakMap;function St(t){return Et(t)?t:jt(t,!1,J,gt,kt)}function Ot(t){return jt(t,!0,Q,yt,bt)}function jt(t,e,s,n,i){if(!h(t))return t;if(t.__k_raw&&(!e||!t.__k_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__k_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(_(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function xt(t){return Et(t)?xt(t.__k_raw):!(!t||!t.__k_isReactive)}function Et(t){return!(!t||!t.__k_isReadonly)}function Pt(t){return!(!t||!t.__k_isShallow)}function Mt(t){const e=t&&t.__k_raw;return e?Mt(e):t}const zt=t=>h(t)?St(t):t,Wt=t=>h(t)?Ot(t):t;function Vt(t){z&&j&&N((t=Mt(t)).dep||(t.dep=w()))}function At(t,e){const s=(t=Mt(t)).dep;s&&C(s)}function Kt(t){return!(!t||!0!==t.__k_isRef)}function Nt(t){return Tt(t,!1)}function Tt(t,e){return Kt(t)?t:new Ct(t,e)}class Ct{constructor(t,e){this.__k_isShallow=e,this.dep=void 0,this.__k_isRef=!0,this._rawValue=e?t:Mt(t),this._value=e?t:zt(t)}get value(){return Vt(this),this._value}set value(t){const e=this.__k_isShallow||Pt(t)||Et(t);t=e?t:Mt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:zt(t),At(this))}}function It(t){return Kt(t)?t.value:t}const Dt={get:(t,e,s)=>It(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Kt(i)&&!Kt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};class Lt{constructor(t){this.dep=void 0,this.__k_isRef=!0;const{get:e,set:s}=t((()=>Vt(this)),(()=>At(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}class Yt{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__k_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Mt(this._object),e=this._key,null==(s=b.get(t))?void 0:s.get(e);var t,e,s}}class qt{constructor(t){this._getter=t,this.__k_isRef=!0,this.__k_isReadonly=!0}get value(){return this._getter()}}function Bt(t,e,s){const n=t[e];return Kt(n)?n:new Yt(t,e,s)}class Ft{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__k_isRef=!0,this.__k_isReadonly=!1,this._dirty=!0,this.effect=new P(t,(()=>{this._dirty||(this._dirty=!0,At(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__k_isReadonly=s}get value(){const t=Mt(this);return Vt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const Gt=Promise.resolve(),Ht=[];let Jt=!1;const Qt=()=>{for(let t=0;t<Ht.length;t++)Ht[t]();Ht.length=0,Jt=!1};class Ut{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__k_isRef=!0,this.__k_isReadonly=!0;let s=!1,n=!1;this.effect=new P(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,Ht.push((()=>{this.effect.active&&this._get()!==t&&At(this),n=!1})),Jt||(Jt=!0,Gt.then(Qt))}for(const t of this.dep)t.computed instanceof Ut&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Vt(this),Mt(this)._get()}}return t.EffectScope=v,t.ITERATE_KEY=x,t.ReactiveEffect=P,t.computed=function(t,e,n=!1){let i,r;const c=u(t);return c?(i=t,r=s):(i=t.get,r=t.set),new Ft(i,r,c||!r,n)},t.customRef=function(t){return new Lt(t)},t.deferredComputed=function(t){return new Ut(t)},t.effect=function(t,e){t.effect instanceof P&&(t=t.effect.fn);const s=new P(t);e&&(n(s,e),e.scope&&y(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i},t.effectScope=function(t){return new v(t)},t.enableTracking=function(){W.push(z),z=!0},t.getCurrentScope=function(){return g},t.isProxy=function(t){return xt(t)||Et(t)},t.isReactive=xt,t.isReadonly=Et,t.isRef=Kt,t.isShallow=Pt,t.markRaw=function(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__k_skip",!0),t},t.onScopeDispose=function(t){g&&g.cleanups.push(t)},t.pauseTracking=V,t.proxyRefs=function(t){return xt(t)?t:new Proxy(t,Dt)},t.reactive=St,t.readonly=Ot,t.ref=Nt,t.resetTracking=A,t.shallowReactive=function(t){return jt(t,!1,U,vt,Rt)},t.shallowReadonly=function(t){return jt(t,!0,X,wt,mt)},t.shallowRef=function(t){return Tt(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Mt,t.toRef=function(t,e,s){return Kt(t)?t:u(t)?new qt(t):h(t)&&arguments.length>1?Bt(t,e,s):Nt(t)},t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const s in t)e[s]=Bt(t,s);return e},t.toValue=function(t){return u(t)?t():It(t)},t.track=K,t.trigger=T,t.triggerRef=function(t){At(t)},t.unref=It,t}({}); |
{ | ||
"name": "@kdujs/reactivity-canary", | ||
"version": "3.20240115.0-minor.0", | ||
"version": "3.20240115.0", | ||
"description": "@kdujs/reactivity", | ||
@@ -39,4 +39,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20240115.0-minor.0" | ||
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20240115.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
221638
6946
1
+ Added@kdujs/shared-canary@3.20240115.0(transitive)
- Removed@kdujs/shared-canary@3.20240115.0-minor.0(transitive)