Skip to content

Commit ff930d5

Browse files
committed
chore: update dependencies and Weave API changes
1 parent 77140f4 commit ff930d5

File tree

8 files changed

+112
-81
lines changed

8 files changed

+112
-81
lines changed

code/components/room-components/hooks/use-context-menu.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5+
import { v4 as uuidv4 } from "uuid";
56
import {
67
WeaveCopyPastePasteMode,
78
WEAVE_COPY_PASTE_PASTE_MODES,
@@ -187,18 +188,22 @@ function useContextMenu() {
187188
label: "Edit with AI",
188189
icon: <Bot size={16} />,
189190
onClick: async () => {
190-
const base64URL: unknown = await instance.triggerAction<
191+
const image = await instance.triggerAction<
191192
WeaveExportNodesActionParams,
192-
void
193+
Promise<HTMLImageElement>
193194
>("exportNodesTool", {
194195
nodes: nodes.map((n) => n.instance),
195196
options: {
196197
padding: 0,
197198
pixelRatio: 1,
198199
},
199-
download: false,
200200
});
201201

202+
const base64URL: unknown = instance.imageToBase64(
203+
image,
204+
"image/png"
205+
);
206+
202207
setImagesLLMPopupSelectedNodes(nodes.map((n) => n.instance));
203208
setImagesLLMPopupType("edit-prompt");
204209
setImagesLLMPopupImage(base64URL as string);
@@ -229,17 +234,23 @@ function useContextMenu() {
229234
),
230235
icon: <ImageDown size={16} />,
231236
disabled: nodes.length <= 0,
232-
onClick: () => {
233-
instance.triggerAction<WeaveExportNodesActionParams, void>(
234-
"exportNodesTool",
235-
{
236-
nodes: nodes.map((n) => n.instance),
237-
options: {
238-
padding: 20,
239-
pixelRatio: 2,
240-
},
241-
}
242-
);
237+
onClick: async () => {
238+
const image = await instance.triggerAction<
239+
WeaveExportNodesActionParams,
240+
Promise<HTMLImageElement>
241+
>("exportNodesTool", {
242+
nodes: nodes.map((n) => n.instance),
243+
options: {
244+
padding: 20,
245+
pixelRatio: 2,
246+
},
247+
});
248+
249+
const link = document.createElement("a");
250+
link.href = image.src;
251+
link.download = `${uuidv4()}image/png`;
252+
link.click();
253+
243254
setContextMenuShow(false);
244255
},
245256
});

code/components/room-components/hooks/use-generate-mask.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ async function generateMask(
140140

141141
finalMaskElements.push(...(masks as WeaveElementInstance[]));
142142

143-
const base64URL: unknown = await instance.triggerAction<
143+
const image: HTMLImageElement = await instance.triggerAction<
144144
WeaveExportNodesActionParams,
145-
void
145+
Promise<HTMLImageElement>
146146
>("exportNodesTool", {
147147
nodes: finalMaskElements,
148148
triggerSelectionTool: false,
@@ -165,9 +165,10 @@ async function generateMask(
165165
padding: 0,
166166
pixelRatio: 1,
167167
},
168-
download: false,
169168
});
170169

170+
const base64URL: unknown = instance.imageToBase64(image, "image/png");
171+
171172
for (const maskElement of masks) {
172173
if (maskElement && maskElement.getAttrs().nodeType === "mask") {
173174
maskElement.setAttrs({

code/components/room-components/hooks/use-keyboard-handler.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
"use client";
66

7+
import { v4 as uuidv4 } from "uuid";
78
import React from "react";
89
import { useWeave } from "@inditextech/weave-react";
910
import { SidebarActive, useCollaborationRoom } from "@/store/store";
@@ -286,17 +287,22 @@ export function useKeyboardHandler() {
286287
);
287288

288289
useKeyDown(
289-
() => {
290+
async () => {
290291
if (instance) {
291-
instance.triggerAction<WeaveExportStageActionParams, void>(
292-
"exportStageTool",
293-
{
294-
options: {
295-
padding: 20,
296-
pixelRatio: 2,
297-
},
298-
}
299-
);
292+
const image = await instance.triggerAction<
293+
WeaveExportStageActionParams,
294+
Promise<HTMLImageElement>
295+
>("exportStageTool", {
296+
options: {
297+
padding: 20,
298+
pixelRatio: 2,
299+
},
300+
});
301+
302+
const link = document.createElement("a");
303+
link.href = image.src;
304+
link.download = `${uuidv4()}image/png`;
305+
link.click();
300306
}
301307
},
302308
["KeyV"],

code/components/room-components/overlay/room-header.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
"use client";
66

7+
import { v4 as uuidv4 } from "uuid";
78
import React from "react";
89
import { cn, SYSTEM_OS } from "@/lib/utils";
910
import { useRouter } from "next/navigation";
@@ -125,17 +126,24 @@ export function RoomHeader() {
125126
[instance]
126127
);
127128

128-
const handleExportToImage = React.useCallback(() => {
129-
if (instance) {
130-
instance.triggerAction<WeaveExportStageActionParams, void>(
131-
"exportStageTool",
132-
{
133-
options: {
134-
padding: 20,
135-
pixelRatio: 2,
136-
},
137-
}
138-
);
129+
const handleExportToImage = React.useCallback(async () => {
130+
if (instance && instance.getActiveAction() !== "exportStageTool") {
131+
const image = await instance.triggerAction<
132+
WeaveExportStageActionParams,
133+
Promise<HTMLImageElement>
134+
>("exportStageTool", {
135+
options: {
136+
padding: 20,
137+
pixelRatio: 2,
138+
},
139+
});
140+
141+
if (image) {
142+
const link = document.createElement("a");
143+
link.href = image.src;
144+
link.download = `${uuidv4()}image/png`;
145+
link.click();
146+
}
139147
}
140148
setMenuOpen(false);
141149
}, [instance]);

code/components/room-components/overlay/selected-mask-popup.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export function SelectedMaskPopup() {
9191
return;
9292
}
9393

94-
const base64URL: unknown = await instance.triggerAction<
94+
const image: HTMLImageElement = await instance.triggerAction<
9595
WeaveExportNodesActionParams,
96-
void
96+
Promise<HTMLImageElement>
9797
>("exportNodesTool", {
9898
nodes: masks as WeaveElementInstance[],
9999
triggerSelectionTool: false,
@@ -102,9 +102,10 @@ export function SelectedMaskPopup() {
102102
padding: 40,
103103
pixelRatio: 2,
104104
},
105-
download: false,
106105
});
107106

107+
const base64URL: unknown = instance.imageToBase64(image, "image/png");
108+
108109
setActualMaskBase64(base64URL as string);
109110
};
110111

code/components/room-components/overlay/tools-node-overlay.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,22 @@ export function ToolsNodeOverlay() {
316316
return;
317317
}
318318

319-
const base64URL: unknown = await instance.triggerAction<
319+
const image = await instance.triggerAction<
320320
WeaveExportNodesActionParams,
321-
void
321+
Promise<HTMLImageElement>
322322
>("exportNodesTool", {
323323
nodes: nodes.map((n) => n.instance),
324324
options: {
325325
padding: 0,
326326
pixelRatio: 1,
327327
},
328-
download: false,
329328
});
330329

330+
const base64URL: unknown = instance.imageToBase64(
331+
image,
332+
"image/png"
333+
);
334+
331335
setImagesLLMPopupSelectedNodes(nodes.map((n) => n.instance));
332336
setImagesLLMPopupType("edit-prompt");
333337
setImagesLLMPopupImage(base64URL as string);

code/package-lock.json

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
"@commitlint/cli": "19.4.0",
3535
"@commitlint/config-conventional": "19.2.2",
3636
"@hookform/resolvers": "^4.1.3",
37-
"@inditextech/weave-react": "0.47.1",
38-
"@inditextech/weave-sdk": "0.47.1",
39-
"@inditextech/weave-store-azure-web-pubsub": "0.47.1",
40-
"@inditextech/weave-store-websockets": "0.47.1",
37+
"@inditextech/weave-react": "0.48.0",
38+
"@inditextech/weave-sdk": "0.48.0",
39+
"@inditextech/weave-store-azure-web-pubsub": "0.48.0",
40+
"@inditextech/weave-store-websockets": "0.48.0",
4141
"@next/env": "^15.2.1",
4242
"@radix-ui/react-accordion": "^1.2.10",
4343
"@radix-ui/react-avatar": "^1.1.3",

0 commit comments

Comments
 (0)