@push.rocks/taskbuffer 3.0.15 → 3.1.0

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.
@@ -5926,22 +5926,23 @@ var logger = new dist_ts_exports9.ConsoleLog();
5926
5926
  // ts/taskbuffer.classes.task.ts
5927
5927
  var _Task = class {
5928
5928
  constructor(optionsArg) {
5929
+ // Add a list to store the blocking tasks
5930
+ this.blockingTasks = [];
5929
5931
  this.running = false;
5930
5932
  this.bufferRunner = new BufferRunner(this);
5931
5933
  this.cycleCounter = new CycleCounter(this);
5932
- this.idle = true;
5933
- this._state = "ready";
5934
5934
  this.taskFunction = optionsArg.taskFunction;
5935
5935
  this.preTask = optionsArg.preTask;
5936
5936
  this.afterTask = optionsArg.afterTask;
5937
- this.idle = !this.running;
5938
5937
  this.buffered = optionsArg.buffered;
5939
5938
  this.bufferMax = optionsArg.bufferMax;
5940
5939
  this.execDelay = optionsArg.execDelay;
5941
5940
  this.name = optionsArg.name;
5942
5941
  this.taskSetup = optionsArg.taskSetup;
5942
+ this.finished = new Promise((resolve) => {
5943
+ this.resolveFinished = resolve;
5944
+ });
5943
5945
  }
5944
- // STATIC
5945
5946
  static extractTask(preOrAfterTaskArg) {
5946
5947
  switch (true) {
5947
5948
  case !preOrAfterTaskArg:
@@ -5965,6 +5966,9 @@ var _Task = class {
5965
5966
  }
5966
5967
  return result;
5967
5968
  }
5969
+ get idle() {
5970
+ return !this.running;
5971
+ }
5968
5972
  trigger(x) {
5969
5973
  if (this.buffered) {
5970
5974
  return this.triggerBuffered(x);
@@ -5978,16 +5982,6 @@ var _Task = class {
5978
5982
  triggerBuffered(x) {
5979
5983
  return this.bufferRunner.trigger(x);
5980
5984
  }
5981
- get state() {
5982
- return this._state;
5983
- }
5984
- set state(stateArg) {
5985
- if (stateArg === "locked") {
5986
- this._state = "locked";
5987
- } else {
5988
- logger.log("error", `state type ${stateArg} could not be set`);
5989
- }
5990
- }
5991
5985
  };
5992
5986
  var Task = _Task;
5993
5987
  Task.emptyTaskFunction = function(x) {
@@ -6005,6 +5999,9 @@ Task.isTask = (taskArg) => {
6005
5999
  Task.runTask = async (taskArg, optionsArg) => {
6006
6000
  const taskToRun = _Task.extractTask(taskArg);
6007
6001
  const done = dist_ts_exports.defer();
6002
+ for (const task of taskToRun.blockingTasks) {
6003
+ await task.finished;
6004
+ }
6008
6005
  if (!taskToRun.setupValue && taskToRun.taskSetup) {
6009
6006
  taskToRun.setupValue = await taskToRun.taskSetup();
6010
6007
  }
@@ -6014,6 +6011,10 @@ Task.runTask = async (taskArg, optionsArg) => {
6014
6011
  taskToRun.running = true;
6015
6012
  done.promise.then(async () => {
6016
6013
  taskToRun.running = false;
6014
+ taskToRun.resolveFinished();
6015
+ taskToRun.finished = new Promise((resolve) => {
6016
+ taskToRun.resolveFinished = resolve;
6017
+ });
6017
6018
  });
6018
6019
  const options = {
6019
6020
  ...{ x: void 0, touchedTasksArray: [] },