dsh-plugin-beyond-simulator 2.0.7 → 2.0.8
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/README.md +2 -2
- package/dsh-plugin/dist/client.js +6 -5
- package/dsh-plugin/lib/play.html +73 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ dsh plugin --profile web add dsh-plugin-beyond-simulator
|
|
|
95
95
|
# 或,从 GitHub 默认分支源码安装
|
|
96
96
|
dsh plugin --profile web add github:1475505/miliastra-beyond-simulator
|
|
97
97
|
# 或,从本地安装包安装
|
|
98
|
-
dsh plugin --profile web add ./release/dsh-plugin-beyond-simulator-2.0.
|
|
98
|
+
dsh plugin --profile web add ./release/dsh-plugin-beyond-simulator-2.0.8.tgz
|
|
99
99
|
|
|
100
100
|
dsh --profile web --dump-config
|
|
101
101
|
dsh web
|
|
@@ -152,7 +152,7 @@ GitHub 安装使用仓库默认分支,安装时由 `prepare` 自动构建。
|
|
|
152
152
|
1. 在“UI 编辑”页添加控件,调整属性,并切换 PC / 手机画布检查适配。
|
|
153
153
|
2. 在“Lua 脚本”页创建或导入脚本,将入口脚本挂载到客户端控件或客户端模板;模板脚本在模板实例化时运行。
|
|
154
154
|
3. 如果玩法需要服务端响应,在“服务端逻辑”页配置监听信号、设置变量和向玩家发送信号。
|
|
155
|
-
4. 点击“试玩
|
|
155
|
+
4. 点击“试玩 ↗”,在独立窗口中操作游戏;Desktop 等宿主拒绝新窗口时自动进入应用内全屏试玩。遇到问题时暂停、单步推进,并查看“日志”页中的脚本输出与运行状态。内嵌时通过“返回编辑”“关闭试玩”或 Escape 停止并返回。
|
|
156
156
|
5. 返回编辑器修改,再次试玩;需要检查多人交互时,调整试玩人数并切换玩家视角。
|
|
157
157
|
|
|
158
158
|
### 3. 让 AI 帮你测试
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
(()=>{function Ke(m){let x=m.createElement;return function({snap:$,request:e,patch:X,prepare:G,refresh:Y}){let D={version:1,workspaceDir:"",clientImportRoot:"",clientSubdir:""},[U,se]=m.useState($.scriptSync||D),[_,re]=m.useState($.storage?.path||"qxqy-simulator.save.json"),[fe,Q]=m.useState([]),[j,L]=m.useState(null),[A,oe]=m.useState([]),[R,V]=m.useState(null),[le,ce]=m.useState(""),[J,be]=m.useState(!1);m.useEffect(()=>{se($.scriptSync||D),L(null)},[JSON.stringify($.scriptSync),$.storage?.path]),m.useEffect(()=>{L(null)},[$.version,$.asset?.type]),m.useEffect(()=>{$.storage?.path&&re($.storage.path)},[$.storage?.path]);let E=async p=>{be(!0),ce("");try{await p()}catch(z){ce(z.message||String(z))}finally{be(!1)}},M=(p,z={})=>e("script-sync",{action:p,args:z});async function Ne(){L(null),V(null);let p=await G();await e("save",{path:_,expectedRevision:p.version}),await Y();let z=await M("preview");L(z),oe(z.rows.filter(O=>!O.error&&O.status!=="\u672A\u53D8\u5316").map(O=>O.id))}let F=JSON.stringify(U)!==JSON.stringify($.scriptSync||D),de=(p,z)=>x("label",{className:"qxsim-field",key:p},x("span",null,z),x("input",{type:"text",value:U[p],disabled:J,onChange:O=>{se({...U,[p]:O.target.value}),L(null)}})),pe=U.clientImportRoot.replaceAll("\\","/").match(/BeyondLocal\/([^/]+)\/Beyond_Local_Save_Level\/([^/]+)/),H=(p,z,O=!1)=>x("button",{type:"button",className:"qxsim-action",disabled:J||O,onClick:()=>void E(z)},p);return x("details",{className:"qxsim-section",style:{flexShrink:0,maxHeight:"55%",overflow:"auto",margin:"5px 10px"}},x("summary",null,`\u5B9E\u673A\u811A\u672C\u540C\u6B65 \xB7 ${$.scriptSync?"\u5DF2\u914D\u7F6E\uFF08\u624B\u52A8\u590D\u5236\uFF09":"\u672A\u914D\u7F6E"}`),x("div",{className:"qxsim-section-body"},x("p",null,"\u76EE\u5F55\u4F4D\u4E8E\u6A21\u62DF\u5668\u5BBF\u4E3B\u673A\u5668\u3002\u4FDD\u5B58\u5B58\u6863\u540E\u68C0\u67E5\u5DEE\u5F02\uFF0C\u786E\u8BA4\u624D\u590D\u5236\uFF1B\u4E4B\u540E\u8BF7\u5728\u5343\u661F\u6C99\u7BB1\u4FDD\u5B58\u5E76\u8BD5\u73A9\u3002\u65B0\u589E\u811A\u672C\u4ECD\u9700\u5EFA\u7ACB\u6620\u5C04\u3002"),de("workspaceDir","\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\uFF08\u76F8\u5BF9\u8DEF\u5F84\uFF1B\u7559\u7A7A\u8868\u793A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\uFF09"),de("clientImportRoot","\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\uFF08default_import_file \u7684\u5B8C\u6574\u8DEF\u5F84\uFF09"),de("clientSubdir","\u5B9E\u673A\u5BF9\u5E94\u5B50\u76EE\u5F55\uFF08\u901A\u5E38\u4E0E\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u76F8\u540C\uFF0C\u4FDD\u7559 GIA \u8DEF\u5F84\uFF09"),pe?x("p",null,`UID\uFF1A${pe[1]} \xB7 \u7F16\u8F91\u5668 ID\uFF1A${pe[2]}`):null,x("div",{style:{display:"flex",gap:6,flexWrap:"wrap"}},H("\u53D1\u73B0\u672C\u673A\u76EE\u5F55",async()=>{let p=await M("discover");Q(p.candidates),p.candidates.length||ce("\u672A\u53D1\u73B0\u76EE\u5F55\uFF0C\u53EF\u7C98\u8D34\u5B8C\u6574\u8DEF\u5F84\u3002")}),H("\u4FDD\u5B58\u76EE\u5F55\u914D\u7F6E",async()=>{await G();let p=await X({op:"setScriptSync",config:U});await e("save",{path:_,expectedRevision:p.version}),await Y(),L(null)},!U.clientImportRoot||!_.trim()),H("\u6E05\u9664\u914D\u7F6E",async()=>{await G();let p=await X({op:"setScriptSync",config:null});await e("save",{path:_,expectedRevision:p.version}),await Y(),L(null)},!$.scriptSync||!_.trim())),fe.length?x("label",{className:"qxsim-field"},"\u53D1\u73B0\u7684\u76EE\u5F55",x("select",{value:"",disabled:J,onChange:p=>{se({...U,clientImportRoot:p.target.value}),L(null)}},x("option",{value:""},"\u9009\u62E9 UID / \u7F16\u8F91\u5668\u2026"),fe.map(p=>x("option",{key:p.path,value:p.path},`${p.uid} / ${p.editorId} \xB7 ${p.path}`)))):null,x("label",{className:"qxsim-field",style:{marginTop:8}},x("span",null,"\u5B8C\u6574\u5B58\u6863\u4FDD\u5B58\u8DEF\u5F84"),x("input",{type:"text",value:_,disabled:J,onChange:p=>{re(p.target.value),L(null)}})),H("\u4FDD\u5B58\u5B58\u6863\u5E76\u68C0\u67E5\u5DEE\u5F02",Ne,!$.scriptSync||F||!_.trim()),F?x("p",null,"\u76EE\u5F55\u914D\u7F6E\u5DF2\u4FEE\u6539\uFF0C\u8BF7\u5148\u4FDD\u5B58\u76EE\u5F55\u914D\u7F6E\u3002"):null,le?x("p",{role:"alert",style:{color:"var(--danger)"}},le):null,j?x("section",{"aria-label":"\u811A\u672C\u540C\u6B65\u786E\u8BA4"},x("p",null,`\u76EE\u6807\u76EE\u5F55\uFF1A${j.root}`),j.pendingGuidChanges?x("p",{role:"alert"},"\u5C1A\u6709\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\u5F85\u6838\u5BF9\uFF0C\u8BF7\u5904\u7406\u5E76\u786E\u8BA4\u8BB0\u5F55\u540E\u518D\u540C\u6B65\u3002"):null,j.rows.map(p=>x("div",{key:p.id,style:{borderTop:"1px solid var(--line)",padding:6}},x("label",null,x("input",{type:"checkbox",disabled:J||!!p.error||p.status==="\u672A\u53D8\u5316",checked:A.includes(p.id),onChange:z=>oe(z.target.checked?[...A,p.id]:A.filter(O=>O!==p.id))}),` ${p.path} \xB7 ${p.sourceKind} \xB7 ${p.status}`),x("div",{style:{overflowWrap:"anywhere"}},p.error||`\u2192 ${p.target}`),p.sourceMismatch?x("div",{className:"qxsim-note"},"\u5B58\u6863\u6E90\u7801\u4E0E\u5DE5\u4F5C\u533A\u6587\u4EF6\u4E0D\u540C\uFF1B\u5F53\u524D\u4F7F\u7528\u5B58\u6863\u6E90\u7801\u3002",x("details",null,x("summary",null,"\u67E5\u770B\u5DE5\u4F5C\u533A\u6587\u4EF6"),x("pre",{style:{maxHeight:200,overflow:"auto"}},p.diskSource)),H("\u4ECE\u5DE5\u4F5C\u533A\u6587\u4EF6\u66F4\u65B0\u5B58\u6863\u6E90\u7801",async()=>{await G(),await X({op:"updateScript",id:p.id,source:p.diskSource}),L(null)})):null,!p.error&&p.status!=="\u672A\u53D8\u5316"?x("details",null,x("summary",null,"\u67E5\u770B\u590D\u5236\u524D\u540E\u5185\u5BB9"),x("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8}},x("div",null,"\u5B9E\u673A\u5F53\u524D\u5185\u5BB9",x("pre",{style:{maxHeight:240,overflow:"auto"}},p.beforeSource)),x("div",null,"\u5C06\u5199\u5165\u7684\u5185\u5BB9",x("pre",{style:{maxHeight:240,overflow:"auto"}},p.source)))):null)),x("p",null,`\u786E\u8BA4\u590D\u5236 ${A.length} \u4E2A\u811A\u672C\uFF0C\u5176\u4E2D\u8986\u76D6 ${j.rows.filter(p=>A.includes(p.id)&&p.status==="\u8986\u76D6").length} \u4E2A\u3002\u8986\u76D6\u524D\u5907\u4EFD\uFF0C\u4E0D\u5220\u9664\u5B9E\u673A\u989D\u5916\u6587\u4EF6\u3002`),x("div",{style:{display:"flex",gap:6}},H("\u53D6\u6D88",async()=>L(null)),H(`\u786E\u8BA4\u590D\u5236 ${A.length} \u4E2A\u811A\u672C`,async()=>{let p=j;L(null),await G(),V(await e("script-sync-apply",{planId:p.id,scriptIds:A,confirmed:!0}))},!A.length||!!j.pendingGuidChanges))):null,R?x("div",{role:"status"},x("strong",null,R.completed?"\u540C\u6B65\u5B8C\u6210":"\u90E8\u5206\u6587\u4EF6\u540C\u6B65\u5931\u8D25"),x("p",null,`${R.at} \xB7 \u5907\u4EFD\u4F4D\u7F6E\uFF1A${R.backupRoot}`),x("ul",null,R.results.map(p=>x("li",{key:p.id},`${p.target}\uFF1A${p.status}${p.error?` \xB7 ${p.error}`:""}`)))):null))}}function Ze(m,{api:x,playUrl:ge,saveToWorkspace:$=!1}){let e=m.createElement,X=Ke(m),G="qxqy-simulator-style",Y=`
|
|
1
|
+
(()=>{function Re(d){let u=d.createElement;return function({snap:L,request:e,patch:I,prepare:U,refresh:B}){let F={version:1,workspaceDir:"",clientImportRoot:"",clientSubdir:""},[M,ee]=d.useState(L.scriptSync||F),[j,W]=d.useState(L.storage?.path||"qxqy-simulator.save.json"),[Z,se]=d.useState([]),[O,b]=d.useState(null),[y,P]=d.useState([]),[$,J]=d.useState(null),[D,R]=d.useState(""),[S,me]=d.useState(!1);d.useEffect(()=>{ee(L.scriptSync||F),b(null)},[JSON.stringify(L.scriptSync),L.storage?.path]),d.useEffect(()=>{b(null)},[L.version,L.asset?.type]),d.useEffect(()=>{L.storage?.path&&W(L.storage.path)},[L.storage?.path]);let Ne=async m=>{me(!0),R("");try{await m()}catch(G){R(G.message||String(G))}finally{me(!1)}},_=(m,G={})=>e("script-sync",{action:m,args:G});async function K(){b(null),J(null);let m=await U();await e("save",{path:j,expectedRevision:m.version}),await B();let G=await _("preview");b(G),P(G.rows.filter(X=>!X.error&&X.status!=="\u672A\u53D8\u5316").map(X=>X.id))}let be=JSON.stringify(M)!==JSON.stringify(L.scriptSync||F),Q=(m,G)=>u("label",{className:"qxsim-field",key:m},u("span",null,G),u("input",{type:"text",value:M[m],disabled:S,onChange:X=>{ee({...M,[m]:X.target.value}),b(null)}})),ue=M.clientImportRoot.replaceAll("\\","/").match(/BeyondLocal\/([^/]+)\/Beyond_Local_Save_Level\/([^/]+)/),ie=(m,G,X=!1)=>u("button",{type:"button",className:"qxsim-action",disabled:S||X,onClick:()=>void Ne(G)},m);return u("details",{className:"qxsim-section",style:{flexShrink:0,maxHeight:"55%",overflow:"auto",margin:"5px 10px"}},u("summary",null,`\u5B9E\u673A\u811A\u672C\u540C\u6B65 \xB7 ${L.scriptSync?"\u5DF2\u914D\u7F6E\uFF08\u624B\u52A8\u590D\u5236\uFF09":"\u672A\u914D\u7F6E"}`),u("div",{className:"qxsim-section-body"},u("p",null,"\u76EE\u5F55\u4F4D\u4E8E\u6A21\u62DF\u5668\u5BBF\u4E3B\u673A\u5668\u3002\u4FDD\u5B58\u5B58\u6863\u540E\u68C0\u67E5\u5DEE\u5F02\uFF0C\u786E\u8BA4\u624D\u590D\u5236\uFF1B\u4E4B\u540E\u8BF7\u5728\u5343\u661F\u6C99\u7BB1\u4FDD\u5B58\u5E76\u8BD5\u73A9\u3002\u65B0\u589E\u811A\u672C\u4ECD\u9700\u5EFA\u7ACB\u6620\u5C04\u3002"),Q("workspaceDir","\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\uFF08\u76F8\u5BF9\u8DEF\u5F84\uFF1B\u7559\u7A7A\u8868\u793A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\uFF09"),Q("clientImportRoot","\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\uFF08default_import_file \u7684\u5B8C\u6574\u8DEF\u5F84\uFF09"),Q("clientSubdir","\u5B9E\u673A\u5BF9\u5E94\u5B50\u76EE\u5F55\uFF08\u901A\u5E38\u4E0E\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u76F8\u540C\uFF0C\u4FDD\u7559 GIA \u8DEF\u5F84\uFF09"),ue?u("p",null,`UID\uFF1A${ue[1]} \xB7 \u7F16\u8F91\u5668 ID\uFF1A${ue[2]}`):null,u("div",{style:{display:"flex",gap:6,flexWrap:"wrap"}},ie("\u53D1\u73B0\u672C\u673A\u76EE\u5F55",async()=>{let m=await _("discover");se(m.candidates),m.candidates.length||R("\u672A\u53D1\u73B0\u76EE\u5F55\uFF0C\u53EF\u7C98\u8D34\u5B8C\u6574\u8DEF\u5F84\u3002")}),ie("\u4FDD\u5B58\u76EE\u5F55\u914D\u7F6E",async()=>{await U();let m=await I({op:"setScriptSync",config:M});await e("save",{path:j,expectedRevision:m.version}),await B(),b(null)},!M.clientImportRoot||!j.trim()),ie("\u6E05\u9664\u914D\u7F6E",async()=>{await U();let m=await I({op:"setScriptSync",config:null});await e("save",{path:j,expectedRevision:m.version}),await B(),b(null)},!L.scriptSync||!j.trim())),Z.length?u("label",{className:"qxsim-field"},"\u53D1\u73B0\u7684\u76EE\u5F55",u("select",{value:"",disabled:S,onChange:m=>{ee({...M,clientImportRoot:m.target.value}),b(null)}},u("option",{value:""},"\u9009\u62E9 UID / \u7F16\u8F91\u5668\u2026"),Z.map(m=>u("option",{key:m.path,value:m.path},`${m.uid} / ${m.editorId} \xB7 ${m.path}`)))):null,u("label",{className:"qxsim-field",style:{marginTop:8}},u("span",null,"\u5B8C\u6574\u5B58\u6863\u4FDD\u5B58\u8DEF\u5F84"),u("input",{type:"text",value:j,disabled:S,onChange:m=>{W(m.target.value),b(null)}})),ie("\u4FDD\u5B58\u5B58\u6863\u5E76\u68C0\u67E5\u5DEE\u5F02",K,!L.scriptSync||be||!j.trim()),be?u("p",null,"\u76EE\u5F55\u914D\u7F6E\u5DF2\u4FEE\u6539\uFF0C\u8BF7\u5148\u4FDD\u5B58\u76EE\u5F55\u914D\u7F6E\u3002"):null,D?u("p",{role:"alert",style:{color:"var(--danger)"}},D):null,O?u("section",{"aria-label":"\u811A\u672C\u540C\u6B65\u786E\u8BA4"},u("p",null,`\u76EE\u6807\u76EE\u5F55\uFF1A${O.root}`),O.pendingGuidChanges?u("p",{role:"alert"},"\u5C1A\u6709\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\u5F85\u6838\u5BF9\uFF0C\u8BF7\u5904\u7406\u5E76\u786E\u8BA4\u8BB0\u5F55\u540E\u518D\u540C\u6B65\u3002"):null,O.rows.map(m=>u("div",{key:m.id,style:{borderTop:"1px solid var(--line)",padding:6}},u("label",null,u("input",{type:"checkbox",disabled:S||!!m.error||m.status==="\u672A\u53D8\u5316",checked:y.includes(m.id),onChange:G=>P(G.target.checked?[...y,m.id]:y.filter(X=>X!==m.id))}),` ${m.path} \xB7 ${m.sourceKind} \xB7 ${m.status}`),u("div",{style:{overflowWrap:"anywhere"}},m.error||`\u2192 ${m.target}`),m.sourceMismatch?u("div",{className:"qxsim-note"},"\u5B58\u6863\u6E90\u7801\u4E0E\u5DE5\u4F5C\u533A\u6587\u4EF6\u4E0D\u540C\uFF1B\u5F53\u524D\u4F7F\u7528\u5B58\u6863\u6E90\u7801\u3002",u("details",null,u("summary",null,"\u67E5\u770B\u5DE5\u4F5C\u533A\u6587\u4EF6"),u("pre",{style:{maxHeight:200,overflow:"auto"}},m.diskSource)),ie("\u4ECE\u5DE5\u4F5C\u533A\u6587\u4EF6\u66F4\u65B0\u5B58\u6863\u6E90\u7801",async()=>{await U(),await I({op:"updateScript",id:m.id,source:m.diskSource}),b(null)})):null,!m.error&&m.status!=="\u672A\u53D8\u5316"?u("details",null,u("summary",null,"\u67E5\u770B\u590D\u5236\u524D\u540E\u5185\u5BB9"),u("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8}},u("div",null,"\u5B9E\u673A\u5F53\u524D\u5185\u5BB9",u("pre",{style:{maxHeight:240,overflow:"auto"}},m.beforeSource)),u("div",null,"\u5C06\u5199\u5165\u7684\u5185\u5BB9",u("pre",{style:{maxHeight:240,overflow:"auto"}},m.source)))):null)),u("p",null,`\u786E\u8BA4\u590D\u5236 ${y.length} \u4E2A\u811A\u672C\uFF0C\u5176\u4E2D\u8986\u76D6 ${O.rows.filter(m=>y.includes(m.id)&&m.status==="\u8986\u76D6").length} \u4E2A\u3002\u8986\u76D6\u524D\u5907\u4EFD\uFF0C\u4E0D\u5220\u9664\u5B9E\u673A\u989D\u5916\u6587\u4EF6\u3002`),u("div",{style:{display:"flex",gap:6}},ie("\u53D6\u6D88",async()=>b(null)),ie(`\u786E\u8BA4\u590D\u5236 ${y.length} \u4E2A\u811A\u672C`,async()=>{let m=O;b(null),await U(),J(await e("script-sync-apply",{planId:m.id,scriptIds:y,confirmed:!0}))},!y.length||!!O.pendingGuidChanges))):null,$?u("div",{role:"status"},u("strong",null,$.completed?"\u540C\u6B65\u5B8C\u6210":"\u90E8\u5206\u6587\u4EF6\u540C\u6B65\u5931\u8D25"),u("p",null,`${$.at} \xB7 \u5907\u4EFD\u4F4D\u7F6E\uFF1A${$.backupRoot}`),u("ul",null,$.results.map(m=>u("li",{key:m.id},`${m.target}\uFF1A${m.status}${m.error?` \xB7 ${m.error}`:""}`)))):null))}}function Qe(d){let u=d.createElement,ae=new Map;function L({entry:e,api:I,onClosed:U}){let B=d.useRef(null),F=d.useRef(null),[M,ee]=d.useState(!1),[j,W]=d.useState(""),[Z,se]=d.useState(!1);d.useLayoutEffect(()=>{let b={closing:!1,stopped:!1,pending:null,controller:null,requests:new Set};F.current=b;let y=B.current,P=y.querySelector("iframe"),$=!0,J=()=>{if(b.stopped)return Promise.resolve();if(b.closing=!0,!b.controller)return b.stopped=!0,Promise.resolve();if(!b.pending){let S=(async()=>{b.controller?.quiesce(),await Promise.allSettled([...b.requests]),await I(e.sessionId,"play",{action:"stop",args:{}}),b.stopped=!0})().finally(()=>{b.pending=null,ae.get(e.sessionId)===S&&ae.delete(e.sessionId)});b.pending=S,ae.set(e.sessionId,S)}return b.pending};b.close=async()=>{if(!(b.pending||b.stopped)){ee(!0),W("");try{await J(),$&&U()}catch(S){$&&(W(`\u505C\u6B62\u8BD5\u73A9\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1A${S?.message||S}`),ee(!1))}}};let D=S=>{S.source!==P.contentWindow||S.data?.type!=="qxqy-play-close"||S.data.sessionId!==e.sessionId||b.close()},R=S=>{S.preventDefault(),b.close()};return window.addEventListener("message",D),y.addEventListener("cancel",R),y.showModal(),()=>{$=!1,window.removeEventListener("message",D),y.removeEventListener("cancel",R),y.close(),J().catch(S=>console.error("Embedded play cleanup failed",S)),e.returnFocus?.isConnected&&e.returnFocus.focus()}},[e,I,U]);function O(b){let y=F.current;if(!y.closing)try{let P=b.currentTarget,$=P.contentWindow?.qxqyEmbeddedPlay;if(!$)throw new Error("\u8BD5\u73A9\u9875\u672A\u80FD\u52A0\u8F7D\uFF0C\u8BF7\u8FD4\u56DE\u7F16\u8F91\u540E\u91CD\u8BD5\u3002");y.controller=$,se(!0),P.focus(),$.focus();let J=(D,R={})=>{if(y.closing)return Promise.reject(new Error("\u8BD5\u73A9\u6B63\u5728\u5173\u95ED"));let S=I(e.sessionId,"play",{action:D,args:R});return y.requests.add(S),S.then(()=>y.requests.delete(S),()=>y.requests.delete(S)),S};$.start(J).catch(D=>{y.closing||W(D?.message||String(D))})}catch(P){W(P?.message||String(P))}}return u("dialog",{ref:B,className:"qxsim-play-overlay","aria-label":"\u5185\u5D4C\u8BD5\u73A9","aria-modal":!0},u("header",{className:"qxsim-play-header"},u("span",{role:"status"},M?"\u6B63\u5728\u505C\u6B62\u8BD5\u73A9\u2026":Z?"\u5185\u5D4C\u8BD5\u73A9":"\u6B63\u5728\u8F7D\u5165\u8BD5\u73A9\u2026"),u("button",{className:"qxsim-action",type:"button",disabled:M,onClick:()=>void F.current?.close?.()},"\u5173\u95ED\u8BD5\u73A9")),j?u("div",{className:"qxsim-play-error",role:"alert"},j):null,u("iframe",{title:"\u5343\u661F\u6C99\u7BB1\u8BD5\u73A9",src:e.url,onLoad:O,tabIndex:0}))}return function({sessionId:I,api:U,playUrl:B,onError:F}){let M=d.useRef(null),[ee,j]=d.useState(!1),[W,Z]=d.useState(null),se=d.useCallback(()=>Z(null),[]);d.useEffect(()=>{let b={active:!0,pending:!1,popup:null};return M.current=b,j(!1),Z(null),()=>{b.active=!1,b.popup?.close()}},[I]);async function O(b){let y=M.current;if(!y?.active||y.pending||W)return;y.pending=!0;let P=document.activeElement;j(!0);try{let $=window.open("about:blank","_blank");if(y.popup=$,$&&$.document.write('<!doctype html><meta charset="utf-8"><title>\u6B63\u5728\u51C6\u5907\u8BD5\u73A9\u2026</title><p>\u6B63\u5728\u4FDD\u5B58\u9879\u76EE\u5E76\u51C6\u5907\u8BD5\u73A9\u2026</p>'),await ae.get(I),!y.active||(await b(),!y.active))return;let J=new URL(B(I),window.location.href);$?($.location.replace(J.href),y.popup=null):(J.searchParams.set("embedded","1"),Z({sessionId:I,url:J.href,returnFocus:P}))}catch($){y.popup?.close(),y.popup=null,y.active&&F($?.message||String($))}finally{y.pending=!1,y.active&&j(!1)}}return{open:O,opening:ee,overlay:W?.sessionId===I?u(L,{key:I,entry:W,api:U,onClosed:se}):null}}}function et(d,{api:u,playUrl:ae,saveToWorkspace:L=!1}){let e=d.createElement,I=Re(d),U=Qe(d),B="qxqy-simulator-style",F=`
|
|
2
2
|
.qxsim-save-overlay{position:absolute;inset:0;z-index:30;display:grid;place-items:center;background:#0006}.qxsim-save-dialog{width:min(440px,90%);padding:24px;border:1px solid var(--line);border-radius:12px;background:var(--panel);box-shadow:0 12px 48px #0005}.qxsim-save-dialog h2{margin:0 0 16px;font-size:17px}.qxsim-save-dialog input{width:100%;margin:8px 0 16px;padding:10px;border:1px solid var(--line);border-radius:6px;background:var(--input)}.qxsim-save-dialog footer{display:flex;justify-content:flex-end;gap:8px}.qxsim-save-dialog [role=alert]{color:var(--danger);margin-bottom:12px;overflow-wrap:anywhere}
|
|
3
|
+
.qxsim-play-overlay{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:var(--bg);color:var(--text)}.qxsim-play-overlay[open]{display:flex;flex-direction:column}.qxsim-play-overlay::backdrop{background:#0008}.qxsim-play-header{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;gap:12px;padding:4px 12px;border-bottom:1px solid var(--line);background:var(--panel)}.qxsim-play-overlay iframe{display:block;flex:1;width:100%;min-height:0;border:0;background:var(--bg)}.qxsim-play-error{padding:8px 12px;color:var(--danger);overflow-wrap:anywhere}html[data-windows-titlebar] .qxsim-play-overlay{top:40px;height:calc(100% - 40px)}
|
|
3
4
|
.qxsim{--blue:#477cf0;--danger:#e75a6a;position:relative;display:flex;flex:1 1 0;align-self:stretch;flex-direction:column;width:100%;height:100%;min-width:0;min-height:0;max-height:none;container-type:inline-size;color:var(--text);background:var(--bg);font:13px/1.4 Inter,"Microsoft YaHei UI","Microsoft YaHei",sans-serif;overflow:hidden;color-scheme:inherit}
|
|
4
5
|
.qxsim[data-theme=dark]{--bg:#20242e;--panel:#181d27;--panel2:#202632;--input:#151b25;--line:#363e4d;--lineSoft:#2b3240;--text:#edf1f7;--muted:#929baa;--hover:#252c37;--workspace:#383d47;--toolbarA:#242a35;--toolbarB:#1e232d;--status:#242a33;--button:#1d2430;--shadow:#0004}
|
|
5
6
|
.qxsim[data-theme=light]{--bg:#f5f6f8;--panel:#fff;--panel2:#f4f6f8;--input:#fff;--line:#d6dbe3;--lineSoft:#e7e9ed;--text:#20242a;--muted:#69717d;--hover:#eef1f5;--workspace:#d9dde3;--toolbarA:#fff;--toolbarB:#f3f5f8;--status:#f7f8fa;--button:#f7f8fa;--shadow:#18203318}
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
@container(max-width:1180px){.qxsim-toolbar{grid-template-columns:minmax(130px,1fr) auto auto;column-gap:8px}.qxsim-action{padding:0 8px}.qxsim-main{grid-template-columns:200px minmax(300px,1fr) 292px}.qxsim-control{min-width:132px}.qxsim-control.ratio{width:128px}.qxsim-io .qxsim-control{width:96px}.qxsim-device-switch button{padding:0 7px}.qxsim-workspace{padding-left:12px;padding-right:12px}.qxsim-brand-text span{display:none}.qxsim-asset-switch button{font-size:11px}}
|
|
23
24
|
@container(max-width:1000px){.qxsim-toolbar{height:90px;flex-basis:90px;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:42px 42px}.qxsim-toolbar-center{justify-self:end}.qxsim-actions{grid-column:1 / -1}.qxsim-editor-nav .save-summary{display:none}.qxsim-inspector{top:130px}}
|
|
24
25
|
@container(max-width:820px){.qxsim-main{grid-template-columns:180px minmax(280px,1fr)}.qxsim-inspector{position:absolute;right:0;top:130px;bottom:0;width:285px;z-index:5;box-shadow:-10px 0 24px var(--shadow)}.qxsim-script-page{grid-template-columns:190px minmax(320px,1fr)}.qxsim-script-editor{padding:12px}.qxsim-script-fields{grid-template-columns:1fr}}
|
|
25
|
-
`,D={"server-container":["\u25A3","\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"],container:["\u25A1","\u5BB9\u5668\u8282\u70B9"],textbox:["T","\u6587\u672C\u6846"],cursor:["\u2301","\u5149\u6807\u68C0\u6D4B\u533A\u57DF"],reference:["\u2197","\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"],grid:["\u25A6","\u7F51\u683C\u89C6\u7A97"],image:["\u25A7","\u56FE\u7247"],button:["Btn","\u9884\u8BBE\u6309\u94AE"],textwindow:["T\u2195","\u6587\u672C\u89C6\u7A97"],keyhint:["1","\u6309\u952E\u63D0\u793A"],animation:["\u2726","\u754C\u9762\u52A8\u6548"],fullscreen:["\u2725","\u5168\u5C4F\u52A8\u6548"]},U=[["container","\u5BB9\u5668\u8282\u70B9"],["textbox","\u6587\u672C\u6846"],["cursor","\u5149\u6807\u68C0\u6D4B"],["reference","\u6A21\u677F\u5F15\u7528"],["grid","\u7F51\u683C\u89C6\u7A97"],["button","\u9884\u8BBE\u6309\u94AE"],["textwindow","\u6587\u672C\u89C6\u7A97"],["keyhint","\u6309\u952E\u63D0\u793A"],["image","\u56FE\u7247"],["animation","\u754C\u9762\u52A8\u6548"],["fullscreen","\u5168\u5C4F\u52A8\u6548"]],se={container:["isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor"],textbox:["fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text"],cursor:[],reference:["referencedPrefabId"],grid:["cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount"],image:["imageSource","imageId","imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","enableFill","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount","reverseMaskArea"],button:["raycastTarget","interactable","unavailableChildId","hoverChildId","pressedChildId","selectedChildId","clickAudioId"],textwindow:["fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text"],keyhint:["keyboardKeyCode","controllerKeyCode"],animation:["animationId"],fullscreen:["animationId"]};function _(){if(document.getElementById(G))return;let t=document.createElement("style");t.id=G,t.textContent=Y,document.head.appendChild(t)}function re(){let t=document.documentElement,s=document.body,i=[t.dataset.theme,t.className,t.getAttribute("style"),s?.dataset?.theme,s?.className,s?.getAttribute("style"),getComputedStyle(t).colorScheme].filter(Boolean).join(" ").toLowerCase();return i.includes("dark")?"dark":i.includes("light")?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}function fe(){let[t,s]=m.useState(re);return m.useEffect(()=>{let i=()=>s(re()),n=new MutationObserver(i);n.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme"]}),document.body&&n.observe(document.body,{attributes:!0,attributeFilter:["class","style","data-theme"]});let o=window.matchMedia?.("(prefers-color-scheme: dark)");return o?.addEventListener?.("change",i),()=>{n.disconnect(),o?.removeEventListener?.("change",i)}},[]),t}function Q(t,s){let i=Number(t??s)>>>0;return`rgba(${i>>>16&255},${i>>>8&255},${i&255},${(i>>>24&255)/255})`}function j(t){return`#${(Number(t)>>>0).toString(16).padStart(8,"0").toUpperCase()}`}function L(t,s){return t==="circle"?{borderRadius:"50%",background:s}:t==="ring"?{borderRadius:"50%",border:`7px solid ${s}`,background:"transparent"}:t==="triangle"?{background:s,clipPath:"polygon(50% 0,100% 100%,0 100%)"}:t==="fourstar"?{background:s,clipPath:"polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%)"}:t==="fivestar"?{background:s,clipPath:"polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)"}:t==="missing"?{background:"#4822285c",border:"1px dashed #ff7481"}:{background:s}}let A=x;function oe(t){let s;try{s=atob(t.data)}catch{throw new Error("\u5BFC\u51FA\u5185\u5BB9\u89E3\u7801\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u6216\u5237\u65B0\u9875\u9762")}let i=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)i[c]=s.charCodeAt(c);let n=URL.createObjectURL(new Blob([i],{type:t.mimeType||"application/octet-stream"})),o=document.createElement("a");o.href=n,o.download=t.filename||"qxqy-export",o.rel="noopener",o.style.display="none",document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function R(t){let s=new Uint8Array(await t.arrayBuffer()),i="",n=32768;for(let o=0;o<s.length;o+=n)i+=String.fromCharCode(...s.subarray(o,o+n));return btoa(i)}let V=t=>typeof t=="object"?t.value:t,le=t=>typeof t=="object"?t.label:t,ce=[{key:"KEYBOARD",label:"PC",title:"PC KEYBOARD \u753B\u5E03\uFF1A1600\xD7900 / 2100\xD7900"},{key:"TOUCHSCREEN",label:"\u624B\u673A",title:"\u624B\u673A TOUCHSCREEN \u753B\u5E03\uFF1A1280\xD7720 / 1560\xD7720 / 1280\xD7960"}];function J(t){return String(t.id||"").split("-").slice(1).join(":")}function be(t,s){let i=(o,c)=>c?i(c,o%c):o,n=i(Math.round(t),Math.round(s))||1;return`${Math.round(t)/n}:${Math.round(s)/n}`}function E({field:t,commit:s,axis:i}){let n=t.type==="color"?j(t.value):t.value==null?"":String(t.value),[o,c]=m.useState(n);if(m.useEffect(()=>c(t.type==="color"?j(t.value):t.value==null?"":String(t.value)),[t.value,t.type]),t.type==="note")return e("div",{className:"qxsim-note"},t.value||t.label);if(t.readonly&&(t.evidence==="N"||t.evidence==="U"))return e("div",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label),e("div",{className:"qxsim-unsupported"},t.value==null?"\u5C1A\u65E0\u53EF\u7F16\u8F91\u503C":String(t.value)));if(t.type==="bool")return e("div",{className:"qxsim-switch-row"},e("span",null,t.label),e("label",{className:"qxsim-switch"},e("input",{type:"checkbox",checked:!!t.value,disabled:!!t.readonly,onChange:l=>s(t.key,l.target.checked)}),e("span",{className:"qxsim-switch-track"})));if(t.type==="enum"){let l=[...t.options||[]],b=String(t.value??"");return l.some(v=>String(V(v))===b)||l.unshift({value:t.value??"",label:`\u672A\u8BC6\u522B\u9009\u9879 ${t.unknownValue??(b||"\u7A7A")}\uFF08\u4FDD\u7559\u539F\u503C\uFF09`}),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label),e("select",{value:b,disabled:!!t.readonly,onChange:v=>s(t.key,v.target.value)},l.map(v=>e("option",{key:String(V(v)),value:V(v)},le(v)))))}if(t.type==="percent"){let l=Math.round(Number(t.value||0)*100);return e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label),e("span",{className:"qxsim-percent"},e("input",{type:"range",min:0,max:100,value:l,onInput:b=>s(t.key,Number(b.target.value)/100)}),e("output",null,`${l}%`)))}if(t.type==="color"){let l=/^#[0-9a-f]{8}$/i.test(o)?o:j(t.value);return e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label,e("small",null,"ARGB")),e("span",{className:"qxsim-color-row"},e("span",{className:"qxsim-color-swatch",title:"\u6253\u5F00\u53D6\u8272\u5668"},e("input",{type:"color",value:`#${l.slice(3)}`,onInput:b=>{let v=`#${l.slice(1,3)}${b.target.value.slice(1).toUpperCase()}`;c(v),s(t.key,v)}})),e("input",{type:"text",value:o,spellCheck:!1,"aria-label":`${t.label} ARGB`,onChange:b=>c(b.target.value),onBlur:()=>s(t.key,o),onKeyDown:b=>{b.key==="Enter"&&b.currentTarget.blur(),b.key==="Escape"&&c(j(t.value))}})))}let g={value:o,disabled:!!t.readonly,readOnly:!!t.readonly,onChange:l=>c(l.target.value),onBlur:()=>{t.readonly||s(t.key,o)},onKeyDown:l=>{l.key==="Enter"&&t.type!=="text"&&l.currentTarget.blur(),l.key==="Escape"&&c(t.value==null?"":String(t.value))}};return e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},i?e("b",{className:`qxsim-axis ${i.toLowerCase()}`},i):null,t.label),t.type==="text"?e("textarea",{...g,rows:4}):e("input",{...g,type:t.type==="number"?"number":"text",step:t.type==="number"?"any":void 0}))}function M({title:t,open:s=!0,children:i}){return e("details",{className:"qxsim-section",open:s},e("summary",null,t),e("div",{className:"qxsim-section-body"},i))}function Ne(t){let s={};for(let i of t||[])s[i.key]=i;return s}function F({label:t,x:s,y:i,xAxis:n="X",yAxis:o="Y",commit:c}){return e("div",{className:"qxsim-pair"},e("div",{className:"qxsim-pair-name"},t),e(E,{field:s,axis:n,commit:c}),e(E,{field:i,axis:o,commit:c}))}function de({field:t,commit:s,createStateChild:i}){return e("div",{className:"qxsim-state-field"},e("div",{className:"qxsim-state-label"},t.label),e("div",{className:"qxsim-state-ref"},e("button",{title:`\u65B0\u5EFA\u5E76\u7ED1\u5B9A${t.label}\u56FE\u7247`,onClick:()=>i(t.key,t.label)},"+"),e("select",{value:String(t.value??""),"aria-label":t.label,onChange:n=>s(t.key,n.target.value)},(t.options||[]).map(n=>e("option",{key:String(V(n)),value:V(n)},le(n))))))}function pe({inspector:t,commit:s,createStateChild:i}){let n=Ne(t.fields),o=b=>b?.type==="node"?e(de,{key:b.key,field:b,commit:s,createStateChild:i}):b?e(E,{key:b.key,field:b,commit:s}):null,c=(se[t.kind]||[]).map(b=>n[b]).filter(Boolean).map(o),g=null;if(t.kind==="image"){let b=n.fillType?.value==="Horizontal"?n.fillHorizontalType:n.fillType?.value==="Vertical"?n.fillVerticalType:n.fillType?.value==="Radial90"?n.fillRadial90Type:n.fillRadialType,v=[o(n.enableMask),o(n.enableSoftEdge),n.enableSoftEdge?.value?e("div",{className:"qxsim-subfields",key:"soft-fields"},o(n.softEdgeMode),e(F,{label:"\u7FBD\u5316\u5BBD\u5EA6",x:n.softEdgeWidthX,y:n.softEdgeWidthY,commit:s}),e(F,{label:"\u7FBD\u5316\u8303\u56F4",x:n.horizontalSoftRange,y:n.verticalSoftRange,commit:s})):null,o(n.enableFill),n.enableFill?.value?e("div",{className:"qxsim-subfields",key:"fill-fields"},o(n.fillType),o(b),o(n.fillAmount)):null,o(n.reverseMaskArea)];g=e(m.Fragment,null,e(M,{title:"\u56FE\u7247\u8BBE\u7F6E"},o(n.imageSource),o(n.imageId),o(n.imageColor)),e(M,{title:"\u906E\u7F69\u8BBE\u7F6E"},v))}let l=t.kind==="textbox"?"\u6587\u672C\u6846\u8BBE\u7F6E":t.kind==="button"?"\u6309\u94AE\u8BBE\u7F6E":`${t.label}\u8BBE\u7F6E`;return e(m.Fragment,null,e(M,{title:"\u8282\u70B9\u4FE1\u606F",open:!1},e(E,{field:n.name,commit:s})),e(M,{title:"\u53D8\u6362"},n.posX?e(F,{label:"\u4F4D\u7F6E",x:n.posX,y:n.posY,commit:s}):null,n.width?e(F,{label:"\u5927\u5C0F",x:n.width,y:n.height,xAxis:"W",yAxis:"H",commit:s}):null,n.rotationZ?e(E,{field:n.rotationZ,commit:s}):null,n.syncAllDevices?e(E,{field:n.syncAllDevices,commit:s}):null,n.anchorType?e(E,{field:n.anchorType,commit:s}):null,n.anchorMinX?e(F,{label:"Min",x:n.anchorMinX,y:n.anchorMinY,commit:s}):null,n.anchorMaxX?e(F,{label:"Max",x:n.anchorMaxX,y:n.anchorMaxY,commit:s}):null,n.pivotX?e(F,{label:"\u4E2D\u5FC3",x:n.pivotX,y:n.pivotY,commit:s}):null),e(M,{title:"\u521B\u5EFA\u8BBE\u7F6E"},n.active?e(E,{field:n.active,commit:s}):null,n.visible?e(E,{field:n.visible,commit:s}):null),g||(c.length?e(M,{title:l},c):null),n.canControllerFocus?e(M,{title:"\u624B\u67C4\u5BFC\u822A",open:!1},e(E,{field:n.canControllerFocus,commit:s})):null,n.incomplete?e(M,{title:"\u5B9E\u73B0\u72B6\u6001"},e(E,{field:n.incomplete,commit:s})):null)}function H({snap:t,selectedScriptId:s,selectScript:i,draft:n,updateDraft:o,saveScript:c,addScript:g,removeScript:l,exportLua:b,exportScripts:v,exportScriptsGia:S,notice:B}){let y=t.scripts||[],u=y.find(h=>h.id===s)||null,w=t.mountTargets||[],k=w.filter(h=>h.assetType==="server-control-template"),q=w.filter(h=>h.assetType==="client-control-template"),W=h=>{let I=w.find(ee=>ee.id===h);return I?`${I.assetLabel} \xB7 ${I.name}`:""};return e("div",{className:"qxsim-script-page"},e("aside",{className:"qxsim-script-assets"},e("h3",null,`\u5B58\u6863\u5185 Lua \u811A\u672C\uFF08${y.length}\uFF09`),e("button",{className:"qxsim-action",style:{width:"100%",marginBottom:8},onClick:g},"\uFF0B \u65B0\u5EFA\u811A\u672C"),y.length?y.map(h=>e("div",{key:h.id,className:"qxsim-script-list-row"},e("button",{className:`qxsim-script-asset${h.id===s?" active":""}`,onClick:()=>i(h.id)},e("strong",null,h.path||"(\u672A\u547D\u540D\u811A\u672C)"),e("small",null,h.mounted?`\u6302\u8F7D\uFF1A${h.assetLabel} \xB7 ${h.controlName}`:"\u672A\u6302\u8F7D\uFF08\u4EC5\u53EF\u88AB require\uFF09")),e("button",{className:"qxsim-iconbtn",title:"\u4E0B\u8F7D\u8BE5\u811A\u672C .lua",onClick:()=>b(h.id)},"\u21E9"),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u8BE5\u811A\u672C",onClick:()=>l(h.id)},"\u2715"))):e("div",{className:"qxsim-empty"},"\u8FD8\u6CA1\u6709\u811A\u672C\uFF0C\u70B9\u51FB\u201C\u65B0\u5EFA\u811A\u672C\u201D\u5F00\u59CB")),e("main",{className:"qxsim-script-editor"},u&&n?e(m.Fragment,null,e("div",{className:"qxsim-script-title"},e("div",null,e("h2",null,n.path||"(\u672A\u547D\u540D\u811A\u672C)"),e("span",null,`\u5C5E\u4E8E\u5B58\u6863\u201C${t.save?.name||"\u672A\u547D\u540D\u5B58\u6863"}\u201D \xB7 Lua \u811A\u672C\u662F\u5B58\u6863\u5185\u72EC\u7ACB\u8D44\u4EA7`)),e("span",null,`\u811A\u672C ${u.id}`)),e("div",{className:"qxsim-script-fields"},e("label",null,"\u811A\u672C\u8DEF\u5F84\uFF08\u5DE5\u4F5C\u533A\u76F8\u5BF9\u8DEF\u5F84\uFF09",e("input",{type:"text",value:n.path,placeholder:"lua/example.lua",onChange:h=>o({path:h.target.value})})),e("label",null,"\u6302\u8F7D\u76EE\u6807\uFF08\u5BA2\u6237\u7AEF\u63A7\u4EF6 / \u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\uFF09",e("select",{value:n.controlId?`${n.controlAsset||"server-control-template"}|${n.controlId}`:"",onChange:h=>{let[I,ee]=h.target.value.split("|");o(ee?{controlId:ee,controlAsset:I}:{controlId:"",controlAsset:""})}},e("option",{value:""},"\u672A\u6302\u8F7D\uFF08\u4E0D\u751F\u6548\uFF0C\u4EC5\u53EF\u88AB require\uFF09"),e("optgroup",{label:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F \xB7 \u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668\u5185"},k.map(h=>e("option",{key:h.id,value:`${h.assetType}|${h.id}`},`${h.name} \xB7 ${h.id}`))),q.length?e("optgroup",{label:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"},q.map(h=>e("option",{key:h.id,value:`${h.assetType}|${h.id}`},`${h.name} \xB7 ${h.id}`))):null))),e("label",null,"Lua \u6E90\u7801",e("textarea",{value:n.source,spellCheck:!1,placeholder:"-- \u5728\u8FD9\u91CC\u8F93\u5165\u5BA2\u6237\u7AEF Lua\uFF1B\u811A\u672C\u53EA\u6709\u6302\u8F7D\u5230\u5BA2\u6237\u7AEF\u63A7\u4EF6\u540E\u624D\u4F1A\u5728\u8BD5\u73A9\u65F6\u751F\u6548",onChange:h=>o({source:h.target.value})})),e("div",{className:"qxsim-script-footer"},e("span",null,n.dirty?"\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539":B||(u.mounted?`\u5DF2\u6302\u8F7D\uFF1A${W(u.controlId)}`:"\u5F53\u524D\u672A\u6302\u8F7D\uFF0C\u8BD5\u73A9\u65F6\u4E0D\u4F1A\u81EA\u52A8\u8FD0\u884C")),e("span",{className:"spacer"}),e("button",{className:"qxsim-action",onClick:v},"\u21E9 \u811A\u672C\u5305 JSON"),e("button",{className:"qxsim-action",onClick:S},"\u21E9 \u811A\u672C\u5305 GIA"),e("button",{className:"qxsim-action primary",disabled:!n.dirty,onClick:c},"\u4FDD\u5B58\u811A\u672C"))):e("div",{className:"qxsim-empty"},"\u8BF7\u65B0\u5EFA\u6216\u9009\u62E9\u4E00\u4E2A\u811A\u672C")))}function p(t){if(t===void 0)return"null";try{return JSON.stringify(t)}catch{return String(t)}}function z(t){let s=String(t??"").trim();if(!s)return null;try{return JSON.parse(s)}catch{return s}}function O(t){return!!(t&&typeof t=="object"&&!Array.isArray(t)&&Object.prototype.hasOwnProperty.call(t,"fromSignalParam"))}function De(t){return{version:1,dirty:!1,rules:(Array.isArray(t?.rules)?t.rules:[]).map((i,n)=>({id:String(i.id||`signal-${n+1}`),signalName:String(i.signalName||""),actions:Array.isArray(i.actions)&&i.actions.length?i.actions.map(o=>tt(o)):[me("setCustomVariable")]}))}}let Be=["PlayerSelf","AllPlayers","Player1","Player2","Player3","Player4","Player5","Player6","Player7","Player8"],Fe=["PlayerSelf","Level","Player1","Player2","Player3","Player4","Player5","Player6","Player7","Player8"],Ue={PlayerSelf:"PlayerSelf \u5F53\u524D\u73A9\u5BB6",AllPlayers:"AllPlayers \u5168\u90E8\u73A9\u5BB6",Level:"Level \u5173\u5361",Player1:"Player1 \u73A9\u5BB61",Player2:"Player2 \u73A9\u5BB62",Player3:"Player3 \u73A9\u5BB63",Player4:"Player4 \u73A9\u5BB64",Player5:"Player5 \u73A9\u5BB65",Player6:"Player6 \u73A9\u5BB66",Player7:"Player7 \u73A9\u5BB67",Player8:"Player8 \u73A9\u5BB68"};function Se(t){return Fe.includes(t)&&t!=="AllPlayers"?t:t==="Level"?"Level":"PlayerSelf"}function Ce(t){return Be.includes(t)?t:"PlayerSelf"}function me(t){return t==="sendClientScriptSignal"?{kind:"sendClientScriptSignal",target:"PlayerSelf",signalName:"",params:[]}:{kind:"setCustomVariable",entityType:"PlayerSelf",name:"",value:0}}function Qe(t){return{version:1,rules:(t?.rules||[]).map(s=>({id:String(s.id||""),signalName:String(s.signalName||"").trim(),actions:(s.actions||[]).map(i=>i?.kind==="sendClientScriptSignal"?{kind:"sendClientScriptSignal",target:Ce(i.target),signalName:String(i.signalName||"").trim(),params:Array.isArray(i.params)?i.params:[]}:{kind:"setCustomVariable",entityType:Se(i?.entityType),name:String(i?.name||"").trim(),value:i&&Object.prototype.hasOwnProperty.call(i,"value")?i.value:0})}))}}function et(t){let s=[];for(let[i,n]of(t?.rules||[]).entries()){String(n.signalName||"").trim()||s.push(`\u89C4\u5219 ${i+1} \u9700\u8981\u76D1\u542C\u4FE1\u53F7\u540D`);let o=n.actions||[];o.length||s.push(`\u89C4\u5219 ${i+1} \u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u52A8\u4F5C`);for(let[c,g]of o.entries())g?.kind==="sendClientScriptSignal"?String(g.signalName||"").trim()||s.push(`\u89C4\u5219 ${i+1} \u52A8\u4F5C ${c+1} \u9700\u8981\u5BA2\u6237\u7AEF\u4FE1\u53F7\u540D`):String(g?.name||"").trim()||s.push(`\u89C4\u5219 ${i+1} \u52A8\u4F5C ${c+1} \u9700\u8981\u53D8\u91CF\u540D`)}return s}function tt(t){if(t?.kind==="sendClientScriptSignal")return{kind:"sendClientScriptSignal",target:Ce(t.target),signalName:String(t.signalName||""),params:Array.isArray(t.params)?t.params.map(i=>{try{return JSON.parse(JSON.stringify(i))}catch{return i}}):[]};let s=0;if(t&&Object.prototype.hasOwnProperty.call(t,"value"))try{s=JSON.parse(JSON.stringify(t.value))}catch{s=t.value}return{kind:"setCustomVariable",entityType:Se(t?.entityType),name:String(t?.name||""),value:s}}function _e({label:t,value:s,onChange:i}){let n=O(s),[o,c]=m.useState(()=>n?"":p(s));return m.useEffect(()=>{O(s)||c(p(s))},[s]),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t),e("select",{value:n?"param":"literal","aria-label":`${t}\u6765\u6E90`,onChange:g=>{g.target.value==="param"?i({fromSignalParam:Number(s?.fromSignalParam)||0}):i(z(o||"0"))}},e("option",{value:"literal"},"\u5B57\u9762\u91CF\uFF08JSON\uFF09"),e("option",{value:"param"},"\u5F15\u7528\u76D1\u542C\u4FE1\u53F7\u53C2\u6570")),n?e("input",{type:"number",min:0,step:1,value:Number(s.fromSignalParam)||0,"aria-label":`${t}\u53C2\u6570\u5E8F\u53F7`,onChange:g=>i({fromSignalParam:Math.max(0,Math.trunc(Number(g.target.value)||0))})}):e("textarea",{className:"qxsim-logic-json",value:o,spellCheck:!1,"aria-label":`${t}\u5B57\u9762\u91CF`,onBlur:()=>i(z(o)),onChange:g=>c(g.target.value)}))}function at({params:t,onChange:s}){let i=Array.isArray(t)?t:[];return e("div",{className:"qxsim-field wide"},e("span",{className:"qxsim-field-label"},"\u5BA2\u6237\u7AEF\u4FE1\u53F7\u53C2\u6570\uFF08\u6309\u6DFB\u52A0\u987A\u5E8F\uFF09"),i.length?i.map((n,o)=>e("div",{key:o,style:{display:"flex",gap:6,alignItems:"flex-start",marginBottom:6}},e("div",{style:{flex:1,minWidth:0}},e(_e,{label:`\u53C2\u6570 ${o}`,value:n,onChange:c=>s(i.map((g,l)=>l===o?c:g))})),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u53C2\u6570",onClick:()=>s(i.filter((c,g)=>g!==o))},"\u2715"))):e("div",{className:"qxsim-muted"},"\u6682\u65E0\u53C2\u6570\uFF0C\u53EF\u53D1\u9001\u7A7A\u53C2\u6570\u5217\u8868"),e("button",{className:"qxsim-action",style:{marginTop:4},onClick:()=>s(i.concat([0]))},"\uFF0B \u6DFB\u52A0\u53C2\u6570"))}function it({snap:t,draft:s,setDraft:i,saveLogic:n,notice:o,error:c}){let g=s?.rules||[];function l(y){i({version:1,rules:y,dirty:!0})}function b(){l(g.concat([{id:`signal-${Date.now().toString(36)}`,signalName:"",actions:[me("setCustomVariable")]}]))}function v(y,u){l(g.map((w,k)=>k===y?{...w,...u}:w))}function S(y,u,w){let k=g[y];k&&v(y,{actions:k.actions.map((q,W)=>W===u?{...q,...w}:q)})}function B(y,u,w){S(y,u,me(w))}return e("div",{className:"qxsim-server-logic"},e("div",{className:"qxsim-logic-wrap"},e("div",{className:"qxsim-logic-title"},e("div",null,e("h2",null,"\u670D\u52A1\u7AEF\u903B\u8F91"),e("p",null,`\u5C5E\u4E8E\u5B58\u6863\u201C${t.save?.name||"\u672A\u547D\u540D\u5B58\u6863"}\u201D \xB7 \u76D1\u542C\u5BA2\u6237\u7AEF\u4FE1\u53F7\u540E\u8BBE\u7F6E Level / \u73A9\u5BB6\u53D8\u91CF\uFF0C\u6216\u5411\u6307\u5B9A\u73A9\u5BB6\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7`)),e("button",{className:"qxsim-action primary",disabled:!s?.dirty,onClick:n},"\u4FDD\u5B58\u670D\u52A1\u7AEF\u903B\u8F91")),e("div",{className:"qxsim-note"},"\u8FD9\u662F\u6A21\u62DF\u5668\u5B58\u6863\u683C\u5F0F\uFF0C\u4E0D\u662F\u5B98\u65B9\u8282\u70B9\u56FE\u3002PlayerSelf \u8868\u793A\u53D1\u4FE1\u53F7\u7684\u90A3\u4F4D\u73A9\u5BB6\uFF1BPlayer1\u20138 \u662F\u56FA\u5B9A\u5EA7\u4F4D\uFF1BAllPlayers \u5411\u672C\u5C40\u5168\u90E8\u8BD5\u73A9\u73A9\u5BB6\u5E7F\u64AD\u3002"),c?e("div",{className:"qxsim-logic-error"},c):null,g.length?g.map((y,u)=>e("section",{key:y.id||u,className:"qxsim-logic-rule"},e("div",{className:"qxsim-logic-rule-head"},e("strong",null,`\u89C4\u5219 ${u+1}`),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u76D1\u542C\u4FE1\u53F7\u540D"),e("input",{type:"text",value:y.signalName,placeholder:"EarnGold","aria-label":`\u89C4\u5219 ${u+1} \u76D1\u542C\u4FE1\u53F7\u540D`,onChange:w=>v(u,{signalName:w.target.value})})),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u89C4\u5219",onClick:()=>l(g.filter((w,k)=>k!==u))},"\u2715")),e("div",{className:"qxsim-logic-actions"},(y.actions||[]).map((w,k)=>e("div",{key:k,className:"qxsim-logic-action"},e("div",{className:"qxsim-logic-action-head"},e("strong",null,`\u52A8\u4F5C ${k+1}`),e("select",{value:w.kind,"aria-label":`\u89C4\u5219 ${u+1} \u52A8\u4F5C ${k+1} \u7C7B\u578B`,onChange:q=>B(u,k,q.target.value)},e("option",{value:"setCustomVariable"},"\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF"),e("option",{value:"sendClientScriptSignal"},"\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7")),e("span",null,w.kind==="sendClientScriptSignal"?"\u53D1\u7ED9\u5F53\u524D\u73A9\u5BB6\u3001\u6307\u5B9A\u73A9\u5BB6\u6216\u5168\u90E8\u73A9\u5BB6":"\u5199\u5165 Level / \u5F53\u524D\u73A9\u5BB6 / \u73A9\u5BB61-8"),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u52A8\u4F5C",disabled:(y.actions||[]).length<=1,onClick:()=>v(u,{actions:y.actions.filter((q,W)=>W!==k)})},"\u2715")),w.kind==="sendClientScriptSignal"?e("div",{className:"qxsim-logic-fields"},e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u53D1\u9001\u76EE\u6807"),e("select",{value:Ce(w.target),onChange:q=>S(u,k,{target:q.target.value})},Be.map(q=>e("option",{key:q,value:q},Ue[q])))),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u5BA2\u6237\u7AEF\u4FE1\u53F7\u540D"),e("input",{type:"text",value:w.signalName,placeholder:"GoldChanged",onChange:q=>S(u,k,{signalName:q.target.value})})),e(at,{params:w.params,onChange:q=>S(u,k,{params:q})})):e("div",{className:"qxsim-logic-fields"},e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u5B9E\u4F53"),e("select",{value:Se(w.entityType),onChange:q=>S(u,k,{entityType:q.target.value})},Fe.map(q=>e("option",{key:q,value:q},Ue[q])))),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u53D8\u91CF\u540D"),e("input",{type:"text",value:w.name,placeholder:"Gold",onChange:q=>S(u,k,{name:q.target.value})})),e("div",{className:"wide"},e(_e,{label:"\u53D8\u91CF\u503C",value:w.value,onChange:q=>S(u,k,{value:q})}))))),e("div",{className:"qxsim-logic-actions-foot"},e("button",{className:"qxsim-action",onClick:()=>v(u,{actions:(y.actions||[]).concat([me("setCustomVariable")])})},"\uFF0B \u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF"),e("button",{className:"qxsim-action",onClick:()=>v(u,{actions:(y.actions||[]).concat([me("sendClientScriptSignal")])})},"\uFF0B \u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7"))))):e("div",{className:"qxsim-logic-empty"},"\u8FD8\u6CA1\u6709\u76D1\u542C\u89C4\u5219\u3002\u8BD5\u73A9\u65F6\u5BA2\u6237\u7AEF SendSignal \u4E0D\u4F1A\u81EA\u52A8\u6539\u53D8\u91CF\u6216\u56DE\u4F20\u4FE1\u53F7\u3002"),e("div",{className:"qxsim-logic-actions-foot"},e("button",{className:"qxsim-action",onClick:b},"\uFF0B \u6DFB\u52A0\u76D1\u542C\u89C4\u5219")),e("div",{className:"qxsim-script-footer",style:{marginTop:16}},e("span",null,s?.dirty?"\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539":o||"\u4FDD\u5B58\u540E\u4F1A\u5199\u5165\u5F53\u524D\u5B58\u6863\uFF0C\u4E0B\u6B21\u8BD5\u73A9\u751F\u6548"),e("span",{className:"spacer"}))))}function nt({inspector:t,onSave:s}){let[i,n]=m.useState(String(t.guid??"")),[o,c]=m.useState(!1),[g,l]=m.useState("");m.useEffect(()=>{n(String(t.guid??"")),l("")},[t.guid]);async function b(v){v.preventDefault();let S=i.trim();if(!/^[0-9]+$/.test(S)||Number(S)<1||Number(S)>2147483647){l("\u8BF7\u8F93\u5165 1\u20132147483647 \u4E4B\u95F4\u7684\u6574\u6570\u7D22\u5F15\u3002");return}c(!0),l("");try{await s(t.id,Number(S))}catch(B){l(B?.message||String(B))}finally{c(!1)}}return e("form",{onSubmit:b,style:{marginTop:8}},e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15"),e("div",{style:{display:"flex",gap:6}},e("input",{type:"text",inputMode:"numeric","aria-label":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15",value:i,disabled:o,onChange:v=>{n(v.target.value),l("")},onKeyDown:v=>{v.key==="Escape"&&(n(String(t.guid)),l(""))}}),e("button",{type:"submit",className:"qxsim-action",disabled:o||i.trim()===String(t.guid)},o?"\u4FDD\u5B58\u4E2D":"\u4FEE\u6539"))),g?e("div",{role:"alert",className:"qxsim-note"},g):null,e("div",{className:"qxsim-muted",style:{lineHeight:1.5}},"\u586B\u5199 GIA \u5BFC\u5165\u540E\u5B9E\u9645\u663E\u793A\u7684\u7D22\u5F15\uFF1B\u4FEE\u6539\u540E\u987B\u8BA9 AI \u540C\u6B65 Lua \u811A\u672C\u4E2D\u7684\u5F15\u7528\u3002"))}function st({snap:t,addScriptMounted:s,mountScriptTo:i,unmountScript:n,openScript:o}){let c=(t.scripts||[]).filter(l=>l.controlId===t.selectedId),g=(t.scripts||[]).filter(l=>l.controlId!==t.selectedId);return e(m.Fragment,null,e(M,{title:"\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6\u7684\u811A\u672C"},c.length?c.map(l=>e("div",{key:l.id,className:"qxsim-script-list-row"},e("button",{className:"qxsim-script-asset",onClick:()=>o(l.id)},e("strong",null,l.path||"(\u672A\u547D\u540D\u811A\u672C)"),e("small",null,`\u811A\u672C ${l.id}`)),e("button",{className:"qxsim-iconbtn",title:"\u89E3\u9664\u6302\u8F7D\uFF08\u4FDD\u7559\u811A\u672C\uFF09",onClick:()=>n(l.id)},"\u292B"))):e("div",{className:"qxsim-note"},"\u8BE5\u63A7\u4EF6\u5C1A\u672A\u6302\u8F7D\u811A\u672C\u3002\u811A\u672C\u6302\u8F7D\u5230\u5BA2\u6237\u7AEF\u63A7\u4EF6\u540E\u624D\u4F1A\u5728\u8BD5\u73A9\u65F6\u751F\u6548\u3002")),e(M,{title:"\u6302\u8F7D\u5DF2\u6709\u811A\u672C",open:!1},g.length?e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u9009\u62E9\u811A\u672C\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6"),e("select",{value:"","aria-label":"\u9009\u62E9\u811A\u672C\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6",onChange:l=>{let b=l.target.value;l.target.value="",b&&i(b)}},e("option",{value:""},"\u9009\u62E9\u811A\u672C\u2026"),g.map(l=>e("option",{key:l.id,value:l.id},`${l.path||"(\u672A\u547D\u540D\u811A\u672C)"} \xB7 ${l.id}${l.mounted?`\uFF08\u5F53\u524D\u6302\u8F7D\u4E8E ${l.assetLabel} \xB7 ${l.controlName}\uFF0C\u5C06\u79FB\u52A8\u5230\u6B64\u63A7\u4EF6\uFF09`:"\uFF08\u672A\u6302\u8F7D\uFF09"}`)))):e("div",{className:"qxsim-note"},"\u5B58\u6863\u5185\u8FD8\u6CA1\u6709\u5176\u4ED6\u811A\u672C\uFF0C\u53EF\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u65B0\u5EFA\u3002"),e("div",{className:"qxsim-script-actions",style:{marginTop:8}},e("button",{onClick:()=>s(t.selectedId)},"\uFF0B \u65B0\u5EFA\u811A\u672C\u5E76\u6302\u8F7D\u5230\u6B64\u63A7\u4EF6"))))}function rt(t,s){let i=null,n=null;function o(c,g){c.id===s&&(i=c,n=g);for(let l of c.children||[])o(l,c)}if(o(t,null),i?.kind==="container")return i.id;if(i?.kind==="server-container")return i.children?.find(c=>c.kind==="container")?.id||i.id;for(;n&&n.kind!=="container";){let g=function(l){for(let b of l.children||[])b===n&&(c=l),g(b)},c=null;g(t),n=c}return n?.id||t.children?.find(c=>c.kind==="container")?.id}function ot(t,s){let i=null;function n(o){o.id===s&&(i=o);for(let c of o.children||[])n(c)}return n(t),i&&i.kind!=="server-container"?i.id:rt(t,s)}function lt(t,s,i,n){let o=t,c=t.kind,g=c==="textbox"||c==="textwindow",l=o.renderLeft??o.left,b=o.renderBottom??o.bottom,v=o.renderWidth??o.width,S=o.renderHeight??o.height,B=o.renderRotationZ??t.rotationZ??0,y={left:`${l/i*100}%`,bottom:`${b/n*100}%`,width:`${v/i*100}%`,height:`${S/n*100}%`,"--rotation":`${-Number(B)}deg`,fontSize:Math.max(8,Math.min(40,Number(t.fontSize||12))),color:g?Q(t.fontColor,4294967295):"#fff"};c==="image"?Object.assign(y,L(t.primitive,Q(t.imageColor,4294967295))):g?(y.background=Q(t.bgColor,16777215),y.justifyContent=t.horizontalAlignment==="Right"?"flex-end":t.horizontalAlignment==="Middle"?"center":"flex-start",y.alignItems=t.verticalAlignment==="Bottom"?"flex-end":t.verticalAlignment==="Middle"?"center":"flex-start",y.textShadow=t.enableOutline===!1?"none":`0 0 2px ${Q(t.outlineColor,4278190080)}`):c==="container"&&(y.background="transparent");let u=t.id===s.selectedId,w=g?t.text||"":c==="image"&&t.primitive==="missing"?e("span",{className:"qxsim-box-label"},`\u7F3A\u5C11\u56FE\u7247 ${t.imageId||""}`):c!=="container"&&c!=="image"?e("span",{className:"qxsim-box-label"},t.name||D[c]?.[1]||c):null;return e("div",{key:t.id,className:`qxsim-box ${c}${u?" selected":""}${t.instantiated?" dynamic":""}${t.pressed?" pressed":""}`,style:y},w,u&&c!=="container"?["tl","tr","bl","br"].map(k=>e("i",{key:k,className:`qxsim-handle ${k}`})):null)}function ct({sessionId:t}){let s=fe(),[i,n]=m.useState(null),o=m.useRef(null),c=m.useRef(Promise.resolve()),[g,l]=m.useState(""),[b,v]=m.useState(null),[S,B]=m.useState(!1),[y,u]=m.useState(""),w=m.useRef(null),[k,q]=m.useState([]),[W,h]=m.useState([]),[I,ee]=m.useState("ui"),[$e,Ae]=m.useState("base"),[Pe,dt]=m.useState("fit"),[ze,pt]=m.useState({}),[he,Le]=m.useState(""),[te,Ie]=m.useState("template"),[Te,ve]=m.useState(""),[Ee,ue]=m.useState(null),[He,Me]=m.useState({version:1,rules:[],dirty:!1}),Ye=m.useRef(null),[ye,mt]=m.useState({width:0,height:0});m.useEffect(()=>{let a=Ye.current;if(!a||typeof ResizeObserver>"u")return;let r=new ResizeObserver(d=>{let f=d[0]?.contentRect;f&&f.width>0&&mt({width:f.width,height:f.height})});return r.observe(a),()=>r.disconnect()},[i?.canvas?.id]);function ae(a,{keepLogicDraft:r=!0}={}){return o.current=a,n(a),a?.scripts&&ve(d=>a.scripts.some(f=>f.id===d)?d:a.scripts[0]?.id||""),Me(d=>r&&d?.dirty?d:De(a?.serverLogic)),a}let qe=m.useCallback(async()=>{try{l(""),ae(await A(t,"get"),{keepLogicDraft:!1})}catch(a){l(a?.message||String(a))}},[t]),we=m.useCallback(async()=>{try{let a=await A(t,"archives");h(a?.archives||[])}catch{h([])}},[t]);m.useEffect(()=>{qe(),we()},[qe,we]);function C(a,r=""){let d=async()=>{let f=o.current;if(!f)throw new Error("editor is not ready");try{if(r&&f.asset?.type!==r)throw new Error("\u5F53\u524D\u8D44\u4EA7\u5DF2\u5207\u6362\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u63A7\u4EF6\u540E\u4FEE\u6539\u7D22\u5F15");let T=await A(t,"patch",{op:{...a,expectedRevision:f.version}});return l(""),ae(T)}catch(T){throw l(T?.message||String(T)),/revision conflict/.test(String(T?.message||T))&&await qe(),T}};return c.current=c.current.then(d,d),c.current}async function ut(a,r,d){await C({op:"setControlGuid",id:a,guid:r},d),u("\u63A7\u4EF6\u7D22\u5F15\u5DF2\u4FEE\u6539\uFF1B\u8BF7\u8BA9 AI \u6839\u636E\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u540C\u6B65 Lua \u811A\u672C\u5F15\u7528\u3002")}async function xt(){let d=["\u8BF7\u540C\u6B65\u5F53\u524D\u6A21\u62DF\u5668\u5DE5\u7A0B\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\uFF1A",...(o.current?.controlGuidChanges||[]).map(f=>`${f.controlAsset} / ${f.controlName}\uFF08${f.controlId}\uFF09\uFF1A${f.oldGuid} \u2192 ${f.newGuid}\uFF1B\u8BB0\u5F55 ${f.id}`),"\u5148\u8BFB\u53D6\u6700\u65B0\u5FEB\u7167\u7684 controlGuidChanges\uFF0C\u6309\u63A7\u4EF6\u8EAB\u4EFD\u548C\u53D8\u66F4\u987A\u5E8F\u6838\u5BF9\u5168\u90E8 Lua \u811A\u672C\u7684\u7D22\u5F15\u5E38\u91CF\u3001\u914D\u7F6E\u8868\u4E0E\u8C03\u7528\uFF0C\u4FEE\u6539\u5B58\u6863\u4E2D\u7684 source \u53CA\u76F8\u5173 Lua \u6E90\u6587\u4EF6\u3002\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\uFF0C\u4E5F\u4E0D\u8981\u6539\u8FD0\u884C\u65F6\u5B9E\u4F8B ID \u6216\u56FE\u7247\u8D44\u6E90 ID\u3002","\u68C0\u67E5\u65E7\u7D22\u5F15\u5F15\u7528\u5E76\u91CD\u65B0\u8BD5\u73A9\uFF1B\u786E\u8BA4\u5B8C\u6210\u540E\u7528 acknowledgeControlGuidChanges \u7684 changeIds \u6E05\u9664\u5DF2\u6838\u5BF9\u8BB0\u5F55\uFF0C\u518D\u4FDD\u5B58\u5B8C\u6574\u5B58\u6863\u3002"].join(`
|
|
26
|
-
`);try{await navigator.clipboard.writeText(
|
|
27
|
-
`)),
|
|
28
|
-
${i.meta?.sourceFile||"\u5C1A\u672A\u5BFC\u5165\u6587\u4EF6"}`},e("span",{className:"qxsim-appicon"},"UI"),e("span",{className:"qxsim-brand-text"},e("strong",null,`\u5B58\u6863\uFF1A${i.save?.name||i.meta?.name||"\u672A\u547D\u540D\u5B58\u6863"}`),e("span",null,`\u5DE5\u4F5C\u533A\uFF1A${i.workspace?.bound?i.workspace.name:"\u672A\u7ED1\u5B9A"} \xB7 \u5F53\u524D\u8D44\u4EA7\uFF1A${i.asset?.label||"UI\u63A7\u4EF6"}`))),e("div",{className:"qxsim-toolbar-center"},I==="ui"?e(m.Fragment,null,e("div",{className:"qxsim-device-switch",role:"group","aria-label":"\u76EE\u6807\u8BBE\u5907"},ce.map(a=>e("button",{key:a.key,className:i.canvas.platform===a.key?"active":"",title:a.title,onClick:()=>Lt(a.key)},a.label))),e("select",{className:"qxsim-control ratio","aria-label":"\u5C4F\u5E55\u6BD4\u4F8B",value:i.canvasId,onChange:a=>void C({op:"setCanvas",canvasId:a.target.value}).catch(()=>{})},zt.map(a=>e("option",{key:a.id,value:a.id},`${J(a)} \xB7 ${a.width}\xD7${a.height}`))),e("select",{className:"qxsim-control zoom","aria-label":"\u753B\u5E03\u7F29\u653E",value:Pe,onChange:a=>dt(a.target.value)},[["fit","\u9002\u5E94"],["0.25","25%"],["0.5","50%"],["0.75","75%"],["1","100%"]].map(([a,r])=>e("option",{key:a,value:a},r)))):e("span",{className:"qxsim-muted"},I==="logic"?"\u670D\u52A1\u7AEF\u903B\u8F91\uFF1A\u76D1\u542C\u4FE1\u53F7 / \u81EA\u5B9A\u4E49\u53D8\u91CF / \u73A9\u5BB61-8 \u56DE\u4F20":"Lua \u811A\u672C\u8D44\u4EA7\u7F16\u8F91")),e("div",{className:"qxsim-actions"},$?e("button",{className:"qxsim-action",title:"\u4FDD\u5B58\u5B8C\u6574\u5B58\u6863\u5230\u5DE5\u4F5C\u533A",onClick:()=>{l(""),v(o.current?.storage?.path||"qxqy-simulator.save.json")}},"\u4FDD\u5B58\u5B58\u6863"):null,e("div",{className:"qxsim-io"},e("input",{ref:w,hidden:!0,type:"file",accept:".json,.gia,.lua,application/json,application/octet-stream,text/plain",onChange:a=>void St(a.target.files?.[0])}),e("select",{className:"qxsim-control zoom","aria-label":"\u4ECE\u5DE5\u4F5C\u533A\u62C9\u53D6\u5B58\u6863",defaultValue:"",onFocus:()=>void we(),onChange:a=>{let r=a.target.value;a.target.value="",r&&Nt(r)}},e("option",{value:"",disabled:!0},i.workspace?.bound?"\u2913 \u5DE5\u4F5C\u533A\u5B58\u6863":"\u5DE5\u4F5C\u533A\u672A\u7ED1\u5B9A"),...W.length?W.map(a=>e("option",{key:a.path,value:a.path},`${a.name} \xB7 ${a.path}`)):[e("option",{value:"",disabled:!0},i.workspace?.bound?"\u672A\u53D1\u73B0 qxqy-simulator-save":"\u5148\u7ED1\u5B9A\u4F1A\u8BDD\u5DE5\u4F5C\u533A")]),e("button",{className:"qxsim-action",title:"\u5BFC\u5165\u5B58\u6863\u3001\u5355\u9879 UI \u8D44\u4EA7\u6216 Lua",onClick:()=>w.current?.click()},"\u21E7 \u5BFC\u5165"),e("select",{className:"qxsim-control zoom","aria-label":"\u5BFC\u51FA\u683C\u5F0F",defaultValue:"",onChange:a=>{let[r,d=""]=a.target.value.split("|");a.target.value="",r&&ke(r,d)}},e("option",{value:"",disabled:!0},"\u21E9 \u5BFC\u51FA"),e("option",{value:"save"},"\u8D44\u4EA7\u5305 JSON\uFF08\u4E09\u7C7B\u5408\u4E00\uFF09"),e("option",{value:"save-gia"},"\u8D44\u4EA7\u5305 GIA\uFF08\u5DF2\u6539\u52A8\u9879\uFF09"),e("option",{value:"gia-combined"},"\u8D44\u4EA7\u5305 GIA \u6574\u5408\u5305\uFF08\u63A7\u4EF6+\u811A\u672C\uFF09"),e("optgroup",{label:"\u5F53\u524D\u754C\u9762\uFF08\u5DE6\u680F\u6B63\u5728\u770B\u7684\u90A3\u68F5\u6811\uFF09"},e("option",{value:"json"},"\u5F53\u524D\u754C\u9762 Authoring JSON"),e("option",{value:"gia"},"\u5F53\u524D\u754C\u9762 GIA")),e("optgroup",{label:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F"},e("option",{value:"json|server-control-template"},"Authoring JSON"),e("option",{value:"gia|server-control-template"},"GIA")),e("optgroup",{label:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\uFF08\u4EC5\u5F53\u5DE6\u680F\u5207\u5230\u300CUI\u63A7\u4EF6-\u5BA2\u6237\u7AEF\u300D\u65F6\u624D\u662F\u9875\u9762\u5185\u5BB9\uFF09"},e("option",{value:"json|client-control-template"},"Authoring JSON"),e("option",{value:"gia|client-control-template"},"GIA")),e("optgroup",{label:"Lua \u811A\u672C"},e("option",{value:"scripts"},"\u811A\u672C\u5305 JSON\uFF08\u5168\u90E8\u811A\u672C\uFF09"),e("option",{value:"scripts-gia"},"\u811A\u672C\u5305 GIA\uFF08\u5168\u90E8\u811A\u672C\uFF09")))),e("button",{className:"qxsim-action primary",title:"\u5728\u72EC\u7ACB\u6807\u7B7E\u9875\u4E2D\u8BD5\u73A9",onClick:Ct},"\u25B7 \u8BD5\u73A9 \u2197"),e("button",{className:"qxsim-iconbtn",title:"\u91CD\u65B0\u8F7D\u5165",onClick:qe},"\u21BB"))),e("nav",{className:"qxsim-editor-nav","aria-label":"\u7F16\u8F91\u9875\u9762"},e("button",{className:I==="ui"?"active":"",onClick:()=>xe("ui")},"UI \u7F16\u8F91"),e("button",{className:I==="script"?"active":"",onClick:()=>xe("script")},"Lua \u811A\u672C"),e("button",{className:I==="logic"?"active":"",onClick:()=>xe("logic")},"\u670D\u52A1\u7AEF\u903B\u8F91"),e("span",{className:"save-summary"},"\u4E00\u4E2A\u5B58\u6863 \xB7 \u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F + \u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F + Lua \u811A\u672C + \u670D\u52A1\u7AEF\u903B\u8F91")),I==="script"?e(X,{snap:i,patch:C,request:(a,r)=>A(t,a,r),refresh:async()=>ae(await A(t,"get")),prepare:async()=>(await c.current,await K(),await ie(),o.current)}):null,i.controlGuidChanges?.length?e("details",{className:"qxsim-note",open:!0,style:{flexShrink:0,maxHeight:170,overflow:"auto"}},e("summary",{style:{cursor:"pointer"}},`\u5F85\u540C\u6B65 Lua \u7D22\u5F15\u5F15\u7528\uFF08${i.controlGuidChanges.length} \u9879\uFF09`),e("div",null,"\u63A7\u4EF6\u7D22\u5F15\u5DF2\u4FEE\u6539\u3002\u8BF7\u8BA9 AI \u66F4\u65B0\u5B58\u6863\u811A\u672C\u548C\u76F8\u5173 Lua \u6E90\u6587\u4EF6\uFF0C\u5E76\u91CD\u65B0\u8BD5\u73A9\u6838\u5BF9\u3002"),e("ul",{style:{margin:"5px 0"}},i.controlGuidChanges.map(a=>e("li",{key:a.id},`${a.controlAsset==="client-control-template"?"\u5BA2\u6237\u7AEF\u6A21\u677F":"\u670D\u52A1\u7AEF\u754C\u9762"} \xB7 ${a.controlName}\uFF1A${a.oldGuid} \u2192 ${a.newGuid}`))),e("div",{style:{display:"flex",gap:6}},e("button",{className:"qxsim-action",onClick:xt},"\u590D\u5236\u7ED9 AI"),e("button",{className:"qxsim-action",title:"\u4EC5\u5728\u5DF2\u4FEE\u6539\u6216\u786E\u8BA4\u4E0D\u6D89\u53CA\u811A\u672C\u5F15\u7528\uFF0C\u5E76\u5B8C\u6210\u6838\u5BF9\u540E\u4F7F\u7528",onClick:gt},"\u5DF2\u5B8C\u6210\u811A\u672C\u540C\u6B65"))):null,k.length?e("details",{className:"qxsim-export-warnings",open:!0,role:"status",style:{flexShrink:0,maxHeight:180,overflow:"auto",padding:"8px 16px",borderBottom:"1px solid currentColor"}},e("summary",{style:{cursor:"pointer"}},`\u4E0A\u6B21\u5BFC\u51FA\u8BF4\u660E\uFF08${k.length} \u9879\uFF0C\u8BF7\u6838\u5BF9\u5BFC\u5165\u540E\u7684\u6548\u679C\uFF09`),e("button",{className:"qxsim-action",onClick:()=>q([])},"\u5173\u95ED\u5BFC\u51FA\u8BF4\u660E"),e("ul",null,k.map((a,r)=>e("li",{key:r},a)))):null,I==="ui"?e("div",{className:"qxsim-main"},e("aside",{className:"qxsim-tree"},e("div",{className:"qxsim-asset-switch","aria-label":"\u7F16\u8F91\u8D44\u6E90\u7C7B\u578B"},e("button",{className:P?"":"active",title:"\u7F16\u8F91\u5B58\u6863\u5185\u7684\u670D\u52A1\u7AEF UI \u63A7\u4EF6",onClick:()=>void We("server-control-template")},"UI\u63A7\u4EF6-\u670D\u52A1\u7AEF"),e("button",{className:P?"active":"",title:"\u7F16\u8F91\u5B58\u6863\u5185\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F",onClick:()=>void We("client-control-template")},"UI\u63A7\u4EF6-\u5BA2\u6237\u7AEF")),e("div",{className:"qxsim-pane-head"},e("div",{className:"qxsim-pane-title"},P?"\u6A21\u677F\u4E0E\u5B50\u63A7\u4EF6":"\u63A7\u4EF6\u6811"),e("span",{className:"qxsim-muted"},P?`${i.asset.templateCount} \u4E2A\u6A21\u677F \xB7 ${i.tree.length} \u4E2A\u63A7\u4EF6`:`${i.tree.length} \u4E2A\u8282\u70B9`)),e("label",{className:"qxsim-search"},"\u2315",e("input",{value:he,placeholder:P?"\u641C\u7D22\u6A21\u677F\u6216\u63A7\u4EF6":"\u641C\u7D22\u63A7\u4EF6",onChange:a=>Le(a.target.value)}),he?e("button",{onClick:()=>Le("")},"\xD7"):e("span",null,"\u2301")),e("div",{className:"qxsim-tree-scroll"},Re.length?Re.map(a=>{let r=D[a.kind]||["\u25C7",a.label],d=Ge.has(a.id),f=!!ze[a.id];return e("div",{key:a.id,className:`qxsim-row${P&&a.depth===0?" template-root":""}${a.id===i.selectedId?" active":""}${d?" canvas-hidden":""}`,style:{paddingLeft:8+a.depth*18,"--depth":a.depth},title:`${r[1]} \xB7 ${a.name} \xB7 GUID ${a.guid??a.id}`,onClick:()=>void C({op:"select",id:a.id}).catch(()=>{})},e("span",{className:"qxsim-chevron"},a.childCount?"\u25BC":""),e("span",{className:"qxsim-kind"},r[0]),e("span",{className:"qxsim-row-label"},a.name),e("span",{className:"qxsim-row-end"},P&&a.depth===0?e(m.Fragment,null,e("span",{className:"qxsim-template-tag"},"\u6A21\u677F"),e("span",{className:"qxsim-template-id"},`#${a.guid??a.id}`)):a.incomplete?e("span",{className:"qxsim-incomplete"},"\u6682\u4E0D\u652F\u6301"):null,e("button",{className:`qxsim-eye${f?" off":""}`,type:"button",title:f?"\u5728\u753B\u5E03\u4E0A\u663E\u793A\uFF08\u4E0D\u5F71\u54CD\u63A7\u4EF6\u521D\u59CB\u53EF\u89C1\u6027\uFF09":"\u5728\u753B\u5E03\u4E0A\u9690\u85CF\uFF08\u4E0D\u5F71\u54CD\u63A7\u4EF6\u521D\u59CB\u53EF\u89C1\u6027\uFF09","aria-label":`${a.name}\u753B\u5E03\u53EF\u89C1\u6027`,"aria-pressed":!f,onClick:T=>Tt(T,a.id)},f?"\u25CC":"\u25C9")))}):e("div",{className:"qxsim-empty"},"\u6CA1\u6709\u5339\u914D\u7684\u63A7\u4EF6")),e("div",{className:"qxsim-tree-foot"},P&&N?e("div",{className:"qxsim-hierarchy"},e("div",{className:"qxsim-hierarchy-head"},e("strong",null,"\u5C42\u7EA7\u4E0E\u6A21\u677F\u8FB9\u754C"),e("span",null,N.name)),e("div",{className:"qxsim-parent-row"},e("select",{"aria-label":"\u7236\u7EA7\u63A7\u4EF6",value:Mt,onChange:a=>void C({op:"reparent",id:N.id,parentId:a.target.value}).then(()=>u(a.target.value===i.root.id?"\u5DF2\u63D0\u5347\u4E3A\u53EF\u5B9E\u4F8B\u5316\u9876\u5C42\u6A21\u677F":"\u5DF2\u8C03\u6574\u63A7\u4EF6\u7236\u7EA7")).catch(()=>{})},e("option",{value:i.root.id},"\u9876\u5C42\u6A21\u677F\uFF08\u53EF\u5B9E\u4F8B\u5316\uFF09"),Et.map(a=>e("option",{key:a.id,value:a.id},`${"\u3000".repeat(a.depth)}${a.name}`))),e("button",{title:"\u5728\u540C\u7EA7\u4E2D\u4E0A\u79FB",disabled:N.siblingIndex<=0,onClick:()=>void C({op:"moveSibling",id:N.id,direction:"up"}).catch(()=>{})},"\u2191"),e("button",{title:"\u5728\u540C\u7EA7\u4E2D\u4E0B\u79FB",disabled:N.siblingIndex>=N.siblingCount-1,onClick:()=>void C({op:"moveSibling",id:N.id,direction:"down"}).catch(()=>{})},"\u2193")),e("div",{className:"qxsim-hierarchy-note"},N.depth===0?"\u8BE5\u8282\u70B9\u4F1A\u5199\u5165\u72EC\u7ACB UIControlTemplate\uFF0C\u53EF\u76F4\u63A5\u4F5C\u4E3A prefabId\u3002":`\u5F53\u524D\u4E3A\u7B2C ${N.depth} \u5C42\u5B50\u63A7\u4EF6\uFF0C\u4E0D\u4F1A\u5355\u72EC\u6210\u4E3A prefabId\u3002`)):null,e("div",{className:"qxsim-palette-head"},e("span",{title:P&&te==="template"?"\u65B0\u589E\u72EC\u7ACB\u53EF\u5B9E\u4F8B\u5316\u6A21\u677F":`\u6DFB\u52A0\u5230${N?N.name:"\u5F53\u524D\u63A7\u4EF6"}`},P&&te==="template"?"\u65B0\u589E\u9876\u5C42\u6A21\u677F":`\u6DFB\u52A0\u5230${N?`\u201C${N.name}\u201D`:"\u5F53\u524D\u63A7\u4EF6"}`),P?e("span",{className:"qxsim-add-mode"},e("button",{className:te==="template"?"active":"",onClick:()=>Ie("template")},"\u9876\u5C42"),e("button",{className:te==="child"?"active":"",onClick:()=>Ie("child")},"\u5B50\u63A7\u4EF6")):null),e("div",{className:"qxsim-add"},U.filter(([a])=>P||a!=="container").map(([a,r])=>e("button",{key:a,title:`${P&&te==="template"?"\u65B0\u589E":"\u6DFB\u52A0"}${r}`,onClick:()=>kt(a,r)},`\uFF0B ${r}`))))),e("main",{className:"qxsim-center"},e("div",{className:"qxsim-workspace",ref:Ye},e("div",{className:"qxsim-stage-shell",style:{width:`${Math.max(40,Math.round(Z*Pt))}px`}},e("div",{className:"qxsim-stage-label"},e("b",null,P?"Lua \u6A21\u677F\u9884\u89C8":"\u754C\u9762\u63A7\u4EF6\u7EC4"),e("span",{className:"qxsim-platform-tag"},i.canvas.platform),e("span",null,`${Xe} \xB7 ${Z}\xD7${ne} \xB7 \u5DE6\u4E0B\u539F\u70B9`)),e("div",{className:"qxsim-stage",style:{width:"100%",aspectRatio:`${Z} / ${ne}`},onClick:a=>{let r=a.currentTarget.getBoundingClientRect();C({op:"pick",x:(a.clientX-r.left)*Z/r.width,y:(r.bottom-a.clientY)*ne/r.height}).catch(()=>{})}},It.map(a=>lt(a,i,Z,ne))))),g?e("div",{className:"qxsim-status error"},"\u26A0 ",g):e("div",{className:"qxsim-status"},e("span",null,`\u25CF ${i.asset?.label||"\u63A7\u4EF6"}\u7F16\u8F91`),e("span",null,y||(N?`\u5F53\u524D\uFF1A${N.name}`:"")),e("span",{className:"spacer"}),e("span",null,P?"GIA \u5BFC\u51FA\u540E\u53EF\u5728 Lua \u4E2D\u6309 prefabId \u5B9E\u4F8B\u5316":"\u5B57\u6BB5\u5728\u5931\u7126\u6216 Enter \u65F6\u63D0\u4EA4"),e("a",{className:"qxsim-community",href:"https://space.bilibili.com/23358791",target:"_blank",rel:"noreferrer",title:"\u4F5C\u8005 B\u7AD9\u4E3B\u9875"},"\u4F5C\u8005B\u7AD9"),e("a",{className:"qxsim-community",href:"https://qm.qq.com/q/DpuMvxAfhm",target:"_blank",rel:"noreferrer",title:"\u52A0\u5165 QQ \u7FA4 1007538100"},"QQ\u7FA4 1007538100"))),e("aside",{className:"qxsim-inspector"},i.inspector?e(m.Fragment,null,e("div",{className:"qxsim-inspector-head"},e("div",{className:"qxsim-inspector-line"},e("span",{className:"qxsim-kind"},(D[i.inspector.kind]||["\u25C7"])[0]),e("strong",null,i.inspector.label),P&&N?.depth===0?e("span",{className:"qxsim-template-tag"},"\u53EF\u5B9E\u4F8B\u5316"):null),e("div",{className:"qxsim-node-id"},P&&N?.depth===0?"\u6A21\u677F\u7D22\u5F15 ":"\u63A7\u4EF6 GUID ",e("code",null,i.inspector.guid??i.inspector.id)," \xB7 ",N?.name||"\u8282\u70B9"),i.inspector.kind!=="server-container"?e(nt,{key:`${i.asset.type}:${i.inspector.id}`,inspector:i.inspector,onSave:(a,r)=>ut(a,r,i.asset.type)}):null),e("div",{className:"qxsim-tabs",style:je?void 0:{gridTemplateColumns:"1fr"}},e("button",{className:$e==="base"?"active":"",onClick:()=>Ae("base")},"\u57FA\u7840\u5C5E\u6027"),je?e("button",{className:$e==="script"?"active":"",onClick:()=>Ae("script")},"\u811A\u672C"):null),e("div",{className:"qxsim-inspector-scroll"},je&&$e==="script"?e(st,{snap:i,addScriptMounted:a=>void Je({controlId:a,controlAsset:i.asset?.type}).then(()=>xe("script")),mountScriptTo:wt,unmountScript:qt,openScript:a=>{ve(a),xe("script")}}):e(pe,{inspector:i.inspector,commit:ft,createStateChild:bt})),e("div",{className:"qxsim-tree-foot"},e("button",{className:"qxsim-action danger",style:{width:"100%"},onClick:()=>void C({op:"remove"}).catch(()=>{})},P&&N?.depth===0?"\u232B \u5220\u9664\u5F53\u524D\u6A21\u677F":"\u232B \u5220\u9664\u5F53\u524D\u63A7\u4EF6"))):e("div",{className:"qxsim-empty"},"\u8BF7\u9009\u62E9\u4E00\u4E2A\u63A7\u4EF6"))):I==="script"?e(H,{snap:i,selectedScriptId:Te,selectScript:a=>{Ve(),ve(a)},draft:Ee,updateDraft:ht,saveScript:()=>void K().then(()=>u("Lua \u811A\u672C\u5DF2\u4FDD\u5B58\u5230\u5F53\u524D\u5B58\u6863")).catch(()=>{}),addScript:()=>void Je(),removeScript:yt,exportLua:a=>void ke("lua",a),exportScripts:()=>void ke("scripts"),exportScriptsGia:()=>void ke("scripts-gia"),notice:y}):e(it,{snap:i,draft:He,setDraft:Me,saveLogic:()=>void ie().catch(()=>{}),notice:y,error:g}))}return{SimulatorView:ct,ensureStyle:_,removeStyle:()=>document.getElementById(G)?.remove()}}window.__ModuleLoader__.load({id:"dsh-plugin-beyond-simulator",factory:m=>{let x={},ge=m("react"),$=Ze(ge,{async api(e,X,G){let Y=await fetch("/qxqy-simulator/api/"+X,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sessionId:e,...G||{}})}),D=await Y.json();if(!Y.ok||!D.ok)throw new Error(D.error||"Request failed");return D.value},playUrl:e=>"/qxqy-simulator/play#"+encodeURIComponent(e)});return x.inject=["slots"],x.apply=e=>{$.ensureStyle(),e.effect(()=>$.removeStyle,"qxqy-simulator: style cleanup"),e.slots.inject("conversation.view",()=>e.slots.register({name:"conversation.view",id:"qxqy-simulator",order:20,label:()=>"\u6A21\u62DF\u5668"},$.SimulatorView))},x}});})();
|
|
26
|
+
`,M={"server-container":["\u25A3","\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"],container:["\u25A1","\u5BB9\u5668\u8282\u70B9"],textbox:["T","\u6587\u672C\u6846"],cursor:["\u2301","\u5149\u6807\u68C0\u6D4B\u533A\u57DF"],reference:["\u2197","\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"],grid:["\u25A6","\u7F51\u683C\u89C6\u7A97"],image:["\u25A7","\u56FE\u7247"],button:["Btn","\u9884\u8BBE\u6309\u94AE"],textwindow:["T\u2195","\u6587\u672C\u89C6\u7A97"],keyhint:["1","\u6309\u952E\u63D0\u793A"],animation:["\u2726","\u754C\u9762\u52A8\u6548"],fullscreen:["\u2725","\u5168\u5C4F\u52A8\u6548"]},ee=[["container","\u5BB9\u5668\u8282\u70B9"],["textbox","\u6587\u672C\u6846"],["cursor","\u5149\u6807\u68C0\u6D4B"],["reference","\u6A21\u677F\u5F15\u7528"],["grid","\u7F51\u683C\u89C6\u7A97"],["button","\u9884\u8BBE\u6309\u94AE"],["textwindow","\u6587\u672C\u89C6\u7A97"],["keyhint","\u6309\u952E\u63D0\u793A"],["image","\u56FE\u7247"],["animation","\u754C\u9762\u52A8\u6548"],["fullscreen","\u5168\u5C4F\u52A8\u6548"]],j={container:["isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor"],textbox:["fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text"],cursor:[],reference:["referencedPrefabId"],grid:["cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount"],image:["imageSource","imageId","imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","enableFill","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount","reverseMaskArea"],button:["raycastTarget","interactable","unavailableChildId","hoverChildId","pressedChildId","selectedChildId","clickAudioId"],textwindow:["fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text"],keyhint:["keyboardKeyCode","controllerKeyCode"],animation:["animationId"],fullscreen:["animationId"]};function W(){if(document.getElementById(B))return;let t=document.createElement("style");t.id=B,t.textContent=F,document.head.appendChild(t)}function Z(){let t=document.documentElement,s=document.body,i=[t.dataset.theme,t.className,t.getAttribute("style"),s?.dataset?.theme,s?.className,s?.getAttribute("style"),getComputedStyle(t).colorScheme].filter(Boolean).join(" ").toLowerCase();return i.includes("dark")?"dark":i.includes("light")?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}function se(){let[t,s]=d.useState(Z);return d.useEffect(()=>{let i=()=>s(Z()),n=new MutationObserver(i);n.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme"]}),document.body&&n.observe(document.body,{attributes:!0,attributeFilter:["class","style","data-theme"]});let o=window.matchMedia?.("(prefers-color-scheme: dark)");return o?.addEventListener?.("change",i),()=>{n.disconnect(),o?.removeEventListener?.("change",i)}},[]),t}function O(t,s){let i=Number(t??s)>>>0;return`rgba(${i>>>16&255},${i>>>8&255},${i&255},${(i>>>24&255)/255})`}function b(t){return`#${(Number(t)>>>0).toString(16).padStart(8,"0").toUpperCase()}`}function y(t,s){return t==="circle"?{borderRadius:"50%",background:s}:t==="ring"?{borderRadius:"50%",border:`7px solid ${s}`,background:"transparent"}:t==="triangle"?{background:s,clipPath:"polygon(50% 0,100% 100%,0 100%)"}:t==="fourstar"?{background:s,clipPath:"polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%)"}:t==="fivestar"?{background:s,clipPath:"polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)"}:t==="missing"?{background:"#4822285c",border:"1px dashed #ff7481"}:{background:s}}let P=u;function $(t){let s;try{s=atob(t.data)}catch{throw new Error("\u5BFC\u51FA\u5185\u5BB9\u89E3\u7801\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u6216\u5237\u65B0\u9875\u9762")}let i=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)i[c]=s.charCodeAt(c);let n=URL.createObjectURL(new Blob([i],{type:t.mimeType||"application/octet-stream"})),o=document.createElement("a");o.href=n,o.download=t.filename||"qxqy-export",o.rel="noopener",o.style.display="none",document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function J(t){let s=new Uint8Array(await t.arrayBuffer()),i="",n=32768;for(let o=0;o<s.length;o+=n)i+=String.fromCharCode(...s.subarray(o,o+n));return btoa(i)}let D=t=>typeof t=="object"?t.value:t,R=t=>typeof t=="object"?t.label:t,S=[{key:"KEYBOARD",label:"PC",title:"PC KEYBOARD \u753B\u5E03\uFF1A1600\xD7900 / 2100\xD7900"},{key:"TOUCHSCREEN",label:"\u624B\u673A",title:"\u624B\u673A TOUCHSCREEN \u753B\u5E03\uFF1A1280\xD7720 / 1560\xD7720 / 1280\xD7960"}];function me(t){return String(t.id||"").split("-").slice(1).join(":")}function Ne(t,s){let i=(o,c)=>c?i(c,o%c):o,n=i(Math.round(t),Math.round(s))||1;return`${Math.round(t)/n}:${Math.round(s)/n}`}function _({field:t,commit:s,axis:i}){let n=t.type==="color"?b(t.value):t.value==null?"":String(t.value),[o,c]=d.useState(n);if(d.useEffect(()=>c(t.type==="color"?b(t.value):t.value==null?"":String(t.value)),[t.value,t.type]),t.type==="note")return e("div",{className:"qxsim-note"},t.value||t.label);if(t.readonly&&(t.evidence==="N"||t.evidence==="U"))return e("div",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label),e("div",{className:"qxsim-unsupported"},t.value==null?"\u5C1A\u65E0\u53EF\u7F16\u8F91\u503C":String(t.value)));if(t.type==="bool")return e("div",{className:"qxsim-switch-row"},e("span",null,t.label),e("label",{className:"qxsim-switch"},e("input",{type:"checkbox",checked:!!t.value,disabled:!!t.readonly,onChange:l=>s(t.key,l.target.checked)}),e("span",{className:"qxsim-switch-track"})));if(t.type==="enum"){let l=[...t.options||[]],h=String(t.value??"");return l.some(q=>String(D(q))===h)||l.unshift({value:t.value??"",label:`\u672A\u8BC6\u522B\u9009\u9879 ${t.unknownValue??(h||"\u7A7A")}\uFF08\u4FDD\u7559\u539F\u503C\uFF09`}),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label),e("select",{value:h,disabled:!!t.readonly,onChange:q=>s(t.key,q.target.value)},l.map(q=>e("option",{key:String(D(q)),value:D(q)},R(q)))))}if(t.type==="percent"){let l=Math.round(Number(t.value||0)*100);return e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label),e("span",{className:"qxsim-percent"},e("input",{type:"range",min:0,max:100,value:l,onInput:h=>s(t.key,Number(h.target.value)/100)}),e("output",null,`${l}%`)))}if(t.type==="color"){let l=/^#[0-9a-f]{8}$/i.test(o)?o:b(t.value);return e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t.label,e("small",null,"ARGB")),e("span",{className:"qxsim-color-row"},e("span",{className:"qxsim-color-swatch",title:"\u6253\u5F00\u53D6\u8272\u5668"},e("input",{type:"color",value:`#${l.slice(3)}`,onInput:h=>{let q=`#${l.slice(1,3)}${h.target.value.slice(1).toUpperCase()}`;c(q),s(t.key,q)}})),e("input",{type:"text",value:o,spellCheck:!1,"aria-label":`${t.label} ARGB`,onChange:h=>c(h.target.value),onBlur:()=>s(t.key,o),onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur(),h.key==="Escape"&&c(b(t.value))}})))}let x={value:o,disabled:!!t.readonly,readOnly:!!t.readonly,onChange:l=>c(l.target.value),onBlur:()=>{t.readonly||s(t.key,o)},onKeyDown:l=>{l.key==="Enter"&&t.type!=="text"&&l.currentTarget.blur(),l.key==="Escape"&&c(t.value==null?"":String(t.value))}};return e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},i?e("b",{className:`qxsim-axis ${i.toLowerCase()}`},i):null,t.label),t.type==="text"?e("textarea",{...x,rows:4}):e("input",{...x,type:t.type==="number"?"number":"text",step:t.type==="number"?"any":void 0}))}function K({title:t,open:s=!0,children:i}){return e("details",{className:"qxsim-section",open:s},e("summary",null,t),e("div",{className:"qxsim-section-body"},i))}function be(t){let s={};for(let i of t||[])s[i.key]=i;return s}function Q({label:t,x:s,y:i,xAxis:n="X",yAxis:o="Y",commit:c}){return e("div",{className:"qxsim-pair"},e("div",{className:"qxsim-pair-name"},t),e(_,{field:s,axis:n,commit:c}),e(_,{field:i,axis:o,commit:c}))}function ue({field:t,commit:s,createStateChild:i}){return e("div",{className:"qxsim-state-field"},e("div",{className:"qxsim-state-label"},t.label),e("div",{className:"qxsim-state-ref"},e("button",{title:`\u65B0\u5EFA\u5E76\u7ED1\u5B9A${t.label}\u56FE\u7247`,onClick:()=>i(t.key,t.label)},"+"),e("select",{value:String(t.value??""),"aria-label":t.label,onChange:n=>s(t.key,n.target.value)},(t.options||[]).map(n=>e("option",{key:String(D(n)),value:D(n)},R(n))))))}function ie({inspector:t,commit:s,createStateChild:i}){let n=be(t.fields),o=h=>h?.type==="node"?e(ue,{key:h.key,field:h,commit:s,createStateChild:i}):h?e(_,{key:h.key,field:h,commit:s}):null,c=(j[t.kind]||[]).map(h=>n[h]).filter(Boolean).map(o),x=null;if(t.kind==="image"){let h=n.fillType?.value==="Horizontal"?n.fillHorizontalType:n.fillType?.value==="Vertical"?n.fillVerticalType:n.fillType?.value==="Radial90"?n.fillRadial90Type:n.fillRadialType,q=[o(n.enableMask),o(n.enableSoftEdge),n.enableSoftEdge?.value?e("div",{className:"qxsim-subfields",key:"soft-fields"},o(n.softEdgeMode),e(Q,{label:"\u7FBD\u5316\u5BBD\u5EA6",x:n.softEdgeWidthX,y:n.softEdgeWidthY,commit:s}),e(Q,{label:"\u7FBD\u5316\u8303\u56F4",x:n.horizontalSoftRange,y:n.verticalSoftRange,commit:s})):null,o(n.enableFill),n.enableFill?.value?e("div",{className:"qxsim-subfields",key:"fill-fields"},o(n.fillType),o(h),o(n.fillAmount)):null,o(n.reverseMaskArea)];x=e(d.Fragment,null,e(K,{title:"\u56FE\u7247\u8BBE\u7F6E"},o(n.imageSource),o(n.imageId),o(n.imageColor)),e(K,{title:"\u906E\u7F69\u8BBE\u7F6E"},q))}let l=t.kind==="textbox"?"\u6587\u672C\u6846\u8BBE\u7F6E":t.kind==="button"?"\u6309\u94AE\u8BBE\u7F6E":`${t.label}\u8BBE\u7F6E`;return e(d.Fragment,null,e(K,{title:"\u8282\u70B9\u4FE1\u606F",open:!1},e(_,{field:n.name,commit:s})),e(K,{title:"\u53D8\u6362"},n.posX?e(Q,{label:"\u4F4D\u7F6E",x:n.posX,y:n.posY,commit:s}):null,n.width?e(Q,{label:"\u5927\u5C0F",x:n.width,y:n.height,xAxis:"W",yAxis:"H",commit:s}):null,n.rotationZ?e(_,{field:n.rotationZ,commit:s}):null,n.syncAllDevices?e(_,{field:n.syncAllDevices,commit:s}):null,n.anchorType?e(_,{field:n.anchorType,commit:s}):null,n.anchorMinX?e(Q,{label:"Min",x:n.anchorMinX,y:n.anchorMinY,commit:s}):null,n.anchorMaxX?e(Q,{label:"Max",x:n.anchorMaxX,y:n.anchorMaxY,commit:s}):null,n.pivotX?e(Q,{label:"\u4E2D\u5FC3",x:n.pivotX,y:n.pivotY,commit:s}):null),e(K,{title:"\u521B\u5EFA\u8BBE\u7F6E"},n.active?e(_,{field:n.active,commit:s}):null,n.visible?e(_,{field:n.visible,commit:s}):null),x||(c.length?e(K,{title:l},c):null),n.canControllerFocus?e(K,{title:"\u624B\u67C4\u5BFC\u822A",open:!1},e(_,{field:n.canControllerFocus,commit:s})):null,n.incomplete?e(K,{title:"\u5B9E\u73B0\u72B6\u6001"},e(_,{field:n.incomplete,commit:s})):null)}function m({snap:t,selectedScriptId:s,selectScript:i,draft:n,updateDraft:o,saveScript:c,addScript:x,removeScript:l,exportLua:h,exportScripts:q,exportScriptsGia:z,notice:H}){let k=t.scripts||[],w=k.find(v=>v.id===s)||null,f=t.mountTargets||[],C=f.filter(v=>v.assetType==="server-control-template"),N=f.filter(v=>v.assetType==="client-control-template"),te=v=>{let ne=f.find(Y=>Y.id===v);return ne?`${ne.assetLabel} \xB7 ${ne.name}`:""};return e("div",{className:"qxsim-script-page"},e("aside",{className:"qxsim-script-assets"},e("h3",null,`\u5B58\u6863\u5185 Lua \u811A\u672C\uFF08${k.length}\uFF09`),e("button",{className:"qxsim-action",style:{width:"100%",marginBottom:8},onClick:x},"\uFF0B \u65B0\u5EFA\u811A\u672C"),k.length?k.map(v=>e("div",{key:v.id,className:"qxsim-script-list-row"},e("button",{className:`qxsim-script-asset${v.id===s?" active":""}`,onClick:()=>i(v.id)},e("strong",null,v.path||"(\u672A\u547D\u540D\u811A\u672C)"),e("small",null,v.mounted?`\u6302\u8F7D\uFF1A${v.assetLabel} \xB7 ${v.controlName}`:"\u672A\u6302\u8F7D\uFF08\u4EC5\u53EF\u88AB require\uFF09")),e("button",{className:"qxsim-iconbtn",title:"\u4E0B\u8F7D\u8BE5\u811A\u672C .lua",onClick:()=>h(v.id)},"\u21E9"),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u8BE5\u811A\u672C",onClick:()=>l(v.id)},"\u2715"))):e("div",{className:"qxsim-empty"},"\u8FD8\u6CA1\u6709\u811A\u672C\uFF0C\u70B9\u51FB\u201C\u65B0\u5EFA\u811A\u672C\u201D\u5F00\u59CB")),e("main",{className:"qxsim-script-editor"},w&&n?e(d.Fragment,null,e("div",{className:"qxsim-script-title"},e("div",null,e("h2",null,n.path||"(\u672A\u547D\u540D\u811A\u672C)"),e("span",null,`\u5C5E\u4E8E\u5B58\u6863\u201C${t.save?.name||"\u672A\u547D\u540D\u5B58\u6863"}\u201D \xB7 Lua \u811A\u672C\u662F\u5B58\u6863\u5185\u72EC\u7ACB\u8D44\u4EA7`)),e("span",null,`\u811A\u672C ${w.id}`)),e("div",{className:"qxsim-script-fields"},e("label",null,"\u811A\u672C\u8DEF\u5F84\uFF08\u5DE5\u4F5C\u533A\u76F8\u5BF9\u8DEF\u5F84\uFF09",e("input",{type:"text",value:n.path,placeholder:"lua/example.lua",onChange:v=>o({path:v.target.value})})),e("label",null,"\u6302\u8F7D\u76EE\u6807\uFF08\u5BA2\u6237\u7AEF\u63A7\u4EF6 / \u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\uFF09",e("select",{value:n.controlId?`${n.controlAsset||"server-control-template"}|${n.controlId}`:"",onChange:v=>{let[ne,Y]=v.target.value.split("|");o(Y?{controlId:Y,controlAsset:ne}:{controlId:"",controlAsset:""})}},e("option",{value:""},"\u672A\u6302\u8F7D\uFF08\u4E0D\u751F\u6548\uFF0C\u4EC5\u53EF\u88AB require\uFF09"),e("optgroup",{label:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F \xB7 \u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668\u5185"},C.map(v=>e("option",{key:v.id,value:`${v.assetType}|${v.id}`},`${v.name} \xB7 ${v.id}`))),N.length?e("optgroup",{label:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"},N.map(v=>e("option",{key:v.id,value:`${v.assetType}|${v.id}`},`${v.name} \xB7 ${v.id}`))):null))),e("label",null,"Lua \u6E90\u7801",e("textarea",{value:n.source,spellCheck:!1,placeholder:"-- \u5728\u8FD9\u91CC\u8F93\u5165\u5BA2\u6237\u7AEF Lua\uFF1B\u811A\u672C\u53EA\u6709\u6302\u8F7D\u5230\u5BA2\u6237\u7AEF\u63A7\u4EF6\u540E\u624D\u4F1A\u5728\u8BD5\u73A9\u65F6\u751F\u6548",onChange:v=>o({source:v.target.value})})),e("div",{className:"qxsim-script-footer"},e("span",null,n.dirty?"\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539":H||(w.mounted?`\u5DF2\u6302\u8F7D\uFF1A${te(w.controlId)}`:"\u5F53\u524D\u672A\u6302\u8F7D\uFF0C\u8BD5\u73A9\u65F6\u4E0D\u4F1A\u81EA\u52A8\u8FD0\u884C")),e("span",{className:"spacer"}),e("button",{className:"qxsim-action",onClick:q},"\u21E9 \u811A\u672C\u5305 JSON"),e("button",{className:"qxsim-action",onClick:z},"\u21E9 \u811A\u672C\u5305 GIA"),e("button",{className:"qxsim-action primary",disabled:!n.dirty,onClick:c},"\u4FDD\u5B58\u811A\u672C"))):e("div",{className:"qxsim-empty"},"\u8BF7\u65B0\u5EFA\u6216\u9009\u62E9\u4E00\u4E2A\u811A\u672C")))}function G(t){if(t===void 0)return"null";try{return JSON.stringify(t)}catch{return String(t)}}function X(t){let s=String(t??"").trim();if(!s)return null;try{return JSON.parse(s)}catch{return s}}function Ge(t){return!!(t&&typeof t=="object"&&!Array.isArray(t)&&Object.prototype.hasOwnProperty.call(t,"fromSignalParam"))}function Be(t){return{version:1,dirty:!1,rules:(Array.isArray(t?.rules)?t.rules:[]).map((i,n)=>({id:String(i.id||`signal-${n+1}`),signalName:String(i.signalName||""),actions:Array.isArray(i.actions)&&i.actions.length?i.actions.map(o=>it(o)):[xe("setCustomVariable")]}))}}let Fe=["PlayerSelf","AllPlayers","Player1","Player2","Player3","Player4","Player5","Player6","Player7","Player8"],Ue=["PlayerSelf","Level","Player1","Player2","Player3","Player4","Player5","Player6","Player7","Player8"],_e={PlayerSelf:"PlayerSelf \u5F53\u524D\u73A9\u5BB6",AllPlayers:"AllPlayers \u5168\u90E8\u73A9\u5BB6",Level:"Level \u5173\u5361",Player1:"Player1 \u73A9\u5BB61",Player2:"Player2 \u73A9\u5BB62",Player3:"Player3 \u73A9\u5BB63",Player4:"Player4 \u73A9\u5BB64",Player5:"Player5 \u73A9\u5BB65",Player6:"Player6 \u73A9\u5BB66",Player7:"Player7 \u73A9\u5BB67",Player8:"Player8 \u73A9\u5BB68"};function Se(t){return Ue.includes(t)&&t!=="AllPlayers"?t:t==="Level"?"Level":"PlayerSelf"}function Ce(t){return Fe.includes(t)?t:"PlayerSelf"}function xe(t){return t==="sendClientScriptSignal"?{kind:"sendClientScriptSignal",target:"PlayerSelf",signalName:"",params:[]}:{kind:"setCustomVariable",entityType:"PlayerSelf",name:"",value:0}}function tt(t){return{version:1,rules:(t?.rules||[]).map(s=>({id:String(s.id||""),signalName:String(s.signalName||"").trim(),actions:(s.actions||[]).map(i=>i?.kind==="sendClientScriptSignal"?{kind:"sendClientScriptSignal",target:Ce(i.target),signalName:String(i.signalName||"").trim(),params:Array.isArray(i.params)?i.params:[]}:{kind:"setCustomVariable",entityType:Se(i?.entityType),name:String(i?.name||"").trim(),value:i&&Object.prototype.hasOwnProperty.call(i,"value")?i.value:0})}))}}function at(t){let s=[];for(let[i,n]of(t?.rules||[]).entries()){String(n.signalName||"").trim()||s.push(`\u89C4\u5219 ${i+1} \u9700\u8981\u76D1\u542C\u4FE1\u53F7\u540D`);let o=n.actions||[];o.length||s.push(`\u89C4\u5219 ${i+1} \u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u52A8\u4F5C`);for(let[c,x]of o.entries())x?.kind==="sendClientScriptSignal"?String(x.signalName||"").trim()||s.push(`\u89C4\u5219 ${i+1} \u52A8\u4F5C ${c+1} \u9700\u8981\u5BA2\u6237\u7AEF\u4FE1\u53F7\u540D`):String(x?.name||"").trim()||s.push(`\u89C4\u5219 ${i+1} \u52A8\u4F5C ${c+1} \u9700\u8981\u53D8\u91CF\u540D`)}return s}function it(t){if(t?.kind==="sendClientScriptSignal")return{kind:"sendClientScriptSignal",target:Ce(t.target),signalName:String(t.signalName||""),params:Array.isArray(t.params)?t.params.map(i=>{try{return JSON.parse(JSON.stringify(i))}catch{return i}}):[]};let s=0;if(t&&Object.prototype.hasOwnProperty.call(t,"value"))try{s=JSON.parse(JSON.stringify(t.value))}catch{s=t.value}return{kind:"setCustomVariable",entityType:Se(t?.entityType),name:String(t?.name||""),value:s}}function He({label:t,value:s,onChange:i}){let n=Ge(s),[o,c]=d.useState(()=>n?"":G(s));return d.useEffect(()=>{Ge(s)||c(G(s))},[s]),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},t),e("select",{value:n?"param":"literal","aria-label":`${t}\u6765\u6E90`,onChange:x=>{x.target.value==="param"?i({fromSignalParam:Number(s?.fromSignalParam)||0}):i(X(o||"0"))}},e("option",{value:"literal"},"\u5B57\u9762\u91CF\uFF08JSON\uFF09"),e("option",{value:"param"},"\u5F15\u7528\u76D1\u542C\u4FE1\u53F7\u53C2\u6570")),n?e("input",{type:"number",min:0,step:1,value:Number(s.fromSignalParam)||0,"aria-label":`${t}\u53C2\u6570\u5E8F\u53F7`,onChange:x=>i({fromSignalParam:Math.max(0,Math.trunc(Number(x.target.value)||0))})}):e("textarea",{className:"qxsim-logic-json",value:o,spellCheck:!1,"aria-label":`${t}\u5B57\u9762\u91CF`,onBlur:()=>i(X(o)),onChange:x=>c(x.target.value)}))}function nt({params:t,onChange:s}){let i=Array.isArray(t)?t:[];return e("div",{className:"qxsim-field wide"},e("span",{className:"qxsim-field-label"},"\u5BA2\u6237\u7AEF\u4FE1\u53F7\u53C2\u6570\uFF08\u6309\u6DFB\u52A0\u987A\u5E8F\uFF09"),i.length?i.map((n,o)=>e("div",{key:o,style:{display:"flex",gap:6,alignItems:"flex-start",marginBottom:6}},e("div",{style:{flex:1,minWidth:0}},e(He,{label:`\u53C2\u6570 ${o}`,value:n,onChange:c=>s(i.map((x,l)=>l===o?c:x))})),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u53C2\u6570",onClick:()=>s(i.filter((c,x)=>x!==o))},"\u2715"))):e("div",{className:"qxsim-muted"},"\u6682\u65E0\u53C2\u6570\uFF0C\u53EF\u53D1\u9001\u7A7A\u53C2\u6570\u5217\u8868"),e("button",{className:"qxsim-action",style:{marginTop:4},onClick:()=>s(i.concat([0]))},"\uFF0B \u6DFB\u52A0\u53C2\u6570"))}function st({snap:t,draft:s,setDraft:i,saveLogic:n,notice:o,error:c}){let x=s?.rules||[];function l(k){i({version:1,rules:k,dirty:!0})}function h(){l(x.concat([{id:`signal-${Date.now().toString(36)}`,signalName:"",actions:[xe("setCustomVariable")]}]))}function q(k,w){l(x.map((f,C)=>C===k?{...f,...w}:f))}function z(k,w,f){let C=x[k];C&&q(k,{actions:C.actions.map((N,te)=>te===w?{...N,...f}:N)})}function H(k,w,f){z(k,w,xe(f))}return e("div",{className:"qxsim-server-logic"},e("div",{className:"qxsim-logic-wrap"},e("div",{className:"qxsim-logic-title"},e("div",null,e("h2",null,"\u670D\u52A1\u7AEF\u903B\u8F91"),e("p",null,`\u5C5E\u4E8E\u5B58\u6863\u201C${t.save?.name||"\u672A\u547D\u540D\u5B58\u6863"}\u201D \xB7 \u76D1\u542C\u5BA2\u6237\u7AEF\u4FE1\u53F7\u540E\u8BBE\u7F6E Level / \u73A9\u5BB6\u53D8\u91CF\uFF0C\u6216\u5411\u6307\u5B9A\u73A9\u5BB6\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7`)),e("button",{className:"qxsim-action primary",disabled:!s?.dirty,onClick:n},"\u4FDD\u5B58\u670D\u52A1\u7AEF\u903B\u8F91")),e("div",{className:"qxsim-note"},"\u8FD9\u662F\u6A21\u62DF\u5668\u5B58\u6863\u683C\u5F0F\uFF0C\u4E0D\u662F\u5B98\u65B9\u8282\u70B9\u56FE\u3002PlayerSelf \u8868\u793A\u53D1\u4FE1\u53F7\u7684\u90A3\u4F4D\u73A9\u5BB6\uFF1BPlayer1\u20138 \u662F\u56FA\u5B9A\u5EA7\u4F4D\uFF1BAllPlayers \u5411\u672C\u5C40\u5168\u90E8\u8BD5\u73A9\u73A9\u5BB6\u5E7F\u64AD\u3002"),c?e("div",{className:"qxsim-logic-error"},c):null,x.length?x.map((k,w)=>e("section",{key:k.id||w,className:"qxsim-logic-rule"},e("div",{className:"qxsim-logic-rule-head"},e("strong",null,`\u89C4\u5219 ${w+1}`),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u76D1\u542C\u4FE1\u53F7\u540D"),e("input",{type:"text",value:k.signalName,placeholder:"EarnGold","aria-label":`\u89C4\u5219 ${w+1} \u76D1\u542C\u4FE1\u53F7\u540D`,onChange:f=>q(w,{signalName:f.target.value})})),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u89C4\u5219",onClick:()=>l(x.filter((f,C)=>C!==w))},"\u2715")),e("div",{className:"qxsim-logic-actions"},(k.actions||[]).map((f,C)=>e("div",{key:C,className:"qxsim-logic-action"},e("div",{className:"qxsim-logic-action-head"},e("strong",null,`\u52A8\u4F5C ${C+1}`),e("select",{value:f.kind,"aria-label":`\u89C4\u5219 ${w+1} \u52A8\u4F5C ${C+1} \u7C7B\u578B`,onChange:N=>H(w,C,N.target.value)},e("option",{value:"setCustomVariable"},"\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF"),e("option",{value:"sendClientScriptSignal"},"\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7")),e("span",null,f.kind==="sendClientScriptSignal"?"\u53D1\u7ED9\u5F53\u524D\u73A9\u5BB6\u3001\u6307\u5B9A\u73A9\u5BB6\u6216\u5168\u90E8\u73A9\u5BB6":"\u5199\u5165 Level / \u5F53\u524D\u73A9\u5BB6 / \u73A9\u5BB61-8"),e("button",{className:"qxsim-iconbtn",title:"\u5220\u9664\u52A8\u4F5C",disabled:(k.actions||[]).length<=1,onClick:()=>q(w,{actions:k.actions.filter((N,te)=>te!==C)})},"\u2715")),f.kind==="sendClientScriptSignal"?e("div",{className:"qxsim-logic-fields"},e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u53D1\u9001\u76EE\u6807"),e("select",{value:Ce(f.target),onChange:N=>z(w,C,{target:N.target.value})},Fe.map(N=>e("option",{key:N,value:N},_e[N])))),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u5BA2\u6237\u7AEF\u4FE1\u53F7\u540D"),e("input",{type:"text",value:f.signalName,placeholder:"GoldChanged",onChange:N=>z(w,C,{signalName:N.target.value})})),e(nt,{params:f.params,onChange:N=>z(w,C,{params:N})})):e("div",{className:"qxsim-logic-fields"},e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u5B9E\u4F53"),e("select",{value:Se(f.entityType),onChange:N=>z(w,C,{entityType:N.target.value})},Ue.map(N=>e("option",{key:N,value:N},_e[N])))),e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u53D8\u91CF\u540D"),e("input",{type:"text",value:f.name,placeholder:"Gold",onChange:N=>z(w,C,{name:N.target.value})})),e("div",{className:"wide"},e(He,{label:"\u53D8\u91CF\u503C",value:f.value,onChange:N=>z(w,C,{value:N})}))))),e("div",{className:"qxsim-logic-actions-foot"},e("button",{className:"qxsim-action",onClick:()=>q(w,{actions:(k.actions||[]).concat([xe("setCustomVariable")])})},"\uFF0B \u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF"),e("button",{className:"qxsim-action",onClick:()=>q(w,{actions:(k.actions||[]).concat([xe("sendClientScriptSignal")])})},"\uFF0B \u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7"))))):e("div",{className:"qxsim-logic-empty"},"\u8FD8\u6CA1\u6709\u76D1\u542C\u89C4\u5219\u3002\u8BD5\u73A9\u65F6\u5BA2\u6237\u7AEF SendSignal \u4E0D\u4F1A\u81EA\u52A8\u6539\u53D8\u91CF\u6216\u56DE\u4F20\u4FE1\u53F7\u3002"),e("div",{className:"qxsim-logic-actions-foot"},e("button",{className:"qxsim-action",onClick:h},"\uFF0B \u6DFB\u52A0\u76D1\u542C\u89C4\u5219")),e("div",{className:"qxsim-script-footer",style:{marginTop:16}},e("span",null,s?.dirty?"\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539":o||"\u4FDD\u5B58\u540E\u4F1A\u5199\u5165\u5F53\u524D\u5B58\u6863\uFF0C\u4E0B\u6B21\u8BD5\u73A9\u751F\u6548"),e("span",{className:"spacer"}))))}function rt({inspector:t,onSave:s}){let[i,n]=d.useState(String(t.guid??"")),[o,c]=d.useState(!1),[x,l]=d.useState("");d.useEffect(()=>{n(String(t.guid??"")),l("")},[t.guid]);async function h(q){q.preventDefault();let z=i.trim();if(!/^[0-9]+$/.test(z)||Number(z)<1||Number(z)>2147483647){l("\u8BF7\u8F93\u5165 1\u20132147483647 \u4E4B\u95F4\u7684\u6574\u6570\u7D22\u5F15\u3002");return}c(!0),l("");try{await s(t.id,Number(z))}catch(H){l(H?.message||String(H))}finally{c(!1)}}return e("form",{onSubmit:h,style:{marginTop:8}},e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15"),e("div",{style:{display:"flex",gap:6}},e("input",{type:"text",inputMode:"numeric","aria-label":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15",value:i,disabled:o,onChange:q=>{n(q.target.value),l("")},onKeyDown:q=>{q.key==="Escape"&&(n(String(t.guid)),l(""))}}),e("button",{type:"submit",className:"qxsim-action",disabled:o||i.trim()===String(t.guid)},o?"\u4FDD\u5B58\u4E2D":"\u4FEE\u6539"))),x?e("div",{role:"alert",className:"qxsim-note"},x):null,e("div",{className:"qxsim-muted",style:{lineHeight:1.5}},"\u586B\u5199 GIA \u5BFC\u5165\u540E\u5B9E\u9645\u663E\u793A\u7684\u7D22\u5F15\uFF1B\u4FEE\u6539\u540E\u987B\u8BA9 AI \u540C\u6B65 Lua \u811A\u672C\u4E2D\u7684\u5F15\u7528\u3002"))}function ot({snap:t,addScriptMounted:s,mountScriptTo:i,unmountScript:n,openScript:o}){let c=(t.scripts||[]).filter(l=>l.controlId===t.selectedId),x=(t.scripts||[]).filter(l=>l.controlId!==t.selectedId);return e(d.Fragment,null,e(K,{title:"\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6\u7684\u811A\u672C"},c.length?c.map(l=>e("div",{key:l.id,className:"qxsim-script-list-row"},e("button",{className:"qxsim-script-asset",onClick:()=>o(l.id)},e("strong",null,l.path||"(\u672A\u547D\u540D\u811A\u672C)"),e("small",null,`\u811A\u672C ${l.id}`)),e("button",{className:"qxsim-iconbtn",title:"\u89E3\u9664\u6302\u8F7D\uFF08\u4FDD\u7559\u811A\u672C\uFF09",onClick:()=>n(l.id)},"\u292B"))):e("div",{className:"qxsim-note"},"\u8BE5\u63A7\u4EF6\u5C1A\u672A\u6302\u8F7D\u811A\u672C\u3002\u811A\u672C\u6302\u8F7D\u5230\u5BA2\u6237\u7AEF\u63A7\u4EF6\u540E\u624D\u4F1A\u5728\u8BD5\u73A9\u65F6\u751F\u6548\u3002")),e(K,{title:"\u6302\u8F7D\u5DF2\u6709\u811A\u672C",open:!1},x.length?e("label",{className:"qxsim-field"},e("span",{className:"qxsim-field-label"},"\u9009\u62E9\u811A\u672C\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6"),e("select",{value:"","aria-label":"\u9009\u62E9\u811A\u672C\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6",onChange:l=>{let h=l.target.value;l.target.value="",h&&i(h)}},e("option",{value:""},"\u9009\u62E9\u811A\u672C\u2026"),x.map(l=>e("option",{key:l.id,value:l.id},`${l.path||"(\u672A\u547D\u540D\u811A\u672C)"} \xB7 ${l.id}${l.mounted?`\uFF08\u5F53\u524D\u6302\u8F7D\u4E8E ${l.assetLabel} \xB7 ${l.controlName}\uFF0C\u5C06\u79FB\u52A8\u5230\u6B64\u63A7\u4EF6\uFF09`:"\uFF08\u672A\u6302\u8F7D\uFF09"}`)))):e("div",{className:"qxsim-note"},"\u5B58\u6863\u5185\u8FD8\u6CA1\u6709\u5176\u4ED6\u811A\u672C\uFF0C\u53EF\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u65B0\u5EFA\u3002"),e("div",{className:"qxsim-script-actions",style:{marginTop:8}},e("button",{onClick:()=>s(t.selectedId)},"\uFF0B \u65B0\u5EFA\u811A\u672C\u5E76\u6302\u8F7D\u5230\u6B64\u63A7\u4EF6"))))}function lt(t,s){let i=null,n=null;function o(c,x){c.id===s&&(i=c,n=x);for(let l of c.children||[])o(l,c)}if(o(t,null),i?.kind==="container")return i.id;if(i?.kind==="server-container")return i.children?.find(c=>c.kind==="container")?.id||i.id;for(;n&&n.kind!=="container";){let x=function(l){for(let h of l.children||[])h===n&&(c=l),x(h)},c=null;x(t),n=c}return n?.id||t.children?.find(c=>c.kind==="container")?.id}function ct(t,s){let i=null;function n(o){o.id===s&&(i=o);for(let c of o.children||[])n(c)}return n(t),i&&i.kind!=="server-container"?i.id:lt(t,s)}function dt(t,s,i,n){let o=t,c=t.kind,x=c==="textbox"||c==="textwindow",l=o.renderLeft??o.left,h=o.renderBottom??o.bottom,q=o.renderWidth??o.width,z=o.renderHeight??o.height,H=o.renderRotationZ??t.rotationZ??0,k={left:`${l/i*100}%`,bottom:`${h/n*100}%`,width:`${q/i*100}%`,height:`${z/n*100}%`,"--rotation":`${-Number(H)}deg`,fontSize:Math.max(8,Math.min(40,Number(t.fontSize||12))),color:x?O(t.fontColor,4294967295):"#fff"};c==="image"?Object.assign(k,y(t.primitive,O(t.imageColor,4294967295))):x?(k.background=O(t.bgColor,16777215),k.justifyContent=t.horizontalAlignment==="Right"?"flex-end":t.horizontalAlignment==="Middle"?"center":"flex-start",k.alignItems=t.verticalAlignment==="Bottom"?"flex-end":t.verticalAlignment==="Middle"?"center":"flex-start",k.textShadow=t.enableOutline===!1?"none":`0 0 2px ${O(t.outlineColor,4278190080)}`):c==="container"&&(k.background="transparent");let w=t.id===s.selectedId,f=x?t.text||"":c==="image"&&t.primitive==="missing"?e("span",{className:"qxsim-box-label"},`\u7F3A\u5C11\u56FE\u7247 ${t.imageId||""}`):c!=="container"&&c!=="image"?e("span",{className:"qxsim-box-label"},t.name||M[c]?.[1]||c):null;return e("div",{key:t.id,className:`qxsim-box ${c}${w?" selected":""}${t.instantiated?" dynamic":""}${t.pressed?" pressed":""}`,style:k},f,w&&c!=="container"?["tl","tr","bl","br"].map(C=>e("i",{key:C,className:`qxsim-handle ${C}`})):null)}function pt({sessionId:t}){let s=se(),[i,n]=d.useState(null),o=d.useRef(null),c=d.useRef(Promise.resolve()),[x,l]=d.useState(""),h=U({sessionId:t,api:P,playUrl:ae,onError:l}),[q,z]=d.useState(null),[H,k]=d.useState(!1),[w,f]=d.useState(""),C=d.useRef(null),[N,te]=d.useState([]),[v,ne]=d.useState([]),[Y,mt]=d.useState("ui"),[$e,Pe]=d.useState("base"),[Ae,ut]=d.useState("fit"),[Le,xt]=d.useState({}),[he,Ee]=d.useState(""),[le,ze]=d.useState("template"),[Ie,ve]=d.useState(""),[Te,ge]=d.useState(null),[Ye,Me]=d.useState({version:1,rules:[],dirty:!1}),Ve=d.useRef(null),[ye,gt]=d.useState({width:0,height:0});d.useEffect(()=>{let a=Ve.current;if(!a||typeof ResizeObserver>"u")return;let r=new ResizeObserver(p=>{let g=p[0]?.contentRect;g&&g.width>0&>({width:g.width,height:g.height})});return r.observe(a),()=>r.disconnect()},[i?.canvas?.id]);function ce(a,{keepLogicDraft:r=!0}={}){return o.current=a,n(a),a?.scripts&&ve(p=>a.scripts.some(g=>g.id===p)?p:a.scripts[0]?.id||""),Me(p=>r&&p?.dirty?p:Be(a?.serverLogic)),a}let qe=d.useCallback(async()=>{try{l(""),ce(await P(t,"get"),{keepLogicDraft:!1})}catch(a){l(a?.message||String(a))}},[t]),we=d.useCallback(async()=>{try{let a=await P(t,"archives");ne(a?.archives||[])}catch{ne([])}},[t]);d.useEffect(()=>{qe(),we()},[qe,we]);function E(a,r=""){let p=async()=>{let g=o.current;if(!g)throw new Error("editor is not ready");try{if(r&&g.asset?.type!==r)throw new Error("\u5F53\u524D\u8D44\u4EA7\u5DF2\u5207\u6362\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u63A7\u4EF6\u540E\u4FEE\u6539\u7D22\u5F15");let V=await P(t,"patch",{op:{...a,expectedRevision:g.version}});return l(""),ce(V)}catch(V){throw l(V?.message||String(V)),/revision conflict/.test(String(V?.message||V))&&await qe(),V}};return c.current=c.current.then(p,p),c.current}async function ft(a,r,p){await E({op:"setControlGuid",id:a,guid:r},p),f("\u63A7\u4EF6\u7D22\u5F15\u5DF2\u4FEE\u6539\uFF1B\u8BF7\u8BA9 AI \u6839\u636E\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u540C\u6B65 Lua \u811A\u672C\u5F15\u7528\u3002")}async function bt(){let p=["\u8BF7\u540C\u6B65\u5F53\u524D\u6A21\u62DF\u5668\u5DE5\u7A0B\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\uFF1A",...(o.current?.controlGuidChanges||[]).map(g=>`${g.controlAsset} / ${g.controlName}\uFF08${g.controlId}\uFF09\uFF1A${g.oldGuid} \u2192 ${g.newGuid}\uFF1B\u8BB0\u5F55 ${g.id}`),"\u5148\u8BFB\u53D6\u6700\u65B0\u5FEB\u7167\u7684 controlGuidChanges\uFF0C\u6309\u63A7\u4EF6\u8EAB\u4EFD\u548C\u53D8\u66F4\u987A\u5E8F\u6838\u5BF9\u5168\u90E8 Lua \u811A\u672C\u7684\u7D22\u5F15\u5E38\u91CF\u3001\u914D\u7F6E\u8868\u4E0E\u8C03\u7528\uFF0C\u4FEE\u6539\u5B58\u6863\u4E2D\u7684 source \u53CA\u76F8\u5173 Lua \u6E90\u6587\u4EF6\u3002\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\uFF0C\u4E5F\u4E0D\u8981\u6539\u8FD0\u884C\u65F6\u5B9E\u4F8B ID \u6216\u56FE\u7247\u8D44\u6E90 ID\u3002","\u68C0\u67E5\u65E7\u7D22\u5F15\u5F15\u7528\u5E76\u91CD\u65B0\u8BD5\u73A9\uFF1B\u786E\u8BA4\u5B8C\u6210\u540E\u7528 acknowledgeControlGuidChanges \u7684 changeIds \u6E05\u9664\u5DF2\u6838\u5BF9\u8BB0\u5F55\uFF0C\u518D\u4FDD\u5B58\u5B8C\u6574\u5B58\u6863\u3002"].join(`
|
|
27
|
+
`);try{await navigator.clipboard.writeText(p),f("\u5DF2\u590D\u5236\u7D22\u5F15\u53D8\u66F4\u53CA\u811A\u672C\u540C\u6B65\u8981\u6C42\uFF0C\u53EF\u7C98\u8D34\u7ED9 AI\u3002")}catch{l("\u65E0\u6CD5\u8BBF\u95EE\u526A\u8D34\u677F\uFF0C\u8BF7\u5C06\u4E0A\u65B9\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u4EA4\u7ED9 AI\uFF0C\u5E76\u8981\u6C42\u540C\u6B65 Lua \u811A\u672C\u5F15\u7528\u3002")}}async function ht(){let a=(o.current?.controlGuidChanges||[]).map(r=>r.id);try{await re(),await E({op:"acknowledgeControlGuidChanges",changeIds:a}),f("\u5DF2\u786E\u8BA4\u811A\u672C\u7D22\u5F15\u5F15\u7528\u5B8C\u6210\u540C\u6B65\uFF1B\u8BF7\u4FDD\u5B58\u5B8C\u6574\u5B58\u6863\u3002")}catch{}}let vt=(a,r)=>void E({op:"set",key:a,value:r}).catch(()=>{});async function yt(a,r){let p=o.current?.inspector?.id;if(p)try{let g=await E({op:"add",kind:"image",parentId:p,name:`${r}\u56FE\u7247`});await E({op:"set",id:p,key:a,value:g.selectedId}),f(`${r}\u5DF2\u521B\u5EFA\u5E76\u7ED1\u5B9A\uFF1B\u53EF\u5728\u63A7\u4EF6\u6811\u4E2D\u7EE7\u7EED\u7F16\u8F91\u56FE\u7247\u3002`)}catch{}}d.useEffect(()=>{let a=i?.scripts?.find(r=>r.id===Ie);ge(r=>r&&a&&r.id===a.id&&r.dirty?r:a?{id:a.id,path:a.path,source:a.source,controlId:a.controlId,controlAsset:a.controlAsset,dirty:!1}:null)},[i,Ie]);function qt(a){ge(r=>r&&{...r,...a,dirty:!0})}async function re(){let a=Te;!a||!a.dirty||(await E({op:"updateScript",id:a.id,path:a.path,source:a.source,controlId:a.controlId,controlAsset:a.controlAsset}),ge(r=>r&&r.id===a.id?{...r,dirty:!1}:r))}function We(){re().then(()=>f("Lua \u811A\u672C\u5DF2\u4FDD\u5B58\u5230\u5F53\u524D\u5B58\u6863")).catch(()=>{})}async function de({silent:a=!1}={}){let r=Ye;if(!r||!r.dirty)return;let p=at(r);if(p.length){let V=p[0];throw a||l(V),new Error(V)}let g=await E({op:"setServerLogic",logic:tt(r)});Me(Be(g.serverLogic)),f("\u670D\u52A1\u7AEF\u903B\u8F91\u5DF2\u4FDD\u5B58\u5230\u5F53\u524D\u5B58\u6863")}function wt(){de({silent:!0}).catch(()=>{})}function fe(a){We(),wt(),mt(a)}async function Je(a={}){let r=await E({op:"addScript",...a}),p=r.scripts?.[r.scripts.length-1];return p&&ve(p.id),f(a.controlId?"\u5DF2\u65B0\u5EFA\u811A\u672C\u5E76\u6302\u8F7D\u5230\u8BE5\u63A7\u4EF6":"\u5DF2\u65B0\u5EFA\u811A\u672C\uFF0C\u53EF\u7F16\u8F91\u8DEF\u5F84\u3001\u6E90\u7801\u548C\u6302\u8F7D\u76EE\u6807"),p}function kt(a){Te?.id===a&&ge(null),E({op:"removeScript",id:a}).then(()=>f("\u811A\u672C\u5DF2\u5220\u9664")).catch(()=>{})}function Nt(a){E({op:"updateScript",id:a,controlId:""}).then(()=>f("\u5DF2\u89E3\u9664\u6302\u8F7D\uFF0C\u811A\u672C\u4ECD\u4FDD\u7559\u5728\u5B58\u6863\u4E2D")).catch(()=>{})}function St(a){let r=o.current?.selectedId||"",p=o.current?.asset?.type||"";r&&(ge(g=>g&&g.id===a?{...g,controlId:r,controlAsset:p}:g),E({op:"updateScript",id:a,controlId:r,controlAsset:p}).then(()=>f("\u5DF2\u6302\u8F7D\u5230\u5F53\u524D\u63A7\u4EF6")).catch(()=>{}))}async function Xe(a){if(o.current?.asset?.type!==a)try{let r=await E({op:"selectAsset",assetType:a});Ee(""),ze(a==="client-control-template"?"template":"child"),f(`\u5DF2\u5207\u6362\u5230\u5B58\u6863\u5185\u7684${r.asset.label}`)}catch{}}function Ct(a,r){let p=o.current;if(!p)return;let g=p.asset?.type==="client-control-template"&&le==="template",V=g?{op:"addTemplate",kind:a,name:`${r}\u6A21\u677F`}:{op:"add",kind:a,parentId:ct(p.root,p.selectedId),name:r};E(V).then(()=>f(g?`\u5DF2\u65B0\u589E${r}\u6A21\u677F`:`\u5DF2\u6DFB\u52A0${r}\u5B50\u63A7\u4EF6`)).catch(()=>{})}async function ke(a,r=""){try{await c.current.catch(()=>{}),await re(),await de();let p=await P(t,"export",{format:a,assetType:r});if(te([...new Set([...p.warnings||[],...(p.files||[]).flatMap(g=>g.warnings||[])])]),Array.isArray(p?.files)&&p.files.length){for(let g of p.files)$(g);l(""),f(`\u5DF2\u5BFC\u51FA ${p.files.length} \u4E2A GIA \u6587\u4EF6\uFF08${p.files.map(g=>g.filename).join("\u3001")}\uFF09\uFF1B\u82E5\u6D4F\u89C8\u5668\u62E6\u622A\u591A\u6587\u4EF6\u4E0B\u8F7D\uFF0C\u8BF7\u5141\u8BB8\u540E\u91CD\u8BD5\u3002`);return}$(p),l(""),f(p.warnings?.length?`\u5DF2\u5BFC\u51FA ${p.filename}\uFF1B\u8BF7\u67E5\u770B\u4E0A\u65B9\u5BFC\u51FA\u8BF4\u660E\u3002`:`\u5DF2\u5BFC\u51FA ${p.filename}`)}catch(p){l(p?.message||String(p))}}async function $t(a){if(a)try{await c.current.catch(()=>{});let r=await P(t,"load-archive",{path:a});ce(r.snapshot,{keepLogicDraft:!1}),l(""),f(`\u5DF2\u4ECE\u5DE5\u4F5C\u533A\u62C9\u53D6 ${a}`),te([])}catch(r){l(r?.message||String(r))}}async function Pt(a){if(!a)return;let r=a.name.toLowerCase().endsWith(".gia")?"gia":a.name.toLowerCase().endsWith(".json")?"json":a.name.toLowerCase().endsWith(".lua")?"lua":"";if(!r){l("\u4EC5\u652F\u6301 .json\u3001.gia \u6216 .lua \u6587\u4EF6");return}try{await c.current.catch(()=>{});let p=await P(t,"import",{format:r,filename:a.name,data:await J(a)});ce(p.snapshot,{keepLogicDraft:!1}),l(""),f([`\u5DF2\u5BFC\u5165 ${a.name}`,...p.warnings||[]].join(`
|
|
28
|
+
`)),te([])}catch(p){l(p?.message||String(p))}finally{C.current&&(C.current.value="")}}function At(){h.open(async()=>{await c.current.catch(()=>{}),await re(),await de(),await c.current,l("")})}async function Lt(){if(!(H||!q?.trim())){k(!0);try{await re(),await de(),await c.current.catch(()=>{});let a=o.current,r=await P(t,"save",{path:q.trim(),expectedRevision:a.version});ce(await P(t,"get")),f(`\u5DF2\u4FDD\u5B58\u5230 ${r.path}`),l(""),z(null),we()}catch(a){l(a?.message||String(a))}finally{k(!1)}}}if(d.useEffect(()=>{i?.inspector?.kind==="server-container"&&Pe("base")},[i?.inspector?.kind]),!i)return e("div",{className:"qxsim","data-theme":s,"data-qxsim-session-id":t},e("div",{className:"qxsim-status error"},x||"\u6B63\u5728\u8F7D\u5165\u5343\u661F\u6C99\u7BB1\u2026"));let oe=i.canvas.width,pe=i.canvas.height,je=ye.width>0&&ye.height>0?Math.min((ye.width-44)/oe,(ye.height-54)/pe):NaN,Et=Number.isFinite(je)&&je>0?Math.min(2,Math.round(je*1e3)/1e3):.5,zt=Ae==="fit"?Et:Number(Ae)||.5,Ke=Ne(oe,pe),It=(i.canvas.presets||[]).filter(a=>a.platform===i.canvas.platform);function Tt(a){if(!i||i.canvas.platform===a)return;let r=(i.canvas.presets||[]).filter(g=>g.platform===a);if(!r.length)return;let p=r.find(g=>me(g)===Ke)||r[0];E({op:"setCanvas",canvasId:p.id}).then(()=>f(`\u5DF2\u5207\u6362\u5230${p.label}`)).catch(()=>{})}let T=i.asset?.type==="client-control-template",Oe=!!(i.inspector&&i.inspector.kind!=="server-container"),De=new Set;for(let a of i.tree||[])(Le[a.id]||(a.ancestorIds||[]).some(r=>Le[r]))&&De.add(a.id);let Mt=(i.boxes||[]).filter(a=>a.kind!=="server-container"&&a.visible&&!De.has(a.id));function jt(a,r){a.stopPropagation(),xt(p=>{let g={...p};return g[r]?delete g[r]:g[r]=!0,g})}let Ze=i.tree.filter(a=>!he.trim()||`${a.name} ${a.label}`.toLowerCase().includes(he.trim().toLowerCase())),A=i.tree.find(a=>a.id===i.selectedId),Ot=T&&A?i.tree.filter(a=>a.id!==A.id&&!(a.ancestorIds||[]).includes(A.id)):[],Dt=A?.parentId||i.root.id;return e("div",{className:"qxsim","data-theme":s,"data-qxsim-session-id":t},h.overlay,Y==="script"&&x?e("div",{className:"qxsim-status error",role:"alert"},x):null,q!==null?e("div",{className:"qxsim-save-overlay"},e("form",{className:"qxsim-save-dialog",role:"dialog","aria-modal":!0,"aria-label":"\u4FDD\u5B58\u5230\u5DE5\u4F5C\u533A",onSubmit:a=>{a.preventDefault(),Lt()}},e("h2",null,"\u4FDD\u5B58\u5230\u5DE5\u4F5C\u533A"),e("label",null,"\u5B58\u6863\u76F8\u5BF9\u8DEF\u5F84",e("input",{autoFocus:!0,required:!0,value:q,disabled:H,onChange:a=>z(a.target.value)})),x?e("div",{role:"alert"},x):null,e("footer",null,e("button",{className:"qxsim-action",type:"button",disabled:H,onClick:()=>z(null)},"\u53D6\u6D88"),e("button",{className:"qxsim-action primary",type:"submit",disabled:H||!q.trim()},H?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58")))):null,e("header",{className:"qxsim-toolbar"},e("div",{className:"qxsim-brand",title:`${i.workspace?.bound?i.workspace.path:"\u5DE5\u4F5C\u533A\u672A\u7ED1\u5B9A"}
|
|
29
|
+
${i.meta?.sourceFile||"\u5C1A\u672A\u5BFC\u5165\u6587\u4EF6"}`},e("span",{className:"qxsim-appicon"},"UI"),e("span",{className:"qxsim-brand-text"},e("strong",null,`\u5B58\u6863\uFF1A${i.save?.name||i.meta?.name||"\u672A\u547D\u540D\u5B58\u6863"}`),e("span",null,`\u5DE5\u4F5C\u533A\uFF1A${i.workspace?.bound?i.workspace.name:"\u672A\u7ED1\u5B9A"} \xB7 \u5F53\u524D\u8D44\u4EA7\uFF1A${i.asset?.label||"UI\u63A7\u4EF6"}`))),e("div",{className:"qxsim-toolbar-center"},Y==="ui"?e(d.Fragment,null,e("div",{className:"qxsim-device-switch",role:"group","aria-label":"\u76EE\u6807\u8BBE\u5907"},S.map(a=>e("button",{key:a.key,className:i.canvas.platform===a.key?"active":"",title:a.title,onClick:()=>Tt(a.key)},a.label))),e("select",{className:"qxsim-control ratio","aria-label":"\u5C4F\u5E55\u6BD4\u4F8B",value:i.canvasId,onChange:a=>void E({op:"setCanvas",canvasId:a.target.value}).catch(()=>{})},It.map(a=>e("option",{key:a.id,value:a.id},`${me(a)} \xB7 ${a.width}\xD7${a.height}`))),e("select",{className:"qxsim-control zoom","aria-label":"\u753B\u5E03\u7F29\u653E",value:Ae,onChange:a=>ut(a.target.value)},[["fit","\u9002\u5E94"],["0.25","25%"],["0.5","50%"],["0.75","75%"],["1","100%"]].map(([a,r])=>e("option",{key:a,value:a},r)))):e("span",{className:"qxsim-muted"},Y==="logic"?"\u670D\u52A1\u7AEF\u903B\u8F91\uFF1A\u76D1\u542C\u4FE1\u53F7 / \u81EA\u5B9A\u4E49\u53D8\u91CF / \u73A9\u5BB61-8 \u56DE\u4F20":"Lua \u811A\u672C\u8D44\u4EA7\u7F16\u8F91")),e("div",{className:"qxsim-actions"},L?e("button",{className:"qxsim-action",title:"\u4FDD\u5B58\u5B8C\u6574\u5B58\u6863\u5230\u5DE5\u4F5C\u533A",onClick:()=>{l(""),z(o.current?.storage?.path||"qxqy-simulator.save.json")}},"\u4FDD\u5B58\u5B58\u6863"):null,e("div",{className:"qxsim-io"},e("input",{ref:C,hidden:!0,type:"file",accept:".json,.gia,.lua,application/json,application/octet-stream,text/plain",onChange:a=>void Pt(a.target.files?.[0])}),e("select",{className:"qxsim-control zoom","aria-label":"\u4ECE\u5DE5\u4F5C\u533A\u62C9\u53D6\u5B58\u6863",defaultValue:"",onFocus:()=>void we(),onChange:a=>{let r=a.target.value;a.target.value="",r&&$t(r)}},e("option",{value:"",disabled:!0},i.workspace?.bound?"\u2913 \u5DE5\u4F5C\u533A\u5B58\u6863":"\u5DE5\u4F5C\u533A\u672A\u7ED1\u5B9A"),...v.length?v.map(a=>e("option",{key:a.path,value:a.path},`${a.name} \xB7 ${a.path}`)):[e("option",{value:"",disabled:!0},i.workspace?.bound?"\u672A\u53D1\u73B0 qxqy-simulator-save":"\u5148\u7ED1\u5B9A\u4F1A\u8BDD\u5DE5\u4F5C\u533A")]),e("button",{className:"qxsim-action",title:"\u5BFC\u5165\u5B58\u6863\u3001\u5355\u9879 UI \u8D44\u4EA7\u6216 Lua",onClick:()=>C.current?.click()},"\u21E7 \u5BFC\u5165"),e("select",{className:"qxsim-control zoom","aria-label":"\u5BFC\u51FA\u683C\u5F0F",defaultValue:"",onChange:a=>{let[r,p=""]=a.target.value.split("|");a.target.value="",r&&ke(r,p)}},e("option",{value:"",disabled:!0},"\u21E9 \u5BFC\u51FA"),e("option",{value:"save"},"\u8D44\u4EA7\u5305 JSON\uFF08\u4E09\u7C7B\u5408\u4E00\uFF09"),e("option",{value:"save-gia"},"\u8D44\u4EA7\u5305 GIA\uFF08\u5DF2\u6539\u52A8\u9879\uFF09"),e("option",{value:"gia-combined"},"\u8D44\u4EA7\u5305 GIA \u6574\u5408\u5305\uFF08\u63A7\u4EF6+\u811A\u672C\uFF09"),e("optgroup",{label:"\u5F53\u524D\u754C\u9762\uFF08\u5DE6\u680F\u6B63\u5728\u770B\u7684\u90A3\u68F5\u6811\uFF09"},e("option",{value:"json"},"\u5F53\u524D\u754C\u9762 Authoring JSON"),e("option",{value:"gia"},"\u5F53\u524D\u754C\u9762 GIA")),e("optgroup",{label:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F"},e("option",{value:"json|server-control-template"},"Authoring JSON"),e("option",{value:"gia|server-control-template"},"GIA")),e("optgroup",{label:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\uFF08\u4EC5\u5F53\u5DE6\u680F\u5207\u5230\u300CUI\u63A7\u4EF6-\u5BA2\u6237\u7AEF\u300D\u65F6\u624D\u662F\u9875\u9762\u5185\u5BB9\uFF09"},e("option",{value:"json|client-control-template"},"Authoring JSON"),e("option",{value:"gia|client-control-template"},"GIA")),e("optgroup",{label:"Lua \u811A\u672C"},e("option",{value:"scripts"},"\u811A\u672C\u5305 JSON\uFF08\u5168\u90E8\u811A\u672C\uFF09"),e("option",{value:"scripts-gia"},"\u811A\u672C\u5305 GIA\uFF08\u5168\u90E8\u811A\u672C\uFF09")))),e("button",{className:"qxsim-action primary",title:"\u6253\u5F00\u8BD5\u73A9\uFF1B\u65B0\u7A97\u53E3\u4E0D\u53EF\u7528\u65F6\u5728\u5E94\u7528\u5185\u8BD5\u73A9",disabled:h.opening,onClick:At},h.opening?"\u6B63\u5728\u51C6\u5907\u2026":"\u25B7 \u8BD5\u73A9 \u2197"),e("button",{className:"qxsim-iconbtn",title:"\u91CD\u65B0\u8F7D\u5165",onClick:qe},"\u21BB"))),e("nav",{className:"qxsim-editor-nav","aria-label":"\u7F16\u8F91\u9875\u9762"},e("button",{className:Y==="ui"?"active":"",onClick:()=>fe("ui")},"UI \u7F16\u8F91"),e("button",{className:Y==="script"?"active":"",onClick:()=>fe("script")},"Lua \u811A\u672C"),e("button",{className:Y==="logic"?"active":"",onClick:()=>fe("logic")},"\u670D\u52A1\u7AEF\u903B\u8F91"),e("span",{className:"save-summary"},"\u4E00\u4E2A\u5B58\u6863 \xB7 \u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F + \u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F + Lua \u811A\u672C + \u670D\u52A1\u7AEF\u903B\u8F91")),Y==="script"?e(I,{snap:i,patch:E,request:(a,r)=>P(t,a,r),refresh:async()=>ce(await P(t,"get")),prepare:async()=>(await c.current,await re(),await de(),o.current)}):null,i.controlGuidChanges?.length?e("details",{className:"qxsim-note",open:!0,style:{flexShrink:0,maxHeight:170,overflow:"auto"}},e("summary",{style:{cursor:"pointer"}},`\u5F85\u540C\u6B65 Lua \u7D22\u5F15\u5F15\u7528\uFF08${i.controlGuidChanges.length} \u9879\uFF09`),e("div",null,"\u63A7\u4EF6\u7D22\u5F15\u5DF2\u4FEE\u6539\u3002\u8BF7\u8BA9 AI \u66F4\u65B0\u5B58\u6863\u811A\u672C\u548C\u76F8\u5173 Lua \u6E90\u6587\u4EF6\uFF0C\u5E76\u91CD\u65B0\u8BD5\u73A9\u6838\u5BF9\u3002"),e("ul",{style:{margin:"5px 0"}},i.controlGuidChanges.map(a=>e("li",{key:a.id},`${a.controlAsset==="client-control-template"?"\u5BA2\u6237\u7AEF\u6A21\u677F":"\u670D\u52A1\u7AEF\u754C\u9762"} \xB7 ${a.controlName}\uFF1A${a.oldGuid} \u2192 ${a.newGuid}`))),e("div",{style:{display:"flex",gap:6}},e("button",{className:"qxsim-action",onClick:bt},"\u590D\u5236\u7ED9 AI"),e("button",{className:"qxsim-action",title:"\u4EC5\u5728\u5DF2\u4FEE\u6539\u6216\u786E\u8BA4\u4E0D\u6D89\u53CA\u811A\u672C\u5F15\u7528\uFF0C\u5E76\u5B8C\u6210\u6838\u5BF9\u540E\u4F7F\u7528",onClick:ht},"\u5DF2\u5B8C\u6210\u811A\u672C\u540C\u6B65"))):null,N.length?e("details",{className:"qxsim-export-warnings",open:!0,role:"status",style:{flexShrink:0,maxHeight:180,overflow:"auto",padding:"8px 16px",borderBottom:"1px solid currentColor"}},e("summary",{style:{cursor:"pointer"}},`\u4E0A\u6B21\u5BFC\u51FA\u8BF4\u660E\uFF08${N.length} \u9879\uFF0C\u8BF7\u6838\u5BF9\u5BFC\u5165\u540E\u7684\u6548\u679C\uFF09`),e("button",{className:"qxsim-action",onClick:()=>te([])},"\u5173\u95ED\u5BFC\u51FA\u8BF4\u660E"),e("ul",null,N.map((a,r)=>e("li",{key:r},a)))):null,Y==="ui"?e("div",{className:"qxsim-main"},e("aside",{className:"qxsim-tree"},e("div",{className:"qxsim-asset-switch","aria-label":"\u7F16\u8F91\u8D44\u6E90\u7C7B\u578B"},e("button",{className:T?"":"active",title:"\u7F16\u8F91\u5B58\u6863\u5185\u7684\u670D\u52A1\u7AEF UI \u63A7\u4EF6",onClick:()=>void Xe("server-control-template")},"UI\u63A7\u4EF6-\u670D\u52A1\u7AEF"),e("button",{className:T?"active":"",title:"\u7F16\u8F91\u5B58\u6863\u5185\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F",onClick:()=>void Xe("client-control-template")},"UI\u63A7\u4EF6-\u5BA2\u6237\u7AEF")),e("div",{className:"qxsim-pane-head"},e("div",{className:"qxsim-pane-title"},T?"\u6A21\u677F\u4E0E\u5B50\u63A7\u4EF6":"\u63A7\u4EF6\u6811"),e("span",{className:"qxsim-muted"},T?`${i.asset.templateCount} \u4E2A\u6A21\u677F \xB7 ${i.tree.length} \u4E2A\u63A7\u4EF6`:`${i.tree.length} \u4E2A\u8282\u70B9`)),e("label",{className:"qxsim-search"},"\u2315",e("input",{value:he,placeholder:T?"\u641C\u7D22\u6A21\u677F\u6216\u63A7\u4EF6":"\u641C\u7D22\u63A7\u4EF6",onChange:a=>Ee(a.target.value)}),he?e("button",{onClick:()=>Ee("")},"\xD7"):e("span",null,"\u2301")),e("div",{className:"qxsim-tree-scroll"},Ze.length?Ze.map(a=>{let r=M[a.kind]||["\u25C7",a.label],p=De.has(a.id),g=!!Le[a.id];return e("div",{key:a.id,className:`qxsim-row${T&&a.depth===0?" template-root":""}${a.id===i.selectedId?" active":""}${p?" canvas-hidden":""}`,style:{paddingLeft:8+a.depth*18,"--depth":a.depth},title:`${r[1]} \xB7 ${a.name} \xB7 GUID ${a.guid??a.id}`,onClick:()=>void E({op:"select",id:a.id}).catch(()=>{})},e("span",{className:"qxsim-chevron"},a.childCount?"\u25BC":""),e("span",{className:"qxsim-kind"},r[0]),e("span",{className:"qxsim-row-label"},a.name),e("span",{className:"qxsim-row-end"},T&&a.depth===0?e(d.Fragment,null,e("span",{className:"qxsim-template-tag"},"\u6A21\u677F"),e("span",{className:"qxsim-template-id"},`#${a.guid??a.id}`)):a.incomplete?e("span",{className:"qxsim-incomplete"},"\u6682\u4E0D\u652F\u6301"):null,e("button",{className:`qxsim-eye${g?" off":""}`,type:"button",title:g?"\u5728\u753B\u5E03\u4E0A\u663E\u793A\uFF08\u4E0D\u5F71\u54CD\u63A7\u4EF6\u521D\u59CB\u53EF\u89C1\u6027\uFF09":"\u5728\u753B\u5E03\u4E0A\u9690\u85CF\uFF08\u4E0D\u5F71\u54CD\u63A7\u4EF6\u521D\u59CB\u53EF\u89C1\u6027\uFF09","aria-label":`${a.name}\u753B\u5E03\u53EF\u89C1\u6027`,"aria-pressed":!g,onClick:V=>jt(V,a.id)},g?"\u25CC":"\u25C9")))}):e("div",{className:"qxsim-empty"},"\u6CA1\u6709\u5339\u914D\u7684\u63A7\u4EF6")),e("div",{className:"qxsim-tree-foot"},T&&A?e("div",{className:"qxsim-hierarchy"},e("div",{className:"qxsim-hierarchy-head"},e("strong",null,"\u5C42\u7EA7\u4E0E\u6A21\u677F\u8FB9\u754C"),e("span",null,A.name)),e("div",{className:"qxsim-parent-row"},e("select",{"aria-label":"\u7236\u7EA7\u63A7\u4EF6",value:Dt,onChange:a=>void E({op:"reparent",id:A.id,parentId:a.target.value}).then(()=>f(a.target.value===i.root.id?"\u5DF2\u63D0\u5347\u4E3A\u53EF\u5B9E\u4F8B\u5316\u9876\u5C42\u6A21\u677F":"\u5DF2\u8C03\u6574\u63A7\u4EF6\u7236\u7EA7")).catch(()=>{})},e("option",{value:i.root.id},"\u9876\u5C42\u6A21\u677F\uFF08\u53EF\u5B9E\u4F8B\u5316\uFF09"),Ot.map(a=>e("option",{key:a.id,value:a.id},`${"\u3000".repeat(a.depth)}${a.name}`))),e("button",{title:"\u5728\u540C\u7EA7\u4E2D\u4E0A\u79FB",disabled:A.siblingIndex<=0,onClick:()=>void E({op:"moveSibling",id:A.id,direction:"up"}).catch(()=>{})},"\u2191"),e("button",{title:"\u5728\u540C\u7EA7\u4E2D\u4E0B\u79FB",disabled:A.siblingIndex>=A.siblingCount-1,onClick:()=>void E({op:"moveSibling",id:A.id,direction:"down"}).catch(()=>{})},"\u2193")),e("div",{className:"qxsim-hierarchy-note"},A.depth===0?"\u8BE5\u8282\u70B9\u4F1A\u5199\u5165\u72EC\u7ACB UIControlTemplate\uFF0C\u53EF\u76F4\u63A5\u4F5C\u4E3A prefabId\u3002":`\u5F53\u524D\u4E3A\u7B2C ${A.depth} \u5C42\u5B50\u63A7\u4EF6\uFF0C\u4E0D\u4F1A\u5355\u72EC\u6210\u4E3A prefabId\u3002`)):null,e("div",{className:"qxsim-palette-head"},e("span",{title:T&&le==="template"?"\u65B0\u589E\u72EC\u7ACB\u53EF\u5B9E\u4F8B\u5316\u6A21\u677F":`\u6DFB\u52A0\u5230${A?A.name:"\u5F53\u524D\u63A7\u4EF6"}`},T&&le==="template"?"\u65B0\u589E\u9876\u5C42\u6A21\u677F":`\u6DFB\u52A0\u5230${A?`\u201C${A.name}\u201D`:"\u5F53\u524D\u63A7\u4EF6"}`),T?e("span",{className:"qxsim-add-mode"},e("button",{className:le==="template"?"active":"",onClick:()=>ze("template")},"\u9876\u5C42"),e("button",{className:le==="child"?"active":"",onClick:()=>ze("child")},"\u5B50\u63A7\u4EF6")):null),e("div",{className:"qxsim-add"},ee.filter(([a])=>T||a!=="container").map(([a,r])=>e("button",{key:a,title:`${T&&le==="template"?"\u65B0\u589E":"\u6DFB\u52A0"}${r}`,onClick:()=>Ct(a,r)},`\uFF0B ${r}`))))),e("main",{className:"qxsim-center"},e("div",{className:"qxsim-workspace",ref:Ve},e("div",{className:"qxsim-stage-shell",style:{width:`${Math.max(40,Math.round(oe*zt))}px`}},e("div",{className:"qxsim-stage-label"},e("b",null,T?"Lua \u6A21\u677F\u9884\u89C8":"\u754C\u9762\u63A7\u4EF6\u7EC4"),e("span",{className:"qxsim-platform-tag"},i.canvas.platform),e("span",null,`${Ke} \xB7 ${oe}\xD7${pe} \xB7 \u5DE6\u4E0B\u539F\u70B9`)),e("div",{className:"qxsim-stage",style:{width:"100%",aspectRatio:`${oe} / ${pe}`},onClick:a=>{let r=a.currentTarget.getBoundingClientRect();E({op:"pick",x:(a.clientX-r.left)*oe/r.width,y:(r.bottom-a.clientY)*pe/r.height}).catch(()=>{})}},Mt.map(a=>dt(a,i,oe,pe))))),x?e("div",{className:"qxsim-status error"},"\u26A0 ",x):e("div",{className:"qxsim-status"},e("span",null,`\u25CF ${i.asset?.label||"\u63A7\u4EF6"}\u7F16\u8F91`),e("span",null,w||(A?`\u5F53\u524D\uFF1A${A.name}`:"")),e("span",{className:"spacer"}),e("span",null,T?"GIA \u5BFC\u51FA\u540E\u53EF\u5728 Lua \u4E2D\u6309 prefabId \u5B9E\u4F8B\u5316":"\u5B57\u6BB5\u5728\u5931\u7126\u6216 Enter \u65F6\u63D0\u4EA4"),e("a",{className:"qxsim-community",href:"https://space.bilibili.com/23358791",target:"_blank",rel:"noreferrer",title:"\u4F5C\u8005 B\u7AD9\u4E3B\u9875"},"\u4F5C\u8005B\u7AD9"),e("a",{className:"qxsim-community",href:"https://qm.qq.com/q/DpuMvxAfhm",target:"_blank",rel:"noreferrer",title:"\u52A0\u5165 QQ \u7FA4 1007538100"},"QQ\u7FA4 1007538100"))),e("aside",{className:"qxsim-inspector"},i.inspector?e(d.Fragment,null,e("div",{className:"qxsim-inspector-head"},e("div",{className:"qxsim-inspector-line"},e("span",{className:"qxsim-kind"},(M[i.inspector.kind]||["\u25C7"])[0]),e("strong",null,i.inspector.label),T&&A?.depth===0?e("span",{className:"qxsim-template-tag"},"\u53EF\u5B9E\u4F8B\u5316"):null),e("div",{className:"qxsim-node-id"},T&&A?.depth===0?"\u6A21\u677F\u7D22\u5F15 ":"\u63A7\u4EF6 GUID ",e("code",null,i.inspector.guid??i.inspector.id)," \xB7 ",A?.name||"\u8282\u70B9"),i.inspector.kind!=="server-container"?e(rt,{key:`${i.asset.type}:${i.inspector.id}`,inspector:i.inspector,onSave:(a,r)=>ft(a,r,i.asset.type)}):null),e("div",{className:"qxsim-tabs",style:Oe?void 0:{gridTemplateColumns:"1fr"}},e("button",{className:$e==="base"?"active":"",onClick:()=>Pe("base")},"\u57FA\u7840\u5C5E\u6027"),Oe?e("button",{className:$e==="script"?"active":"",onClick:()=>Pe("script")},"\u811A\u672C"):null),e("div",{className:"qxsim-inspector-scroll"},Oe&&$e==="script"?e(ot,{snap:i,addScriptMounted:a=>void Je({controlId:a,controlAsset:i.asset?.type}).then(()=>fe("script")),mountScriptTo:St,unmountScript:Nt,openScript:a=>{ve(a),fe("script")}}):e(ie,{inspector:i.inspector,commit:vt,createStateChild:yt})),e("div",{className:"qxsim-tree-foot"},e("button",{className:"qxsim-action danger",style:{width:"100%"},onClick:()=>void E({op:"remove"}).catch(()=>{})},T&&A?.depth===0?"\u232B \u5220\u9664\u5F53\u524D\u6A21\u677F":"\u232B \u5220\u9664\u5F53\u524D\u63A7\u4EF6"))):e("div",{className:"qxsim-empty"},"\u8BF7\u9009\u62E9\u4E00\u4E2A\u63A7\u4EF6"))):Y==="script"?e(m,{snap:i,selectedScriptId:Ie,selectScript:a=>{We(),ve(a)},draft:Te,updateDraft:qt,saveScript:()=>void re().then(()=>f("Lua \u811A\u672C\u5DF2\u4FDD\u5B58\u5230\u5F53\u524D\u5B58\u6863")).catch(()=>{}),addScript:()=>void Je(),removeScript:kt,exportLua:a=>void ke("lua",a),exportScripts:()=>void ke("scripts"),exportScriptsGia:()=>void ke("scripts-gia"),notice:w}):e(st,{snap:i,draft:Ye,setDraft:Me,saveLogic:()=>void de().catch(()=>{}),notice:w,error:x}))}return{SimulatorView:pt,ensureStyle:W,removeStyle:()=>document.getElementById(B)?.remove()}}window.__ModuleLoader__.load({id:"dsh-plugin-beyond-simulator",factory:d=>{let u={},ae=d("react"),L=et(ae,{async api(e,I,U){let B=await fetch("/qxqy-simulator/api/"+I,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sessionId:e,...U||{}}),...I==="play"?{signal:AbortSignal.timeout(15e3)}:{}}),F=await B.json();if(!B.ok||!F.ok)throw new Error(F.error||"Request failed");return F.value},playUrl:e=>"/qxqy-simulator/play#"+encodeURIComponent(e)});return u.inject=["slots"],u.apply=e=>{L.ensureStyle(),e.effect(()=>L.removeStyle,"qxqy-simulator: style cleanup"),e.slots.inject("conversation.view",()=>e.slots.register({name:"conversation.view",id:"qxqy-simulator",order:20,label:()=>"\u6A21\u62DF\u5668"},L.SimulatorView))},u}});})();
|
package/dsh-plugin/lib/play.html
CHANGED
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
'use strict'
|
|
43
43
|
const API = '/qxqy-simulator/api/play'
|
|
44
44
|
const sessionId = decodeURIComponent(location.hash.slice(1))
|
|
45
|
+
const embedded = window.parent !== window && new URLSearchParams(location.search).get('embedded') === '1'
|
|
46
|
+
let closing = false
|
|
47
|
+
let stopped = false
|
|
48
|
+
let embeddedApi = null
|
|
45
49
|
const $ = (id) => document.getElementById(id)
|
|
46
50
|
const stage = $('stage')
|
|
47
51
|
const cv = $('cv')
|
|
@@ -64,11 +68,16 @@
|
|
|
64
68
|
if (!showLog) requestAnimationFrame(() => fitStage(true))
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
function api(action, args = {}) {
|
|
72
|
+
if (closing && action !== 'stop') return Promise.reject(new Error('试玩正在关闭'))
|
|
73
|
+
return embeddedApi ? embeddedApi(action, args) : request(action, args)
|
|
74
|
+
}
|
|
75
|
+
async function request(action, args) {
|
|
68
76
|
const response = await fetch(API, {
|
|
69
77
|
method: 'POST',
|
|
70
78
|
headers: { 'content-type': 'application/json' },
|
|
71
79
|
body: JSON.stringify({ sessionId, action, args }),
|
|
80
|
+
signal: AbortSignal.timeout(15_000),
|
|
72
81
|
})
|
|
73
82
|
const envelope = await response.json().catch(() => null)
|
|
74
83
|
if (!response.ok || !envelope || envelope.ok !== true) throw new Error(envelope?.error || '试玩请求失败')
|
|
@@ -225,6 +234,7 @@
|
|
|
225
234
|
}
|
|
226
235
|
|
|
227
236
|
function showError(error) {
|
|
237
|
+
if (closing) return
|
|
228
238
|
$('loading').classList.add('hidden')
|
|
229
239
|
$('fatal').classList.remove('hidden')
|
|
230
240
|
$('fatal').textContent = error?.message || String(error)
|
|
@@ -238,6 +248,7 @@
|
|
|
238
248
|
onSnapshot: renderChrome,
|
|
239
249
|
onStatus: applyStatus,
|
|
240
250
|
onError: showError,
|
|
251
|
+
isActive: () => !closing,
|
|
241
252
|
})
|
|
242
253
|
play.bindInput(stage, { keysOn: window })
|
|
243
254
|
|
|
@@ -300,7 +311,40 @@
|
|
|
300
311
|
revealStage()
|
|
301
312
|
} catch (error) { showError(error) }
|
|
302
313
|
})
|
|
303
|
-
|
|
314
|
+
function quiesce() {
|
|
315
|
+
closing = true
|
|
316
|
+
document.querySelector('.app').inert = true
|
|
317
|
+
play.reset()
|
|
318
|
+
}
|
|
319
|
+
function focusStage() {
|
|
320
|
+
stage.tabIndex = -1
|
|
321
|
+
stage.focus({ preventScroll: true })
|
|
322
|
+
}
|
|
323
|
+
stage.addEventListener('pointerdown', focusStage)
|
|
324
|
+
function requestEmbeddedClose() {
|
|
325
|
+
// Custom desktop schemes can serialize their origin as "null".
|
|
326
|
+
// The parent checks the exact iframe WindowProxy and session id.
|
|
327
|
+
parent.postMessage({ type: 'qxqy-play-close', sessionId }, location.origin === 'null' ? '*' : location.origin)
|
|
328
|
+
}
|
|
329
|
+
addEventListener('keydown', event => {
|
|
330
|
+
if (embedded && event.key === 'Escape') { event.preventDefault(); requestEmbeddedClose() }
|
|
331
|
+
})
|
|
332
|
+
$('close').addEventListener('click', async () => {
|
|
333
|
+
if (embedded) {
|
|
334
|
+
requestEmbeddedClose()
|
|
335
|
+
return
|
|
336
|
+
}
|
|
337
|
+
try {
|
|
338
|
+
quiesce()
|
|
339
|
+
await api('stop')
|
|
340
|
+
stopped = true
|
|
341
|
+
window.close()
|
|
342
|
+
} catch (error) {
|
|
343
|
+
closing = false
|
|
344
|
+
document.querySelector('.app').inert = false
|
|
345
|
+
showError(error)
|
|
346
|
+
}
|
|
347
|
+
})
|
|
304
348
|
$('theme').addEventListener('click', () => { theme = theme === 'dark' ? 'light' : 'dark'; applyTheme() })
|
|
305
349
|
let lastCase = null
|
|
306
350
|
function parseAsserts() {
|
|
@@ -327,12 +371,37 @@
|
|
|
327
371
|
for (const button of document.querySelectorAll('[data-view]')) button.addEventListener('click', () => setView(button.dataset.view))
|
|
328
372
|
addEventListener('resize', () => fitStage(true))
|
|
329
373
|
addEventListener('pagehide', () => {
|
|
374
|
+
closing = true
|
|
330
375
|
play.destroy()
|
|
331
|
-
|
|
376
|
+
// Embedded close/unmount is owned by the parent. A late keepalive stop
|
|
377
|
+
// from the old frame must never terminate the next play session.
|
|
378
|
+
if (!embedded && !stopped) fetch(API, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ sessionId, action: 'stop', args: {} }), keepalive: true }).catch(() => {})
|
|
332
379
|
})
|
|
380
|
+
if (embedded) {
|
|
381
|
+
// Closing the whole application document has no awaitable teardown.
|
|
382
|
+
// This fallback is separate from normal modal close, which awaits stop.
|
|
383
|
+
const parentPagehide = () => {
|
|
384
|
+
quiesce()
|
|
385
|
+
fetch(API, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ sessionId, action: 'stop', args: {} }), keepalive: true }).catch(() => {})
|
|
386
|
+
}
|
|
387
|
+
parent.addEventListener('pagehide', parentPagehide)
|
|
388
|
+
addEventListener('pagehide', () => parent.removeEventListener('pagehide', parentPagehide))
|
|
389
|
+
}
|
|
333
390
|
|
|
334
391
|
if (!sessionId) showError(new Error('缺少会话 ID'))
|
|
335
|
-
else
|
|
392
|
+
else if (embedded) {
|
|
393
|
+
// Wait for the parent's load handler: closing a still-loading iframe
|
|
394
|
+
// must not race an automatic start from this document.
|
|
395
|
+
window.qxqyEmbeddedPlay = {
|
|
396
|
+
start: request => {
|
|
397
|
+
if (closing) return Promise.resolve()
|
|
398
|
+
embeddedApi = request
|
|
399
|
+
return play.start().then(() => { if (closing) play.reset(); else { revealStage(); focusStage() } })
|
|
400
|
+
},
|
|
401
|
+
quiesce,
|
|
402
|
+
focus: focusStage,
|
|
403
|
+
}
|
|
404
|
+
} else play.start().then(() => setTimeout(revealStage, 0)).catch(showError)
|
|
336
405
|
})()
|
|
337
406
|
</script>
|
|
338
407
|
</body>
|