@cadenza.io/core 3.13.1 → 3.13.3

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/index.mjs CHANGED
@@ -13,7 +13,7 @@ function deepCloneFilter(input, filterOut = () => false) {
13
13
  const currentTarget = key !== void 0 ? target[key] : target;
14
14
  if (
15
15
  // TODO Should probably not be done like this...
16
- key === "__taskInstance" || key === "__routineInstance" || key === "__task" || key === "__routine" || key === "__tasks" || key === "__routines" || key === "__httpServer" || key === "__httpsServer" || key === "__socketServer"
16
+ key === "taskInstance" || key === "routineInstance" || key === "task" || key === "routine" || key === "tasks" || key === "routines" || key === "httpServer" || key === "httpsServer"
17
17
  ) {
18
18
  target[key] = source;
19
19
  continue;
@@ -133,15 +133,15 @@ var SignalBroker = class _SignalBroker {
133
133
  }
134
134
  }));
135
135
  return {
136
- __signals: processedSignals,
136
+ signals: processedSignals,
137
137
  ...ctx
138
138
  };
139
139
  });
140
140
  this.registerSignalTask = Cadenza.createMetaTask(
141
141
  "Register signal",
142
142
  (ctx) => {
143
- const { __signalName } = ctx;
144
- this.signalObservers.get(__signalName).registered = true;
143
+ const { signalName } = ctx;
144
+ this.signalObservers.get(signalName).registered = true;
145
145
  }
146
146
  ).doOn("meta.signal.registered");
147
147
  }
@@ -407,7 +407,7 @@ var SignalBroker = class _SignalBroker {
407
407
  return;
408
408
  }
409
409
  }
410
- this.emit("meta.signal_broker.added", { __signalName: _signal });
410
+ this.emit("meta.signal_broker.added", { signalName: _signal });
411
411
  }
412
412
  }
413
413
  /**
@@ -1825,7 +1825,7 @@ var GraphRoutine = class extends SignalEmitter {
1825
1825
  description: this.description,
1826
1826
  isMeta: this.isMeta
1827
1827
  },
1828
- __routineInstance: this
1828
+ routineInstance: this
1829
1829
  });
1830
1830
  tasks.forEach((t) => {
1831
1831
  this.tasks.add(t);
@@ -2072,7 +2072,7 @@ var Task = class _Task extends SignalEmitter {
2072
2072
  // inputContextSchemaId: this.inputContextSchema,
2073
2073
  // outputContextSchemaId: this.outputContextSchema,
2074
2074
  },
2075
- __taskInstance: this,
2075
+ taskInstance: this,
2076
2076
  __isSubMeta: this.isSubMeta
2077
2077
  });
2078
2078
  }
@@ -2383,6 +2383,7 @@ var Task = class _Task extends SignalEmitter {
2383
2383
  */
2384
2384
  doAfter(...tasks) {
2385
2385
  for (const pred of tasks) {
2386
+ if (!pred) continue;
2386
2387
  if (this.predecessorTasks.has(pred)) continue;
2387
2388
  pred.nextTasks.add(this);
2388
2389
  this.predecessorTasks.add(pred);
@@ -2413,6 +2414,7 @@ var Task = class _Task extends SignalEmitter {
2413
2414
  */
2414
2415
  then(...tasks) {
2415
2416
  for (const next of tasks) {
2417
+ if (!next) continue;
2416
2418
  if (this.nextTasks.has(next)) continue;
2417
2419
  this.nextTasks.add(next);
2418
2420
  next.predecessorTasks.add(this);
@@ -2871,11 +2873,11 @@ var GraphRegistry = class _GraphRegistry {
2871
2873
  this.registerTask = new Task(
2872
2874
  "Register task",
2873
2875
  (context) => {
2874
- const { __taskInstance } = context;
2875
- if (__taskInstance && !this.tasks.has(__taskInstance.name)) {
2876
- this.tasks.set(__taskInstance.name, __taskInstance);
2876
+ const { taskInstance } = context;
2877
+ if (taskInstance && !this.tasks.has(taskInstance.name)) {
2878
+ this.tasks.set(taskInstance.name, taskInstance);
2877
2879
  }
2878
- delete context.__taskInstance;
2880
+ delete context.taskInstance;
2879
2881
  return true;
2880
2882
  },
2881
2883
  "Registers tasks. Seed for meta.taskCreated",
@@ -2914,7 +2916,7 @@ var GraphRegistry = class _GraphRegistry {
2914
2916
  const { __name } = context;
2915
2917
  for (const task of this.tasks.values()) {
2916
2918
  if (task.name === __name) {
2917
- return { ...context, __task: task };
2919
+ return { ...context, task };
2918
2920
  }
2919
2921
  }
2920
2922
  return false;
@@ -2928,13 +2930,13 @@ var GraphRegistry = class _GraphRegistry {
2928
2930
  const layerTasks = Array.from(this.tasks.values()).filter(
2929
2931
  (task) => task.layerIndex === __layerIndex
2930
2932
  );
2931
- return { ...context, __tasks: layerTasks };
2933
+ return { ...context, tasks: layerTasks };
2932
2934
  },
2933
2935
  "Gets tasks by layer index."
2934
2936
  );
2935
2937
  this.getAllTasks = Cadenza.createMetaTask(
2936
2938
  "Get all tasks",
2937
- (context) => ({ ...context, __tasks: Array.from(this.tasks.values()) }),
2939
+ (context) => ({ ...context, tasks: Array.from(this.tasks.values()) }),
2938
2940
  // Use arrow to capture this
2939
2941
  "Gets all tasks."
2940
2942
  );
@@ -2942,7 +2944,7 @@ var GraphRegistry = class _GraphRegistry {
2942
2944
  "Do for each task",
2943
2945
  function* (context) {
2944
2946
  for (const task of this.tasks.values()) {
2945
- yield { ...context, __task: task };
2947
+ yield { ...context, task };
2946
2948
  }
2947
2949
  }.bind(this),
2948
2950
  // Bind to capture this in generator
@@ -2960,11 +2962,11 @@ var GraphRegistry = class _GraphRegistry {
2960
2962
  this.registerRoutine = Cadenza.createMetaTask(
2961
2963
  "Register routine",
2962
2964
  (context) => {
2963
- const { __routineInstance } = context;
2964
- if (__routineInstance && !this.routines.has(__routineInstance.name)) {
2965
- this.routines.set(__routineInstance.name, __routineInstance);
2965
+ const { routineInstance } = context;
2966
+ if (routineInstance && !this.routines.has(routineInstance.name)) {
2967
+ this.routines.set(routineInstance.name, routineInstance);
2966
2968
  }
2967
- delete context.__routineInstance;
2969
+ delete context.routineInstance;
2968
2970
  return true;
2969
2971
  },
2970
2972
  "Registers routine."
@@ -2975,7 +2977,7 @@ var GraphRegistry = class _GraphRegistry {
2975
2977
  const { __name } = context;
2976
2978
  for (const routine of this.routines.values()) {
2977
2979
  if (routine.name === __name) {
2978
- return { ...context, __routine: routine };
2980
+ return { ...context, routine };
2979
2981
  }
2980
2982
  }
2981
2983
  return false;
@@ -2986,7 +2988,7 @@ var GraphRegistry = class _GraphRegistry {
2986
2988
  "Get all routines",
2987
2989
  (context) => ({
2988
2990
  ...context,
2989
- __routines: Array.from(this.routines.values())
2991
+ routines: Array.from(this.routines.values())
2990
2992
  }),
2991
2993
  // Use arrow to capture this
2992
2994
  "Gets all routines."
@@ -2995,7 +2997,7 @@ var GraphRegistry = class _GraphRegistry {
2995
2997
  "Do for each routine",
2996
2998
  function* (context) {
2997
2999
  for (const routine of this.routines.values()) {
2998
- yield { ...context, __routine: routine };
3000
+ yield { ...context, routine };
2999
3001
  }
3000
3002
  }.bind(this),
3001
3003
  "Yields each routine."
@@ -3202,10 +3204,10 @@ var GraphRunner = class extends SignalEmitter {
3202
3204
  }
3203
3205
  // TODO This should not live here. This is deputy related.
3204
3206
  startRun(context, emit) {
3205
- if (context.__task || context.__routine) {
3206
- const routine = context.__task ?? context.__routine;
3207
- delete context.__task;
3208
- delete context.__routine;
3207
+ if (context.task || context.routine) {
3208
+ const routine = context.task ?? context.routine;
3209
+ delete context.task;
3210
+ delete context.routine;
3209
3211
  context.__routineExecId = context.__metadata?.__deputyExecId ?? null;
3210
3212
  context.__isDeputy = true;
3211
3213
  this.run(routine, context);