@novely/core 0.27.0 → 0.27.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.
@@ -521,8 +521,8 @@ var Novely = (() => {
521
521
  }
522
522
  }
523
523
  const run = async (match) => {
524
- for await (const [action, ...params] of processedQueue) {
525
- const result = match(action, params);
524
+ for await (const item of processedQueue) {
525
+ const result = match(item);
526
526
  if (isPromise(result)) {
527
527
  await result;
528
528
  }
@@ -1075,7 +1075,7 @@ var Novely = (() => {
1075
1075
  const { keep, characters: characters2, audio } = processor.keep;
1076
1076
  if (previous) {
1077
1077
  const { queue: prevQueue } = getActionsFromPath(story, previous[0], false);
1078
- for (let i = prevQueue.length - 1; i > queue.length; i--) {
1078
+ for (let i = prevQueue.length - 1; i > queue.length - 1; i--) {
1079
1079
  const element = prevQueue[i];
1080
1080
  if (!isAction(element)) {
1081
1081
  continue;
@@ -1090,9 +1090,15 @@ var Novely = (() => {
1090
1090
  ctx: context,
1091
1091
  data: latest[1]
1092
1092
  });
1093
- await processor.run((action2, props) => {
1093
+ const lastQueueItem = queue.at(-1) || [];
1094
+ const isLastQueueItemRequiresUserAction = isUserRequiredAction(lastQueueItem);
1095
+ await processor.run((item) => {
1094
1096
  if (!latest)
1095
1097
  return;
1098
+ if (isLastQueueItemRequiresUserAction && lastQueueItem === item) {
1099
+ return;
1100
+ }
1101
+ const [action2, ...props] = item;
1096
1102
  return match(action2, props, {
1097
1103
  ctx: context,
1098
1104
  data: latest[1]
@@ -1136,6 +1142,7 @@ var Novely = (() => {
1136
1142
  const stack = useStack(ctx);
1137
1143
  const current = stack.value;
1138
1144
  stack.clear();
1145
+ ctx.clear(EMPTY_SET, EMPTY_SET, { music: EMPTY_SET, sounds: EMPTY_SET }, noop);
1139
1146
  renderer.ui.showScreen("mainmenu");
1140
1147
  ctx.audio.destroy();
1141
1148
  const [time, type] = current[2];
@@ -1164,7 +1171,7 @@ var Novely = (() => {
1164
1171
  const processor = createQueueProcessor(queue, {
1165
1172
  skip: /* @__PURE__ */ new Set()
1166
1173
  });
1167
- await processor.run((action2, props) => {
1174
+ await processor.run(([action2, ...props]) => {
1168
1175
  if (isAudioAction(action2))
1169
1176
  return;
1170
1177
  if (action2 === "vibrate")