mbler 0.1.1 → 0.1.3-alpha-r2

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/bin/mbler.js +12 -12
  4. package/bin/minify.js +58 -44
  5. package/lib/build/build-g-config.json +11 -11
  6. package/lib/build/index.js +1 -1
  7. package/lib/data/includes.json +12 -12
  8. package/lib/data/version.json +88 -88
  9. package/lib/lang/en.js +1 -1
  10. package/lib/lang/index.js +1 -1
  11. package/lib/lang/zh.js +1 -1
  12. package/lib/mcx/ast/tag.js +1 -1
  13. package/lib/mcx/compile-mcx/compile.js +1 -1
  14. package/lib/mcx/compile-mcx/compiler/bundler.js +1 -0
  15. package/lib/mcx/compile-mcx/compiler/compileData.js +1 -0
  16. package/lib/mcx/compile-mcx/compiler/compileMain.js +1 -0
  17. package/lib/mcx/compile-mcx/compiler/index.js +1 -0
  18. package/lib/mcx/compile-mcx/compiler/utils.js +1 -0
  19. package/lib/mcx/compile-mcx/types.js +1 -1
  20. package/lib/modules/create-game/mbler.config.json +13 -13
  21. package/lib/modules/gameLib/mbler.config.json +15 -15
  22. package/lib/modules/gutils/mbler.config.json +11 -11
  23. package/lib/modules/innerDef.json +4 -4
  24. package/lib/runTemp/config.json +3 -3
  25. package/lib/start/create.js +1 -1
  26. package/lib/start/index.js +1 -1
  27. package/lib/start/rechce.js +1 -1
  28. package/package.json +49 -1
  29. package/test/2x sword/behavior/scripts/index.js +24 -24
  30. package/test/2x sword/mbler.config.json +11 -11
  31. package/test/2x sword/package.json +13 -13
  32. package/test/README.md +7 -7
  33. package/test/des/index.js +19 -19
  34. package/test/des/mbler.config.json +4 -4
  35. package/test/des/package.json +6 -6
  36. package/test/initializer/index.js +5 -5
  37. package/test/initializer/mbler.config.json +4 -4
  38. package/test/initializer/package.json +6 -6
  39. package/test/mbler-int/behavior/res/items/mang_one_int.json +21 -21
  40. package/test/mbler-int/behavior/scripts/index.js +7 -7
  41. package/test/mbler-int/behavior/scripts/lib/event/index.js +19 -19
  42. package/test/mbler-int/behavior/scripts/lib/ui/Lore.js +18 -18
  43. package/test/mbler-int/behavior/scripts/lib/ui/baseUi.js +6 -6
  44. package/test/mbler-int/behavior/scripts/lib/ui/index.js +206 -206
  45. package/test/mbler-int/behavior/scripts/lib/utils/index.js +51 -51
  46. package/test/mbler-int/mbler.config.json +18 -18
  47. package/test/mbler-int/package.json +12 -12
  48. package/test/script-mbler/behavior/scripts/index.js +5 -5
  49. package/test/script-mbler/behavior/scripts/index.ts +5 -5
  50. package/test/script-mbler/mbler.config.json +14 -14
  51. package/test/script-mbler/package.json +15 -15
  52. package/lib/mcx/compile-mcx/_compile.js +0 -602
package/lib/lang/zh.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const cmdList=["dev","install","build","init","version","-v","web_edit","clean","checkout","-c","-i","v","create","recache","lang"];exports.default={help:`MBLER\nMinecraft Bedrock Edition\nAddon Bulider In Nodejs\n在基岩版我的世界上的 nodejs 构建工具\n解决到处查文档配置 api 版本的难题\n用法: node index.js [command]\n* 也可以 npm link 链接后省略 node 前缀\n命令 : ${cmdList.join(", ")}\n帮助命令 : \n help\n 显示帮助信息\n 第二个参数为要查询的命令名称或空\n 别名: -h, -help\n git https://github.com/RuanhoR/mbler/`,config_invalid:"非 GameLib 项目",err_bulid:"构建错误",uncommand:"无效的命令",s0:"操作成功 ",noGit:"\n检测到 Git 安全限制\nGit 拒绝操作,因为该目录可能不属于当前用户或位于系统保护路径。\n请选择处理方式:\n\n1 : 仅将当前目录加入可信区(推荐,安全)\n2 : 全局信任所有目录(不推荐,但方便)\n3 : 取消操作",SameDes:"同名的依赖",invalidConfig:"无效的配置",inited:"已经初始化过了",noGitRepo:"没有指定索取的git仓库,安装失败",invalidDes:"无效的依赖",workPackV:"当前工作目录包版本:",cleanFinally:"清理构建版本成功",noCommandTip:"你是否想表达 : ",init:{name:"项目名称 : ",desc:"项目描述 : ",useMcVersion:"支持的minecraft版本 : ",useSapi:"使用Script Api吗?(Y/N) ",useTs:"使用TypeScript吗?(Y/N) ",InputFormatErr:"不是正确的x.x.x格式版本号,重新输入\n ",main:"主脚本路径(如 ./index.js): ",useUi:"使用 UI 吗?(Y/N) ",ReInput:"不符合规范 重试:\n "},dev:{start:"开始即时监听构建 以下为第一次构建",start_d:"开始增量构建",tip:"监听到变化 : "},installGit:{NoPackage:"此 GIT 库未包含正确配置mbler",InstallFinally:"安装完成",HadBeen:"已有相同包名依赖包,是否替换? Y/N",SetContent:"正在修改索引表"},vm:{shouldNotImp:"禁止导入模块,因为该模块可以用于不安全举动",runScriptErr:"运行脚本出错,错误栈 "},build:{build_info_header:"--- 构建信息一览表 ---",project_path:"项目路径:",output_dir:"输出目录:",minify_enabled:"启用压缩:",build_time:"构建时间:",build_success:"构建成功 耗时 :",build_failed:"构建失败",config_invalid:"配置无效",package_file_missing_fields:`字段缺失:必需字段 ${JSON.stringify(["name","description","version","mcVersion"])}`,script_main_entry_missing:"启用了 script,但未指定 main 入口文件",subpack_folder_not_found:"{id} 子包文件夹不存在,打包失败",subpack_processing_failed:"子包 {id} 处理失败: {error}",includes_not_array:"includes.json 不是数组,跳过资源复制",ts_no_files:"未发现任何 .ts 文件,跳过 TypeScript 编译",ts_diagnostics:"{file} ({line},{character}): {message}",ts_compilation_error:"编译 TypeScript 时出错",no_ts_files_skip:"未发现任何 .ts 文件,跳过 TypeScript 编译",copying_subpack_script:"已复制子包脚本目录",copying_subpack_resources:"正在复制子包其他资源",removing_js_files:"移除脚本目录中的 .js 文件",copying_compiled_ts:"复制编译后的 TypeScript 文件",minification_error:"代码压缩失败",temp_mod_init:"初始化临时模块目录",script_entry_required:"script 启用但未设置 main 入口",invalid_script_entry:"main 入口文件为空或无效",module_copy_success:"模块已复制到输出目录",invalid_subpack_type:"subpack 不是对象,跳过处理",invalid_includes_type:"includes.json 不是数组,跳过资源复制",handle_includes_info:"处理 includes 资源拷贝",minification_skipped:"includes.json 非数组,跳过代码压缩",remove_js_files_info:"移除编译出的 .js 文件(如来自 ts)",process_minification:"开始代码压缩处理",copy_compiled_ts_only:"仅复制编译后的 ts 文件",temp_mod_usage:"使用临时目录处理 TypeScript 编译",build_failed_catch:"构建流程异常终止",error_message_log:"错误信息: ",exit_with_code:"进程退出,代码: ",class_pri_locked:"锁定类内关键属性",object_pri_enforced:"设置对象属性不可枚举",no_resources:"没找到资源包资源,跳过资源编译",ziped:"zip 压缩完成,你可以直接导入游戏啦\nmcaddon文件在 : ",tip_dist:"打包模式 :"},buildBase:{npm_deps_skipped_no_json:"没有找到npm依赖,跳过安装",build_time:"构建时间",cannot_read_project_config:"无法读取项目配置文件",invalid_project_config_format:"项目配置文件格式无效",starting_npm_install:"开始安装 npm 依赖",npm_install_completed:"依赖安装完成",npm_install_exit_code:"npm install 退出码:",npm_install_error:"npmInstall 错误",calculating_sha1:"计算文件 SHA1 哈希值",file_not_exist:"文件不存在",config_hash_stored:"配置哈希已存储",package_hash_stored:"包哈希已存储",config_changed:"配置已变更",package_changed:"包已变更",saving_current_hash:"保存当前哈希到缓存",removing_js_files:"移除脚本目录中的 .js 文件",removing_js_error_ignored:"移除 .js 文件错误,已忽略",removing_npm_des:"移除 npm 依赖描述",module_not_included:"模块未包含,跳过删除",recursive_remove_js:"递归移除 Js 文件",reading_file_content:"读取文件内容"},commands:{list:cmdList,dev:"mbler dev \n监听文件,在修改时重打包",build:"mbler build \n打包项目,把mbler项目打包成标准mcbe行为包,mbler项目介绍详见文档",init:"mbler init \n初始化路径的配置文件,以命令行交互式创建,别名: -i",version:"mbler version [null | x.x.x] \n查看或设置当前工作目录的包版本","-c":"$checkout","-i":"$init","-v":"$v",v:"mbler [v/-v] \n查看mbler工具本身的版本",checkout:"mbler [checkout/-c] [null | PATH]\n查看(当第二个参数为null时)或切换工作目录",web_edit:"mbler web_edit \n开启本地 HTTP 工作目录的文本编辑器,开发中不建议食用",create:"mbler create [npm package name | git url | path]\n从指定源下载后(有缓存)进行在沙盒vm内的创建模板包,类似npm create",recache:"mbler recache \n重置缓存",lang:"mbler lang [lang name] \n设置语言,如 mbler lang zh_CN\n目前语言有 \n 1. zh 中文 \n 2. en 英文",install:"mbler install [modulesName[]]\n安装模块,会顺便扫描配置中声明的模块"}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const cmdList=["dev","install","build","init","version","-v","clean","checkout","-c","-i","v","create","recache","lang"];exports.default={help:`MBLER\nMinecraft Bedrock Edition\nAddon Bulider In Nodejs\n在基岩版我的世界上的 nodejs 构建工具\n解决到处查文档配置 api 版本的难题\n用法: node index.js [command]\n* 也可以 npm link 链接后省略 node 前缀\n命令 : ${cmdList.join(", ")}\n帮助命令 : \n help\n 显示帮助信息\n 第二个参数为要查询的命令名称或空\n 别名: -h, -help\n git https://github.com/RuanhoR/mbler/`,config_invalid:"非 GameLib 项目",err_bulid:"构建错误",uncommand:"无效的命令",s0:"操作成功 ",noGit:"\n检测到 Git 安全限制\nGit 拒绝操作,因为该目录可能不属于当前用户或位于系统保护路径。\n请选择处理方式:\n\n1 : 仅将当前目录加入可信区(推荐,安全)\n2 : 全局信任所有目录(不推荐,但方便)\n3 : 取消操作",SameDes:"同名的依赖",invalidConfig:"无效的配置",inited:"已经初始化过了",noGitRepo:"没有指定索取的git仓库,安装失败",invalidDes:"无效的依赖",workPackV:"当前工作目录包版本:",cleanFinally:"清理构建版本成功",noCommandTip:"你是否想表达 : ",init:{name:"项目名称 : ",desc:"项目描述 : ",useMcVersion:"支持的minecraft版本 : ",useSapi:"使用Script Api吗?(Y/N) ",useTs:"使用TypeScript吗?(Y/N) ",InputFormatErr:"不是正确的x.x.x格式版本号,重新输入\n ",main:"主脚本路径(如 ./index.js): ",useUi:"使用 UI 吗?(Y/N) ",ReInput:"不符合规范 重试:\n "},dev:{start:"开始即时监听构建 以下为第一次构建",start_d:"开始增量构建",tip:"监听到变化 : "},installGit:{NoPackage:"此 GIT 库未包含正确配置mbler",InstallFinally:"安装完成",HadBeen:"已有相同包名依赖包,是否替换? Y/N",SetContent:"正在修改索引表"},vm:{shouldNotImp:"禁止导入模块,因为该模块可以用于不安全举动",runScriptErr:"运行脚本出错,错误栈 "},build:{build_info_header:"--- 构建信息一览表 ---",project_path:"项目路径:",output_dir:"输出目录:",minify_enabled:"启用压缩:",build_time:"构建时间:",build_success:"构建成功 耗时 :",build_failed:"构建失败",config_invalid:"配置无效",package_file_missing_fields:`字段缺失:必需字段 ${JSON.stringify(["name","description","version","mcVersion"])}`,script_main_entry_missing:"启用了 script,但未指定 main 入口文件",subpack_folder_not_found:"{id} 子包文件夹不存在,打包失败",subpack_processing_failed:"子包 {id} 处理失败: {error}",includes_not_array:"includes.json 不是数组,跳过资源复制",ts_no_files:"未发现任何 .ts 文件,跳过 TypeScript 编译",ts_diagnostics:"{file} ({line},{character}): {message}",ts_compilation_error:"编译 TypeScript 时出错",no_ts_files_skip:"未发现任何 .ts 文件,跳过 TypeScript 编译",copying_subpack_script:"已复制子包脚本目录",copying_subpack_resources:"正在复制子包其他资源",removing_js_files:"移除脚本目录中的 .js 文件",copying_compiled_ts:"复制编译后的 TypeScript 文件",minification_error:"代码压缩失败",temp_mod_init:"初始化临时模块目录",script_entry_required:"script 启用但未设置 main 入口",invalid_script_entry:"main 入口文件为空或无效",module_copy_success:"模块已复制到输出目录",invalid_subpack_type:"subpack 不是对象,跳过处理",invalid_includes_type:"includes.json 不是数组,跳过资源复制",handle_includes_info:"处理 includes 资源拷贝",minification_skipped:"includes.json 非数组,跳过代码压缩",remove_js_files_info:"移除编译出的 .js 文件(如来自 ts)",process_minification:"开始代码压缩处理",copy_compiled_ts_only:"仅复制编译后的 ts 文件",temp_mod_usage:"使用临时目录处理 TypeScript 编译",build_failed_catch:"构建流程异常终止",error_message_log:"错误信息: ",exit_with_code:"进程退出,代码: ",class_pri_locked:"锁定类内关键属性",object_pri_enforced:"设置对象属性不可枚举",no_resources:"没找到资源包资源,跳过资源编译",ziped:"zip 压缩完成,你可以直接导入游戏啦\nmcaddon文件在 : ",tip_dist:"打包模式 :"},buildBase:{npm_deps_skipped_no_json:"没有找到npm依赖,跳过安装",build_time:"构建时间",cannot_read_project_config:"无法读取项目配置文件",invalid_project_config_format:"项目配置文件格式无效",starting_npm_install:"开始安装 npm 依赖",npm_install_completed:"依赖安装完成",npm_install_exit_code:"npm install 退出码:",npm_install_error:"npmInstall 错误",calculating_sha1:"计算文件 SHA1 哈希值",file_not_exist:"文件不存在",config_hash_stored:"配置哈希已存储",package_hash_stored:"包哈希已存储",config_changed:"配置已变更",package_changed:"包已变更",saving_current_hash:"保存当前哈希到缓存",removing_js_files:"移除脚本目录中的 .js 文件",removing_js_error_ignored:"移除 .js 文件错误,已忽略",removing_npm_des:"移除 npm 依赖描述",module_not_included:"模块未包含,跳过删除",recursive_remove_js:"递归移除 Js 文件",reading_file_content:"读取文件内容"},commands:{list:cmdList,dev:"mbler dev \n监听文件,在修改时重打包",build:"mbler build \n打包项目,把mbler项目打包成标准mcbe行为包,mbler项目介绍详见文档",init:"mbler init \n初始化路径的配置文件,以命令行交互式创建,别名: -i",version:"mbler version [null | x.x.x] \n查看或设置当前工作目录的包版本","-c":"$checkout","-i":"$init","-v":"$v",v:"mbler [v/-v] \n查看mbler工具本身的版本",checkout:"mbler [checkout/-c] [null | PATH]\n查看(当第二个参数为null时)或切换工作目录",web_edit:"mbler web_edit \n开启本地 HTTP 工作目录的文本编辑器,开发中不建议食用",create:"mbler create [npm package name | git url | path]\n从指定源下载后(有缓存)进行在沙盒vm内的创建模板包,类似npm create",recache:"mbler recache \n重置缓存",lang:"mbler lang [lang name] \n设置语言,如 mbler lang zh_CN\n目前语言有 \n 1. zh 中文 \n 2. en 英文",install:"mbler install [modulesName[]]\n安装模块,会顺便扫描配置中声明的模块"}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class Lexer{text;booleanProxyCache;constructor(t){this.text=t,this.booleanProxyCache=new WeakMap}get tokens(){return{[Symbol.iterator]:()=>this.tokenIterator()}}parseAttributes(t){const e={};let r="",n="",o=!0,a="",s=!1,l=null,i=!0;for(let c=0;c<t.length;c++){const h=t[c];if(i)if(" "===h||">"===h){if(a=r.trim(),r="",i=!1,">"===h)break}else r+=h;else if(s)h!==l||0!==n.length&&"\\"===n[n.length-1]?n+=h:(e[r.trim()]=n,r="",n="",o=!0,s=!1,l=null);else if("="===h&&o){o=!1,s=!0;const e=c+1,r=e<t.length?t[e]:" ";l='"'===r||"'"===r?r:null}else" "===h&&o&&r?(e[r.trim()]="true",r=""):o&&(r+=h)}return i?a=r.trim():r&&(e[r.trim()]=s?n.replace(/^["']/,"").replace(/["']$/,""):"true"),{name:a,arr:e}}*tagSplitIterator(){let t=!1,e="",r="";for(const n of this.text)if("<"===n){if(r){const t={data:r,type:"Content"};yield t,r=""}t=!0,e="<"}else if(">"===n){if(!t)throw new Error("未匹配的 '>'");e+=">",t=!1;const r=e.startsWith("</")?"TagEnd":"Tag",n={data:e,type:r};yield n,e=""}else t?e+=n:r+=n;if(r){const t={data:r,type:"Content"};yield t}}*tokenIterator(){const t=Array.from(this.tagSplitIterator());let e=null,r=0;for(let n=0;n<t.length;n++){const o=t[n];if(o)if("Tag"===o.type){const t=this.parseAttributes(o.data.slice(1,-1));e={start:o,name:t.name,arr:t.arr,content:null,end:null},r=n+1}else if("TagEnd"===o.type&&e){e.end=o;let a="";for(let e=r;e<n;e++){a+=t[e].data}const s={data:a,type:"TagContent"};e.content=s;const l={start:e.start,name:e.name,arr:e.arr,content:e.content,end:e.end};yield l,e=null}}}getBooleanCheckProxy(){if(!this.booleanProxyCache.has(this)){const t=new Map,e=new Proxy({},{get:(e,r)=>"string"==typeof r&&(t.get(r)||!1),set:(e,r,n)=>"string"==typeof r&&(t.set(r,Boolean(n)),!0)});this.booleanProxyCache.set(this,e)}return this.booleanProxyCache.get(this)}}class McxAst{text;constructor(t){this.text=t}getAST(){const t=new Lexer(this.text);return Array.from(t.tokens)}get data(){return this.getAST()}parseAST(){return this.getAST()}static generateCode(t){let e=`<${t.name}`;for(const[r,n]of Object.entries(t.arr))e+="true"===n?` ${r}`:` ${r}=${n}`;return e+=">",t.content&&(e+=t.content.data),e+=`</${t.name}>`,e}}exports.default=McxAst;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MCXUtils=void 0;class Lexer{text;booleanProxyCache;constructor(t){this.text=t,this.booleanProxyCache=new WeakMap}get tokens(){return{[Symbol.iterator]:()=>this.tokenIterator()}}parseAttributes(t){const e={};let n="",s="",r=!0,a="",i=!1,o=null,l=!0;for(let c=0;c<t.length;c++){const d=t[c];if(l)if(" "===d||">"===d){if(a=n.trim(),n="",l=!1,">"===d)break}else n+=d;else if(i)d!==o||0!==s.length&&"\\"===s[s.length-1]?s+=d:(e[n.trim()]=s,n="",s="",r=!0,i=!1,o=null);else if("="===d&&r){r=!1,i=!0;const e=c+1,n=e<t.length?t[e]:" ";o='"'===n||"'"===n?n:null}else" "===d&&r&&n?(e[n.trim()]="true",n=""):r&&(n+=d)}return l?a=n.trim():n&&(e[n.trim()]=i?s.replace(/^["']/,"").replace(/["']$/,""):"true"),{name:a,arr:e}}*tagSplitIterator(){const t=this.text;let e=0,n=1;const s=t.length;for(;e<s;){if("<"===t[e]){if(t.startsWith("!--",e+1)){const r=t.indexOf("--\x3e",e+4),a=-1===r?s-1:r+2,i=t.slice(e,a+1);for(const t of i)"\n"===t&&n++;e=a+1;continue}const r=e,a=n;let i=e+1,o=!1;for(;i<s;i++){const e=t[i];if(">"===e){o=!0;break}"\n"===e&&n++}const l=i,c=t.slice(r,o?i+1:s),d=c.startsWith("</")?"TagEnd":"Tag",g={data:c,type:d,startIndex:r,endIndex:o?l:s-1,startLine:a};yield g,e=o?i+1:s}else{const r=e,a=n;let i=e;for(;i<s;i++){const e=t[i];if("<"===e)break;"\n"===e&&n++}const o={data:t.slice(r,i),type:"Content",startIndex:r,endIndex:i-1,startLine:a};yield o,e=i}}}*tokenIterator(){const t=Array.from(this.tagSplitIterator()),e=[],n=[];for(let s=0;s<t.length;s++){const r=t[s];if(r)if("Content"===r.type){const t={data:r.data,type:"TagContent"};if(n.length>0){n[n.length-1].content.push(t)}else e.push(t)}else if("Tag"===r.type){const t=r.data.slice(1,-1).trim(),e=t.endsWith("/"),s=this.parseAttributes(e?t.slice(0,-1).trim():t),a={start:r,name:s.name,arr:s.arr,content:[],end:null,loc:{start:{line:r.startLine||1,index:r.startIndex||0},end:{line:r.startLine||1,index:r.endIndex||r.startIndex||0}}};e?n.length>0?n[n.length-1].content.push(a):yield a:n.push(a)}else if("TagEnd"===r.type){const t=r.data.replace(/^<\/\s*/,"").replace(/\s*>$/,"").trim();for(let e=n.length-1;e>=0;e--){const s=n[e];if(s&&s.name===t){s.end=r,s.loc.end={line:r.startLine||s.loc.start.line,index:r.endIndex||r.loc.start.index},n.splice(e,1),n.length>0?n[n.length-1].content.push(s):yield s;break}}}}for(;n.length>0;){const t=n.shift();n.length>0?n[0].content.push(t):yield t}}getBooleanCheckProxy(){if(!this.booleanProxyCache.has(this)){const t=new Map,e=new Proxy({},{get:(e,n)=>"string"==typeof n&&(t.get(n)||!1),set:(e,n,s)=>"string"==typeof n&&(t.set(n,Boolean(s)),!0)});this.booleanProxyCache.set(this,e)}return this.booleanProxyCache.get(this)}}class McxAst{text;constructor(t){this.text=t}getAST(){const t=new Lexer(this.text);return Array.from(t.tokens)}get data(){return this.getAST()}parseAST(){return this.getAST()}static generateCode(t){let e=`<${t.name}`;for(const[n,s]of Object.entries(t.arr||{}))e+="true"===s?` ${n}`:` ${n}=${String(s)}`;e+=">";const n=t.content;if(Array.isArray(n))for(const t of n)"TagContent"===t.type?e+=t.data:e+=McxAst.generateCode(t);return e+=`</${t.name}>`,e}}exports.default=McxAst;class MCXUtils{static isTagNode(t){return!!t&&"object"==typeof t&&"start"in t&&"name"in t&&"arr"in t&&"content"in t&&"end"in t}static isTagContentNode(t){return!!t&&"object"==typeof t&&"data"in t&&"type"in t&&"TagContent"===t.type}static isAttributeMap(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}static isToken(t){return!!t&&"object"==typeof t&&"data"in t&&"type"in t&&("Tag"===t.type||"TagEnd"===t.type||"Content"===t.type)}static isTagToken(t){return MCXUtils.isToken(t)&&"Tag"===t.type}static isTagEndToken(t){return MCXUtils.isToken(t)&&"TagEnd"===t.type}static isContentToken(t){return MCXUtils.isToken(t)&&"Content"===t.type}static isBaseToken(t){return!!t&&"object"==typeof t&&"data"in t&&"type"in t}static isTokenType(t){return"Tag"===t||"TagEnd"===t||"Content"===t}static isParseNode(t){return Array.isArray(t)&&t.every(MCXUtils.isTagNode)}}exports.MCXUtils=MCXUtils;
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CompileMcxProject;const utils_js_1=__importDefault(require("./../utils.js")),_compile_js_1=__importDefault(require("./_compile.js"));function CompileMcxProject(t){return new Compile(t).start()}class Compile{BuildOpt;constructor(t){if(this.BuildOpt=t,!utils_js_1.default.TypeVerify(this.BuildOpt,{cacheDir:"string",main:"string",moduleDir:"string",output:"string",isCache:"boolean"}))throw new TypeError("[compile checker]Input Opt is not right")}async start(){await new _compile_js_1.default(this.BuildOpt).compile()}}
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CompileMcxProject;const utils_js_1=__importDefault(require("./../utils.js"));function CompileMcxProject(t){return new Compile(t).start()}class Compile{BuildOpt;constructor(t){if(this.BuildOpt=t,!utils_js_1.default.TypeVerify(this.BuildOpt,{cacheDir:"string",main:"string",moduleDir:"string",output:"string",isCache:"boolean"}))throw new TypeError("[compile checker]Input Opt is not right")}async start(){}}
@@ -0,0 +1 @@
1
+ "use strict";function bundlerWrite(e){}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=bundlerWrite;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MCXCompileData=exports.JsCompileData=void 0;class JsCompileData{node;BuildCache;File="__repl";isFile=!1;constructor(e,t={export:[],import:[],call:[]}){this.node=e,this.BuildCache=t}setFilePath(e){this.isFile=!0,this.File=e}}exports.JsCompileData=JsCompileData;class MCXCompileData{raw;JSIR;strLoc;File="";isFile=!1;constructor(e,t,i){this.raw=e,this.JSIR=t,this.strLoc=i}setFilePath(e){this.JSIR.setFilePath(e),this.isFile=!0,this.File=e}}exports.MCXCompileData=MCXCompileData;
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=e(t),n=0;n<i.length;n++)"default"!==i[n]&&__createBinding(r,t,i[n]);return __setModuleDefault(r,t),r}}();Object.defineProperty(exports,"__esModule",{value:!0});const utils_1=require("./../../../utils"),compiler=__importStar(require("./")),promises_1=require("node:fs/promises"),node_path_1=require("node:path");class CompileMain{opt;main="";constructor(e){this.opt=e,"string"==typeof e.main&&(this.main=(0,utils_1.join)(e.ProjectDir,e.main))}async start(){if(!this.main)throw new Error("[mcx load]: mcx loader must has a main file");const e=await(0,promises_1.readFile)(this.main,"utf-8");this.compMain(e)}compMain(e){if(".js"!==(0,node_path_1.extname)(this.main))throw new Error("[load project]: main file must is a javascript.");return compiler.compileJSFn(e)}}exports.default=CompileMain;
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,o)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var r=e(t),o=0;o<r.length;o++)"default"!==r[o]&&__createBinding(i,t,r[o]);return __setModuleDefault(i,t),i}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompileJS=void 0,exports.compileJSFn=compileJSFn,exports.compileMCXFn=compileMCXFn;const t=__importStar(require("@babel/types")),types_1=require("../types"),CompileData=__importStar(require("./compileData")),utils_1=__importDefault(require("./utils")),parser_1=require("@babel/parser"),tag_1=__importStar(require("../../ast/tag")),prop_1=__importDefault(require("../../ast/prop"));class CompileJS{node;constructor(e){if(this.node=e,!t.isProgram(e))throw new Error("[compile error]: jsCompile can't work in a not program");this.CompileData=new CompileData.JsCompileData(e),this.run(),this.writeBuildCache()}TopContext={};indexTemp={};push(e){for(const t of e.imported)this.indexTemp[t.as]={source:e.source,import:t.import,isAll:t.isAll}}takeInnerMost(e){if(!t.isMemberExpression(e))throw new Error("[take item}: must MemberExpression");let i=e;for(;;){if(!t.isMemberExpression(i)){if(t.isCallExpression(i)){const e=i.callee;if(t.isMemberExpression(e)){i=e.object;continue}i=e;continue}return t.isIdentifier(i)||t.isThisExpression(i)||t.isSuper(i)||t.isImport(i)||t.isNewExpression(i)||"function"==typeof t.isLiteral&&t.isLiteral(i)||t.isLiteral(i)?i:t.stringLiteral("")}i=i.object}}writeImportKeys=[];extractIdentifierNames(e){const i=[];if(t.isIdentifier(e))i.push(e.name);else if(t.isMemberExpression(e))i.push(...this.extractIdentifierNames(e.object)),"PrivateName"!==e.property.type&&i.push(...this.extractIdentifierNames(e.property));else if(t.isCallExpression(e)){i.push(...this.extractIdentifierNames(e.callee));for(const r of e.arguments)t.isExpression(r)&&i.push(...this.extractIdentifierNames(r))}else t.isBinaryExpression(e)||t.isLogicalExpression(e)?(i.push(...this.extractIdentifierNames(e.left)),i.push(...this.extractIdentifierNames(e.right))):t.isUnaryExpression(e)?i.push(...this.extractIdentifierNames(e.argument)):t.isConditionalExpression(e)&&(i.push(...this.extractIdentifierNames(e.test)),i.push(...this.extractIdentifierNames(e.consequent)),i.push(...this.extractIdentifierNames(e.alternate)));return i}writeBuildCache(){const e=[];let t=[];for(const[i,r]of Object.entries(this.indexTemp))if(this.writeImportKeys.includes(i))if(e.includes(r.source)){let e=!1;for(const o in t){const n=t[o];n&&(n.source==r.source&&(n.imported.push({as:i,isAll:r.isAll,import:r.import}),e=!0))}if(!e)throw new Error("[mcx compoiler]: internal error: unexpected source")}else t.push({source:r.source,imported:[{as:i,import:r.import,isAll:r.isAll}]}),e.push(r.source);this.CompileData.BuildCache.import=t}CompileData;getCompileData(){return this.CompileData}conditionalInTempImport(e,i,r){if(t.isIdentifier(e))e.name in this.indexTemp&&!this.writeImportKeys.includes(e.name)&&this.writeImportKeys.push(e.name);else if("FunctionExpression"!=e.type)if("ArrowFunctionExpression"!=e.type){if(!t.isLiteral(e)){if(t.isMemberExpression(e)){const o=this.extractIdentifierNames(e);for(const e of o)e in this.indexTemp&&!this.writeImportKeys.includes(e)&&this.writeImportKeys.push(e);return this.conditionalInTempImport(e.object,i,r),void(t.isExpression(e.property)&&this.conditionalInTempImport(e.property,i,r))}if(t.isCallExpression(e)&&"V8IntrinsicIdentifier"!==e.callee?.type){this.CompileData.BuildCache.call.push({source:e.callee,arguments:e.arguments,remove:r}),this.conditionalInTempImport(e.callee,i,r);for(const o of e.arguments)t.isExpression(o)&&this.conditionalInTempImport(o,i,r)}else try{const t=this.extractIdentifierNames(e);for(const e of t)e in this.indexTemp&&!this.writeImportKeys.includes(e)&&this.writeImportKeys.push(e)}catch(e){}}}else t.isExpression(e.body)?this.conditionalInTempImport(e.body,i,r):this.tre(e.body);else this.tre(t.blockStatement([e.body]))}tre(e,i={}){if(!t.isBlock(e))throw new Error("[compile error]: can't for in not block node");const r=t.isProgram(e),o=r?this.TopContext:i;for(let i=0;i<e.body.length;i++){const n=e.body[i],s=()=>{e.body.splice(i,1),i--};if(n)if("ImportDeclaration"==n.type){if(!r)throw new Error("[compile node]: import declaration must use in top.");this.push(utils_1.default.ImportToCache(n)),s()}else if("BlockStatement"==n.type)this.tre(n,o);else{if("BreakStatement"==n.type||"EmptyStatement"==n.type||"ContinueStatement"==n.type||"ThrowStatement"==n.type||"WithStatement"==n.type)continue;if("TryStatement"==n.type)this.tre(n.block,o);else if("IfStatement"==n.type){const e=n.test;this.conditionalInTempImport(e,o,s);const i=[n.consequent];n.alternate&&i.push(n.alternate),this.tre(t.blockStatement(i),o)}else if("WhileStatement"==n.type)this.tre(t.blockStatement([n.body]),o);else if("ClassDeclaration"==n.type){if(n.superClass){const e=n.superClass;let t=null;if("Identifier"==e.type&&(t=e.name),"MemberExpression"==e.type){const i=this.takeInnerMost(e);"Identifier"==i.type&&(t=i.name)}if("ArrayExpression"==e.type||"BooleanLiteral"==e.type||"BinaryExpression"==e.type||"ThisExpression"==e.type||"ArrowFunctionExpression"==e.type||"BigIntLiteral"==e.type||"NumericLiteral"==e.type||"NullLiteral"==e.type||"AssignmentExpression"==e.type||"Super"==e.type||"NewExpression"==e.type||"DoExpression"==e.type||"StringLiteral"==e.type||"YieldExpression"==e.type||"RecordExpression"==e.type||"RegExpLiteral"==e.type||"DecimalLiteral"==e.type||"BindExpression"==e.type)throw new Error("[compilr error]: class can't extends a not constructor or null");t&&this.indexTemp[t]&&this.writeImportKeys.push(t)}}else if("DoWhileStatement"==n.type)this.tre(t.blockStatement([n.body])),this.conditionalInTempImport(n.test,o,s);else if("VariableDeclaration"==n.type){const e=n.declarations;for(const t of e){const e=t.init,i=t.id;if("Identifier"==i.type){if(e||"let"!=n.kind&&"var"!=n.kind||(o[i.name]={status:"wait"}),!e)throw new Error("[compilr node]: 'const' must has a init");o[i.name]=e}}}else if("ReturnStatement"==n.type){const e=n.argument;if(!e)continue;this.conditionalInTempImport(e,o,s)}else if("ExportAllDeclaration"==n.type||"ExportDefaultDeclaration"==n.type||"ExportNamedDeclaration"==n.type){if(!r)throw new Error("[compiler]: export node can't in not top");this.CompileData.BuildCache.export.push(n),s()}else if("SwitchStatement"==n.type){const e=n.discriminant;this.conditionalInTempImport(e,o,s);for(const e of n.cases)e.test&&this.conditionalInTempImport(e.test,o,s),this.tre(t.blockStatement(e.consequent),o)}else if("ExpressionStatement"==n.type)this.conditionalInTempImport(n.expression,o,s);else if("FunctionDeclaration"==n.type){const e=n.body;this.tre(e,o)}}}}run(){if(!t.isBlock(this.node))throw new Error("[compile error]: can't for a not block");this.tre(this.node)}}exports.CompileJS=CompileJS;class CompileMCX{code;constructor(e){this.code=e;const t=new tag_1.default(e).parseAST();if(!tag_1.MCXUtils.isParseNode(t))throw new Error("[compile error]: mcxCompile can't work in a not mcxNode");this.mcxCode=t,this.structureCheck();const i=this.genenrateJSIR();this.CompileData=new CompileData.MCXCompileData(t,i,this.tempLoc)}mcxCode;tempLoc={script:"",Event:{on:"after",subscribe:{}},Component:{}};getCompileData(){return this.CompileData}checkComponentName(e){return Object.values(types_1._MCXstructureLocComponentTypes).includes(e)}checkComponentParentName(e){return Object.keys(types_1._MCXstructureLocComponentTypes).includes(e)}commonTagNodeContent(e){if(tag_1.MCXUtils.isTagContentNode(e))return e.data;if(tag_1.MCXUtils.isTagNode(e))return e.content.map(e=>this.commonTagNodeContent(e)).join("");throw new Error("[mcx compile]: internal error: unknown node type")}getEventOn(e){if(!tag_1.MCXUtils.isTagNode(e))throw new Error("[mcx compile]: internal error: not tag node");let t="after";const i="string"==typeof e.arr["@after"],r="string"==typeof e.arr["@before"];if(i&&r)throw new Error("[mcx compile]: Event node can't has both @after and @before");return i&&(t="after"),r&&(t="before"),t}structureCheck(){let e=null;const t={script:"",Event:null,Component:{}};for(const i of this.mcxCode||[])tag_1.MCXUtils.isTagNode(i)&&("script"==i.name?t.script=0==i.content.length?"":this.commonTagNodeContent(i):"Event"==i.name?t.Event=i:"Component"==i.name&&(e=i));if(!t.script)throw new Error("[compile error]: mcx must has a script");if(this.tempLoc.script=t.script,t.Event){const e=this.getEventOn(t.Event),i=t.Event.content;if(0==i.length||i.length>1||!tag_1.MCXUtils.isTagContentNode(i[0]))throw new Error("[compile error]: Event node has invalid content");const r=i[0].data.trim();this.tempLoc.Event={on:e,subscribe:Object.fromEntries((0,prop_1.default)(r).map(e=>[e.key,e.value.toString()]))}}if(e)for(const t of e.content||[]){if(!tag_1.MCXUtils.isTagNode(t))continue;t.name;this.handlerChildComponent(t)}}handlerChildComponent(e){const t=e.name;if(!this.checkComponentParentName(t))throw new Error(`[compile error]: invalid component name: ${t}`);const i=e.content;if(!i||0==i.length)throw new Error(`[compile error]: component ${t} has no content`);for(const e of i){if(!tag_1.MCXUtils.isTagNode(e))continue;const i=e.name,r=e.arr.id;if(!r||"string"!=typeof r||""==r.trim())throw new Error(`[compile error]: component ${t} child component ${i} has no id`);const o=r.trim(),n=e.content;if(0==n.length)throw new Error(`[compile error]: component ${t} child component ${i} has no content`);if(!n[0]||!tag_1.MCXUtils.isTagContentNode(n[0]))throw new Error(`[compile error]: component ${t} child component ${i} has invalid content`);const s=n[0].data.trim();i==types_1._MCXstructureLocComponentTypes[t]&&(this.tempLoc.Component[`${t}/${o}`]={type:i,useExpore:s})}}CompileData;genenrateJSIR(){if(!this.tempLoc.script.trim())throw new Error("[compile error]: mcx must has a script");return compileJSFn(this.tempLoc.script)}}function compileJSFn(e){const t=new CompileJS((0,parser_1.parse)(e,{sourceType:"module"}).program);return t.run(),t.getCompileData()}function compileMCXFn(e){return new CompileMCX(e).getCompileData()}
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=e(t),o=0;o<i.length;o++)"default"!==i[o]&&__createBinding(r,t,i[o]);return __setModuleDefault(r,t),r}}();Object.defineProperty(exports,"__esModule",{value:!0});const promises_1=require("node:fs/promises"),Parser=__importStar(require("@babel/parser")),t=__importStar(require("@babel/types"));class Utils{static async FileAST(e,t){if("string"!=typeof e)throw new TypeError("[read file]: compile utils was passed a non-string value");const r=await(0,promises_1.readFile)(e,"utf-8");if("string"!=typeof r)throw new Error("[read file]: not found file "+e);try{return Parser.parse(r).program}catch(e){throw new Error("[compile ast]: "+e.stack)}}static async FileContent(e){return await(0,promises_1.readFile)(e,"utf-8")}static nodeStringValue(e){if("StringLiteral"==e.type)return e.value;if("Identifier"==e.type)return e.name;throw new TypeError("[read id error]: no way to read string id")}static CheckImportNode(e,t){const r=Utils.ImportToCache(e);if(r.source!==t.source)return!1;if(r.imported.length!==t.imported.length)return!1;for(let e=0;e<r.imported.length;e++){const i=r.imported[e],o=t.imported[e];if(i?.import!==o?.import||i?.as!==o?.as||i?.isAll!==o?.isAll)return!1}return!0}static CacheToImportNode(e){if(!e)throw new TypeError("plase call use right ImportList");if(e?.raw&&Utils.CheckImportNode(e?.raw,e))return e.raw;let r=[];for(let i of e.imported)if(i)if(i.isAll)r.push(t.importNamespaceSpecifier(t.identifier(i.as)));else if("default"!=i.import){if(!i.import)throw new TypeError("[compile node]: not found imported");r.push(t.importSpecifier(t.identifier(i.as),t.identifier(i.import)))}else r.push(t.importDefaultSpecifier(t.identifier(i.as)));return t.importDeclaration(r,t.stringLiteral(e.source))}static ImportToCache(e){const t=[];for(let r of e.specifiers){const e=r.local.name;"ImportNamespaceSpecifier"==r.type?t.push({isAll:!0,as:e}):"ImportDefaultSpecifier"==r.type?t.push({isAll:!1,import:"default",as:e}):"ImportSpecifier"==r.type&&t.push({isAll:!1,as:e,import:Utils.nodeStringValue(r.imported)})}return{source:Utils.nodeStringValue(e.source),imported:t}}}exports.default=Utils;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._MCXstructureLocComponentTypes=void 0,exports._MCXstructureLocComponentTypes={items:"item",blocks:"block",entities:"entity"};
@@ -1,14 +1,14 @@
1
- {
2
- "name": "create-game",
3
- "description": "create game fast",
4
- "git": "gitee.com/ykxyx666_admin/sapi-game.git",
5
- "version": "0.0.1",
6
- "type": "scriptsDes",
7
- "script": {
8
- "main": "./src/main.js"
9
- },
10
- "mcVersion": [
11
- "1.21.10",
12
- "1.21.120"
13
- ]
1
+ {
2
+ "name": "create-game",
3
+ "description": "create game fast",
4
+ "git": "gitee.com/ykxyx666_admin/sapi-game.git",
5
+ "version": "0.0.1",
6
+ "type": "scriptsDes",
7
+ "script": {
8
+ "main": "./src/main.js"
9
+ },
10
+ "mcVersion": [
11
+ "1.21.10",
12
+ "1.21.120"
13
+ ]
14
14
  }
@@ -1,16 +1,16 @@
1
- {
2
- "name": "GameLib",
3
- "description": "test",
4
- "version": "0.0.1",
5
- "type": "scriptsDes",
6
- "script": {
7
- "main": "./src/index.js",
8
- "dependencies":{
9
- "gutils": "inner"
10
- }
11
- },
12
- "mcVersion": [
13
- "1.21.10",
14
- "1.21.120"
15
- ]
1
+ {
2
+ "name": "GameLib",
3
+ "description": "test",
4
+ "version": "0.0.1",
5
+ "type": "scriptsDes",
6
+ "script": {
7
+ "main": "./src/index.js",
8
+ "dependencies":{
9
+ "gutils": "inner"
10
+ }
11
+ },
12
+ "mcVersion": [
13
+ "1.21.10",
14
+ "1.21.120"
15
+ ]
16
16
  }
@@ -1,12 +1,12 @@
1
- {
2
- "name": "gutils",
3
- "description": "t",
4
- "version": "0.0.1",
5
- "type": "scriptsDes",
6
- "script": {
7
- "main": "./src/index.js",
8
- "dependencies": [
9
- "gutils"
10
- ]
11
- }
1
+ {
2
+ "name": "gutils",
3
+ "description": "t",
4
+ "version": "0.0.1",
5
+ "type": "scriptsDes",
6
+ "script": {
7
+ "main": "./src/index.js",
8
+ "dependencies": [
9
+ "gutils"
10
+ ]
11
+ }
12
12
  }
@@ -1,5 +1,5 @@
1
- [
2
- "gameLib",
3
- "gutils",
4
- "create-game"
1
+ [
2
+ "gameLib",
3
+ "gutils",
4
+ "create-game"
5
5
  ]
@@ -1,4 +1,4 @@
1
- {
2
- "MAX": 3,
3
- "CACHE_DESC": ".cache.json"
1
+ {
2
+ "MAX": 3,
3
+ "CACHE_DESC": ".cache.json"
4
4
  }
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var r=e(t),n=0;n<r.length;n++)"default"!==r[n]&&__createBinding(i,t,r[n]);return __setModuleDefault(i,t),i}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const index_js_1=__importDefault(require("./../uuid/index.js")),promises_1=__importDefault(require("fs/promises")),utils=__importStar(require("./../utils/index.js")),path_1=__importDefault(require("path")),index_js_2=__importDefault(require("./../git/index.js")),child_process_1=require("child_process"),index_js_3=__importDefault(require("./../runTemp/index.js")),securityFile_js_1=__importDefault(require("./../runTemp/securityFile.js")),regex=/(https?:\/\/[^\s\/]+\/[^\s\/]+\/[^\s]+(?:\.git)?|(?:git@|[\w.-]+@)[\w.-]+:[^\s]+(?:\.git)?)/,npmStart="npm:";let dirname="";async function Load(e,t){const i=JSON.parse(await promises_1.default.readFile(path_1.default.join(e,"package.json"),{encoding:"utf-8"})).main,r=JSON.parse(await promises_1.default.readFile(path_1.default.join(e,"mbler.config.json"),{encoding:"utf-8"})),n={name:r.name,description:r.description,version:r.version,setWorkDir:new securityFile_js_1.default(t)};let a=require(path_1.default.join(e,i));a=a.main(n),a instanceof Promise&&(a=await a)}function runNpm(e,t){return new Promise((i,r)=>{const n=(0,child_process_1.spawn)("npm",e,{cwd:t,stdio:"ignore"});n.on("close",i),n.on("error",e=>{r(e)})})}async function NpmInstall(e,t){const i=new index_js_3.default(path_1.default.join(require("os").tmpdir(),"mbler"));await i.init();const{dir:r}=i;await promises_1.default.writeFile(path_1.default.join(r,"package.json"),JSON.stringify({name:"",description:"",version:"0.0.1",type:"commjs"}));if(0!==await runNpm(["install",e],r))throw new Error("npm package install falled");const n=path_1.default.join(r,"node_modules");await copy(n,t),await i.remove()}function copy(e,t){return new Promise((i,r)=>promises_1.default.readdir(e).then(r=>Promise.all(r.map(i=>utils.copy(path_1.default.join(e,i),path_1.default.join(t,i)))).then(()=>i())).catch(r))}module.exports=async function(e,t,i=""){i=i.trim(),dirname=t;try{if(!e)throw new Error("Wrok Dir is undefined");if(await utils.isMblerProject(e))throw new Error("WorkDir is init You shouldn't use 'create' command");const t=index_js_1.default.fromString(`ul-to-${i}`),r=path_1.default.join(process.cwd(),"lib/initializer-cache",t);if(await utils.FileExsit(r))await Load(r,e);else{const t=utils.join(dirname,i);if(regex.test(i))await index_js_2.default.clone(i,r);else if(i.startsWith("npm:")){const e=i.slice(4);await NpmInstall(e,r)}else{if(!await utils.FileExsit(t))throw new Error("Package source not match");await copy(i,r)}await Load(r,e)}}catch(e){console.error(`加载模板初始化失败 错误信息\n${e.stack}`)}};
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var r=e(t),n=0;n<r.length;n++)"default"!==r[n]&&__createBinding(i,t,r[n]);return __setModuleDefault(i,t),i}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const index_js_1=__importDefault(require("./../uuid/index.js")),promises_1=__importDefault(require("fs/promises")),utils=__importStar(require("./../utils/index.js")),path_1=__importDefault(require("path")),index_js_2=__importDefault(require("./../git/index.js")),child_process_1=require("child_process"),index_js_3=__importDefault(require("./../runTemp/index.js")),securityFile_js_1=__importDefault(require("./../runTemp/securityFile.js")),os_1=require("os"),regex=/(https?:\/\/[^\s\/]+\/[^\s\/]+\/[^\s]+(?:\.git)?|(?:git@|[\w.-]+@)[\w.-]+:[^\s]+(?:\.git)?)/,npmStart="npm:";let dirname="";async function Load(e,t){const i=JSON.parse(await promises_1.default.readFile(path_1.default.join(e,"package.json"),{encoding:"utf-8"})).main,r=JSON.parse(await promises_1.default.readFile(path_1.default.join(e,"mbler.config.json"),{encoding:"utf-8"})),n={name:r.name,description:r.description,version:r.version,setWorkDir:new securityFile_js_1.default(t)};let a=require(path_1.default.join(e,i));a=a.main(n),a instanceof Promise&&(a=await a)}function runNpm(e,t){return new Promise((i,r)=>{const n=(0,child_process_1.spawn)("npm",e,{cwd:t,stdio:"ignore"});n.on("close",i),n.on("error",e=>{r(e)})})}async function NpmInstall(e,t){const i=new index_js_3.default(path_1.default.join(require("os").tmpdir(),"mbler"));await i.init();const{dir:r}=i;await promises_1.default.writeFile(path_1.default.join(r,"package.json"),JSON.stringify({name:"",description:"",version:"0.0.1",type:"commjs"}));if(0!==await runNpm(["install",e],r))throw new Error("npm package install falled");const n=path_1.default.join(r,"node_modules");await copy(n,t),await i.remove()}function copy(e,t){return new Promise((i,r)=>promises_1.default.readdir(e).then(r=>Promise.all(r.map(i=>utils.copy(path_1.default.join(e,i),path_1.default.join(t,i)))).then(()=>i())).catch(r))}module.exports=async function(e,t,i=""){i=i.trim(),dirname=t;try{if(!e)throw new Error("Wrok Dir is undefined");if(await utils.isMblerProject(e))throw new Error("WorkDir is init You shouldn't use 'create' command");const t=index_js_1.default.fromString(`ul-to-${i}`),r=path_1.default.join((0,os_1.tmpdir)(),"mbler/initializer-cache",t);if(await utils.FileExsit(r))await Load(r,e);else{const t=utils.join(dirname,i);if(regex.test(i))await index_js_2.default.clone(i,r);else if(i.startsWith("npm:")){const e=i.slice(4);await NpmInstall(e,r)}else{if(!await utils.FileExsit(t))throw new Error("Package source not match");await copy(i,r)}await Load(r,e)}}catch(e){console.error(`加载模板初始化失败 错误信息\n${e.stack}`)}};
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var r=Object.getOwnPropertyDescriptor(e,i);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,r)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(t){var e=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[e.length]=i);return e},t(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(null!=e)for(var s=t(e),r=0;r<s.length;r++)"default"!==s[r]&&__createBinding(i,e,s[r]);return __setModuleDefault(i,e),i}}(),__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const promises_1=__importDefault(require("node:fs/promises")),index_js_1=__importDefault(require("./../lang/index.js")),node_path_1=__importDefault(require("node:path")),utils=__importStar(require("./../utils/index.js")),db=".cache/mbler/.path.db";require("./../commander/index.js");const node_process_1=__importDefault(require("node:process")),node_os_1=__importDefault(require("node:os"));class start{command;two;param;dirname;DataPath;constructor(t){this.dirname=t,this.param="",this.DataPath=node_path_1.default.join(node_os_1.default.homedir(),db),this.command=node_process_1.default.argv[2]||"",this.two=(node_process_1.default.argv[3]||"").trim(),this.start()}v=()=>{const{version:t}=require("./../../package.json");console.log(`MBLER : ${t}`)};build=async()=>{const t=new(0,require("./../build").default)(this.param,this.dirname);await t.build()};help=()=>{const t=index_js_1.default.commands;if(t.list.includes(this.two)&&"string"==typeof t[this.two]){let e=t[this.two];return e.startsWith("$")&&(e=t[e.slice(1)]),console.log(`-- '${this.two}' command -- : \n`),void console.log(`Usage : ${e}`)}this.echoHelp()};checkout=async()=>{this.two&&(this.two=utils.join(node_process_1.default.cwd(),this.two||"./")),await utils.FileExsit(this.two)&&this.two&&this.param!==this.two?(await promises_1.default.writeFile(this.DataPath,this.two),console.log(index_js_1.default.s0,`PATH => ${this.two}`)):console.log(this.param)};init=()=>new(require("./init.js"))(this.param,this.dirname).start();async start(){await this.getWorkDir();const t=this.command.toLowerCase().trim(),e={build:this.build,dev:()=>require("./dev")(this.param,this.dirname),create:()=>require("./create")(this.param,this.dirname,this.two),"":()=>this.echoHelp(),recache:()=>require("./rechce")(this.dirname,this.param),lang:()=>{this.two&&index_js_1.default.__internal.set(this.two),console.log(index_js_1.default.__internal.class.currenyLang)},"-h":this.help,"-help":this.help,help:this.help,version:()=>{new(require("./version.js"))(this.param,this.dirname)},v:this.v,"-v":this.v,checkout:this.checkout,"-c":this.checkout,init:this.init,"-i":this.init,web_edit:()=>{new(require("./../web"))({PORT:1025,PATH:this.param})},install:async()=>require("./incg.js")(this.dirname,this.param),uninstall:()=>require("./unincg.js")(this.two,this.dirname),add:()=>require("./addPack.js")(this.two,this.dirname,this.param),remive:()=>require("./unaddPack.js")(this.two,this.dirname,this.param),clean:async()=>{const t=require("./clean.js");await new t(this.param,this.dirname).run()}}[t];try{if("function"==typeof e){const t=e();t instanceof Promise&&await t}else this.defaultCommand(t);node_process_1.default.exit(0)}catch(t){console.error(t)}}defaultCommand(t){console.log(`${index_js_1.default.uncommand}: ${this.command.toLowerCase().trim()}`);const e=index_js_1.default.commands.list.map(e=>this.getMatchChance(t,e)).reduce((t,e,i)=>{try{if(e>t.max)return{max:e,index:i};if(e===t.max)return t.indices.push(i),t}catch{}return t},{max:-1/0,index:-1,indices:[]}),i=index_js_1.default.commands.list[e.index];i&&console.log(`${index_js_1.default.noCommandTip} ${i}`)}async getWorkDir(){try{this.param=(await promises_1.default.readFile(this.DataPath,"utf-8")).toString()||"./test"}catch(t){}}echoHelp(){console.log(index_js_1.default.help)}getMatchChance(t,e){let i=0;for(let s=0;s<e.length;s++)t[s]==e[s]&&i++;return i/e.length}}module.exports=start;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,i,a){void 0===a&&(a=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,a,s)}:function(t,e,i,a){void 0===a&&(a=i),t[a]=e[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(t){var e=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[e.length]=i);return e},t(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(null!=e)for(var a=t(e),s=0;s<a.length;s++)"default"!==a[s]&&__createBinding(i,e,a[s]);return __setModuleDefault(i,e),i}}(),__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const promises_1=__importDefault(require("node:fs/promises")),index_js_1=__importDefault(require("./../lang/index.js")),node_path_1=__importDefault(require("node:path")),utils=__importStar(require("./../utils/index.js")),db=".cache/mbler/.path.db";require("./../commander/index.js");const node_process_1=__importDefault(require("node:process")),node_os_1=__importDefault(require("node:os"));class start{command;two;param;dirname;DataPath;constructor(t){this.dirname=t,this.param="",this.DataPath=node_path_1.default.join(node_os_1.default.homedir(),db),this.command=node_process_1.default.argv[2]||"",this.two=(node_process_1.default.argv[3]||"").trim(),this.start()}v=()=>{const{version:t}=require("./../../package.json");console.log(`MBLER : ${t}`)};build=async()=>{const t=new(0,require("./../build").default)(this.param,this.dirname);await t.build()};help=()=>{const t=index_js_1.default.commands;if(t.list.includes(this.two)&&"string"==typeof t[this.two]){let e=t[this.two];return e.startsWith("$")&&(e=t[e.slice(1)]),console.log(`-- '${this.two}' command -- : \n`),void console.log(`Usage : ${e}`)}this.echoHelp()};checkout=async()=>{if(this.two&&(this.two=utils.join(node_process_1.default.cwd(),this.two||"./")),await utils.FileExsit(this.two)&&this.two&&this.param!==this.two){try{await utils.FileExsit(node_path_1.default.dirname(this.DataPath))||await promises_1.default.mkdir(node_path_1.default.dirname(this.DataPath))}catch(t){}await promises_1.default.writeFile(this.DataPath,this.two),console.log(index_js_1.default.s0,`PATH => ${this.two}`)}else console.log(this.param)};init=()=>new(require("./init.js"))(this.param,this.dirname).start();async start(){await this.getWorkDir();const t=this.command.toLowerCase().trim(),e={build:this.build,dev:()=>require("./dev")(this.param,this.dirname),create:()=>require("./create")(this.param,this.dirname,this.two),"":()=>this.echoHelp(),recache:()=>require("./rechce")(this.dirname,this.param),lang:()=>{this.two&&index_js_1.default.__internal.set(this.two),console.log(index_js_1.default.__internal.class.currenyLang)},"-h":this.help,"-help":this.help,help:this.help,version:()=>{new(require("./version.js"))(this.param,this.dirname)},v:this.v,"-v":this.v,checkout:this.checkout,"-c":this.checkout,init:this.init,"-i":this.init,web_edit:()=>{new(require("./../web"))({PORT:1025,PATH:this.param})},install:async()=>require("./incg.js")(this.dirname,this.param),uninstall:()=>require("./unincg.js")(this.two,this.dirname),add:()=>require("./addPack.js")(this.two,this.dirname,this.param),remive:()=>require("./unaddPack.js")(this.two,this.dirname,this.param),clean:async()=>{const t=require("./clean.js");await new t(this.param,this.dirname).run()}}[t];try{if("function"==typeof e){const t=e();t instanceof Promise&&await t}else this.defaultCommand(t);node_process_1.default.exit(0)}catch(t){console.error(t)}}defaultCommand(t){console.log(`${index_js_1.default.uncommand}: ${this.command.toLowerCase().trim()}`);const e=index_js_1.default.commands.list.map(e=>this.getMatchChance(t,e)).reduce((t,e,i)=>{try{if(e>t.max)return{max:e,index:i};if(e===t.max)return t.indices.push(i),t}catch{}return t},{max:-1/0,index:-1,indices:[]}),i=index_js_1.default.commands.list[e.index];i&&console.log(`${index_js_1.default.noCommandTip} ${i}`)}async getWorkDir(){try{this.param=(await promises_1.default.readFile(this.DataPath,"utf-8")).toString()||"./test"}catch(t){}}echoHelp(){console.log(index_js_1.default.help)}getMatchChance(t,e){let i=0;for(let a=0;a<e.length;a++)t[a]==e[a]&&i++;return i/e.length}}module.exports=start;
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,a)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=e(t),a=0;a<i.length;a++)"default"!==i[a]&&__createBinding(r,t,i[a]);return __setModuleDefault(r,t),r}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const fs=__importStar(require("fs/promises")),index_js_1=__importDefault(require("./../lang/index.js")),path_1=__importDefault(require("path"));module.exports=async function(e,t){await Promise.all([fs.rm(path_1.default.join(e,"lib/data/path.db"),{recursive:!0,force:!0}).catch(()=>{}),fs.rm(path_1.default.join(e,"lib/initializer-cache/"),{recursive:!0,force:!0}).catch(()=>{}),fs.rm(path_1.default.join(e,"lib/data/cache"),{recursive:!0,force:!0}).catch(()=>{})]),console.log(index_js_1.default.s0)};
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=e(t),n=0;n<i.length;n++)"default"!==i[n]&&__createBinding(r,t,i[n]);return __setModuleDefault(r,t),r}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const fs=__importStar(require("fs/promises")),index_js_1=__importDefault(require("./../lang/index.js")),path_1=__importDefault(require("path")),os_1=require("os");module.exports=async function(e,t){await Promise.all([fs.rm(path_1.default.join((0,os_1.homedir)(),".cache/mbler"),{recursive:!0,force:!0}).catch(()=>{}),fs.rm(path_1.default.join(e,"lib/initializer-cache/"),{recursive:!0,force:!0}).catch(()=>{}),fs.rm(path_1.default.join((0,os_1.tmpdir)(),"mbler"),{recursive:!0,force:!0}).catch(()=>{})]),console.log(index_js_1.default.s0)};
package/package.json CHANGED
@@ -1 +1,49 @@
1
- {"name":"mbler","version":"0.1.1","description":"一个针对Minecraft JavaScript API 的lib库,让你的附加包版本管理更简单","repository":{"type":"git","url":"git+https://github.com/RuanhoR/mbler.git"},"keywords":["Minecraft","build"],"engines":{"node":">=16.0.0"},"license":"MIT","type":"commonjs","main":"./lib/start/index.js","scripts":{"cli":"node bin/mbler.js","build":"node bin/minify.js"},"dependencies":{"@babel/generator":"7.28.5","@babel/parser":"7.28.5","@babel/traverse":"7.28.5","@babel/types":"^7.28.6","adm-zip":"^0.5.16","chokidar":"^4.0.3","dayjs":"1.11.18","mime-types":"3.0.1","terser":"5.44.0","typescript":"^5.9.3"},"files":["lib","test","bin"],"publishConfig":{"registry":"https://registry.npmjs.org"},"bin":{"mbler":"bin/mbler.js"}}
1
+ {
2
+ "name": "mbler",
3
+ "version": "0.1.3-alpha-r2",
4
+ "description": "一个针对Minecraft JavaScript API 的lib库,让你的附加包版本管理更简单",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/RuanhoR/mbler.git"
8
+ },
9
+ "keywords": [
10
+ "Minecraft",
11
+ "build",
12
+ "cli"
13
+ ],
14
+ "engines": {
15
+ "node": ">=16.0.0"
16
+ },
17
+ "license": "MIT",
18
+ "type": "commonjs",
19
+ "main": "./lib/start/index.js",
20
+ "scripts": {
21
+ "cli": "node bin/mbler.js",
22
+ "build": "node bin/minify.js"
23
+ },
24
+ "dependencies": {
25
+ "@babel/generator": "7.28.5",
26
+ "@babel/parser": "7.28.5",
27
+ "@babel/traverse": "7.28.5",
28
+ "@babel/types": "7.28.6",
29
+ "adm-zip": "0.5.16",
30
+ "chokidar": "4.0.3",
31
+ "dayjs": "1.11.18",
32
+ "terser": "5.44.0",
33
+ "typescript": "^5.9.3",
34
+ "@mbler/mcx-core": "0.0.2-alpha"
35
+ },
36
+ "files": [
37
+ "lib",
38
+ "test",
39
+ "bin",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "publishConfig": {
44
+ "registry": "https://registry.npmjs.org"
45
+ },
46
+ "bin": {
47
+ "mbler": "bin/mbler.js"
48
+ }
49
+ }
@@ -1,25 +1,25 @@
1
- const config = {
2
- itemId: "§r§6§lmbler_test_2xsword:as§r§l §8 二倍剑",
3
- ForRanger: 2
4
- }
5
- import {
6
- EntityComponentTypes,
7
- EquipmentSlot,
8
- world,
9
- system
10
- } from "@minecraft/server"
11
- world.afterEvents.entityDie.subscribe(({
12
- deadEntity: entity,
13
- damageSource: source
14
- }) => {
15
- system.run(()=>{ try { // 排除非正常人
16
- if (!source.typeId.includes("player") || !getMainHand(source).nameTag.includes(config.itemId)) return;
17
- } catch {}
18
- for (let i = 0; i < config.ForRanger; i++) {
19
- try {
20
- entity.dimension.spawnEntity(entity.typeId)
21
- } catch (err){
22
- console.error(err)
23
- }
24
- }})
1
+ const config = {
2
+ itemId: "§r§6§lmbler_test_2xsword:as§r§l §8 二倍剑",
3
+ ForRanger: 2
4
+ }
5
+ import {
6
+ EntityComponentTypes,
7
+ EquipmentSlot,
8
+ world,
9
+ system
10
+ } from "@minecraft/server"
11
+ world.afterEvents.entityDie.subscribe(({
12
+ deadEntity: entity,
13
+ damageSource: source
14
+ }) => {
15
+ system.run(()=>{ try { // 排除非正常人
16
+ if (!source.typeId.includes("player") || !getMainHand(source).nameTag.includes(config.itemId)) return;
17
+ } catch {}
18
+ for (let i = 0; i < config.ForRanger; i++) {
19
+ try {
20
+ entity.dimension.spawnEntity(entity.typeId)
21
+ } catch (err){
22
+ console.error(err)
23
+ }
24
+ }})
25
25
  })
@@ -1,12 +1,12 @@
1
- {
2
- "name": "双倍剑",
3
- "description": "打生物会再生成一个的奇葩剑",
4
- "mcVersion": "1.21.80",
5
- "version": "0.0.2",
6
- "script": {
7
- "main": "index",
8
- "ui": true
9
- },
10
- "minify": false,
11
- "outdir": "/storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/development_behavior_packs/test/"
1
+ {
2
+ "name": "双倍剑",
3
+ "description": "打生物会再生成一个的奇葩剑",
4
+ "mcVersion": "1.21.80",
5
+ "version": "0.0.2",
6
+ "script": {
7
+ "main": "index",
8
+ "ui": true
9
+ },
10
+ "minify": false,
11
+ "outdir": "/storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/development_behavior_packs/test/"
12
12
  }
@@ -1,14 +1,14 @@
1
- {
2
- "name": "双倍剑",
3
- "description": "打生物会再生成一个的奇葩剑",
4
- "version": "0.0.2",
5
- "engines": {
6
- "node": ">=20.0.0"
7
- },
8
- "scripts": {
9
- "dev": "mbler dev",
10
- "build": "MBLER_BUILD_MODULE=dist mbler build",
11
- "dev-build": "MBLER_BUILD_MODULE=dev mbler build"
12
- },
13
- "dependencies": {}
1
+ {
2
+ "name": "双倍剑",
3
+ "description": "打生物会再生成一个的奇葩剑",
4
+ "version": "0.0.2",
5
+ "engines": {
6
+ "node": ">=20.0.0"
7
+ },
8
+ "scripts": {
9
+ "dev": "mbler dev",
10
+ "build": "MBLER_BUILD_MODULE=dist mbler build",
11
+ "dev-build": "MBLER_BUILD_MODULE=dev mbler build"
12
+ },
13
+ "dependencies": {}
14
14
  }
package/test/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # 欢迎来到测试脚本列表 !
2
-
3
- 这里有两个文件夹,分别是包测试,你可以使用
4
-
5
- > mbler <
6
-
7
- 构建成Minecraft行为包 !
1
+ # 欢迎来到测试脚本列表 !
2
+
3
+ 这里有两个文件夹,分别是包测试,你可以使用
4
+
5
+ > mbler <
6
+
7
+ 构建成Minecraft行为包 !
8
8
  这些包可供你学习mbler的用法
package/test/des/index.js CHANGED
@@ -1,20 +1,20 @@
1
- exports.main = async function main(content) {
2
- const name = await MblerApi.input("名称")
3
- const desc = await MblerApi.input(`描述 `)
4
- const main = await MblerApi.input(`主脚本 `)
5
- content.setWorkDir
6
- .writeFile("./mbler.config.json", JSON.stringify({
7
- name,
8
- description: desc,
9
- script: {
10
- main: "src/index.js",
11
- dependencies: {}
12
- },
13
- type: "scriptsDes",
14
- version: "0.0.1",
15
- mcVersion: [
16
- "1.21.00",
17
- "1.21.100"
18
- ]
19
- }, null, 2))
1
+ exports.main = async function main(content) {
2
+ const name = await MblerApi.input("名称")
3
+ const desc = await MblerApi.input(`描述 `)
4
+ const main = await MblerApi.input(`主脚本 `)
5
+ content.setWorkDir
6
+ .writeFile("./mbler.config.json", JSON.stringify({
7
+ name,
8
+ description: desc,
9
+ script: {
10
+ main: "src/index.js",
11
+ dependencies: {}
12
+ },
13
+ type: "scriptsDes",
14
+ version: "0.0.1",
15
+ mcVersion: [
16
+ "1.21.00",
17
+ "1.21.100"
18
+ ]
19
+ }, null, 2))
20
20
  }
@@ -1,5 +1,5 @@
1
- {
2
- "name": "",
3
- "description": "",
4
- "version": ""
1
+ {
2
+ "name": "",
3
+ "description": "",
4
+ "version": ""
5
5
  }
@@ -1,7 +1,7 @@
1
- {
2
- "name": "",
3
- "description": "",
4
- "version": "0.0.1",
5
- "module": "commjs",
6
- "main": "./index.js"
1
+ {
2
+ "name": "",
3
+ "description": "",
4
+ "version": "0.0.1",
5
+ "module": "commjs",
6
+ "main": "./index.js"
7
7
  }
@@ -1,6 +1,6 @@
1
- require("./test.js")
2
- exports.main = function({
3
- work
4
- }) {
5
- console.log(work)
1
+ require("./test.js")
2
+ exports.main = function({
3
+ work
4
+ }) {
5
+ console.log(work)
6
6
  }
@@ -1,5 +1,5 @@
1
- {
2
- "name": "",
3
- "description": "",
4
- "version": ""
1
+ {
2
+ "name": "",
3
+ "description": "",
4
+ "version": ""
5
5
  }
@@ -1,7 +1,7 @@
1
- {
2
- "name": "",
3
- "description": "",
4
- "version": "0.0.1",
5
- "module": "commjs",
6
- "main": "./index.js"
1
+ {
2
+ "name": "",
3
+ "description": "",
4
+ "version": "0.0.1",
5
+ "module": "commjs",
6
+ "main": "./index.js"
7
7
  }