@novely/core 0.47.0 → 0.47.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.
package/dist/index.js CHANGED
@@ -490,7 +490,7 @@ var createQueueProcessor = (queue, options) => {
490
490
  const characters = /* @__PURE__ */ new Set();
491
491
  const audio2 = {
492
492
  music: /* @__PURE__ */ new Set(),
493
- sound: /* @__PURE__ */ new Set()
493
+ sounds: /* @__PURE__ */ new Set()
494
494
  };
495
495
  const next = (i) => queue.slice(i + 1);
496
496
  for (const [i, item] of queue.entries()) {
@@ -519,23 +519,35 @@ var createQueueProcessor = (queue, options) => {
519
519
  }
520
520
  }
521
521
  processedQueue.push(item);
522
- } else if (action === "showCharacter" || action === "playSound" || action === "playMusic" || action === "voice") {
522
+ } else if (action === "playSound") {
523
+ const closing = getOppositeAction(action);
524
+ const skip = next(i).some((item2) => {
525
+ if (isUserRequiredAction(item2) || isSkippedDuringRestore(item2[0])) {
526
+ return true;
527
+ }
528
+ const [_action, target] = item2;
529
+ if (target !== params[0]) {
530
+ return false;
531
+ }
532
+ return _action === closing || _action === action;
533
+ });
534
+ if (skip) continue;
535
+ audio2.sounds.add(unwrapAsset(params[0]));
536
+ processedQueue.push(item);
537
+ } else if (action === "showCharacter" || action === "playMusic" || action === "voice") {
523
538
  const closing = getOppositeAction(action);
524
539
  const skip = next(i).some(([_action, target]) => {
525
540
  if (target !== params[0] && action !== "voice") {
526
541
  return false;
527
542
  }
528
- const musicGonnaBePaused = action === "playMusic" && _action === "pauseMusic";
529
- const soundGonnaBePaused = action === "playSound" && _action === "pauseSound";
530
- return musicGonnaBePaused || soundGonnaBePaused || _action === closing || _action === action;
543
+ const musicWillBePaused = action === "playMusic" && _action === "pauseMusic";
544
+ return musicWillBePaused || _action === closing || _action === action;
531
545
  });
532
546
  if (skip) continue;
533
547
  if (action === "showCharacter") {
534
548
  characters.add(params[0]);
535
549
  } else if (action === "playMusic") {
536
550
  audio2.music.add(unwrapAsset(params[0]));
537
- } else if (action === "playSound") {
538
- audio2.sound.add(unwrapAsset(params[0]));
539
551
  }
540
552
  processedQueue.push(item);
541
553
  } else if (action === "showBackground" || action === "preload") {
@@ -2392,18 +2404,28 @@ var asset = (...variants) => {
2392
2404
  return assetPrivate(variants);
2393
2405
  };
2394
2406
  asset.image = (source) => {
2395
- return {
2407
+ if (assetPrivate.cache.has(source)) {
2408
+ return assetPrivate.cache.get(source);
2409
+ }
2410
+ const asset2 = {
2396
2411
  type: "image",
2397
2412
  source,
2398
2413
  id: generateRandomId()
2399
2414
  };
2415
+ assetPrivate.cache.set(source, asset2);
2416
+ return asset2;
2400
2417
  };
2401
2418
  asset.audio = (source) => {
2402
- return {
2419
+ if (assetPrivate.cache.has(source)) {
2420
+ return assetPrivate.cache.get(source);
2421
+ }
2422
+ const asset2 = {
2403
2423
  type: "audio",
2404
2424
  source,
2405
2425
  id: generateRandomId()
2406
2426
  };
2427
+ assetPrivate.cache.set(source, asset2);
2428
+ return asset2;
2407
2429
  };
2408
2430
  export {
2409
2431
  EN,