diff --git a/static/render-graph/adapter.js b/static/render-graph/adapter.js index c52824b..c0a68fe 100644 --- a/static/render-graph/adapter.js +++ b/static/render-graph/adapter.js @@ -6,7 +6,7 @@ import { socketTypes, } from "./catalog.js"; -export class AuthoringGraphError extends Error { +class AuthoringGraphError extends Error { constructor(code, details = {}) { super(code); this.name = "AuthoringGraphError"; @@ -53,7 +53,6 @@ const deepFreeze = (value) => { return value; }; const sourceMaps = new WeakMap(); -export const getSourceMap = (ir) => sourceMaps.get(ir); export const mapAuthoringDiagnostic = (ir, diagnostic) => { const details = diagnostic?.details; const path = [ @@ -62,7 +61,7 @@ export const mapAuthoringDiagnostic = (ir, diagnostic) => { details?.field, diagnostic?.field, ].find((value) => typeof value === "string"); - const map = getSourceMap(ir); + const map = sourceMaps.get(ir); let match; if (path && map) for (const key of Object.keys(map)) diff --git a/static/render-graph/fxnode-editor.js b/static/render-graph/fxnode-editor.js index 79acc03..7232c15 100644 --- a/static/render-graph/fxnode-editor.js +++ b/static/render-graph/fxnode-editor.js @@ -135,34 +135,17 @@ export async function createRenderGraphEditor(canvas) { menu = createAddNodeMenu(canvas.ownerDocument); host.attach(root, view); await view.whenRendered(); - return createEditorFacade(root, view, { requestAddNode, destroy }); + const editorRoot = root, + editorView = view; + return { + getState: () => editorRoot.getState(), + onSnapshots: (fn) => + editorRoot.onSnapshots((event) => fn(event.snapshot, event.version)), + whenRendered: () => editorView.whenRendered(), + destroy, + }; } catch (e) { await destroy().catch(() => {}); throw e; } } - -/** Creates the small application-facing wrapper around an fxnode root and view. */ -export function createEditorFacade( - root, - view, - { requestAddNode = () => null, destroy = async () => {} } = {}, -) { - return { - getState: () => root.getState(), - getSaveData: () => root.getSaveData(), - load: async (data) => { - await root.load(data); - await view.whenRendered(); - }, - loadComposition: async (data) => { - await root.loadComposition(data); - await view.whenRendered(); - }, - onSnapshots: (fn) => - root.onSnapshots((event) => fn(event.snapshot, event.version)), - requestAddNode, - whenRendered: () => view.whenRendered(), - destroy, - }; -}