narrat 2.12.0-alpha.0 → 2.12.0-alpha.1
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/narrat.es.js +1 -1
- package/dist/narrat.umd.js +1 -1
- package/package.json +1 -1
package/dist/narrat.es.js
CHANGED
|
@@ -38748,7 +38748,7 @@ const ev = "###_--_~=:;_JUMP", pw = "###_--_~=:;_RETURN", _te = "###_--_~=:;_OK"
|
|
|
38748
38748
|
function xte(t) {
|
|
38749
38749
|
return t === ev || t === pw || t === _te || t === tv;
|
|
38750
38750
|
}
|
|
38751
|
-
const jte = "2.12.0-alpha.
|
|
38751
|
+
const jte = "2.12.0-alpha.1", Ste = new Date("2023-04-11T18:01:20.183Z"), Cte = 400, Ay = 20;
|
|
38752
38752
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
38753
38753
|
function PL(t) {
|
|
38754
38754
|
return typeof t > "u" || t === null;
|
package/dist/narrat.umd.js
CHANGED
|
@@ -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?lb(r,e,i,s):t7(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?lb(c,e,i,s,!0):t7(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 Za(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 n7=["music","ambiant","sound"],r7=wZ(n7),Yr=qr("audio",{state:()=>{const t=new Map;for(const e in r7)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=Vu(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=Vu(n.audio);if(!r){Ut(`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.actuallyPlayChannel(t,n,e)},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=Vu(n);if(!r){Ut(`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=Vu(t);e&&e.stop()},generateSaveData(){const t={};for(const e in r7){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=Vu(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}}}),i7={};Ya.Howler.volume(.5);let ub={};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&&(ub=t.audioTriggers),Promise.all(e)}function Tl(t){ub[t]&&Yr().playChannel("sound",ub[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:Qo(e.src)});i.load(),i7[t]=i,n()})}function XZ(t,e){const n=Vu(t);if(!n){Ml(`Could not find music ${t}`);return}n.stop(e)}function Vu(t){return i7[t]}const qu={};async function ZZ(t){return qu[t]?qu[t]:o7(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 o7(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 o7(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=>{Ut(`Failed to load image ${t} at ${e}`,a),i(a)},o.src=Qo(e)});return qu[t]=n,n}function Hu(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const cb="1.5.0";function fb(){return`NARRAT_SAVE_${pt().saveFileName}`}const tee="gameSave";let Or;function es(){if(Or)return Or;if(!Or){let t=null;try{let e=localStorage.getItem(fb());e||(e=localStorage.getItem(tee)),e&&(localStorage.setItem(`${fb()}_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){Ml(`Save file deleted because it was either broken or an outdated format: ${e}`)}t?Or=t:Or=s7()}return ree(Or),l7(Or),Lf(),Or}function nee(){Or=s7(),Lf()}function a7(){return{achievements:{achievements:{}},data:{}}}function ree(t){t.version==="1.4.0"&&(t.globalSave=a7(),t.version=cb)}function s7(){const t={version:cb,slots:[],globalSave:a7()};return l7(t),t}function l7(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 u7(t,e,n){const r=aee(n);if(Or.slots[r])Or.slots[r].saveData=t;else{Ut(`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(fb(),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 db(){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=ts(t.title)),t.text=ts(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 hb(){return window}function cee(t){const e=od().options.keywordsPrefix,n=new RegExp(`${e}(\\w*)`,"gi");return t=t.replace(n,fee),t}hb().onTooltipEnter=(t,e)=>{const n={x:t.clientX,y:t.clientY-20};dm().addTooltip(e,n)},hb().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 ts(t){const e=t.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return c7(r)});return cee(e)}function c7(t){const e=ac(),[n,r]=Gm(e,t);return n[r]}const f7=/\$\$"/,dee=t=>typeof t=="string"&&t.search(f7)===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:ts(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 d7(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=Ik(t),a=r.skills[t].level,s=d7(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=Ik(e.skill),i=d7(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 h7(t){const e=_r(),n=e.getSkillCheck(t.id);if(n&&n.happened&&(n.succeeded||!t.repeatable))return n;const r=yee(t);return v7(vee(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function bee(t){const e=t.options,n=t.staticOptions,r=!!e.condition;if(r)return n.success;if(!r&&n.failure)return n.failure}function p7(t){return typeof t=="object"}function m7(t){return typeof t=="string"&&t.search(/\$/)===0}function v7(t){const e={speaker:"game",text:t,interactive:!1};Fn().addDialog(e)}async function pb(t){Fn().addDialog(t)}function kee(t,e){if(e<t.length)return t[e]}const hm="###_--_~=:;_JUMP",mb="###_--_~=:;_RETURN",wee="###_--_~=:;_OK",pm="###_--_~=:;_STOP";function _ee(t){return t===hm||t===mb||t===wee||t===pm}const xee="2.12.0-alpha.
|
|
180
|
+
onmouseleave="onTooltipLeave()">${e}</span>`:n}function ts(t){const e=t.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return c7(r)});return cee(e)}function c7(t){const e=ac(),[n,r]=Gm(e,t);return n[r]}const f7=/\$\$"/,dee=t=>typeof t=="string"&&t.search(f7)===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:ts(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 d7(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=Ik(t),a=r.skills[t].level,s=d7(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=Ik(e.skill),i=d7(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 h7(t){const e=_r(),n=e.getSkillCheck(t.id);if(n&&n.happened&&(n.succeeded||!t.repeatable))return n;const r=yee(t);return v7(vee(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function bee(t){const e=t.options,n=t.staticOptions,r=!!e.condition;if(r)return n.success;if(!r&&n.failure)return n.failure}function p7(t){return typeof t=="object"}function m7(t){return typeof t=="string"&&t.search(/\$/)===0}function v7(t){const e={speaker:"game",text:t,interactive:!1};Fn().addDialog(e)}async function pb(t){Fn().addDialog(t)}function kee(t,e){if(e<t.length)return t[e]}const hm="###_--_~=:;_JUMP",mb="###_--_~=:;_RETURN",wee="###_--_~=:;_OK",pm="###_--_~=:;_STOP";function _ee(t){return t===hm||t===mb||t===wee||t===pm}const xee="2.12.0-alpha.1",jee=new Date("2023-04-11T18:01:20.183Z"),See=400,vb=20;/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function g7(t){return typeof t>"u"||t===null}function Cee(t){return typeof t=="object"&&t!==null}function $ee(t){return Array.isArray(t)?t:g7(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=g7,Mee=Cee,Pee=$ee,Nee=Oee,Iee=Tee,Dee=Eee,Nr={isNothing:Aee,isObject:Mee,toArray:Pee,repeat:Nee,isNegativeZero:Iee,extend:Dee};function y7(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=y7(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+": "+y7(this,e)};var Mi=Bf;function gb(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 yb(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=gb(t.buffer,r[a-l],i[a-l],t.position-(r[a]-r[a-l]),c),s=Nr.repeat(" ",e.indent)+yb((t.line-l+1).toString(),f)+" | "+u.str+`
|
|
183
183
|
`+s;for(u=gb(t.buffer,r[a],i[a],t.position,c),s+=Nr.repeat(" ",e.indent)+yb((t.line+1).toString(),f)+" | "+u.str+`
|