dsh-crate 0.5.4 → 0.5.5

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 (2) hide show
  1. package/lib/registry.js +15 -2
  2. package/package.json +1 -1
package/lib/registry.js CHANGED
@@ -7,6 +7,7 @@ import { BODY_STALL_TIMEOUT_MS, HEADERS_TIMEOUT_MS, readBodyWhileProgressing } f
7
7
  import { logEvent } from './log.js';
8
8
  import { configuredProxy, marketFetch } from './net.js';
9
9
  import { catalogFromPackage } from './catalog-npm.js';
10
+ import { asCrateRegistry, isCrateCatalog } from './crate-catalog.js';
10
11
  import { activeRegion, catalogSourcesFor, routesFor } from './regions.js';
11
12
  import { NPM_NAME_RE } from './sources.js';
12
13
  /**
@@ -110,6 +111,18 @@ let served = null;
110
111
  function sourceKey(source) {
111
112
  return source.kind === 'npm' ? `npm:${source.registry}/${source.pkg}` : `url:${source.url}`;
112
113
  }
114
+ /**
115
+ * 目录载荷分派:按结构选适配器,而不是按地区或地址。
116
+ *
117
+ * crate 的载荷带 `entries`,上游目录带 `plugins`;两套结构各自校验,
118
+ * 夹具与真实数据都不会误入对方的分支。
119
+ *
120
+ * @param value - 已经 `JSON.parse` 过的目录载荷。
121
+ * @throws 两个适配器都可能因为数据不可用而抛出,异常留给调用方重试。
122
+ */
123
+ function parseCatalog(value) {
124
+ return isCrateCatalog(value) ? asCrateRegistry(value) : asRegistry(value);
125
+ }
113
126
  /** A parsed catalog, or a thrown explanation of why it is not one. */
114
127
  function asRegistry(value) {
115
128
  const data = value;
@@ -221,7 +234,7 @@ export async function loadRegistry(region = activeRegion()) {
221
234
  return servedBy(reusable.data);
222
235
  if (data === null)
223
236
  throw new Error('the catalog package reported no change with nothing to reuse');
224
- const parsed = asRegistry(data);
237
+ const parsed = parseCatalog(data);
225
238
  served = { key, etag: null, modified: null, version, data: parsed };
226
239
  return servedBy(parsed);
227
240
  }
@@ -260,7 +273,7 @@ export async function loadRegistry(region = activeRegion()) {
260
273
  }
261
274
  if (!res.ok)
262
275
  throw new Error(`HTTP ${String(res.status)}`);
263
- const data = asRegistry(JSON.parse(new TextDecoder().decode(await readBodyWhileProgressing(res, BODY_STALL_TIMEOUT_MS))));
276
+ const data = parseCatalog(JSON.parse(new TextDecoder().decode(await readBodyWhileProgressing(res, BODY_STALL_TIMEOUT_MS))));
264
277
  served = {
265
278
  key, etag: res.headers.get('etag'), modified: res.headers.get('last-modified'), version: null, data,
266
279
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-crate",
3
3
  "description": "逛一逛,点一下,装好。浏览和搜索 DeepSeek Harness 社区插件,看详情、一键安装,收藏和更新都在一处。",
4
- "version": "0.5.4",
4
+ "version": "0.5.5",
5
5
  "icon": "assets/logo.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",