dsh-plugin-core-demo 0.36.0 → 0.36.1
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/dist/client.js +209 -42
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1716,6 +1716,37 @@ function requireProject(project) {
|
|
|
1716
1716
|
}
|
|
1717
1717
|
return fallback;
|
|
1718
1718
|
}
|
|
1719
|
+
var TASK_KEY_TUPLE_PREFIX = "#";
|
|
1720
|
+
function taskKey(key) {
|
|
1721
|
+
if (typeof key === "string") {
|
|
1722
|
+
if (key.trim() === "")
|
|
1723
|
+
throw new Error("task notification key must be a non-empty string");
|
|
1724
|
+
return key;
|
|
1725
|
+
}
|
|
1726
|
+
if (!Array.isArray(key) || key.length === 0) {
|
|
1727
|
+
throw new Error("task notification key must be a non-empty array of strings and numbers");
|
|
1728
|
+
}
|
|
1729
|
+
for (const part of key) {
|
|
1730
|
+
if (typeof part === "number") {
|
|
1731
|
+
if (!Number.isFinite(part))
|
|
1732
|
+
throw new Error("task notification key numbers must be finite");
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
if (typeof part !== "string" || part === "") {
|
|
1736
|
+
throw new Error("task notification key parts must be non-empty strings or finite numbers");
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
return TASK_KEY_TUPLE_PREFIX + JSON.stringify(key);
|
|
1740
|
+
}
|
|
1741
|
+
var TaskNotificationConflictError = class extends Error {
|
|
1742
|
+
constructor(key, ownerOrigin) {
|
|
1743
|
+
super(`task notification key is already running: ${key} (owner ${ownerOrigin})`);
|
|
1744
|
+
this.code = "TASK_NOTIFICATION_CONFLICT";
|
|
1745
|
+
this.name = "TaskNotificationConflictError";
|
|
1746
|
+
this.key = key;
|
|
1747
|
+
this.ownerOrigin = ownerOrigin;
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1719
1750
|
var SELECT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1720
1751
|
function selectTaskNotifications(snapshot, groups, options = {}) {
|
|
1721
1752
|
const allProjects = groups === "*" && options.project === void 0;
|
|
@@ -1846,6 +1877,8 @@ function isTaskRecord(value) {
|
|
|
1846
1877
|
return false;
|
|
1847
1878
|
if (!isOptionalString(value.groupLabel))
|
|
1848
1879
|
return false;
|
|
1880
|
+
if (value.key !== void 0 && (typeof value.key !== "string" || value.key === ""))
|
|
1881
|
+
return false;
|
|
1849
1882
|
if (!isOptionalString(value.icon))
|
|
1850
1883
|
return false;
|
|
1851
1884
|
if (!isOptionalString(value.iconSvg))
|
|
@@ -1976,6 +2009,7 @@ function createTaskNotificationPool(options = {}) {
|
|
|
1976
2009
|
const bus = () => options.events ?? taskNotificationEvents;
|
|
1977
2010
|
const locks = options.locks === void 0 ? browserLocks() : options.locks;
|
|
1978
2011
|
const finishers = /* @__PURE__ */ new Map();
|
|
2012
|
+
const handles = /* @__PURE__ */ new Map();
|
|
1979
2013
|
const runners = /* @__PURE__ */ new Map();
|
|
1980
2014
|
const pendingInvokes = /* @__PURE__ */ new Map();
|
|
1981
2015
|
const probing = /* @__PURE__ */ new Set();
|
|
@@ -2081,6 +2115,9 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2081
2115
|
function find2(id3) {
|
|
2082
2116
|
return localShard().find((task) => task.id === id3);
|
|
2083
2117
|
}
|
|
2118
|
+
function findByKey(project, key) {
|
|
2119
|
+
return store.getState().tasks.find((task) => task.project === project && task.key === key);
|
|
2120
|
+
}
|
|
2084
2121
|
function locate(id3) {
|
|
2085
2122
|
for (const shard of shards.values()) {
|
|
2086
2123
|
const hit = shard.tasks.find((task) => task.id === id3 && task.origin === shard.origin);
|
|
@@ -2143,6 +2180,11 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2143
2180
|
function replace2(tasks2, record) {
|
|
2144
2181
|
return tasks2.map((task) => task.id === record.id ? record : task);
|
|
2145
2182
|
}
|
|
2183
|
+
function withoutActions(task) {
|
|
2184
|
+
const next = { ...task };
|
|
2185
|
+
delete next.actions;
|
|
2186
|
+
return next;
|
|
2187
|
+
}
|
|
2146
2188
|
function holdLiveness() {
|
|
2147
2189
|
if (offline || locksHeld || locks === null)
|
|
2148
2190
|
return;
|
|
@@ -2294,10 +2336,11 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2294
2336
|
holdLiveness();
|
|
2295
2337
|
post({ kind: "hello", origin });
|
|
2296
2338
|
}
|
|
2297
|
-
function
|
|
2339
|
+
function ensure(input) {
|
|
2298
2340
|
const project = requireProject(input.project);
|
|
2299
2341
|
if (project === null)
|
|
2300
2342
|
throw new Error("task notification project cannot be null when registering");
|
|
2343
|
+
const key = input.key === void 0 ? void 0 : taskKey(input.key);
|
|
2301
2344
|
const group = normalizeGroup(input.group);
|
|
2302
2345
|
const detail = cloneDetail(input.detail);
|
|
2303
2346
|
const actions2 = normalizeActions(input.actions);
|
|
@@ -2311,10 +2354,48 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2311
2354
|
throw new Error("task notification title must be a string");
|
|
2312
2355
|
assertOptionalText(input, ["projectLabel", "groupLabel", "icon", "iconSvg"]);
|
|
2313
2356
|
connect();
|
|
2357
|
+
if (key !== void 0) {
|
|
2358
|
+
const existing = findByKey(project, key);
|
|
2359
|
+
if (existing !== void 0) {
|
|
2360
|
+
if (existing.origin !== origin)
|
|
2361
|
+
throw new TaskNotificationConflictError(key, existing.origin);
|
|
2362
|
+
const handle2 = handles.get(existing.id);
|
|
2363
|
+
if (handle2 !== void 0) {
|
|
2364
|
+
if (input.actions !== void 0) {
|
|
2365
|
+
for (const runnerId of [...runners.keys()]) {
|
|
2366
|
+
if (runnerId.startsWith(`${existing.id}#`))
|
|
2367
|
+
runners.delete(runnerId);
|
|
2368
|
+
}
|
|
2369
|
+
runs.forEach((run, index3) => {
|
|
2370
|
+
runners.set(runnerKey(existing.id, index3), run);
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
const next = {
|
|
2374
|
+
...input.actions === void 0 ? existing : withoutActions(existing),
|
|
2375
|
+
title: input.title,
|
|
2376
|
+
...detail === void 0 ? {} : { detail },
|
|
2377
|
+
...input.group === void 0 ? {} : { group },
|
|
2378
|
+
...input.projectLabel === void 0 ? {} : { projectLabel: input.projectLabel },
|
|
2379
|
+
...input.groupLabel === void 0 ? {} : { groupLabel: input.groupLabel },
|
|
2380
|
+
...input.icon === void 0 ? {} : { icon: input.icon },
|
|
2381
|
+
...input.iconSvg === void 0 ? {} : { iconSvg: input.iconSvg },
|
|
2382
|
+
...input.hidden === void 0 ? {} : { hidden: input.hidden },
|
|
2383
|
+
...input.actions === void 0 || actions2.length === 0 ? {} : { actions: actions2 },
|
|
2384
|
+
updatedAt: Date.now()
|
|
2385
|
+
};
|
|
2386
|
+
publish((current3) => current3.some((task) => task.id === existing.id) ? replace2(current3, next) : current3, {
|
|
2387
|
+
type: "updated",
|
|
2388
|
+
task: next
|
|
2389
|
+
});
|
|
2390
|
+
return { handle: handle2, created: false };
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2314
2394
|
const now = Date.now();
|
|
2315
2395
|
const id3 = `${origin}:${String(++idSeq2)}`;
|
|
2316
2396
|
const record = {
|
|
2317
2397
|
id: id3,
|
|
2398
|
+
...key === void 0 ? {} : { key },
|
|
2318
2399
|
project,
|
|
2319
2400
|
group,
|
|
2320
2401
|
...input.projectLabel === void 0 ? {} : { projectLabel: input.projectLabel },
|
|
@@ -2342,28 +2423,6 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2342
2423
|
runners.set(runnerKey(id3, index3), run);
|
|
2343
2424
|
});
|
|
2344
2425
|
finishers.set(id3, finish);
|
|
2345
|
-
publish((current3) => [...current3, record], { type: "registered", task: record });
|
|
2346
|
-
function finish(outcome, reason) {
|
|
2347
|
-
if (isSettled)
|
|
2348
|
-
return;
|
|
2349
|
-
const current3 = find2(id3);
|
|
2350
|
-
if (current3 === void 0)
|
|
2351
|
-
return;
|
|
2352
|
-
isSettled = true;
|
|
2353
|
-
finishers.delete(id3);
|
|
2354
|
-
runs.forEach((_, index3) => {
|
|
2355
|
-
runners.delete(runnerKey(id3, index3));
|
|
2356
|
-
});
|
|
2357
|
-
const reasonText = reason === void 0 ? void 0 : String(reason);
|
|
2358
|
-
const final = {
|
|
2359
|
-
...current3,
|
|
2360
|
-
status: outcome === "done" ? "done" : "failed",
|
|
2361
|
-
...reasonText === void 0 ? {} : { reason: reasonText },
|
|
2362
|
-
updatedAt: Date.now()
|
|
2363
|
-
};
|
|
2364
|
-
publish((current4) => current4.filter((task) => task.id !== id3), { type: "settled", task: final, outcome });
|
|
2365
|
-
resolveSettled({ outcome, reason: reasonText, task: final });
|
|
2366
|
-
}
|
|
2367
2426
|
const handle = {
|
|
2368
2427
|
id: id3,
|
|
2369
2428
|
get isSettled() {
|
|
@@ -2428,7 +2487,32 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2428
2487
|
return promise;
|
|
2429
2488
|
}
|
|
2430
2489
|
};
|
|
2431
|
-
|
|
2490
|
+
handles.set(id3, handle);
|
|
2491
|
+
publish((current3) => [...current3, record], { type: "registered", task: record });
|
|
2492
|
+
function finish(outcome, reason) {
|
|
2493
|
+
if (isSettled)
|
|
2494
|
+
return;
|
|
2495
|
+
const current3 = find2(id3);
|
|
2496
|
+
if (current3 === void 0)
|
|
2497
|
+
return;
|
|
2498
|
+
isSettled = true;
|
|
2499
|
+
finishers.delete(id3);
|
|
2500
|
+
handles.delete(id3);
|
|
2501
|
+
for (const runnerId of [...runners.keys()]) {
|
|
2502
|
+
if (runnerId.startsWith(`${id3}#`))
|
|
2503
|
+
runners.delete(runnerId);
|
|
2504
|
+
}
|
|
2505
|
+
const reasonText = reason === void 0 ? void 0 : String(reason);
|
|
2506
|
+
const final = {
|
|
2507
|
+
...current3,
|
|
2508
|
+
status: outcome === "done" ? "done" : "failed",
|
|
2509
|
+
...reasonText === void 0 ? {} : { reason: reasonText },
|
|
2510
|
+
updatedAt: Date.now()
|
|
2511
|
+
};
|
|
2512
|
+
publish((current4) => current4.filter((task) => task.id !== id3), { type: "settled", task: final, outcome });
|
|
2513
|
+
resolveSettled({ outcome, reason: reasonText, task: final });
|
|
2514
|
+
}
|
|
2515
|
+
return { handle, created: true };
|
|
2432
2516
|
}
|
|
2433
2517
|
function settleLocal(reason) {
|
|
2434
2518
|
let settledCount = 0;
|
|
@@ -2453,7 +2537,8 @@ function createTaskNotificationPool(options = {}) {
|
|
|
2453
2537
|
connect,
|
|
2454
2538
|
refresh,
|
|
2455
2539
|
select: (groups, options2) => selectTaskNotifications(store.getState(), groups, options2),
|
|
2456
|
-
register,
|
|
2540
|
+
register: (input) => ensure(input).handle,
|
|
2541
|
+
ensure,
|
|
2457
2542
|
broadcast,
|
|
2458
2543
|
settleLocal,
|
|
2459
2544
|
runAction,
|
|
@@ -2510,6 +2595,7 @@ var taskNotifications = {
|
|
|
2510
2595
|
},
|
|
2511
2596
|
select: (groups, options) => globalPool().select(groups, options),
|
|
2512
2597
|
register: (input) => globalPool().register(input),
|
|
2598
|
+
ensure: (input) => globalPool().ensure(input),
|
|
2513
2599
|
broadcast: (input) => globalPool().broadcast(input),
|
|
2514
2600
|
settleLocal: (reason) => globalPool().settleLocal(reason),
|
|
2515
2601
|
runAction: (taskId, index3) => globalPool().runAction(taskId, index3),
|
|
@@ -2519,11 +2605,12 @@ var taskNotifications = {
|
|
|
2519
2605
|
globalPool().dispose();
|
|
2520
2606
|
}
|
|
2521
2607
|
};
|
|
2522
|
-
function
|
|
2523
|
-
return
|
|
2608
|
+
function notifyTaskInput(title, options) {
|
|
2609
|
+
return {
|
|
2524
2610
|
title,
|
|
2525
2611
|
...options.project === void 0 ? {} : { project: options.project },
|
|
2526
2612
|
...options.group === void 0 ? {} : { group: options.group },
|
|
2613
|
+
...options.key === void 0 ? {} : { key: options.key },
|
|
2527
2614
|
...options.detail === void 0 ? {} : { detail: options.detail },
|
|
2528
2615
|
...options.actions === void 0 ? {} : { actions: options.actions },
|
|
2529
2616
|
...options.projectLabel === void 0 ? {} : { projectLabel: options.projectLabel },
|
|
@@ -2532,7 +2619,13 @@ function notifyTaskBase(title, options = {}) {
|
|
|
2532
2619
|
...options.iconSvg === void 0 ? {} : { iconSvg: options.iconSvg },
|
|
2533
2620
|
...options.hidden === void 0 ? {} : { hidden: options.hidden },
|
|
2534
2621
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
2535
|
-
}
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
function notifyTaskBase(title, options = {}) {
|
|
2625
|
+
return taskNotifications.register(notifyTaskInput(title, options));
|
|
2626
|
+
}
|
|
2627
|
+
function ensureTask(title, options = {}) {
|
|
2628
|
+
return taskNotifications.ensure(notifyTaskInput(title, options));
|
|
2536
2629
|
}
|
|
2537
2630
|
function notifyMessage(title, options = {}) {
|
|
2538
2631
|
return taskNotifications.broadcast({
|
|
@@ -2546,7 +2639,18 @@ function notifyMessage(title, options = {}) {
|
|
|
2546
2639
|
});
|
|
2547
2640
|
}
|
|
2548
2641
|
function runTask(title, work, options = {}) {
|
|
2549
|
-
|
|
2642
|
+
let claim2;
|
|
2643
|
+
let key;
|
|
2644
|
+
try {
|
|
2645
|
+
key = options.key === void 0 ? void 0 : taskKey(options.key);
|
|
2646
|
+
claim2 = taskNotifications.ensure(notifyTaskInput(title, options));
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
return Promise.reject(error);
|
|
2649
|
+
}
|
|
2650
|
+
if (key !== void 0 && !claim2.created) {
|
|
2651
|
+
return Promise.reject(new TaskNotificationConflictError(key, taskNotifications.origin));
|
|
2652
|
+
}
|
|
2653
|
+
const handle = claim2.handle;
|
|
2550
2654
|
let pending;
|
|
2551
2655
|
try {
|
|
2552
2656
|
pending = typeof work === "function" ? work() : work;
|
|
@@ -2556,7 +2660,7 @@ function runTask(title, work, options = {}) {
|
|
|
2556
2660
|
}
|
|
2557
2661
|
return handle.track(pending);
|
|
2558
2662
|
}
|
|
2559
|
-
var notifyTask = Object.assign(notifyTaskBase, { run: runTask });
|
|
2663
|
+
var notifyTask = Object.assign(notifyTaskBase, { ensure: ensureTask, run: runTask });
|
|
2560
2664
|
var taskNotificationEvents = {
|
|
2561
2665
|
subscribe: (listener) => globalBus().subscribe(listener),
|
|
2562
2666
|
emit: (event) => {
|
|
@@ -70083,6 +70187,10 @@ h(SideSheet, {
|
|
|
70083
70187
|
"zh": "\u6309\u94AE\uFF1A\u8981\u7ED9\u540E\u53F0\u6761\u76EE\u52A0\u300C\u62C9\u56DE\u6765\u300D\u8FD9\u7C7B\u64CD\u4F5C\uFF0C\u5C31\u4F20 `actions: [{ label?, icon?, color?, run }]`\uFF08`label` \u4E0E `icon` \u81F3\u5C11\u7ED9\u4E00\u4E2A\uFF09\u3002\u65B9\u6CD5\u7559\u5728\u521B\u5EFA\u9875\u5185\u5B58\u91CC\uFF0C\u8BB0\u5F55\u53EA\u5E26\u6587\u6848 / \u56FE\u6807\u6807\u8BC6 / \u989C\u8272\uFF0C\u6240\u4EE5\u522B\u7684\u6807\u7B7E\u9875\u4E5F\u753B\u5F97\u51FA\u6309\u94AE\uFF0C\u70B9\u51FB\u4F1A\u53D1\u56DE\u521B\u5EFA\u9875\u6267\u884C\u3002\u4E00\u6761\u8BB0\u5F55\u53EF\u5E26\u591A\u9897\u6309\u94AE\uFF0C\u5C55\u793A\u65B9\u6309\u987A\u5E8F\u5168\u753B\u51FA\u6765\uFF1B\u53EA\u7ED9 `icon` \u7684\u90A3\u9897\u662F\u6B63\u65B9\u5F62\u56FE\u6807\u94AE\u3002",
|
|
70084
70188
|
"en": "Actions: to give a backgrounded row something to do, pass `actions: [{ label?, icon?, color?, run }]` (at least one of `label` and `icon`). The method stays in the creating page's memory and only labels, icon ids and colors cross pages, so other tabs can render the buttons and a click is executed back on the creating page. A record may carry several buttons; the renderer draws them all in order, and an icon-without-label one becomes a square icon button."
|
|
70085
70189
|
},
|
|
70190
|
+
{
|
|
70191
|
+
"zh": "\u4E1A\u52A1\u952E\uFF1A`key` \u8BA9\u767B\u8BB0\u53D8\u6210\u5E42\u7B49 \u2014\u2014 \u540C\u4E00\u4E2A\u952E\u5728\u6C60\u91CC\u6700\u591A\u4E00\u6761\u3002\u540C\u9875\u91CD\u590D\u767B\u8BB0\u5C31\u5730\u66F4\u65B0\u90A3\u6761\u5E76\u8FD4\u56DE\u540C\u4E00\u4E2A\u53E5\u67C4\uFF0C\u522B\u7684\u9875\u9762\u5360\u7740\u540C\u4E00\u4E2A\u952E\u5219\u629B `TaskNotificationConflictError`\uFF08\u4F5C\u4E1A\u5728\u5B83\u90A3\u4E00\u9875\uFF0C\u7ED9\u4E86\u4E5F\u70B9\u4E0D\u52A8\uFF09\u3002\u952E\u53EA\u80FD\u7528\u7A33\u5B9A\u503C\uFF1A`['close', workspaceId, taskId]` \u5BF9\uFF0C\u5E26\u65F6\u95F4 / \u968F\u673A\u6570 / \u8FDB\u5EA6\u6587\u6848\u8FDB\u53BB\u5C31\u7B49\u4E8E\u6BCF\u6B21\u90FD\u65B0\u5F00\u4E00\u6761\u3002\u60F3\u77E5\u9053\u300C\u8FD9\u6761\u662F\u4E0D\u662F\u6211\u521A\u8D77\u7684\u300D\u7528 `notifyTask.ensure()` \u7684 `created`\u3002",
|
|
70192
|
+
"en": "Business key: `key` makes registration idempotent \u2014 at most one row per key. Re-registering on the same page updates that row in place and returns the same handle; a key held by another page throws `TaskNotificationConflictError` (the work lives there, so a handle would be a dead button). Keys must be stable values: `['close', workspaceId, taskId]` works, while timestamps, randomness or progress text mean a brand-new row every time. Use `created` from `notifyTask.ensure()` to tell whether you started it."
|
|
70193
|
+
},
|
|
70086
70194
|
{
|
|
70087
70195
|
"zh": "\u5176\u4F59\u7EA6\u5B9A\uFF1A`detail` \u6536\u4EFB\u610F JSON \u503C\uFF08\u51FD\u6570\u4E0E\u7C7B\u5B9E\u4F8B\u5F53\u573A\u629B\u9519\uFF09\uFF1B`icon` / `iconSvg` \u53EA\u662F\u5B57\u7B26\u4E32\uFF0C\u6E32\u67D3\u4E0E\u6CE8\u5165\u5B89\u5168\u7531\u6D88\u8D39\u7AEF\u8D1F\u8D23\uFF1B\u4E24\u7EA7\u5206\u7EC4\u7528 `project`\uFF08`setDefaultTaskProject()` \u8BBE\u4E00\u6B21\uFF09+ `group`\uFF08\u7F3A\u7701 `default`\uFF09\u3002",
|
|
70088
70196
|
"en": "The rest: `detail` takes any JSON value (functions and class instances throw immediately); `icon` / `iconSvg` are plain strings and rendering plus injection safety are the consumer's job; two-level grouping uses `project` (set once via `setDefaultTaskProject()`) plus `group` (default `default`)."
|
|
@@ -70129,13 +70237,22 @@ h(SideSheet, {
|
|
|
70129
70237
|
"en": 'Everyday entry: project from the global default, group from options.group (default "default"); reach for register when you need an options object or pool-level control'
|
|
70130
70238
|
}
|
|
70131
70239
|
},
|
|
70240
|
+
{
|
|
70241
|
+
"name": "notifyTask.ensure(title, options?)",
|
|
70242
|
+
"type": "(title: string, options?: NotifyTaskOptions) => { handle: TaskNotificationHandle; created: boolean }",
|
|
70243
|
+
"def": "\u2014",
|
|
70244
|
+
"desc": {
|
|
70245
|
+
"zh": "\u5E42\u7B49\u767B\u8BB0\uFF1A\u5E26 key \u65F6\u672C\u9875\u5DF2\u6709\u540C\u952E\u6761\u76EE\u5C31\u5730\u590D\u7528\u5E76\u8FD4\u56DE\u540C\u4E00\u4E2A\u53E5\u67C4\uFF1B`created === false` \u8BF4\u660E\u5DF2\u7ECF\u5728\u8DD1\uFF0C\u522B\u518D\u8D77\u7B2C\u4E8C\u4EFD\u6D3B",
|
|
70246
|
+
"en": "Idempotent registration: with a key, a matching row on this page is reused and the same handle comes back. `created === false` means it is already running, so do not start a second job"
|
|
70247
|
+
}
|
|
70248
|
+
},
|
|
70132
70249
|
{
|
|
70133
70250
|
"name": "notifyTask.run(title, work, options?)",
|
|
70134
70251
|
"type": "<T>(title: string, work: Promise<T> | (() => Promise<T>), options?: NotifyTaskOptions) => Promise<T>",
|
|
70135
70252
|
"def": "\u2014",
|
|
70136
70253
|
"desc": {
|
|
70137
|
-
"zh": "\u5305\u4F4F\u4E00\u6BB5\u5F02\u6B65\uFF1A\u6210\u529F done\u3001\u5931\u8D25 fail\uFF0C\u7ED3\u679C\u4E0E\u5F02\u5E38\u539F\u6837\u900F\u4F20",
|
|
70138
|
-
"en": "Wraps an async task: done on success, fail on rejection, passing the result and error through"
|
|
70254
|
+
"zh": "\u5305\u4F4F\u4E00\u6BB5\u5F02\u6B65\uFF1A\u6210\u529F done\u3001\u5931\u8D25 fail\uFF0C\u7ED3\u679C\u4E0E\u5F02\u5E38\u539F\u6837\u900F\u4F20\uFF1B\u5E26 key \u649E\u4E0A\u5DF2\u5728\u8DD1\u7684\u540C\u952E\u5219 reject\uFF08\u4E0D\u8C03\u7528 work\uFF09",
|
|
70255
|
+
"en": "Wraps an async task: done on success, fail on rejection, passing the result and error through. A key already running rejects without calling work"
|
|
70139
70256
|
}
|
|
70140
70257
|
},
|
|
70141
70258
|
{
|
|
@@ -70206,8 +70323,17 @@ h(SideSheet, {
|
|
|
70206
70323
|
"type": "(input: TaskNotificationInput) => TaskNotificationHandle",
|
|
70207
70324
|
"def": "\u2014",
|
|
70208
70325
|
"desc": {
|
|
70209
|
-
"zh": "\u767B\u8BB0\u4E00\u6761\u771F\u5B9E\u4EFB\u52A1\u5E76\u8FD4\u56DE\u53E5\u67C4",
|
|
70210
|
-
"en": "Registers a real task and returns its handle"
|
|
70326
|
+
"zh": "\u767B\u8BB0\u4E00\u6761\u771F\u5B9E\u4EFB\u52A1\u5E76\u8FD4\u56DE\u53E5\u67C4\uFF1B\u5E26 key \u65F6\u540C\u9875\u91CD\u590D\u767B\u8BB0\u5C31\u5730\u590D\u7528\uFF08\u53EA\u8981\u53E5\u67C4\u3001\u4E0D\u8981 created \u5C31\u7528\u5B83\uFF09",
|
|
70327
|
+
"en": "Registers a real task and returns its handle; with a key, a repeat on the same page reuses the row (use it when you need the handle but not created)"
|
|
70328
|
+
}
|
|
70329
|
+
},
|
|
70330
|
+
{
|
|
70331
|
+
"name": "ensure(input)",
|
|
70332
|
+
"type": "(input: TaskNotificationInput) => TaskNotificationClaim",
|
|
70333
|
+
"def": "\u2014",
|
|
70334
|
+
"desc": {
|
|
70335
|
+
"zh": "\u540C\u4E0A\uFF0C\u53E6\u4EA4\u56DE `created`\uFF1Afalse = \u672C\u9875\u5DF2\u6709\u540C\u952E\u4EFB\u52A1\uFF0C\u522B\u8D77\u7B2C\u4E8C\u4EFD\u6D3B",
|
|
70336
|
+
"en": "Same as register, plus `created`: false means this page already has that key, so do not start a second job"
|
|
70211
70337
|
}
|
|
70212
70338
|
},
|
|
70213
70339
|
{
|
|
@@ -70279,6 +70405,15 @@ h(SideSheet, {
|
|
|
70279
70405
|
"en": "Second-level bucket inside the project; must not be empty"
|
|
70280
70406
|
}
|
|
70281
70407
|
},
|
|
70408
|
+
{
|
|
70409
|
+
"name": "input.key",
|
|
70410
|
+
"type": "string | readonly (string | number)[]",
|
|
70411
|
+
"def": "\u2014",
|
|
70412
|
+
"desc": {
|
|
70413
|
+
"zh": "\u4E1A\u52A1\u952E\uFF1A\u552F\u4E00\u6027\u8303\u56F4\u662F (project, key)\uFF1B\u5B57\u7B26\u4E32\u539F\u6837\u7528\uFF0C\u5143\u7EC4\u6309\u5143\u7D20\u5F52\u4E00\u5316\u6210\u7A33\u5B9A\u4E32\u3002\u53EA\u6536\u6241\u5E73\u539F\u503C\uFF0C\u7A7A\u4E32 / \u7A7A\u6570\u7EC4 / \u5BF9\u8C61 / NaN \u5F53\u573A\u629B\u9519",
|
|
70414
|
+
"en": "Business key, unique per (project, key). Strings are used verbatim; tuples are normalized element-wise into a stable string. Flat primitives only \u2014 empty strings, empty arrays, objects and NaN throw immediately"
|
|
70415
|
+
}
|
|
70416
|
+
},
|
|
70282
70417
|
{
|
|
70283
70418
|
"name": "input.title",
|
|
70284
70419
|
"type": "string",
|
|
@@ -70334,6 +70469,33 @@ h(SideSheet, {
|
|
|
70334
70469
|
"en": "Only labels, icon ids and colors cross pages, and the index is the action id; rows without actions carry no such field"
|
|
70335
70470
|
}
|
|
70336
70471
|
},
|
|
70472
|
+
{
|
|
70473
|
+
"name": "record.key",
|
|
70474
|
+
"type": "string | undefined",
|
|
70475
|
+
"def": "undefined",
|
|
70476
|
+
"desc": {
|
|
70477
|
+
"zh": "\u5F52\u4E00\u5316\u540E\u7684\u4E1A\u52A1\u952E\uFF1B\u8BFB\u4FA7\u62FF\u5B83\u5224\u65AD\u300C\u8FD9\u4E2A\u4EFB\u52A1\u662F\u4E0D\u662F\u5DF2\u7ECF\u5728\u5904\u7406\u4E2D\u300D\uFF0C\u6BD4\u5BF9\u81EA\u5DF1\u7684\u952E\u8981\u7528 `taskKey()` \u7B97\u4E00\u6B21\uFF0C\u522B\u624B\u62FC",
|
|
70478
|
+
"en": "The normalized business key; the read side uses it to tell whether the work is already running. Compare with your own key through `taskKey()` instead of hand-joining strings"
|
|
70479
|
+
}
|
|
70480
|
+
},
|
|
70481
|
+
{
|
|
70482
|
+
"name": "taskKey(key)",
|
|
70483
|
+
"type": "(key: TaskKey) => string",
|
|
70484
|
+
"def": "\u2014",
|
|
70485
|
+
"desc": {
|
|
70486
|
+
"zh": "\u628A\u4E1A\u52A1\u952E\u5F52\u4E00\u5316\u6210\u6C60\u91CC\u5B58\u7684\u90A3\u4E32\uFF08\u5143\u7EC4 \u2192 `#` + JSON\uFF0C\u5B57\u7B26\u4E32\u539F\u6837\uFF09\uFF1B\u8BFB\u5199\u4E24\u4FA7\u7528\u540C\u4E00\u4EFD\u624D\u4E0D\u4F1A\u5BF9\u4E0D\u4E0A",
|
|
70487
|
+
"en": "Normalizes a business key into the stored form (tuples become # + JSON, strings stay verbatim); both sides must use it or they will disagree"
|
|
70488
|
+
}
|
|
70489
|
+
},
|
|
70490
|
+
{
|
|
70491
|
+
"name": "TaskNotificationConflictError",
|
|
70492
|
+
"type": "class extends Error",
|
|
70493
|
+
"def": "\u2014",
|
|
70494
|
+
"desc": {
|
|
70495
|
+
"zh": "\u540C\u952E\u5DF2\u5728\u522B\u7684\u9875\u9762\u767B\u8BB0\u65F6\u629B\u51FA\uFF1B\u5E26 `code`\uFF08\u503C\u4E3A TASK_NOTIFICATION_CONFLICT\uFF09\u3001`key` \u4E0E `ownerOrigin`\u3002\u5224\u51B2\u7A81\u7528 `code`\uFF08core \u88AB\u6253\u8FDB\u6BCF\u4E2A\u63D2\u4EF6\u526F\u672C\uFF0C\u8DE8\u526F\u672C `instanceof` \u4E0D\u53EF\u9760\uFF09",
|
|
70496
|
+
"en": "Thrown when another page holds the key; carries `code` (TASK_NOTIFICATION_CONFLICT), `key` and `ownerOrigin`. Judge by `code`, since core is inlined into each plugin bundle and `instanceof` is unreliable across copies"
|
|
70497
|
+
}
|
|
70498
|
+
},
|
|
70337
70499
|
{
|
|
70338
70500
|
"name": "input.projectLabel / groupLabel",
|
|
70339
70501
|
"type": "string",
|
|
@@ -70348,8 +70510,8 @@ h(SideSheet, {
|
|
|
70348
70510
|
"type": "(patch: TaskNotificationPatch) => void",
|
|
70349
70511
|
"def": "\u2014",
|
|
70350
70512
|
"desc": {
|
|
70351
|
-
"zh": "\u53EA\u6539\u7EAF\u6570\u636E\u5B57\u6BB5\uFF0C\u968F\u65F6\u53EF\u8C03\u7528\
|
|
70352
|
-
"en": "Updates plain data fields, callable any time
|
|
70513
|
+
"zh": "\u53EA\u6539\u7EAF\u6570\u636E\u5B57\u6BB5\uFF0C\u968F\u65F6\u53EF\u8C03\u7528\uFF1B\u6309\u94AE\u6539\u4E0D\u4E86 \u2014\u2014 \u6362\u4E00\u7EC4\u8981\u5E26\u540C\u4E00\u4E2A key \u91CD\u65B0\u767B\u8BB0",
|
|
70514
|
+
"en": "Updates plain data fields, callable any time. Buttons cannot change through it \u2014 re-register with the same key to swap them"
|
|
70353
70515
|
}
|
|
70354
70516
|
},
|
|
70355
70517
|
{
|
|
@@ -70419,6 +70581,11 @@ h(SideSheet, {
|
|
|
70419
70581
|
}
|
|
70420
70582
|
],
|
|
70421
70583
|
"code": [
|
|
70584
|
+
{
|
|
70585
|
+
"id": "bt-keyed-example",
|
|
70586
|
+
"lang": "ts",
|
|
70587
|
+
"src": "import { notifyTask, taskKey, taskNotifications } from 'dsh-plugin-core/ui'\n\n// \u952E = \u300C\u8BA9\u8FD9\u4E24\u6761\u7B97\u540C\u4E00\u4EF6\u4E8B\u300D\u7684\u90A3\u51E0\u4E2A\u503C\u3002\u7A33\u5B9A\u3001\u53EF\u679A\u4E3E\uFF0C\u4E0D\u653E\u65F6\u95F4 / \u968F\u673A\u6570 / \u8FDB\u5EA6\u6587\u6848\u3002\nconst key = ['close', workspaceId, taskId]\n\n// \u2460 \u53EA\u662F\u8981\u5B83\u5728\u90A3\u513F\uFF1A\u53CD\u590D\u767B\u8BB0\u4E5F\u53EA\u6709\u4E00\u6761\uFF0C\u5185\u5BB9\u6309\u6700\u540E\u4E00\u6B21\u5237\u65B0\uFF0C\u53E5\u67C4\u8FD8\u662F\u540C\u4E00\u4E2A\nconst handle = notifyTask('\u6B63\u5728\u7ED3\u6848', { key, timeoutMs: 30 * 60_000 })\nhandle.done('\u5DF2\u7ED3\u6848')\n\n// \u2461 \u8FD8\u8981\u77E5\u9053\u300C\u662F\u4E0D\u662F\u6211\u521A\u8D77\u7684\u300D\uFF1Acreated === false \u8BF4\u660E\u672C\u9875\u5DF2\u7ECF\u5728\u8DD1\uFF0C\u522B\u518D\u8D77\u7B2C\u4E8C\u4EFD\u6D3B\nconst task = notifyTask.ensure('\u6B63\u5728\u7ED3\u6848', { key })\nif (task.created) void closeTask(workspaceId, taskId).finally(() => task.handle.done())\n\n// \u2462 \u8BFB\u4FA7\u5224\u65AD\u300C\u8FD9\u4E2A\u4EFB\u52A1\u662F\u4E0D\u662F\u5DF2\u7ECF\u5728\u5904\u7406\u4E2D\u300D\uFF1A\u8BB0\u5F55\u5E26\u7740\u5F52\u4E00\u5316\u540E\u7684\u952E\nconst running = taskNotifications.select('*').some((t) => t.key === taskKey(key))"
|
|
70588
|
+
},
|
|
70422
70589
|
{
|
|
70423
70590
|
"id": "bt-actions-example",
|
|
70424
70591
|
"lang": "ts",
|
|
@@ -75244,9 +75411,9 @@ function ReferencePage() {
|
|
|
75244
75411
|
"tbody",
|
|
75245
75412
|
null,
|
|
75246
75413
|
[
|
|
75247
|
-
[t3("buildCore"), `v${"0.36.
|
|
75248
|
-
[t3("buildDemo"), `v${"0.36.
|
|
75249
|
-
[t3("buildStamp"), "261115-
|
|
75414
|
+
[t3("buildCore"), `v${"0.36.1"}`],
|
|
75415
|
+
[t3("buildDemo"), `v${"0.36.1"}`],
|
|
75416
|
+
[t3("buildStamp"), "261115-152430-914"]
|
|
75250
75417
|
].map(
|
|
75251
75418
|
([label, value]) => (0, import_react109.createElement)(
|
|
75252
75419
|
"tr",
|
|
@@ -75564,9 +75731,9 @@ function DemoPage() {
|
|
|
75564
75731
|
lineHeight: "14px"
|
|
75565
75732
|
}
|
|
75566
75733
|
},
|
|
75567
|
-
(0, import_react111.createElement)("span", null, `core v${"0.36.
|
|
75568
|
-
(0, import_react111.createElement)("span", null, `demo v${"0.36.
|
|
75569
|
-
(0, import_react111.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261115-
|
|
75734
|
+
(0, import_react111.createElement)("span", null, `core v${"0.36.1"}`),
|
|
75735
|
+
(0, import_react111.createElement)("span", null, `demo v${"0.36.1"}`),
|
|
75736
|
+
(0, import_react111.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261115-152430-914")
|
|
75570
75737
|
)
|
|
75571
75738
|
)
|
|
75572
75739
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-core-demo",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.1",
|
|
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": [
|