ugcinc 4.1.31 → 4.1.32

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.
@@ -354,18 +354,22 @@ export declare function updatePreviewMapForConnection({ nodes, media, accounts,
354
354
  accounts: AccountData[];
355
355
  }): PreviewMap;
356
356
  /**
357
- * Re-generate preview outputs for a specific node with a different selection index.
357
+ * Re-generate preview values for a source node and update all connections from it.
358
358
  * Used for "shuffle" functionality in the editor.
359
359
  *
360
- * @param node - The workflow node to shuffle (typically a source node with a pool)
360
+ * @param nodes - All workflow nodes
361
+ * @param sourceNodeId - The node to shuffle (typically a source node with a pool)
361
362
  * @param shuffleCount - The shuffle index (0 = first pick, 1 = second pick, etc.)
362
363
  * @param media - Media library for source nodes
363
364
  * @param accounts - Account list for account nodes
364
- * @returns Preview values for this node's outputs, or null if node type not found
365
+ * @param currentPreviewMap - The current preview map to update
366
+ * @returns Updated preview map with new values for all connections from the source node
365
367
  */
366
- export declare function shuffleNodePreview({ node, shuffleCount, media, accounts, }: {
367
- node: WorkflowNodeDefinition;
368
+ export declare function shuffleNodePreview({ nodes, sourceNodeId, shuffleCount, media, accounts, currentPreviewMap, }: {
369
+ nodes: WorkflowNodeDefinition[];
370
+ sourceNodeId: string;
368
371
  shuffleCount: number;
369
372
  media: Media[];
370
373
  accounts: AccountData[];
371
- }): Record<string, PortValue | PortValue[] | null> | null;
374
+ currentPreviewMap: PreviewMap;
375
+ }): PreviewMap;
@@ -981,19 +981,24 @@ function updatePreviewMapForConnection({ nodes, media, accounts, }) {
981
981
  return computePreviewMap({ nodes, media, accounts });
982
982
  }
983
983
  /**
984
- * Re-generate preview outputs for a specific node with a different selection index.
984
+ * Re-generate preview values for a source node and update all connections from it.
985
985
  * Used for "shuffle" functionality in the editor.
986
986
  *
987
- * @param node - The workflow node to shuffle (typically a source node with a pool)
987
+ * @param nodes - All workflow nodes
988
+ * @param sourceNodeId - The node to shuffle (typically a source node with a pool)
988
989
  * @param shuffleCount - The shuffle index (0 = first pick, 1 = second pick, etc.)
989
990
  * @param media - Media library for source nodes
990
991
  * @param accounts - Account list for account nodes
991
- * @returns Preview values for this node's outputs, or null if node type not found
992
+ * @param currentPreviewMap - The current preview map to update
993
+ * @returns Updated preview map with new values for all connections from the source node
992
994
  */
993
- function shuffleNodePreview({ node, shuffleCount, media, accounts, }) {
994
- const definition = nodes_1.nodeDefinitions[node.type];
995
+ function shuffleNodePreview({ nodes, sourceNodeId, shuffleCount, media, accounts, currentPreviewMap, }) {
996
+ const sourceNode = nodes.find(n => n.id === sourceNodeId);
997
+ if (!sourceNode)
998
+ return currentPreviewMap;
999
+ const definition = nodes_1.nodeDefinitions[sourceNode.type];
995
1000
  if (!definition)
996
- return null;
1001
+ return currentPreviewMap;
997
1002
  // Build context with shuffleCount as consumedCount
998
1003
  const ctx = {
999
1004
  inputPreviews: {},
@@ -1001,8 +1006,18 @@ function shuffleNodePreview({ node, shuffleCount, media, accounts, }) {
1001
1006
  accounts,
1002
1007
  selectionState: { consumedCount: shuffleCount },
1003
1008
  };
1004
- // Get cached outputs from node.preview_outputs
1005
- const cachedOutputs = node.preview_outputs ?? null;
1006
- // Call generatePreviewFromNode - handles type correlation via runtime check
1007
- return definition.generatePreviewFromNode(node, ctx, cachedOutputs);
1009
+ // Generate new outputs for this node
1010
+ const newOutputs = definition.generatePreviewFromNode(sourceNode, ctx, sourceNode.preview_outputs ?? null);
1011
+ if (!newOutputs)
1012
+ return currentPreviewMap;
1013
+ // Find all connections from this source and update their preview values
1014
+ const connections = deriveConnectionsInternal(nodes);
1015
+ const newMap = { ...currentPreviewMap };
1016
+ for (const conn of connections) {
1017
+ if (conn.sourceNodeId === sourceNodeId) {
1018
+ const key = `${conn.targetNodeId}:${conn.targetInputId}`;
1019
+ newMap[key] = newOutputs[conn.sourceOutputId] ?? null;
1020
+ }
1021
+ }
1022
+ return newMap;
1008
1023
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.1.31",
3
+ "version": "4.1.32",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",