dsh-plugin-core-demo 0.39.0 → 0.40.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.
Files changed (2) hide show
  1. package/dist/client.js +81 -51
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -70034,6 +70034,10 @@ h(SideSheet, {
70034
70034
  "zh": "\u524D\u7AEF\u7684\u901A\u77E5\u53BB\u91CD id \u4E0E\u7EC8\u6001\u4EA4\u63A5\u7ED3\u679C\u7528\u6709\u754C LRU \u7F13\u5B58\uFF08\u4E0A\u9650 512\uFF09\uFF0C\u4E0D\u4F1A\u968F\u957F\u65F6\u95F4\u5F00\u9875\u65E0\u9650\u589E\u957F\uFF1B\u8DE8\u9875 / \u91CD\u5F00\u53BB\u91CD\u9760\u670D\u52A1\u7AEF cursor\u3002\u53E5\u67C4\u5151\u73B0\u4EE5\u767B\u8BB0\u65F6\u670D\u52A1\u7AEF\u539F\u5B50 create \u8FD4\u56DE\u7684\u6743\u5A01\u8BB0\u5F55\u4E3A\u771F\u6E90\uFF0C\u672C\u5730\u7F13\u5B58\u53EA\u662F\u300C\u901A\u77E5\u65E9\u4E8E waiter\u300D\u7684\u5FEB\u8DEF\u5F84\u2014\u2014\u6DD8\u6C70\u540E\u4ECD\u80FD\u5151\u73B0\u3001\u4E0D\u7559 pending\uFF0C\u4E14\u540C key \u91CD\u5EFA\u4E0D\u4F1A\u88AB\u4E0A\u4E00\u8F6E\u7EC8\u6001\u9519\u8BEF\u5151\u73B0\u3002",
70035
70035
  "en": 'Notification de-duplication ids and terminal handoff results on the client use a bounded LRU cache (limit 512) and never grow without bound on a long-lived page. Cross-page / reopen de-duplication relies on the server cursor. Settling an authoritative handle uses the authoritative record returned by the server atomic create at registration as the source of truth; the local cache is only a fast path for "notice before waiter" \u2014 eviction still settles without leaving a pending handle, and reusing a key can never settle a fresh handle with the previous instance terminal.'
70036
70036
  },
70037
+ {
70038
+ "zh": "\u6309\u94AE\u547D\u4EE4\u7684\u5E42\u7B49\u7F13\u5B58\u540C\u6837\u6709\u754C\uFF1A\u6309\uFF08\u9879\u76EE\u3001\u4EFB\u52A1\u3001\u6309\u94AE\u3001\u7248\u672C\uFF09\u4E3A\u952E\uFF0C\u5BB9\u91CF\u4E0A\u9650 512\u3001\u5199\u5165\u540E\u8D85\u8FC7 60 \u79D2\u5373\u8FC7\u671F\uFF08\u5230\u70B9\u90A3\u4E00\u79D2\u4ECD\u6709\u6548\uFF09\uFF0C\u4E24\u8F74\u90FD\u7531\u540C\u4E00\u5957\u901A\u7528\u6709\u754C\u7F13\u5B58\u6267\u884C\u2014\u2014\u5BB9\u91CF\u6EE1\u6DD8\u6C70\u6700\u4E45\u672A\u7528\u9879\uFF0C\u8FC7\u671F\u6761\u76EE\u5728\u4E0B\u6B21\u8BBF\u95EE\u65F6\u5220\u9664\u5E76\u6362\u65B0\u5E42\u7B49\u952E\u3002\u7A97\u53E3\u5185\u91CD\u590D\u70B9\u51FB\u590D\u7528\u540C\u4E00\u6761\u76EE\uFF08\u6210\u529F\u540E\u8FDE\u7ED3\u679C\u4E00\u8D77\u56DE\u653E\uFF0C\u4E0D\u518D\u53D1\u8BF7\u6C42\uFF09\uFF0C\u7A97\u53E3\u5916\u91CD\u65B0\u53D1\u547D\u4EE4\uFF1B\u957F\u751F\u547D\u5468\u671F\u9875\u9762\u4E0D\u4F1A\u56E0\u4E3A\u70B9\u8FC7\u7684\u6309\u94AE\u8D8A\u79EF\u8D8A\u591A\u800C\u65E0\u754C\u589E\u957F\u3002",
70039
+ "en": "Button command idempotency is bounded the same way: keyed by (project, task, action, version), capped at 512 entries and expiring once more than 60 seconds have passed since the write (the boundary second still counts), both enforced by the shared bounded cache \u2014 the oldest unused entry is evicted at capacity, and an expired entry is deleted on next access so a fresh idempotency key is minted. Clicks inside the window reuse the entry (and replay the cached result after success, sending no request); outside it a new command is sent. A long-lived page therefore cannot grow without bound as more buttons are clicked."
70040
+ },
70037
70041
  {
70038
70042
  "zh": "\u771F\u6E90\u5728\u670D\u52A1\u7AEF\uFF1A\u539F\u5B50 `create` \u51B3\u5B9A `created`\uFF0C`startedAt / deadlineAt / version` \u7531\u670D\u52A1\u7AEF\u751F\u6210\uFF0C\u8D85\u65F6\u4E0E\u79DF\u7EA6\u7531\u670D\u52A1\u7AEF watchdog \u5224\u5B9A\uFF0C\u7EC8\u6001\u6309 TTL \u6E05\u7406\u3002\u6838\u5FC3\u53EA\u6309\u5355\u8C03 version \u5408\u5E76\u57FA\u7EBF\u3001\u5206\u9875\u4E0E\u589E\u91CF\uFF1B\u6309\u94AE\u662F `{id, token, expiresAt}` \u63CF\u8FF0\uFF0C`runAction` \u6309 actionId \u8D70\u670D\u52A1\u7AEF\u547D\u4EE4\uFF0C\u4E0D\u4F9D\u8D56\u9875\u9762\u95ED\u5305\u3002\u70B9\u51FB\u6309\u94AE\u4F1A\u5411 `taskNotificationEvents` \u53D1 `action` \u4E8B\u4EF6\uFF08\u542B\u4EFB\u52A1\u5FEB\u7167\u3001actionId\u3001ok\u3001reason\u3001result\uFF09\uFF0C\u6D88\u8D39\u65B9\u636E\u6B64\u628A\u754C\u9762\u5E26\u56DE\u6765\u3002\u6743\u5A01\u53E5\u67C4\u53EA\u6709 `id / isSettled / settled`\uFF0C\u6CA1\u6709 update/touch/background/done/fail/track\u2014\u2014\u7EC8\u6001\u7531\u670D\u52A1\u7AEF\u5224\u5B9A\uFF0C\u7F16\u8BD1\u671F\u5373\u963B\u6B62\u8BEF\u7528\u3002",
70039
70043
  "en": "The server owns the truth: atomic `create` decides `created`; `startedAt / deadlineAt / version` come from the server; a server watchdog decides timeouts and lease expiry; terminal records are cleared by TTL. Actions are `{id, token, expiresAt}` descriptors and `runAction` dispatches by actionId to the server, never through page closures. Every click emits an `action` event to `taskNotificationEvents` (with task snapshot, actionId, ok, reason, result) so consumers can restore their UI. An authoritative handle exposes only `id / isSettled / settled`; update/touch/background/done/fail/track do not exist \u2014 the server decides terminal state, and the type system prevents misuse."
@@ -74812,6 +74816,67 @@ function PaginationPage() {
74812
74816
  // packages/demo/src/sections/task-notifications.tsx
74813
74817
  var import_react108 = require("react");
74814
74818
 
74819
+ // dist/adv/tasks/bounded-cache.js
74820
+ function createBoundedCache(limit, ttlMs = Number.POSITIVE_INFINITY, now = Date.now) {
74821
+ if (!Number.isInteger(limit) || limit < 1) {
74822
+ throw new Error("bounded cache limit must be a positive integer");
74823
+ }
74824
+ if (!(ttlMs > 0)) {
74825
+ throw new Error("bounded cache ttl must be positive");
74826
+ }
74827
+ const entries2 = /* @__PURE__ */ new Map();
74828
+ const expired = (entry) => now() - entry.writtenAt > ttlMs;
74829
+ const dropIfExpired = (key, entry) => {
74830
+ if (!expired(entry))
74831
+ return false;
74832
+ entries2.delete(key);
74833
+ return true;
74834
+ };
74835
+ const refreshOrder = (key, entry) => {
74836
+ entries2.delete(key);
74837
+ entries2.set(key, entry);
74838
+ };
74839
+ return {
74840
+ has(key) {
74841
+ const entry = entries2.get(key);
74842
+ if (entry === void 0)
74843
+ return false;
74844
+ if (dropIfExpired(key, entry))
74845
+ return false;
74846
+ refreshOrder(key, entry);
74847
+ return true;
74848
+ },
74849
+ get(key) {
74850
+ const entry = entries2.get(key);
74851
+ if (entry === void 0)
74852
+ return void 0;
74853
+ if (dropIfExpired(key, entry))
74854
+ return void 0;
74855
+ refreshOrder(key, entry);
74856
+ return entry.value;
74857
+ },
74858
+ set(key, value) {
74859
+ entries2.delete(key);
74860
+ entries2.set(key, { value, writtenAt: now() });
74861
+ while (entries2.size > limit) {
74862
+ const oldest = entries2.keys().next();
74863
+ if (oldest.done)
74864
+ break;
74865
+ entries2.delete(oldest.value);
74866
+ }
74867
+ },
74868
+ delete(key) {
74869
+ entries2.delete(key);
74870
+ },
74871
+ clear() {
74872
+ entries2.clear();
74873
+ },
74874
+ get size() {
74875
+ return entries2.size;
74876
+ }
74877
+ };
74878
+ }
74879
+
74815
74880
  // dist/adv/tasks/authoritative.js
74816
74881
  var idempotencySeq = 0;
74817
74882
  function newIdempotencyKey(clientId) {
@@ -74881,8 +74946,7 @@ function createAuthoritativeEngine(options) {
74881
74946
  }
74882
74947
  return grouped;
74883
74948
  }
74884
- const invokes = /* @__PURE__ */ new Map();
74885
- const INVOKE_CACHE_MS = 6e4;
74949
+ const invokes = createBoundedCache(options.invokeCacheLimit ?? 512, options.invokeCacheTtlMs ?? 6e4);
74886
74950
  function invokeCacheKey(project, key, actionId, version) {
74887
74951
  return `${project}:${key}:${actionId}:${version}`;
74888
74952
  }
@@ -75115,8 +75179,8 @@ function createAuthoritativeEngine(options) {
75115
75179
  }
75116
75180
  const cacheKey = invokeCacheKey(project, key, actionId, record.version);
75117
75181
  let entry = invokes.get(cacheKey);
75118
- if (entry === void 0 || Date.now() - entry.at > INVOKE_CACHE_MS) {
75119
- entry = { idempotencyKey: newIdempotencyKey(clientId), at: Date.now() };
75182
+ if (entry === void 0) {
75183
+ entry = { idempotencyKey: newIdempotencyKey(clientId) };
75120
75184
  invokes.set(cacheKey, entry);
75121
75185
  }
75122
75186
  if (entry.result !== void 0)
@@ -75136,8 +75200,10 @@ function createAuthoritativeEngine(options) {
75136
75200
  }), timed]);
75137
75201
  const result = { ...raw, idempotencyKey: entry.idempotencyKey };
75138
75202
  if (result.ok) {
75139
- entry.result = result;
75140
- entry.at = Date.now();
75203
+ const current3 = invokes.get(cacheKey);
75204
+ if (current3 === void 0 || current3.idempotencyKey === entry.idempotencyKey) {
75205
+ invokes.set(cacheKey, { ...entry, result });
75206
+ }
75141
75207
  }
75142
75208
  return result;
75143
75209
  } finally {
@@ -75148,7 +75214,7 @@ function createAuthoritativeEngine(options) {
75148
75214
  return { ok: false, reason: error instanceof Error ? error.message : String(error) };
75149
75215
  }
75150
75216
  },
75151
- /** 暴露幂等键供上层在 action 事件里回传,迟到结果由它抑制二次 emit。 */
75217
+ /** 暴露幂等键供上层在 action 事件里回传,迟到结果由它抑制二次 emit;只保留窗口内有效,过期或淘汰后返回 undefined。 */
75152
75218
  idempotencyKeyFor(project, key, actionId, version) {
75153
75219
  return invokes.get(invokeCacheKey(project, key, actionId, version))?.idempotencyKey;
75154
75220
  },
@@ -75529,46 +75595,10 @@ function createTaskNotificationPool(options = {}) {
75529
75595
  store.setState({ tasks: collect(), revision }, true);
75530
75596
  }
75531
75597
  const NOTICE_CACHE_LIMIT = 512;
75532
- function boundedLru(limit) {
75533
- const entries2 = /* @__PURE__ */ new Map();
75534
- const refresh2 = (key, value) => {
75535
- entries2.delete(key);
75536
- entries2.set(key, value);
75537
- };
75538
- return {
75539
- has(key) {
75540
- if (!entries2.has(key))
75541
- return false;
75542
- refresh2(key, entries2.get(key));
75543
- return true;
75544
- },
75545
- get(key) {
75546
- if (!entries2.has(key))
75547
- return void 0;
75548
- const value = entries2.get(key);
75549
- refresh2(key, value);
75550
- return value;
75551
- },
75552
- set(key, value) {
75553
- refresh2(key, value);
75554
- if (entries2.size > limit) {
75555
- const oldest = entries2.keys().next();
75556
- if (!oldest.done)
75557
- entries2.delete(oldest.value);
75558
- }
75559
- },
75560
- delete(key) {
75561
- entries2.delete(key);
75562
- },
75563
- clear() {
75564
- entries2.clear();
75565
- }
75566
- };
75567
- }
75568
75598
  const serverSettlers = /* @__PURE__ */ new Map();
75569
75599
  const serverHandles = /* @__PURE__ */ new Map();
75570
- const deliveredNotices = boundedLru(NOTICE_CACHE_LIMIT);
75571
- const settledResults = boundedLru(NOTICE_CACHE_LIMIT);
75600
+ const deliveredNotices = createBoundedCache(NOTICE_CACHE_LIMIT);
75601
+ const settledResults = createBoundedCache(NOTICE_CACHE_LIMIT);
75572
75602
  function settlementOf(row3) {
75573
75603
  if (row3.state !== "done" && row3.state !== "failed")
75574
75604
  return void 0;
@@ -77113,9 +77143,9 @@ function ReferencePage() {
77113
77143
  "tbody",
77114
77144
  null,
77115
77145
  [
77116
- [t3("buildCore"), `v${"0.39.0"}`],
77117
- [t3("buildDemo"), `v${"0.39.0"}`],
77118
- [t3("buildStamp"), "261116-170322-841"]
77146
+ [t3("buildCore"), `v${"0.40.0"}`],
77147
+ [t3("buildDemo"), `v${"0.40.0"}`],
77148
+ [t3("buildStamp"), "261117-013505-595"]
77119
77149
  ].map(
77120
77150
  ([label, value]) => (0, import_react110.createElement)(
77121
77151
  "tr",
@@ -77434,9 +77464,9 @@ function DemoPage() {
77434
77464
  lineHeight: "14px"
77435
77465
  }
77436
77466
  },
77437
- (0, import_react112.createElement)("span", null, `core v${"0.39.0"}`),
77438
- (0, import_react112.createElement)("span", null, `demo v${"0.39.0"}`),
77439
- (0, import_react112.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261116-170322-841")
77467
+ (0, import_react112.createElement)("span", null, `core v${"0.40.0"}`),
77468
+ (0, import_react112.createElement)("span", null, `demo v${"0.40.0"}`),
77469
+ (0, import_react112.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261117-013505-595")
77440
77470
  )
77441
77471
  )
77442
77472
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-core-demo",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "The shared UI foundation for DSH plugins, with a live component preview: design tokens, common controls, workspace browsing and notifications maintained in one place — install it to preview every component in a real host.",
5
5
  "icon": "./assets/icon-components.svg",
6
6
  "keywords": [