wevu 0.0.2-alpha.0 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -37
- package/dist/{index-D1r6nN-t.d.cts → index-0dF4y5p6.d.mts} +4 -2
- package/dist/{index-DHBSC7mS.d.mts → index-DVEFI-Uo.d.cts} +4 -2
- package/dist/index.cjs +176 -145
- package/dist/index.d.cts +35 -24
- package/dist/index.d.mts +35 -24
- package/dist/index.mjs +171 -144
- package/dist/{store-BcU7YVhB.mjs → store-2q4qcdBi.mjs} +100 -12
- package/dist/{store-Cmw9vWBT.cjs → store-D0GD8ulz.cjs} +135 -11
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +1 -1
- package/dist/store.d.mts +1 -1
- package/dist/store.mjs +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,85 @@ function nextTick(fn) {
|
|
|
25
25
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
26
26
|
let activeEffect = null;
|
|
27
27
|
const effectStack = [];
|
|
28
|
+
let batchDepth = 0;
|
|
29
|
+
const batchedEffects = /* @__PURE__ */ new Set();
|
|
30
|
+
function startBatch() {
|
|
31
|
+
batchDepth++;
|
|
32
|
+
}
|
|
33
|
+
function endBatch() {
|
|
34
|
+
if (batchDepth === 0) return;
|
|
35
|
+
batchDepth--;
|
|
36
|
+
if (batchDepth === 0) flushBatchedEffects();
|
|
37
|
+
}
|
|
38
|
+
function batch(fn) {
|
|
39
|
+
startBatch();
|
|
40
|
+
try {
|
|
41
|
+
return fn();
|
|
42
|
+
} finally {
|
|
43
|
+
endBatch();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function flushBatchedEffects() {
|
|
47
|
+
while (batchedEffects.size) {
|
|
48
|
+
const effects = Array.from(batchedEffects);
|
|
49
|
+
batchedEffects.clear();
|
|
50
|
+
for (const ef of effects) ef();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let activeEffectScope;
|
|
54
|
+
var EffectScopeImpl = class {
|
|
55
|
+
active = true;
|
|
56
|
+
effects = [];
|
|
57
|
+
cleanups = [];
|
|
58
|
+
parent;
|
|
59
|
+
scopes;
|
|
60
|
+
constructor(detached = false) {
|
|
61
|
+
this.detached = detached;
|
|
62
|
+
if (!detached && activeEffectScope) {
|
|
63
|
+
this.parent = activeEffectScope;
|
|
64
|
+
(activeEffectScope.scopes ||= []).push(this);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
run(fn) {
|
|
68
|
+
if (!this.active) return;
|
|
69
|
+
const prev = activeEffectScope;
|
|
70
|
+
activeEffectScope = this;
|
|
71
|
+
try {
|
|
72
|
+
return fn();
|
|
73
|
+
} finally {
|
|
74
|
+
activeEffectScope = prev;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
stop() {
|
|
78
|
+
if (!this.active) return;
|
|
79
|
+
this.active = false;
|
|
80
|
+
for (const effect$1 of this.effects) stop(effect$1);
|
|
81
|
+
this.effects.length = 0;
|
|
82
|
+
for (const cleanup of this.cleanups) cleanup();
|
|
83
|
+
this.cleanups.length = 0;
|
|
84
|
+
if (this.scopes) {
|
|
85
|
+
for (const scope of this.scopes) scope.stop();
|
|
86
|
+
this.scopes.length = 0;
|
|
87
|
+
}
|
|
88
|
+
if (this.parent?.scopes) {
|
|
89
|
+
const index = this.parent.scopes.indexOf(this);
|
|
90
|
+
if (index >= 0) this.parent.scopes.splice(index, 1);
|
|
91
|
+
}
|
|
92
|
+
this.parent = void 0;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function effectScope(detached = false) {
|
|
96
|
+
return new EffectScopeImpl(detached);
|
|
97
|
+
}
|
|
98
|
+
function getCurrentScope() {
|
|
99
|
+
return activeEffectScope;
|
|
100
|
+
}
|
|
101
|
+
function onScopeDispose(fn) {
|
|
102
|
+
if (activeEffectScope?.active) activeEffectScope.cleanups.push(fn);
|
|
103
|
+
}
|
|
104
|
+
function recordEffectScope(effect$1) {
|
|
105
|
+
if (activeEffectScope?.active) activeEffectScope.effects.push(effect$1);
|
|
106
|
+
}
|
|
28
107
|
function cleanupEffect(effect$1) {
|
|
29
108
|
const { deps } = effect$1;
|
|
30
109
|
for (let i = 0; i < deps.length; i++) deps[i].delete(effect$1);
|
|
@@ -33,26 +112,30 @@ function cleanupEffect(effect$1) {
|
|
|
33
112
|
function createReactiveEffect(fn, options = {}) {
|
|
34
113
|
const effect$1 = function reactiveEffect() {
|
|
35
114
|
if (!effect$1.active) return fn();
|
|
36
|
-
if (
|
|
115
|
+
if (effect$1._running) return fn();
|
|
37
116
|
cleanupEffect(effect$1);
|
|
38
117
|
try {
|
|
118
|
+
effect$1._running = true;
|
|
39
119
|
effectStack.push(effect$1);
|
|
40
120
|
activeEffect = effect$1;
|
|
41
121
|
return fn();
|
|
42
122
|
} finally {
|
|
43
123
|
effectStack.pop();
|
|
44
124
|
activeEffect = effectStack[effectStack.length - 1] ?? null;
|
|
125
|
+
effect$1._running = false;
|
|
45
126
|
}
|
|
46
127
|
};
|
|
47
128
|
effect$1.deps = [];
|
|
48
129
|
effect$1.scheduler = options.scheduler;
|
|
49
130
|
effect$1.onStop = options.onStop;
|
|
50
131
|
effect$1.active = true;
|
|
132
|
+
effect$1._running = false;
|
|
51
133
|
effect$1._fn = fn;
|
|
52
134
|
return effect$1;
|
|
53
135
|
}
|
|
54
136
|
function effect(fn, options = {}) {
|
|
55
137
|
const _effect = createReactiveEffect(fn, options);
|
|
138
|
+
recordEffectScope(_effect);
|
|
56
139
|
if (!options.lazy) _effect();
|
|
57
140
|
return _effect;
|
|
58
141
|
}
|
|
@@ -88,10 +171,7 @@ function trigger(target, key) {
|
|
|
88
171
|
effects.forEach((ef) => {
|
|
89
172
|
if (ef !== activeEffect) effectsToRun.add(ef);
|
|
90
173
|
});
|
|
91
|
-
effectsToRun.forEach(
|
|
92
|
-
if (ef.scheduler) ef.scheduler();
|
|
93
|
-
else ef();
|
|
94
|
-
});
|
|
174
|
+
effectsToRun.forEach(scheduleEffect);
|
|
95
175
|
}
|
|
96
176
|
function trackEffects(dep) {
|
|
97
177
|
if (!activeEffect) return;
|
|
@@ -101,10 +181,18 @@ function trackEffects(dep) {
|
|
|
101
181
|
}
|
|
102
182
|
}
|
|
103
183
|
function triggerEffects(dep) {
|
|
104
|
-
dep.forEach(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
184
|
+
dep.forEach(scheduleEffect);
|
|
185
|
+
}
|
|
186
|
+
function scheduleEffect(ef) {
|
|
187
|
+
if (ef.scheduler) {
|
|
188
|
+
ef.scheduler();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (batchDepth > 0) {
|
|
192
|
+
batchedEffects.add(ef);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
ef();
|
|
108
196
|
}
|
|
109
197
|
|
|
110
198
|
//#endregion
|
|
@@ -366,7 +454,7 @@ var RefImpl = class {
|
|
|
366
454
|
};
|
|
367
455
|
function ref(value) {
|
|
368
456
|
if (isRef(value)) return value;
|
|
369
|
-
return new RefImpl(value);
|
|
457
|
+
return markRaw(new RefImpl(value));
|
|
370
458
|
}
|
|
371
459
|
function unref(value) {
|
|
372
460
|
return isRef(value) ? value.value : value;
|
|
@@ -390,7 +478,7 @@ var CustomRefImpl = class {
|
|
|
390
478
|
}
|
|
391
479
|
};
|
|
392
480
|
function customRef(factory, defaultValue) {
|
|
393
|
-
return new CustomRefImpl(factory, defaultValue);
|
|
481
|
+
return markRaw(new CustomRefImpl(factory, defaultValue));
|
|
394
482
|
}
|
|
395
483
|
|
|
396
484
|
//#endregion
|
|
@@ -636,6 +724,12 @@ function storeToRefs(store) {
|
|
|
636
724
|
}
|
|
637
725
|
|
|
638
726
|
//#endregion
|
|
727
|
+
Object.defineProperty(exports, 'batch', {
|
|
728
|
+
enumerable: true,
|
|
729
|
+
get: function () {
|
|
730
|
+
return batch;
|
|
731
|
+
}
|
|
732
|
+
});
|
|
639
733
|
Object.defineProperty(exports, 'computed', {
|
|
640
734
|
enumerable: true,
|
|
641
735
|
get: function () {
|
|
@@ -666,6 +760,24 @@ Object.defineProperty(exports, 'effect', {
|
|
|
666
760
|
return effect;
|
|
667
761
|
}
|
|
668
762
|
});
|
|
763
|
+
Object.defineProperty(exports, 'effectScope', {
|
|
764
|
+
enumerable: true,
|
|
765
|
+
get: function () {
|
|
766
|
+
return effectScope;
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
Object.defineProperty(exports, 'endBatch', {
|
|
770
|
+
enumerable: true,
|
|
771
|
+
get: function () {
|
|
772
|
+
return endBatch;
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
Object.defineProperty(exports, 'getCurrentScope', {
|
|
776
|
+
enumerable: true,
|
|
777
|
+
get: function () {
|
|
778
|
+
return getCurrentScope;
|
|
779
|
+
}
|
|
780
|
+
});
|
|
669
781
|
Object.defineProperty(exports, 'isObject', {
|
|
670
782
|
enumerable: true,
|
|
671
783
|
get: function () {
|
|
@@ -708,6 +820,12 @@ Object.defineProperty(exports, 'nextTick', {
|
|
|
708
820
|
return nextTick;
|
|
709
821
|
}
|
|
710
822
|
});
|
|
823
|
+
Object.defineProperty(exports, 'onScopeDispose', {
|
|
824
|
+
enumerable: true,
|
|
825
|
+
get: function () {
|
|
826
|
+
return onScopeDispose;
|
|
827
|
+
}
|
|
828
|
+
});
|
|
711
829
|
Object.defineProperty(exports, 'queueJob', {
|
|
712
830
|
enumerable: true,
|
|
713
831
|
get: function () {
|
|
@@ -732,6 +850,12 @@ Object.defineProperty(exports, 'shallowReactive', {
|
|
|
732
850
|
return shallowReactive;
|
|
733
851
|
}
|
|
734
852
|
});
|
|
853
|
+
Object.defineProperty(exports, 'startBatch', {
|
|
854
|
+
enumerable: true,
|
|
855
|
+
get: function () {
|
|
856
|
+
return startBatch;
|
|
857
|
+
}
|
|
858
|
+
});
|
|
735
859
|
Object.defineProperty(exports, 'stop', {
|
|
736
860
|
enumerable: true,
|
|
737
861
|
get: function () {
|
package/dist/store.cjs
CHANGED
package/dist/store.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DefineStoreOptions, c as SubscriptionCallback, i as ActionSubscriber, n as createStore, o as MutationType, r as defineStore, s as StoreManager, t as storeToRefs } from "./index-
|
|
1
|
+
import { a as DefineStoreOptions, c as SubscriptionCallback, i as ActionSubscriber, n as createStore, o as MutationType, r as defineStore, s as StoreManager, t as storeToRefs } from "./index-DVEFI-Uo.cjs";
|
|
2
2
|
export { ActionSubscriber, DefineStoreOptions, MutationType, StoreManager, SubscriptionCallback, createStore, defineStore, storeToRefs };
|
package/dist/store.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DefineStoreOptions, c as SubscriptionCallback, i as ActionSubscriber, n as createStore, o as MutationType, r as defineStore, s as StoreManager, t as storeToRefs } from "./index-
|
|
1
|
+
import { a as DefineStoreOptions, c as SubscriptionCallback, i as ActionSubscriber, n as createStore, o as MutationType, r as defineStore, s as StoreManager, t as storeToRefs } from "./index-0dF4y5p6.mjs";
|
|
2
2
|
export { ActionSubscriber, DefineStoreOptions, MutationType, StoreManager, SubscriptionCallback, createStore, defineStore, storeToRefs };
|
package/dist/store.mjs
CHANGED