@linxin666/dsh-client-ui-preset-center 0.4.2 → 0.4.4

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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 9d35abeef15a5a52deab6012a37813a3270ecf83
6
- README.zh.md: 5327d2057f67cc7847c604b9fb983ce7dee6f4aa
5
+ README.md: aea6def583a6f63e94b4329633c93fff3f6b9195
6
+ README.zh.md: 646dc41cc1b723b0159046e68270a70b1090c564
package/README.md CHANGED
@@ -15,6 +15,16 @@ This repository owns both the plugin and the community preset catalog in [`prese
15
15
  - Refuses a preset whose id another declaration already supplies (the registry rejects a duplicate, so declaring would look like a successful install and do nothing), and refuses to disable or uninstall the preset the registry's default names (a default naming a missing preset fails every new session).
16
16
  - Verifies market provenance on every state read: per-file sha256 pinned to `https://dsh-market.com`, so a locally edited preset is reported as modified and an update never silently overwrites it.
17
17
 
18
+ ## Most popular presets
19
+
20
+ The three most-liked presets in the Workshop's preset catalog on [dsh-market.com](https://dsh-market.com), in the site's default popularity order — all of them published from [`presets/`](presets/) in this repository:
21
+
22
+ | Preset | Author | Scenario |
23
+ |---|---|---|
24
+ | [Roleplay · Qiao Youyou](https://dsh-market.com/#preset:roleplay-qiaoyouyou) (`roleplay-qiaoyouyou`) | dongshuyan | Immersive all-ages roleplay with Qiao Youyou, a kindergarten teacher |
25
+ | [Roleplay · Xie Wanzhou](https://dsh-market.com/#preset:roleplay-xiewanzhou) (`roleplay-xiewanzhou`) | dongshuyan | Immersive all-ages roleplay with Xie Wanzhou, a backend engineer at an internet company |
26
+ | [Roleplay · Su Mianmian](https://dsh-market.com/#preset:roleplay-sumianmian) (`roleplay-sumianmian`) | dongshuyan | Immersive all-ages roleplay with Su Mianmian, a coddled first-year business student |
27
+
18
28
  ## Install
19
29
 
20
30
  ```sh
package/README.zh.md CHANGED
@@ -15,6 +15,16 @@ DSH Web GUI 的社区 agent 预设管理器:创意工坊的**预设**面板,
15
15
  - 拒绝 id 已被其它声明占用的预设(注册表会拒绝重复 id,声明看起来成功却毫无效果),也拒绝停用或卸载注册表当前默认值指向的预设(默认值指向不存在的预设会让每个新会话创建失败)。
16
16
  - 每次读取状态都校验市场 provenance:逐文件 sha256 锚定 `https://dsh-market.com`,因此本地改动过的预设会被标为「本地已修改」,更新也绝不静默覆盖它。
17
17
 
18
+ ## 人气预设
19
+
20
+ [dsh-market.com](https://dsh-market.com) 创意工坊预设目录里人气最高的三个预设,按网站默认的「按人气」排序——三者都由本仓的 [`presets/`](presets/) 发布:
21
+
22
+ | 预设 | 作者 | 剧情 |
23
+ |---|---|---|
24
+ | [角色扮演 · 乔柚柚](https://dsh-market.com/#preset:roleplay-qiaoyouyou)(`roleplay-qiaoyouyou`) | dongshuyan | 与民办幼儿园老师乔柚柚对话:活泼开朗,带班哄孩子一把好手。全年龄向沉浸式角色扮演 |
25
+ | [角色扮演 · 谢晚舟](https://dsh-market.com/#preset:roleplay-xiewanzhou)(`roleplay-xiewanzhou`) | dongshuyan | 与互联网公司后端工程师谢晚舟对话:上班理性话少,下班宅家看番。全年龄向沉浸式角色扮演 |
26
+ | [角色扮演 · 苏绵绵](https://dsh-market.com/#preset:roleplay-sumianmian)(`roleplay-sumianmian`) | dongshuyan | 与重点大学经管系大一学生苏绵绵对话:呆萌的富家千金,从小被保护得很好。全年龄向沉浸式角色扮演 |
27
+
18
28
  ## 安装
19
29
 
20
30
  ```sh
package/lib/index.js CHANGED
@@ -11,38 +11,111 @@ import { createHash } from "node:crypto";
11
11
  * the loader accepts a standalone install of the same package side by side;
12
12
  * without this guard the second instance would still re-register the same
13
13
  * webserver routes, tools, settings namespaces, and system-prompt sections
14
- * and fail the boot. mountOnce makes the second host apply a no-op for the
15
- * lifetime of the first instance (the browser half is already deduped by
16
- * package name in the client module host).
14
+ * and fail the boot. mountOnce makes a mount of an already-mounted package a
15
+ * no-op for as long as the first instance lives (the browser half is already
16
+ * deduped by package name in the client module host).
17
+ *
18
+ * A no-op is only safe while the holder is ALIVE. The holder can be disposed
19
+ * long after the refused mount ran its course: the Host reloads a profile by
20
+ * creating the new loader entries before the old ones are torn down (a
21
+ * plugin-manager enable/disable/install write, a settings-driven row reload,
22
+ * HMR), so the new aggregate shell entry mounts its family plugin while the
23
+ * previous entry still owns the name. Dropping that refused mount lost the
24
+ * plugin for good - the previous entry then disposed its own mount, releasing
25
+ * the name with nobody left to take it, and the family row stayed listed as
26
+ * active while its host routes 404ed (the task-board panel showed
27
+ * "board.hostError.notMounted", no degraded record appeared, and only a Host
28
+ * restart recovered it).
29
+ *
30
+ * The refused mount is therefore QUEUED, not dropped, and replayed the moment
31
+ * the holder releases the name - if the waiting fiber is still alive then. The
32
+ * single-instance guarantee is unchanged: exactly one mount is live per
33
+ * package name, and the replay re-enters the guard so a later mount still
34
+ * dedupes against it.
17
35
  *
18
36
  * The registry rides a global symbol so two module instances of the same
19
- * package (npm copy vs repository link) still share one verdict. cordis
20
- * `ctx.effect` runs its callback immediately and treats the callback's
37
+ * package (npm copy vs repository link) still share one verdict. That symbol
38
+ * is a CROSS-REPOSITORY contract, not this file's private state: the four
39
+ * satellite packages (dsh-skins / dsh-pet / dsh-presets /
40
+ * dsh-community-plugins) are separate repositories carrying their own copy of
41
+ * this guard, rebuilt on their own schedule, so the value under `MOUNTED`
42
+ * must keep the shape every published copy reads (a `Set` of package names
43
+ * with `has`/`add`/`delete`). The wait queues this guard added therefore live
44
+ * under their own additive key, and the registry reads back a `Set` even when
45
+ * some other build left a different value there. Changing `MOUNTED`'s shape
46
+ * in place broke that contract once: a satellite's legacy copy created a
47
+ * `Set`, the family's new copy read it as a `Map`, and every family row
48
+ * mounted after it failed with "claims.get is not a function".
49
+ *
50
+ * cordis `ctx.effect` runs its callback immediately and treats the callback's
21
51
  * return value as the fiber disposer, so the unmarker is returned, not run.
22
52
  */
53
+ /** Published cross-repository contract: package names currently mounted. */
23
54
  const MOUNTED = Symbol.for("dsh-web.mounted-plugins");
55
+ /** Additive key this guard owns: refused mounts waiting for the name. */
56
+ const WAITERS = Symbol.for("dsh-web.mounted-plugins.waiters");
57
+ /**
58
+ * The shared name registry, always a `Set` whatever another build stored here:
59
+ * a foreign value (an interim shape, a hand-written global) must not take every
60
+ * family plugin down with it.
61
+ * @returns the process-wide set of mounted package names.
62
+ */
24
63
  function mountedSet() {
25
64
  const registry = globalThis;
26
- return registry[MOUNTED] ??= /* @__PURE__ */ new Set();
65
+ const existing = registry[MOUNTED];
66
+ if (existing instanceof Set) return existing;
67
+ const created = /* @__PURE__ */ new Set();
68
+ registry[MOUNTED] = created;
69
+ return created;
70
+ }
71
+ /** Queue per package name for mounts refused while a holder was alive. */
72
+ function mountWaiters() {
73
+ const registry = globalThis;
74
+ return registry[WAITERS] ??= /* @__PURE__ */ new Map();
27
75
  }
28
76
  /**
29
77
  * Wrap a cordis plugin apply so the package runs at most once per process.
30
- * The first mount registers normally and unmarks when its fiber disposes;
31
- * any later mount of the same package name is a no-op.
78
+ * The first mount registers normally and releases the name when its fiber
79
+ * disposes; a mount refused while that name is held waits for the release and
80
+ * then runs, unless its own fiber disposes first.
32
81
  * @param packageName - npm package identity shared by every install source.
33
82
  * @param fn - the original plugin apply.
34
83
  * @returns an apply of the same shape.
35
84
  */
36
85
  function mountOnce(packageName, fn) {
37
- return ((...args) => {
86
+ const mount = (...args) => {
38
87
  const mounted = mountedSet();
39
- if (mounted.has(packageName)) return;
88
+ const ctx = args[0];
89
+ if (mounted.has(packageName)) {
90
+ const waiters = mountWaiters();
91
+ const queue = waiters.get(packageName) ?? [];
92
+ let alive = true;
93
+ const pending = { run: () => {
94
+ if (alive) mount(...args);
95
+ } };
96
+ ctx?.effect?.(() => () => {
97
+ alive = false;
98
+ const index = queue.indexOf(pending);
99
+ if (index >= 0) queue.splice(index, 1);
100
+ });
101
+ queue.push(pending);
102
+ waiters.set(packageName, queue);
103
+ return;
104
+ }
40
105
  mounted.add(packageName);
41
- args[0]?.effect?.(() => () => {
106
+ ctx?.effect?.(() => () => {
42
107
  mounted.delete(packageName);
108
+ const waiters = mountWaiters();
109
+ const queue = waiters.get(packageName);
110
+ if (queue === void 0) return;
111
+ waiters.delete(packageName);
112
+ for (const waiter of queue.splice(0)) queueMicrotask(() => {
113
+ waiter.run();
114
+ });
43
115
  });
44
116
  return fn(...args);
45
- });
117
+ };
118
+ return mount;
46
119
  }
47
120
  //#endregion
48
121
  //#region src/host/declarations.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-preset-center",
3
3
  "description": "Community agent-preset manager: the Workshop's Presets panel and the host library that installs, declares, disables and uninstalls presets downloaded from dsh-market.com, keeping a downloaded composition inert until the plugin declares it to the agent-preset registry.",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },