@combos-fun/plugin-development-tool 0.0.34 → 0.0.36
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/agent-skill.md +48 -6
- package/dist/plugin-development-tool.cjs.js +1 -1
- package/dist/plugin-development-tool.cjs.js.map +1 -1
- package/dist/plugin-development-tool.cjs.prod.js +1 -1
- package/dist/plugin-development-tool.esm.js +1 -1
- package/dist/plugin-development-tool.esm.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),n=require("@combos-fun/plugin-renderer"),o=require("@combos-fun/plugin-renderer-graphics"),s=require("@combos-fun/plugin-renderer-event"),i=require("@combos-fun/inspector-decorator");const r="combos-development-tool:set",a="combos-development-tool:set-success",c="combos-development-tool:refresh",l="combos-development-tool:gameobject-selected",d="combos-development-tool:clear-selection",h="combos-development-tool:gameobject-deselected",u="combos-development-tool:apply-property",p="combos-development-tool:set-muted",m="combos-development-tool:state-changed",f="combos-development-tool:set-marker-overlay",g="combos-development-tool:marker-overlay-success";class y extends t.Component{constructor(){super(...arguments),this.payload={}}static{this.componentName="CombosDevelopmentToolTarget"}init(e){this.payload=e?.payload?{...e.payload}:{}}}const O=[{componentName:"Sound",badgeColor:9133302,glyph:"speaker"}];function b(e,t=O){for(const n of t)if(e.getComponent(n.componentName))return n;return null}const w=16777215;function v(e,t,n=28){if(function(e,t,n){e.clear(),e.roundRect(0,0,n,n,.22*n),e.fill({color:t.badgeColor,alpha:.92}),e.roundRect(0,0,n,n,.22*n),e.stroke({width:Math.max(1,.05*n),color:16777215,alpha:.6})}(e,t,n),"speaker"===t.glyph)!function(e,t){e.poly([.28*t,.4*t,.42*t,.4*t,.55*t,.26*t,.55*t,.74*t,.42*t,.6*t,.28*t,.6*t]),e.fill({color:w,alpha:.96}),e.rect(.62*t,.44*t,.045*t,.12*t),e.fill({color:w,alpha:.96}),e.rect(.71*t,.39*t,.045*t,.22*t),e.fill({color:w,alpha:.96})}(e,n);else!function(e,t){e.circle(.5*t,.5*t,.18*t),e.fill({color:w,alpha:.96})}(e,n)}const E=["knoffice.tech","converge.ai"];function M(e,t){if(t.includes("*"))return!0;if(0===t.length)return!1;let n;try{n=new URL(e)}catch{return!1}const o=e.toLowerCase(),s=n.hostname.toLowerCase();for(const e of t){const t=e.trim();if(!t)continue;if(t.includes("://")){if(o===t.toLowerCase())return!0;continue}const n=t.toLowerCase().replace(/^\./,"");if(s===n||s.endsWith(`.${n}`))return!0}return!1}function S(e){if(!e?.length)return[...E];if(e.includes("*"))return["*"];const t=new Set,n=[];for(const o of[...E,...e]){const e=o.trim();e&&!t.has(e)&&(t.add(e),n.push(e))}return n}function k(e){return"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null!==e&&"object"==typeof e?"object":"unsupported"}function G(e,t=0){if(null==e)return e;if("number"==typeof e||"string"==typeof e||"boolean"==typeof e)return e;if(!(t>6)){if(Array.isArray(e))return e.map(e=>G(e,t+1));if("object"==typeof e){const n={};for(const[o,s]of Object.entries(e)){if("function"==typeof s)continue;const e=G(s,t+1);void 0!==e&&(n[o]=e)}return n}}}function C(e){const t=e.constructor,n=function(e){const t=Reflect.getMetadata(i.IDE_PROPERTY_METADATA,e)||{};return Object.keys(t).map(e=>({key:e,...t[e]}))}(t);return n.length>0?n:function(e){const t=e.IDEProps;return!t||Array.isArray(t)||"object"!=typeof t?[]:Object.keys(t).map(e=>{const n=t[e]||{};return{key:e,type:"string"==typeof n.type?n.type:void 0,step:"number"==typeof n.step?n.step:void 0,min:"number"==typeof n.min?n.min:void 0,max:"number"==typeof n.max?n.max:void 0,label:"string"==typeof n.label?n.label:void 0,description:"string"==typeof n.description?n.description:void 0,group:"string"==typeof n.group?n.group:void 0,editor:n.editor,enumOptions:Array.isArray(n.enumOptions)?n.enumOptions:void 0,unit:"string"==typeof n.unit?n.unit:void 0}})}(t)}function T(e,t){return e.editor?e.editor:"boolean"===t?"toggle":e.enumOptions?.length&&"string"===t?"enum":"number"===t?void 0!==e.min&&void 0!==e.max?"number-slider":"number-stepper":"string"===t?"text":void 0}function _(e){if(void 0!==e.min||void 0!==e.max||void 0!==e.step||void 0!==e.unit)return{min:e.min,max:e.max,step:e.step,unit:e.unit}}function x(e,t){if(e.label?.trim())return e.label.trim();const n=t[t.length-1];return n?function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}(n):void 0}function R(e,t,n,o){const s=t.description?.trim();if(!s)return[];const i=k(o);if("unsupported"===i)return[];const r=t.type,a="size"===r||"object"===i&&null!==o&&"width"in o&&"height"in o;if("vector2"===r||"object"===i&&null!==o&&"x"in o&&"y"in o||a){const i=o,r=a?["width","height"]:["x","y"],c=x(t,n)??e,l=[];for(const o of r){const r=i[o],a=k(r);if("unsupported"===a||"object"===a)continue;const d=[...n,o];l.push({path:d,value:r,valueType:a,label:`${c} ${o.toUpperCase()}`,description:s,group:t.group??e,editorKind:T(t,a),numberMeta:_(t),persistTarget:"Transform"===e?"gameObjectConstructor":"component"})}return l}if("object"===i)return[];const c=x(t,n);return c?[{path:n,value:G(o),valueType:i,label:c,description:s,group:t.group??e,editorKind:T(t,i),enumOptions:t.enumOptions,numberMeta:_(t),persistTarget:"Transform"===e?"gameObjectConstructor":"component"}]:[]}function B(e){const t=e.name,n=C(e);if(0===n.length)return[];const o=[],s=e;for(const e of n){const n=s[e.key];"function"!=typeof n&&o.push(...R(t,e,[e.key],n))}return o}function P(e){const t=e.getComponent(y),n=t?.payload?.source;var o;if((o=n)&&"object"==typeof o&&"string"==typeof o.file)return{file:n.file,anchor:n.anchor??e.name}}function L(e){const t=e.components.filter(e=>"CombosDevelopmentToolTarget"!==e.name).map(e=>({componentName:e.name,fieldDescriptors:B(e)})).filter(e=>e.fieldDescriptors.length>0);return{id:e.id,name:e.name,components:t,source:P(e)}}function A(e,t,n,o){const s=e.getComponent(t);if(!s||!n.length)return!1;let i=s;for(let e=0;e<n.length-1;e++){const t=n[e];void 0!==i[t]&&null!==i[t]||(i[t]={}),i=i[t]}return i[n[n.length-1]]=o,!0}const j=new Set(["position","size","origin","anchor","scale","skew"]);function D(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}const N={Transform:function(e,t,n,o){const s=e.transform??t,i=s;if(1===n.length&&"rotation"===n[0]){const e=D(o);return void 0!==e&&(s.rotation=e,!0)}if(2===n.length&&j.has(n[0])){const t=n[0],s=n[1],r=D(o);if(void 0===r)return!1;const a=i[t];return!(!a||"object"!=typeof a)&&(a[s]=r,"position"===t&&(function(e){const t=e.getComponent("Physics");if(!t?.body)return;const{x:n,y:o}=e.transform.position;t.Body?.setPosition?t.Body.setPosition(t.body,{x:n,y:o}):(t.body.position.x=n,t.body.position.y=o)}(e),function(e){const t=e.getComponent("PlatformerMover");t&&(t.originX=e.transform.position.x,t.originY=e.transform.position.y)}(e)),!0)}return!1},Text:function(e,t,n,o){const s=t;if(1===n.length&&"text"===n[0])return s.text=String(o??""),!0;if(2===n.length&&"style"===n[0]){const e=n[1],t={...s.style??{},[e]:o};return s.style=t,!0}return!1},Sound:function(e,t,n,o){const s=t;if(1===n.length&&"volume"===n[0]||2===n.length&&"config"===n[0]&&"volume"===n[1]){const e=D(o);return void 0!==e&&(s.volume=e,!0)}return!1}};function I(e,t,n,o){const s=e.getComponent(t);if(!s||!n.length)return!1;const i=N[t];return!!i?.(e,s,n,o)||A(e,t,n,o)}function W(e){return{type:h,reason:e}}function V(e){return e}function q(e){return!(!e||"object"!=typeof e)&&e.type===d}const H="__combosDevelopmentToolOutline",U="__combosDevelopmentToolMarker:";let Y=class extends t.System{constructor(){super(...arguments),this.postMessageOrigin="*",this.allowedMessageOrigins=S(),this.enabled=!1,this.outlineGo=null,this.selected=null,this.tapHandlers=new Map,this.tapOwners=new Map,this.disabledGameEventGoIds=new Set,this.pickEvents=new Set,this.needsRescan=!1,this.lastOutlineBounds=null,this.mutedWithoutSoundSystem=!1,this.markerOverlayEnabled=!1,this.needsMarkerRescan=!1,this.markerGoByOwner=new Map,this.onWindowSet=e=>{const t=e.detail;t&&"boolean"==typeof t.enabled&&this.setEnabled(t.enabled)},this.onWindowSetMuted=e=>{const t=e.detail;t&&"boolean"==typeof t.muted&&this.setMuted(t.muted)},this.onWindowSetMarkerOverlay=e=>{const t=e.detail;t&&"boolean"==typeof t.enabled&&this.setMarkerOverlay(t.enabled)},this.onGameSetMarkerOverlay=e=>{e&&"boolean"==typeof e.enabled&&this.setMarkerOverlay(e.enabled)},this.onWindowMessage=e=>{if(!M(e.origin,this.allowedMessageOrigins))return;const t=e.data;t&&"object"==typeof t&&(t.type===r&&"boolean"==typeof t.enabled?this.setEnabled(t.enabled):t.type===p&&"boolean"==typeof t.muted?this.setMuted(t.muted):t.type===f&&"boolean"==typeof t.enabled?this.setMarkerOverlay(t.enabled):t.type===c?this.requestSceneRescan():q(t)?this.clearSelectionAndNotify("parent-request"):t.type===u&&this.handleApplyProperty(t))},this.onGameSet=e=>{e&&"boolean"==typeof e.enabled&&this.setEnabled(e.enabled)},this.onGameRefresh=()=>{this.requestSceneRescan()},this.onGameSetMuted=e=>{e&&"boolean"==typeof e.muted&&this.setMuted(e.muted)},this.onWindowRefresh=()=>{this.requestSceneRescan()}}static{this.systemName="CombosDevelopmentToolSystem"}init(e){this.postMessageOrigin=e?.postMessageOrigin??"*",this.allowedMessageOrigins=S(e?.allowedMessageOrigins),"undefined"!=typeof window&&(window.addEventListener(r,this.onWindowSet),window.addEventListener(p,this.onWindowSetMuted),window.addEventListener(f,this.onWindowSetMarkerOverlay),window.addEventListener(c,this.onWindowRefresh),window.addEventListener("message",this.onWindowMessage)),this.game.on(r,this.onGameSet),this.game.on(p,this.onGameSetMuted),this.game.on(f,this.onGameSetMarkerOverlay),this.game.on(c,this.onGameRefresh),this.enabled&&(this.needsRescan=!0)}onDestroy(){"undefined"!=typeof window&&(window.removeEventListener(r,this.onWindowSet),window.removeEventListener(p,this.onWindowSetMuted),window.removeEventListener(f,this.onWindowSetMarkerOverlay),window.removeEventListener(c,this.onWindowRefresh),window.removeEventListener("message",this.onWindowMessage)),this.game.off(r,this.onGameSet),this.game.off(p,this.onGameSetMuted),this.game.off(f,this.onGameSetMarkerOverlay),this.game.off(c,this.onGameRefresh),this.detachAllPicks(),this.detachAllMarkers(),this.restoreDisabledGameEvents(),this.clearSelectionAndNotify("pick-disabled")}setEnabled(e){this.enabled!==e&&(this.enabled=e,e?this.needsRescan=!0:(this.clearSelectionAndNotify("pick-disabled"),this.detachAllPicks(),this.restoreDisabledGameEvents(),this.postSetSuccess(!1)))}get isEnabled(){return this.enabled}setMarkerOverlay(e){this.markerOverlayEnabled!==e&&(this.markerOverlayEnabled=e,e?this.needsMarkerRescan=!0:(this.detachAllMarkers(),this.postMarkerOverlaySuccess(!1,[]),this.enabled&&(this.needsRescan=!0)))}get isMarkerOverlayEnabled(){return this.markerOverlayEnabled}get isMuted(){const e=this.getSoundSystem();return e?e.muted:this.mutedWithoutSoundSystem}setMuted(e){const t=this.getSoundSystem();t?t.muted=e:this.mutedWithoutSoundSystem=e,this.postStateChanged()}update(e){this.enabled&&this.needsRescan&&(this.needsRescan=!1,this.attachEditMode(),this.postSetSuccess(!0)),this.markerOverlayEnabled&&this.needsMarkerRescan&&(this.needsMarkerRescan=!1,this.attachMarkers());for(const e of[...this.tapOwners.values()])e.destroyed&&this.releasePick(e);for(const[e,t]of[...this.markerGoByOwner.entries()]){const n=this.findGameObjectById(e);(!n||n.destroyed||t.destroyed)&&this.removeMarker(e)}this.enabled&&this.selected&&this.outlineGo&&this.updateSelectionOutline()}componentChanged(e){if(!this.enabled)return;const{type:n,gameObject:o,componentName:s}=e;o&&"CombosDevelopmentToolTarget"===s&&(n===t.OBSERVER_TYPE.ADD?(this.stripGameEvent(o),this.ensurePick(o)):n===t.OBSERVER_TYPE.REMOVE&&(this.releasePick(o),this.selected===o&&this.clearSelectionAndNotify("target-removed")))}requestSceneRescan(){this.enabled&&(this.needsRescan=!0),this.markerOverlayEnabled&&(this.needsMarkerRescan=!0)}attachEditMode(){this.detachAllPicks();const e=[];for(const t of this.game.scene.transform.children)this.collectGameObjects(t.gameObject,e);for(const t of e)this.isIgnoredPickGo(t)||this.stripGameEvent(t);for(const t of e)this.isIgnoredPickGo(t)||t.getComponent(y)&&this.ensurePick(t)}collectGameObjects(e,t){t.push(e);for(const n of e.transform.children)this.collectGameObjects(n.gameObject,t)}isIgnoredPickGo(e){return e.name===H||e===this.outlineGo||this.isMarkerGo(e)}isMarkerGo(e){return"string"==typeof e.name&&e.name.startsWith(U)}stripGameEvent(e){if(this.disabledGameEventGoIds.has(e.id))return;if(!e.getComponent(s.Event))return;const t=this.getRendererContainer(e);if(t)try{t.interactive=!1,this.disabledGameEventGoIds.add(e.id)}catch{}}restoreDisabledGameEvents(){for(const e of[...this.disabledGameEventGoIds]){const t=this.findGameObjectById(e);if(!t||t.destroyed){this.disabledGameEventGoIds.delete(e);continue}const n=this.getRendererContainer(t);if(n)try{n.interactive=!0}catch{}this.disabledGameEventGoIds.delete(e)}}detachAllPicks(){for(const e of[...this.tapOwners.values()])this.releasePick(e)}ensurePick(e){if(this.tapHandlers.has(e.id))return;const t=this.getRendererContainer(e);if(t)try{t.interactive=!0}catch{}let n=e.getComponent(s.Event);n||(n=e.addComponent(this.createPickEvent(e)),this.pickEvents.add(e.id));const o=t=>this.onSelect(e,t);this.tapHandlers.set(e.id,o),this.tapOwners.set(e.id,e),n.on("tap",o)}createPickEvent(e){const t=this.resolvePickBounds(e);return t.width>0&&t.height>0?new s.Event({hitArea:{type:s.HIT_AREA_TYPE.Rect,style:{x:t.x,y:t.y,width:t.width,height:t.height}}}):new s.Event}resolvePickBounds(e){if(this.shouldPreferRenderedBounds(e)){const t=this.resolveOwnGraphicsLocalBounds(e);if(t)return t;const n=this.resolveContainerLocalBounds(e);if(n)return n}const{width:t,height:n}=e.transform.size;if(t>0&&n>0)return{x:0,y:0,width:t,height:n};const o=this.resolveContainerLocalBounds(e);return o||{x:0,y:0,width:1,height:1}}shouldPreferRenderedBounds(e){return null!=e.getComponent(o.Graphics)}resolveOwnGraphicsLocalBounds(e){const t=e.getComponent(o.Graphics);if(!t?.graphics)return null;try{const e=t.graphics.getLocalBounds();if(e.width>0&&e.height>0)return{x:e.x,y:e.y,width:e.width,height:e.height}}catch{}return null}resolveContainerLocalBounds(e){const t=this.getRendererContainer(e);if(!t)return null;const n=this.getOutlineContainerIfChildOf(e);let o=!1;n?.parent===t&&(t.removeChild(n),o=!0);try{const e=t.getLocalBounds();if(e.width>0&&e.height>0)return{x:e.x,y:e.y,width:e.width,height:e.height}}catch{}finally{o&&n&&t.addChild(n)}return null}getOutlineContainerIfChildOf(e){return this.outlineGo&&this.outlineGo.parent===e?this.getRendererContainer(this.outlineGo):null}getRendererContainer(e){const t=this.game.getSystem(n.RendererSystem);if(!t?.containerManager)return null;try{return t.containerManager.getContainer(e.id)}catch{return null}}releasePick(e){const t=this.tapHandlers.get(e.id);if(!t)return;const n=e.getComponent(s.Event);if(n?.off("tap",t),this.tapHandlers.delete(e.id),this.tapOwners.delete(e.id),this.pickEvents.has(e.id)){try{e.removeComponent(s.Event)}catch{}this.pickEvents.delete(e.id)}}postSetSuccess(e){const t={type:a,enabled:e};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(t,this.postMessageOrigin),this.game.emit(a,{enabled:e})}postStateChanged(){const e={muted:this.isMuted},t={type:m,...e};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(t,this.postMessageOrigin),this.game.emit(m,e)}attachMarkers(){this.detachAllMarkers();const e=[];for(const t of this.game.scene.transform.children)this.collectGameObjects(t.gameObject,e);const t=new Map;for(const n of e){if(this.isIgnoredPickGo(n))continue;const e=b(n);e&&(this.createMarker(n,e),t.set(e.componentName,(t.get(e.componentName)??0)+1))}const n=[...t.entries()].map(([e,t])=>({componentName:e,count:t}));this.postMarkerOverlaySuccess(!0,n),this.enabled&&(this.needsRescan=!0)}createMarker(e,n){if(this.markerGoByOwner.has(e.id))return;const s=this.resolvePickBounds(e),i=new t.GameObject(U+e.id,{size:{width:28,height:28},position:{x:s.x,y:s.y},origin:{x:0,y:0}}),r=i.addComponent(new o.Graphics);r?.graphics&&v(r.graphics,n,28),e.addChild(i),this.markerGoByOwner.set(e.id,i)}removeMarker(e){const t=this.markerGoByOwner.get(e);t&&(this.markerGoByOwner.delete(e),t.destroyed||t.destroy())}detachAllMarkers(){for(const e of[...this.markerGoByOwner.keys()])this.removeMarker(e);this.markerGoByOwner.clear()}postMarkerOverlaySuccess(e,t){const n={enabled:e,total:t.reduce((e,t)=>e+t.count,0),markers:t},o={type:g,...n};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(o,this.postMessageOrigin),this.game.emit(g,n)}getSoundSystem(){const e=this.game.getSystem("SoundSystem");return e&&"object"==typeof e&&"muted"in e&&"boolean"==typeof e.muted?e:null}ensureOutline(){if(this.outlineGo)return;const e=new t.GameObject(H,{size:{width:1,height:1},position:{x:0,y:0},origin:{x:0,y:0}});e.addComponent(new o.Graphics),this.outlineGo=e}onSelect(e,t){if(!this.enabled)return;if(t?.stopPropagation?.(),this.ensureOutline(),!this.outlineGo)return;this.selected=e,this.outlineGo.parent&&this.outlineGo.remove(),e.addChild(this.outlineGo),this.invalidateOutlineBounds(),this.updateSelectionOutline();const n=L(e),o={type:l,snapshot:n,pointer:t?.data?.position??null};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(o,this.postMessageOrigin)}findGameObjectById(e){const t=[];for(const e of this.game.scene.transform.children)this.collectGameObjects(e.gameObject,t);return t.find(t=>t.id===e)??null}findGameObjectBySource(e){const t=[];for(const e of this.game.scene.transform.children)this.collectGameObjects(e.gameObject,t);const n=e.file.trim(),o=(e.anchor??"").trim();if(!o)return null;for(const e of t){const t=P(e);if(!t||t.file!==n)continue;if((t.anchor??e.name)===o)return e}return null}resolveApplyTarget(e){if("number"==typeof e.gameObjectId){const t=this.findGameObjectById(e.gameObjectId);if(t)return t}const t=e.source?.file?.trim(),n=e.source?.anchor?.trim();return t&&n?this.findGameObjectBySource({file:t,anchor:n}):null}handleApplyProperty(e){const t=e.componentName,n=e.path,o="number"==typeof e.gameObjectId,s=Boolean(e.source?.file?.trim())&&Boolean(e.source?.anchor?.trim());if(!o&&!s||"string"!=typeof t||!Array.isArray(n)||0===n.length)return;const i=this.resolveApplyTarget(e);if(!i)return;I(i,t,n,e.value)&&this.selected?.id===i.id&&(this.invalidateOutlineBounds(),this.updateSelectionOutline(),this.postSnapshotUpdate(i))}postSnapshotUpdate(e){const t=L(e);"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage({type:l,snapshot:t,pointer:null,source:"property-applied"},this.postMessageOrigin)}clearSelectionAndNotify(e){const t=null!=this.selected;this.clearSelection(),t&&this.postGameObjectDeselected(e)}postGameObjectDeselected(e){const t=W(e);"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(t,this.postMessageOrigin),this.game.emit(t.type,{reason:e})}clearSelection(){this.selected=null,this.invalidateOutlineBounds(),this.outlineGo?.parent&&this.outlineGo.remove();const e=this.outlineGo?.getComponent(o.Graphics);e?.graphics&&e.graphics.clear()}updateSelectionOutline(){if(!this.enabled||!this.selected||!this.outlineGo)return;const e=this.outlineGo.getComponent(o.Graphics);if(!e?.graphics)return;const t=this.resolvePickBounds(this.selected);if(this.lastOutlineBounds&&this.pickBoundsEqual(this.lastOutlineBounds,t))return;this.lastOutlineBounds=t;const n=e.graphics;n.clear(),n.rect(t.x,t.y,t.width,t.height),n.stroke({width:4,color:5636010,alpha:1})}invalidateOutlineBounds(){this.lastOutlineBounds=null}pickBoundsEqual(e,t){const n=.01;return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n&&Math.abs(e.width-t.width)<n&&Math.abs(e.height-t.height)<n}};Y=e.__decorate([t.decorators.componentObserver({CombosDevelopmentToolTarget:[]})],Y);var z=Y;Object.assign(z,{packageName:"@combos-fun/plugin-development-tool",packageVersion:"0.0.34"}),exports.COMBOS_DEVELOPMENT_TOOL_APPLY_PROPERTY=u,exports.COMBOS_DEVELOPMENT_TOOL_CLEAR_SELECTION=d,exports.COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_DESELECTED=h,exports.COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_SELECTED=l,exports.COMBOS_DEVELOPMENT_TOOL_MARKER_OVERLAY_SUCCESS=g,exports.COMBOS_DEVELOPMENT_TOOL_READY="combos-development-tool:ready",exports.COMBOS_DEVELOPMENT_TOOL_REFRESH=c,exports.COMBOS_DEVELOPMENT_TOOL_SET=r,exports.COMBOS_DEVELOPMENT_TOOL_SET_MARKER_OVERLAY=f,exports.COMBOS_DEVELOPMENT_TOOL_SET_MUTED=p,exports.COMBOS_DEVELOPMENT_TOOL_SET_SUCCESS=a,exports.COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED=m,exports.CombosDevelopmentToolSystem=z,exports.CombosDevelopmentToolTarget=y,exports.DEFAULT_ALLOWED_MESSAGE_HOST_SUFFIXES=E,exports.MARKER_COMPONENTS=O,exports.MARKER_ICON_SIZE=28,exports.applyPropertyValue=A,exports.applyPropertyWithHooks=I,exports.buildGameObjectDeselectedPayload=W,exports.buildGameObjectSnapshot=L,exports.drawMarkerIcon=v,exports.isAllowedMessageOrigin=M,exports.isClearSelectionMessage=q,exports.mergeAllowedMessageOrigins=S,exports.readPropertyValue=function(e,t,n){const o=e.getComponent(t);if(!o||!n.length)return;let s=o;for(const e of n){if(null==s||"object"!=typeof s)return;s=s[e]}return s},exports.readSourceAnchor=P,exports.resolveMarkerDef=b,exports.shouldNotifyGameObjectDeselected=V;
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),n=require("@combos-fun/plugin-renderer"),o=require("@combos-fun/plugin-renderer-graphics"),s=require("@combos-fun/plugin-renderer-event"),i=require("@combos-fun/inspector-decorator");const r="combos-development-tool:set",a="combos-development-tool:set-success",c="combos-development-tool:refresh",l="combos-development-tool:gameobject-selected",d="combos-development-tool:clear-selection",h="combos-development-tool:gameobject-deselected",u="combos-development-tool:apply-property",p="combos-development-tool:set-muted",m="combos-development-tool:state-changed",f="combos-development-tool:set-marker-overlay",g="combos-development-tool:marker-overlay-success";class y extends t.Component{constructor(){super(...arguments),this.payload={}}static{this.componentName="CombosDevelopmentToolTarget"}init(e){this.payload=e?.payload?{...e.payload}:{}}}const O=[{componentName:"Sound",badgeColor:9133302,glyph:"speaker"}];function b(e,t=O){for(const n of t)if(e.getComponent(n.componentName))return n;return null}const w=16777215;function v(e,t,n=28){if(function(e,t,n){e.clear(),e.roundRect(0,0,n,n,.22*n),e.fill({color:t.badgeColor,alpha:.92}),e.roundRect(0,0,n,n,.22*n),e.stroke({width:Math.max(1,.05*n),color:16777215,alpha:.6})}(e,t,n),"speaker"===t.glyph)!function(e,t){e.poly([.28*t,.4*t,.42*t,.4*t,.55*t,.26*t,.55*t,.74*t,.42*t,.6*t,.28*t,.6*t]),e.fill({color:w,alpha:.96}),e.rect(.62*t,.44*t,.045*t,.12*t),e.fill({color:w,alpha:.96}),e.rect(.71*t,.39*t,.045*t,.22*t),e.fill({color:w,alpha:.96})}(e,n);else!function(e,t){e.circle(.5*t,.5*t,.18*t),e.fill({color:w,alpha:.96})}(e,n)}const E=["knoffice.tech","converge.ai"];function M(e,t){if(t.includes("*"))return!0;if(0===t.length)return!1;let n;try{n=new URL(e)}catch{return!1}const o=e.toLowerCase(),s=n.hostname.toLowerCase();for(const e of t){const t=e.trim();if(!t)continue;if(t.includes("://")){if(o===t.toLowerCase())return!0;continue}const n=t.toLowerCase().replace(/^\./,"");if(s===n||s.endsWith(`.${n}`))return!0}return!1}function S(e){if(!e?.length)return[...E];if(e.includes("*"))return["*"];const t=new Set,n=[];for(const o of[...E,...e]){const e=o.trim();e&&!t.has(e)&&(t.add(e),n.push(e))}return n}function k(e){return"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null!==e&&"object"==typeof e?"object":"unsupported"}function G(e,t=0){if(null==e)return e;if("number"==typeof e||"string"==typeof e||"boolean"==typeof e)return e;if(!(t>6)){if(Array.isArray(e))return e.map(e=>G(e,t+1));if("object"==typeof e){const n={};for(const[o,s]of Object.entries(e)){if("function"==typeof s)continue;const e=G(s,t+1);void 0!==e&&(n[o]=e)}return n}}}function C(e){const t=e.constructor,n=function(e){const t=Reflect.getMetadata(i.IDE_PROPERTY_METADATA,e)||{};return Object.keys(t).map(e=>({key:e,...t[e]}))}(t);return n.length>0?n:function(e){const t=e.IDEProps;return!t||Array.isArray(t)||"object"!=typeof t?[]:Object.keys(t).map(e=>{const n=t[e]||{};return{key:e,type:"string"==typeof n.type?n.type:void 0,step:"number"==typeof n.step?n.step:void 0,min:"number"==typeof n.min?n.min:void 0,max:"number"==typeof n.max?n.max:void 0,label:"string"==typeof n.label?n.label:void 0,description:"string"==typeof n.description?n.description:void 0,group:"string"==typeof n.group?n.group:void 0,editor:n.editor,enumOptions:Array.isArray(n.enumOptions)?n.enumOptions:void 0,unit:"string"==typeof n.unit?n.unit:void 0}})}(t)}function T(e,t){return e.editor?e.editor:"boolean"===t?"toggle":e.enumOptions?.length&&"string"===t?"enum":"number"===t?void 0!==e.min&&void 0!==e.max?"number-slider":"number-stepper":"string"===t?"text":void 0}function _(e){if(void 0!==e.min||void 0!==e.max||void 0!==e.step||void 0!==e.unit)return{min:e.min,max:e.max,step:e.step,unit:e.unit}}function x(e,t){if(e.label?.trim())return e.label.trim();const n=t[t.length-1];return n?function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}(n):void 0}function R(e,t,n,o){const s=t.description?.trim();if(!s)return[];const i=k(o);if("unsupported"===i)return[];const r=t.type,a="size"===r||"object"===i&&null!==o&&"width"in o&&"height"in o;if("vector2"===r||"object"===i&&null!==o&&"x"in o&&"y"in o||a){const i=o,r=a?["width","height"]:["x","y"],c=x(t,n)??e,l=[];for(const o of r){const r=i[o],a=k(r);if("unsupported"===a||"object"===a)continue;const d=[...n,o];l.push({path:d,value:r,valueType:a,label:`${c} ${o.toUpperCase()}`,description:s,group:t.group??e,editorKind:T(t,a),numberMeta:_(t),persistTarget:"Transform"===e?"gameObjectConstructor":"component"})}return l}if("object"===i)return[];const c=x(t,n);return c?[{path:n,value:G(o),valueType:i,label:c,description:s,group:t.group??e,editorKind:T(t,i),enumOptions:t.enumOptions,numberMeta:_(t),persistTarget:"Transform"===e?"gameObjectConstructor":"component"}]:[]}function B(e){const t=e.name,n=C(e);if(0===n.length)return[];const o=[],s=e;for(const e of n){const n=s[e.key];"function"!=typeof n&&o.push(...R(t,e,[e.key],n))}return o}function P(e){const t=e.getComponent(y),n=t?.payload?.source;var o;if((o=n)&&"object"==typeof o&&"string"==typeof o.file)return{file:n.file,anchor:n.anchor??e.name}}function L(e){const t=e.components.filter(e=>"CombosDevelopmentToolTarget"!==e.name).map(e=>({componentName:e.name,fieldDescriptors:B(e)})).filter(e=>e.fieldDescriptors.length>0);return{id:e.id,name:e.name,components:t,source:P(e)}}function A(e,t,n,o){const s=e.getComponent(t);if(!s||!n.length)return!1;let i=s;for(let e=0;e<n.length-1;e++){const t=n[e];void 0!==i[t]&&null!==i[t]||(i[t]={}),i=i[t]}return i[n[n.length-1]]=o,!0}const j=new Set(["position","size","origin","anchor","scale","skew"]);function D(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}const N={Transform:function(e,t,n,o){const s=e.transform??t,i=s;if(1===n.length&&"rotation"===n[0]){const e=D(o);return void 0!==e&&(s.rotation=e,!0)}if(2===n.length&&j.has(n[0])){const t=n[0],s=n[1],r=D(o);if(void 0===r)return!1;const a=i[t];return!(!a||"object"!=typeof a)&&(a[s]=r,"position"===t&&(function(e){const t=e.getComponent("Physics");if(!t?.body)return;const{x:n,y:o}=e.transform.position;t.Body?.setPosition?t.Body.setPosition(t.body,{x:n,y:o}):(t.body.position.x=n,t.body.position.y=o)}(e),function(e){const t=e.getComponent("PlatformerMover");t&&(t.originX=e.transform.position.x,t.originY=e.transform.position.y)}(e)),!0)}return!1},Text:function(e,t,n,o){const s=t;if(1===n.length&&"text"===n[0])return s.text=String(o??""),!0;if(2===n.length&&"style"===n[0]){const e=n[1],t={...s.style??{},[e]:o};return s.style=t,!0}return!1},Sound:function(e,t,n,o){const s=t;if(1===n.length&&"volume"===n[0]||2===n.length&&"config"===n[0]&&"volume"===n[1]){const e=D(o);return void 0!==e&&(s.volume=e,!0)}return!1}};function I(e,t,n,o){const s=e.getComponent(t);if(!s||!n.length)return!1;const i=N[t];return!!i?.(e,s,n,o)||A(e,t,n,o)}function W(e){return{type:h,reason:e}}function V(e){return e}function q(e){return!(!e||"object"!=typeof e)&&e.type===d}const H="__combosDevelopmentToolOutline",U="__combosDevelopmentToolMarker:";let Y=class extends t.System{constructor(){super(...arguments),this.postMessageOrigin="*",this.allowedMessageOrigins=S(),this.enabled=!1,this.outlineGo=null,this.selected=null,this.tapHandlers=new Map,this.tapOwners=new Map,this.disabledGameEventGoIds=new Set,this.pickEvents=new Set,this.needsRescan=!1,this.lastOutlineBounds=null,this.mutedWithoutSoundSystem=!1,this.markerOverlayEnabled=!1,this.needsMarkerRescan=!1,this.markerGoByOwner=new Map,this.onWindowSet=e=>{const t=e.detail;t&&"boolean"==typeof t.enabled&&this.setEnabled(t.enabled)},this.onWindowSetMuted=e=>{const t=e.detail;t&&"boolean"==typeof t.muted&&this.setMuted(t.muted)},this.onWindowSetMarkerOverlay=e=>{const t=e.detail;t&&"boolean"==typeof t.enabled&&this.setMarkerOverlay(t.enabled)},this.onGameSetMarkerOverlay=e=>{e&&"boolean"==typeof e.enabled&&this.setMarkerOverlay(e.enabled)},this.onWindowMessage=e=>{if(!M(e.origin,this.allowedMessageOrigins))return;const t=e.data;t&&"object"==typeof t&&(t.type===r&&"boolean"==typeof t.enabled?this.setEnabled(t.enabled):t.type===p&&"boolean"==typeof t.muted?this.setMuted(t.muted):t.type===f&&"boolean"==typeof t.enabled?this.setMarkerOverlay(t.enabled):t.type===c?this.requestSceneRescan():q(t)?this.clearSelectionAndNotify("parent-request"):t.type===u&&this.handleApplyProperty(t))},this.onGameSet=e=>{e&&"boolean"==typeof e.enabled&&this.setEnabled(e.enabled)},this.onGameRefresh=()=>{this.requestSceneRescan()},this.onGameSetMuted=e=>{e&&"boolean"==typeof e.muted&&this.setMuted(e.muted)},this.onWindowRefresh=()=>{this.requestSceneRescan()}}static{this.systemName="CombosDevelopmentToolSystem"}init(e){this.postMessageOrigin=e?.postMessageOrigin??"*",this.allowedMessageOrigins=S(e?.allowedMessageOrigins),"undefined"!=typeof window&&(window.addEventListener(r,this.onWindowSet),window.addEventListener(p,this.onWindowSetMuted),window.addEventListener(f,this.onWindowSetMarkerOverlay),window.addEventListener(c,this.onWindowRefresh),window.addEventListener("message",this.onWindowMessage)),this.game.on(r,this.onGameSet),this.game.on(p,this.onGameSetMuted),this.game.on(f,this.onGameSetMarkerOverlay),this.game.on(c,this.onGameRefresh),this.enabled&&(this.needsRescan=!0)}onDestroy(){"undefined"!=typeof window&&(window.removeEventListener(r,this.onWindowSet),window.removeEventListener(p,this.onWindowSetMuted),window.removeEventListener(f,this.onWindowSetMarkerOverlay),window.removeEventListener(c,this.onWindowRefresh),window.removeEventListener("message",this.onWindowMessage)),this.game.off(r,this.onGameSet),this.game.off(p,this.onGameSetMuted),this.game.off(f,this.onGameSetMarkerOverlay),this.game.off(c,this.onGameRefresh),this.detachAllPicks(),this.detachAllMarkers(),this.restoreDisabledGameEvents(),this.clearSelectionAndNotify("pick-disabled")}setEnabled(e){this.enabled!==e&&(this.enabled=e,e?this.needsRescan=!0:(this.clearSelectionAndNotify("pick-disabled"),this.detachAllPicks(),this.restoreDisabledGameEvents(),this.postSetSuccess(!1)))}get isEnabled(){return this.enabled}setMarkerOverlay(e){this.markerOverlayEnabled!==e&&(this.markerOverlayEnabled=e,e?this.needsMarkerRescan=!0:(this.detachAllMarkers(),this.postMarkerOverlaySuccess(!1,[]),this.enabled&&(this.needsRescan=!0)))}get isMarkerOverlayEnabled(){return this.markerOverlayEnabled}get isMuted(){const e=this.getSoundSystem();return e?e.muted:this.mutedWithoutSoundSystem}setMuted(e){const t=this.getSoundSystem();t?t.muted=e:this.mutedWithoutSoundSystem=e,this.postStateChanged()}update(e){this.enabled&&this.needsRescan&&(this.needsRescan=!1,this.attachEditMode(),this.postSetSuccess(!0)),this.markerOverlayEnabled&&this.needsMarkerRescan&&(this.needsMarkerRescan=!1,this.attachMarkers());for(const e of[...this.tapOwners.values()])e.destroyed&&this.releasePick(e);for(const[e,t]of[...this.markerGoByOwner.entries()]){const n=this.findGameObjectById(e);(!n||n.destroyed||t.destroyed)&&this.removeMarker(e)}this.enabled&&this.selected&&this.outlineGo&&this.updateSelectionOutline()}componentChanged(e){if(!this.enabled)return;const{type:n,gameObject:o,componentName:s}=e;o&&"CombosDevelopmentToolTarget"===s&&(n===t.OBSERVER_TYPE.ADD?(this.stripGameEvent(o),this.ensurePick(o)):n===t.OBSERVER_TYPE.REMOVE&&(this.releasePick(o),this.selected===o&&this.clearSelectionAndNotify("target-removed")))}requestSceneRescan(){this.enabled&&(this.needsRescan=!0),this.markerOverlayEnabled&&(this.needsMarkerRescan=!0)}attachEditMode(){this.detachAllPicks();const e=[];for(const t of this.game.scene.transform.children)this.collectGameObjects(t.gameObject,e);for(const t of e)this.isIgnoredPickGo(t)||this.stripGameEvent(t);for(const t of e)this.isIgnoredPickGo(t)||t.getComponent(y)&&this.ensurePick(t)}collectGameObjects(e,t){t.push(e);for(const n of e.transform.children)this.collectGameObjects(n.gameObject,t)}isIgnoredPickGo(e){return e.name===H||e===this.outlineGo||this.isMarkerGo(e)}isMarkerGo(e){return"string"==typeof e.name&&e.name.startsWith(U)}stripGameEvent(e){if(this.disabledGameEventGoIds.has(e.id))return;if(!e.getComponent(s.Event))return;const t=this.getRendererContainer(e);if(t)try{t.interactive=!1,this.disabledGameEventGoIds.add(e.id)}catch{}}restoreDisabledGameEvents(){for(const e of[...this.disabledGameEventGoIds]){const t=this.findGameObjectById(e);if(!t||t.destroyed){this.disabledGameEventGoIds.delete(e);continue}const n=this.getRendererContainer(t);if(n)try{n.interactive=!0}catch{}this.disabledGameEventGoIds.delete(e)}}detachAllPicks(){for(const e of[...this.tapOwners.values()])this.releasePick(e)}ensurePick(e){if(this.tapHandlers.has(e.id))return;const t=this.getRendererContainer(e);if(t)try{t.interactive=!0}catch{}let n=e.getComponent(s.Event);n||(n=e.addComponent(this.createPickEvent(e)),this.pickEvents.add(e.id));const o=t=>this.onSelect(e,t);this.tapHandlers.set(e.id,o),this.tapOwners.set(e.id,e),n.on("tap",o)}createPickEvent(e){const t=this.resolvePickBounds(e);return t.width>0&&t.height>0?new s.Event({hitArea:{type:s.HIT_AREA_TYPE.Rect,style:{x:t.x,y:t.y,width:t.width,height:t.height}}}):new s.Event}resolvePickBounds(e){if(this.shouldPreferRenderedBounds(e)){const t=this.resolveOwnGraphicsLocalBounds(e);if(t)return t;const n=this.resolveContainerLocalBounds(e);if(n)return n}const{width:t,height:n}=e.transform.size;if(t>0&&n>0)return{x:0,y:0,width:t,height:n};const o=this.resolveContainerLocalBounds(e);return o||{x:0,y:0,width:1,height:1}}shouldPreferRenderedBounds(e){return null!=e.getComponent(o.Graphics)}resolveOwnGraphicsLocalBounds(e){const t=e.getComponent(o.Graphics);if(!t?.graphics)return null;try{const e=t.graphics.getLocalBounds();if(e.width>0&&e.height>0)return{x:e.x,y:e.y,width:e.width,height:e.height}}catch{}return null}resolveContainerLocalBounds(e){const t=this.getRendererContainer(e);if(!t)return null;const n=this.getOutlineContainerIfChildOf(e);let o=!1;n?.parent===t&&(t.removeChild(n),o=!0);try{const e=t.getLocalBounds();if(e.width>0&&e.height>0)return{x:e.x,y:e.y,width:e.width,height:e.height}}catch{}finally{o&&n&&t.addChild(n)}return null}getOutlineContainerIfChildOf(e){return this.outlineGo&&this.outlineGo.parent===e?this.getRendererContainer(this.outlineGo):null}getRendererContainer(e){const t=this.game.getSystem(n.RendererSystem);if(!t?.containerManager)return null;try{return t.containerManager.getContainer(e.id)}catch{return null}}releasePick(e){const t=this.tapHandlers.get(e.id);if(!t)return;const n=e.getComponent(s.Event);if(n?.off("tap",t),this.tapHandlers.delete(e.id),this.tapOwners.delete(e.id),this.pickEvents.has(e.id)){try{e.removeComponent(s.Event)}catch{}this.pickEvents.delete(e.id)}}postSetSuccess(e){const t={type:a,enabled:e};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(t,this.postMessageOrigin),this.game.emit(a,{enabled:e})}postStateChanged(){const e={muted:this.isMuted},t={type:m,...e};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(t,this.postMessageOrigin),this.game.emit(m,e)}attachMarkers(){this.detachAllMarkers();const e=[];for(const t of this.game.scene.transform.children)this.collectGameObjects(t.gameObject,e);const t=new Map;for(const n of e){if(this.isIgnoredPickGo(n))continue;const e=b(n);e&&(this.createMarker(n,e),t.set(e.componentName,(t.get(e.componentName)??0)+1))}const n=[...t.entries()].map(([e,t])=>({componentName:e,count:t}));this.postMarkerOverlaySuccess(!0,n),this.enabled&&(this.needsRescan=!0)}createMarker(e,n){if(this.markerGoByOwner.has(e.id))return;const s=this.resolvePickBounds(e),i=new t.GameObject(U+e.id,{size:{width:28,height:28},position:{x:s.x,y:s.y},origin:{x:0,y:0}}),r=i.addComponent(new o.Graphics);r?.graphics&&v(r.graphics,n,28),e.addChild(i),this.markerGoByOwner.set(e.id,i)}removeMarker(e){const t=this.markerGoByOwner.get(e);t&&(this.markerGoByOwner.delete(e),t.destroyed||t.destroy())}detachAllMarkers(){for(const e of[...this.markerGoByOwner.keys()])this.removeMarker(e);this.markerGoByOwner.clear()}postMarkerOverlaySuccess(e,t){const n={enabled:e,total:t.reduce((e,t)=>e+t.count,0),markers:t},o={type:g,...n};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(o,this.postMessageOrigin),this.game.emit(g,n)}getSoundSystem(){const e=this.game.getSystem("SoundSystem");return e&&"object"==typeof e&&"muted"in e&&"boolean"==typeof e.muted?e:null}ensureOutline(){if(this.outlineGo)return;const e=new t.GameObject(H,{size:{width:1,height:1},position:{x:0,y:0},origin:{x:0,y:0}});e.addComponent(new o.Graphics),this.outlineGo=e}onSelect(e,t){if(!this.enabled)return;if(t?.stopPropagation?.(),this.ensureOutline(),!this.outlineGo)return;this.selected=e,this.outlineGo.parent&&this.outlineGo.remove(),e.addChild(this.outlineGo),this.invalidateOutlineBounds(),this.updateSelectionOutline();const n=L(e),o={type:l,snapshot:n,pointer:t?.data?.position??null};"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(o,this.postMessageOrigin)}findGameObjectById(e){const t=[];for(const e of this.game.scene.transform.children)this.collectGameObjects(e.gameObject,t);return t.find(t=>t.id===e)??null}findGameObjectBySource(e){const t=[];for(const e of this.game.scene.transform.children)this.collectGameObjects(e.gameObject,t);const n=e.file.trim(),o=(e.anchor??"").trim();if(!o)return null;for(const e of t){const t=P(e);if(!t||t.file!==n)continue;if((t.anchor??e.name)===o)return e}return null}resolveApplyTarget(e){if("number"==typeof e.gameObjectId){const t=this.findGameObjectById(e.gameObjectId);if(t)return t}const t=e.source?.file?.trim(),n=e.source?.anchor?.trim();return t&&n?this.findGameObjectBySource({file:t,anchor:n}):null}handleApplyProperty(e){const t=e.componentName,n=e.path,o="number"==typeof e.gameObjectId,s=Boolean(e.source?.file?.trim())&&Boolean(e.source?.anchor?.trim());if(!o&&!s||"string"!=typeof t||!Array.isArray(n)||0===n.length)return;const i=this.resolveApplyTarget(e);if(!i)return;I(i,t,n,e.value)&&this.selected?.id===i.id&&(this.invalidateOutlineBounds(),this.updateSelectionOutline(),this.postSnapshotUpdate(i))}postSnapshotUpdate(e){const t=L(e);"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage({type:l,snapshot:t,pointer:null,source:"property-applied"},this.postMessageOrigin)}clearSelectionAndNotify(e){const t=null!=this.selected;this.clearSelection(),t&&this.postGameObjectDeselected(e)}postGameObjectDeselected(e){const t=W(e);"undefined"!=typeof window&&window.parent&&window.parent!==window&&window.parent.postMessage(t,this.postMessageOrigin),this.game.emit(t.type,{reason:e})}clearSelection(){this.selected=null,this.invalidateOutlineBounds(),this.outlineGo?.parent&&this.outlineGo.remove();const e=this.outlineGo?.getComponent(o.Graphics);e?.graphics&&e.graphics.clear()}updateSelectionOutline(){if(!this.enabled||!this.selected||!this.outlineGo)return;const e=this.outlineGo.getComponent(o.Graphics);if(!e?.graphics)return;const t=this.resolvePickBounds(this.selected);if(this.lastOutlineBounds&&this.pickBoundsEqual(this.lastOutlineBounds,t))return;this.lastOutlineBounds=t;const n=e.graphics;n.clear(),n.rect(t.x,t.y,t.width,t.height),n.stroke({width:4,color:5636010,alpha:1})}invalidateOutlineBounds(){this.lastOutlineBounds=null}pickBoundsEqual(e,t){const n=.01;return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n&&Math.abs(e.width-t.width)<n&&Math.abs(e.height-t.height)<n}};Y=e.__decorate([t.decorators.componentObserver({CombosDevelopmentToolTarget:[]})],Y);var z=Y;Object.assign(z,{packageName:"@combos-fun/plugin-development-tool",packageVersion:"0.0.36"}),exports.COMBOS_DEVELOPMENT_TOOL_APPLY_PROPERTY=u,exports.COMBOS_DEVELOPMENT_TOOL_CLEAR_SELECTION=d,exports.COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_DESELECTED=h,exports.COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_SELECTED=l,exports.COMBOS_DEVELOPMENT_TOOL_MARKER_OVERLAY_SUCCESS=g,exports.COMBOS_DEVELOPMENT_TOOL_READY="combos-development-tool:ready",exports.COMBOS_DEVELOPMENT_TOOL_REFRESH=c,exports.COMBOS_DEVELOPMENT_TOOL_SET=r,exports.COMBOS_DEVELOPMENT_TOOL_SET_MARKER_OVERLAY=f,exports.COMBOS_DEVELOPMENT_TOOL_SET_MUTED=p,exports.COMBOS_DEVELOPMENT_TOOL_SET_SUCCESS=a,exports.COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED=m,exports.CombosDevelopmentToolSystem=z,exports.CombosDevelopmentToolTarget=y,exports.DEFAULT_ALLOWED_MESSAGE_HOST_SUFFIXES=E,exports.MARKER_COMPONENTS=O,exports.MARKER_ICON_SIZE=28,exports.applyPropertyValue=A,exports.applyPropertyWithHooks=I,exports.buildGameObjectDeselectedPayload=W,exports.buildGameObjectSnapshot=L,exports.drawMarkerIcon=v,exports.isAllowedMessageOrigin=M,exports.isClearSelectionMessage=q,exports.mergeAllowedMessageOrigins=S,exports.readPropertyValue=function(e,t,n){const o=e.getComponent(t);if(!o||!n.length)return;let s=o;for(const e of n){if(null==s||"object"!=typeof s)return;s=s[e]}return s},exports.readSourceAnchor=P,exports.resolveMarkerDef=b,exports.shouldNotifyGameObjectDeselected=V;
|
|
@@ -1373,7 +1373,7 @@ var CombosDevelopmentToolSystem$1 = CombosDevelopmentToolSystem;
|
|
|
1373
1373
|
/** Auto-generated by scripts/build-package.mjs — do not edit. */
|
|
1374
1374
|
Object.assign(CombosDevelopmentToolSystem$1, {
|
|
1375
1375
|
packageName: "@combos-fun/plugin-development-tool",
|
|
1376
|
-
packageVersion: "0.0.
|
|
1376
|
+
packageVersion: "0.0.36",
|
|
1377
1377
|
});
|
|
1378
1378
|
|
|
1379
1379
|
export { COMBOS_DEVELOPMENT_TOOL_APPLY_PROPERTY, COMBOS_DEVELOPMENT_TOOL_CLEAR_SELECTION, COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_DESELECTED, COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_SELECTED, COMBOS_DEVELOPMENT_TOOL_MARKER_OVERLAY_SUCCESS, COMBOS_DEVELOPMENT_TOOL_READY, COMBOS_DEVELOPMENT_TOOL_REFRESH, COMBOS_DEVELOPMENT_TOOL_SET, COMBOS_DEVELOPMENT_TOOL_SET_MARKER_OVERLAY, COMBOS_DEVELOPMENT_TOOL_SET_MUTED, COMBOS_DEVELOPMENT_TOOL_SET_SUCCESS, COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, CombosDevelopmentToolSystem$1 as CombosDevelopmentToolSystem, CombosDevelopmentToolTarget, DEFAULT_ALLOWED_MESSAGE_HOST_SUFFIXES, MARKER_COMPONENTS, MARKER_ICON_SIZE, applyPropertyValue, applyPropertyWithHooks, buildGameObjectDeselectedPayload, buildGameObjectSnapshot, drawMarkerIcon, isAllowedMessageOrigin, isClearSelectionMessage, mergeAllowedMessageOrigins, readPropertyValue, readSourceAnchor, resolveMarkerDef, shouldNotifyGameObjectDeselected };
|