create-yeow 0.4.2 → 0.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-yeow",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Scaffold a Yeow plugin project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -114,7 +114,7 @@ async function main() {
114
114
  console.log(' \u2713 Bundled (' + (statSync(resolve(outDir, 'main.js')).size / 1024).toFixed(1) + ' KB)');
115
115
 
116
116
  // ── 组装 JAR ──
117
- const zip = new AdmZip(resolve(root, '.yeow', 'assets', 'yeow-template-0.1.0.jar'));
117
+ const zip = new AdmZip(resolve(root, '.yeow', 'assets', 'yeow-template-0.5.0.jar'));
118
118
  zip.updateFile('plugin.yml', Buffer.from(
119
119
  'name: ' + name + '\n' +
120
120
  'version: ' + version + '\n' +
@@ -17,7 +17,6 @@ const WS_PORT = 17368;
17
17
 
18
18
  const YES = process.argv.includes('-y') || process.env.CI === 'true';
19
19
  const EULA = process.argv.includes('--eula') || YES;
20
- const PROXY = process.argv.find(a => a.startsWith('--proxy='))?.split('=').slice(1).join('=');
21
20
  const STOP = (() => { const a = process.argv.find(a => a.startsWith('--stop=')); if (!a) return null; const m = a.split('=')[1].match(/^(\d+)(s|m|h)?$/); return m ? parseInt(m[1]) * (m[2] === 'm' ? 60 : m[2] === 'h' ? 3600 : 1) : null; })();
22
21
 
23
22
  // ── AI 工作流参数(headless 模式)─────────────────────────────
@@ -35,7 +34,7 @@ const HEADLESS = process.argv.includes('--eula') || process.argv.includes('--tim
35
34
  || process.argv.includes('--wait') || process.argv.includes('--outfile') || KEEP;
36
35
 
37
36
  const cfg = JSON.parse(readFileSync(resolve(ROOT, 'yeow.config.json'), 'utf-8'));
38
- const RUNTIME = resolve(ROOT, '.yeow', 'assets', 'yeow-runtime-0.2.0.jar');
37
+ const RUNTIME = resolve(ROOT, '.yeow', 'assets', 'yeow-runtime-0.5.0.jar');
39
38
 
40
39
  // Dev server config (optional, from yeow.config.json)
41
40
  const devCfg = cfg.dev || {};
@@ -139,12 +138,11 @@ function broadcast(msg) {
139
138
  }
140
139
 
141
140
  // ── Download ────────────────────────────────────────────────────
142
- function download(url, dest, agent) {
141
+ function download(url, dest) {
143
142
  return new Promise((resolve, reject) => {
144
143
  const f = createWriteStream(dest);
145
- const o = agent ? { agent } : {};
146
- https.get(url, o, res => {
147
- if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { f.close(); download(res.headers.location, dest, agent).then(resolve).catch(reject); return; }
144
+ https.get(url, res => {
145
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { f.close(); download(res.headers.location, dest).then(resolve).catch(reject); return; }
148
146
  if (res.statusCode !== 200) { f.close(); reject(new Error(`HTTP ${res.statusCode}`)); return; }
149
147
  const total = parseInt(res.headers['content-length'], 10);
150
148
  let dl = 0;
@@ -161,10 +159,8 @@ async function ensurePaper() {
161
159
  if (PAPER_URL.startsWith('http://') || PAPER_URL.startsWith('https://')) {
162
160
  if (existsSync(PAPER_PATH) && statSync(PAPER_PATH).size > 1_000_000) { if (!HEADLESS) ok('Paper found in cache'); return; }
163
161
  mkdirSync(CACHE, { recursive: true });
164
- let agent = null;
165
- if (PROXY) { info(`Proxy: ${PROXY}`); try { const { HttpsProxyAgent } = await import('https-proxy-agent'); agent = new HttpsProxyAgent(PROXY); } catch {} }
166
162
  if (!HEADLESS) info('Downloading Paper...');
167
- try { await download(PAPER_URL, PAPER_PATH, agent); if (!HEADLESS) ok('Paper downloaded'); }
163
+ try { await download(PAPER_URL, PAPER_PATH); if (!HEADLESS) ok('Paper downloaded'); }
168
164
  catch (e) { fail('Download failed: ' + e.message); console.log(' Manually: ' + PAPER_PATH); process.exit(1); }
169
165
  } else {
170
166
  if (!existsSync(PAPER_PATH)) { fail(`Paper JAR not found: ${PAPER_PATH}`); process.exit(1); }
@@ -179,7 +175,7 @@ async function ensurePaper() {
179
175
  const versions = await fetch(apiUrl).then(r => r.json());
180
176
  const latestBuild = versions.builds[versions.builds.length - 1];
181
177
  const dlUrl = `https://api.papermc.io/v2/projects/paper/versions/${PAPER_VERSION}/builds/${latestBuild}/downloads/paper-${PAPER_VERSION}-${latestBuild}.jar`;
182
- await download(dlUrl, PAPER_PATH, null);
178
+ await download(dlUrl, PAPER_PATH);
183
179
  if (!HEADLESS) ok('Paper downloaded');
184
180
  } catch (e) {
185
181
  fail('Download failed: ' + e.message);
@@ -8,12 +8,11 @@
8
8
  "permissions": "node .yeow/permissions.js"
9
9
  },
10
10
  "dependencies": {
11
- "yeow-api": "^0.4.0"
11
+ "yeow-api": "^0.5.0"
12
12
  },
13
13
  "devDependencies": {
14
14
  "esbuild": "^0.25.0",
15
15
  "adm-zip": "^0.6.0",
16
- "https-proxy-agent": "^9.0.0",
17
16
  "source-map": "^0.7.4",
18
17
  "ws": "^8.0.0",
19
18
  "typescript": "^7.0.0"
@@ -10,7 +10,8 @@
10
10
  | 概览 | `https://yexin.wiki/yeow/v1/overview` | 项目总览:用 TypeScript 写 Paper 插件(QuickJS 引擎,每插件独立线程)。按角色(初学者/开发者/服主/平台实现者)的文档入口导引 + 关键概念速览 |
11
11
  | AI 辅助启动指南 | `https://yexin.wiki/yeow/v1/ai-agent` | 面向 AI 代理 / Vibe Coding:Yeow 项目简介、启动命令(`--ts`)、下一步、文档查阅策略(站点地图/docs.zip/Harness 用法) |
12
12
  | 快速开始 | `https://yexin.wiki/yeow/v1/getting-started` | 从零开始:`npm create yeow` 建项目 → `npm run dev` 开发(热重载)→ `npm run build` 构建 → 部署方式。含插件示例(/back 传送)、异步/同步约定 |
13
- | CLI 参考 | `https://yexin.wiki/yeow/v1/cli` | create-yeow 脚手架与 dev-server 的命令行用法:交互式/非交互创建、开发服务器参数(-y/--stop/--proxy)、构建脚本、调试体验(source-map 错误定位与异步调用链) |
13
+ | 环境能力 | `https://yexin.wiki/yeow/v1/environment` | 运行时环境速览:全局能力($send/fetch/TextEncoder/TextDecoder/定时器)、线程与异步模型、与浏览器/Node 环境的差异、性能建议 |
14
+ | CLI 参考 | `https://yexin.wiki/yeow/v1/cli` | create-yeow 脚手架与 dev-server 的命令行用法:交互式/非交互创建、开发服务器参数(-y/--stop)、构建脚本、调试体验(source-map 错误定位与异步调用链) |
14
15
  | 构建与分发 | `https://yexin.wiki/yeow/v1/distribution` | 两种产物:标准 Paper JAR(plugins/)与平台无关 .yeow.zip(plugins/Yeow/ 自动扫描或 /yeow install);分发建议与 Modrinth 发布 |
15
16
  | 权限与原生服务可信性 | `https://yexin.wiki/yeow/v1/permissions` | 敏感权限声明(默认拒绝表/通配规则/computedPermissions)、原生服务 SHA-256 可信性声明与一次性批准码机制 |
16
17
  | 运行时运维 | `https://yexin.wiki/yeow/v1/operations` | 服主视角:/yeow 管理命令全集、运行时配置(config.yml 含 Folia 节)、部署形态速查 |
@@ -20,7 +21,7 @@
20
21
  | 进阶 · 调度器与任务 | `https://yexin.wiki/yeow/v1/advanced/scheduler` | 三级优先级调度器(时间片预算/自动降级/空闲自旋)、任务配置(TaskOptions)、异步 vs 同步、手动分片、调度器设计(队列/降级算法/空队自旋) |
21
22
  | 进阶 · 事件与回调 | `https://yexin.wiki/yeow/v1/advanced/events` | 事件桥(EventBridge):并发/串行、事件数据、处理器操作与模式选择、事件重入死锁 |
22
23
  | 进阶 · 生命周期与热重载 | `https://yexin.wiki/yeow/v1/advanced/lifecycle` | onInit/onLoad/onUnload、统一回调系统、热重载(强杀机制:原生中断 + 实体重建)、生产 /yeow reload/unload |
23
- | 进阶 · 环境能力与通道 | `https://yexin.wiki/yeow/v1/advanced/channels` | $_send/$send 封装、各消息通道说明(运行时配置指向 /operations) |
24
+ | 进阶 · 环境能力与通道 | `https://yexin.wiki/yeow/v1/advanced/channels` | $send 封装(底层桥 $_send 为内部实现,闭包持有不外露)、各消息通道说明(运行时配置指向 /operations) |
24
25
  | 进阶 · 服务机制 | `https://yexin.wiki/yeow/v1/advanced/service` | Plugin Service(插件间通信)与 Native Service(原生扩展)的机制(API 用法见 /api/service) |
25
26
  | 关于 Yeow | `https://yexin.wiki/yeow/v1/advanced/about` | 关于 Yeow |
26
27
  | 编写依赖包 | `https://yexin.wiki/yeow/v1/package-author` | 将共享逻辑与资源封装为 npm 依赖包:assets 命名空间、依赖项识别、构建自动处理(多副本共存/权限合并/native 清单) |
@@ -55,7 +56,7 @@
55
56
  | Command | `https://yexin.wiki/yeow/v1/api/command` | 命令注册 + Tab 补全(含 yeow-command 重载式命令 Command.create 与模式化参数) |
56
57
  | ItemStack | `https://yexin.wiki/yeow/v1/api/item` | 物品纯数据描述符:type/amount/meta(显示名/附魔/耐久/染色/药水/头颅/属性修饰符);构造工具(create/clone/equals);值语义(快照,不绑定真实物品) |
57
58
  | Service | `https://yexin.wiki/yeow/v1/api/service` | 插件间服务(registerService/request/subscribe/publish)与原生服务(registerNativeService,spawn 子进程 + TCP 通信) |
58
- | HTTP | `https://yexin.wiki/yeow/v1/api/http` | 底层 HTTP 客户端:request(异步)/requestSync(同步阻塞)/fetch |
59
+ | HTTP | `https://yexin.wiki/yeow/v1/api/http` | 底层 HTTP 客户端:`request`(异步,请求/响应体二进制与 fs 同语义、encoding/timeout 可选)、全局 `fetch`(text/json 按需解码 + base64/bytes) |
59
60
  | HTTP Server | `https://yexin.wiki/yeow/v1/api/http-server` | 高层 `createServer`(yeow-server):洋葱中间件、路由、mount/mountAssets 静态挂载、二进制响应(Uint8Array/encoding)、返回对象自动 JSON、资源包下载闭环 |
60
61
  | Worker | `https://yexin.wiki/yeow/v1/api/worker` | 虚拟插件(独立线程):createWorker(仅注册)/load/unload/reload、双向 postMessage、Worker 侧 onMessage/postMessage;共享数据目录/权限、禁嵌套、/yeow 不覆盖 |
61
62
  | FS | `https://yexin.wiki/yeow/v1/api/fs` | 文件系统:plugin/server/outer 三级(路径安全)、读写/追加/二进制、目录操作、systemPaths、path 工具 |
@@ -70,7 +71,7 @@
70
71
  | 页面 | URL | 摘要 |
71
72
  | -------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
72
73
  | 规范总览 | `https://yexin.wiki/yeow/v1/specifications/` | 协议层总纲:包结构(yeow.json/.yeow/main.js/assets)、加载流程、权限模型、运行时架构、任务执行器、事件/命令桥、Native Service、合格运行时检查清单 |
73
- | 值域附录 | `https://yexin.wiki/yeow/v1/specifications/values` | 取值格式规则(R1-R5)与清单:平台枚举直接维护(游戏模式/难度/BossBar/计分板/ClickType/ItemFlag/DamageCause/InventoryType 等);版本变迁域规则+链接(方块/物品/实体/生物群系/音效/粒子/附魔/药水/属性/伤害类型/游戏规则/翻译键/进度/配方) |
74
+ | 值域附录 | `https://yexin.wiki/yeow/v1/specifications/values` | 取值格式规则(R1-R5)与清单:平台枚举直接维护(游戏模式/难度/BossBar/计分板/ClickType/ItemFlag/InventoryType 等);参考实现(非强制:DamageCause/传送原因/回血原因);版本变迁域规则+链接(方块/物品/实体/生物群系/音效/粒子/附魔/药水/属性/伤害类型/游戏规则/翻译键/进度/配方) |
74
75
  | Java 插件集成 | `https://yexin.wiki/yeow/v1/specifications/java-api` | 其他 Java 插件调用 Yeow 服务(requestService 请求-响应、subscribeService 订阅事件)、提交游戏任务、约束 |
75
76
  | 适配器规范 | `https://yexin.wiki/yeow/v1/specifications/adapter/` | 多语言/社区适配器:PluginEntity 接口、消息契约、submitTask、注册 API、检查清单 |
76
77
  | 运行时环境标准 | `https://yexin.wiki/yeow/v1/specifications/runtime/` | JS 环境:语言标准(ES2025+SecU8)、回调系统(cb 语义)、事件循环、通道总览与权限、全局变量($send/$dev/fetch/timers) |
@@ -90,6 +91,7 @@
90
91
  | Log | `https://yexin.wiki/yeow/v1/specifications/message/log` | log 通道:日志消息格式 |
91
92
  | Lifecycle | `https://yexin.wiki/yeow/v1/specifications/message/lifecycle` | lifecycle 通道:unloadDone 确认、gc-collect 资源回收 |
92
93
  | Debug | `https://yexin.wiki/yeow/v1/specifications/message/debug` | debug 通道:reportError 错误上报、ping-pong 心跳 |
94
+ | Util | `https://yexin.wiki/yeow/v1/specifications/message/util` | util 通道:gzip 压缩/解压(一次性与流式分块)、UTF-8 ↔ 字节转换(encode.utf8/decode.utf8) |
93
95
  | Worker | `https://yexin.wiki/yeow/v1/specifications/message/worker` | worker 通道:create(仅注册)/load/unload/post/reload/postToMain 消息格式、生命周期、origin 错误字段、约束(禁嵌套/共享数据与权限) |
94
96
 
95
97
  ### 任务类型(/v1/specifications/task/)