aoye 0.0.46 → 0.0.48
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/dist/aoye.cjs.js +38 -8
- package/dist/aoye.cjs.js.map +1 -1
- package/dist/aoye.esm.js +36 -9
- package/dist/aoye.esm.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.umd.js +38 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/aoye.esm.js
CHANGED
|
@@ -23,6 +23,12 @@ let ScheduleType = function (ScheduleType) {
|
|
|
23
23
|
ScheduleType[ScheduleType["Post"] = 8] = "Post";
|
|
24
24
|
return ScheduleType;
|
|
25
25
|
}({});
|
|
26
|
+
const EffectStrType2Enum = {
|
|
27
|
+
sync: ScheduleType.Sync,
|
|
28
|
+
pre: ScheduleType.Pre,
|
|
29
|
+
render: ScheduleType.Render,
|
|
30
|
+
post: ScheduleType.Post
|
|
31
|
+
};
|
|
26
32
|
let ScheduleStatus = function (ScheduleStatus) {
|
|
27
33
|
ScheduleStatus[ScheduleStatus["Idle"] = 0] = "Idle";
|
|
28
34
|
ScheduleStatus[ScheduleStatus["Ready"] = 1] = "Ready";
|
|
@@ -709,6 +715,19 @@ class Scope {
|
|
|
709
715
|
}
|
|
710
716
|
}
|
|
711
717
|
}
|
|
718
|
+
class NoopEffect {
|
|
719
|
+
constructor(callback) {
|
|
720
|
+
this.callback = callback;
|
|
721
|
+
const scope = new Scope(callback);
|
|
722
|
+
scope.get();
|
|
723
|
+
return scope;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
const noopEffect = callback => {
|
|
727
|
+
const scope = new Scope(callback);
|
|
728
|
+
scope.get();
|
|
729
|
+
return scope;
|
|
730
|
+
};
|
|
712
731
|
Scope.prototype.dispose = dispose;
|
|
713
732
|
|
|
714
733
|
const rawToProxy = new WeakMap();
|
|
@@ -1254,14 +1273,16 @@ function $(data) {
|
|
|
1254
1273
|
};
|
|
1255
1274
|
}
|
|
1256
1275
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1276
|
+
const DefaultCustomEffectOpt = {
|
|
1277
|
+
immediate: true,
|
|
1278
|
+
type: 'sync'
|
|
1279
|
+
};
|
|
1260
1280
|
function effectUt(callback, depOrOpt, opt) {
|
|
1261
1281
|
const hasDep = Array.isArray(depOrOpt);
|
|
1262
1282
|
opt = hasDep ? opt || {} : depOrOpt || {};
|
|
1283
|
+
const scheduleType = EffectStrType2Enum[opt.type];
|
|
1263
1284
|
if (!hasDep) {
|
|
1264
|
-
const ef = new Effect(callback,
|
|
1285
|
+
const ef = new Effect(callback, scheduleType);
|
|
1265
1286
|
const run = ef.dispose.bind(ef);
|
|
1266
1287
|
run.ins = ef;
|
|
1267
1288
|
return run;
|
|
@@ -1287,7 +1308,7 @@ function effectUt(callback, depOrOpt, opt) {
|
|
|
1287
1308
|
eff.state &= -257;
|
|
1288
1309
|
}
|
|
1289
1310
|
mounted = true;
|
|
1290
|
-
},
|
|
1311
|
+
}, scheduleType);
|
|
1291
1312
|
const run = ef.dispose.bind(ef);
|
|
1292
1313
|
run.ins = ef;
|
|
1293
1314
|
return run;
|
|
@@ -1295,8 +1316,13 @@ function effectUt(callback, depOrOpt, opt) {
|
|
|
1295
1316
|
function effect(callback, depOrOpt, opt) {
|
|
1296
1317
|
const hasDep = Array.isArray(depOrOpt);
|
|
1297
1318
|
opt = hasDep ? opt || {} : depOrOpt || {};
|
|
1319
|
+
opt = {
|
|
1320
|
+
...DefaultCustomEffectOpt,
|
|
1321
|
+
...opt
|
|
1322
|
+
};
|
|
1323
|
+
const scheduleType = EffectStrType2Enum[opt.type];
|
|
1298
1324
|
if (!hasDep) {
|
|
1299
|
-
const ef = new Effect(callback,
|
|
1325
|
+
const ef = new Effect(callback, scheduleType);
|
|
1300
1326
|
return ef;
|
|
1301
1327
|
}
|
|
1302
1328
|
let mounted = false;
|
|
@@ -1310,7 +1336,8 @@ function effect(callback, depOrOpt, opt) {
|
|
|
1310
1336
|
}));
|
|
1311
1337
|
const ef = new Effect(eff => {
|
|
1312
1338
|
for (let i = 0; i < deps.length; i++) {
|
|
1313
|
-
const
|
|
1339
|
+
const dep = deps[i];
|
|
1340
|
+
const value = typeof dep === 'function' ? dep() : dep.get();
|
|
1314
1341
|
vs[i].old = vs[i].val;
|
|
1315
1342
|
vs[i].val = value;
|
|
1316
1343
|
}
|
|
@@ -1320,7 +1347,7 @@ function effect(callback, depOrOpt, opt) {
|
|
|
1320
1347
|
eff.state &= -257;
|
|
1321
1348
|
}
|
|
1322
1349
|
mounted = true;
|
|
1323
|
-
},
|
|
1350
|
+
}, scheduleType);
|
|
1324
1351
|
return ef;
|
|
1325
1352
|
}
|
|
1326
1353
|
function scope(...args) {
|
|
@@ -1334,5 +1361,5 @@ function scope(...args) {
|
|
|
1334
1361
|
return run;
|
|
1335
1362
|
}
|
|
1336
1363
|
|
|
1337
|
-
export { $, Computed, Effect, IsStore, Keys, ScheduleStatus, ScheduleType, Scope, Signal, Store, StoreIgnoreKeys, batchEnd, batchStart, clean, deepSignal, effect, effectUt, execId, execIdInc, getPulling, ide, macro, micro, now, runWithPulling, scope, setExecId, setPulling, shareSignal, toRaw };
|
|
1364
|
+
export { $, Computed, Effect, EffectStrType2Enum, IsStore, Keys, NoopEffect, ScheduleStatus, ScheduleType, Scope, Signal, Store, StoreIgnoreKeys, batchEnd, batchStart, clean, deepSignal, effect, effectUt, execId, execIdInc, getPulling, ide, macro, micro, noopEffect, now, runWithPulling, scope, setExecId, setPulling, shareSignal, toRaw };
|
|
1338
1365
|
//# sourceMappingURL=aoye.esm.js.map
|