made-market 0.4.1 → 0.4.3
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/bin/made-market.mjs +8 -3
- package/lib/plugin.mjs +19 -5
- package/package.json +2 -2
- package/src/install.mjs +4 -1
package/bin/made-market.mjs
CHANGED
|
@@ -315,13 +315,18 @@ async function main() {
|
|
|
315
315
|
// (自建源/精确复现用)。
|
|
316
316
|
if (!options.registry && !process.env.MADE_MARKET_REGISTRY) {
|
|
317
317
|
const server = options.server || process.env.MADE_MARKET_SERVER || DEFAULT_SERVER;
|
|
318
|
+
// 只把「解析包信息」的失败当成线上市场不可用;install 的业务错误
|
|
319
|
+
// (已存在、校验不匹配等)必须原样抛出,不能混进离线回落误导用户。
|
|
320
|
+
let resolved = null;
|
|
318
321
|
try {
|
|
319
|
-
|
|
320
|
-
await install(options.args, { home: options.home, registry: base, index: { packages }, force: options.force, dryRun: options.dryRun });
|
|
321
|
-
return;
|
|
322
|
+
resolved = await resolveViaApi(options.args, server);
|
|
322
323
|
} catch (error) {
|
|
323
324
|
console.error(`线上市场不可用(${error.message}),改用包内自带索引(仅示例包,离线兜底)。`);
|
|
324
325
|
}
|
|
326
|
+
if (resolved) {
|
|
327
|
+
await install(options.args, { home: options.home, registry: resolved.base, index: { packages: resolved.packages }, force: options.force, dryRun: options.dryRun });
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
325
330
|
}
|
|
326
331
|
// 归档从索引所在的位置取:远端索引配远端归档,自带索引配包内归档,可离线。
|
|
327
332
|
const { source, index } = await loadIndex();
|
package/lib/plugin.mjs
CHANGED
|
@@ -19,16 +19,30 @@ const MAX_VALUE = 500;
|
|
|
19
19
|
const MAX_PATTERN = 200;
|
|
20
20
|
const MAX_FILE = 16 * 1024;
|
|
21
21
|
|
|
22
|
-
/** Commands the device currently executes (made 仓库
|
|
22
|
+
/** Commands the device currently executes (made 仓库 docs/standards/03-plugin-capabilities.md). */
|
|
23
23
|
export const BOARD_COMMANDS = Object.freeze([
|
|
24
24
|
'caption.show', 'audio.play', 'theme.apply', 'volume.set', 'agent.select',
|
|
25
25
|
'session.create', 'session.select', 'session.delete', 'voice.start',
|
|
26
26
|
'task.confirm', 'task.cancel',
|
|
27
|
-
'ui.swipe', 'ui.tap', 'debug.screenshot',
|
|
27
|
+
'ui.swipe', 'ui.tap', 'ui.back', 'debug.screenshot',
|
|
28
28
|
]);
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Events the device currently publishes. motion.shake 仅在带 IMU 的板子上上报;
|
|
32
|
+
* touch.double 是无 IMU 板子的等价触发源(2026-10-18 新增)。
|
|
33
|
+
*/
|
|
34
|
+
export const BOARD_EVENTS = Object.freeze([
|
|
35
|
+
'boot.click', 'boot.double', 'boot.triple', 'boot.long',
|
|
36
|
+
'motion.shake', 'touch.double',
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 行动系统:动作作为 action.<名> 并入命令清单,名单由素材 manifest 决定、
|
|
41
|
+
* 设备动态上报——静态清单穷举不了,按前缀放行(设备端对未知动作静默降级)。
|
|
42
|
+
*/
|
|
43
|
+
export function isKnownCommand(name, known) {
|
|
44
|
+
return name.startsWith('action.') || known.includes(name);
|
|
45
|
+
}
|
|
32
46
|
|
|
33
47
|
/** Event and command names share one shape, mirroring the bridge validator. */
|
|
34
48
|
const NAME = /^[a-z][a-z0-9_]{0,15}(?:\.[a-z][a-z0-9_]{0,15}){0,2}$/;
|
|
@@ -162,7 +176,7 @@ export function checkNames(list, label, known, fail, warn) {
|
|
|
162
176
|
}
|
|
163
177
|
if (new Set(list).size !== list.length) fail(`${label} 有重复项`);
|
|
164
178
|
for (const name of list) {
|
|
165
|
-
if (known && !
|
|
179
|
+
if (known && !isKnownCommand(name, known)) fail(`${label} 中的 ${name} 不在板侧公开清单里,设备不会执行`);
|
|
166
180
|
}
|
|
167
181
|
if (!list.length) warn(`${label} 为空`);
|
|
168
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "made-market",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "码得(made)公开插件市场的命令行工具:列出、搜索、安装主题/管控/agent 包,以及登录后发布新包。市场服务端在 github.com/jobop/made-market 仓库内,不随本包分发。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
"prepublishOnly": "cd .. && node tools/validate.mjs && node tools/build.mjs && node --test",
|
|
46
46
|
"prepack": "mkdir -p registry && cp ../registry/index.json registry/index.json"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|
package/src/install.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import fs from 'node:fs';
|
|
|
15
15
|
import os from 'node:os';
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import zlib from 'node:zlib';
|
|
18
|
+
import { pathToFileURL } from 'node:url';
|
|
18
19
|
import { KINDS, PKG_ROOT, ROOT, sha256 } from '../lib/market.mjs';
|
|
19
20
|
import { extractTar } from '../lib/tar.mjs';
|
|
20
21
|
|
|
@@ -189,4 +190,6 @@ function main() {
|
|
|
189
190
|
});
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
// 入口判断必须走 pathToFileURL:argv[1] 未编码,路径含空格(如 "My project")
|
|
194
|
+
// 时与 import.meta.url 永不相等,CLI 会静默退出(exit 0 无任何输出)。
|
|
195
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) main();
|