dsh-plugin-core-demo 0.38.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 +199 -77
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -70027,8 +70027,16 @@ h(SideSheet, {
70027
70027
  "en": "The status-source mode only asks the server about keys it already knows: after every page closes there are no keys, a reload restarts the clock, and action handlers die with the page. For full recovery use `taskNotifications.setTaskBackend(project, backend)` plus `notifyTask.server(title, options)`. A backend must provide `list / follow / listNotices / ackNotices / invoke / ack`; registering otherwise throws \u2014 there is no silent fallback."
70028
70028
  },
70029
70029
  {
70030
- "zh": "\u4E24\u6761\u901A\u9053\u5404\u53F8\u5176\u804C\uFF1A\u901A\u9053 A\uFF08`list / follow`\uFF09\u53EA\u6C34\u5408\u5728\u8DD1\u4EFB\u52A1\uFF0C\u7EC8\u6001\u5893\u7891\u53EA\u66F4\u65B0\u672C\u5730\u7EC8\u6001\u95E8\uFF0C\u7EDD\u4E0D\u53D1 `settled`\u3001\u7EDD\u4E0D ack\uFF1B\u901A\u9053 B\uFF08`listNotices / ackNotices`\uFF09\u4E13\u95E8\u6295\u9012\u672A\u786E\u8BA4\u7684\u7EC8\u6001\u901A\u77E5\uFF0C\u4E8B\u4EF6\u53D1\u51FA\u540E\u624D\u6309\u8FDE\u7EED\u6210\u529F\u524D\u7F00 ack\u3002\u56E0\u6B64\u9875\u9762\u91CD\u5F00\u540E\u57FA\u7EBF\u56DE\u653E\u4E0D\u4F1A\u9020\u6210\u91CD\u590D\u901A\u77E5\uFF0C\u672A\u786E\u8BA4\u7684\u901A\u77E5\u4ECD\u4F1A\u901A\u8FC7\u901A\u9053 B \u9001\u8FBE\u3002",
70031
- "en": "Two channels with separate jobs: channel A (`list / follow`) only hydrates running tasks; a terminal tombstone only updates the local terminal gate and never emits `settled` nor acks. Channel B (`listNotices / ackNotices`) delivers unacknowledged terminal notices; the cursor advances only after the event is emitted. A page reopen therefore never duplicates a notice from baseline replay, and unacknowledged notices still arrive through channel B."
70030
+ "zh": "\u4E24\u6761\u901A\u9053\u5404\u53F8\u5176\u804C\uFF1A\u901A\u9053 A\uFF08`list / follow`\uFF09\u53EA\u6C34\u5408\u5728\u8DD1\u4EFB\u52A1\uFF0C\u7EC8\u6001\u5893\u7891\u53EA\u66F4\u65B0\u672C\u5730\u7EC8\u6001\u95E8\uFF0C\u7EDD\u4E0D\u53D1 `settled`\u3001\u7EDD\u4E0D ack\uFF1B\u901A\u9053 B\uFF08`listNotices / ackNotices`\uFF09\u4E13\u95E8\u6295\u9012\u672A\u786E\u8BA4\u7684\u7EC8\u6001\u901A\u77E5\uFF0C\u4E8B\u4EF6\u53D1\u51FA\u540E\u624D\u6309\u8FDE\u7EED\u6210\u529F\u524D\u7F00 ack\u3002\u56E0\u6B64\u9875\u9762\u91CD\u5F00\u540E\u57FA\u7EBF\u56DE\u653E\u4E0D\u4F1A\u9020\u6210\u91CD\u590D\u901A\u77E5\uFF0C\u672A\u786E\u8BA4\u7684\u901A\u77E5\u4ECD\u4F1A\u901A\u8FC7\u901A\u9053 B \u9001\u8FBE\u3002\u901A\u9053 B \u6309\u540E\u7AEF\u5F52\u5C5E\u5206\u7EC4\uFF1A\u6BCF\u4E2A\u540E\u7AEF\u53EA\u67E5\u81EA\u5DF1\u6CE8\u518C\u7684 project\u3001\u7528\u81EA\u5DF1\u7684\u6E38\u6807\u63A8\u8FDB\u4E0E ack\uFF0C\u7EDD\u4E0D\u62FF\u9996\u4E2A\u540E\u7AEF\u4EE3\u67E5\u5168\u90E8\u9879\u76EE\u2014\u2014\u4E0D\u540C\u540E\u7AEF\u53EF\u80FD\u662F\u4E0D\u540C\u670D\u52A1\u6216\u4E0D\u540C\u9274\u6743\u57DF\u3002",
70031
+ "en": "Two channels with separate jobs: channel A (`list / follow`) only hydrates running tasks; a terminal tombstone only updates the local terminal gate and never emits `settled` nor acks. Channel B (`listNotices / ackNotices`) delivers unacknowledged terminal notices; the cursor advances only after the event is emitted. A page reopen therefore never duplicates a notice from baseline replay, and unacknowledged notices still arrive through channel B. Channel B is grouped by backend ownership: each backend queries only the projects registered to it and advances/acks with its own cursor \u2014 it never queries all projects through whichever backend was registered first, since backends may be different services or auth domains."
70032
+ },
70033
+ {
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
+ "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
+ },
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."
70032
70040
  },
70033
70041
  {
70034
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",
@@ -74808,6 +74816,67 @@ function PaginationPage() {
74808
74816
  // packages/demo/src/sections/task-notifications.tsx
74809
74817
  var import_react108 = require("react");
74810
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
+
74811
74880
  // dist/adv/tasks/authoritative.js
74812
74881
  var idempotencySeq = 0;
74813
74882
  function newIdempotencyKey(clientId) {
@@ -74854,11 +74923,30 @@ function createAuthoritativeEngine(options) {
74854
74923
  const noticeCursors = /* @__PURE__ */ new Map();
74855
74924
  let noticePumping = false;
74856
74925
  let noticePending = false;
74857
- function clientCursor() {
74858
- return noticeCursors.get(clientId);
74926
+ let pumpGeneration = 0;
74927
+ function clientCursor(backend) {
74928
+ return noticeCursors.get(backend)?.get(clientId);
74929
+ }
74930
+ function setClientCursor(backend, cursor2) {
74931
+ let byClient = noticeCursors.get(backend);
74932
+ if (byClient === void 0) {
74933
+ byClient = /* @__PURE__ */ new Map();
74934
+ noticeCursors.set(backend, byClient);
74935
+ }
74936
+ byClient.set(clientId, cursor2);
74859
74937
  }
74860
- const invokes = /* @__PURE__ */ new Map();
74861
- const INVOKE_CACHE_MS = 6e4;
74938
+ function byBackend() {
74939
+ const grouped = /* @__PURE__ */ new Map();
74940
+ for (const [project, backend] of backends) {
74941
+ const bucket = grouped.get(backend);
74942
+ if (bucket === void 0)
74943
+ grouped.set(backend, [project]);
74944
+ else
74945
+ bucket.push(project);
74946
+ }
74947
+ return grouped;
74948
+ }
74949
+ const invokes = createBoundedCache(options.invokeCacheLimit ?? 512, options.invokeCacheTtlMs ?? 6e4);
74862
74950
  function invokeCacheKey(project, key, actionId, version) {
74863
74951
  return `${project}:${key}:${actionId}:${version}`;
74864
74952
  }
@@ -74886,6 +74974,37 @@ function createAuthoritativeEngine(options) {
74886
74974
  return;
74887
74975
  emitChange();
74888
74976
  }
74977
+ async function pumpBackendNotices(backend, projects2, generation) {
74978
+ let cursor2 = clientCursor(backend);
74979
+ const seenCursors = /* @__PURE__ */ new Set();
74980
+ for (; ; ) {
74981
+ if (disposed || generation !== pumpGeneration)
74982
+ return;
74983
+ if (cursor2 !== void 0) {
74984
+ if (seenCursors.has(cursor2))
74985
+ return;
74986
+ seenCursors.add(cursor2);
74987
+ }
74988
+ const page = await backend.listNotices(projects2, cursor2);
74989
+ if (disposed || generation !== pumpGeneration || page.notices.length === 0)
74990
+ return;
74991
+ let delivered = 0;
74992
+ for (const notice of page.notices) {
74993
+ onNotice(notice);
74994
+ cursor2 = notice.cursor;
74995
+ delivered += 1;
74996
+ }
74997
+ if (delivered > 0 && cursor2 !== void 0) {
74998
+ await backend.ackNotices(projects2, cursor2);
74999
+ if (disposed || generation !== pumpGeneration)
75000
+ return;
75001
+ setClientCursor(backend, cursor2);
75002
+ }
75003
+ if (page.nextCursor === void 0 || page.nextCursor === cursor2)
75004
+ return;
75005
+ cursor2 = page.nextCursor;
75006
+ }
75007
+ }
74889
75008
  async function pumpNotices() {
74890
75009
  if (disposed || !started || backends.size === 0)
74891
75010
  return;
@@ -74894,44 +75013,24 @@ function createAuthoritativeEngine(options) {
74894
75013
  return;
74895
75014
  }
74896
75015
  noticePumping = true;
75016
+ const generation = pumpGeneration;
74897
75017
  try {
74898
75018
  do {
74899
75019
  noticePending = false;
74900
- const projectsNow = [...backends.keys()];
74901
- const backend = backends.get(projectsNow[0] ?? "");
74902
- if (backend === void 0)
74903
- return;
74904
- let cursor2 = clientCursor();
74905
- const seenCursors = /* @__PURE__ */ new Set();
74906
- for (; ; ) {
74907
- if (disposed)
75020
+ for (const [backend, projects2] of byBackend()) {
75021
+ if (disposed || generation !== pumpGeneration)
74908
75022
  return;
74909
- if (cursor2 !== void 0) {
74910
- if (seenCursors.has(cursor2))
74911
- return;
74912
- seenCursors.add(cursor2);
74913
- }
74914
- const page = await backend.listNotices(projectsNow, cursor2);
74915
- if (disposed || page.notices.length === 0)
74916
- break;
74917
- let delivered = 0;
74918
- for (const notice of page.notices) {
74919
- onNotice(notice);
74920
- cursor2 = notice.cursor;
74921
- delivered += 1;
74922
- }
74923
- if (delivered > 0 && cursor2 !== void 0) {
74924
- await backend.ackNotices(projectsNow, cursor2);
74925
- noticeCursors.set(clientId, cursor2);
75023
+ try {
75024
+ await pumpBackendNotices(backend, projects2, generation);
75025
+ } catch {
74926
75026
  }
74927
- if (page.nextCursor === void 0 || page.nextCursor === cursor2)
74928
- break;
74929
- cursor2 = page.nextCursor;
74930
75027
  }
74931
- } while (noticePending && !disposed);
75028
+ } while (noticePending && !disposed && generation === pumpGeneration);
74932
75029
  } catch {
74933
75030
  } finally {
74934
75031
  noticePumping = false;
75032
+ if (noticePending && started && !disposed)
75033
+ void pumpNotices();
74935
75034
  }
74936
75035
  }
74937
75036
  function advanceCursor2(project, event) {
@@ -74971,15 +75070,7 @@ function createAuthoritativeEngine(options) {
74971
75070
  function startFollow() {
74972
75071
  if (disposed || backends.size === 0)
74973
75072
  return;
74974
- const byBackend = /* @__PURE__ */ new Map();
74975
- for (const [project, backend] of backends) {
74976
- const bucket = byBackend.get(backend);
74977
- if (bucket === void 0)
74978
- byBackend.set(backend, [project]);
74979
- else
74980
- bucket.push(project);
74981
- }
74982
- for (const [backend, owned] of byBackend) {
75073
+ for (const [backend, owned] of byBackend()) {
74983
75074
  if (followers.has(backend))
74984
75075
  continue;
74985
75076
  const cursors = {};
@@ -75030,6 +75121,11 @@ function createAuthoritativeEngine(options) {
75030
75121
  }
75031
75122
  backends.set(project, backend);
75032
75123
  projectState(project);
75124
+ const active = new Set(backends.values());
75125
+ for (const stale of noticeCursors.keys()) {
75126
+ if (!active.has(stale))
75127
+ noticeCursors.delete(stale);
75128
+ }
75033
75129
  if (started) {
75034
75130
  const wasStarted = started;
75035
75131
  this.stop();
@@ -75083,8 +75179,8 @@ function createAuthoritativeEngine(options) {
75083
75179
  }
75084
75180
  const cacheKey = invokeCacheKey(project, key, actionId, record.version);
75085
75181
  let entry = invokes.get(cacheKey);
75086
- if (entry === void 0 || Date.now() - entry.at > INVOKE_CACHE_MS) {
75087
- entry = { idempotencyKey: newIdempotencyKey(clientId), at: Date.now() };
75182
+ if (entry === void 0) {
75183
+ entry = { idempotencyKey: newIdempotencyKey(clientId) };
75088
75184
  invokes.set(cacheKey, entry);
75089
75185
  }
75090
75186
  if (entry.result !== void 0)
@@ -75104,8 +75200,10 @@ function createAuthoritativeEngine(options) {
75104
75200
  }), timed]);
75105
75201
  const result = { ...raw, idempotencyKey: entry.idempotencyKey };
75106
75202
  if (result.ok) {
75107
- entry.result = result;
75108
- 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
+ }
75109
75207
  }
75110
75208
  return result;
75111
75209
  } finally {
@@ -75116,7 +75214,7 @@ function createAuthoritativeEngine(options) {
75116
75214
  return { ok: false, reason: error instanceof Error ? error.message : String(error) };
75117
75215
  }
75118
75216
  },
75119
- /** 暴露幂等键供上层在 action 事件里回传,迟到结果由它抑制二次 emit。 */
75217
+ /** 暴露幂等键供上层在 action 事件里回传,迟到结果由它抑制二次 emit;只保留窗口内有效,过期或淘汰后返回 undefined。 */
75120
75218
  idempotencyKeyFor(project, key, actionId, version) {
75121
75219
  return invokes.get(invokeCacheKey(project, key, actionId, version))?.idempotencyKey;
75122
75220
  },
@@ -75139,6 +75237,7 @@ function createAuthoritativeEngine(options) {
75139
75237
  return backends.has(project);
75140
75238
  },
75141
75239
  stop() {
75240
+ pumpGeneration += 1;
75142
75241
  for (const state of projects.values())
75143
75242
  state.epoch += 1;
75144
75243
  for (const off of followers.values())
@@ -75154,6 +75253,7 @@ function createAuthoritativeEngine(options) {
75154
75253
  this.stop();
75155
75254
  projects.clear();
75156
75255
  invokes.clear();
75256
+ noticeCursors.clear();
75157
75257
  }
75158
75258
  };
75159
75259
  }
@@ -75494,29 +75594,37 @@ function createTaskNotificationPool(options = {}) {
75494
75594
  revision += 1;
75495
75595
  store.setState({ tasks: collect(), revision }, true);
75496
75596
  }
75597
+ const NOTICE_CACHE_LIMIT = 512;
75497
75598
  const serverSettlers = /* @__PURE__ */ new Map();
75498
75599
  const serverHandles = /* @__PURE__ */ new Map();
75499
- const deliveredNotices = /* @__PURE__ */ new Set();
75500
- const settledResults = /* @__PURE__ */ new Map();
75600
+ const deliveredNotices = createBoundedCache(NOTICE_CACHE_LIMIT);
75601
+ const settledResults = createBoundedCache(NOTICE_CACHE_LIMIT);
75602
+ function settlementOf(row3) {
75603
+ if (row3.state !== "done" && row3.state !== "failed")
75604
+ return void 0;
75605
+ return {
75606
+ outcome: row3.state,
75607
+ reason: row3.reason,
75608
+ task: serverRecordToProjection(row3)
75609
+ };
75610
+ }
75501
75611
  function deliverTerminal(notice) {
75502
75612
  const row3 = notice.record;
75503
75613
  const cacheKey = `${row3.project}:${row3.key}`;
75504
75614
  if (deliveredNotices.has(notice.notificationId))
75505
75615
  return;
75506
- deliveredNotices.add(notice.notificationId);
75507
- const projection = serverRecordToProjection(row3);
75508
- const settlement = {
75509
- outcome: row3.state === "done" ? "done" : "failed",
75510
- reason: row3.reason,
75511
- task: projection
75512
- };
75513
- settledResults.set(cacheKey, settlement);
75514
- bus().emit({ type: "settled", outcome: settlement.outcome, task: projection, remote: false });
75616
+ const settlement = settlementOf(row3);
75617
+ if (settlement === void 0)
75618
+ return;
75619
+ deliveredNotices.set(notice.notificationId, true);
75620
+ bus().emit({ type: "settled", outcome: settlement.outcome, task: settlement.task, remote: false });
75515
75621
  const waiter = serverSettlers.get(cacheKey);
75516
75622
  if (waiter !== void 0) {
75517
75623
  serverSettlers.delete(cacheKey);
75518
75624
  serverHandles.delete(cacheKey);
75519
75625
  waiter(settlement);
75626
+ } else {
75627
+ settledResults.set(cacheKey, settlement);
75520
75628
  }
75521
75629
  }
75522
75630
  const authoritative = createAuthoritativeEngine({
@@ -76245,18 +76353,10 @@ function createTaskNotificationPool(options = {}) {
76245
76353
  return isSettled;
76246
76354
  }, settled };
76247
76355
  serverHandles.set(keyOfHandle, handle);
76248
- const cached = settledResults.get(keyOfHandle);
76249
- if (cached !== void 0) {
76250
- settledResults.delete(keyOfHandle);
76251
- serverHandles.delete(keyOfHandle);
76356
+ serverSettlers.set(keyOfHandle, (value) => {
76252
76357
  isSettled = true;
76253
- resolveSettled(cached);
76254
- } else {
76255
- serverSettlers.set(keyOfHandle, (value) => {
76256
- isSettled = true;
76257
- resolveSettled(value);
76258
- });
76259
- }
76358
+ resolveSettled(value);
76359
+ });
76260
76360
  }
76261
76361
  const created = await authoritative.create({
76262
76362
  project,
@@ -76270,6 +76370,28 @@ function createTaskNotificationPool(options = {}) {
76270
76370
  });
76271
76371
  if (created === void 0)
76272
76372
  throw new Error(`project ${project} backend does not support create`);
76373
+ const waiter = serverSettlers.get(keyOfHandle);
76374
+ if (waiter !== void 0) {
76375
+ const authoritative2 = settlementOf(created.record);
76376
+ if (authoritative2 !== void 0) {
76377
+ settledResults.delete(keyOfHandle);
76378
+ serverSettlers.delete(keyOfHandle);
76379
+ serverHandles.delete(keyOfHandle);
76380
+ waiter(authoritative2);
76381
+ } else if (created.created === false) {
76382
+ const cached = settledResults.get(keyOfHandle);
76383
+ if (cached !== void 0 && cached.task.version !== void 0 && cached.task.version > created.record.version) {
76384
+ settledResults.delete(keyOfHandle);
76385
+ serverSettlers.delete(keyOfHandle);
76386
+ serverHandles.delete(keyOfHandle);
76387
+ waiter(cached);
76388
+ } else {
76389
+ settledResults.delete(keyOfHandle);
76390
+ }
76391
+ } else {
76392
+ settledResults.delete(keyOfHandle);
76393
+ }
76394
+ }
76273
76395
  return { handle, created: created.created };
76274
76396
  }
76275
76397
  function settleLocal(reason) {
@@ -77021,9 +77143,9 @@ function ReferencePage() {
77021
77143
  "tbody",
77022
77144
  null,
77023
77145
  [
77024
- [t3("buildCore"), `v${"0.38.0"}`],
77025
- [t3("buildDemo"), `v${"0.38.0"}`],
77026
- [t3("buildStamp"), "261116-161113-772"]
77146
+ [t3("buildCore"), `v${"0.40.0"}`],
77147
+ [t3("buildDemo"), `v${"0.40.0"}`],
77148
+ [t3("buildStamp"), "261117-013505-595"]
77027
77149
  ].map(
77028
77150
  ([label, value]) => (0, import_react110.createElement)(
77029
77151
  "tr",
@@ -77342,9 +77464,9 @@ function DemoPage() {
77342
77464
  lineHeight: "14px"
77343
77465
  }
77344
77466
  },
77345
- (0, import_react112.createElement)("span", null, `core v${"0.38.0"}`),
77346
- (0, import_react112.createElement)("span", null, `demo v${"0.38.0"}`),
77347
- (0, import_react112.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261116-161113-772")
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")
77348
77470
  )
77349
77471
  )
77350
77472
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-core-demo",
3
- "version": "0.38.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": [