narrat 2.14.0 → 2.14.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.
@@ -177,7 +177,7 @@ Found in store "${C.$id}".`),p&&o&&n.hydrate&&n.hydrate(C.$state,p),u=!0,f=!0,C}
177
177
  app.use(pinia)
178
178
  This will fail in production.`);s=Nf,s._s.has(r)||(o?cb(r,e,i,s):n7(r,i,s),process.env.NODE_ENV!=="production"&&(a._pinia=s));const f=s._s.get(r);if(process.env.NODE_ENV!=="production"&&l){const c="__hot:"+r,d=o?cb(c,e,i,s,!0):n7(c,jo({},i),s,!0);l._hotUpdate(d),delete s.state.value[c],s._s.delete(c)}if(process.env.NODE_ENV!=="production"&&sm&&u&&u.proxy&&!l){const c=u.proxy,d="_pStores"in c?c._pStores:c._pStores={};d[r]=f}return f}return a.$id=r,a}function Ls(t,e){return Array.isArray(e)?e.reduce((n,r)=>(n[r]=function(){return t(this.$pinia)[r]},n),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const i=t(this.$pinia),o=e[r];return typeof o=="function"?o.call(this,i):i[o]},n),{})}const r7=["music","ambiant","sound"],i7=wZ(r7),Hr=qr("audio",{state:()=>{const t=new Map;for(const e in i7)t.set(e,{channels:[],options:{volume:1}});return{modes:t,masterVolume:1}},actions:{stopAll(){this.modes.forEach(t=>{t.channels.forEach((e,n)=>{e&&(this.actuallyStopChannel(e),t.channels[n]=null)})})},async stopChannel(t,e){const n=this.getAudioChannel(t,e);if(!!n){if(this.setAudioChannel(t,e,null),Ma().options.musicFadeOutTime){const r=Al(n.audio);r&&r.fade(r.volume(n.howlerId),0,Ma().options.musicFadeOutTime*1e3,n.howlerId),await xo(Ma().options.musicFadeOutTime*1e3)}this.actuallyStopChannel(n)}},async pauseChannel(t,e){const n=this.getAudioChannel(t,e);if(!n)return;const r=Al(n.audio);if(!r){qt(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(t,e,n){if(Ya.Howler.ctx.state==="suspended"){console.warn("Audio context not started yet, skipping audio");return}const r=this.getAudioChannel(t,n);if(t==="sound")return this.actuallyPlayChannel(t,n,e);r&&r.audio!==e?await this.changeChannel(t,e,n):r&&r.audio===e?await this.resumeChannel(t,n):await this.actuallyPlayChannel(t,n,e)},async resumeChannel(t,e){const n=this.getAudioChannel(t,e);if(!n)return;const r=Al(n.audio);if(!r){qt(`Could not find audio ${n.audio}`);return}r.play(n.howlerId)},async changeChannel(t,e,n){this.getAudioChannel(t,n)&&t!=="sound"&&await this.stopChannel(t,n),await this.actuallyPlayChannel(t,n,e)},actuallyStopChannel(t){XZ(t.audio,t.howlerId)},getAudioChannel(t,e){return this.modes.get(t).channels[e]||null},setAudioChannel(t,e,n){this.modes.get(t).channels[e]=n},async actuallyPlayChannel(t,e,n){const r=Al(n);if(!r){qt(`Could not find audio ${n}`);return}if(t!=="sound"){const i=r.play();r.volume(0,i),r.pause(i),this.setAudioChannel(t,e,{audio:n,howlerId:i}),await xo(Ma().options.musicFadeInDelay*1e3);const o=this.getAudioChannel(t,e);o!==null&&o.audio===n&&(r.play(i),r.fade(0,this.modeVolume(t)*r.volume(),Ma().options.musicFadeInTime*1e3,i))}else if(t==="sound"){const i=r.play();r.volume(this.modeVolume(t)*r.volume(),i),this.setAudioChannel(t,e,{audio:n,howlerId:i})}},reloadAudio(t){for(const e in t.modes){if(e==="sound")continue;const n=e;this.modes.get(n).options=Dr(t.modes[n].options);for(const r in t.modes[n].channels){const i=t.modes[n].channels[r];i&&i.audio&&this.actuallyPlayChannel(n,Number(r),i.audio)}}},stopSound(t){const e=Al(t);e&&e.stop()},generateSaveData(){const t={};for(const e in i7){const n=this.modes.get(e);t[e]={options:Dr(n.options),channels:Dr(n.channels).map(r=>r?{audio:r.audio}:{audio:null})}}return{modes:t,masterVolume:this.masterVolume}},loadSaveData(t){this.masterVolume=t.masterVolume},reset(){this.stopAll()},setModeVolume(t,e){const n=this.modes.get(t);n.options.volume=e;for(const r in n.channels){const i=n.channels[r];if(i){const o=Al(i.audio);o&&o.volume(this.modeVolume(t),i.howlerId)}}},setMasterVolume(t){this.masterVolume=t,Ya.Howler.volume(t)},modeVolume(t){return this.masterVolume*this.modes.get(t).options.volume}}}),o7={};Ya.Howler.volume(.5);let fb={};async function QZ(t){ea.log("Loading audio");const e=[];Ya.Howler.volume(t.options.volume);for(const n in t.files){const r=t.files[n];r.src||(r.src=r.path,r.path||console.error(`Audio config for ${n} doesn't have any \`src\` value to find the file`),console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!")),e.push(YZ(n,t.files[n]))}return t.audioTriggers&&(fb=t.audioTriggers),Promise.all(e)}function Tl(t){fb[t]&&Hr().playChannel("sound",fb[t],0)}async function YZ(t,e){return new Promise((n,r)=>{ea.log(`Loading audio ${e.src}`);const i=new Ya.Howl({...e,src:Eo(e.src)});i.load(),o7[t]=i,n()})}function XZ(t,e){const n=Al(t);if(!n){Pl(`Could not find music ${t}`);return}n.stop(e)}function Al(t){return o7[t]}const qu={};async function ZZ(t){return qu[t]?qu[t]:a7(t,t)}async function eee(t){ea.log("Loading images");let e=0,n=0;const r=[],i=async(a,s)=>{n++;const l=await a7(a,s);return e++,console.log(`Loaded ${e} / ${n} images`),l},o=(a,s)=>{r.push(i(a,s))};for(const a in t.images){const s=t.images[a];o(a,s)}for(const a in t.screens.screens){const s=t.screens.screens[a];if(s.background&&!t.images[s.background]&&o(s.background,s.background),s.buttons)for(const l in s.buttons){const u=s.buttons[l];typeof u=="object"&&u.background&&!t.images[u.background]&&o(u.background,u.background)}}return Promise.all(r)}async function a7(t,e){if(qu[t])return qu[t];const n=new Promise((r,i)=>{ea.log(`Loading image ${t} at ${e}`);const o=new Image;o.onload=()=>{qu[t]=o,ea.log(`Loaded image ${t} successfully`),r(o)},o.onerror=a=>{qt(`Failed to load image ${t} at ${e}`,a),i(a)},o.src=Eo(e)});return qu[t]=n,n}function Hu(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const db="1.5.0";function hb(){return`NARRAT_SAVE_${pt().saveFileName}`}const tee="gameSave";let Or;function Za(){if(Or)return Or;if(!Or){let t=null;try{let e=localStorage.getItem(hb());e||(e=localStorage.getItem(tee)),e&&(localStorage.setItem(`${hb()}_BACKUP`,e),t=JSON.parse(e)),t&&typeof t=="object"&&t.slots&&t.slots[0]&&t.slots[0].id||(t=null,localStorage.clear())}catch(e){Pl(`Save file deleted because it was either broken or an outdated format: ${e}`)}t?Or=t:Or=l7()}return ree(Or),u7(Or),Lf(),Or}function nee(){Or=l7(),Lf()}function s7(){return{achievements:{achievements:{}},data:{}}}function ree(t){t.version==="1.4.0"&&(t.globalSave=s7(),t.version=db)}function l7(){const t={version:db,slots:[],globalSave:s7()};return u7(t),t}function u7(t){var n;const e=(n=pt().saves.slots)!=null?n:10;t.slots.length<1&&(t.slots[0]={slotType:"auto",id:Hu(),saveData:null,slotNumber:0}),t.slots[0].slotType="auto";for(let r=1;r<e+1;r++)t.slots.length<=r&&(t.slots[r]={slotNumber:r,slotType:pt().saves.mode==="manual"?"manual":"auto",id:Hu(),saveData:null})}function c7(t,e,n){const r=aee(n);if(Or.slots[r])Or.slots[r].saveData=t;else{qt(`Tried to save to slot ${n} but it doesn't exist`);return}Or.globalSave=e,Lf()}function iee(t){Or.lastSaveSlot=t}function Lf(){localStorage.setItem(hb(),JSON.stringify(Or))}function oee(){const t=Or.slots.find(e=>!e.saveData);return t?t.id:!1}function aee(t){return Or.slots.findIndex(e=>e.id===t)}function Rf(t){return Or.slots.find(e=>e.id===t)}function pb(){return Or.slots.find(t=>t.slotType==="auto")}function see(t){const e=Or.slots.findIndex(n=>n.id===t);Or.slots[e].saveData=null,Lf()}function lee(t,e){const n=Rf(t);n&&n.saveData&&(n.saveData.metadata.name=e),Lf()}function uee(){return{saveDate:new Date().toISOString(),name:"New Save"}}const dm=qr("tooltips",{state:()=>({tooltip:null}),actions:{addCustomTooltip(t){t.title&&(t.title=es(t.title)),t.text=es(t.text),this.tooltip=t},addTooltip(t,e){var r,i;const n=sR(t);n&&this.addCustomTooltip({title:n.title,text:n.description,x:(r=e==null?void 0:e.x)!=null?r:window.screenX,y:(i=e==null?void 0:e.y)!=null?i:window.screenY,width:od().options.width})},deleteTooltip(){this.tooltip=null}}});function mb(){return window}function cee(t){const e=od().options.keywordsPrefix,n=new RegExp(`${e}(\\w*)`,"gi");return t=t.replace(n,fee),t}mb().onTooltipEnter=(t,e)=>{const n={x:t.clientX,y:t.clientY-20};dm().addTooltip(e,n)},mb().onTooltipLeave=()=>{dm().deleteTooltip()};function fee(t,e){const n=e.toLowerCase();return sR(n)?`<span class='highlighted-tooltip-keyword'
179
179
  onmouseenter="onTooltipEnter(event, '${n}')"
180
- onmouseleave="onTooltipLeave()">${e}</span>`:n}function es(t){const e=t.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return f7(r)});return cee(e)}function f7(t){const e=ac(),[n,r]=Jm(e,t);return n[r]}const d7=/\$\$"/,dee=t=>typeof t=="string"&&t.search(d7)===0;function hee(t){let e=null;const n=[],r=/<[^>]*>/g;do e=r.exec(t),e&&n.push(e);while(e);return n}const Fn=qr("dialog",{state:()=>({dialog:[],playMode:"normal"}),actions:{generateSaveData(){return{dialog:Dr(this.dialog)}},loadSaveData(t){this.dialog=t.dialog},addDialog(t){var e;this.dialog.push({...t,interactive:(e=t.interactive)!=null?e:!1,id:Hu(),text:es(t.text)}),this.dialog.length>200&&this.dialog.shift()},toggleAutoPlay(){this.playMode=this.playMode==="auto"?"normal":"auto"},toggleSkip(){this.playMode=this.playMode==="skip"?"normal":"skip"},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[],this.playMode="normal"}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function pee(t,e){return t-e*$o().skillChecks.skillMultiplier}function h7(t,e){const n=pee(t,e),r=$o().skillChecks;let i=!1,o=0,a=r.difficultyText[0][1];for(;!i;)r.difficultyText.length>o&&n>=r.difficultyText[o][0]?a=r.difficultyText[o][1]:i=!0,o++;return a}function mee({skill:t,skillCheckId:e,value:n}){const r=_r(),i=r.getSkillCheck(e),o=Lk(t),a=r.skills[t].level,s=h7(n,a);let l=!0,u=`<span class='skill-check'>[<span class='skill-check-name'>${o.name}</span> - `;return i.happened?i.succeeded?u="":(l=!1,u+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):u+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:u,allowed:l}}function vee(t,e){const n=_r(),r=Lk(e.skill),i=h7(e.value,n.skills[e.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${i}</span> - ${t?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function gee(t){const{skillChecks:e}=$o(),n=_r(),r=Math.floor(Math.random()*e.rollRange),i=n.skills[t].level*e.skillMultiplier,o=r+i;return ea.log(`[SKILL CHECK] Roll: ${o}. (Base roll: ${r}, modifier: ${i} - Skill level: ${n.skills[t].level})`),{roll:o,unmodifiedRoll:r}}function yee(t){const{skills:e,skillChecks:n}=$o();let r=!0;const{roll:i}=gee(t.skill);i<=n.failureChance-1&&(r=!1);const o=e[t.skill];return i<t.value&&(r=!1),ea.log(`[SKILL CHECK ${o.name}]: ${r?"\u2705":"\u274C"}`,`(${t.id}) - ${i}/${t.value}`),Tl(r?"onSkillCheckSuccess":"onSkillCheckFailure"),r}function p7(t){const e=_r(),n=e.getSkillCheck(t.id);if(n&&n.happened&&(n.succeeded||!t.repeatable))return n;const r=yee(t);return g7(vee(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function bee(t,e=[]){const n=t.options,r=t.staticOptions,i=!!n.condition;if(i)return r.success;if(!i){for(const[o,a]of r.elseifs.entries())if(e[o]===!0)return a.branch}if(!i&&r.failure)return r.failure}function m7(t){return typeof t=="object"}function v7(t){return typeof t=="string"&&t.search(/\$/)===0}function g7(t){const e={speaker:"game",text:t,interactive:!1};Fn().addDialog(e)}async function vb(t){Fn().addDialog(t)}function kee(t,e){if(e<t.length)return t[e]}const hm="###_--_~=:;_JUMP",gb="###_--_~=:;_RETURN",wee="###_--_~=:;_OK",pm="###_--_~=:;_STOP";function _ee(t){return t===hm||t===gb||t===wee||t===pm}const xee="2.14.0",jee=new Date("2023-06-11T10:34:35.665Z"),See=400,yb=20;/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function y7(t){return typeof t>"u"||t===null}function Cee(t){return typeof t=="object"&&t!==null}function $ee(t){return Array.isArray(t)?t:y7(t)?[]:[t]}function Eee(t,e){var n,r,i,o;if(e)for(o=Object.keys(e),n=0,r=o.length;n<r;n+=1)i=o[n],t[i]=e[i];return t}function Oee(t,e){var n="",r;for(r=0;r<e;r+=1)n+=t;return n}function Tee(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var Aee=y7,Mee=Cee,Pee=$ee,Nee=Oee,Iee=Tee,Dee=Eee,Nr={isNothing:Aee,isObject:Mee,toArray:Pee,repeat:Nee,isNegativeZero:Iee,extend:Dee};function b7(t,e){var n="",r=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(n+='in "'+t.mark.name+'" '),n+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!e&&t.mark.snippet&&(n+=`
180
+ onmouseleave="onTooltipLeave()">${e}</span>`:n}function es(t){const e=t.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return f7(r)});return cee(e)}function f7(t){const e=ac(),[n,r]=Jm(e,t);return n[r]}const d7=/\$\$"/,dee=t=>typeof t=="string"&&t.search(d7)===0;function hee(t){let e=null;const n=[],r=/<[^>]*>/g;do e=r.exec(t),e&&n.push(e);while(e);return n}const Fn=qr("dialog",{state:()=>({dialog:[],playMode:"normal"}),actions:{generateSaveData(){return{dialog:Dr(this.dialog)}},loadSaveData(t){this.dialog=t.dialog},addDialog(t){var e;this.dialog.push({...t,interactive:(e=t.interactive)!=null?e:!1,id:Hu(),text:es(t.text)}),this.dialog.length>200&&this.dialog.shift()},toggleAutoPlay(){this.playMode=this.playMode==="auto"?"normal":"auto"},toggleSkip(){this.playMode=this.playMode==="skip"?"normal":"skip"},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[],this.playMode="normal"}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function pee(t,e){return t-e*$o().skillChecks.skillMultiplier}function h7(t,e){const n=pee(t,e),r=$o().skillChecks;let i=!1,o=0,a=r.difficultyText[0][1];for(;!i;)r.difficultyText.length>o&&n>=r.difficultyText[o][0]?a=r.difficultyText[o][1]:i=!0,o++;return a}function mee({skill:t,skillCheckId:e,value:n}){const r=_r(),i=r.getSkillCheck(e),o=Lk(t),a=r.skills[t].level,s=h7(n,a);let l=!0,u=`<span class='skill-check'>[<span class='skill-check-name'>${o.name}</span> - `;return i.happened?i.succeeded?u="":(l=!1,u+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):u+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:u,allowed:l}}function vee(t,e){const n=_r(),r=Lk(e.skill),i=h7(e.value,n.skills[e.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${i}</span> - ${t?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function gee(t){const{skillChecks:e}=$o(),n=_r(),r=Math.floor(Math.random()*e.rollRange),i=n.skills[t].level*e.skillMultiplier,o=r+i;return ea.log(`[SKILL CHECK] Roll: ${o}. (Base roll: ${r}, modifier: ${i} - Skill level: ${n.skills[t].level})`),{roll:o,unmodifiedRoll:r}}function yee(t){const{skills:e,skillChecks:n}=$o();let r=!0;const{roll:i}=gee(t.skill);i<=n.failureChance-1&&(r=!1);const o=e[t.skill];return i<t.value&&(r=!1),ea.log(`[SKILL CHECK ${o.name}]: ${r?"\u2705":"\u274C"}`,`(${t.id}) - ${i}/${t.value}`),Tl(r?"onSkillCheckSuccess":"onSkillCheckFailure"),r}function p7(t){const e=_r(),n=e.getSkillCheck(t.id);if(n&&n.happened&&(n.succeeded||!t.repeatable))return n;const r=yee(t);return g7(vee(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function bee(t,e=[]){const n=t.options,r=t.staticOptions,i=!!n.condition;if(i)return r.success;if(!i){for(const[o,a]of r.elseifs.entries())if(e[o]===!0)return a.branch}if(!i&&r.failure)return r.failure}function m7(t){return typeof t=="object"}function v7(t){return typeof t=="string"&&t.search(/\$/)===0}function g7(t){const e={speaker:"game",text:t,interactive:!1};Fn().addDialog(e)}async function vb(t){Fn().addDialog(t)}function kee(t,e){if(e<t.length)return t[e]}const hm="###_--_~=:;_JUMP",gb="###_--_~=:;_RETURN",wee="###_--_~=:;_OK",pm="###_--_~=:;_STOP";function _ee(t){return t===hm||t===gb||t===wee||t===pm}const xee="2.14.2",jee=new Date("2023-06-11T14:33:17.717Z"),See=400,yb=20;/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function y7(t){return typeof t>"u"||t===null}function Cee(t){return typeof t=="object"&&t!==null}function $ee(t){return Array.isArray(t)?t:y7(t)?[]:[t]}function Eee(t,e){var n,r,i,o;if(e)for(o=Object.keys(e),n=0,r=o.length;n<r;n+=1)i=o[n],t[i]=e[i];return t}function Oee(t,e){var n="",r;for(r=0;r<e;r+=1)n+=t;return n}function Tee(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var Aee=y7,Mee=Cee,Pee=$ee,Nee=Oee,Iee=Tee,Dee=Eee,Nr={isNothing:Aee,isObject:Mee,toArray:Pee,repeat:Nee,isNegativeZero:Iee,extend:Dee};function b7(t,e){var n="",r=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(n+='in "'+t.mark.name+'" '),n+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!e&&t.mark.snippet&&(n+=`
181
181
 
182
182
  `+t.mark.snippet),r+" "+n):r}function Bf(t,e){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=e,this.message=b7(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Bf.prototype=Object.create(Error.prototype),Bf.prototype.constructor=Bf,Bf.prototype.toString=function(e){return this.name+": "+b7(this,e)};var Mi=Bf;function bb(t,e,n,r,i){var o="",a="",s=Math.floor(i/2)-1;return r-e>s&&(o=" ... ",e=r-s+o.length),n-r>s&&(a=" ...",n=r+s-a.length),{str:o+t.slice(e,n).replace(/\t/g,"\u2192")+a,pos:r-e+o.length}}function kb(t,e){return Nr.repeat(" ",e-t.length)+t}function Lee(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),typeof e.indent!="number"&&(e.indent=1),typeof e.linesBefore!="number"&&(e.linesBefore=3),typeof e.linesAfter!="number"&&(e.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],i=[],o,a=-1;o=n.exec(t.buffer);)i.push(o.index),r.push(o.index+o[0].length),t.position<=o.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var s="",l,u,f=Math.min(t.line+e.linesAfter,i.length).toString().length,c=e.maxLength-(e.indent+f+3);for(l=1;l<=e.linesBefore&&!(a-l<0);l++)u=bb(t.buffer,r[a-l],i[a-l],t.position-(r[a]-r[a-l]),c),s=Nr.repeat(" ",e.indent)+kb((t.line-l+1).toString(),f)+" | "+u.str+`
183
183
  `+s;for(u=bb(t.buffer,r[a],i[a],t.position,c),s+=Nr.repeat(" ",e.indent)+kb((t.line+1).toString(),f)+" | "+u.str+`