@tutti-os/workbench-surface 0.0.358 → 0.0.360
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/index.js +88 -16
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -4950,6 +4950,31 @@ function writeCachedWorkbenchNodePreviewImage(nodeID, previewImageUrl) {
|
|
|
4950
4950
|
previewImageUrl
|
|
4951
4951
|
});
|
|
4952
4952
|
}
|
|
4953
|
+
function readCachedWorkbenchNodePreviewImage(nodeID) {
|
|
4954
|
+
return workbenchNodePreviewRuntime.readLatest(nodeID);
|
|
4955
|
+
}
|
|
4956
|
+
async function captureWorkbenchNodePreviewImage(nodeID, options = {}) {
|
|
4957
|
+
if (!options.bypassCache) {
|
|
4958
|
+
const cachedPreviewImageUrl = readCachedWorkbenchNodePreviewImage(nodeID);
|
|
4959
|
+
if (cachedPreviewImageUrl) {
|
|
4960
|
+
return cachedPreviewImageUrl;
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4963
|
+
const windowElement = Array.from(
|
|
4964
|
+
document.querySelectorAll("[data-workbench-window-id]")
|
|
4965
|
+
).find((candidate) => candidate.dataset.workbenchWindowId === nodeID) ?? null;
|
|
4966
|
+
const captureTarget = windowElement ? resolveWorkbenchCaptureElement(windowElement) : null;
|
|
4967
|
+
if (!captureTarget) {
|
|
4968
|
+
return null;
|
|
4969
|
+
}
|
|
4970
|
+
const texture = await captureElementTexture(captureTarget, {
|
|
4971
|
+
maxHeight: dockPreviewMaxHeight,
|
|
4972
|
+
maxWidth: dockPreviewMaxWidth
|
|
4973
|
+
}).catch(() => null);
|
|
4974
|
+
const previewImageUrl = texture ? createDockPreviewDataUrl(texture.canvas) : null;
|
|
4975
|
+
writeCachedWorkbenchNodePreviewImage(nodeID, previewImageUrl);
|
|
4976
|
+
return previewImageUrl;
|
|
4977
|
+
}
|
|
4953
4978
|
async function captureProvidedWorkbenchNodePreviewImageForNode(node, input = {}) {
|
|
4954
4979
|
const previewImageUrl = await Promise.resolve(
|
|
4955
4980
|
input.captureNodePreviewImage?.(node) ?? null
|
|
@@ -12983,7 +13008,7 @@ var WorkbenchHostDockPopupCard = forwardRef(function WorkbenchHostDockPopupCard2
|
|
|
12983
13008
|
onKeyDown: handleSelectKeyDown,
|
|
12984
13009
|
children: [
|
|
12985
13010
|
/* @__PURE__ */ jsx15(WorkbenchHostDockPopupCardPreview, { previewState }),
|
|
12986
|
-
labelMode === "hover-overlay" &&
|
|
13011
|
+
labelMode === "hover-overlay" && title.trim() ? /* @__PURE__ */ jsx15(WorkbenchHostDockPopupCardLabel, { title }) : null
|
|
12987
13012
|
]
|
|
12988
13013
|
}
|
|
12989
13014
|
),
|
|
@@ -13293,11 +13318,12 @@ function useWorkbenchHostDockPopupPreviewCapture(input) {
|
|
|
13293
13318
|
writeCachedWorkbenchNodePreviewImage(item.node.id, preview.src);
|
|
13294
13319
|
}
|
|
13295
13320
|
writeDockPopupPreviewImage(previewMemoryKey, preview, revision);
|
|
13296
|
-
if (cacheKey && preview.kind === "image") {
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13321
|
+
if (cacheKey && preview.kind === "image" && !item.isMinimized) {
|
|
13322
|
+
writeLatestPersistedDockPreview(
|
|
13323
|
+
dockPreviewCacheRef.current,
|
|
13324
|
+
cacheKey,
|
|
13325
|
+
preview.src
|
|
13326
|
+
);
|
|
13301
13327
|
}
|
|
13302
13328
|
setCapturedPreviewByMemoryKey((current) => ({
|
|
13303
13329
|
...current,
|
|
@@ -13305,29 +13331,63 @@ function useWorkbenchHostDockPopupPreviewCapture(input) {
|
|
|
13305
13331
|
}));
|
|
13306
13332
|
continue;
|
|
13307
13333
|
}
|
|
13308
|
-
const
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13334
|
+
const fallbackMemoryPreview = !item.isMinimized ? readCachedWorkbenchNodePreviewImage(item.node.id) : null;
|
|
13335
|
+
const [
|
|
13336
|
+
fallbackLatestPersistedPreview,
|
|
13337
|
+
fallbackExactPersistedPreview
|
|
13338
|
+
] = !item.isMinimized && !fallbackMemoryPreview && cacheKey ? await Promise.all([
|
|
13339
|
+
readPersistedDockPreview(
|
|
13340
|
+
dockPreviewCacheRef.current,
|
|
13341
|
+
resolveLatestDockPreviewCacheKey(cacheKey)
|
|
13342
|
+
),
|
|
13343
|
+
readPersistedDockPreview(
|
|
13344
|
+
dockPreviewCacheRef.current,
|
|
13345
|
+
cacheKey
|
|
13346
|
+
)
|
|
13347
|
+
]) : [null, null];
|
|
13312
13348
|
if (!captureItemStateIsCurrent(itemStateKey)) {
|
|
13313
13349
|
continue;
|
|
13314
13350
|
}
|
|
13315
|
-
|
|
13316
|
-
|
|
13351
|
+
let fallbackDomPreview = null;
|
|
13352
|
+
if (!item.isMinimized && !fallbackMemoryPreview && !fallbackLatestPersistedPreview && !fallbackExactPersistedPreview) {
|
|
13353
|
+
await yieldDockPopupPreviewCaptureTask();
|
|
13354
|
+
if (!captureItemStateIsCurrent(itemStateKey)) {
|
|
13355
|
+
continue;
|
|
13356
|
+
}
|
|
13357
|
+
fallbackDomPreview = await captureWorkbenchNodePreviewImage(
|
|
13317
13358
|
item.node.id,
|
|
13318
|
-
|
|
13319
|
-
);
|
|
13359
|
+
{ bypassCache: true }
|
|
13360
|
+
).catch(() => null);
|
|
13361
|
+
}
|
|
13362
|
+
if (!captureItemStateIsCurrent(itemStateKey)) {
|
|
13363
|
+
continue;
|
|
13364
|
+
}
|
|
13365
|
+
const fallbackPreviewImageUrl = fallbackMemoryPreview ?? fallbackLatestPersistedPreview ?? fallbackExactPersistedPreview ?? fallbackDomPreview;
|
|
13366
|
+
if (fallbackPreviewImageUrl) {
|
|
13367
|
+
if (fallbackMemoryPreview || fallbackLatestPersistedPreview || fallbackExactPersistedPreview) {
|
|
13368
|
+
writeCachedWorkbenchNodePreviewImage(
|
|
13369
|
+
item.node.id,
|
|
13370
|
+
fallbackPreviewImageUrl
|
|
13371
|
+
);
|
|
13372
|
+
}
|
|
13320
13373
|
const fallbackPreview2 = {
|
|
13321
13374
|
kind: "image",
|
|
13322
|
-
src:
|
|
13375
|
+
src: fallbackPreviewImageUrl
|
|
13323
13376
|
};
|
|
13324
13377
|
writeDockPopupPreviewImage(
|
|
13325
13378
|
previewMemoryKey,
|
|
13326
13379
|
fallbackPreview2,
|
|
13327
13380
|
revision
|
|
13328
13381
|
);
|
|
13382
|
+
if (cacheKey && !fallbackLatestPersistedPreview) {
|
|
13383
|
+
writeLatestPersistedDockPreview(
|
|
13384
|
+
dockPreviewCacheRef.current,
|
|
13385
|
+
cacheKey,
|
|
13386
|
+
fallbackPreviewImageUrl
|
|
13387
|
+
);
|
|
13388
|
+
}
|
|
13329
13389
|
}
|
|
13330
|
-
const fallbackPreview =
|
|
13390
|
+
const fallbackPreview = fallbackPreviewImageUrl ? { kind: "image", src: fallbackPreviewImageUrl } : null;
|
|
13331
13391
|
setCapturedPreviewByMemoryKey((current) => ({
|
|
13332
13392
|
...current,
|
|
13333
13393
|
[previewMemoryKey]: { preview: fallbackPreview, revision }
|
|
@@ -13438,6 +13498,18 @@ function readPersistedDockPreview(dockPreviewCache, cacheKey) {
|
|
|
13438
13498
|
}
|
|
13439
13499
|
return dockPreviewCache?.read(cacheKey).catch(() => null) ?? Promise.resolve(null);
|
|
13440
13500
|
}
|
|
13501
|
+
function writeLatestPersistedDockPreview(dockPreviewCache, cacheKey, previewImageUrl) {
|
|
13502
|
+
dockPreviewCache?.write({
|
|
13503
|
+
key: resolveLatestDockPreviewCacheKey(cacheKey),
|
|
13504
|
+
previewImageUrl
|
|
13505
|
+
});
|
|
13506
|
+
}
|
|
13507
|
+
function resolveLatestDockPreviewCacheKey(cacheKey) {
|
|
13508
|
+
return { ...cacheKey, revision: void 0 };
|
|
13509
|
+
}
|
|
13510
|
+
function yieldDockPopupPreviewCaptureTask() {
|
|
13511
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
13512
|
+
}
|
|
13441
13513
|
function resolveDockPopupPreviewCacheKey(cacheKey, revision) {
|
|
13442
13514
|
return cacheKey ? { ...cacheKey, revision } : null;
|
|
13443
13515
|
}
|