Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kdujs/reactivity-canary

Package Overview
Dependencies
Maintainers
0
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kdujs/reactivity-canary - npm Package Compare versions

Comparing version 3.20241202.0-minor.0 to 3.20241202.0

662

dist/reactivity.cjs.js

@@ -0,1 +1,6 @@

/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
'use strict';

@@ -111,95 +116,80 @@

const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit;
}
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = /* @__PURE__ */ new WeakMap();
let effectTrackDepth = 0;
let trackOpBit = 1;
const maxMarkerBits = 30;
let activeEffect;
const ITERATE_KEY = Symbol("iterate" );
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
constructor(fn, trigger, scheduler, scope) {
this.fn = fn;
this.trigger = trigger;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
this.parent = void 0;
/**
* @internal
*/
this._dirtyLevel = 4;
/**
* @internal
*/
this._trackId = 0;
/**
* @internal
*/
this._runnings = 0;
/**
* @internal
*/
this._shouldSchedule = false;
/**
* @internal
*/
this._depsLength = 0;
recordEffectScope(this, scope);
}
get dirty() {
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
this._dirtyLevel = 1;
pauseTracking();
for (let i = 0; i < this._depsLength; i++) {
const dep = this.deps[i];
if (dep.computed) {
triggerComputed(dep.computed);
if (this._dirtyLevel >= 4) {
break;
}
}
}
if (this._dirtyLevel === 1) {
this._dirtyLevel = 0;
}
resetTracking();
}
return this._dirtyLevel >= 4;
}
set dirty(v) {
this._dirtyLevel = v ? 4 : 0;
}
run() {
this._dirtyLevel = 0;
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
let lastEffect = activeEffect;
try {
this.parent = activeEffect;
shouldTrack = true;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
this._runnings++;
preCleanupEffect(this);
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
postCleanupEffect(this);
this._runnings--;
activeEffect = lastEffect;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
if (this.active) {
preCleanupEffect(this);
postCleanupEffect(this);
this.onStop && this.onStop();
this.active = false;

@@ -209,11 +199,26 @@ }

}
function cleanupEffect(effect2) {
const { deps } = effect2;
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].delete(effect2);
function triggerComputed(computed) {
return computed.value;
}
function preCleanupEffect(effect2) {
effect2._trackId++;
effect2._depsLength = 0;
}
function postCleanupEffect(effect2) {
if (effect2.deps.length > effect2._depsLength) {
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
cleanupDepEffect(effect2.deps[i], effect2);
}
deps.length = 0;
effect2.deps.length = effect2._depsLength;
}
}
function cleanupDepEffect(dep, effect2) {
const trackId = dep.get(effect2);
if (trackId !== void 0 && effect2._trackId !== trackId) {
dep.delete(effect2);
if (dep.size === 0) {
dep.cleanup();
}
}
}
function effect(fn, options) {

@@ -223,7 +228,10 @@ if (fn.effect instanceof ReactiveEffect) {

}
const _effect = new ReactiveEffect(fn);
const _effect = new ReactiveEffect(fn, shared.NOOP, () => {
if (_effect.dirty) {
_effect.run();
}
});
if (options) {
shared.extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
if (options.scope) recordEffectScope(_effect, options.scope);
}

@@ -241,2 +249,3 @@ if (!options || !options.lazy) {

let shouldTrack = true;
let pauseScheduleStack = 0;
const trackStack = [];

@@ -255,2 +264,65 @@ function pauseTracking() {

}
function pauseScheduling() {
pauseScheduleStack++;
}
function resetScheduling() {
pauseScheduleStack--;
while (!pauseScheduleStack && queueEffectSchedulers.length) {
queueEffectSchedulers.shift()();
}
}
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
var _a;
if (dep.get(effect2) !== effect2._trackId) {
dep.set(effect2, effect2._trackId);
const oldDep = effect2.deps[effect2._depsLength];
if (oldDep !== dep) {
if (oldDep) {
cleanupDepEffect(oldDep, effect2);
}
effect2.deps[effect2._depsLength++] = dep;
} else {
effect2._depsLength++;
}
{
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, shared.extend({ effect: effect2 }, debuggerEventExtraInfo));
}
}
}
const queueEffectSchedulers = [];
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
var _a;
pauseScheduling();
for (const effect2 of dep.keys()) {
let tracking;
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
effect2._dirtyLevel = dirtyLevel;
}
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
{
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, shared.extend({ effect: effect2 }, debuggerEventExtraInfo));
}
effect2.trigger();
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
effect2._shouldSchedule = false;
if (effect2.scheduler) {
queueEffectSchedulers.push(effect2.scheduler);
}
}
}
}
resetScheduling();
}
const createDep = (cleanup, computed) => {
const dep = /* @__PURE__ */ new Map();
dep.cleanup = cleanup;
dep.computed = computed;
return dep;
};
const targetMap = /* @__PURE__ */ new WeakMap();
const ITERATE_KEY = Symbol("iterate" );
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
function track(target, type, key) {

@@ -264,33 +336,15 @@ if (shouldTrack && activeEffect) {

if (!dep) {
depsMap.set(key, dep = createDep());
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
}
const eventInfo = { effect: activeEffect, target, type, key } ;
trackEffects(dep, eventInfo);
trackEffect(
activeEffect,
dep,
{
target,
type,
key
}
);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if (activeEffect.onTrack) {
activeEffect.onTrack(
shared.extend(
{
effect: activeEffect
},
debuggerEventExtraInfo
)
);
}
}
}
function trigger(target, type, key, newValue, oldValue, oldTarget) {

@@ -307,3 +361,3 @@ const depsMap = targetMap.get(target);

depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
if (key2 === "length" || !shared.isSymbol(key2) && key2 >= newLength) {
deps.push(dep);

@@ -342,49 +396,24 @@ }

}
const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
pauseScheduling();
for (const dep of deps) {
if (dep) {
triggerEffects(
dep,
4,
{
target,
type,
key,
newValue,
oldValue,
oldTarget
}
);
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
{
triggerEffects(createDep(effects), eventInfo);
}
}
resetScheduling();
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = shared.isArray(dep) ? dep : [...dep];
for (const effect2 of effects) {
if (effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
for (const effect2 of effects) {
if (!effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
}
function triggerEffect(effect2, debuggerEventExtraInfo) {
if (effect2 !== activeEffect || effect2.allowRecurse) {
if (effect2.onTrigger) {
effect2.onTrigger(shared.extend({ effect: effect2 }, debuggerEventExtraInfo));
}
if (effect2.scheduler) {
effect2.scheduler();
} else {
effect2.run();
}
}
}
function getDepFromReactive(object, key) {
var _a;
return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
const depsMap = targetMap.get(object);
return depsMap && depsMap.get(key);
}

@@ -416,3 +445,5 @@

pauseTracking();
pauseScheduling();
const res = toRaw(this)[key].apply(this, args);
resetScheduling();
resetTracking();

@@ -425,2 +456,3 @@ return res;

function hasOwnProperty(key) {
if (!shared.isSymbol(key)) key = String(key);
const obj = toRaw(this);

@@ -431,8 +463,8 @@ track(obj, "has", key);

class BaseReactiveHandler {
constructor(_isReadonly = false, _shallow = false) {
constructor(_isReadonly = false, _isShallow = false) {
this._isReadonly = _isReadonly;
this._shallow = _shallow;
this._isShallow = _isShallow;
}
get(target, key, receiver) {
const isReadonly2 = this._isReadonly, shallow = this._shallow;
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
if (key === "__k_isReactive") {

@@ -443,5 +475,10 @@ return !isReadonly2;

} else if (key === "__k_isShallow") {
return shallow;
} else if (key === "__k_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
return isShallow2;
} else if (key === "__k_raw") {
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
// this means the reciever is a user proxy of the reactive proxy
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
return target;
}
return;
}

@@ -464,3 +501,3 @@ const targetIsArray = shared.isArray(target);

}
if (shallow) {
if (isShallow2) {
return res;

@@ -478,11 +515,9 @@ }

class MutableReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(false, shallow);
constructor(isShallow2 = false) {
super(false, isShallow2);
}
set(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!this._shallow) {
if (!this._isShallow) {
const isOldValueReadonly = isReadonly(oldValue);
if (!isShallow(value) && !isReadonly(value)) {

@@ -493,4 +528,8 @@ oldValue = toRaw(oldValue);

if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
if (isOldValueReadonly) {
return false;
} else {
oldValue.value = value;
return true;
}
}

@@ -535,4 +574,4 @@ }

class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(true, shallow);
constructor(isShallow2 = false) {
super(true, isShallow2);
}

@@ -708,3 +747,3 @@ set(target, key) {

const key = args[0] ? `on key "${args[0]}" ` : ``;
console.warn(
warn(
`${shared.capitalize(type)} operation ${key}failed: target is readonly.`,

@@ -714,3 +753,3 @@ toRaw(this)

}
return type === "delete" ? false : this;
return type === "delete" ? false : type === "clear" ? void 0 : this;
};

@@ -779,19 +818,12 @@ }

};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
const iteratorMethods = [
"keys",
"values",
"entries",
Symbol.iterator
];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(
method,
false,
false
);
readonlyInstrumentations2[method] = createIterableMethod(
method,
true,
false
);
shallowInstrumentations2[method] = createIterableMethod(
method,
false,
true
);
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations2[method] = createIterableMethod(

@@ -849,3 +881,3 @@ method,

const type = shared.toRawType(target);
console.warn(
warn(
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`

@@ -919,3 +951,7 @@ );

{
console.warn(`value cannot be made reactive: ${String(target)}`);
warn(
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
target
)}`
);
}

@@ -955,3 +991,3 @@ return target;

function isProxy(value) {
return isReactive(value) || isReadonly(value);
return value ? !!value["__k_raw"] : false;
}

@@ -963,3 +999,5 @@ function toRaw(observed) {

function markRaw(value) {
shared.def(value, "__k_skip", true);
if (Object.isExtensible(value)) {
shared.def(value, "__k_skip", true);
}
return value;

@@ -970,20 +1008,96 @@ }

const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://kdu-js.web.app/guide/essentials/computed.html#getters-should-be-side-effect-free`;
class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this.getter = getter;
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this.effect = new ReactiveEffect(
() => getter(this._value),
() => triggerRefValue(
this,
this.effect._dirtyLevel === 2 ? 2 : 3
)
);
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
if ((!self._cacheable || self.effect.dirty) && shared.hasChanged(self._value, self._value = self.effect.run())) {
triggerRefValue(self, 4);
}
trackRefValue(self);
if (self.effect._dirtyLevel >= 2) {
if (this._warnRecursive) {
warn(COMPUTED_SIDE_EFFECT_WARN, `
getter: `, this.getter);
}
triggerRefValue(self, 2);
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
// #region polyfill _dirty for backward compatibility third party code for Kdu <= 3.3.x
get _dirty() {
return this.effect.dirty;
}
set _dirty(v) {
this.effect.dirty = v;
}
// #endregion
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = shared.isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
warn("Write operation failed: computed value is readonly");
} ;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
function trackRefValue(ref2) {
var _a;
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
{
trackEffects(ref2.dep || (ref2.dep = createDep()), {
trackEffect(
activeEffect,
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
() => ref2.dep = void 0,
ref2 instanceof ComputedRefImpl ? ref2 : void 0
),
{
target: ref2,
type: "get",
key: "value"
});
}
}
);
}
}
function triggerRefValue(ref2, newVal) {
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
{
triggerEffects(dep, {
triggerEffects(
dep,
dirtyLevel,
{
target: ref2,

@@ -993,4 +1107,4 @@ type: "set",

newValue: newVal
});
}
}
);
}

@@ -1031,3 +1145,3 @@ }

this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
triggerRefValue(this, 4, newVal);
}

@@ -1037,3 +1151,3 @@ }

function triggerRef(ref2) {
triggerRefValue(ref2, ref2.value );
triggerRefValue(ref2, 4, ref2.value );
}

@@ -1084,3 +1198,3 @@ function unref(ref2) {

if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
warn(`toRefs() expects a reactive object but received a plain one.`);
}

@@ -1137,123 +1251,22 @@ const ret = shared.isArray(object) ? new Array(object.length) : {};

class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
trackRefValue(self);
if (self._dirty || !self._cacheable) {
self._dirty = false;
self._value = self.effect.run();
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = shared.isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
console.warn("Write operation failed: computed value is readonly");
} ;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
const deferredComputed = computed;
const tick = /* @__PURE__ */ Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
const TrackOpTypes = {
"GET": "get",
"HAS": "has",
"ITERATE": "iterate"
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
const TriggerOpTypes = {
"SET": "set",
"ADD": "add",
"DELETE": "delete",
"CLEAR": "clear"
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = void 0;
this._dirty = true;
this.__k_isRef = true;
this["__k_isReadonly"] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
} else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
for (const e of this.dep) {
if (e.computed instanceof DeferredComputedRefImpl) {
e.scheduler(
true
/* computedTrigger */
);
}
}
}
this._dirty = true;
});
this.effect.computed = this;
}
_get() {
if (this._dirty) {
this._dirty = false;
return this._value = this.effect.run();
}
return this._value;
}
get value() {
trackRefValue(this);
return toRaw(this)._get();
}
}
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
const ReactiveFlags = {
"SKIP": "__k_skip",
"IS_REACTIVE": "__k_isReactive",
"IS_READONLY": "__k_isReadonly",
"IS_SHALLOW": "__k_isShallow",
"RAW": "__k_raw"
};

@@ -1263,2 +1276,5 @@ exports.EffectScope = EffectScope;

exports.ReactiveEffect = ReactiveEffect;
exports.ReactiveFlags = ReactiveFlags;
exports.TrackOpTypes = TrackOpTypes;
exports.TriggerOpTypes = TriggerOpTypes;
exports.computed = computed;

@@ -1278,2 +1294,3 @@ exports.customRef = customRef;

exports.onScopeDispose = onScopeDispose;
exports.pauseScheduling = pauseScheduling;
exports.pauseTracking = pauseTracking;

@@ -1284,2 +1301,3 @@ exports.proxyRefs = proxyRefs;

exports.ref = ref;
exports.resetScheduling = resetScheduling;
exports.resetTracking = resetTracking;

@@ -1286,0 +1304,0 @@ exports.shallowReactive = shallowReactive;

@@ -0,1 +1,6 @@

/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
'use strict';

@@ -101,95 +106,80 @@

const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit;
}
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = /* @__PURE__ */ new WeakMap();
let effectTrackDepth = 0;
let trackOpBit = 1;
const maxMarkerBits = 30;
let activeEffect;
const ITERATE_KEY = Symbol("");
const MAP_KEY_ITERATE_KEY = Symbol("");
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
constructor(fn, trigger, scheduler, scope) {
this.fn = fn;
this.trigger = trigger;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
this.parent = void 0;
/**
* @internal
*/
this._dirtyLevel = 4;
/**
* @internal
*/
this._trackId = 0;
/**
* @internal
*/
this._runnings = 0;
/**
* @internal
*/
this._shouldSchedule = false;
/**
* @internal
*/
this._depsLength = 0;
recordEffectScope(this, scope);
}
get dirty() {
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
this._dirtyLevel = 1;
pauseTracking();
for (let i = 0; i < this._depsLength; i++) {
const dep = this.deps[i];
if (dep.computed) {
triggerComputed(dep.computed);
if (this._dirtyLevel >= 4) {
break;
}
}
}
if (this._dirtyLevel === 1) {
this._dirtyLevel = 0;
}
resetTracking();
}
return this._dirtyLevel >= 4;
}
set dirty(v) {
this._dirtyLevel = v ? 4 : 0;
}
run() {
this._dirtyLevel = 0;
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
let lastEffect = activeEffect;
try {
this.parent = activeEffect;
shouldTrack = true;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
this._runnings++;
preCleanupEffect(this);
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
postCleanupEffect(this);
this._runnings--;
activeEffect = lastEffect;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
if (this.active) {
preCleanupEffect(this);
postCleanupEffect(this);
this.onStop && this.onStop();
this.active = false;

@@ -199,11 +189,26 @@ }

}
function cleanupEffect(effect2) {
const { deps } = effect2;
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].delete(effect2);
function triggerComputed(computed) {
return computed.value;
}
function preCleanupEffect(effect2) {
effect2._trackId++;
effect2._depsLength = 0;
}
function postCleanupEffect(effect2) {
if (effect2.deps.length > effect2._depsLength) {
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
cleanupDepEffect(effect2.deps[i], effect2);
}
deps.length = 0;
effect2.deps.length = effect2._depsLength;
}
}
function cleanupDepEffect(dep, effect2) {
const trackId = dep.get(effect2);
if (trackId !== void 0 && effect2._trackId !== trackId) {
dep.delete(effect2);
if (dep.size === 0) {
dep.cleanup();
}
}
}
function effect(fn, options) {

@@ -213,7 +218,10 @@ if (fn.effect instanceof ReactiveEffect) {

}
const _effect = new ReactiveEffect(fn);
const _effect = new ReactiveEffect(fn, shared.NOOP, () => {
if (_effect.dirty) {
_effect.run();
}
});
if (options) {
shared.extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
if (options.scope) recordEffectScope(_effect, options.scope);
}

@@ -231,2 +239,3 @@ if (!options || !options.lazy) {

let shouldTrack = true;
let pauseScheduleStack = 0;
const trackStack = [];

@@ -245,2 +254,57 @@ function pauseTracking() {

}
function pauseScheduling() {
pauseScheduleStack++;
}
function resetScheduling() {
pauseScheduleStack--;
while (!pauseScheduleStack && queueEffectSchedulers.length) {
queueEffectSchedulers.shift()();
}
}
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
if (dep.get(effect2) !== effect2._trackId) {
dep.set(effect2, effect2._trackId);
const oldDep = effect2.deps[effect2._depsLength];
if (oldDep !== dep) {
if (oldDep) {
cleanupDepEffect(oldDep, effect2);
}
effect2.deps[effect2._depsLength++] = dep;
} else {
effect2._depsLength++;
}
}
}
const queueEffectSchedulers = [];
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
pauseScheduling();
for (const effect2 of dep.keys()) {
let tracking;
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
effect2._dirtyLevel = dirtyLevel;
}
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
effect2.trigger();
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
effect2._shouldSchedule = false;
if (effect2.scheduler) {
queueEffectSchedulers.push(effect2.scheduler);
}
}
}
}
resetScheduling();
}
const createDep = (cleanup, computed) => {
const dep = /* @__PURE__ */ new Map();
dep.cleanup = cleanup;
dep.computed = computed;
return dep;
};
const targetMap = /* @__PURE__ */ new WeakMap();
const ITERATE_KEY = Symbol("");
const MAP_KEY_ITERATE_KEY = Symbol("");
function track(target, type, key) {

@@ -254,22 +318,9 @@ if (shouldTrack && activeEffect) {

if (!dep) {
depsMap.set(key, dep = createDep());
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
}
trackEffects(dep);
trackEffect(
activeEffect,
dep);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
}
}
function trigger(target, type, key, newValue, oldValue, oldTarget) {

@@ -286,3 +337,3 @@ const depsMap = targetMap.get(target);

depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
if (key2 === "length" || !shared.isSymbol(key2) && key2 >= newLength) {
deps.push(dep);

@@ -321,45 +372,15 @@ }

}
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0]);
}
pauseScheduling();
for (const dep of deps) {
if (dep) {
triggerEffects(
dep,
4);
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
{
triggerEffects(createDep(effects));
}
}
resetScheduling();
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = shared.isArray(dep) ? dep : [...dep];
for (const effect2 of effects) {
if (effect2.computed) {
triggerEffect(effect2);
}
}
for (const effect2 of effects) {
if (!effect2.computed) {
triggerEffect(effect2);
}
}
}
function triggerEffect(effect2, debuggerEventExtraInfo) {
if (effect2 !== activeEffect || effect2.allowRecurse) {
if (effect2.scheduler) {
effect2.scheduler();
} else {
effect2.run();
}
}
}
function getDepFromReactive(object, key) {
var _a;
return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
const depsMap = targetMap.get(object);
return depsMap && depsMap.get(key);
}

@@ -391,3 +412,5 @@

pauseTracking();
pauseScheduling();
const res = toRaw(this)[key].apply(this, args);
resetScheduling();
resetTracking();

@@ -400,2 +423,3 @@ return res;

function hasOwnProperty(key) {
if (!shared.isSymbol(key)) key = String(key);
const obj = toRaw(this);

@@ -406,8 +430,8 @@ track(obj, "has", key);

class BaseReactiveHandler {
constructor(_isReadonly = false, _shallow = false) {
constructor(_isReadonly = false, _isShallow = false) {
this._isReadonly = _isReadonly;
this._shallow = _shallow;
this._isShallow = _isShallow;
}
get(target, key, receiver) {
const isReadonly2 = this._isReadonly, shallow = this._shallow;
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
if (key === "__k_isReactive") {

@@ -418,5 +442,10 @@ return !isReadonly2;

} else if (key === "__k_isShallow") {
return shallow;
} else if (key === "__k_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
return isShallow2;
} else if (key === "__k_raw") {
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
// this means the reciever is a user proxy of the reactive proxy
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
return target;
}
return;
}

@@ -439,3 +468,3 @@ const targetIsArray = shared.isArray(target);

}
if (shallow) {
if (isShallow2) {
return res;

@@ -453,11 +482,9 @@ }

class MutableReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(false, shallow);
constructor(isShallow2 = false) {
super(false, isShallow2);
}
set(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!this._shallow) {
if (!this._isShallow) {
const isOldValueReadonly = isReadonly(oldValue);
if (!isShallow(value) && !isReadonly(value)) {

@@ -468,4 +495,8 @@ oldValue = toRaw(oldValue);

if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
if (isOldValueReadonly) {
return false;
} else {
oldValue.value = value;
return true;
}
}

@@ -510,4 +541,4 @@ }

class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(true, shallow);
constructor(isShallow2 = false) {
super(true, isShallow2);
}

@@ -664,3 +695,3 @@ set(target, key) {

return function(...args) {
return type === "delete" ? false : this;
return type === "delete" ? false : type === "clear" ? void 0 : this;
};

@@ -729,19 +760,12 @@ }

};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
const iteratorMethods = [
"keys",
"values",
"entries",
Symbol.iterator
];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(
method,
false,
false
);
readonlyInstrumentations2[method] = createIterableMethod(
method,
true,
false
);
shallowInstrumentations2[method] = createIterableMethod(
method,
false,
true
);
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations2[method] = createIterableMethod(

@@ -891,3 +915,3 @@ method,

function isProxy(value) {
return isReactive(value) || isReadonly(value);
return value ? !!value["__k_raw"] : false;
}

@@ -899,3 +923,5 @@ function toRaw(observed) {

function markRaw(value) {
shared.def(value, "__k_skip", true);
if (Object.isExtensible(value)) {
shared.def(value, "__k_skip", true);
}
return value;

@@ -906,17 +932,77 @@ }

class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this.getter = getter;
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this.effect = new ReactiveEffect(
() => getter(this._value),
() => triggerRefValue(
this,
this.effect._dirtyLevel === 2 ? 2 : 3
)
);
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
if ((!self._cacheable || self.effect.dirty) && shared.hasChanged(self._value, self._value = self.effect.run())) {
triggerRefValue(self, 4);
}
trackRefValue(self);
if (self.effect._dirtyLevel >= 2) {
triggerRefValue(self, 2);
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
// #region polyfill _dirty for backward compatibility third party code for Kdu <= 3.3.x
get _dirty() {
return this.effect.dirty;
}
set _dirty(v) {
this.effect.dirty = v;
}
// #endregion
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = shared.isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = shared.NOOP;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
return cRef;
}
function trackRefValue(ref2) {
var _a;
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
{
trackEffects(ref2.dep || (ref2.dep = createDep()));
}
trackEffect(
activeEffect,
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
() => ref2.dep = void 0,
ref2 instanceof ComputedRefImpl ? ref2 : void 0
));
}
}
function triggerRefValue(ref2, newVal) {
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
{
triggerEffects(dep);
}
triggerEffects(
dep,
dirtyLevel);
}

@@ -957,3 +1043,3 @@ }

this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this);
triggerRefValue(this, 4);
}

@@ -963,3 +1049,3 @@ }

function triggerRef(ref2) {
triggerRefValue(ref2);
triggerRefValue(ref2, 4);
}

@@ -1059,117 +1145,22 @@ function unref(ref2) {

class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
trackRefValue(self);
if (self._dirty || !self._cacheable) {
self._dirty = false;
self._value = self.effect.run();
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = shared.isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = shared.NOOP;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
return cRef;
}
const deferredComputed = computed;
const tick = /* @__PURE__ */ Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
const TrackOpTypes = {
"GET": "get",
"HAS": "has",
"ITERATE": "iterate"
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
const TriggerOpTypes = {
"SET": "set",
"ADD": "add",
"DELETE": "delete",
"CLEAR": "clear"
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = void 0;
this._dirty = true;
this.__k_isRef = true;
this["__k_isReadonly"] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
} else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
for (const e of this.dep) {
if (e.computed instanceof DeferredComputedRefImpl) {
e.scheduler(
true
/* computedTrigger */
);
}
}
}
this._dirty = true;
});
this.effect.computed = this;
}
_get() {
if (this._dirty) {
this._dirty = false;
return this._value = this.effect.run();
}
return this._value;
}
get value() {
trackRefValue(this);
return toRaw(this)._get();
}
}
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
const ReactiveFlags = {
"SKIP": "__k_skip",
"IS_REACTIVE": "__k_isReactive",
"IS_READONLY": "__k_isReadonly",
"IS_SHALLOW": "__k_isShallow",
"RAW": "__k_raw"
};

@@ -1179,2 +1170,5 @@ exports.EffectScope = EffectScope;

exports.ReactiveEffect = ReactiveEffect;
exports.ReactiveFlags = ReactiveFlags;
exports.TrackOpTypes = TrackOpTypes;
exports.TriggerOpTypes = TriggerOpTypes;
exports.computed = computed;

@@ -1194,2 +1188,3 @@ exports.customRef = customRef;

exports.onScopeDispose = onScopeDispose;
exports.pauseScheduling = pauseScheduling;
exports.pauseTracking = pauseTracking;

@@ -1200,2 +1195,3 @@ exports.proxyRefs = proxyRefs;

exports.ref = ref;
exports.resetScheduling = resetScheduling;
exports.resetTracking = resetTracking;

@@ -1202,0 +1198,0 @@ exports.shallowReactive = shallowReactive;

import { IfAny } from '@kdujs/shared';
export declare const enum ReactiveFlags {
export declare enum TrackOpTypes {
GET = "get",
HAS = "has",
ITERATE = "iterate"
}
export declare enum TriggerOpTypes {
SET = "set",
ADD = "add",
DELETE = "delete",
CLEAR = "clear"
}
export declare enum ReactiveFlags {
SKIP = "__k_skip",

@@ -10,2 +21,182 @@ IS_REACTIVE = "__k_isReactive",

}
type Dep = Map<ReactiveEffect, number> & {
cleanup: () => void;
computed?: ComputedRefImpl<any>;
};
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;
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 class ReactiveEffect<T = any> {
fn: () => T;
trigger: () => void;
scheduler?: EffectScheduler | undefined;
active: boolean;
deps: Dep[];
onStop?: () => void;
onTrack?: (event: DebuggerEvent) => void;
onTrigger?: (event: DebuggerEvent) => void;
constructor(fn: () => T, trigger: () => void, scheduler?: EffectScheduler | undefined, scope?: EffectScope);
get dirty(): boolean;
set dirty(v: boolean);
run(): T;
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;
export declare function pauseScheduling(): void;
export declare function resetScheduling(): void;
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> = (oldValue?: T) => T;
export type ComputedSetter<T> = (newValue: T) => void;
export interface WritableComputedOptions<T> {
get: ComputedGetter<T>;
set: ComputedSetter<T>;
}
export declare class ComputedRefImpl<T> {
private getter;
private readonly _setter;
dep?: Dep;
private _value;
readonly effect: ReactiveEffect<T>;
readonly __k_isRef = true;
readonly [ReactiveFlags.IS_READONLY]: boolean;
_cacheable: boolean;
/**
* Dev only
*/
_warnRecursive?: boolean;
constructor(getter: ComputedGetter<T>, _setter: ComputedSetter<T>, isReadonly: boolean, isSSR: boolean);
get value(): T;
set value(newValue: T);
get _dirty(): boolean;
set _dirty(v: boolean);
}
/**
* 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 type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;

@@ -168,3 +359,3 @@ /**

*/
export declare function isProxy(value: unknown): boolean;
export declare function isProxy(value: any): boolean;
/**

@@ -221,157 +412,2 @@ * Returns the raw, original object of a Kdu-created proxy.

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"
}
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;
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;
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;
};
declare const RefSymbol: unique symbol;

@@ -402,3 +438,2 @@ declare const RawSymbol: unique symbol;

*/
export declare function ref<T extends Ref>(value: T): T;
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;

@@ -427,4 +462,3 @@ export declare function ref<T = any>(): Ref<T | undefined>;

*/
export declare function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>;
export declare function shallowRef<T>(value: T): ShallowRef<T>;
export declare function shallowRef<T>(value: T): Ref extends T ? T extends Ref ? IfAny<T, ShallowRef<T>, T> : ShallowRef<T> : ShallowRef<T>;
export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;

@@ -475,3 +509,3 @@ /**

*/
export declare function unref<T>(ref: MaybeRef<T>): T;
export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
/**

@@ -493,3 +527,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;
/**

@@ -594,8 +628,9 @@ * Returns a reactive proxy for the given object.

export type ShallowUnwrapRef<T> = {
[K in keyof T]: T[K] extends Ref<infer V> ? V : T[K] extends Ref<infer V> | undefined ? unknown extends V ? undefined : V | undefined : T[K];
[K in keyof T]: DistrubuteRef<T[K]>;
};
type DistrubuteRef<T> = T extends Ref<infer V> ? V : T;
export type UnwrapRef<T> = T extends ShallowRef<infer V> ? V : T extends Ref<infer V> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>;
type UnwrapRefSimple<T> = T extends Function | CollectionTypes | BaseTypes | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | {
type UnwrapRefSimple<T> = T extends Function | BaseTypes | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | {
[RawSymbol]?: true;
} ? T : T extends ReadonlyArray<any> ? {
} ? T : T extends Map<infer K, infer V> ? Map<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Map<any, any>>> : T extends WeakMap<infer K, infer V> ? WeakMap<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakMap<any, any>>> : T extends Set<infer V> ? Set<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Set<any>>> : T extends WeakSet<infer V> ? WeakSet<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakSet<any>>> : T extends ReadonlyArray<any> ? {
[K in keyof T]: UnwrapRefSimple<T[K]>;

@@ -608,53 +643,28 @@ } : T extends 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.
* @deprecated use `computed` instead. See #5912
*/
export declare const deferredComputed: typeof computed;
export declare const ITERATE_KEY: unique symbol;
/**
* Tracks access to a reactive property.
*
* @example
* ```js
* // Creating a readonly computed ref:
* const count = ref(1)
* const plusOne = computed(() => count.value + 1)
* 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.
*
* console.log(plusOne.value) // 2
* plusOne.value++ // error
* ```
* @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.
*
* ```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}
* @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 computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;

@@ -0,10 +1,15 @@

/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function makeMap(str, expectsLowerCase) {
const map = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
const set = new Set(str.split(","));
return (val) => set.has(val);
}
const NOOP = () => {
};
const extend = Object.assign;

@@ -36,6 +41,7 @@ const hasOwnProperty$1 = Object.prototype.hasOwnProperty;

const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
const def = (obj, key, value) => {
const def = (obj, key, value, writable = false) => {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
writable,
value

@@ -149,95 +155,80 @@ });

const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit;
}
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = /* @__PURE__ */ new WeakMap();
let effectTrackDepth = 0;
let trackOpBit = 1;
const maxMarkerBits = 30;
let activeEffect;
const ITERATE_KEY = Symbol("iterate" );
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
constructor(fn, trigger, scheduler, scope) {
this.fn = fn;
this.trigger = trigger;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
this.parent = void 0;
/**
* @internal
*/
this._dirtyLevel = 4;
/**
* @internal
*/
this._trackId = 0;
/**
* @internal
*/
this._runnings = 0;
/**
* @internal
*/
this._shouldSchedule = false;
/**
* @internal
*/
this._depsLength = 0;
recordEffectScope(this, scope);
}
get dirty() {
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
this._dirtyLevel = 1;
pauseTracking();
for (let i = 0; i < this._depsLength; i++) {
const dep = this.deps[i];
if (dep.computed) {
triggerComputed(dep.computed);
if (this._dirtyLevel >= 4) {
break;
}
}
}
if (this._dirtyLevel === 1) {
this._dirtyLevel = 0;
}
resetTracking();
}
return this._dirtyLevel >= 4;
}
set dirty(v) {
this._dirtyLevel = v ? 4 : 0;
}
run() {
this._dirtyLevel = 0;
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
let lastEffect = activeEffect;
try {
this.parent = activeEffect;
shouldTrack = true;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
this._runnings++;
preCleanupEffect(this);
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
postCleanupEffect(this);
this._runnings--;
activeEffect = lastEffect;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
if (this.active) {
preCleanupEffect(this);
postCleanupEffect(this);
this.onStop && this.onStop();
this.active = false;

@@ -247,11 +238,26 @@ }

}
function cleanupEffect(effect2) {
const { deps } = effect2;
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].delete(effect2);
function triggerComputed(computed) {
return computed.value;
}
function preCleanupEffect(effect2) {
effect2._trackId++;
effect2._depsLength = 0;
}
function postCleanupEffect(effect2) {
if (effect2.deps.length > effect2._depsLength) {
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
cleanupDepEffect(effect2.deps[i], effect2);
}
deps.length = 0;
effect2.deps.length = effect2._depsLength;
}
}
function cleanupDepEffect(dep, effect2) {
const trackId = dep.get(effect2);
if (trackId !== void 0 && effect2._trackId !== trackId) {
dep.delete(effect2);
if (dep.size === 0) {
dep.cleanup();
}
}
}
function effect(fn, options) {

@@ -261,7 +267,10 @@ if (fn.effect instanceof ReactiveEffect) {

}
const _effect = new ReactiveEffect(fn);
const _effect = new ReactiveEffect(fn, NOOP, () => {
if (_effect.dirty) {
_effect.run();
}
});
if (options) {
extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
if (options.scope) recordEffectScope(_effect, options.scope);
}

@@ -279,2 +288,3 @@ if (!options || !options.lazy) {

let shouldTrack = true;
let pauseScheduleStack = 0;
const trackStack = [];

@@ -293,2 +303,65 @@ function pauseTracking() {

}
function pauseScheduling() {
pauseScheduleStack++;
}
function resetScheduling() {
pauseScheduleStack--;
while (!pauseScheduleStack && queueEffectSchedulers.length) {
queueEffectSchedulers.shift()();
}
}
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
var _a;
if (dep.get(effect2) !== effect2._trackId) {
dep.set(effect2, effect2._trackId);
const oldDep = effect2.deps[effect2._depsLength];
if (oldDep !== dep) {
if (oldDep) {
cleanupDepEffect(oldDep, effect2);
}
effect2.deps[effect2._depsLength++] = dep;
} else {
effect2._depsLength++;
}
{
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
}
}
}
const queueEffectSchedulers = [];
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
var _a;
pauseScheduling();
for (const effect2 of dep.keys()) {
let tracking;
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
effect2._dirtyLevel = dirtyLevel;
}
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
{
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
}
effect2.trigger();
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
effect2._shouldSchedule = false;
if (effect2.scheduler) {
queueEffectSchedulers.push(effect2.scheduler);
}
}
}
}
resetScheduling();
}
const createDep = (cleanup, computed) => {
const dep = /* @__PURE__ */ new Map();
dep.cleanup = cleanup;
dep.computed = computed;
return dep;
};
const targetMap = /* @__PURE__ */ new WeakMap();
const ITERATE_KEY = Symbol("iterate" );
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
function track(target, type, key) {

@@ -302,33 +375,15 @@ if (shouldTrack && activeEffect) {

if (!dep) {
depsMap.set(key, dep = createDep());
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
}
const eventInfo = { effect: activeEffect, target, type, key } ;
trackEffects(dep, eventInfo);
trackEffect(
activeEffect,
dep,
{
target,
type,
key
}
);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if (activeEffect.onTrack) {
activeEffect.onTrack(
extend(
{
effect: activeEffect
},
debuggerEventExtraInfo
)
);
}
}
}
function trigger(target, type, key, newValue, oldValue, oldTarget) {

@@ -345,3 +400,3 @@ const depsMap = targetMap.get(target);

depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
deps.push(dep);

@@ -380,49 +435,24 @@ }

}
const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
pauseScheduling();
for (const dep of deps) {
if (dep) {
triggerEffects(
dep,
4,
{
target,
type,
key,
newValue,
oldValue,
oldTarget
}
);
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
{
triggerEffects(createDep(effects), eventInfo);
}
}
resetScheduling();
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = isArray(dep) ? dep : [...dep];
for (const effect2 of effects) {
if (effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
for (const effect2 of effects) {
if (!effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
}
function triggerEffect(effect2, debuggerEventExtraInfo) {
if (effect2 !== activeEffect || effect2.allowRecurse) {
if (effect2.onTrigger) {
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
}
if (effect2.scheduler) {
effect2.scheduler();
} else {
effect2.run();
}
}
}
function getDepFromReactive(object, key) {
var _a;
return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
const depsMap = targetMap.get(object);
return depsMap && depsMap.get(key);
}

@@ -454,3 +484,5 @@

pauseTracking();
pauseScheduling();
const res = toRaw(this)[key].apply(this, args);
resetScheduling();
resetTracking();

@@ -463,2 +495,3 @@ return res;

function hasOwnProperty(key) {
if (!isSymbol(key)) key = String(key);
const obj = toRaw(this);

@@ -469,8 +502,8 @@ track(obj, "has", key);

class BaseReactiveHandler {
constructor(_isReadonly = false, _shallow = false) {
constructor(_isReadonly = false, _isShallow = false) {
this._isReadonly = _isReadonly;
this._shallow = _shallow;
this._isShallow = _isShallow;
}
get(target, key, receiver) {
const isReadonly2 = this._isReadonly, shallow = this._shallow;
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
if (key === "__k_isReactive") {

@@ -481,5 +514,10 @@ return !isReadonly2;

} else if (key === "__k_isShallow") {
return shallow;
} else if (key === "__k_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
return isShallow2;
} else if (key === "__k_raw") {
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
// this means the reciever is a user proxy of the reactive proxy
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
return target;
}
return;
}

@@ -502,3 +540,3 @@ const targetIsArray = isArray(target);

}
if (shallow) {
if (isShallow2) {
return res;

@@ -516,11 +554,9 @@ }

class MutableReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(false, shallow);
constructor(isShallow2 = false) {
super(false, isShallow2);
}
set(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!this._shallow) {
if (!this._isShallow) {
const isOldValueReadonly = isReadonly(oldValue);
if (!isShallow(value) && !isReadonly(value)) {

@@ -531,4 +567,8 @@ oldValue = toRaw(oldValue);

if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
if (isOldValueReadonly) {
return false;
} else {
oldValue.value = value;
return true;
}
}

@@ -573,4 +613,4 @@ }

class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(true, shallow);
constructor(isShallow2 = false) {
super(true, isShallow2);
}

@@ -746,3 +786,3 @@ set(target, key) {

const key = args[0] ? `on key "${args[0]}" ` : ``;
console.warn(
warn(
`${capitalize(type)} operation ${key}failed: target is readonly.`,

@@ -752,3 +792,3 @@ toRaw(this)

}
return type === "delete" ? false : this;
return type === "delete" ? false : type === "clear" ? void 0 : this;
};

@@ -817,19 +857,12 @@ }

};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
const iteratorMethods = [
"keys",
"values",
"entries",
Symbol.iterator
];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(
method,
false,
false
);
readonlyInstrumentations2[method] = createIterableMethod(
method,
true,
false
);
shallowInstrumentations2[method] = createIterableMethod(
method,
false,
true
);
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations2[method] = createIterableMethod(

@@ -887,3 +920,3 @@ method,

const type = toRawType(target);
console.warn(
warn(
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`

@@ -957,3 +990,7 @@ );

{
console.warn(`value cannot be made reactive: ${String(target)}`);
warn(
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
target
)}`
);
}

@@ -993,3 +1030,3 @@ return target;

function isProxy(value) {
return isReactive(value) || isReadonly(value);
return value ? !!value["__k_raw"] : false;
}

@@ -1001,3 +1038,5 @@ function toRaw(observed) {

function markRaw(value) {
def(value, "__k_skip", true);
if (Object.isExtensible(value)) {
def(value, "__k_skip", true);
}
return value;

@@ -1008,20 +1047,96 @@ }

const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://kdu-js.web.app/guide/essentials/computed.html#getters-should-be-side-effect-free`;
class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this.getter = getter;
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this.effect = new ReactiveEffect(
() => getter(this._value),
() => triggerRefValue(
this,
this.effect._dirtyLevel === 2 ? 2 : 3
)
);
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
triggerRefValue(self, 4);
}
trackRefValue(self);
if (self.effect._dirtyLevel >= 2) {
if (this._warnRecursive) {
warn(COMPUTED_SIDE_EFFECT_WARN, `
getter: `, this.getter);
}
triggerRefValue(self, 2);
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
// #region polyfill _dirty for backward compatibility third party code for Kdu <= 3.3.x
get _dirty() {
return this.effect.dirty;
}
set _dirty(v) {
this.effect.dirty = v;
}
// #endregion
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
warn("Write operation failed: computed value is readonly");
} ;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
function trackRefValue(ref2) {
var _a;
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
{
trackEffects(ref2.dep || (ref2.dep = createDep()), {
trackEffect(
activeEffect,
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
() => ref2.dep = void 0,
ref2 instanceof ComputedRefImpl ? ref2 : void 0
),
{
target: ref2,
type: "get",
key: "value"
});
}
}
);
}
}
function triggerRefValue(ref2, newVal) {
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
{
triggerEffects(dep, {
triggerEffects(
dep,
dirtyLevel,
{
target: ref2,

@@ -1031,4 +1146,4 @@ type: "set",

newValue: newVal
});
}
}
);
}

@@ -1069,3 +1184,3 @@ }

this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
triggerRefValue(this, 4, newVal);
}

@@ -1075,3 +1190,3 @@ }

function triggerRef(ref2) {
triggerRefValue(ref2, ref2.value );
triggerRefValue(ref2, 4, ref2.value );
}

@@ -1122,3 +1237,3 @@ function unref(ref2) {

if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
warn(`toRefs() expects a reactive object but received a plain one.`);
}

@@ -1175,124 +1290,23 @@ const ret = isArray(object) ? new Array(object.length) : {};

class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
trackRefValue(self);
if (self._dirty || !self._cacheable) {
self._dirty = false;
self._value = self.effect.run();
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
console.warn("Write operation failed: computed value is readonly");
} ;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
const deferredComputed = computed;
const tick = /* @__PURE__ */ Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
const TrackOpTypes = {
"GET": "get",
"HAS": "has",
"ITERATE": "iterate"
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
const TriggerOpTypes = {
"SET": "set",
"ADD": "add",
"DELETE": "delete",
"CLEAR": "clear"
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = void 0;
this._dirty = true;
this.__k_isRef = true;
this["__k_isReadonly"] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
} else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
for (const e of this.dep) {
if (e.computed instanceof DeferredComputedRefImpl) {
e.scheduler(
true
/* computedTrigger */
);
}
}
}
this._dirty = true;
});
this.effect.computed = this;
}
_get() {
if (this._dirty) {
this._dirty = false;
return this._value = this.effect.run();
}
return this._value;
}
get value() {
trackRefValue(this);
return toRaw(this)._get();
}
}
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
const ReactiveFlags = {
"SKIP": "__k_skip",
"IS_REACTIVE": "__k_isReactive",
"IS_READONLY": "__k_isReadonly",
"IS_SHALLOW": "__k_isShallow",
"RAW": "__k_raw"
};
export { EffectScope, ITERATE_KEY, ReactiveEffect, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref };
export { EffectScope, ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseScheduling, pauseTracking, proxyRefs, reactive, readonly, ref, resetScheduling, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref };

@@ -1,1 +0,7 @@

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};
/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
/*! #__NO_SIDE_EFFECTS__ */
function t(t,e){const s=new Set(t.split(","));return t=>s.has(t)}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===a(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,a=t=>l.call(t),_=t=>a(t).slice(8,-1),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p,g;class v{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 y(t){return new v(t)}function k(t,e=p){e&&e.active&&e.effects.push(t)}function w(){return p}function b(t){p&&p.cleanups.push(t)}class R{constructor(t,e,s,n){this.fn=t,this.trigger=e,this.scheduler=s,this.active=!0,this.deps=[],this._dirtyLevel=4,this._trackId=0,this._runnings=0,this._shouldSchedule=!1,this._depsLength=0,k(this,n)}get dirty(){if(2===this._dirtyLevel||3===this._dirtyLevel){this._dirtyLevel=1,A();for(let t=0;t<this._depsLength;t++){const e=this.deps[t];if(e.computed&&(S(e.computed),this._dirtyLevel>=4))break}1===this._dirtyLevel&&(this._dirtyLevel=0),W()}return this._dirtyLevel>=4}set dirty(t){this._dirtyLevel=t?4:0}run(){if(this._dirtyLevel=0,!this.active)return this.fn();let t=x,e=g;try{return x=!0,g=this,this._runnings++,L(this),this.fn()}finally{E(this),this._runnings--,g=e,x=t}}stop(){this.active&&(L(this),E(this),this.onStop&&this.onStop(),this.active=!1)}}function S(t){return t.value}function L(t){t._trackId++,t._depsLength=0}function E(t){if(t.deps.length>t._depsLength){for(let e=t._depsLength;e<t.deps.length;e++)O(t.deps[e],t);t.deps.length=t._depsLength}}function O(t,e){const s=t.get(e);void 0!==s&&e._trackId!==s&&(t.delete(e),0===t.size&&t.cleanup())}function m(t,n){t.effect instanceof R&&(t=t.effect.fn);const i=new R(t,e,(()=>{i.dirty&&i.run()}));n&&(s(i,n),n.scope&&k(i,n.scope)),n&&n.lazy||i.run();const r=i.run.bind(i);return r.effect=i,r}function j(t){t.effect.stop()}let x=!0,I=0;const P=[];function A(){P.push(x),x=!1}function M(){P.push(x),x=!0}function W(){const t=P.pop();x=void 0===t||t}function z(){I++}function N(){for(I--;!I&&V.length;)V.shift()()}function T(t,e,s){if(e.get(t)!==t._trackId){e.set(t,t._trackId);const s=t.deps[t._depsLength];s!==e?(s&&O(s,t),t.deps[t._depsLength++]=e):t._depsLength++}}const V=[];function D(t,e,s){z();for(const n of t.keys()){let s;n._dirtyLevel<e&&(null!=s?s:s=t.get(n)===n._trackId)&&(n._shouldSchedule||(n._shouldSchedule=0===n._dirtyLevel),n._dirtyLevel=e),n._shouldSchedule&&(null!=s?s:s=t.get(n)===n._trackId)&&(n.trigger(),n._runnings&&!n.allowRecurse||2===n._dirtyLevel||(n._shouldSchedule=!1,n.scheduler&&V.push(n.scheduler)))}N()}const K=(t,e)=>{const s=new Map;return s.cleanup=t,s.computed=e,s},C=new WeakMap,H=Symbol(""),G=Symbol("");function Y(t,e,s){if(x&&g){let e=C.get(t);e||C.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=K((()=>e.delete(s)))),T(g,n)}}function q(t,e,s,n,i,o){const h=C.get(t);if(!h)return;let l=[];if("clear"===e)l=[...h.values()];else if("length"===s&&r(t)){const t=Number(n);h.forEach(((e,s)=>{("length"===s||!u(s)&&s>=t)&&l.push(e)}))}else switch(void 0!==s&&l.push(h.get(s)),e){case"add":r(t)?f(s)&&l.push(h.get("length")):(l.push(h.get(H)),c(t)&&l.push(h.get(G)));break;case"delete":r(t)||(l.push(h.get(H)),c(t)&&l.push(h.get(G)));break;case"set":c(t)&&l.push(h.get(H))}z();for(const r of l)r&&D(r,4);N()}const B=t("__proto__,__k_isRef,__isKdu"),F=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),J=Q();function Q(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Dt(this);for(let e=0,i=this.length;e<i;e++)Y(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Dt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){A(),z();const s=Dt(this)[e].apply(this,t);return N(),W(),s}})),t}function U(t){u(t)||(t=String(t));const e=Dt(this);return Y(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._isShallow=e}get(t,e,s){const n=this._isReadonly,c=this._isShallow;if("__k_isReactive"===e)return!n;if("__k_isReadonly"===e)return n;if("__k_isShallow"===e)return c;if("__k_raw"===e)return s===(n?c?xt:jt:c?mt:Ot).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=r(t);if(!n){if(o&&i(J,e))return Reflect.get(J,e,s);if("hasOwnProperty"===e)return U}const l=Reflect.get(t,e,s);return(u(e)?F.has(e):B(e))?l:(n||Y(t,0,e),c?l:Ft(l)?o&&f(e)?l:l.value:h(l)?n?At(l):It(l):l)}}class Z extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(!this._isShallow){const e=Nt(c);if(Tt(s)||Nt(s)||(c=Dt(c),s=Dt(s)),!r(t)&&Ft(c)&&!Ft(s))return!e&&(c.value=s,!0)}const o=r(t)&&f(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Dt(n)&&(o?d(s,c)&&q(t,"set",e,s):q(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&q(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&F.has(e)||Y(t,0,e),s}ownKeys(t){return Y(t,0,r(t)?"length":H),Reflect.ownKeys(t)}}class $ extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const tt=new Z,et=new $,st=new Z(!0),nt=new $(!0),it=t=>t,rt=t=>Reflect.getPrototypeOf(t);function ct(t,e,s=!1,n=!1){const i=Dt(t=t.__k_raw),r=Dt(e);s||(d(e,r)&&Y(i,0,e),Y(i,0,r));const{has:c}=rt(i),o=n?it:s?Ht:Ct;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ot(t,e=!1){const s=this.__k_raw,n=Dt(s),i=Dt(t);return e||(d(t,i)&&Y(n,0,t),Y(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ut(t,e=!1){return t=t.__k_raw,!e&&Y(Dt(t),0,H),Reflect.get(t,"size",t)}function ht(t){t=Dt(t);const e=Dt(this);return rt(e).has.call(e,t)||(e.add(t),q(e,"add",t,t)),this}function lt(t,e){e=Dt(e);const s=Dt(this),{has:n,get:i}=rt(s);let r=n.call(s,t);r||(t=Dt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&q(s,"set",t,e):q(s,"add",t,e),this}function at(t){const e=Dt(this),{has:s,get:n}=rt(e);let i=s.call(e,t);i||(t=Dt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&q(e,"delete",t,void 0),r}function _t(){const t=Dt(this),e=0!==t.size,s=t.clear();return e&&q(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__k_raw,c=Dt(r),o=e?it:t?Ht:Ct;return!t&&Y(c,0,H),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function dt(t,e,s){return function(...n){const i=this.__k_raw,r=Dt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,l=i[t](...n),a=s?it:e?Ht:Ct;return!e&&Y(r,0,h?G:H),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[a(t[0]),a(t[1])]:a(t),done:e}},[Symbol.iterator](){return this}}}}function pt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function gt(){const t={get(t){return ct(this,t)},get size(){return ut(this)},has:ot,add:ht,set:lt,delete:at,clear:_t,forEach:ft(!1,!1)},e={get(t){return ct(this,t,!1,!0)},get size(){return ut(this)},has:ot,add:ht,set:lt,delete:at,clear:_t,forEach:ft(!1,!0)},s={get(t){return ct(this,t,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:ft(!0,!1)},n={get(t){return ct(this,t,!0,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=dt(i,!1,!1),s[i]=dt(i,!0,!1),e[i]=dt(i,!1,!0),n[i]=dt(i,!0,!0)})),[t,s,e,n]}const[vt,yt,kt,wt]=gt();function bt(t,e){const s=e?t?wt:kt:t?yt:vt;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 Rt={get:bt(!1,!1)},St={get:bt(!1,!0)},Lt={get:bt(!0,!1)},Et={get:bt(!0,!0)},Ot=new WeakMap,mt=new WeakMap,jt=new WeakMap,xt=new WeakMap;function It(t){return Nt(t)?t:Wt(t,!1,tt,Rt,Ot)}function Pt(t){return Wt(t,!1,st,St,mt)}function At(t){return Wt(t,!0,et,Lt,jt)}function Mt(t){return Wt(t,!0,nt,Et,xt)}function Wt(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 zt(t){return Nt(t)?zt(t.__k_raw):!(!t||!t.__k_isReactive)}function Nt(t){return!(!t||!t.__k_isReadonly)}function Tt(t){return!(!t||!t.__k_isShallow)}function Vt(t){return!!t&&!!t.__k_raw}function Dt(t){const e=t&&t.__k_raw;return e?Dt(e):t}function Kt(t){return Object.isExtensible(t)&&((t,e,s,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:s})})(t,"__k_skip",!0),t}const Ct=t=>h(t)?It(t):t,Ht=t=>h(t)?At(t):t;class Gt{constructor(t,e,s,n){this.getter=t,this._setter=e,this.dep=void 0,this.__k_isRef=!0,this.__k_isReadonly=!1,this.effect=new R((()=>t(this._value)),(()=>Bt(this,2===this.effect._dirtyLevel?2:3))),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__k_isReadonly=s}get value(){const t=Dt(this);return t._cacheable&&!t.effect.dirty||!d(t._value,t._value=t.effect.run())||Bt(t,4),qt(t),t.effect._dirtyLevel>=2&&Bt(t,2),t._value}set value(t){this._setter(t)}get _dirty(){return this.effect.dirty}set _dirty(t){this.effect.dirty=t}}function Yt(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new Gt(i,r,c||!r,n)}function qt(t){var e;x&&g&&(t=Dt(t),T(g,null!=(e=t.dep)?e:t.dep=K((()=>t.dep=void 0),t instanceof Gt?t:void 0)))}function Bt(t,e=4,s){const n=(t=Dt(t)).dep;n&&D(n,e)}function Ft(t){return!(!t||!0!==t.__k_isRef)}function Jt(t){return Ut(t,!1)}function Qt(t){return Ut(t,!0)}function Ut(t,e){return Ft(t)?t:new Xt(t,e)}class Xt{constructor(t,e){this.__k_isShallow=e,this.dep=void 0,this.__k_isRef=!0,this._rawValue=e?t:Dt(t),this._value=e?t:Ct(t)}get value(){return qt(this),this._value}set value(t){const e=this.__k_isShallow||Tt(t)||Nt(t);t=e?t:Dt(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Ct(t),Bt(this,4))}}function Zt(t){Bt(t,4)}function $t(t){return Ft(t)?t.value:t}function te(t){return o(t)?t():$t(t)}const ee={get:(t,e,s)=>$t(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Ft(i)&&!Ft(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function se(t){return zt(t)?t:new Proxy(t,ee)}class ne{constructor(t){this.dep=void 0,this.__k_isRef=!0;const{get:e,set:s}=t((()=>qt(this)),(()=>Bt(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ie(t){return new ne(t)}function re(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=he(t,s);return e}class ce{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 function(t,e){const s=C.get(t);return s&&s.get(e)}(Dt(this._object),this._key)}}class oe{constructor(t){this._getter=t,this.__k_isRef=!0,this.__k_isReadonly=!0}get value(){return this._getter()}}function ue(t,e,s){return Ft(t)?t:o(t)?new oe(t):h(t)&&arguments.length>1?he(t,e,s):Jt(t)}function he(t,e,s){const n=t[e];return Ft(n)?n:new ce(t,e,s)}const le=Yt,ae={GET:"get",HAS:"has",ITERATE:"iterate"},_e={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},fe={SKIP:"__k_skip",IS_REACTIVE:"__k_isReactive",IS_READONLY:"__k_isReadonly",IS_SHALLOW:"__k_isShallow",RAW:"__k_raw"};export{v as EffectScope,H as ITERATE_KEY,R as ReactiveEffect,fe as ReactiveFlags,ae as TrackOpTypes,_e as TriggerOpTypes,Yt as computed,ie as customRef,le as deferredComputed,m as effect,y as effectScope,M as enableTracking,w as getCurrentScope,Vt as isProxy,zt as isReactive,Nt as isReadonly,Ft as isRef,Tt as isShallow,Kt as markRaw,b as onScopeDispose,z as pauseScheduling,A as pauseTracking,se as proxyRefs,It as reactive,At as readonly,Jt as ref,N as resetScheduling,W as resetTracking,Pt as shallowReactive,Mt as shallowReadonly,Qt as shallowRef,j as stop,Dt as toRaw,ue as toRef,re as toRefs,te as toValue,Y as track,q as trigger,Zt as triggerRef,$t as unref};

@@ -1,2 +0,7 @@

import { extend, isArray, isMap, isIntegerKey, isSymbol, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@kdujs/shared';
/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
import { NOOP, extend, isArray, isSymbol, isMap, isIntegerKey, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction } from '@kdujs/shared';

@@ -107,95 +112,80 @@ function warn(msg, ...args) {

const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit;
}
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = /* @__PURE__ */ new WeakMap();
let effectTrackDepth = 0;
let trackOpBit = 1;
const maxMarkerBits = 30;
let activeEffect;
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
constructor(fn, trigger, scheduler, scope) {
this.fn = fn;
this.trigger = trigger;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
this.parent = void 0;
/**
* @internal
*/
this._dirtyLevel = 4;
/**
* @internal
*/
this._trackId = 0;
/**
* @internal
*/
this._runnings = 0;
/**
* @internal
*/
this._shouldSchedule = false;
/**
* @internal
*/
this._depsLength = 0;
recordEffectScope(this, scope);
}
get dirty() {
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
this._dirtyLevel = 1;
pauseTracking();
for (let i = 0; i < this._depsLength; i++) {
const dep = this.deps[i];
if (dep.computed) {
triggerComputed(dep.computed);
if (this._dirtyLevel >= 4) {
break;
}
}
}
if (this._dirtyLevel === 1) {
this._dirtyLevel = 0;
}
resetTracking();
}
return this._dirtyLevel >= 4;
}
set dirty(v) {
this._dirtyLevel = v ? 4 : 0;
}
run() {
this._dirtyLevel = 0;
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
let lastEffect = activeEffect;
try {
this.parent = activeEffect;
shouldTrack = true;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
this._runnings++;
preCleanupEffect(this);
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
postCleanupEffect(this);
this._runnings--;
activeEffect = lastEffect;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
if (this.active) {
preCleanupEffect(this);
postCleanupEffect(this);
this.onStop && this.onStop();
this.active = false;

@@ -205,11 +195,26 @@ }

}
function cleanupEffect(effect2) {
const { deps } = effect2;
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].delete(effect2);
function triggerComputed(computed) {
return computed.value;
}
function preCleanupEffect(effect2) {
effect2._trackId++;
effect2._depsLength = 0;
}
function postCleanupEffect(effect2) {
if (effect2.deps.length > effect2._depsLength) {
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
cleanupDepEffect(effect2.deps[i], effect2);
}
deps.length = 0;
effect2.deps.length = effect2._depsLength;
}
}
function cleanupDepEffect(dep, effect2) {
const trackId = dep.get(effect2);
if (trackId !== void 0 && effect2._trackId !== trackId) {
dep.delete(effect2);
if (dep.size === 0) {
dep.cleanup();
}
}
}
function effect(fn, options) {

@@ -219,7 +224,10 @@ if (fn.effect instanceof ReactiveEffect) {

}
const _effect = new ReactiveEffect(fn);
const _effect = new ReactiveEffect(fn, NOOP, () => {
if (_effect.dirty) {
_effect.run();
}
});
if (options) {
extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
if (options.scope) recordEffectScope(_effect, options.scope);
}

@@ -237,2 +245,3 @@ if (!options || !options.lazy) {

let shouldTrack = true;
let pauseScheduleStack = 0;
const trackStack = [];

@@ -251,2 +260,65 @@ function pauseTracking() {

}
function pauseScheduling() {
pauseScheduleStack++;
}
function resetScheduling() {
pauseScheduleStack--;
while (!pauseScheduleStack && queueEffectSchedulers.length) {
queueEffectSchedulers.shift()();
}
}
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
var _a;
if (dep.get(effect2) !== effect2._trackId) {
dep.set(effect2, effect2._trackId);
const oldDep = effect2.deps[effect2._depsLength];
if (oldDep !== dep) {
if (oldDep) {
cleanupDepEffect(oldDep, effect2);
}
effect2.deps[effect2._depsLength++] = dep;
} else {
effect2._depsLength++;
}
if (!!(process.env.NODE_ENV !== "production")) {
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
}
}
}
const queueEffectSchedulers = [];
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
var _a;
pauseScheduling();
for (const effect2 of dep.keys()) {
let tracking;
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
effect2._dirtyLevel = dirtyLevel;
}
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
if (!!(process.env.NODE_ENV !== "production")) {
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
}
effect2.trigger();
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
effect2._shouldSchedule = false;
if (effect2.scheduler) {
queueEffectSchedulers.push(effect2.scheduler);
}
}
}
}
resetScheduling();
}
const createDep = (cleanup, computed) => {
const dep = /* @__PURE__ */ new Map();
dep.cleanup = cleanup;
dep.computed = computed;
return dep;
};
const targetMap = /* @__PURE__ */ new WeakMap();
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
function track(target, type, key) {

@@ -260,33 +332,15 @@ if (shouldTrack && activeEffect) {

if (!dep) {
depsMap.set(key, dep = createDep());
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
}
const eventInfo = !!(process.env.NODE_ENV !== "production") ? { effect: activeEffect, target, type, key } : void 0;
trackEffects(dep, eventInfo);
trackEffect(
activeEffect,
dep,
!!(process.env.NODE_ENV !== "production") ? {
target,
type,
key
} : void 0
);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if (!!(process.env.NODE_ENV !== "production") && activeEffect.onTrack) {
activeEffect.onTrack(
extend(
{
effect: activeEffect
},
debuggerEventExtraInfo
)
);
}
}
}
function trigger(target, type, key, newValue, oldValue, oldTarget) {

@@ -303,3 +357,3 @@ const depsMap = targetMap.get(target);

depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
deps.push(dep);

@@ -338,53 +392,24 @@ }

}
const eventInfo = !!(process.env.NODE_ENV !== "production") ? { target, type, key, newValue, oldValue, oldTarget } : void 0;
if (deps.length === 1) {
if (deps[0]) {
if (!!(process.env.NODE_ENV !== "production")) {
triggerEffects(deps[0], eventInfo);
} else {
triggerEffects(deps[0]);
}
pauseScheduling();
for (const dep of deps) {
if (dep) {
triggerEffects(
dep,
4,
!!(process.env.NODE_ENV !== "production") ? {
target,
type,
key,
newValue,
oldValue,
oldTarget
} : void 0
);
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
if (!!(process.env.NODE_ENV !== "production")) {
triggerEffects(createDep(effects), eventInfo);
} else {
triggerEffects(createDep(effects));
}
}
resetScheduling();
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = isArray(dep) ? dep : [...dep];
for (const effect2 of effects) {
if (effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
for (const effect2 of effects) {
if (!effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
}
function triggerEffect(effect2, debuggerEventExtraInfo) {
if (effect2 !== activeEffect || effect2.allowRecurse) {
if (!!(process.env.NODE_ENV !== "production") && effect2.onTrigger) {
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
}
if (effect2.scheduler) {
effect2.scheduler();
} else {
effect2.run();
}
}
}
function getDepFromReactive(object, key) {
var _a;
return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
const depsMap = targetMap.get(object);
return depsMap && depsMap.get(key);
}

@@ -416,3 +441,5 @@

pauseTracking();
pauseScheduling();
const res = toRaw(this)[key].apply(this, args);
resetScheduling();
resetTracking();

@@ -425,2 +452,3 @@ return res;

function hasOwnProperty(key) {
if (!isSymbol(key)) key = String(key);
const obj = toRaw(this);

@@ -431,8 +459,8 @@ track(obj, "has", key);

class BaseReactiveHandler {
constructor(_isReadonly = false, _shallow = false) {
constructor(_isReadonly = false, _isShallow = false) {
this._isReadonly = _isReadonly;
this._shallow = _shallow;
this._isShallow = _isShallow;
}
get(target, key, receiver) {
const isReadonly2 = this._isReadonly, shallow = this._shallow;
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
if (key === "__k_isReactive") {

@@ -443,5 +471,10 @@ return !isReadonly2;

} else if (key === "__k_isShallow") {
return shallow;
} else if (key === "__k_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
return isShallow2;
} else if (key === "__k_raw") {
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
// this means the reciever is a user proxy of the reactive proxy
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
return target;
}
return;
}

@@ -464,3 +497,3 @@ const targetIsArray = isArray(target);

}
if (shallow) {
if (isShallow2) {
return res;

@@ -478,11 +511,9 @@ }

class MutableReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(false, shallow);
constructor(isShallow2 = false) {
super(false, isShallow2);
}
set(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!this._shallow) {
if (!this._isShallow) {
const isOldValueReadonly = isReadonly(oldValue);
if (!isShallow(value) && !isReadonly(value)) {

@@ -493,4 +524,8 @@ oldValue = toRaw(oldValue);

if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
if (isOldValueReadonly) {
return false;
} else {
oldValue.value = value;
return true;
}
}

@@ -535,4 +570,4 @@ }

class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(true, shallow);
constructor(isShallow2 = false) {
super(true, isShallow2);
}

@@ -708,3 +743,3 @@ set(target, key) {

const key = args[0] ? `on key "${args[0]}" ` : ``;
console.warn(
warn(
`${capitalize(type)} operation ${key}failed: target is readonly.`,

@@ -714,3 +749,3 @@ toRaw(this)

}
return type === "delete" ? false : this;
return type === "delete" ? false : type === "clear" ? void 0 : this;
};

@@ -779,19 +814,12 @@ }

};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
const iteratorMethods = [
"keys",
"values",
"entries",
Symbol.iterator
];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(
method,
false,
false
);
readonlyInstrumentations2[method] = createIterableMethod(
method,
true,
false
);
shallowInstrumentations2[method] = createIterableMethod(
method,
false,
true
);
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations2[method] = createIterableMethod(

@@ -849,3 +877,3 @@ method,

const type = toRawType(target);
console.warn(
warn(
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`

@@ -919,3 +947,7 @@ );

if (!!(process.env.NODE_ENV !== "production")) {
console.warn(`value cannot be made reactive: ${String(target)}`);
warn(
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
target
)}`
);
}

@@ -955,3 +987,3 @@ return target;

function isProxy(value) {
return isReactive(value) || isReadonly(value);
return value ? !!value["__k_raw"] : false;
}

@@ -963,3 +995,5 @@ function toRaw(observed) {

function markRaw(value) {
def(value, "__k_skip", true);
if (Object.isExtensible(value)) {
def(value, "__k_skip", true);
}
return value;

@@ -970,22 +1004,96 @@ }

const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://kdu-js.web.app/guide/essentials/computed.html#getters-should-be-side-effect-free`;
class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this.getter = getter;
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this.effect = new ReactiveEffect(
() => getter(this._value),
() => triggerRefValue(
this,
this.effect._dirtyLevel === 2 ? 2 : 3
)
);
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
triggerRefValue(self, 4);
}
trackRefValue(self);
if (self.effect._dirtyLevel >= 2) {
if (!!(process.env.NODE_ENV !== "production") && this._warnRecursive) {
warn(COMPUTED_SIDE_EFFECT_WARN, `
getter: `, this.getter);
}
triggerRefValue(self, 2);
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
// #region polyfill _dirty for backward compatibility third party code for Kdu <= 3.3.x
get _dirty() {
return this.effect.dirty;
}
set _dirty(v) {
this.effect.dirty = v;
}
// #endregion
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = !!(process.env.NODE_ENV !== "production") ? () => {
warn("Write operation failed: computed value is readonly");
} : NOOP;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
function trackRefValue(ref2) {
var _a;
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
if (!!(process.env.NODE_ENV !== "production")) {
trackEffects(ref2.dep || (ref2.dep = createDep()), {
trackEffect(
activeEffect,
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
() => ref2.dep = void 0,
ref2 instanceof ComputedRefImpl ? ref2 : void 0
),
!!(process.env.NODE_ENV !== "production") ? {
target: ref2,
type: "get",
key: "value"
});
} else {
trackEffects(ref2.dep || (ref2.dep = createDep()));
}
} : void 0
);
}
}
function triggerRefValue(ref2, newVal) {
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
if (!!(process.env.NODE_ENV !== "production")) {
triggerEffects(dep, {
triggerEffects(
dep,
dirtyLevel,
!!(process.env.NODE_ENV !== "production") ? {
target: ref2,

@@ -995,6 +1103,4 @@ type: "set",

newValue: newVal
});
} else {
triggerEffects(dep);
}
} : void 0
);
}

@@ -1035,3 +1141,3 @@ }

this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
triggerRefValue(this, 4, newVal);
}

@@ -1041,3 +1147,3 @@ }

function triggerRef(ref2) {
triggerRefValue(ref2, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
}

@@ -1088,3 +1194,3 @@ function unref(ref2) {

if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
warn(`toRefs() expects a reactive object but received a plain one.`);
}

@@ -1141,124 +1247,23 @@ const ret = isArray(object) ? new Array(object.length) : {};

class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
trackRefValue(self);
if (self._dirty || !self._cacheable) {
self._dirty = false;
self._value = self.effect.run();
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = !!(process.env.NODE_ENV !== "production") ? () => {
console.warn("Write operation failed: computed value is readonly");
} : NOOP;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
const deferredComputed = computed;
const tick = /* @__PURE__ */ Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
const TrackOpTypes = {
"GET": "get",
"HAS": "has",
"ITERATE": "iterate"
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
const TriggerOpTypes = {
"SET": "set",
"ADD": "add",
"DELETE": "delete",
"CLEAR": "clear"
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = void 0;
this._dirty = true;
this.__k_isRef = true;
this["__k_isReadonly"] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
} else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
for (const e of this.dep) {
if (e.computed instanceof DeferredComputedRefImpl) {
e.scheduler(
true
/* computedTrigger */
);
}
}
}
this._dirty = true;
});
this.effect.computed = this;
}
_get() {
if (this._dirty) {
this._dirty = false;
return this._value = this.effect.run();
}
return this._value;
}
get value() {
trackRefValue(this);
return toRaw(this)._get();
}
}
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
const ReactiveFlags = {
"SKIP": "__k_skip",
"IS_REACTIVE": "__k_isReactive",
"IS_READONLY": "__k_isReadonly",
"IS_SHALLOW": "__k_isShallow",
"RAW": "__k_raw"
};
export { EffectScope, ITERATE_KEY, ReactiveEffect, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref };
export { EffectScope, ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseScheduling, pauseTracking, proxyRefs, reactive, readonly, ref, resetScheduling, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref };

@@ -0,13 +1,18 @@

/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
var KduReactivity = (function (exports) {
'use strict';
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function makeMap(str, expectsLowerCase) {
const map = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
const set = new Set(str.split(","));
return (val) => set.has(val);
}
const NOOP = () => {
};
const extend = Object.assign;

@@ -39,6 +44,7 @@ const hasOwnProperty$1 = Object.prototype.hasOwnProperty;

const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
const def = (obj, key, value) => {
const def = (obj, key, value, writable = false) => {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
writable,
value

@@ -152,95 +158,80 @@ });

const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit;
}
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = /* @__PURE__ */ new WeakMap();
let effectTrackDepth = 0;
let trackOpBit = 1;
const maxMarkerBits = 30;
let activeEffect;
const ITERATE_KEY = Symbol("iterate" );
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
constructor(fn, trigger, scheduler, scope) {
this.fn = fn;
this.trigger = trigger;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
this.parent = void 0;
/**
* @internal
*/
this._dirtyLevel = 4;
/**
* @internal
*/
this._trackId = 0;
/**
* @internal
*/
this._runnings = 0;
/**
* @internal
*/
this._shouldSchedule = false;
/**
* @internal
*/
this._depsLength = 0;
recordEffectScope(this, scope);
}
get dirty() {
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
this._dirtyLevel = 1;
pauseTracking();
for (let i = 0; i < this._depsLength; i++) {
const dep = this.deps[i];
if (dep.computed) {
triggerComputed(dep.computed);
if (this._dirtyLevel >= 4) {
break;
}
}
}
if (this._dirtyLevel === 1) {
this._dirtyLevel = 0;
}
resetTracking();
}
return this._dirtyLevel >= 4;
}
set dirty(v) {
this._dirtyLevel = v ? 4 : 0;
}
run() {
this._dirtyLevel = 0;
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
let lastEffect = activeEffect;
try {
this.parent = activeEffect;
shouldTrack = true;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
this._runnings++;
preCleanupEffect(this);
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
postCleanupEffect(this);
this._runnings--;
activeEffect = lastEffect;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
if (this.active) {
preCleanupEffect(this);
postCleanupEffect(this);
this.onStop && this.onStop();
this.active = false;

@@ -250,11 +241,26 @@ }

}
function cleanupEffect(effect2) {
const { deps } = effect2;
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].delete(effect2);
function triggerComputed(computed) {
return computed.value;
}
function preCleanupEffect(effect2) {
effect2._trackId++;
effect2._depsLength = 0;
}
function postCleanupEffect(effect2) {
if (effect2.deps.length > effect2._depsLength) {
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
cleanupDepEffect(effect2.deps[i], effect2);
}
deps.length = 0;
effect2.deps.length = effect2._depsLength;
}
}
function cleanupDepEffect(dep, effect2) {
const trackId = dep.get(effect2);
if (trackId !== void 0 && effect2._trackId !== trackId) {
dep.delete(effect2);
if (dep.size === 0) {
dep.cleanup();
}
}
}
function effect(fn, options) {

@@ -264,7 +270,10 @@ if (fn.effect instanceof ReactiveEffect) {

}
const _effect = new ReactiveEffect(fn);
const _effect = new ReactiveEffect(fn, NOOP, () => {
if (_effect.dirty) {
_effect.run();
}
});
if (options) {
extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
if (options.scope) recordEffectScope(_effect, options.scope);
}

@@ -282,2 +291,3 @@ if (!options || !options.lazy) {

let shouldTrack = true;
let pauseScheduleStack = 0;
const trackStack = [];

@@ -296,2 +306,65 @@ function pauseTracking() {

}
function pauseScheduling() {
pauseScheduleStack++;
}
function resetScheduling() {
pauseScheduleStack--;
while (!pauseScheduleStack && queueEffectSchedulers.length) {
queueEffectSchedulers.shift()();
}
}
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
var _a;
if (dep.get(effect2) !== effect2._trackId) {
dep.set(effect2, effect2._trackId);
const oldDep = effect2.deps[effect2._depsLength];
if (oldDep !== dep) {
if (oldDep) {
cleanupDepEffect(oldDep, effect2);
}
effect2.deps[effect2._depsLength++] = dep;
} else {
effect2._depsLength++;
}
{
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
}
}
}
const queueEffectSchedulers = [];
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
var _a;
pauseScheduling();
for (const effect2 of dep.keys()) {
let tracking;
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
effect2._dirtyLevel = dirtyLevel;
}
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
{
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
}
effect2.trigger();
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
effect2._shouldSchedule = false;
if (effect2.scheduler) {
queueEffectSchedulers.push(effect2.scheduler);
}
}
}
}
resetScheduling();
}
const createDep = (cleanup, computed) => {
const dep = /* @__PURE__ */ new Map();
dep.cleanup = cleanup;
dep.computed = computed;
return dep;
};
const targetMap = /* @__PURE__ */ new WeakMap();
const ITERATE_KEY = Symbol("iterate" );
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
function track(target, type, key) {

@@ -305,33 +378,15 @@ if (shouldTrack && activeEffect) {

if (!dep) {
depsMap.set(key, dep = createDep());
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
}
const eventInfo = { effect: activeEffect, target, type, key } ;
trackEffects(dep, eventInfo);
trackEffect(
activeEffect,
dep,
{
target,
type,
key
}
);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if (activeEffect.onTrack) {
activeEffect.onTrack(
extend(
{
effect: activeEffect
},
debuggerEventExtraInfo
)
);
}
}
}
function trigger(target, type, key, newValue, oldValue, oldTarget) {

@@ -348,3 +403,3 @@ const depsMap = targetMap.get(target);

depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
deps.push(dep);

@@ -383,49 +438,24 @@ }

}
const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
pauseScheduling();
for (const dep of deps) {
if (dep) {
triggerEffects(
dep,
4,
{
target,
type,
key,
newValue,
oldValue,
oldTarget
}
);
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
{
triggerEffects(createDep(effects), eventInfo);
}
}
resetScheduling();
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = isArray(dep) ? dep : [...dep];
for (const effect2 of effects) {
if (effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
for (const effect2 of effects) {
if (!effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
}
function triggerEffect(effect2, debuggerEventExtraInfo) {
if (effect2 !== activeEffect || effect2.allowRecurse) {
if (effect2.onTrigger) {
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
}
if (effect2.scheduler) {
effect2.scheduler();
} else {
effect2.run();
}
}
}
function getDepFromReactive(object, key) {
var _a;
return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
const depsMap = targetMap.get(object);
return depsMap && depsMap.get(key);
}

@@ -457,3 +487,5 @@

pauseTracking();
pauseScheduling();
const res = toRaw(this)[key].apply(this, args);
resetScheduling();
resetTracking();

@@ -466,2 +498,3 @@ return res;

function hasOwnProperty(key) {
if (!isSymbol(key)) key = String(key);
const obj = toRaw(this);

@@ -472,8 +505,8 @@ track(obj, "has", key);

class BaseReactiveHandler {
constructor(_isReadonly = false, _shallow = false) {
constructor(_isReadonly = false, _isShallow = false) {
this._isReadonly = _isReadonly;
this._shallow = _shallow;
this._isShallow = _isShallow;
}
get(target, key, receiver) {
const isReadonly2 = this._isReadonly, shallow = this._shallow;
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
if (key === "__k_isReactive") {

@@ -484,5 +517,10 @@ return !isReadonly2;

} else if (key === "__k_isShallow") {
return shallow;
} else if (key === "__k_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
return isShallow2;
} else if (key === "__k_raw") {
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
// this means the reciever is a user proxy of the reactive proxy
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
return target;
}
return;
}

@@ -505,3 +543,3 @@ const targetIsArray = isArray(target);

}
if (shallow) {
if (isShallow2) {
return res;

@@ -519,11 +557,9 @@ }

class MutableReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(false, shallow);
constructor(isShallow2 = false) {
super(false, isShallow2);
}
set(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!this._shallow) {
if (!this._isShallow) {
const isOldValueReadonly = isReadonly(oldValue);
if (!isShallow(value) && !isReadonly(value)) {

@@ -534,4 +570,8 @@ oldValue = toRaw(oldValue);

if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
if (isOldValueReadonly) {
return false;
} else {
oldValue.value = value;
return true;
}
}

@@ -576,4 +616,4 @@ }

class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(true, shallow);
constructor(isShallow2 = false) {
super(true, isShallow2);
}

@@ -749,3 +789,3 @@ set(target, key) {

const key = args[0] ? `on key "${args[0]}" ` : ``;
console.warn(
warn(
`${capitalize(type)} operation ${key}failed: target is readonly.`,

@@ -755,3 +795,3 @@ toRaw(this)

}
return type === "delete" ? false : this;
return type === "delete" ? false : type === "clear" ? void 0 : this;
};

@@ -820,19 +860,12 @@ }

};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
const iteratorMethods = [
"keys",
"values",
"entries",
Symbol.iterator
];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(
method,
false,
false
);
readonlyInstrumentations2[method] = createIterableMethod(
method,
true,
false
);
shallowInstrumentations2[method] = createIterableMethod(
method,
false,
true
);
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations2[method] = createIterableMethod(

@@ -890,3 +923,3 @@ method,

const type = toRawType(target);
console.warn(
warn(
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`

@@ -960,3 +993,7 @@ );

{
console.warn(`value cannot be made reactive: ${String(target)}`);
warn(
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
target
)}`
);
}

@@ -996,3 +1033,3 @@ return target;

function isProxy(value) {
return isReactive(value) || isReadonly(value);
return value ? !!value["__k_raw"] : false;
}

@@ -1004,3 +1041,5 @@ function toRaw(observed) {

function markRaw(value) {
def(value, "__k_skip", true);
if (Object.isExtensible(value)) {
def(value, "__k_skip", true);
}
return value;

@@ -1011,20 +1050,96 @@ }

const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://kdu-js.web.app/guide/essentials/computed.html#getters-should-be-side-effect-free`;
class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this.getter = getter;
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this.effect = new ReactiveEffect(
() => getter(this._value),
() => triggerRefValue(
this,
this.effect._dirtyLevel === 2 ? 2 : 3
)
);
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
triggerRefValue(self, 4);
}
trackRefValue(self);
if (self.effect._dirtyLevel >= 2) {
if (this._warnRecursive) {
warn(COMPUTED_SIDE_EFFECT_WARN, `
getter: `, this.getter);
}
triggerRefValue(self, 2);
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
// #region polyfill _dirty for backward compatibility third party code for Kdu <= 3.3.x
get _dirty() {
return this.effect.dirty;
}
set _dirty(v) {
this.effect.dirty = v;
}
// #endregion
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
warn("Write operation failed: computed value is readonly");
} ;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
function trackRefValue(ref2) {
var _a;
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
{
trackEffects(ref2.dep || (ref2.dep = createDep()), {
trackEffect(
activeEffect,
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
() => ref2.dep = void 0,
ref2 instanceof ComputedRefImpl ? ref2 : void 0
),
{
target: ref2,
type: "get",
key: "value"
});
}
}
);
}
}
function triggerRefValue(ref2, newVal) {
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
{
triggerEffects(dep, {
triggerEffects(
dep,
dirtyLevel,
{
target: ref2,

@@ -1034,4 +1149,4 @@ type: "set",

newValue: newVal
});
}
}
);
}

@@ -1072,3 +1187,3 @@ }

this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
triggerRefValue(this, 4, newVal);
}

@@ -1078,3 +1193,3 @@ }

function triggerRef(ref2) {
triggerRefValue(ref2, ref2.value );
triggerRefValue(ref2, 4, ref2.value );
}

@@ -1125,3 +1240,3 @@ function unref(ref2) {

if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
warn(`toRefs() expects a reactive object but received a plain one.`);
}

@@ -1178,123 +1293,22 @@ const ret = isArray(object) ? new Array(object.length) : {};

class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__k_isRef = true;
this["__k_isReadonly"] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__k_isReadonly"] = isReadonly;
}
get value() {
const self = toRaw(this);
trackRefValue(self);
if (self._dirty || !self._cacheable) {
self._dirty = false;
self._value = self.effect.run();
}
return self._value;
}
set value(newValue) {
this._setter(newValue);
}
}
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
console.warn("Write operation failed: computed value is readonly");
} ;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
const deferredComputed = computed;
const tick = /* @__PURE__ */ Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
const TrackOpTypes = {
"GET": "get",
"HAS": "has",
"ITERATE": "iterate"
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
const TriggerOpTypes = {
"SET": "set",
"ADD": "add",
"DELETE": "delete",
"CLEAR": "clear"
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = void 0;
this._dirty = true;
this.__k_isRef = true;
this["__k_isReadonly"] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
} else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
for (const e of this.dep) {
if (e.computed instanceof DeferredComputedRefImpl) {
e.scheduler(
true
/* computedTrigger */
);
}
}
}
this._dirty = true;
});
this.effect.computed = this;
}
_get() {
if (this._dirty) {
this._dirty = false;
return this._value = this.effect.run();
}
return this._value;
}
get value() {
trackRefValue(this);
return toRaw(this)._get();
}
}
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
const ReactiveFlags = {
"SKIP": "__k_skip",
"IS_REACTIVE": "__k_isReactive",
"IS_READONLY": "__k_isReadonly",
"IS_SHALLOW": "__k_isShallow",
"RAW": "__k_raw"
};

@@ -1304,2 +1318,5 @@ exports.EffectScope = EffectScope;

exports.ReactiveEffect = ReactiveEffect;
exports.ReactiveFlags = ReactiveFlags;
exports.TrackOpTypes = TrackOpTypes;
exports.TriggerOpTypes = TriggerOpTypes;
exports.computed = computed;

@@ -1319,2 +1336,3 @@ exports.customRef = customRef;

exports.onScopeDispose = onScopeDispose;
exports.pauseScheduling = pauseScheduling;
exports.pauseTracking = pauseTracking;

@@ -1325,2 +1343,3 @@ exports.proxyRefs = proxyRefs;

exports.ref = ref;
exports.resetScheduling = resetScheduling;
exports.resetTracking = resetTracking;

@@ -1327,0 +1346,0 @@ exports.shallowReactive = shallowReactive;

@@ -1,1 +0,7 @@

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}({});
/**
* @kdujs/reactivity-canary v3.20241202.0
* (c) 2021-present NKDuy
* @license MIT
**/
var KduReactivity=function(t){"use strict";
/*! #__NO_SIDE_EFFECTS__ */function e(t,e){const s=new Set(t.split(","));return t=>s.has(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,l=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,f=t=>h.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,y;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 k(t,e=g){e&&e.active&&e.effects.push(t)}class w{constructor(t,e,s,n){this.fn=t,this.trigger=e,this.scheduler=s,this.active=!0,this.deps=[],this._dirtyLevel=4,this._trackId=0,this._runnings=0,this._shouldSchedule=!1,this._depsLength=0,k(this,n)}get dirty(){if(2===this._dirtyLevel||3===this._dirtyLevel){this._dirtyLevel=1,j();for(let t=0;t<this._depsLength;t++){const e=this.deps[t];if(e.computed&&(R(e.computed),this._dirtyLevel>=4))break}1===this._dirtyLevel&&(this._dirtyLevel=0),x()}return this._dirtyLevel>=4}set dirty(t){this._dirtyLevel=t?4:0}run(){if(this._dirtyLevel=0,!this.active)return this.fn();let t=E,e=y;try{return E=!0,y=this,this._runnings++,S(this),this.fn()}finally{b(this),this._runnings--,y=e,E=t}}stop(){this.active&&(S(this),b(this),this.onStop&&this.onStop(),this.active=!1)}}function R(t){return t.value}function S(t){t._trackId++,t._depsLength=0}function b(t){if(t.deps.length>t._depsLength){for(let e=t._depsLength;e<t.deps.length;e++)L(t.deps[e],t);t.deps.length=t._depsLength}}function L(t,e){const s=t.get(e);void 0!==s&&e._trackId!==s&&(t.delete(e),0===t.size&&t.cleanup())}let E=!0,O=0;const m=[];function j(){m.push(E),E=!1}function x(){const t=m.pop();E=void 0===t||t}function I(){O++}function P(){for(O--;!O&&A.length;)A.shift()()}function T(t,e,s){if(e.get(t)!==t._trackId){e.set(t,t._trackId);const s=t.deps[t._depsLength];s!==e?(s&&L(s,t),t.deps[t._depsLength++]=e):t._depsLength++}}const A=[];function M(t,e,s){I();for(const n of t.keys()){let s;n._dirtyLevel<e&&(null!=s?s:s=t.get(n)===n._trackId)&&(n._shouldSchedule||(n._shouldSchedule=0===n._dirtyLevel),n._dirtyLevel=e),n._shouldSchedule&&(null!=s?s:s=t.get(n)===n._trackId)&&(n.trigger(),n._runnings&&!n.allowRecurse||2===n._dirtyLevel||(n._shouldSchedule=!1,n.scheduler&&A.push(n.scheduler)))}P()}const W=(t,e)=>{const s=new Map;return s.cleanup=t,s.computed=e,s},z=new WeakMap,V=Symbol(""),K=Symbol("");function N(t,e,s){if(E&&y){let e=z.get(t);e||z.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=W((()=>e.delete(s)))),T(y,n)}}function D(t,e,s,n,i,r){const u=z.get(t);if(!u)return;let l=[];if("clear"===e)l=[...u.values()];else if("length"===s&&c(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||!a(s)&&s>=t)&&l.push(e)}))}else switch(void 0!==s&&l.push(u.get(s)),e){case"add":c(t)?d(s)&&l.push(u.get("length")):(l.push(u.get(V)),o(t)&&l.push(u.get(K)));break;case"delete":c(t)||(l.push(u.get(V)),o(t)&&l.push(u.get(K)));break;case"set":o(t)&&l.push(u.get(V))}I();for(const c of l)c&&M(c,4);P()}const C=e("__proto__,__k_isRef,__isKdu"),H=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),Y=F();function F(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Pt(this);for(let e=0,i=this.length;e<i;e++)N(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Pt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){j(),I();const s=Pt(this)[e].apply(this,t);return P(),x(),s}})),t}function G(t){a(t)||(t=String(t));const e=Pt(this);return N(e,0,t),e.hasOwnProperty(t)}class q{constructor(t=!1,e=!1){this._isReadonly=t,this._isShallow=e}get(t,e,s){const n=this._isReadonly,i=this._isShallow;if("__k_isReactive"===e)return!n;if("__k_isReadonly"===e)return n;if("__k_isShallow"===e)return i;if("__k_raw"===e)return s===(n?i?Lt:bt:i?St:Rt).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=c(t);if(!n){if(o&&r(Y,e))return Reflect.get(Y,e,s);if("hasOwnProperty"===e)return G}const u=Reflect.get(t,e,s);return(a(e)?H.has(e):C(e))?u:(n||N(t,0,e),i?u:Kt(u)?o&&d(e)?u:u.value:l(u)?n?Ot(u):Et(u):u)}}class B extends q{constructor(t=!1){super(!1,t)}set(t,e,s,n){let i=t[e];if(!this._isShallow){const e=xt(i);if(It(s)||xt(s)||(i=Pt(i),s=Pt(s)),!c(t)&&Kt(i)&&!Kt(s))return!e&&(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===Pt(n)&&(o?p(s,i)&&D(t,"set",e,s):D(t,"add",e,s)),u}deleteProperty(t,e){const s=r(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 a(e)&&H.has(e)||N(t,0,e),s}ownKeys(t){return N(t,0,c(t)?"length":V),Reflect.ownKeys(t)}}class J extends q{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const Q=new B,U=new J,X=new B(!0),Z=new J(!0),$=t=>t,tt=t=>Reflect.getPrototypeOf(t);function et(t,e,s=!1,n=!1){const i=Pt(t=t.__k_raw),r=Pt(e);s||(p(e,r)&&N(i,0,e),N(i,0,r));const{has:c}=tt(i),o=n?$:s?At:Tt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function st(t,e=!1){const s=this.__k_raw,n=Pt(s),i=Pt(t);return e||(p(t,i)&&N(n,0,t),N(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function nt(t,e=!1){return t=t.__k_raw,!e&&N(Pt(t),0,V),Reflect.get(t,"size",t)}function it(t){t=Pt(t);const e=Pt(this);return tt(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function rt(t,e){e=Pt(e);const s=Pt(this),{has:n,get:i}=tt(s);let r=n.call(s,t);r||(t=Pt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?p(e,c)&&D(s,"set",t,e):D(s,"add",t,e),this}function ct(t){const e=Pt(this),{has:s,get:n}=tt(e);let i=s.call(e,t);i||(t=Pt(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 ot(){const t=Pt(this),e=0!==t.size,s=t.clear();return e&&D(t,"clear",void 0,void 0),s}function ut(t,e){return function(s,n){const i=this,r=i.__k_raw,c=Pt(r),o=e?$:t?At:Tt;return!t&&N(c,0,V),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function at(t,e,s){return function(...n){const i=this.__k_raw,r=Pt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=i[t](...n),h=s?$:e?At:Tt;return!e&&N(r,0,a?K:V),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[h(t[0]),h(t[1])]:h(t),done:e}},[Symbol.iterator](){return this}}}}function lt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function ht(){const t={get(t){return et(this,t)},get size(){return nt(this)},has:st,add:it,set:rt,delete:ct,clear:ot,forEach:ut(!1,!1)},e={get(t){return et(this,t,!1,!0)},get size(){return nt(this)},has:st,add:it,set:rt,delete:ct,clear:ot,forEach:ut(!1,!0)},s={get(t){return et(this,t,!0)},get size(){return nt(this,!0)},has(t){return st.call(this,t,!0)},add:lt("add"),set:lt("set"),delete:lt("delete"),clear:lt("clear"),forEach:ut(!0,!1)},n={get(t){return et(this,t,!0,!0)},get size(){return nt(this,!0)},has(t){return st.call(this,t,!0)},add:lt("add"),set:lt("set"),delete:lt("delete"),clear:lt("clear"),forEach:ut(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=at(i,!1,!1),s[i]=at(i,!0,!1),e[i]=at(i,!1,!0),n[i]=at(i,!0,!0)})),[t,s,e,n]}const[ft,_t,dt,pt]=ht();function gt(t,e){const s=e?t?pt:dt:t?_t:ft;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 yt={get:gt(!1,!1)},vt={get:gt(!1,!0)},kt={get:gt(!0,!1)},wt={get:gt(!0,!0)},Rt=new WeakMap,St=new WeakMap,bt=new WeakMap,Lt=new WeakMap;function Et(t){return xt(t)?t:mt(t,!1,Q,yt,Rt)}function Ot(t){return mt(t,!0,U,kt,bt)}function mt(t,e,s,n,i){if(!l(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 jt(t){return xt(t)?jt(t.__k_raw):!(!t||!t.__k_isReactive)}function xt(t){return!(!t||!t.__k_isReadonly)}function It(t){return!(!t||!t.__k_isShallow)}function Pt(t){const e=t&&t.__k_raw;return e?Pt(e):t}const Tt=t=>l(t)?Et(t):t,At=t=>l(t)?Ot(t):t;class Mt{constructor(t,e,s,n){this.getter=t,this._setter=e,this.dep=void 0,this.__k_isRef=!0,this.__k_isReadonly=!1,this.effect=new w((()=>t(this._value)),(()=>Vt(this,2===this.effect._dirtyLevel?2:3))),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__k_isReadonly=s}get value(){const t=Pt(this);return t._cacheable&&!t.effect.dirty||!p(t._value,t._value=t.effect.run())||Vt(t,4),zt(t),t.effect._dirtyLevel>=2&&Vt(t,2),t._value}set value(t){this._setter(t)}get _dirty(){return this.effect.dirty}set _dirty(t){this.effect.dirty=t}}function Wt(t,e,n=!1){let i,r;const c=u(t);c?(i=t,r=s):(i=t.get,r=t.set);return new Mt(i,r,c||!r,n)}function zt(t){var e;E&&y&&(t=Pt(t),T(y,null!=(e=t.dep)?e:t.dep=W((()=>t.dep=void 0),t instanceof Mt?t:void 0)))}function Vt(t,e=4,s){const n=(t=Pt(t)).dep;n&&M(n,e)}function Kt(t){return!(!t||!0!==t.__k_isRef)}function Nt(t){return Dt(t,!1)}function Dt(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:Pt(t),this._value=e?t:Tt(t)}get value(){return zt(this),this._value}set value(t){const e=this.__k_isShallow||It(t)||xt(t);t=e?t:Pt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Tt(t),Vt(this,4))}}function Ht(t){return Kt(t)?t.value:t}const Yt={get:(t,e,s)=>Ht(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 Ft{constructor(t){this.dep=void 0,this.__k_isRef=!0;const{get:e,set:s}=t((()=>zt(this)),(()=>Vt(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}class Gt{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 function(t,e){const s=z.get(t);return s&&s.get(e)}(Pt(this._object),this._key)}}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 Gt(t,e,s)}const Jt=Wt;return t.EffectScope=v,t.ITERATE_KEY=V,t.ReactiveEffect=w,t.ReactiveFlags={SKIP:"__k_skip",IS_REACTIVE:"__k_isReactive",IS_READONLY:"__k_isReadonly",IS_SHALLOW:"__k_isShallow",RAW:"__k_raw"},t.TrackOpTypes={GET:"get",HAS:"has",ITERATE:"iterate"},t.TriggerOpTypes={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},t.computed=Wt,t.customRef=function(t){return new Ft(t)},t.deferredComputed=Jt,t.effect=function(t,e){t.effect instanceof w&&(t=t.effect.fn);const i=new w(t,s,(()=>{i.dirty&&i.run()}));e&&(n(i,e),e.scope&&k(i,e.scope)),e&&e.lazy||i.run();const r=i.run.bind(i);return r.effect=i,r},t.effectScope=function(t){return new v(t)},t.enableTracking=function(){m.push(E),E=!0},t.getCurrentScope=function(){return g},t.isProxy=function(t){return!!t&&!!t.__k_raw},t.isReactive=jt,t.isReadonly=xt,t.isRef=Kt,t.isShallow=It,t.markRaw=function(t){return Object.isExtensible(t)&&((t,e,s,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:s})})(t,"__k_skip",!0),t},t.onScopeDispose=function(t){g&&g.cleanups.push(t)},t.pauseScheduling=I,t.pauseTracking=j,t.proxyRefs=function(t){return jt(t)?t:new Proxy(t,Yt)},t.reactive=Et,t.readonly=Ot,t.ref=Nt,t.resetScheduling=P,t.resetTracking=x,t.shallowReactive=function(t){return mt(t,!1,X,vt,St)},t.shallowReadonly=function(t){return mt(t,!0,Z,wt,Lt)},t.shallowRef=function(t){return Dt(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Pt,t.toRef=function(t,e,s){return Kt(t)?t:u(t)?new qt(t):l(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():Ht(t)},t.track=N,t.trigger=D,t.triggerRef=function(t){Vt(t,4)},t.unref=Ht,t}({});
{
"name": "@kdujs/reactivity-canary",
"version": "3.20241202.0-minor.0",
"version": "3.20241202.0",
"description": "@kdujs/reactivity",

@@ -14,2 +14,16 @@ "main": "index.js",

],
"exports": {
".": {
"types": "./dist/reactivity.d.ts",
"node": {
"production": "./dist/reactivity.cjs.prod.js",
"development": "./dist/reactivity.cjs.js",
"default": "./index.js"
},
"module": "./dist/reactivity.esm-bundler.js",
"import": "./dist/reactivity.esm-bundler.js",
"require": "./index.js"
},
"./*": "./*"
},
"sideEffects": false,

@@ -40,4 +54,4 @@ "repository": {

"dependencies": {
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20241202.0-minor.0"
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20241202.0"
}
}

@@ -7,4 +7,14 @@ # @kdujs/reactivity

For full exposed APIs, see `src/index.ts`.
## Credits
The implementation of this module is inspired by the following prior art in the JavaScript ecosystem:
- [Meteor Tracker](https://docs.meteor.com/api/tracker.html)
- [nx-js/observer-util](https://github.com/nx-js/observer-util)
- [salesforce/observable-membrane](https://github.com/salesforce/observable-membrane)
## Caveats
- Built-in objects are not observed except for `Array`, `Map`, `WeakMap`, `Set` and `WeakSet`.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc