aoye 0.0.45 → 0.0.47

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 CHANGED
@@ -25,6 +25,18 @@ let ScheduleType = function (ScheduleType) {
25
25
  ScheduleType[ScheduleType["Post"] = 8] = "Post";
26
26
  return ScheduleType;
27
27
  }({});
28
+ const EffectStrType2Enum = {
29
+ sync: ScheduleType.Sync,
30
+ pre: ScheduleType.Pre,
31
+ render: ScheduleType.Render,
32
+ post: ScheduleType.Post
33
+ };
34
+ let ScheduleStatus = function (ScheduleStatus) {
35
+ ScheduleStatus[ScheduleStatus["Idle"] = 0] = "Idle";
36
+ ScheduleStatus[ScheduleStatus["Ready"] = 1] = "Ready";
37
+ ScheduleStatus[ScheduleStatus["Running"] = 2] = "Running";
38
+ return ScheduleStatus;
39
+ }({});
28
40
 
29
41
  class MultiScheduler {
30
42
  hasTask = 0;
@@ -276,10 +288,14 @@ function flushSyncEffect() {
276
288
  consumeI = -1;
277
289
  produceI = -1;
278
290
  }
291
+ let schedulerStatus = ScheduleStatus.Idle;
279
292
  function flushMicroEffect() {
280
- if (multiScheduler.hasTask) {
293
+ if (schedulerStatus === ScheduleStatus.Idle && multiScheduler.hasTask) {
294
+ schedulerStatus = ScheduleStatus.Ready;
281
295
  micro(() => {
296
+ schedulerStatus = ScheduleStatus.Running;
282
297
  multiScheduler.flushAllTask();
298
+ schedulerStatus = ScheduleStatus.Idle;
283
299
  });
284
300
  }
285
301
  }
@@ -1246,14 +1262,12 @@ function $(data) {
1246
1262
  };
1247
1263
  }
1248
1264
  }
1249
- ({
1250
- type: ScheduleType.Sync
1251
- });
1252
1265
  function effectUt(callback, depOrOpt, opt) {
1253
1266
  const hasDep = Array.isArray(depOrOpt);
1254
1267
  opt = hasDep ? opt || {} : depOrOpt || {};
1268
+ const scheduleType = EffectStrType2Enum[opt.type];
1255
1269
  if (!hasDep) {
1256
- const ef = new Effect(callback, opt.type);
1270
+ const ef = new Effect(callback, scheduleType);
1257
1271
  const run = ef.dispose.bind(ef);
1258
1272
  run.ins = ef;
1259
1273
  return run;
@@ -1279,7 +1293,7 @@ function effectUt(callback, depOrOpt, opt) {
1279
1293
  eff.state &= -257;
1280
1294
  }
1281
1295
  mounted = true;
1282
- }, opt.type);
1296
+ }, scheduleType);
1283
1297
  const run = ef.dispose.bind(ef);
1284
1298
  run.ins = ef;
1285
1299
  return run;
@@ -1287,8 +1301,9 @@ function effectUt(callback, depOrOpt, opt) {
1287
1301
  function effect(callback, depOrOpt, opt) {
1288
1302
  const hasDep = Array.isArray(depOrOpt);
1289
1303
  opt = hasDep ? opt || {} : depOrOpt || {};
1304
+ const scheduleType = EffectStrType2Enum[opt.type];
1290
1305
  if (!hasDep) {
1291
- const ef = new Effect(callback, opt.type);
1306
+ const ef = new Effect(callback, scheduleType);
1292
1307
  return ef;
1293
1308
  }
1294
1309
  let mounted = false;
@@ -1312,7 +1327,7 @@ function effect(callback, depOrOpt, opt) {
1312
1327
  eff.state &= -257;
1313
1328
  }
1314
1329
  mounted = true;
1315
- }, opt.type);
1330
+ }, scheduleType);
1316
1331
  return ef;
1317
1332
  }
1318
1333
  function scope(...args) {
@@ -1329,8 +1344,10 @@ function scope(...args) {
1329
1344
  exports.$ = $;
1330
1345
  exports.Computed = Computed;
1331
1346
  exports.Effect = Effect;
1347
+ exports.EffectStrType2Enum = EffectStrType2Enum;
1332
1348
  exports.IsStore = IsStore;
1333
1349
  exports.Keys = Keys;
1350
+ exports.ScheduleStatus = ScheduleStatus;
1334
1351
  exports.ScheduleType = ScheduleType;
1335
1352
  exports.Scope = Scope;
1336
1353
  exports.Signal = Signal;