narrat 2.2.6 → 2.2.7

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/CHANGELOG.md CHANGED
@@ -40,7 +40,7 @@ Examples:
40
40
  - `wait 2000`
41
41
  - `play music calm 1` will play the music `calm` on channel 1. Because it's a different channel, the musics will superpose
42
42
  - `wait 2000`
43
- - `stop music calm 1` will stop the music `calm` on channel 1.
43
+ - `stop music 1` will stop the music on channel 1.
44
44
  - `play ambiant forest` will play the ambiant sound `forest` on channel 0. This is a different audio mode, so it will be played independently of the musics.
45
45
 
46
46
  Sounds now also use channels, but they ignore all the code related to fading musics in and out, or stopping the previous audio on the channel (because sounds are meant to be a one off and people shouldn't have to bother keeping track of sound channels).
package/dist/narrat.es.js CHANGED
@@ -34410,13 +34410,6 @@ function getQuestConfig(questId) {
34410
34410
  function getObjectiveConfig(quest, objectiveId) {
34411
34411
  return getQuestConfig(quest).objectives[objectiveId];
34412
34412
  }
34413
- const SAVE_FILE = "gameSave";
34414
- const JUMP_SIGNAL = `###_--_~=:;_JUMP`;
34415
- const RETURN_SIGNAL = `###_--_~=:;_RETURN`;
34416
- const OK_SIGNAL = `###_--_~=:;_OK`;
34417
- function isReturnSignal(s2) {
34418
- return s2 === JUMP_SIGNAL || s2 === RETURN_SIGNAL || s2 === OK_SIGNAL;
34419
- }
34420
34413
  var howler = {};
34421
34414
  /*!
34422
34415
  * howler.js v2.2.3
@@ -36374,68 +36367,6 @@ var howler = {};
36374
36367
  };
36375
36368
  })();
36376
36369
  })(howler);
36377
- const audio = {};
36378
- howler.Howler.volume(0.5);
36379
- let audioTriggers = {};
36380
- async function loadAudioAssets(config2) {
36381
- logger$1.log(`Loading audio`);
36382
- const loadingPromises = [];
36383
- howler.Howler.volume(config2.audioOptions.volume);
36384
- for (const key in config2.music) {
36385
- const musicConf = {
36386
- loop: true,
36387
- ...config2.music[key]
36388
- };
36389
- config2.audio[key] = musicConf;
36390
- console.warn(`Music config is deprecated, instead you can now add musics to the \`audio\` config as they behave the same as other sounds!`);
36391
- }
36392
- for (const key in config2.sound) {
36393
- config2.audio[key] = config2.sound[key];
36394
- }
36395
- for (const key in config2.audio) {
36396
- const sound = config2.audio[key];
36397
- if (!sound.src) {
36398
- sound.src = sound.path;
36399
- if (!sound.path) {
36400
- console.error(`Audio config for ${key} doesn't have any \`src\` value to find the file`);
36401
- }
36402
- console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!");
36403
- }
36404
- loadingPromises.push(loadAudio(key, config2.audio[key]));
36405
- }
36406
- if (config2.audioTriggers) {
36407
- audioTriggers = config2.audioTriggers;
36408
- }
36409
- return Promise.all(loadingPromises);
36410
- }
36411
- function audioEvent(event) {
36412
- if (audioTriggers[event]) {
36413
- useAudio().playChannel("sound", audioTriggers[event], 0);
36414
- }
36415
- }
36416
- async function loadAudio(key, config2) {
36417
- return new Promise((resolve, reject) => {
36418
- logger$1.log(`Loading audio ${config2.src}`);
36419
- const sound = new howler.Howl({
36420
- ...config2,
36421
- src: getAssetUrl(config2.src)
36422
- });
36423
- sound.load();
36424
- audio[key] = sound;
36425
- resolve();
36426
- });
36427
- }
36428
- function stopHowlerById(musicKey, howlerId) {
36429
- const audio2 = getAudio(musicKey);
36430
- if (!audio2) {
36431
- error(`Could not find music ${musicKey}`);
36432
- return;
36433
- }
36434
- audio2.stop(howlerId);
36435
- }
36436
- function getAudio(key) {
36437
- return audio[key];
36438
- }
36439
36370
  function timeout(durationMs) {
36440
36371
  return new Promise((resolve, reject) => {
36441
36372
  setTimeout(resolve, durationMs);
@@ -36958,6 +36889,75 @@ const useAudio = defineStore("audio", {
36958
36889
  }
36959
36890
  }
36960
36891
  });
36892
+ const audio = {};
36893
+ howler.Howler.volume(0.5);
36894
+ let audioTriggers = {};
36895
+ async function loadAudioAssets(config2) {
36896
+ logger$1.log(`Loading audio`);
36897
+ const loadingPromises = [];
36898
+ howler.Howler.volume(config2.audioOptions.volume);
36899
+ for (const key in config2.music) {
36900
+ const musicConf = {
36901
+ loop: true,
36902
+ ...config2.music[key]
36903
+ };
36904
+ config2.audio[key] = musicConf;
36905
+ console.warn(`Music config is deprecated, instead you can now add musics to the \`audio\` config as they behave the same as other sounds!`);
36906
+ }
36907
+ for (const key in config2.sound) {
36908
+ config2.audio[key] = config2.sound[key];
36909
+ }
36910
+ for (const key in config2.audio) {
36911
+ const sound = config2.audio[key];
36912
+ if (!sound.src) {
36913
+ sound.src = sound.path;
36914
+ if (!sound.path) {
36915
+ console.error(`Audio config for ${key} doesn't have any \`src\` value to find the file`);
36916
+ }
36917
+ console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!");
36918
+ }
36919
+ loadingPromises.push(loadAudio(key, config2.audio[key]));
36920
+ }
36921
+ if (config2.audioTriggers) {
36922
+ audioTriggers = config2.audioTriggers;
36923
+ }
36924
+ return Promise.all(loadingPromises);
36925
+ }
36926
+ function audioEvent(event) {
36927
+ if (audioTriggers[event]) {
36928
+ useAudio().playChannel("sound", audioTriggers[event], 0);
36929
+ }
36930
+ }
36931
+ async function loadAudio(key, config2) {
36932
+ return new Promise((resolve, reject) => {
36933
+ logger$1.log(`Loading audio ${config2.src}`);
36934
+ const sound = new howler.Howl({
36935
+ ...config2,
36936
+ src: getAssetUrl(config2.src)
36937
+ });
36938
+ sound.load();
36939
+ audio[key] = sound;
36940
+ resolve();
36941
+ });
36942
+ }
36943
+ function stopHowlerById(musicKey, howlerId) {
36944
+ const audio2 = getAudio(musicKey);
36945
+ if (!audio2) {
36946
+ error(`Could not find music ${musicKey}`);
36947
+ return;
36948
+ }
36949
+ audio2.stop(howlerId);
36950
+ }
36951
+ function getAudio(key) {
36952
+ return audio[key];
36953
+ }
36954
+ const SAVE_FILE = "gameSave";
36955
+ const JUMP_SIGNAL = `###_--_~=:;_JUMP`;
36956
+ const RETURN_SIGNAL = `###_--_~=:;_RETURN`;
36957
+ const OK_SIGNAL = `###_--_~=:;_OK`;
36958
+ function isReturnSignal(s2) {
36959
+ return s2 === JUMP_SIGNAL || s2 === RETURN_SIGNAL || s2 === OK_SIGNAL;
36960
+ }
36961
36961
  function isOldSave(save2) {
36962
36962
  if (typeof save2 === "object") {
36963
36963
  const saveTest = save2;
@@ -38611,6 +38611,7 @@ const useMain = defineStore("main", {
38611
38611
  startMachine() {
38612
38612
  const audioStore = useAudio();
38613
38613
  audioStore.stopAll();
38614
+ audioEvent("onPressStart");
38614
38615
  const vmStore = useVM();
38615
38616
  vmStore.start();
38616
38617
  this.ready = true;
@@ -40952,7 +40953,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
40952
40953
  const saveSlot2 = ref(-1);
40953
40954
  const choosingSave = ref(false);
40954
40955
  async function startGame() {
40955
- audioEvent("onPressStart");
40956
40956
  const main2 = useMain();
40957
40957
  if (saveSlot2.value === -1) {
40958
40958
  saveSlot2.value = getFreeSlot();
@@ -40960,7 +40960,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
40960
40960
  await main2.startGame(saveSlot2.value);
40961
40961
  }
40962
40962
  async function loadGame() {
40963
- audioEvent("onPressStart");
40964
40963
  const save2 = getSaveSlot(saveSlot2.value);
40965
40964
  if (!save2) {
40966
40965
  error("No save file found");