@mgamadeus/ddd-design-studio 0.7.3 → 0.8.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.
- package/dist/canvas/index.js +69 -17
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-BLRROGEA.js → chunk-WFH4CMA6.js} +6 -1
- package/dist/chunk-WFH4CMA6.js.map +1 -0
- package/dist/index.d.ts +33 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-BLRROGEA.js.map +0 -1
package/dist/canvas/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
viewportOfComment,
|
|
34
34
|
viewportWithWidth,
|
|
35
35
|
wasContentUrlLoaded
|
|
36
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-WFH4CMA6.js";
|
|
37
37
|
|
|
38
38
|
// src/canvas/DesignStudioCanvasScreen.tsx
|
|
39
39
|
import { normalizeDddError as normalizeDddError3 } from "@mgamadeus/ddd-web/api";
|
|
@@ -2024,13 +2024,53 @@ var FlowCanvas = ({
|
|
|
2024
2024
|
};
|
|
2025
2025
|
var DesignCanvasFlow = (props) => /* @__PURE__ */ jsx7(ReactFlowProvider, { children: /* @__PURE__ */ jsx7(FlowCanvas, { ...props }) });
|
|
2026
2026
|
|
|
2027
|
+
// src/canvas/thumbnailRenderState.ts
|
|
2028
|
+
var OPEN_RENDER_STATUSES = /* @__PURE__ */ new Set(["QUEUED", "RUNNING", "WAITING_FOR_RENDERER"]);
|
|
2029
|
+
var describeThumbnailRenderState = (canvas) => {
|
|
2030
|
+
if (!canvas?.isRendererEnabled) return null;
|
|
2031
|
+
const missingCount = Math.max(0, canvas.missingThumbnailCount ?? 0);
|
|
2032
|
+
const pictureCount = Math.max(missingCount, canvas.thumbnailPictureCount ?? 0);
|
|
2033
|
+
const failedBoards = (canvas.renderRequestFailedBoards?.elements ?? []).map((failure) => ({
|
|
2034
|
+
renderTargetKey: failure.renderTargetKey ?? "",
|
|
2035
|
+
error: failure.error ?? ""
|
|
2036
|
+
}));
|
|
2037
|
+
const reason = canvas.renderRequestError?.trim() ? canvas.renderRequestError.trim() : null;
|
|
2038
|
+
const base = {
|
|
2039
|
+
renderedCount: pictureCount - missingCount,
|
|
2040
|
+
pictureCount,
|
|
2041
|
+
failedCount: failedBoards.length,
|
|
2042
|
+
reason,
|
|
2043
|
+
failedBoards
|
|
2044
|
+
};
|
|
2045
|
+
if (canvas.isThemeStyleUnstable) {
|
|
2046
|
+
return { ...base, kind: "themeUnstable", canRetry: false, isBusy: false };
|
|
2047
|
+
}
|
|
2048
|
+
if (missingCount === 0) return null;
|
|
2049
|
+
const status = canvas.renderRequestStatus ?? null;
|
|
2050
|
+
if (status !== null && OPEN_RENDER_STATUSES.has(status)) {
|
|
2051
|
+
return {
|
|
2052
|
+
...base,
|
|
2053
|
+
kind: status === "WAITING_FOR_RENDERER" ? "waiting" : "rendering",
|
|
2054
|
+
canRetry: false,
|
|
2055
|
+
isBusy: true
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
if (status === "FAILED") {
|
|
2059
|
+
return { ...base, kind: "failed", canRetry: true, isBusy: false };
|
|
2060
|
+
}
|
|
2061
|
+
if (status === "DONE" && (failedBoards.length > 0 || reason !== null)) {
|
|
2062
|
+
return { ...base, kind: "partlyFailed", canRetry: true, isBusy: false };
|
|
2063
|
+
}
|
|
2064
|
+
return { ...base, kind: "pending", canRetry: true, isBusy: false };
|
|
2065
|
+
};
|
|
2066
|
+
var shouldFileRenderRequestAutomatically = (canvas) => describeThumbnailRenderState(canvas)?.kind === "pending";
|
|
2067
|
+
|
|
2027
2068
|
// src/canvas/DesignStudioCanvasScreen.tsx
|
|
2028
2069
|
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2029
2070
|
var CANVAS_STATE_KEYS = ["q", "section", "status", "theme", "mode", "vp"];
|
|
2030
2071
|
var UNCOUNTED_CANVAS_STATE_KEYS = ["q", "theme", "mode", "vp"];
|
|
2031
2072
|
var LIVE_UPDATE_POLL_MS = 15e3;
|
|
2032
2073
|
var THUMBNAIL_RENDER_POLL_MS = 3e3;
|
|
2033
|
-
var OPEN_RENDER_STATUSES = /* @__PURE__ */ new Set(["QUEUED", "RUNNING", "WAITING_FOR_RENDERER"]);
|
|
2034
2074
|
var MAX_PRIORITY_BOARDS = 200;
|
|
2035
2075
|
var LIVE_UPDATE_TOAST_ID = "design-canvas-live-update";
|
|
2036
2076
|
var usePageVisible = () => {
|
|
@@ -2361,6 +2401,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
|
|
|
2361
2401
|
const isRendererEnabled = Boolean(canvas?.isRendererEnabled);
|
|
2362
2402
|
const missingThumbnailCount = canvas?.missingThumbnailCount ?? 0;
|
|
2363
2403
|
const renderStatus = canvas?.renderRequestStatus ?? null;
|
|
2404
|
+
const thumbnailRenderState = useMemo2(() => describeThumbnailRenderState(canvas), [canvas]);
|
|
2364
2405
|
const isRenderOpen = renderStatus !== null && OPEN_RENDER_STATUSES.has(renderStatus);
|
|
2365
2406
|
useEffect6(() => setIsRenderPolling(isRenderOpen), [isRenderOpen]);
|
|
2366
2407
|
const [requestThumbnailRendering] = api.useRequestThumbnailRenderingMutation();
|
|
@@ -2392,9 +2433,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
|
|
|
2392
2433
|
[writesAllowed, currentCanvas, themeArgument, projectKey, canvasKey, requestThumbnailRendering]
|
|
2393
2434
|
);
|
|
2394
2435
|
useEffect6(() => {
|
|
2395
|
-
if (!currentCanvas
|
|
2396
|
-
const currentStatus = currentCanvas.renderRequestStatus ?? null;
|
|
2397
|
-
if (currentStatus === "FAILED" || currentStatus !== null && OPEN_RENDER_STATUSES.has(currentStatus)) return;
|
|
2436
|
+
if (!shouldFileRenderRequestAutomatically(currentCanvas)) return;
|
|
2398
2437
|
fileRenderRequest(false);
|
|
2399
2438
|
}, [currentCanvas, fileRenderRequest]);
|
|
2400
2439
|
const themeOptions = useMemo2(
|
|
@@ -2910,28 +2949,41 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
|
|
|
2910
2949
|
className: "w-44"
|
|
2911
2950
|
}
|
|
2912
2951
|
),
|
|
2913
|
-
|
|
2952
|
+
thumbnailRenderState && (thumbnailRenderState.kind !== "pending" || writesAllowed) ? /* @__PURE__ */ jsxs8(Tooltip, { children: [
|
|
2914
2953
|
/* @__PURE__ */ jsx8(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs8(
|
|
2915
2954
|
"button",
|
|
2916
2955
|
{
|
|
2917
2956
|
type: "button",
|
|
2918
|
-
disabled:
|
|
2919
|
-
|
|
2957
|
+
disabled: !thumbnailRenderState.canRetry || !writesAllowed,
|
|
2958
|
+
"data-thumbnail-render-state": thumbnailRenderState.kind,
|
|
2959
|
+
className: cx(
|
|
2960
|
+
"flex h-8 min-w-0 max-w-[28rem] shrink items-center gap-1.5 rounded-full bg-tint px-3 text-xs font-semibold text-muted-foreground transition-colors enabled:hover:bg-tint-strong enabled:hover:text-foreground",
|
|
2961
|
+
(thumbnailRenderState.kind === "failed" || thumbnailRenderState.kind === "themeUnstable") && "text-destructive"
|
|
2962
|
+
),
|
|
2920
2963
|
onClick: () => fileRenderRequest(true),
|
|
2921
2964
|
children: [
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
" ",
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2965
|
+
thumbnailRenderState.isBusy ? /* @__PURE__ */ jsx8(LoaderCircle, { className: "size-4 shrink-0 animate-spin motion-reduce:animate-none", "aria-hidden": true }) : /* @__PURE__ */ jsx8(ImageDown, { className: "size-4 shrink-0", "aria-hidden": true }),
|
|
2966
|
+
/* @__PURE__ */ jsx8("span", { className: "shrink-0", children: thumbnailRenderState.kind === "themeUnstable" ? texts.thumbnailsThemeUnstable : thumbnailRenderState.kind === "failed" ? texts.thumbnailsFailed : thumbnailRenderState.kind === "partlyFailed" ? texts.thumbnailsPartlyFailed : thumbnailRenderState.kind === "pending" ? texts.thumbnailsPending : thumbnailRenderState.kind === "waiting" ? texts.thumbnailsWaitingForRenderer(shownThemeLabel) : texts.thumbnailsRendering(shownThemeLabel) }),
|
|
2967
|
+
thumbnailRenderState.kind !== "themeUnstable" ? /* @__PURE__ */ jsxs8("span", { className: "shrink-0", children: [
|
|
2968
|
+
"\xB7",
|
|
2969
|
+
" ",
|
|
2970
|
+
texts.thumbnailsProgress(
|
|
2971
|
+
thumbnailRenderState.renderedCount,
|
|
2972
|
+
thumbnailRenderState.pictureCount,
|
|
2973
|
+
thumbnailRenderState.failedCount
|
|
2974
|
+
)
|
|
2975
|
+
] }) : null,
|
|
2976
|
+
thumbnailRenderState.kind === "failed" && thumbnailRenderState.reason ? /* @__PURE__ */ jsxs8("span", { className: "min-w-0 truncate font-normal", children: [
|
|
2977
|
+
"\xB7 ",
|
|
2978
|
+
thumbnailRenderState.reason
|
|
2979
|
+
] }) : null
|
|
2929
2980
|
]
|
|
2930
2981
|
}
|
|
2931
2982
|
) }),
|
|
2932
2983
|
/* @__PURE__ */ jsxs8(TooltipContent, { side: "bottom", className: "max-w-sm", children: [
|
|
2933
|
-
texts.thumbnailsMissing(missingThumbnailCount),
|
|
2934
|
-
|
|
2984
|
+
missingThumbnailCount > 0 ? texts.thumbnailsMissing(missingThumbnailCount) : null,
|
|
2985
|
+
thumbnailRenderState.reason ? ` ${texts.thumbnailsLastError(thumbnailRenderState.reason)}` : "",
|
|
2986
|
+
thumbnailRenderState.failedBoards.length > 0 ? /* @__PURE__ */ jsx8("ul", { className: "mt-1 list-none", children: thumbnailRenderState.failedBoards.map((failedBoard) => /* @__PURE__ */ jsx8("li", { children: texts.thumbnailFailedBoard(failedBoard.renderTargetKey, failedBoard.error) }, failedBoard.renderTargetKey)) }) : null
|
|
2935
2987
|
] })
|
|
2936
2988
|
] }) : null,
|
|
2937
2989
|
hasThemes && themes.length > 0 && /* @__PURE__ */ jsxs8(Tooltip, { children: [
|