Comparing version 0.10.9 to 0.10.10
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Vue")):"function"==typeof define&&define.amd?define(["Vue"],t):"object"==typeof exports?exports.Phavuer=t(require("Vue")):e.Phavuer=t(e.Vue)}(this,(e=>(()=>{"use strict";var t={744:(e,t)=>{t.Z=(e,t)=>{const i=e.__vccOpts||e;for(const[e,r]of t)i[e]=r;return i}},740:t=>{t.exports=e}},i={};function r(e){var n=i[e];if(void 0!==n)return n.exports;var o=i[e]={exports:{}};return t[e](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{Body:()=>D,Circle:()=>S,Container:()=>g,Image:()=>Y,InjectionKeys:()=>T,Light:()=>R,Line:()=>O,Rectangle:()=>b,RoundRectangle:()=>w,Scene:()=>p,Sprite:()=>C,StaticBody:()=>F,Text:()=>B,TilemapLayer:()=>P,Zone:()=>E,createPhavuerApp:()=>Z,initGameObject:()=>V,onPostUpdate:()=>Q,onPreUpdate:()=>J,refObj:()=>H,refScene:()=>q,refTo:()=>z,useGame:()=>L,useScene:()=>M});var e=r(740);const t=[{attr:"onPointerdown",emit:"pointerdown",eventIndex:3},{attr:"onPointermove",emit:"pointermove",eventIndex:3},{attr:"onPointerup",emit:"pointerup",eventIndex:3},{attr:"onPointerout",emit:"pointerout",eventIndex:1},{attr:"onPointerover",emit:"pointerover",eventIndex:3},{attr:"onWheel",emit:"wheel",eventIndex:4},{attr:"onDragstart",emit:"dragstart",drag:!0},{attr:"onDrag",emit:"drag",drag:!0},{attr:"onDragend",emit:"dragend",drag:!0},{attr:"onDragenter",emit:"dragenter",drag:!0},{attr:"onDragover",emit:"dragover",drag:!0},{attr:"onDragleave",emit:"dragleave",drag:!0},{attr:"onDrop",emit:"drop",drag:!0}],i=e=>{e.updateDisplayOrigin&&e.updateDisplayOrigin(),e.input?e.input.hitArea.setSize(e.width,e.height):e._events&&t.some((t=>t.emit in e._events))&&e.setInteractive()},o=["tween","tweens","timeline","style"],s={active:e=>t=>e.setActive(t),visible:e=>t=>e.setVisible(t),x:e=>t=>e.x=t,_x:e=>t=>e._x=t,y:e=>t=>e.y=t,_y:e=>t=>e._y=t,x1:e=>t=>e.x1=t,y1:e=>t=>e.y1=t,x2:e=>t=>e.x2=t,y2:e=>t=>e.y2=t,rotation:e=>t=>e.setRotation(t),origin:e=>t=>e.setOrigin(t,t),originX:e=>t=>e.setOrigin(t,e.originY),originY:e=>t=>e.setOrigin(e.originX,t),scale:e=>t=>e.setScale(t,t),scaleX:e=>t=>e.setScale(t,e.scaleY),scaleY:e=>t=>e.setScale(e.scaleX,t),width:e=>t=>{e.setSize(t,e.height),i(e)},height:e=>t=>{e.setSize(e.width,t),i(e)},radius:e=>t=>e.setRadius(t),displayWidth:e=>t=>e.setDisplaySize(t,e.displayHeight),displayHeight:e=>t=>e.setDisplaySize(e.displayWidth,t),displayOriginX:e=>t=>e.setDisplayOrigin(t,e.displayOriginY),displayOriginY:e=>t=>e.setDisplayOrigin(e.displayOriginX,t),dropZone:e=>t=>{t&&(e.input||e.setInteractive(),e.input.dropZone=!0)},flipX:e=>t=>e.setFlipX(t),flipY:e=>t=>e.setFlipY(t),depth:e=>t=>e.setDepth(t),alpha:e=>t=>e.setAlpha(t),blendMode:e=>t=>e.setBlendMode(t),pipeline:e=>t=>e.setPipeline(t),intensity:e=>t=>e.setIntensity(t),tint:e=>t=>e.setTint(t),text:e=>t=>e.setText(t),texture:e=>t=>e.setTexture(t,e.frame&&e.frame.name),frame:e=>t=>e.setFrame(t),color:e=>t=>e.setColor(t),fillColor:e=>t=>e.setFillStyle(t,e.fillAlpha),fillAlpha:e=>t=>e.setFillStyle(e.fillColor,t),lineWidth:e=>(t,i)=>{e.setLineWidth?e.setLineWidth(t,i):e.setStrokeStyle(...t?[t,e.strokeColor,e.strokeAlpha]:[])},strokeColor:e=>t=>e.setStrokeStyle(e.lineWidth,t,e.strokeAlpha),strokeAlpha:e=>t=>e.setStrokeStyle(e.lineWidth,e.strokeColor,t),style:e=>t=>e.setStyle(t),lineSpacing:e=>t=>e.setLineSpacing(t),padding:e=>t=>e.setPadding(t),collision:e=>t=>e.setCollision(t),collisionByProperty:e=>t=>e.setCollisionByProperty(t),enable:e=>t=>e.enable=t,immovable:e=>t=>e.setImmovable(t),moves:e=>t=>e.moves=t,bounceX:e=>t=>e.setBounceX(t),bounceY:e=>t=>e.setBounceY(t),drag:e=>t=>e.setDrag(t),dragX:e=>t=>e.setDragX(t),dragY:e=>t=>e.setDragY(t),gravityX:e=>t=>e.setGravityX(t),gravityY:e=>t=>e.setGravityY(t),frictionX:e=>t=>e.setFrictionX(t),frictionY:e=>t=>e.setFrictionY(t),velocityX:e=>t=>e.setVelocityX(t),velocityY:e=>t=>e.setVelocityY(t),maxVelocityX:e=>t=>e.setMaxVelocityX(t),maxVelocityY:e=>t=>e.setMaxVelocityY(t),accelerationX:e=>t=>e.setAccelerationX(t),accelerationY:e=>t=>e.setAccelerationY(t),offsetX:e=>t=>e.setOffset(t,e.offset.y),offsetY:e=>t=>e.setOffset(e.offset.x,t),tween:e=>t=>{e.tween&&e.tween.stop(),t&&(e.tween=e.scene.add.tween(Object.assign({targets:e},t)))},tweens:e=>t=>{e.tween&&e.tween.stop(),t&&(e.tween=e.scene.tweens.timeline({targets:e,tweens:t}))},timeline:e=>t=>{e.tween&&e.tween.stop(),t&&(e.tween=e.scene.tweens.timeline(Object.assign({targets:e},t)))}},l=(0,e.defineComponent)({emits:["init","create","update","preload"],props:{name:{type:String,required:!0},autoStart:{type:Boolean,default:!0}},setup(t,i){const r=(0,e.ref)(!1),n=[],o=[],s=class extends Phaser.Scene{init(e){i.emit("init",this,e)}create(e){r.value=!0,i.emit("create",this,e)}update(e,t){n.forEach((i=>i(e,t))),i.emit("update",this,e,t),o.forEach((i=>i(e,t)))}preload(){i.emit("preload",this)}},l=(0,e.inject)(T.Game).scene.add(t.name,s,t.autoStart);return l.events.on("shutdown",(()=>r.value=!1)),(0,e.provide)(T.Scene,l),(0,e.provide)(T.PreUpdateEvents,n),(0,e.provide)(T.PostUpdateEvents,o),{scene:l,show:r}}});var a=r(744);const p=(0,a.Z)(l,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[t.show?(0,e.renderSlot)(t.$slots,"default",{key:0}):(0,e.createCommentVNode)("v-if",!0)])}]]),d={active:{type:Boolean},visible:{type:Boolean},x:{type:Number},y:{type:Number},x1:{type:Number},y1:{type:Number},x2:{type:Number},y2:{type:Number},rotation:{type:Number},origin:{type:Number},originX:{type:Number},originY:{type:Number},scale:{type:Number},scaleX:{type:Number},scaleY:{type:Number},width:{type:Number},height:{type:Number},radius:{type:Number},displayWidth:{type:Number},displayHeight:{type:Number},displayOriginX:{type:Number},displayOriginY:{type:Number},dropZone:{type:Boolean},flipX:{type:Boolean},flipY:{type:Boolean},depth:{type:Number},alpha:{type:Number},blendMode:{type:[Number,String]},pipeline:{type:[String,Object]},intensity:{type:Number},tint:{type:Number},text:{type:[String,Number]},texture:{type:String},frame:{type:[Number,String]},color:{type:String},fillColor:{type:Number},fillAlpha:{type:Number},lineWidth:{type:Number},strokeColor:{type:Number},strokeAlpha:{type:Number},style:{type:Object},lineSpacing:{type:Number},padding:{type:[Number,Object]},collision:{type:[Number,Array]},collisionByProperty:{type:Object},enable:{type:Boolean},immovable:{type:Boolean},moves:{type:Boolean},bounceX:{type:Number},bounceY:{type:Number},drag:{type:Number},dragX:{type:Number},dragY:{type:Number},gravityX:{type:Number},gravityY:{type:Number},frictionX:{type:Number},frictionY:{type:Number},velocityX:{type:Number},velocityY:{type:Number},maxVelocityX:{type:Number},maxVelocityY:{type:Number},accelerationX:{type:Number},accelerationY:{type:Number},offsetX:{type:Number},offsetY:{type:Number},tween:{type:Object},tweens:{type:Array},timeline:{type:Object}},c=Object.entries(d),h=(...e)=>{const t=new Set(e);return Object.fromEntries(c.filter((([e])=>t.has(e))))},u=h("tween","tweens","timeline","visible","x","y","rotation","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","displayWidth","displayHeight","dropZone","depth","alpha","blendMode","pipeline"),y=["create",...t.map((e=>e.emit)),"update:x","update:y"],m=(0,e.defineComponent)({emits:[...y],props:{...u},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Container(r,t.x||0,t.y||0);return V(n,t,i),(0,e.provide)(T.Container,n),(0,e.provide)(T.GameObject,n),{object:n}}}),g=(0,a.Z)(m,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),f=(0,e.defineComponent)({emits:[...y],props:{...u,...h("width","height","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Rectangle(r,t.x||0,t.y||0,t.width,t.height);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),b=(0,a.Z)(f,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),v=(0,e.defineComponent)({emits:[...y],props:{...u,...h("width","height","radius","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene);class n extends Phaser.GameObjects.Graphics{constructor(e,t,i,r,n,o){super(e,t,i,r,n),this._originX=0,this._originY=0,this._width=r||0,this._height=n||0,this._radius=o||0,this._fillColor=null,this._fillAlpha=1,this._lineWidth=0,this._strokeColor=null,this._strokeAlpha=1,this.setRenderFlag(!0)}preUpdate(...e){this.renderFlag&&this.render()}setRenderFlag(e){this.renderFlag=e}render(){this.setRenderFlag(!1);const e=this.originX*-this.width,t=this.originY*-this.height,i="number"==typeof this.radius?Math.min(this.radius,this.width.half,this.height.half):this.radius;this.clear(),null!==this.fillColor&&(this.fillStyle(this.fillColor,this.fillAlpha),this.fillRoundedRect(e,t,this.width,this.height,i)),this.lineWidth&&null!==this.strokeColor&&(this.lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha),this.strokeRoundedRect(e,t,this.width,this.height,i))}get originX(){return this._originX}set originX(e){this._originX=e,this.displayOriginX=this.width*e,this.setRenderFlag(!0)}get originY(){return this._originY}set originY(e){this._originY=e,this.displayOriginY=this.height*e,this.setRenderFlag(!0)}setOrigin(e,t){return this.originX=e,this.originY=void 0===t?e:t,this}get radius(){return this._radius}set radius(e){this._radius=e,this.setRenderFlag(!0)}setRadius(e){return this.radius=e,this}get width(){return this._width}set width(e){this._width=e,this.fixSize(),this.setRenderFlag(!0)}get height(){return this._height}set height(e){this._height=e,this.fixSize(),this.setRenderFlag(!0)}setSize(e,t){return void 0!==e&&(this.width=e),void 0!==t&&(this.height=t),this}fixSize(){this.input&&this.input.hitArea.setSize(this.width,this.height),this.body&&this.body.setSize(this.width,this.height)}get displayWidth(){return Math.abs(this.scaleX*this.width)}set displayWidth(e){this.scaleX=e/this.width}get displayHeight(){return Math.abs(this.scaleY*this.height)}set displayHeight(e){this.scaleY=e/this.height}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this.setRenderFlag(!0)}get fillAlpha(){return this._fillAlpha}set fillAlpha(e){this._fillAlpha=e,this.setRenderFlag(!0)}setFillStyle(e,t){return void 0!==e&&(this.fillColor=e),void 0!==t&&(this.fillAlpha=t),this}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this.setRenderFlag(!0)}get strokeColor(){return this._strokeColor}set strokeColor(e){this._strokeColor=e,this.setRenderFlag(!0)}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(e){this._strokeAlpha=e,this.setRenderFlag(!0)}setStrokeStyle(e,t,i){return void 0!==e&&(this.lineWidth=e),void 0!==t&&(this.strokeColor=t),void 0!==i&&(this.strokeAlpha=i),this}}const o=new n(r,t.x||0,t.y||0,t.width,t.height,t.radius);return V(o,t,i),(0,e.provide)(T.GameObject,o),{object:o}}}),w=(0,a.Z)(v,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),x=(0,e.defineComponent)({emits:[...y],props:{...u,...h("radius","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Arc(r,t.x||0,t.y||0,t.radius);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),S=(0,a.Z)(x,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),j=(0,e.defineComponent)({emits:[...y],props:{...u,...h("x1","y1","x2","y2","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Line(r,t.x||0,t.y||0,t.x1,t.y1,t.x2,t.y2);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),O=(0,a.Z)(j,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),k=(0,e.defineComponent)({emits:[...y],props:{...u,...h("texture","frame","tint","flipX","flipY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Image(r,t.x||0,t.y||0,t.texture);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),Y=(0,a.Z)(k,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),X=(0,e.defineComponent)({emits:[...y],props:{...u,...h("texture","frame","tint","flipX","flipY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Sprite(r,t.x||0,t.y||0,t.texture);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),C=(0,a.Z)(X,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),N=(0,e.defineComponent)({emits:[...y],props:{...u,...h("text","style","lineSpacing","padding")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Text(r,t.x||0,t.y||0,t.text);return V(n,t,i),{object:n}}}),B=(0,a.Z)(N,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),_=(0,e.defineComponent)({emits:["create"],props:{...h("tween","tweens","timeline","visible","x","y","width","height","depth","pipeline","collision","collisionByProperty"),tilemap:{type:Object},layerIndex:{type:Number},tileset:{type:[Array,String]}},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.Tilemaps.TilemapLayer(r,t.tilemap,t.layerIndex,t.tileset,t.x||0,t.y||0);return V(n,t,i),{object:n}}}),P=(0,a.Z)(_,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),A=(0,e.defineComponent)({emits:["create"],props:{...h("tween","tweens","timeline","active","dropArea","x","y","width","height","origin","originX","originY","displayOriginX","displayOriginY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Zone(r,t.x||0,t.y||0,t.width,t.height);return V(n,t,i),{object:n}}}),E=(0,a.Z)(A,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),G=(0,e.defineComponent)({emits:["create"],props:{...h("tween","tweens","timeline","visible","x","y","radius","color","intensity")},setup(e,t){const i=new Phaser.GameObjects.Light(e.x||0,e.y||0);return V(i,e,t),{object:i}}}),R=(0,a.Z)(G,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),W=(0,e.defineComponent)({emits:[...y],props:{...h("width","height","offsetX","offsetY","enable")},setup(t,i){const r=(0,e.inject)(T.Scene),n=(0,e.inject)(T.GameObject),o=r.physics.add.existing(n,Phaser.Physics.Arcade.STATIC_BODY).body;V(o,t,i)}}),F=(0,a.Z)(W,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),I=(0,e.defineComponent)({emits:["create"],props:{...h("width","height","offsetX","offsetY","enable","immovable","moves","bounceX","bounceY","drag","dragX","dragY","gravityX","gravityY","frictionX","frictionY","velocityX","velocityY","maxVelocityX","maxVelocityY","accelerationX","accelerationY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=(0,e.inject)(T.GameObject),o=r.physics.add.existing(n,Phaser.Physics.Arcade.DYNAMIC_BODY).body;V(o,t,i)}}),D=(0,a.Z)(I,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),Z=(e,t)=>{t.provide(T.Game,e),t.provide(T.Scene,null),t.provide(T.Container,null);const i=()=>{const e=window.document.createElement("div");return document.body.appendChild(e),t.mount(e)};return new Promise((t=>{if(e.isRunning)return t(i());e.events.addListener("ready",(()=>{t(i())}))}))},U=(e,t,i)=>{const r=`_${t}`,n=`update:${t}`;e[r]=e[t],Object.defineProperty(e,t,{get(){return this[r]},set(e){this[r]!==e&&i(n,e)}})},V=(i,r,n)=>{const l=(0,e.getCurrentInstance)(),a="bounce"in i,p=i.constructor===Phaser.GameObjects.Light,d=(0,e.inject)(T.Scene);if(p)d.lights.active||d.lights.enable(),d.lights.lights.push(i);else if(a);else{d.add.existing(i);const t=(0,e.inject)(T.Container);t&&t.add([i])}const c=l.vnode.props||[],h=(l.vnode.dynamicProps,Object.keys(c).filter((e=>e.startsWith("onUpdate:"))).map((e=>e.split(":")[1])).filter((e=>s[`_${e}`])));h.forEach((e=>U(i,e,n.emit)));const u=Object.entries(c).filter((([e])=>s[e])).map((([t,n])=>{const l=h.includes(t)?`_${t}`:t,a=s[l](i);return a(n),(0,e.watch)((()=>r[t]),a,{deep:o.includes(t)})})).filter(Boolean);c.onCreate&&n.emit("create",i);const y=t.filter((e=>e.attr in c));return y.length&&(i.input||i.setInteractive(),y.some((e=>e.drag))&&d.input.setDraggable(i),y.forEach((e=>{i.on(e.emit,((...t)=>{"eventIndex"in e&&(t[0].stopPropagation=t[e.eventIndex].stopPropagation),n.emit(e.emit,...t)}))}))),(0,e.onBeforeUnmount)((()=>{i.tween&&i.tween.stop(),u.forEach((e=>e()))})),p?(0,e.onBeforeUnmount)((()=>d.lights.removeLight(i))):(0,e.onBeforeUnmount)((()=>i.destroy())),i},T={Game:"phavuer_game",Scene:"phavuer_scene",GameObject:"phavuer_gameObject",Container:"phavuer_container",PreUpdateEvents:"phavuer_preUpdateEvents",PostUpdateEvents:"phavuer_postUpdateEvents"},$=t=>()=>{const i=(0,e.inject)(t);if(!i)throw new Error(`${t.description} is not provided`);return i},L=$(T.Game),M=$(T.Scene),z=(t,i)=>(0,e.customRef)(((e,r)=>({get:()=>(e(),t),set(e){t&&e||(t=e?e[i]:null,r())}}))),H=e=>z(e,"object"),q=e=>z(e,"scene"),K=t=>i=>{const r=(0,e.inject)(t);r.push(i),(0,e.onBeforeUnmount)((()=>{const e=r.findIndex((e=>e===i));r.splice(e,1)}))},J=K(T.PreUpdateEvents),Q=K(T.PostUpdateEvents)})(),n})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Vue")):"function"==typeof define&&define.amd?define(["Vue"],t):"object"==typeof exports?exports.Phavuer=t(require("Vue")):e.Phavuer=t(e.Vue)}(this,(e=>(()=>{"use strict";var t={744:(e,t)=>{t.Z=(e,t)=>{const i=e.__vccOpts||e;for(const[e,r]of t)i[e]=r;return i}},740:t=>{t.exports=e}},i={};function r(e){var n=i[e];if(void 0!==n)return n.exports;var o=i[e]={exports:{}};return t[e](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{Body:()=>D,Circle:()=>S,Container:()=>g,Image:()=>Y,InjectionKeys:()=>T,Light:()=>R,Line:()=>O,Rectangle:()=>b,RoundRectangle:()=>w,Scene:()=>p,Sprite:()=>C,StaticBody:()=>F,Text:()=>B,TilemapLayer:()=>P,Zone:()=>E,createPhavuerApp:()=>Z,initGameObject:()=>V,onPostUpdate:()=>Q,onPreUpdate:()=>J,refObj:()=>H,refScene:()=>q,refTo:()=>z,useGame:()=>L,useScene:()=>M});var e=r(740);const t=[{attr:"onPointerdown",emit:"pointerdown",eventIndex:3},{attr:"onPointermove",emit:"pointermove",eventIndex:3},{attr:"onPointerup",emit:"pointerup",eventIndex:3},{attr:"onPointerout",emit:"pointerout",eventIndex:1},{attr:"onPointerover",emit:"pointerover",eventIndex:3},{attr:"onWheel",emit:"wheel",eventIndex:4},{attr:"onDragstart",emit:"dragstart",drag:!0},{attr:"onDrag",emit:"drag",drag:!0},{attr:"onDragend",emit:"dragend",drag:!0},{attr:"onDragenter",emit:"dragenter",drag:!0},{attr:"onDragover",emit:"dragover",drag:!0},{attr:"onDragleave",emit:"dragleave",drag:!0},{attr:"onDrop",emit:"drop",drag:!0}],i=e=>{e.updateDisplayOrigin&&e.updateDisplayOrigin(),e.input?e.input.hitArea.setSize(e.width,e.height):e._events&&t.some((t=>t.emit in e._events))&&e.setInteractive()},o=["tween","tweens","timeline","style"],s={active:e=>t=>e.setActive(t),visible:e=>t=>e.setVisible(t),x:e=>t=>e.x=t,_x:e=>t=>e._x=t,y:e=>t=>e.y=t,_y:e=>t=>e._y=t,x1:e=>t=>e.geom.x1=t,y1:e=>t=>e.geom.y1=t,x2:e=>t=>e.geom.x2=t,y2:e=>t=>e.geom.y2=t,rotation:e=>t=>e.setRotation(t),origin:e=>t=>e.setOrigin(t,t),originX:e=>t=>e.setOrigin(t,e.originY),originY:e=>t=>e.setOrigin(e.originX,t),scale:e=>t=>e.setScale(t,t),scaleX:e=>t=>e.setScale(t,e.scaleY),scaleY:e=>t=>e.setScale(e.scaleX,t),width:e=>t=>{e.setSize(t,e.height),i(e)},height:e=>t=>{e.setSize(e.width,t),i(e)},radius:e=>t=>e.setRadius(t),displayWidth:e=>t=>e.setDisplaySize(t,e.displayHeight),displayHeight:e=>t=>e.setDisplaySize(e.displayWidth,t),displayOriginX:e=>t=>e.setDisplayOrigin(t,e.displayOriginY),displayOriginY:e=>t=>e.setDisplayOrigin(e.displayOriginX,t),dropZone:e=>t=>{t&&(e.input||e.setInteractive(),e.input.dropZone=!0)},flipX:e=>t=>e.setFlipX(t),flipY:e=>t=>e.setFlipY(t),depth:e=>t=>e.setDepth(t),alpha:e=>t=>e.setAlpha(t),blendMode:e=>t=>e.setBlendMode(t),pipeline:e=>t=>e.setPipeline(t),intensity:e=>t=>e.setIntensity(t),tint:e=>t=>e.setTint(t),text:e=>t=>e.setText(t),texture:e=>t=>e.setTexture(t,e.frame&&e.frame.name),frame:e=>t=>e.setFrame(t),color:e=>t=>e.setColor(t),fillColor:e=>t=>e.setFillStyle(t,e.fillAlpha),fillAlpha:e=>t=>e.setFillStyle(e.fillColor,t),lineWidth:e=>(t,i)=>{e.setLineWidth?e.setLineWidth(t,i):e.setStrokeStyle(...t?[t,e.strokeColor,e.strokeAlpha]:[])},strokeColor:e=>t=>e.setStrokeStyle(e.lineWidth,t,e.strokeAlpha),strokeAlpha:e=>t=>e.setStrokeStyle(e.lineWidth,e.strokeColor,t),style:e=>t=>e.setStyle(t),lineSpacing:e=>t=>e.setLineSpacing(t),padding:e=>t=>e.setPadding(t),collision:e=>t=>e.setCollision(t),collisionByProperty:e=>t=>e.setCollisionByProperty(t),enable:e=>t=>e.enable=t,immovable:e=>t=>e.setImmovable(t),moves:e=>t=>e.moves=t,bounceX:e=>t=>e.setBounceX(t),bounceY:e=>t=>e.setBounceY(t),drag:e=>t=>e.setDrag(t),dragX:e=>t=>e.setDragX(t),dragY:e=>t=>e.setDragY(t),gravityX:e=>t=>e.setGravityX(t),gravityY:e=>t=>e.setGravityY(t),frictionX:e=>t=>e.setFrictionX(t),frictionY:e=>t=>e.setFrictionY(t),velocityX:e=>t=>e.setVelocityX(t),velocityY:e=>t=>e.setVelocityY(t),maxVelocityX:e=>t=>e.setMaxVelocityX(t),maxVelocityY:e=>t=>e.setMaxVelocityY(t),accelerationX:e=>t=>e.setAccelerationX(t),accelerationY:e=>t=>e.setAccelerationY(t),offsetX:e=>t=>e.setOffset(t,e.offset.y),offsetY:e=>t=>e.setOffset(e.offset.x,t),tween:e=>t=>{e.tween&&e.tween.stop(),t&&(e.tween=e.scene.add.tween(Object.assign({targets:e},t)))},tweens:e=>t=>{e.tween&&e.tween.stop(),t&&(e.tween=e.scene.tweens.timeline({targets:e,tweens:t}))},timeline:e=>t=>{e.tween&&e.tween.stop(),t&&(e.tween=e.scene.tweens.timeline(Object.assign({targets:e},t)))}},l=(0,e.defineComponent)({emits:["init","create","update","preload"],props:{name:{type:String,required:!0},autoStart:{type:Boolean,default:!0}},setup(t,i){const r=(0,e.ref)(!1),n=[],o=[],s=class extends Phaser.Scene{init(e){i.emit("init",this,e)}create(e){r.value=!0,i.emit("create",this,e)}update(e,t){n.forEach((i=>i(e,t))),i.emit("update",this,e,t),o.forEach((i=>i(e,t)))}preload(){i.emit("preload",this)}},l=(0,e.inject)(T.Game).scene.add(t.name,s,t.autoStart);return l.events.on("shutdown",(()=>r.value=!1)),(0,e.provide)(T.Scene,l),(0,e.provide)(T.PreUpdateEvents,n),(0,e.provide)(T.PostUpdateEvents,o),{scene:l,show:r}}});var a=r(744);const p=(0,a.Z)(l,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[t.show?(0,e.renderSlot)(t.$slots,"default",{key:0}):(0,e.createCommentVNode)("v-if",!0)])}]]),d={active:{type:Boolean},visible:{type:Boolean},x:{type:Number},y:{type:Number},x1:{type:Number},y1:{type:Number},x2:{type:Number},y2:{type:Number},rotation:{type:Number},origin:{type:Number},originX:{type:Number},originY:{type:Number},scale:{type:Number},scaleX:{type:Number},scaleY:{type:Number},width:{type:Number},height:{type:Number},radius:{type:Number},displayWidth:{type:Number},displayHeight:{type:Number},displayOriginX:{type:Number},displayOriginY:{type:Number},dropZone:{type:Boolean},flipX:{type:Boolean},flipY:{type:Boolean},depth:{type:Number},alpha:{type:Number},blendMode:{type:[Number,String]},pipeline:{type:[String,Object]},intensity:{type:Number},tint:{type:Number},text:{type:[String,Number]},texture:{type:String},frame:{type:[Number,String]},color:{type:String},fillColor:{type:Number},fillAlpha:{type:Number},lineWidth:{type:Number},strokeColor:{type:Number},strokeAlpha:{type:Number},style:{type:Object},lineSpacing:{type:Number},padding:{type:[Number,Object]},collision:{type:[Number,Array]},collisionByProperty:{type:Object},enable:{type:Boolean},immovable:{type:Boolean},moves:{type:Boolean},bounceX:{type:Number},bounceY:{type:Number},drag:{type:Number},dragX:{type:Number},dragY:{type:Number},gravityX:{type:Number},gravityY:{type:Number},frictionX:{type:Number},frictionY:{type:Number},velocityX:{type:Number},velocityY:{type:Number},maxVelocityX:{type:Number},maxVelocityY:{type:Number},accelerationX:{type:Number},accelerationY:{type:Number},offsetX:{type:Number},offsetY:{type:Number},tween:{type:Object},tweens:{type:Array},timeline:{type:Object}},c=Object.entries(d),h=(...e)=>{const t=new Set(e);return Object.fromEntries(c.filter((([e])=>t.has(e))))},u=h("tween","tweens","timeline","visible","x","y","rotation","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","displayWidth","displayHeight","dropZone","depth","alpha","blendMode","pipeline"),m=["create",...t.map((e=>e.emit)),"update:x","update:y"],y=(0,e.defineComponent)({emits:[...m],props:{...u},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Container(r,t.x||0,t.y||0);return V(n,t,i),(0,e.provide)(T.Container,n),(0,e.provide)(T.GameObject,n),{object:n}}}),g=(0,a.Z)(y,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),f=(0,e.defineComponent)({emits:[...m],props:{...u,...h("width","height","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Rectangle(r,t.x||0,t.y||0,t.width,t.height);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),b=(0,a.Z)(f,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),v=(0,e.defineComponent)({emits:[...m],props:{...u,...h("width","height","radius","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene);class n extends Phaser.GameObjects.Graphics{constructor(e,t,i,r,n,o){super(e,t,i,r,n),this._originX=0,this._originY=0,this._width=r||0,this._height=n||0,this._radius=o||0,this._fillColor=null,this._fillAlpha=1,this._lineWidth=0,this._strokeColor=null,this._strokeAlpha=1,this.setRenderFlag(!0)}preUpdate(...e){this.renderFlag&&this.render()}setRenderFlag(e){this.renderFlag=e}render(){this.setRenderFlag(!1);const e=this.originX*-this.width,t=this.originY*-this.height,i="number"==typeof this.radius?Math.min(this.radius,this.width.half,this.height.half):this.radius;this.clear(),null!==this.fillColor&&(this.fillStyle(this.fillColor,this.fillAlpha),this.fillRoundedRect(e,t,this.width,this.height,i)),this.lineWidth&&null!==this.strokeColor&&(this.lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha),this.strokeRoundedRect(e,t,this.width,this.height,i))}get originX(){return this._originX}set originX(e){this._originX=e,this.displayOriginX=this.width*e,this.setRenderFlag(!0)}get originY(){return this._originY}set originY(e){this._originY=e,this.displayOriginY=this.height*e,this.setRenderFlag(!0)}setOrigin(e,t){return this.originX=e,this.originY=void 0===t?e:t,this}get radius(){return this._radius}set radius(e){this._radius=e,this.setRenderFlag(!0)}setRadius(e){return this.radius=e,this}get width(){return this._width}set width(e){this._width=e,this.fixSize(),this.setRenderFlag(!0)}get height(){return this._height}set height(e){this._height=e,this.fixSize(),this.setRenderFlag(!0)}setSize(e,t){return void 0!==e&&(this.width=e),void 0!==t&&(this.height=t),this}fixSize(){this.input&&this.input.hitArea.setSize(this.width,this.height),this.body&&this.body.setSize(this.width,this.height)}get displayWidth(){return Math.abs(this.scaleX*this.width)}set displayWidth(e){this.scaleX=e/this.width}get displayHeight(){return Math.abs(this.scaleY*this.height)}set displayHeight(e){this.scaleY=e/this.height}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this.setRenderFlag(!0)}get fillAlpha(){return this._fillAlpha}set fillAlpha(e){this._fillAlpha=e,this.setRenderFlag(!0)}setFillStyle(e,t){return void 0!==e&&(this.fillColor=e),void 0!==t&&(this.fillAlpha=t),this}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this.setRenderFlag(!0)}get strokeColor(){return this._strokeColor}set strokeColor(e){this._strokeColor=e,this.setRenderFlag(!0)}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(e){this._strokeAlpha=e,this.setRenderFlag(!0)}setStrokeStyle(e,t,i){return void 0!==e&&(this.lineWidth=e),void 0!==t&&(this.strokeColor=t),void 0!==i&&(this.strokeAlpha=i),this}}const o=new n(r,t.x||0,t.y||0,t.width,t.height,t.radius);return V(o,t,i),(0,e.provide)(T.GameObject,o),{object:o}}}),w=(0,a.Z)(v,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),x=(0,e.defineComponent)({emits:[...m],props:{...u,...h("radius","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Arc(r,t.x||0,t.y||0,t.radius);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),S=(0,a.Z)(x,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),j=(0,e.defineComponent)({emits:[...m],props:{...u,...h("x1","y1","x2","y2","lineWidth","strokeColor","strokeAlpha")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Line(r,t.x||0,t.y||0,t.x1,t.y1,t.x2,t.y2);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),O=(0,a.Z)(j,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),k=(0,e.defineComponent)({emits:[...m],props:{...u,...h("texture","frame","tint","flipX","flipY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Image(r,t.x||0,t.y||0,t.texture);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),Y=(0,a.Z)(k,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),X=(0,e.defineComponent)({emits:[...m],props:{...u,...h("texture","frame","tint","flipX","flipY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Sprite(r,t.x||0,t.y||0,t.texture);return V(n,t,i),(0,e.provide)(T.GameObject,n),{object:n}}}),C=(0,a.Z)(X,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div",null,[(0,e.renderSlot)(t.$slots,"default")])}]]),N=(0,e.defineComponent)({emits:[...m],props:{...u,...h("text","style","lineSpacing","padding")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Text(r,t.x||0,t.y||0,t.text);return V(n,t,i),{object:n}}}),B=(0,a.Z)(N,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),_=(0,e.defineComponent)({emits:["create"],props:{...h("tween","tweens","timeline","visible","x","y","width","height","depth","pipeline","collision","collisionByProperty"),tilemap:{type:Object},layerIndex:{type:Number},tileset:{type:[Array,String]}},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.Tilemaps.TilemapLayer(r,t.tilemap,t.layerIndex,t.tileset,t.x||0,t.y||0);return V(n,t,i),{object:n}}}),P=(0,a.Z)(_,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),A=(0,e.defineComponent)({emits:["create"],props:{...h("tween","tweens","timeline","active","dropArea","x","y","width","height","origin","originX","originY","displayOriginX","displayOriginY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=new Phaser.GameObjects.Zone(r,t.x||0,t.y||0,t.width,t.height);return V(n,t,i),{object:n}}}),E=(0,a.Z)(A,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),G=(0,e.defineComponent)({emits:["create"],props:{...h("tween","tweens","timeline","visible","x","y","radius","color","intensity")},setup(e,t){const i=new Phaser.GameObjects.Light(e.x||0,e.y||0);return V(i,e,t),{object:i}}}),R=(0,a.Z)(G,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),W=(0,e.defineComponent)({emits:[...m],props:{...h("width","height","offsetX","offsetY","enable")},setup(t,i){const r=(0,e.inject)(T.Scene),n=(0,e.inject)(T.GameObject),o=r.physics.add.existing(n,Phaser.Physics.Arcade.STATIC_BODY).body;V(o,t,i)}}),F=(0,a.Z)(W,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),I=(0,e.defineComponent)({emits:["create"],props:{...h("width","height","offsetX","offsetY","enable","immovable","moves","bounceX","bounceY","drag","dragX","dragY","gravityX","gravityY","frictionX","frictionY","velocityX","velocityY","maxVelocityX","maxVelocityY","accelerationX","accelerationY")},setup(t,i){const r=(0,e.inject)(T.Scene),n=(0,e.inject)(T.GameObject),o=r.physics.add.existing(n,Phaser.Physics.Arcade.DYNAMIC_BODY).body;V(o,t,i)}}),D=(0,a.Z)(I,[["render",function(t,i,r,n,o,s){return(0,e.openBlock)(),(0,e.createElementBlock)("div")}]]),Z=(e,t)=>{t.provide(T.Game,e),t.provide(T.Scene,null),t.provide(T.Container,null);const i=()=>{const e=window.document.createElement("div");return document.body.appendChild(e),t.mount(e)};return new Promise((t=>{if(e.isRunning)return t(i());e.events.addListener("ready",(()=>{t(i())}))}))},U=(e,t,i)=>{const r=`_${t}`,n=`update:${t}`;e[r]=e[t],Object.defineProperty(e,t,{get(){return this[r]},set(e){this[r]!==e&&i(n,e)}})},V=(i,r,n)=>{const l=(0,e.getCurrentInstance)(),a="bounce"in i,p=i.constructor===Phaser.GameObjects.Light,d=(0,e.inject)(T.Scene);if(p)d.lights.active||d.lights.enable(),d.lights.lights.push(i);else if(a);else{d.add.existing(i);const t=(0,e.inject)(T.Container);t&&t.add([i])}const c=l.vnode.props||[],h=(l.vnode.dynamicProps,Object.keys(c).filter((e=>e.startsWith("onUpdate:"))).map((e=>e.split(":")[1])).filter((e=>s[`_${e}`])));h.forEach((e=>U(i,e,n.emit)));const u=Object.entries(c).filter((([e])=>s[e])).map((([t,n])=>{const l=h.includes(t)?`_${t}`:t,a=s[l](i);return a(n),(0,e.watch)((()=>r[t]),a,{deep:o.includes(t)})})).filter(Boolean);c.onCreate&&n.emit("create",i);const m=t.filter((e=>e.attr in c));return m.length&&(i.input||i.setInteractive(),m.some((e=>e.drag))&&d.input.setDraggable(i),m.forEach((e=>{i.on(e.emit,((...t)=>{"eventIndex"in e&&(t[0].stopPropagation=t[e.eventIndex].stopPropagation),n.emit(e.emit,...t)}))}))),(0,e.onBeforeUnmount)((()=>{i.tween&&i.tween.stop(),u.forEach((e=>e()))})),p?(0,e.onBeforeUnmount)((()=>d.lights.removeLight(i))):(0,e.onBeforeUnmount)((()=>i.destroy())),i},T={Game:"phavuer_game",Scene:"phavuer_scene",GameObject:"phavuer_gameObject",Container:"phavuer_container",PreUpdateEvents:"phavuer_preUpdateEvents",PostUpdateEvents:"phavuer_postUpdateEvents"},$=t=>()=>{const i=(0,e.inject)(t);if(!i)throw new Error(`${t.description} is not provided`);return i},L=$(T.Game),M=$(T.Scene),z=(t,i)=>(0,e.customRef)(((e,r)=>({get:()=>(e(),t),set(e){t&&e||(t=e?e[i]:null,r())}}))),H=e=>z(e,"object"),q=e=>z(e,"scene"),K=t=>i=>{const r=(0,e.inject)(t);r.push(i),(0,e.onBeforeUnmount)((()=>{const e=r.findIndex((e=>e===i));r.splice(e,1)}))},J=K(T.PreUpdateEvents),Q=K(T.PostUpdateEvents)})(),n})())); |
{ | ||
"name": "phavuer", | ||
"version": "0.10.9", | ||
"version": "0.10.10", | ||
"description": "Reactive template engine based on Vue 3 for Phaser 3", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -35,6 +35,6 @@ export const GAME_OBJECT_EVENTS = [ | ||
_y: object => v => object._y = v, | ||
x1: object => v => object.x1 = v, | ||
y1: object => v => object.y1 = v, | ||
x2: object => v => object.x2 = v, | ||
y2: object => v => object.y2 = v, | ||
x1: object => v => object.geom.x1 = v, | ||
y1: object => v => object.geom.y1 = v, | ||
x2: object => v => object.geom.x2 = v, | ||
y2: object => v => object.geom.y2 = v, | ||
rotation: object => v => object.setRotation(v), | ||
@@ -41,0 +41,0 @@ origin: object => v => object.setOrigin(v, v), |
121573