Compare commits
No commits in common. 'master' and 'customized_version/lingshi' have entirely different histories.
master
...
customized
Binary file not shown.
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 988 B |
Binary file not shown.
|
Before Width: | Height: | Size: 988 B |
@ -1,48 +0,0 @@
|
|||||||
function hasObjectValues(value) {
|
|
||||||
return Boolean(value && typeof value === 'object' && Object.keys(value).length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasInitialCanvasData(initialData, useDefault) {
|
|
||||||
if (!initialData) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(initialData)) {
|
|
||||||
return initialData.length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useDefault) {
|
|
||||||
return hasObjectValues(initialData?.main?.components) || hasObjectValues(initialData?.components);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasObjectValues(initialData);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasCanvasContent(canvas) {
|
|
||||||
return Boolean(
|
|
||||||
canvas &&
|
|
||||||
((Array.isArray(canvas.nodes) && canvas.nodes.length > 0) ||
|
|
||||||
(Array.isArray(canvas.edges) && canvas.edges.length > 0))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldUseCachedCanvas({ cachedCanvas, initialData, useDefault }) {
|
|
||||||
if (!cachedCanvas) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasCanvasContent(cachedCanvas)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !hasInitialCanvasData(initialData, useDefault);
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldPersistCanvas({ nodes, edges }) {
|
|
||||||
return hasCanvasContent({ nodes, edges });
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
shouldUseCachedCanvas,
|
|
||||||
shouldPersistCanvas,
|
|
||||||
};
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
export interface RuntimeNodeData {
|
|
||||||
nodeId?: string;
|
|
||||||
input?: Record<string, any>;
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isRuntimeNode = (item: any): item is RuntimeNodeData => {
|
|
||||||
return !!item && typeof item === 'object' && typeof item.nodeId === 'string';
|
|
||||||
};
|
|
||||||
|
|
||||||
export const flattenRuntimeNodeData = (runtimeData: any): RuntimeNodeData[] => {
|
|
||||||
if (!Array.isArray(runtimeData)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return runtimeData.reduce<RuntimeNodeData[]>((nodes, item) => {
|
|
||||||
if (isRuntimeNode(item)) {
|
|
||||||
nodes.push(item);
|
|
||||||
return nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(item?.nodes)) {
|
|
||||||
nodes.push(...item.nodes.filter(isRuntimeNode));
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodes;
|
|
||||||
}, []);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getRuntimeImageUrl = (
|
|
||||||
runtimeData: any,
|
|
||||||
nodeId: string
|
|
||||||
): string => {
|
|
||||||
const nodeData = flattenRuntimeNodeData(runtimeData).find(
|
|
||||||
(item) => item.nodeId === nodeId
|
|
||||||
);
|
|
||||||
const imageUrl = nodeData?.input?.in;
|
|
||||||
|
|
||||||
return typeof imageUrl === 'string' ? imageUrl.trim() : '';
|
|
||||||
};
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
function isScheduledRunning(app) {
|
|
||||||
return app && (app.scheduled === 1 || app.scheduled === '1' || app.scheduled === true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildRuntimeReconnectRequest({ app, socketId, lastReconnectKey }) {
|
|
||||||
const instanceId = app && app.instanceId ? String(app.instanceId) : '';
|
|
||||||
const newSocketId = socketId ? String(socketId) : '';
|
|
||||||
const appKey = app && (app.id || app.key) ? String(app.id || app.key) : '';
|
|
||||||
|
|
||||||
if (!isScheduledRunning(app) || !instanceId || !newSocketId || !appKey) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const reconnectKey = `${appKey}:${instanceId}:${newSocketId}`;
|
|
||||||
if (reconnectKey === lastReconnectKey) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
instanceId,
|
|
||||||
newSocketId,
|
|
||||||
reconnectKey,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
buildRuntimeReconnectRequest,
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue