@chili-publish/studio-sdk 1.46.1 → 1.47.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/_bundles/main.js +4 -4
- package/_bundles/main.js.map +1 -1
- package/lib/src/controllers/ComponentGridController.cjs.js.map +1 -1
- package/lib/src/controllers/ComponentGridController.es.js.map +1 -1
- package/lib/src/controllers/FrameController.cjs.js +8 -0
- package/lib/src/controllers/FrameController.cjs.js.map +1 -1
- package/lib/src/controllers/FrameController.d.ts +14 -0
- package/lib/src/controllers/FrameController.es.js +8 -0
- package/lib/src/controllers/FrameController.es.js.map +1 -1
- package/lib/src/controllers/UtilsController.cjs.js +4 -1
- package/lib/src/controllers/UtilsController.cjs.js.map +1 -1
- package/lib/src/controllers/UtilsController.es.js +4 -1
- package/lib/src/controllers/UtilsController.es.js.map +1 -1
- package/lib/src/interactions/Connector.cjs.js +29 -10
- package/lib/src/interactions/Connector.cjs.js.map +1 -1
- package/lib/src/interactions/Connector.d.ts +2 -2
- package/lib/src/interactions/Connector.es.js +29 -10
- package/lib/src/interactions/Connector.es.js.map +1 -1
- package/lib/src/next/controllers/PageController.cjs.js +1 -0
- package/lib/src/next/controllers/PageController.cjs.js.map +1 -1
- package/lib/src/next/controllers/PageController.es.js +1 -0
- package/lib/src/next/controllers/PageController.es.js.map +1 -1
- package/lib/src/sdk/editor-engine.json.cjs.js +1 -1
- package/lib/src/sdk/editor-engine.json.es.js +1 -1
- package/lib/src/sdk/package.json.cjs.js +1 -1
- package/lib/src/sdk/package.json.es.js +1 -1
- package/lib/src/sdk.cjs.js +26 -13
- package/lib/src/sdk.cjs.js.map +1 -1
- package/lib/src/sdk.d.ts +14 -0
- package/lib/src/sdk.es.js +26 -13
- package/lib/src/sdk.es.js.map +1 -1
- package/lib/src/types/BarcodeTypes.cjs.js.map +1 -1
- package/lib/src/types/BarcodeTypes.d.ts +3 -1
- package/lib/src/types/BarcodeTypes.es.js.map +1 -1
- package/lib/src/types/BrandKitTypes.d.ts +4 -2
- package/lib/src/types/CharacterStyleTypes.d.ts +6 -2
- package/lib/src/types/ColorStyleTypes.cjs.js.map +1 -1
- package/lib/src/types/ColorStyleTypes.es.js.map +1 -1
- package/lib/src/types/ComponentGridTypes.cjs.js.map +1 -1
- package/lib/src/types/ComponentGridTypes.es.js.map +1 -1
- package/lib/src/types/ConnectorTypes.cjs.js.map +1 -1
- package/lib/src/types/ConnectorTypes.es.js.map +1 -1
- package/lib/src/types/FrameTypes.cjs.js.map +1 -1
- package/lib/src/types/FrameTypes.d.ts +5 -0
- package/lib/src/types/FrameTypes.es.js.map +1 -1
- package/lib/src/types/ParagraphStyleTypes.cjs.js.map +1 -1
- package/lib/src/types/ParagraphStyleTypes.d.ts +6 -2
- package/lib/src/types/ParagraphStyleTypes.es.js.map +1 -1
- package/lib/src/types/RichTextRuleTypes.cjs.js.map +1 -1
- package/lib/src/types/RichTextRuleTypes.es.js.map +1 -1
- package/lib/src/types/ShapeTypes.cjs.js.map +1 -1
- package/lib/src/types/ShapeTypes.d.ts +2 -0
- package/lib/src/types/ShapeTypes.es.js.map +1 -1
- package/lib/src/types/TextStyleTypes.cjs.js.map +1 -1
- package/lib/src/types/TextStyleTypes.d.ts +2 -1
- package/lib/src/types/TextStyleTypes.es.js.map +1 -1
- package/lib/src/types/VariableTypes.cjs.js.map +1 -1
- package/lib/src/types/VariableTypes.es.js.map +1 -1
- package/lib/src/utils/EngineCallbackHandler.cjs.js.map +1 -1
- package/lib/src/utils/EngineCallbackHandler.es.js.map +1 -1
- package/lib/src/utils/EngineEvent.cjs.js.map +1 -1
- package/lib/src/utils/EngineEvent.es.js.map +1 -1
- package/package.json +17 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connector.cjs.js","sources":["../../../src/interactions/Connector.ts"],"sourcesContent":["import { Connection, connectToChild } from 'penpal';\nimport { Id } from '../types/CommonTypes';\nimport { StudioStyling } from '../types/ConfigurationTypes';\n\nexport const validateEditorLink = (editorLink: string) => {\n const linkValidator = new RegExp(/^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)+[\\w]+\\/$/);\n let link = '';\n if (linkValidator.test(editorLink)) {\n link = editorLink;\n } else if (editorLink.indexOf('/index.html') > -1) {\n link = editorLink.replace('/index.html', '/');\n } else if (editorLink.charAt(-1) !== '/') {\n link = `${editorLink}/`;\n }\n return link;\n};\n\nexport const setupFrame = (iframe: HTMLIFrameElement, editorLink: string, styling?: StudioStyling) => {\n const link = validateEditorLink(editorLink);\n const stylingJson = JSON.stringify(styling || {});\n const html = `<html>\n <head>\n <base href=\"/\" />\n <meta charset=\"UTF-8\"/>\n <!-- use this property to pass the StudioStyling to the engine -->\n <meta name=\"studio-styling\" content='${stylingJson}'>\n </head>\n <body>\n <script>\n const handleIframeError = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: {\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error?.toString(),\n },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n const handleUnhandledRejection = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: { message: event.reason?.toString() || 'Unhandled promise rejection' },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n window.addEventListener('error', handleIframeError);\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\n </script>\n <script src=\"${link}init.js\" async></script>\n <script src=\"${link}flutter_bootstrap.js\"></script>\n <script>\n try {\n if(!window?.initializeStudioEngine){\n throw new Error('Failed to initialize studio engine: initializeStudioEngine not found');\n }\n initializeStudioEngine({\n assetBase: '${link}',\n });\n } catch(error) {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({\n type: 'iframe-error',\n error: {\n message: error?.message || 'Error initializing studio engine',\n error: error?.toString()\n }\n }, window.location.ancestorOrigins[0] || window.location.origin);\n }\n throw error;\n } finally {\n window.removeEventListener('error', handleIframeError);\n window.removeEventListener('unhandledrejection', handleUnhandledRejection);\n }\n </script>\n </body>\n</html>`;\n\n // Set the iframe's content using DOM manipulation\n // eslint-disable-next-line no-param-reassign\n iframe.srcdoc = html;\n};\n\ninterface ConfigParameterTypes {\n onActionsChanged: (state: string) => void;\n onStateChanged: (state: string) => void;\n onAuthExpired: (authRefreshRequest: string) => Promise<string | null>;\n onViewportRequested: () => string | null;\n onDocumentLoaded: () => void;\n onSelectedFramesContentChanged: (state: string) => void;\n onSelectedFramesLayoutChanged: (state: string) => void;\n onFramesLayoutChanged: (state: string) => void;\n onSelectedLayoutPropertiesChanged: (state: string) => void;\n onSelectedLayoutUnitChanged: (state: string) => void;\n /**\n * @deprecated use `onSelectedPageIdChanged` instead\n */\n onPageSelectionChanged: (id: Id) => void;\n onScrubberPositionChanged: (state: string) => void;\n onFrameAnimationsChanged: (state: string) => void;\n onVariableListChanged: (state: string) => void;\n onSelectedToolChanged: (state: string) => void;\n onUndoStateChanged: (state: string) => void;\n onSelectedLayoutFramesChanged: (state: string) => void;\n onSelectedTextStyleChanged: (styles: string) => void;\n onColorsChanged: (colors: string) => void;\n onParagraphStylesChanged: (paragraphStyles: string) => void;\n onCharacterStylesChanged: (characterStyles: string) => void;\n onFontFamiliesChanged: (fonts: string) => void;\n onSelectedLayoutIdChanged: (id: string) => void;\n onLayoutsChanged: (layouts: string) => void;\n onConnectorEvent: (state: string) => void;\n onConnectorsChanged: (state: string) => void;\n onZoomChanged: (scaleFactor: string) => void;\n onSelectedPageIdChanged: (pageId: string) => void;\n onPagesChanged: (pages: string) => void;\n onPageSnapshotInvalidated: (pageId: Id) => void;\n onPageSizeChanged: (scaleFactor: string) => void;\n onShapeCornerRadiusChanged: (cornerRadius: string) => void;\n onCropActiveFrameIdChanged: (id?: Id) => void;\n onAsyncError: (asyncError: string) => void;\n onViewModeChanged: (viewMode: string) => void;\n onBarcodeValidationChanged: (validationResults: string) => void;\n onDataSourceIdChanged: (connectorId?: Id) => void;\n onInjectedDataChanged: (variableId: Id) => void;\n onDocumentIssueListChanged: (documentIssues: string) => void;\n onCustomUndoDataChanged: (customData: string) => void;\n onEngineEditModeChanged: (engineEditMode: string) => void;\n onBrandKitMediaChanged: (brandKitMedia: string) => void;\n onCanvasFramesManipulated: (frameIds: string) => void;\n}\n\nlet messageHandler: ((event: MessageEvent) => void) | null = null;\n\nconst Connect = (\n editorLink: string,\n params: ConfigParameterTypes,\n setConnection: (connection: Connection) => void,\n editorId = 'chili-editor',\n styling?: StudioStyling,\n onSetupFrameError?: (error: Error) => void,\n) => {\n if (messageHandler) {\n window.removeEventListener('message', messageHandler);\n }\n const editorSelectorId = `#${editorId}`;\n const iframe = document.createElement('iframe');\n iframe.setAttribute('srcdoc', ' ');\n iframe.setAttribute('title', 'Chili-Editor');\n iframe.setAttribute('style', 'width: 100%; height: 100%;');\n iframe.setAttribute('frameBorder', '0');\n iframe.setAttribute('referrerpolicy', 'origin');\n const setupNewFrame = () => {\n const iframeContainer = document.querySelector(editorSelectorId);\n if (iframeContainer) {\n iframeContainer?.appendChild(iframe);\n\n iframe.addEventListener(\n 'error',\n () => {\n const error = new Error('Failed to setup frame: iframe failed to load');\n onSetupFrameError?.(error);\n },\n { capture: true, once: true },\n );\n\n try {\n setupFrame(iframe, editorLink, styling);\n } catch (error: unknown) {\n if (error instanceof Error) {\n onSetupFrameError?.(error);\n } else {\n onSetupFrameError?.(new Error(`Failed to setup frame: ${error}`));\n }\n }\n }\n };\n\n if (document.readyState === 'complete' || document.readyState === 'interactive') {\n setupNewFrame();\n } else {\n document.addEventListener('DOMContentLoaded', () => {\n setupNewFrame();\n });\n }\n\n messageHandler = (event: MessageEvent) => {\n if (event.source !== iframe.contentWindow) {\n return;\n }\n if (event.data?.type === 'iframe-error') {\n const errorData = event.data.error;\n const error = new Error(errorData.message || 'Failed to setup frame: error in iframe');\n onSetupFrameError?.(error);\n }\n };\n\n window.addEventListener('message', messageHandler);\n\n setConnection(\n connectToChild({\n // The iframe to which a connection should be made\n iframe,\n // All the methods that we want to expose to the child should be inside the methods object\n // f.e. stateChange(documentJson)\n methods: {\n actionsChanged: params.onActionsChanged,\n stateChanged: params.onStateChanged,\n documentLoaded: params.onDocumentLoaded,\n authExpired: params.onAuthExpired,\n viewportRequested: params.onViewportRequested,\n selectedFramesContent: params.onSelectedFramesContentChanged,\n selectedFramesLayout: params.onSelectedFramesLayoutChanged,\n allFramesLayout: params.onFramesLayoutChanged,\n selectedLayoutProperties: params.onSelectedLayoutPropertiesChanged,\n openLayoutPropertiesPanel: params.onPageSelectionChanged,\n selectedLayoutUnit: params.onSelectedLayoutUnitChanged,\n scrubberPositionChanged: params.onScrubberPositionChanged,\n frameAnimationsChanged: params.onFrameAnimationsChanged,\n selectedToolChanged: params.onSelectedToolChanged,\n variableListChanged: params.onVariableListChanged,\n undoStackStateChanged: params.onUndoStateChanged,\n selectedLayoutFramesChanged: params.onSelectedLayoutFramesChanged,\n selectedTextStyleChanged: params.onSelectedTextStyleChanged,\n colorsChanged: params.onColorsChanged,\n paragraphStylesChanged: params.onParagraphStylesChanged,\n characterStylesChanged: params.onCharacterStylesChanged,\n fontFamiliesChanged: params.onFontFamiliesChanged,\n selectedLayoutId: params.onSelectedLayoutIdChanged,\n layoutListChanged: params.onLayoutsChanged,\n connectorEvent: params.onConnectorEvent,\n connectorsChanged: params.onConnectorsChanged,\n zoomChanged: params.onZoomChanged,\n pageSnapshotInvalidated: params.onPageSnapshotInvalidated,\n pagesChanged: params.onPagesChanged,\n pageSizeChanged: params.onPageSizeChanged,\n shapeCornerRadiusChanged: params.onShapeCornerRadiusChanged,\n cropActiveFrameIdChanged: params.onCropActiveFrameIdChanged,\n asyncError: params.onAsyncError,\n viewModeChanged: params.onViewModeChanged,\n barcodeValidationChanged: params.onBarcodeValidationChanged,\n selectedPageIdChanged: params.onSelectedPageIdChanged,\n dataSourceIdChanged: params.onDataSourceIdChanged,\n injectedDataChanged: params.onInjectedDataChanged,\n documentIssueListChanged: params.onDocumentIssueListChanged,\n customUndoDataChanged: params.onCustomUndoDataChanged,\n engineEditingModeChanged: params.onEngineEditModeChanged,\n brandKitMediaChanged: params.onBrandKitMediaChanged,\n frameManipulated: params.onCanvasFramesManipulated,\n },\n }),\n );\n};\nexport default Connect;\n"],"names":["connectToChild"],"mappings":";;;AAIO,MAAM,qBAAqB,CAAC,eAAuB;AACtD,QAAM,gBAAgB,IAAI,OAAO,kDAAkD;AACnF,MAAI,OAAO;AACX,MAAI,cAAc,KAAK,UAAU,GAAG;AAChC,WAAO;AAAA,EACX,WAAW,WAAW,QAAQ,aAAa,IAAI,IAAI;AAC/C,WAAO,WAAW,QAAQ,eAAe,GAAG;AAAA,EAChD,WAAW,WAAW,OAAO,EAAE,MAAM,KAAK;AACtC,WAAO,GAAG,UAAU;AAAA,EACxB;AACA,SAAO;AACX;AAEO,MAAM,aAAa,CAAC,QAA2B,YAAoB,YAA4B;AAClG,QAAM,OAAO,mBAAmB,UAAU;AAC1C,QAAM,cAAc,KAAK,UAAU,WAAW,CAAA,CAAE;AAChD,QAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,mDAKkC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAmCvC,IAAI;AAAA,uBACJ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAOW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBtC,SAAO,SAAS;AACpB;AAmDA,IAAI,iBAAyD;AAE7D,MAAM,UAAU,CACZ,YACA,QACA,eACA,WA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AAAA,MAAA;AAAA,IAC7B,CACH;AAAA,EAAA;AAET;;;;"}
|
|
1
|
+
{"version":3,"file":"Connector.cjs.js","sources":["../../../src/interactions/Connector.ts"],"sourcesContent":["import { Connection, connectToChild } from 'penpal';\nimport { Id } from '../types/CommonTypes';\nimport { StudioStyling } from '../types/ConfigurationTypes';\n\nexport const validateEditorLink = (editorLink: string) => {\n const linkValidator = new RegExp(/^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)+[\\w]+\\/$/);\n let link = '';\n if (linkValidator.test(editorLink)) {\n link = editorLink;\n } else if (editorLink.indexOf('/index.html') > -1) {\n link = editorLink.replace('/index.html', '/');\n } else if (editorLink.charAt(-1) !== '/') {\n link = `${editorLink}/`;\n }\n return link;\n};\n\nexport const setupFrame = (iframe: HTMLIFrameElement, editorLink: string, styling?: StudioStyling) => {\n const link = validateEditorLink(editorLink);\n const stylingJson = JSON.stringify(styling || {});\n const html = `<html>\n <head>\n <base href=\"${link}\" />\n <meta charset=\"UTF-8\"/>\n <!-- use this property to pass the StudioStyling to the engine -->\n <meta name=\"studio-styling\" content='${stylingJson}'>\n </head>\n <body>\n <script>\n const handleIframeError = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: {\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error?.toString(),\n },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n const handleUnhandledRejection = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: { message: event.reason?.toString() || 'Unhandled promise rejection' },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n window.addEventListener('error', handleIframeError);\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\n </script>\n <script src=\"${link}init.js\" async></script>\n <script src=\"${link}flutter_bootstrap.js\"></script>\n <script>\n try {\n if(!window?.initializeStudioEngine){\n throw new Error('Failed to initialize studio engine: initializeStudioEngine not found');\n }\n initializeStudioEngine({\n assetBase: '${link}',\n });\n } catch(error) {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({\n type: 'iframe-error',\n error: {\n message: error?.message || 'Error initializing studio engine',\n error: error?.toString()\n }\n }, window.location.ancestorOrigins[0] || window.location.origin);\n }\n throw error;\n } finally {\n window.removeEventListener('error', handleIframeError);\n window.removeEventListener('unhandledrejection', handleUnhandledRejection);\n }\n </script>\n </body>\n</html>`;\n\n const blobUrl = URL.createObjectURL(new Blob([html], { type: 'text/html' }));\n iframe.setAttribute('src', blobUrl);\n return blobUrl;\n};\n\ninterface ConfigParameterTypes {\n onActionsChanged: (state: string) => void;\n onStateChanged: (state: string) => void;\n onAuthExpired: (authRefreshRequest: string) => Promise<string | null>;\n onViewportRequested: () => string | null;\n onDocumentLoaded: () => void;\n onSelectedFramesContentChanged: (state: string) => void;\n onSelectedFramesLayoutChanged: (state: string) => void;\n onFramesLayoutChanged: (state: string) => void;\n onSelectedLayoutPropertiesChanged: (state: string) => void;\n onSelectedLayoutUnitChanged: (state: string) => void;\n /**\n * @deprecated use `onSelectedPageIdChanged` instead\n */\n onPageSelectionChanged: (id: Id) => void;\n onScrubberPositionChanged: (state: string) => void;\n onFrameAnimationsChanged: (state: string) => void;\n onVariableListChanged: (state: string) => void;\n onSelectedToolChanged: (state: string) => void;\n onUndoStateChanged: (state: string) => void;\n onSelectedLayoutFramesChanged: (state: string) => void;\n onSelectedTextStyleChanged: (styles: string) => void;\n onColorsChanged: (colors: string) => void;\n onParagraphStylesChanged: (paragraphStyles: string) => void;\n onCharacterStylesChanged: (characterStyles: string) => void;\n onFontFamiliesChanged: (fonts: string) => void;\n onSelectedLayoutIdChanged: (id: string) => void;\n onLayoutsChanged: (layouts: string) => void;\n onConnectorEvent: (state: string) => void;\n onConnectorsChanged: (state: string) => void;\n onZoomChanged: (scaleFactor: string) => void;\n onSelectedPageIdChanged: (pageId: string) => void;\n onPagesChanged: (pages: string) => void;\n onPageSnapshotInvalidated: (pageId: Id) => void;\n onPageSizeChanged: (scaleFactor: string) => void;\n onShapeCornerRadiusChanged: (cornerRadius: string) => void;\n onCropActiveFrameIdChanged: (id?: Id) => void;\n onAsyncError: (asyncError: string) => void;\n onViewModeChanged: (viewMode: string) => void;\n onBarcodeValidationChanged: (validationResults: string) => void;\n onDataSourceIdChanged: (connectorId?: Id) => void;\n onInjectedDataChanged: (variableId: Id) => void;\n onDocumentIssueListChanged: (documentIssues: string) => void;\n onCustomUndoDataChanged: (customData: string) => void;\n onEngineEditModeChanged: (engineEditMode: string) => void;\n onBrandKitMediaChanged: (brandKitMedia: string) => void;\n onCanvasFramesManipulated: (frameIds: string) => void;\n}\n\nconst Connect = (\n editorLink: string,\n params: ConfigParameterTypes,\n setConnection: (connection: Connection) => void,\n editorId = 'chili-editor',\n styling?: StudioStyling,\n onSetupFrameError?: (error: Error) => void,\n) => {\n const editorSelectorId = `#${editorId}`;\n const iframe = document.createElement('iframe');\n iframe.setAttribute('src', 'about:blank');\n iframe.setAttribute('title', 'Chili-Editor');\n iframe.setAttribute('style', 'width: 100%; height: 100%;');\n iframe.setAttribute('frameBorder', '0');\n iframe.setAttribute('referrerpolicy', 'origin');\n\n // Everything this call attaches outside of the penpal connection is tracked per\n // invocation, so releasing one engine frame can never tear down the frame another\n // SDK instance is still using. The `message` listener closes over the iframe: as\n // long as that listener stays registered on `window`, the iframe element - and with\n // it the entire engine realm (Dart heap, CanvasKit and QuickJS WASM memory) - stays\n // reachable and can never be collected, even when the consumer has dropped every\n // reference of its own.\n let messageHandler: ((event: MessageEvent) => void) | null = null;\n let domContentLoadedHandler: (() => void) | null = null;\n let frameBlobUrl: string | null = null;\n\n /**\n * Releases the iframe and listeners this `Connect` call attached. Safe to call\n * more than once, and leaves frames of other `Connect` calls untouched.\n */\n const teardownFrame = () => {\n if (messageHandler) {\n window.removeEventListener('message', messageHandler);\n messageHandler = null;\n }\n if (domContentLoadedHandler) {\n document.removeEventListener('DOMContentLoaded', domContentLoadedHandler);\n domContentLoadedHandler = null;\n }\n iframe.remove();\n if (frameBlobUrl) {\n URL.revokeObjectURL(frameBlobUrl);\n frameBlobUrl = null;\n }\n };\n\n const setupNewFrame = () => {\n const iframeContainer = document.querySelector(editorSelectorId);\n if (iframeContainer) {\n iframeContainer?.appendChild(iframe);\n\n iframe.addEventListener(\n 'error',\n () => {\n const error = new Error('Failed to setup frame: iframe failed to load');\n onSetupFrameError?.(error);\n },\n { capture: true, once: true },\n );\n\n try {\n frameBlobUrl = setupFrame(iframe, editorLink, styling);\n } catch (error: unknown) {\n if (error instanceof Error) {\n onSetupFrameError?.(error);\n } else {\n onSetupFrameError?.(new Error(`Failed to setup frame: ${error}`));\n }\n }\n }\n };\n\n if (document.readyState === 'complete' || document.readyState === 'interactive') {\n setupNewFrame();\n } else {\n domContentLoadedHandler = () => {\n domContentLoadedHandler = null;\n setupNewFrame();\n };\n document.addEventListener('DOMContentLoaded', domContentLoadedHandler, { once: true });\n }\n\n messageHandler = (event: MessageEvent) => {\n if (event.source !== iframe.contentWindow) {\n return;\n }\n if (event.data?.type === 'iframe-error') {\n const errorData = event.data.error;\n const error = new Error(errorData.message || 'Failed to setup frame: error in iframe');\n onSetupFrameError?.(error);\n }\n };\n\n window.addEventListener('message', messageHandler);\n\n setConnection(\n connectToChild({\n // The iframe to which a connection should be made\n iframe,\n // All the methods that we want to expose to the child should be inside the methods object\n // f.e. stateChange(documentJson)\n methods: {\n actionsChanged: params.onActionsChanged,\n stateChanged: params.onStateChanged,\n documentLoaded: params.onDocumentLoaded,\n authExpired: params.onAuthExpired,\n viewportRequested: params.onViewportRequested,\n selectedFramesContent: params.onSelectedFramesContentChanged,\n selectedFramesLayout: params.onSelectedFramesLayoutChanged,\n allFramesLayout: params.onFramesLayoutChanged,\n selectedLayoutProperties: params.onSelectedLayoutPropertiesChanged,\n openLayoutPropertiesPanel: params.onPageSelectionChanged,\n selectedLayoutUnit: params.onSelectedLayoutUnitChanged,\n scrubberPositionChanged: params.onScrubberPositionChanged,\n frameAnimationsChanged: params.onFrameAnimationsChanged,\n selectedToolChanged: params.onSelectedToolChanged,\n variableListChanged: params.onVariableListChanged,\n undoStackStateChanged: params.onUndoStateChanged,\n selectedLayoutFramesChanged: params.onSelectedLayoutFramesChanged,\n selectedTextStyleChanged: params.onSelectedTextStyleChanged,\n colorsChanged: params.onColorsChanged,\n paragraphStylesChanged: params.onParagraphStylesChanged,\n characterStylesChanged: params.onCharacterStylesChanged,\n fontFamiliesChanged: params.onFontFamiliesChanged,\n selectedLayoutId: params.onSelectedLayoutIdChanged,\n layoutListChanged: params.onLayoutsChanged,\n connectorEvent: params.onConnectorEvent,\n connectorsChanged: params.onConnectorsChanged,\n zoomChanged: params.onZoomChanged,\n pageSnapshotInvalidated: params.onPageSnapshotInvalidated,\n pagesChanged: params.onPagesChanged,\n pageSizeChanged: params.onPageSizeChanged,\n shapeCornerRadiusChanged: params.onShapeCornerRadiusChanged,\n cropActiveFrameIdChanged: params.onCropActiveFrameIdChanged,\n asyncError: params.onAsyncError,\n viewModeChanged: params.onViewModeChanged,\n barcodeValidationChanged: params.onBarcodeValidationChanged,\n selectedPageIdChanged: params.onSelectedPageIdChanged,\n dataSourceIdChanged: params.onDataSourceIdChanged,\n injectedDataChanged: params.onInjectedDataChanged,\n documentIssueListChanged: params.onDocumentIssueListChanged,\n customUndoDataChanged: params.onCustomUndoDataChanged,\n engineEditingModeChanged: params.onEngineEditModeChanged,\n brandKitMediaChanged: params.onBrandKitMediaChanged,\n frameManipulated: params.onCanvasFramesManipulated,\n },\n }),\n );\n\n return teardownFrame;\n};\nexport default Connect;\n"],"names":["connectToChild"],"mappings":";;;AAIO,MAAM,qBAAqB,CAAC,eAAuB;AACtD,QAAM,gBAAgB,IAAI,OAAO,kDAAkD;AACnF,MAAI,OAAO;AACX,MAAI,cAAc,KAAK,UAAU,GAAG;AAChC,WAAO;AAAA,EACX,WAAW,WAAW,QAAQ,aAAa,IAAI,IAAI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AAA,QACjC,sBAAsB,OAAO;AAAA,QAC7B,kBAAkB,OAAO;AAAA,MAAA;AAAA,IAC7B,CACH;AAAA,EAAA;AAGL,SAAO;AACX;;;;"}
|
|
@@ -2,7 +2,7 @@ import { Connection } from 'penpal';
|
|
|
2
2
|
import { Id } from '../types/CommonTypes';
|
|
3
3
|
import { StudioStyling } from '../types/ConfigurationTypes';
|
|
4
4
|
export declare const validateEditorLink: (editorLink: string) => string;
|
|
5
|
-
export declare const setupFrame: (iframe: HTMLIFrameElement, editorLink: string, styling?: StudioStyling) =>
|
|
5
|
+
export declare const setupFrame: (iframe: HTMLIFrameElement, editorLink: string, styling?: StudioStyling) => string;
|
|
6
6
|
interface ConfigParameterTypes {
|
|
7
7
|
onActionsChanged: (state: string) => void;
|
|
8
8
|
onStateChanged: (state: string) => void;
|
|
@@ -51,5 +51,5 @@ interface ConfigParameterTypes {
|
|
|
51
51
|
onBrandKitMediaChanged: (brandKitMedia: string) => void;
|
|
52
52
|
onCanvasFramesManipulated: (frameIds: string) => void;
|
|
53
53
|
}
|
|
54
|
-
declare const Connect: (editorLink: string, params: ConfigParameterTypes, setConnection: (connection: Connection) => void, editorId?: string, styling?: StudioStyling, onSetupFrameError?: (error: Error) => void) => void;
|
|
54
|
+
declare const Connect: (editorLink: string, params: ConfigParameterTypes, setConnection: (connection: Connection) => void, editorId?: string, styling?: StudioStyling, onSetupFrameError?: (error: Error) => void) => () => void;
|
|
55
55
|
export default Connect;
|
|
@@ -16,7 +16,7 @@ const setupFrame = (iframe, editorLink, styling) => {
|
|
|
16
16
|
const stylingJson = JSON.stringify(styling || {});
|
|
17
17
|
const html = `<html>
|
|
18
18
|
<head>
|
|
19
|
-
<base href="
|
|
19
|
+
<base href="${link}" />
|
|
20
20
|
<meta charset="UTF-8"/>
|
|
21
21
|
<!-- use this property to pass the StudioStyling to the engine -->
|
|
22
22
|
<meta name="studio-styling" content='${stylingJson}'>
|
|
@@ -82,20 +82,36 @@ const setupFrame = (iframe, editorLink, styling) => {
|
|
|
82
82
|
<\/script>
|
|
83
83
|
</body>
|
|
84
84
|
</html>`;
|
|
85
|
-
|
|
85
|
+
const blobUrl = URL.createObjectURL(new Blob([html], { type: "text/html" }));
|
|
86
|
+
iframe.setAttribute("src", blobUrl);
|
|
87
|
+
return blobUrl;
|
|
86
88
|
};
|
|
87
|
-
let messageHandler = null;
|
|
88
89
|
const Connect = (editorLink, params, setConnection, editorId = "chili-editor", styling, onSetupFrameError) => {
|
|
89
|
-
if (messageHandler) {
|
|
90
|
-
window.removeEventListener("message", messageHandler);
|
|
91
|
-
}
|
|
92
90
|
const editorSelectorId = `#${editorId}`;
|
|
93
91
|
const iframe = document.createElement("iframe");
|
|
94
|
-
iframe.setAttribute("
|
|
92
|
+
iframe.setAttribute("src", "about:blank");
|
|
95
93
|
iframe.setAttribute("title", "Chili-Editor");
|
|
96
94
|
iframe.setAttribute("style", "width: 100%; height: 100%;");
|
|
97
95
|
iframe.setAttribute("frameBorder", "0");
|
|
98
96
|
iframe.setAttribute("referrerpolicy", "origin");
|
|
97
|
+
let messageHandler = null;
|
|
98
|
+
let domContentLoadedHandler = null;
|
|
99
|
+
let frameBlobUrl = null;
|
|
100
|
+
const teardownFrame = () => {
|
|
101
|
+
if (messageHandler) {
|
|
102
|
+
window.removeEventListener("message", messageHandler);
|
|
103
|
+
messageHandler = null;
|
|
104
|
+
}
|
|
105
|
+
if (domContentLoadedHandler) {
|
|
106
|
+
document.removeEventListener("DOMContentLoaded", domContentLoadedHandler);
|
|
107
|
+
domContentLoadedHandler = null;
|
|
108
|
+
}
|
|
109
|
+
iframe.remove();
|
|
110
|
+
if (frameBlobUrl) {
|
|
111
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
112
|
+
frameBlobUrl = null;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
99
115
|
const setupNewFrame = () => {
|
|
100
116
|
const iframeContainer = document.querySelector(editorSelectorId);
|
|
101
117
|
if (iframeContainer) {
|
|
@@ -109,7 +125,7 @@ const Connect = (editorLink, params, setConnection, editorId = "chili-editor", s
|
|
|
109
125
|
{ capture: true, once: true }
|
|
110
126
|
);
|
|
111
127
|
try {
|
|
112
|
-
setupFrame(iframe, editorLink, styling);
|
|
128
|
+
frameBlobUrl = setupFrame(iframe, editorLink, styling);
|
|
113
129
|
} catch (error) {
|
|
114
130
|
if (error instanceof Error) {
|
|
115
131
|
onSetupFrameError == null ? void 0 : onSetupFrameError(error);
|
|
@@ -122,9 +138,11 @@ const Connect = (editorLink, params, setConnection, editorId = "chili-editor", s
|
|
|
122
138
|
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
123
139
|
setupNewFrame();
|
|
124
140
|
} else {
|
|
125
|
-
|
|
141
|
+
domContentLoadedHandler = () => {
|
|
142
|
+
domContentLoadedHandler = null;
|
|
126
143
|
setupNewFrame();
|
|
127
|
-
}
|
|
144
|
+
};
|
|
145
|
+
document.addEventListener("DOMContentLoaded", domContentLoadedHandler, { once: true });
|
|
128
146
|
}
|
|
129
147
|
messageHandler = (event) => {
|
|
130
148
|
var _a;
|
|
@@ -191,6 +209,7 @@ const Connect = (editorLink, params, setConnection, editorId = "chili-editor", s
|
|
|
191
209
|
}
|
|
192
210
|
})
|
|
193
211
|
);
|
|
212
|
+
return teardownFrame;
|
|
194
213
|
};
|
|
195
214
|
export {
|
|
196
215
|
Connect as default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connector.es.js","sources":["../../../src/interactions/Connector.ts"],"sourcesContent":["import { Connection, connectToChild } from 'penpal';\nimport { Id } from '../types/CommonTypes';\nimport { StudioStyling } from '../types/ConfigurationTypes';\n\nexport const validateEditorLink = (editorLink: string) => {\n const linkValidator = new RegExp(/^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)+[\\w]+\\/$/);\n let link = '';\n if (linkValidator.test(editorLink)) {\n link = editorLink;\n } else if (editorLink.indexOf('/index.html') > -1) {\n link = editorLink.replace('/index.html', '/');\n } else if (editorLink.charAt(-1) !== '/') {\n link = `${editorLink}/`;\n }\n return link;\n};\n\nexport const setupFrame = (iframe: HTMLIFrameElement, editorLink: string, styling?: StudioStyling) => {\n const link = validateEditorLink(editorLink);\n const stylingJson = JSON.stringify(styling || {});\n const html = `<html>\n <head>\n <base href=\"/\" />\n <meta charset=\"UTF-8\"/>\n <!-- use this property to pass the StudioStyling to the engine -->\n <meta name=\"studio-styling\" content='${stylingJson}'>\n </head>\n <body>\n <script>\n const handleIframeError = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: {\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error?.toString(),\n },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n const handleUnhandledRejection = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: { message: event.reason?.toString() || 'Unhandled promise rejection' },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n window.addEventListener('error', handleIframeError);\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\n </script>\n <script src=\"${link}init.js\" async></script>\n <script src=\"${link}flutter_bootstrap.js\"></script>\n <script>\n try {\n if(!window?.initializeStudioEngine){\n throw new Error('Failed to initialize studio engine: initializeStudioEngine not found');\n }\n initializeStudioEngine({\n assetBase: '${link}',\n });\n } catch(error) {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({\n type: 'iframe-error',\n error: {\n message: error?.message || 'Error initializing studio engine',\n error: error?.toString()\n }\n }, window.location.ancestorOrigins[0] || window.location.origin);\n }\n throw error;\n } finally {\n window.removeEventListener('error', handleIframeError);\n window.removeEventListener('unhandledrejection', handleUnhandledRejection);\n }\n </script>\n </body>\n</html>`;\n\n // Set the iframe's content using DOM manipulation\n // eslint-disable-next-line no-param-reassign\n iframe.srcdoc = html;\n};\n\ninterface ConfigParameterTypes {\n onActionsChanged: (state: string) => void;\n onStateChanged: (state: string) => void;\n onAuthExpired: (authRefreshRequest: string) => Promise<string | null>;\n onViewportRequested: () => string | null;\n onDocumentLoaded: () => void;\n onSelectedFramesContentChanged: (state: string) => void;\n onSelectedFramesLayoutChanged: (state: string) => void;\n onFramesLayoutChanged: (state: string) => void;\n onSelectedLayoutPropertiesChanged: (state: string) => void;\n onSelectedLayoutUnitChanged: (state: string) => void;\n /**\n * @deprecated use `onSelectedPageIdChanged` instead\n */\n onPageSelectionChanged: (id: Id) => void;\n onScrubberPositionChanged: (state: string) => void;\n onFrameAnimationsChanged: (state: string) => void;\n onVariableListChanged: (state: string) => void;\n onSelectedToolChanged: (state: string) => void;\n onUndoStateChanged: (state: string) => void;\n onSelectedLayoutFramesChanged: (state: string) => void;\n onSelectedTextStyleChanged: (styles: string) => void;\n onColorsChanged: (colors: string) => void;\n onParagraphStylesChanged: (paragraphStyles: string) => void;\n onCharacterStylesChanged: (characterStyles: string) => void;\n onFontFamiliesChanged: (fonts: string) => void;\n onSelectedLayoutIdChanged: (id: string) => void;\n onLayoutsChanged: (layouts: string) => void;\n onConnectorEvent: (state: string) => void;\n onConnectorsChanged: (state: string) => void;\n onZoomChanged: (scaleFactor: string) => void;\n onSelectedPageIdChanged: (pageId: string) => void;\n onPagesChanged: (pages: string) => void;\n onPageSnapshotInvalidated: (pageId: Id) => void;\n onPageSizeChanged: (scaleFactor: string) => void;\n onShapeCornerRadiusChanged: (cornerRadius: string) => void;\n onCropActiveFrameIdChanged: (id?: Id) => void;\n onAsyncError: (asyncError: string) => void;\n onViewModeChanged: (viewMode: string) => void;\n onBarcodeValidationChanged: (validationResults: string) => void;\n onDataSourceIdChanged: (connectorId?: Id) => void;\n onInjectedDataChanged: (variableId: Id) => void;\n onDocumentIssueListChanged: (documentIssues: string) => void;\n onCustomUndoDataChanged: (customData: string) => void;\n onEngineEditModeChanged: (engineEditMode: string) => void;\n onBrandKitMediaChanged: (brandKitMedia: string) => void;\n onCanvasFramesManipulated: (frameIds: string) => void;\n}\n\nlet messageHandler: ((event: MessageEvent) => void) | null = null;\n\nconst Connect = (\n editorLink: string,\n params: ConfigParameterTypes,\n setConnection: (connection: Connection) => void,\n editorId = 'chili-editor',\n styling?: StudioStyling,\n onSetupFrameError?: (error: Error) => void,\n) => {\n if (messageHandler) {\n window.removeEventListener('message', messageHandler);\n }\n const editorSelectorId = `#${editorId}`;\n const iframe = document.createElement('iframe');\n iframe.setAttribute('srcdoc', ' ');\n iframe.setAttribute('title', 'Chili-Editor');\n iframe.setAttribute('style', 'width: 100%; height: 100%;');\n iframe.setAttribute('frameBorder', '0');\n iframe.setAttribute('referrerpolicy', 'origin');\n const setupNewFrame = () => {\n const iframeContainer = document.querySelector(editorSelectorId);\n if (iframeContainer) {\n iframeContainer?.appendChild(iframe);\n\n iframe.addEventListener(\n 'error',\n () => {\n const error = new Error('Failed to setup frame: iframe failed to load');\n onSetupFrameError?.(error);\n },\n { capture: true, once: true },\n );\n\n try {\n setupFrame(iframe, editorLink, styling);\n } catch (error: unknown) {\n if (error instanceof Error) {\n onSetupFrameError?.(error);\n } else {\n onSetupFrameError?.(new Error(`Failed to setup frame: ${error}`));\n }\n }\n }\n };\n\n if (document.readyState === 'complete' || document.readyState === 'interactive') {\n setupNewFrame();\n } else {\n document.addEventListener('DOMContentLoaded', () => {\n setupNewFrame();\n });\n }\n\n messageHandler = (event: MessageEvent) => {\n if (event.source !== iframe.contentWindow) {\n return;\n }\n if (event.data?.type === 'iframe-error') {\n const errorData = event.data.error;\n const error = new Error(errorData.message || 'Failed to setup frame: error in iframe');\n onSetupFrameError?.(error);\n }\n };\n\n window.addEventListener('message', messageHandler);\n\n setConnection(\n connectToChild({\n // The iframe to which a connection should be made\n iframe,\n // All the methods that we want to expose to the child should be inside the methods object\n // f.e. stateChange(documentJson)\n methods: {\n actionsChanged: params.onActionsChanged,\n stateChanged: params.onStateChanged,\n documentLoaded: params.onDocumentLoaded,\n authExpired: params.onAuthExpired,\n viewportRequested: params.onViewportRequested,\n selectedFramesContent: params.onSelectedFramesContentChanged,\n selectedFramesLayout: params.onSelectedFramesLayoutChanged,\n allFramesLayout: params.onFramesLayoutChanged,\n selectedLayoutProperties: params.onSelectedLayoutPropertiesChanged,\n openLayoutPropertiesPanel: params.onPageSelectionChanged,\n selectedLayoutUnit: params.onSelectedLayoutUnitChanged,\n scrubberPositionChanged: params.onScrubberPositionChanged,\n frameAnimationsChanged: params.onFrameAnimationsChanged,\n selectedToolChanged: params.onSelectedToolChanged,\n variableListChanged: params.onVariableListChanged,\n undoStackStateChanged: params.onUndoStateChanged,\n selectedLayoutFramesChanged: params.onSelectedLayoutFramesChanged,\n selectedTextStyleChanged: params.onSelectedTextStyleChanged,\n colorsChanged: params.onColorsChanged,\n paragraphStylesChanged: params.onParagraphStylesChanged,\n characterStylesChanged: params.onCharacterStylesChanged,\n fontFamiliesChanged: params.onFontFamiliesChanged,\n selectedLayoutId: params.onSelectedLayoutIdChanged,\n layoutListChanged: params.onLayoutsChanged,\n connectorEvent: params.onConnectorEvent,\n connectorsChanged: params.onConnectorsChanged,\n zoomChanged: params.onZoomChanged,\n pageSnapshotInvalidated: params.onPageSnapshotInvalidated,\n pagesChanged: params.onPagesChanged,\n pageSizeChanged: params.onPageSizeChanged,\n shapeCornerRadiusChanged: params.onShapeCornerRadiusChanged,\n cropActiveFrameIdChanged: params.onCropActiveFrameIdChanged,\n asyncError: params.onAsyncError,\n viewModeChanged: params.onViewModeChanged,\n barcodeValidationChanged: params.onBarcodeValidationChanged,\n selectedPageIdChanged: params.onSelectedPageIdChanged,\n dataSourceIdChanged: params.onDataSourceIdChanged,\n injectedDataChanged: params.onInjectedDataChanged,\n documentIssueListChanged: params.onDocumentIssueListChanged,\n customUndoDataChanged: params.onCustomUndoDataChanged,\n engineEditingModeChanged: params.onEngineEditModeChanged,\n brandKitMediaChanged: params.onBrandKitMediaChanged,\n frameManipulated: params.onCanvasFramesManipulated,\n },\n }),\n );\n};\nexport default Connect;\n"],"names":[],"mappings":";AAIO,MA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AC1B,uBAAuB,OAAO;AAAA,QAC9B,sBAAsB,OAAO;AAAA,QAC7B,iBAAiB,OAAO;AAAA,QACxB,0BAA0B,OAAO;AAAA,QACjC,2BAA2B,OAAO;AAAA,QAClC,oBAAoB,OAAO;AAAA,QAC3B,yBAAyB,OAAO;AAAA,QAChC,wBAAwB,OAAO;AAAA,QAC/B,qBAAqB,OAAO;AAAA,QAC5B,qBAAqB,OAAO;AAAA,QAC5B,uBAAuB,OAAO;AAAA,QAC9B,6BAA6B,OAAO;AAAA,QACpC,0BAA0B,OAAO;AAAA,QACjC,eAAe,OAAO;AAAA,QACtB,wBAAwB,OAAO;AAAA,QAC/B,wBAAwB,OAAO;AAAA,QAC/B,qBAAqB,OAAO;AAAA,QAC5B,kBAAkB,OAAO;AAAA,QACzB,mBAAmB,OAAO;AAAA,QAC1B,gBAAgB,OAAO;AAAA,QACvB,mBAAmB,OAAO;AAAA,QAC1B,aAAa,OAAO;AAAA,QACpB,yBAAyB,OAAO;AAAA,QAChC,cAAc,OAAO;AAAA,QACrB,iBAAiB,OAAO;AAAA,QACxB,0BAA0B,OAAO;AAAA,QACjC,0BAA0B,OAAO;AAAA,QACjC,YAAY,OAAO;AAAA,QACnB,iBAAiB,OAAO;AAAA,QACxB,0BAA0B,OAAO;AAAA,QACjC,uBAAuB,OAAO;AAAA,QAC9B,qBAAqB,OAAO;AAAA,QAC5B,qBAAqB,OAAO;AAAA,QAC5B,0BAA0B,OAAO;AAAA,QACjC,uBAAuB,OAAO;AAAA,QAC9B,0BAA0B,OAAO;AAAA,QACjC,sBAAsB,OAAO;AAAA,QAC7B,kBAAkB,OAAO;AAAA,MAAA;AAAA,IAC7B,CACH;AAAA,EAAA;AAET;"}
|
|
1
|
+
{"version":3,"file":"Connector.es.js","sources":["../../../src/interactions/Connector.ts"],"sourcesContent":["import { Connection, connectToChild } from 'penpal';\nimport { Id } from '../types/CommonTypes';\nimport { StudioStyling } from '../types/ConfigurationTypes';\n\nexport const validateEditorLink = (editorLink: string) => {\n const linkValidator = new RegExp(/^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)+[\\w]+\\/$/);\n let link = '';\n if (linkValidator.test(editorLink)) {\n link = editorLink;\n } else if (editorLink.indexOf('/index.html') > -1) {\n link = editorLink.replace('/index.html', '/');\n } else if (editorLink.charAt(-1) !== '/') {\n link = `${editorLink}/`;\n }\n return link;\n};\n\nexport const setupFrame = (iframe: HTMLIFrameElement, editorLink: string, styling?: StudioStyling) => {\n const link = validateEditorLink(editorLink);\n const stylingJson = JSON.stringify(styling || {});\n const html = `<html>\n <head>\n <base href=\"${link}\" />\n <meta charset=\"UTF-8\"/>\n <!-- use this property to pass the StudioStyling to the engine -->\n <meta name=\"studio-styling\" content='${stylingJson}'>\n </head>\n <body>\n <script>\n const handleIframeError = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: {\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error?.toString(),\n },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n const handleUnhandledRejection = (event) => {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage(\n {\n type: 'iframe-error',\n error: { message: event.reason?.toString() || 'Unhandled promise rejection' },\n },\n window.location.ancestorOrigins[0] || window.location.origin,\n );\n }\n };\n window.addEventListener('error', handleIframeError);\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\n </script>\n <script src=\"${link}init.js\" async></script>\n <script src=\"${link}flutter_bootstrap.js\"></script>\n <script>\n try {\n if(!window?.initializeStudioEngine){\n throw new Error('Failed to initialize studio engine: initializeStudioEngine not found');\n }\n initializeStudioEngine({\n assetBase: '${link}',\n });\n } catch(error) {\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({\n type: 'iframe-error',\n error: {\n message: error?.message || 'Error initializing studio engine',\n error: error?.toString()\n }\n }, window.location.ancestorOrigins[0] || window.location.origin);\n }\n throw error;\n } finally {\n window.removeEventListener('error', handleIframeError);\n window.removeEventListener('unhandledrejection', handleUnhandledRejection);\n }\n </script>\n </body>\n</html>`;\n\n const blobUrl = URL.createObjectURL(new Blob([html], { type: 'text/html' }));\n iframe.setAttribute('src', blobUrl);\n return blobUrl;\n};\n\ninterface ConfigParameterTypes {\n onActionsChanged: (state: string) => void;\n onStateChanged: (state: string) => void;\n onAuthExpired: (authRefreshRequest: string) => Promise<string | null>;\n onViewportRequested: () => string | null;\n onDocumentLoaded: () => void;\n onSelectedFramesContentChanged: (state: string) => void;\n onSelectedFramesLayoutChanged: (state: string) => void;\n onFramesLayoutChanged: (state: string) => void;\n onSelectedLayoutPropertiesChanged: (state: string) => void;\n onSelectedLayoutUnitChanged: (state: string) => void;\n /**\n * @deprecated use `onSelectedPageIdChanged` instead\n */\n onPageSelectionChanged: (id: Id) => void;\n onScrubberPositionChanged: (state: string) => void;\n onFrameAnimationsChanged: (state: string) => void;\n onVariableListChanged: (state: string) => void;\n onSelectedToolChanged: (state: string) => void;\n onUndoStateChanged: (state: string) => void;\n onSelectedLayoutFramesChanged: (state: string) => void;\n onSelectedTextStyleChanged: (styles: string) => void;\n onColorsChanged: (colors: string) => void;\n onParagraphStylesChanged: (paragraphStyles: string) => void;\n onCharacterStylesChanged: (characterStyles: string) => void;\n onFontFamiliesChanged: (fonts: string) => void;\n onSelectedLayoutIdChanged: (id: string) => void;\n onLayoutsChanged: (layouts: string) => void;\n onConnectorEvent: (state: string) => void;\n onConnectorsChanged: (state: string) => void;\n onZoomChanged: (scaleFactor: string) => void;\n onSelectedPageIdChanged: (pageId: string) => void;\n onPagesChanged: (pages: string) => void;\n onPageSnapshotInvalidated: (pageId: Id) => void;\n onPageSizeChanged: (scaleFactor: string) => void;\n onShapeCornerRadiusChanged: (cornerRadius: string) => void;\n onCropActiveFrameIdChanged: (id?: Id) => void;\n onAsyncError: (asyncError: string) => void;\n onViewModeChanged: (viewMode: string) => void;\n onBarcodeValidationChanged: (validationResults: string) => void;\n onDataSourceIdChanged: (connectorId?: Id) => void;\n onInjectedDataChanged: (variableId: Id) => void;\n onDocumentIssueListChanged: (documentIssues: string) => void;\n onCustomUndoDataChanged: (customData: string) => void;\n onEngineEditModeChanged: (engineEditMode: string) => void;\n onBrandKitMediaChanged: (brandKitMedia: string) => void;\n onCanvasFramesManipulated: (frameIds: string) => void;\n}\n\nconst Connect = (\n editorLink: string,\n params: ConfigParameterTypes,\n setConnection: (connection: Connection) => void,\n editorId = 'chili-editor',\n styling?: StudioStyling,\n onSetupFrameError?: (error: Error) => void,\n) => {\n const editorSelectorId = `#${editorId}`;\n const iframe = document.createElement('iframe');\n iframe.setAttribute('src', 'about:blank');\n iframe.setAttribute('title', 'Chili-Editor');\n iframe.setAttribute('style', 'width: 100%; height: 100%;');\n iframe.setAttribute('frameBorder', '0');\n iframe.setAttribute('referrerpolicy', 'origin');\n\n // Everything this call attaches outside of the penpal connection is tracked per\n // invocation, so releasing one engine frame can never tear down the frame another\n // SDK instance is still using. The `message` listener closes over the iframe: as\n // long as that listener stays registered on `window`, the iframe element - and with\n // it the entire engine realm (Dart heap, CanvasKit and QuickJS WASM memory) - stays\n // reachable and can never be collected, even when the consumer has dropped every\n // reference of its own.\n let messageHandler: ((event: MessageEvent) => void) | null = null;\n let domContentLoadedHandler: (() => void) | null = null;\n let frameBlobUrl: string | null = null;\n\n /**\n * Releases the iframe and listeners this `Connect` call attached. Safe to call\n * more than once, and leaves frames of other `Connect` calls untouched.\n */\n const teardownFrame = () => {\n if (messageHandler) {\n window.removeEventListener('message', messageHandler);\n messageHandler = null;\n }\n if (domContentLoadedHandler) {\n document.removeEventListener('DOMContentLoaded', domContentLoadedHandler);\n domContentLoadedHandler = null;\n }\n iframe.remove();\n if (frameBlobUrl) {\n URL.revokeObjectURL(frameBlobUrl);\n frameBlobUrl = null;\n }\n };\n\n const setupNewFrame = () => {\n const iframeContainer = document.querySelector(editorSelectorId);\n if (iframeContainer) {\n iframeContainer?.appendChild(iframe);\n\n iframe.addEventListener(\n 'error',\n () => {\n const error = new Error('Failed to setup frame: iframe failed to load');\n onSetupFrameError?.(error);\n },\n { capture: true, once: true },\n );\n\n try {\n frameBlobUrl = setupFrame(iframe, editorLink, styling);\n } catch (error: unknown) {\n if (error instanceof Error) {\n onSetupFrameError?.(error);\n } else {\n onSetupFrameError?.(new Error(`Failed to setup frame: ${error}`));\n }\n }\n }\n };\n\n if (document.readyState === 'complete' || document.readyState === 'interactive') {\n setupNewFrame();\n } else {\n domContentLoadedHandler = () => {\n domContentLoadedHandler = null;\n setupNewFrame();\n };\n document.addEventListener('DOMContentLoaded', domContentLoadedHandler, { once: true });\n }\n\n messageHandler = (event: MessageEvent) => {\n if (event.source !== iframe.contentWindow) {\n return;\n }\n if (event.data?.type === 'iframe-error') {\n const errorData = event.data.error;\n const error = new Error(errorData.message || 'Failed to setup frame: error in iframe');\n onSetupFrameError?.(error);\n }\n };\n\n window.addEventListener('message', messageHandler);\n\n setConnection(\n connectToChild({\n // The iframe to which a connection should be made\n iframe,\n // All the methods that we want to expose to the child should be inside the methods object\n // f.e. stateChange(documentJson)\n methods: {\n actionsChanged: params.onActionsChanged,\n stateChanged: params.onStateChanged,\n documentLoaded: params.onDocumentLoaded,\n authExpired: params.onAuthExpired,\n viewportRequested: params.onViewportRequested,\n selectedFramesContent: params.onSelectedFramesContentChanged,\n selectedFramesLayout: params.onSelectedFramesLayoutChanged,\n allFramesLayout: params.onFramesLayoutChanged,\n selectedLayoutProperties: params.onSelectedLayoutPropertiesChanged,\n openLayoutPropertiesPanel: params.onPageSelectionChanged,\n selectedLayoutUnit: params.onSelectedLayoutUnitChanged,\n scrubberPositionChanged: params.onScrubberPositionChanged,\n frameAnimationsChanged: params.onFrameAnimationsChanged,\n selectedToolChanged: params.onSelectedToolChanged,\n variableListChanged: params.onVariableListChanged,\n undoStackStateChanged: params.onUndoStateChanged,\n selectedLayoutFramesChanged: params.onSelectedLayoutFramesChanged,\n selectedTextStyleChanged: params.onSelectedTextStyleChanged,\n colorsChanged: params.onColorsChanged,\n paragraphStylesChanged: params.onParagraphStylesChanged,\n characterStylesChanged: params.onCharacterStylesChanged,\n fontFamiliesChanged: params.onFontFamiliesChanged,\n selectedLayoutId: params.onSelectedLayoutIdChanged,\n layoutListChanged: params.onLayoutsChanged,\n connectorEvent: params.onConnectorEvent,\n connectorsChanged: params.onConnectorsChanged,\n zoomChanged: params.onZoomChanged,\n pageSnapshotInvalidated: params.onPageSnapshotInvalidated,\n pagesChanged: params.onPagesChanged,\n pageSizeChanged: params.onPageSizeChanged,\n shapeCornerRadiusChanged: params.onShapeCornerRadiusChanged,\n cropActiveFrameIdChanged: params.onCropActiveFrameIdChanged,\n asyncError: params.onAsyncError,\n viewModeChanged: params.onViewModeChanged,\n barcodeValidationChanged: params.onBarcodeValidationChanged,\n selectedPageIdChanged: params.onSelectedPageIdChanged,\n dataSourceIdChanged: params.onDataSourceIdChanged,\n injectedDataChanged: params.onInjectedDataChanged,\n documentIssueListChanged: params.onDocumentIssueListChanged,\n customUndoDataChanged: params.onCustomUndoDataChanged,\n engineEditingModeChanged: params.onEngineEditModeChanged,\n brandKitMediaChanged: params.onBrandKitMediaChanged,\n frameManipulated: params.onCanvasFramesManipulated,\n },\n }),\n );\n\n return teardownFrame;\n};\nexport default Connect;\n"],"names":[],"mappings":";AAIO,MAAM,qBAAqB,CAAC,eAAuB;AACtD,QAAM,gBAAgB,IAAI,OAAO,kDAAkD;AACnF,MAAI,OAAO;AACX,MAAI,cAAc,KAAK,UAAU,GAAG;AAChC,WAAO;AAAA,EACX,WAAW,WAAW,QAAQ,aAAa,IAAI,IAAI;AAC/C,WAAO,WAAW,QAAQ,eAAe,GAAG;AAAA,EAChD,WAAW,WAAW,OAAO,EAAE,MAAM,KAAK;AACtC,WAAO,GAAG,UAAU;AAAA,EACxB;AACA,SAAO;AACX;AAEO,MAAM,aAAa,CAAC,QAA2B,YAAoB,YAA4B;AAClG,QAAM,OAAO,mBAAmB,UAAU;AAC1C,QAAM,cAAc,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;AAAA,QACpB,mBAAmB,OAAO;AAAA,QAC1B,uBAAuB,OAAO;AAAA,QAC9B,sBAAsB,OAAO;AAAA,QAC7B,iBAAiB,OAAO;AAAA,QACxB,0BAA0B,OAAO;AAAA,QACjC,2BAA2B,OAAO;AAAA,QAClC,oBAAoB,OAAO;AAAA,QAC3B,yBAAyB,OAAO;AAAA,QAChC,wBAAwB,OAAO;AAAA,QAC/B,qBAAqB,OAAO;AAAA,QAC5B,qBAAqB,OAAO;AAAA,QAC5B,uBAAuB,OAAO;AAAA,QAC9B,6BAA6B,OAAO;AAAA,QACpC,0BAA0B,OAAO;AAAA,QACjC,eAAe,OAAO;AAAA,QACtB,wBAAwB,OAAO;AAAA,QAC/B,wBAAwB,OAAO;AAAA,QAC/B,qBAAqB,OAAO;AAAA,QAC5B,kBAAkB,OAAO;AAAA,QACzB,mBAAmB,OAAO;AAAA,QAC1B,gBAAgB,OAAO;AAAA,QACvB,mBAAmB,OAAO;AAAA,QAC1B,aAAa,OAAO;AAAA,QACpB,yBAAyB,OAAO;AAAA,QAChC,cAAc,OAAO;AAAA,QACrB,iBAAiB,OAAO;AAAA,QACxB,0BAA0B,OAAO;AAAA,QACjC,0BAA0B,OAAO;AAAA,QACjC,YAAY,OAAO;AAAA,QACnB,iBAAiB,OAAO;AAAA,QACxB,0BAA0B,OAAO;AAAA,QACjC,uBAAuB,OAAO;AAAA,QAC9B,qBAAqB,OAAO;AAAA,QAC5B,qBAAqB,OAAO;AAAA,QAC5B,0BAA0B,OAAO;AAAA,QACjC,uBAAuB,OAAO;AAAA,QAC9B,0BAA0B,OAAO;AAAA,QACjC,sBAAsB,OAAO;AAAA,QAC7B,kBAAkB,OAAO;AAAA,MAAA;AAAA,IAC7B,CACH;AAAA,EAAA;AAGL,SAAO;AACX;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageController.cjs.js","sources":["../../../../src/next/controllers/PageController.ts"],"sourcesContent":["import { EditorAPI, EditorRawAPI } from '../../types/CommonTypes';\nimport { getEditorResponseData } from '../../utils/EditorResponseData';\nimport { CallSender } from 'penpal';\n\n/**\n * The PageController is responsible for all communication regarding Pages.\n * Methods inside this controller can be called by `window.SDK.page.{method-name}`\n */\nexport class PageController {\n /**\n * @ignore\n */\n #editorAPI: EditorAPI;\n\n /**\n * @ignore\n */\n #blobAPI: EditorRawAPI;\n\n /**\n * @ignore\n */\n constructor(editorAPI: EditorAPI) {\n this.#editorAPI = editorAPI;\n this.#blobAPI = editorAPI as CallSender as EditorRawAPI;\n }\n\n /**\n * This method will set the width of all pages to a specific value.\n * This only works if the document is a project.\n * @param width the string value that will be calculated (f.e. 1+1 will result in 2) The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setWidth = async (width: string) => {\n const res = await this.#editorAPI;\n return res.setPageWidth(width).then((result) => getEditorResponseData<null>(result));\n };\n\n /**\n * This method will set the height of all pages to a specific value.\n * This only works if the document is a project.\n * @param height the string value that will be calculated (f.e. 1+1 will result in 2). The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setHeight = async (height: string) => {\n const res = await this.#editorAPI;\n return res.setPageHeight(height).then((result) => getEditorResponseData<null>(result));\n };\n}\n"],"names":["getEditorResponseData"],"mappings":";;;;;;;;;;;AAQO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"PageController.cjs.js","sources":["../../../../src/next/controllers/PageController.ts"],"sourcesContent":["import { EditorAPI, EditorRawAPI } from '../../types/CommonTypes';\nimport { getEditorResponseData } from '../../utils/EditorResponseData';\nimport { CallSender } from 'penpal';\n\n/**\n * The PageController is responsible for all communication regarding Pages.\n * Methods inside this controller can be called by `window.SDK.page.{method-name}`\n */\nexport class PageController {\n /**\n * @ignore\n */\n #editorAPI: EditorAPI;\n\n /**\n * @ignore\n */\n // eslint-disable-next-line no-unused-private-class-members\n #blobAPI: EditorRawAPI;\n\n /**\n * @ignore\n */\n constructor(editorAPI: EditorAPI) {\n this.#editorAPI = editorAPI;\n this.#blobAPI = editorAPI as CallSender as EditorRawAPI;\n }\n\n /**\n * This method will set the width of all pages to a specific value.\n * This only works if the document is a project.\n * @param width the string value that will be calculated (f.e. 1+1 will result in 2) The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setWidth = async (width: string) => {\n const res = await this.#editorAPI;\n return res.setPageWidth(width).then((result) => getEditorResponseData<null>(result));\n };\n\n /**\n * This method will set the height of all pages to a specific value.\n * This only works if the document is a project.\n * @param height the string value that will be calculated (f.e. 1+1 will result in 2). The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setHeight = async (height: string) => {\n const res = await this.#editorAPI;\n return res.setPageHeight(height).then((result) => getEditorResponseData<null>(result));\n };\n}\n"],"names":["getEditorResponseData"],"mappings":";;;;;;;;;;;AAQO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA,EAexB,YAAY,WAAsB;AAXlC;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAgBA,SAAA,WAAW,OAAO,UAAkB;AAChC,YAAM,MAAM,MAAM,mBAAK;AACvB,aAAO,IAAI,aAAa,KAAK,EAAE,KAAK,CAAC,WAAWA,yCAA4B,MAAM,CAAC;AAAA,IACvF;AAQA,SAAA,YAAY,OAAO,WAAmB;AAClC,YAAM,MAAM,MAAM,mBAAK;AACvB,aAAO,IAAI,cAAc,MAAM,EAAE,KAAK,CAAC,WAAWA,yCAA4B,MAAM,CAAC;AAAA,IACzF;AAxBI,uBAAK,YAAa;AAClB,uBAAK,UAAW;AAAA,EACpB;AAuBJ;AArCI;AAMA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageController.es.js","sources":["../../../../src/next/controllers/PageController.ts"],"sourcesContent":["import { EditorAPI, EditorRawAPI } from '../../types/CommonTypes';\nimport { getEditorResponseData } from '../../utils/EditorResponseData';\nimport { CallSender } from 'penpal';\n\n/**\n * The PageController is responsible for all communication regarding Pages.\n * Methods inside this controller can be called by `window.SDK.page.{method-name}`\n */\nexport class PageController {\n /**\n * @ignore\n */\n #editorAPI: EditorAPI;\n\n /**\n * @ignore\n */\n #blobAPI: EditorRawAPI;\n\n /**\n * @ignore\n */\n constructor(editorAPI: EditorAPI) {\n this.#editorAPI = editorAPI;\n this.#blobAPI = editorAPI as CallSender as EditorRawAPI;\n }\n\n /**\n * This method will set the width of all pages to a specific value.\n * This only works if the document is a project.\n * @param width the string value that will be calculated (f.e. 1+1 will result in 2) The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setWidth = async (width: string) => {\n const res = await this.#editorAPI;\n return res.setPageWidth(width).then((result) => getEditorResponseData<null>(result));\n };\n\n /**\n * This method will set the height of all pages to a specific value.\n * This only works if the document is a project.\n * @param height the string value that will be calculated (f.e. 1+1 will result in 2). The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setHeight = async (height: string) => {\n const res = await this.#editorAPI;\n return res.setPageHeight(height).then((result) => getEditorResponseData<null>(result));\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAQO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"PageController.es.js","sources":["../../../../src/next/controllers/PageController.ts"],"sourcesContent":["import { EditorAPI, EditorRawAPI } from '../../types/CommonTypes';\nimport { getEditorResponseData } from '../../utils/EditorResponseData';\nimport { CallSender } from 'penpal';\n\n/**\n * The PageController is responsible for all communication regarding Pages.\n * Methods inside this controller can be called by `window.SDK.page.{method-name}`\n */\nexport class PageController {\n /**\n * @ignore\n */\n #editorAPI: EditorAPI;\n\n /**\n * @ignore\n */\n // eslint-disable-next-line no-unused-private-class-members\n #blobAPI: EditorRawAPI;\n\n /**\n * @ignore\n */\n constructor(editorAPI: EditorAPI) {\n this.#editorAPI = editorAPI;\n this.#blobAPI = editorAPI as CallSender as EditorRawAPI;\n }\n\n /**\n * This method will set the width of all pages to a specific value.\n * This only works if the document is a project.\n * @param width the string value that will be calculated (f.e. 1+1 will result in 2) The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setWidth = async (width: string) => {\n const res = await this.#editorAPI;\n return res.setPageWidth(width).then((result) => getEditorResponseData<null>(result));\n };\n\n /**\n * This method will set the height of all pages to a specific value.\n * This only works if the document is a project.\n * @param height the string value that will be calculated (f.e. 1+1 will result in 2). The default unit is in the current layout unit (e.g. px, mm, in)\n * @returns\n */\n setHeight = async (height: string) => {\n const res = await this.#editorAPI;\n return res.setPageHeight(height).then((result) => getEditorResponseData<null>(result));\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAQO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA,EAexB,YAAY,WAAsB;AAXlC;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAgBA,SAAA,WAAW,OAAO,UAAkB;AAChC,YAAM,MAAM,MAAM,mBAAK;AACvB,aAAO,IAAI,aAAa,KAAK,EAAE,KAAK,CAAC,WAAW,sBAA4B,MAAM,CAAC;AAAA,IACvF;AAQA,SAAA,YAAY,OAAO,WAAmB;AAClC,YAAM,MAAM,MAAM,mBAAK;AACvB,aAAO,IAAI,cAAc,MAAM,EAAE,KAAK,CAAC,WAAW,sBAA4B,MAAM,CAAC;AAAA,IACzF;AAxBI,uBAAK,YAAa;AAClB,uBAAK,UAAW;AAAA,EACpB;AAuBJ;AArCI;AAMA;"}
|
package/lib/src/sdk.cjs.js
CHANGED
|
@@ -47,7 +47,6 @@ const MethodInstrumentation = require("./utils/MethodInstrumentation.cjs.js");
|
|
|
47
47
|
const SdkEvents = require("./utils/SdkEvents.cjs.js");
|
|
48
48
|
const ENGINE_DOMAIN = "studio-cdn.chiligrafx.com";
|
|
49
49
|
const FIXED_EDITOR_LINK = `https://${ENGINE_DOMAIN}/editor/${editorEngine.default.current}/web`;
|
|
50
|
-
let connection;
|
|
51
50
|
const PENDING_INSTRUMENTATION = Symbol("pendingInstrumentation");
|
|
52
51
|
const markForInstrumentation = (controller) => {
|
|
53
52
|
Object.defineProperty(controller, PENDING_INSTRUMENTATION, {
|
|
@@ -65,13 +64,15 @@ class SDK {
|
|
|
65
64
|
* @param config The configuration object where the SDK and editor can get configured
|
|
66
65
|
*/
|
|
67
66
|
constructor(config) {
|
|
68
|
-
var _a;
|
|
67
|
+
var _a, _b;
|
|
69
68
|
this.localConfig = /* @__PURE__ */ new Map();
|
|
70
69
|
this.dataItemMappingTools = new DataItemMappingTools.DataItemMappingTools();
|
|
71
70
|
this.methodListeners = new MethodInstrumentation.MethodListenerRegistry();
|
|
71
|
+
this.teardownFrame = null;
|
|
72
72
|
this.loadEditor = () => {
|
|
73
|
-
var _a2;
|
|
74
|
-
|
|
73
|
+
var _a2, _b2, _c;
|
|
74
|
+
(_a2 = this.teardownFrame) == null ? void 0 : _a2.call(this);
|
|
75
|
+
this.teardownFrame = Connector.default(
|
|
75
76
|
this.config.editorLink || FIXED_EDITOR_LINK,
|
|
76
77
|
{
|
|
77
78
|
onActionsChanged: this.subscriber.onActionsChanged,
|
|
@@ -143,11 +144,11 @@ class SDK {
|
|
|
143
144
|
this.config.editorId,
|
|
144
145
|
this.config.studioStyling,
|
|
145
146
|
(error) => {
|
|
146
|
-
var _a3,
|
|
147
|
-
(
|
|
147
|
+
var _a3, _b3;
|
|
148
|
+
(_b3 = (_a3 = this.config).onConnectionError) == null ? void 0 : _b3.call(_a3, error);
|
|
148
149
|
}
|
|
149
150
|
);
|
|
150
|
-
this.editorAPI = connection == null ? void 0 :
|
|
151
|
+
this.editorAPI = (_b2 = this.connection) == null ? void 0 : _b2.promise.then((editorAPI) => {
|
|
151
152
|
return editorAPI;
|
|
152
153
|
});
|
|
153
154
|
this.action = this.toInstrumented(new ActionController.ActionController(this.editorAPI));
|
|
@@ -171,7 +172,9 @@ class SDK {
|
|
|
171
172
|
this.mediaConnector = this.toInstrumented(new MediaConnectorController.MediaConnectorController(this.editorAPI));
|
|
172
173
|
this.fontConnector = this.toInstrumented(new FontConnectorController.FontConnectorController(this.editorAPI));
|
|
173
174
|
this.componentConnector = this.toInstrumented(new ComponentConnectorController.ComponentConnectorController(this.editorAPI));
|
|
174
|
-
this.dataConnector = this.toInstrumented(
|
|
175
|
+
this.dataConnector = this.toInstrumented(
|
|
176
|
+
new DataConnectorController.DataConnectorController(this.editorAPI, this.dataItemMappingTools)
|
|
177
|
+
);
|
|
175
178
|
this.dataSource = this.toInstrumented(new DataSourceController.DataSourceController(this.editorAPI, this.dataItemMappingTools));
|
|
176
179
|
this.connector = this.toInstrumented(new ConnectorController.ConnectorController(this.editorAPI, this.localConfig));
|
|
177
180
|
this.variable = this.toInstrumented(new VariableController.VariableController(this.editorAPI, this.dataItemMappingTools));
|
|
@@ -194,11 +197,20 @@ class SDK {
|
|
|
194
197
|
this.configuration.updateStudioOptions(this.config.studioOptions || ConfigurationTypes.defaultStudioOptions);
|
|
195
198
|
this.configuration.setValue(
|
|
196
199
|
ConfigurationTypes.WellKnownConfigurationKeys.QueryCallCacheEnabled,
|
|
197
|
-
((
|
|
200
|
+
((_c = this.config.enableQueryCallCache) == null ? void 0 : _c.toString()) || "false"
|
|
198
201
|
);
|
|
199
202
|
};
|
|
200
203
|
this.setConnection = (newConnection) => {
|
|
201
|
-
connection = newConnection;
|
|
204
|
+
this.connection = newConnection;
|
|
205
|
+
};
|
|
206
|
+
this.destroy = () => {
|
|
207
|
+
var _a2, _b2;
|
|
208
|
+
try {
|
|
209
|
+
(_a2 = this.connection) == null ? void 0 : _a2.destroy();
|
|
210
|
+
} catch {
|
|
211
|
+
}
|
|
212
|
+
(_b2 = this.teardownFrame) == null ? void 0 : _b2.call(this);
|
|
213
|
+
this.teardownFrame = null;
|
|
202
214
|
};
|
|
203
215
|
this.toInstrumented = (controller) => {
|
|
204
216
|
markForInstrumentation(controller);
|
|
@@ -222,8 +234,7 @@ class SDK {
|
|
|
222
234
|
};
|
|
223
235
|
this.config = ConfigHelper.ConfigHelper.createRuntimeConfig(config);
|
|
224
236
|
this.sdkEvents = new SdkEvents.SdkEvents((_a = this.config.logging) == null ? void 0 : _a.logger);
|
|
225
|
-
this.
|
|
226
|
-
this.editorAPI = connection == null ? void 0 : connection.promise.then((child) => {
|
|
237
|
+
this.editorAPI = (_b = this.connection) == null ? void 0 : _b.promise.then((child) => {
|
|
227
238
|
return child;
|
|
228
239
|
});
|
|
229
240
|
this.action = this.toInstrumented(new ActionController.ActionController(this.editorAPI));
|
|
@@ -237,7 +248,9 @@ class SDK {
|
|
|
237
248
|
this.mediaConnector = this.toInstrumented(new MediaConnectorController.MediaConnectorController(this.editorAPI));
|
|
238
249
|
this.fontConnector = this.toInstrumented(new FontConnectorController.FontConnectorController(this.editorAPI));
|
|
239
250
|
this.componentConnector = this.toInstrumented(new ComponentConnectorController.ComponentConnectorController(this.editorAPI));
|
|
240
|
-
this.dataConnector = this.toInstrumented(
|
|
251
|
+
this.dataConnector = this.toInstrumented(
|
|
252
|
+
new DataConnectorController.DataConnectorController(this.editorAPI, this.dataItemMappingTools)
|
|
253
|
+
);
|
|
241
254
|
this.dataSource = this.toInstrumented(new DataSourceController.DataSourceController(this.editorAPI, this.dataItemMappingTools));
|
|
242
255
|
this.animation = this.toInstrumented(new AnimationController.AnimationController(this.editorAPI));
|
|
243
256
|
this.document = this.toInstrumented(new DocumentController.DocumentController(this.editorAPI));
|
package/lib/src/sdk.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.cjs.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { Connection } from 'penpal';\nimport engineInfo from '../editor-engine.json';\nimport packageInfo from '../package.json';\nimport Connect from './interactions/Connector';\nimport { defaultStudioOptions, WellKnownConfigurationKeys } from './types/ConfigurationTypes';\n\nimport type { ConfigType, EditorAPI, RuntimeConfigType } from './types/CommonTypes';\nimport { Instrumented } from './types/MethodInvocationTypes';\nimport { DocumentType } from './types/DocumentTypes';\n\nimport { ActionController } from './controllers/ActionController';\nimport { AnimationController } from './controllers/AnimationController';\nimport { BarcodeController } from './controllers/BarcodeController';\nimport { BrandKitController } from './controllers/BrandKitController';\nimport { CanvasController } from './controllers/CanvasController';\nimport { CharacterStyleController } from './controllers/CharacterStyleController';\nimport { ClipboardController } from './controllers/ClipboardController';\nimport { ColorConversionController } from './controllers/ColorConversionController';\nimport { ColorStyleController } from './controllers/ColorStyleController';\nimport { ConfigurationController } from './controllers/ConfigurationController';\nimport { ConnectorController } from './controllers/ConnectorController';\nimport { DataConnectorController } from './controllers/DataConnectorController';\nimport { DataSourceController } from './controllers/DataSourceController';\nimport { DebugController } from './controllers/DebugController';\nimport { DocumentController } from './controllers/DocumentController';\nimport { ExperimentController } from './controllers/ExperimentController';\nimport { FontConnectorController } from './controllers/FontConnectorController';\nimport { FontController } from './controllers/FontController';\nimport { FrameController } from './controllers/FrameController';\nimport { InfoController } from './controllers/InfoController';\nimport { LayoutController } from './controllers/LayoutController';\nimport { MediaConnectorController } from './controllers/MediaConnectorController';\nimport { PageController } from './controllers/PageController';\nimport { ParagraphStyleController } from './controllers/ParagraphStyleController';\nimport { ShapeController } from './controllers/ShapeController';\nimport { SubscriberController } from './controllers/SubscriberController';\nimport { TextStyleController } from './controllers/TextStyleController';\nimport { ToolController } from './controllers/ToolController';\nimport { UndoManagerController } from './controllers/UndoManagerController';\nimport { UtilsController } from './controllers/UtilsController';\nimport { VariableController } from './controllers/VariableController';\nimport { NextSubscribers } from './next';\nimport { NextInitiator } from './next/NextInitiator';\nimport { ConfigHelper } from './utils/ConfigHelper';\nimport { DataItemMappingTools } from './utils/DataItemMappingTools';\nimport { LocalConfigurationDecorator } from './utils/LocalConfigurationDecorator';\nimport { GradientStyleController } from './controllers/GradientStyleController';\nimport { ComponentConnectorController } from './controllers/ComponentConnectorController';\nimport { ComponentController } from './controllers/ComponentController';\nimport { ComponentGridController } from './controllers/ComponentGridController';\nimport { MethodListenerRegistry, wrapWithInvocationObserver } from './utils/MethodInstrumentation';\nimport { SdkEvents } from './utils/SdkEvents';\n\ndeclare const __ENGINE_DOMAIN__: string;\nconst ENGINE_DOMAIN = typeof __ENGINE_DOMAIN__ !== 'undefined' ? __ENGINE_DOMAIN__ : 'studio-cdn.chiligrafx.com';\nconst FIXED_EDITOR_LINK = `https://${ENGINE_DOMAIN}/editor/${engineInfo.current}/web`;\n\nlet connection: Connection;\n\n// Marks a freshly created controller as \"needs instrumentation\" without requiring\n// its property name to be tracked anywhere. `applyMethodInstrumentation` later scans\n// the SDK instance for properties carrying this marker and wraps them automatically,\n// so a controller can never be silently skipped just because a list wasn't updated.\nconst PENDING_INSTRUMENTATION = Symbol('pendingInstrumentation');\n\nconst markForInstrumentation = (controller: object): void => {\n Object.defineProperty(controller, PENDING_INSTRUMENTATION, {\n value: true,\n enumerable: false,\n configurable: true,\n });\n};\n\nconst isPendingInstrumentation = (value: unknown): value is object => {\n return typeof value === 'object' && value !== null && (value as Record<symbol, unknown>)[PENDING_INSTRUMENTATION] === true;\n};\n\nexport class SDK {\n config: RuntimeConfigType;\n connection: Connection;\n\n /**\n * @ignore\n */\n editorAPI: EditorAPI;\n /**\n * SDK method invocation events.\n *\n * Use this to observe which SDK controller method was called and with which parameters/result.\n * These are SDK-level events (SDK -> consumer), separate from engine subscriber events (`config.events`).\n */\n sdkEvents: SdkEvents;\n\n action: Instrumented<ActionController>;\n layout: Instrumented<LayoutController>;\n frame: Instrumented<FrameController>;\n shape: Instrumented<ShapeController>;\n barcode: Instrumented<BarcodeController>;\n /** @experimental */\n component: Instrumented<ComponentController>;\n connector: Instrumented<ConnectorController>;\n mediaConnector: Instrumented<MediaConnectorController>;\n fontConnector: Instrumented<FontConnectorController>;\n /**\n * @experimental This controller is still experimental and might change in future releases.\n */\n componentConnector: Instrumented<ComponentConnectorController>;\n dataConnector: Instrumented<DataConnectorController>;\n dataSource: Instrumented<DataSourceController>;\n animation: Instrumented<AnimationController>;\n document: Instrumented<DocumentController>;\n configuration: Instrumented<ConfigurationController>;\n variable: Instrumented<VariableController>;\n utils: Instrumented<UtilsController>;\n tool: Instrumented<ToolController>;\n page: Instrumented<PageController>;\n debug: Instrumented<DebugController>;\n undoManager: Instrumented<UndoManagerController>;\n textSelection: Instrumented<TextStyleController>;\n paragraphStyle: Instrumented<ParagraphStyleController>;\n characterStyle: Instrumented<CharacterStyleController>;\n colorStyle: Instrumented<ColorStyleController>;\n gradientStyle: Instrumented<GradientStyleController>;\n font: Instrumented<FontController>;\n experiment: Instrumented<ExperimentController>;\n canvas: Instrumented<CanvasController>;\n colorConversion: Instrumented<ColorConversionController>;\n info: Instrumented<InfoController>;\n clipboard: Instrumented<ClipboardController>;\n brandKit: Instrumented<BrandKitController>;\n componentGrid: Instrumented<ComponentGridController>;\n\n next: NextInitiator;\n\n private subscriber: SubscriberController;\n private enabledNextSubscribers: NextSubscribers | undefined;\n private localConfig = new Map<string, string>();\n private dataItemMappingTools = new DataItemMappingTools();\n private methodListeners = new MethodListenerRegistry();\n\n /**\n * The SDK should be configured clientside and it exposes all controllers to work with in other applications\n * @param config The configuration object where the SDK and editor can get configured\n */\n constructor(config: ConfigType) {\n this.config = ConfigHelper.createRuntimeConfig(config);\n this.sdkEvents = new SdkEvents(this.config.logging?.logger);\n\n this.connection = connection;\n this.editorAPI = connection?.promise.then((child: unknown) => {\n return child;\n }) as unknown as EditorAPI;\n\n this.action = this.toInstrumented(new ActionController(this.editorAPI));\n this.layout = this.toInstrumented(new LayoutController(this.editorAPI));\n this.frame = this.toInstrumented(new FrameController(this.editorAPI));\n this.shape = this.toInstrumented(new ShapeController(this.editorAPI));\n this.barcode = this.toInstrumented(new BarcodeController(this.editorAPI));\n this.component = this.toInstrumented(new ComponentController(this.editorAPI));\n this.undoManager = this.toInstrumented(new UndoManagerController(this.editorAPI, this));\n this.connector = this.toInstrumented(new ConnectorController(this.editorAPI, this.localConfig));\n this.mediaConnector = this.toInstrumented(new MediaConnectorController(this.editorAPI));\n this.fontConnector = this.toInstrumented(new FontConnectorController(this.editorAPI));\n this.componentConnector = this.toInstrumented(new ComponentConnectorController(this.editorAPI));\n this.dataConnector = this.toInstrumented(new DataConnectorController(this.editorAPI, this.dataItemMappingTools));\n this.dataSource = this.toInstrumented(new DataSourceController(this.editorAPI, this.dataItemMappingTools));\n this.animation = this.toInstrumented(new AnimationController(this.editorAPI));\n this.document = this.toInstrumented(new DocumentController(this.editorAPI));\n\n this.configuration = this.toInstrumented(new LocalConfigurationDecorator(this.editorAPI, this.localConfig));\n this.variable = this.toInstrumented(new VariableController(this.editorAPI, this.dataItemMappingTools));\n this.utils = this.toInstrumented(new UtilsController(this.editorAPI, this.localConfig));\n this.subscriber = new SubscriberController(this.config, this.localConfig);\n this.tool = this.toInstrumented(new ToolController(this.editorAPI));\n this.page = this.toInstrumented(new PageController(this.editorAPI));\n this.debug = this.toInstrumented(new DebugController(this.editorAPI));\n // To be renamed textSelection > textStyle\n this.textSelection = this.toInstrumented(new TextStyleController(this.editorAPI));\n this.colorStyle = this.toInstrumented(new ColorStyleController(this.editorAPI));\n this.gradientStyle = this.toInstrumented(new GradientStyleController(this.editorAPI));\n this.paragraphStyle = this.toInstrumented(new ParagraphStyleController(this.editorAPI));\n this.characterStyle = this.toInstrumented(new CharacterStyleController(this.editorAPI));\n this.font = this.toInstrumented(new FontController(this.editorAPI));\n this.experiment = this.toInstrumented(new ExperimentController(this.editorAPI));\n this.canvas = this.toInstrumented(new CanvasController(this.editorAPI));\n this.colorConversion = this.toInstrumented(new ColorConversionController(this.editorAPI));\n this.info = this.toInstrumented(new InfoController());\n this.clipboard = this.toInstrumented(new ClipboardController(this.editorAPI));\n this.next = new NextInitiator(this.config, this.connection, this.editorAPI);\n this.enabledNextSubscribers = this.config.enableNextSubscribers;\n this.brandKit = this.toInstrumented(new BrandKitController(this.editorAPI, this));\n this.componentGrid = this.toInstrumented(new ComponentGridController(this.editorAPI));\n\n this.applyMethodInstrumentation();\n }\n\n /**\n * This method will initiate the editor, running this will result in the editor restarting\n * It will generate an iframe in the document\n */\n loadEditor = () => {\n Connect(\n this.config.editorLink || FIXED_EDITOR_LINK,\n {\n onActionsChanged: this.subscriber.onActionsChanged,\n onStateChanged: this.subscriber.onStateChanged,\n onAuthExpired: this.subscriber.onAuthExpired,\n onViewportRequested: this.subscriber.onViewportRequested,\n onDocumentLoaded: this.subscriber.onDocumentLoaded,\n onSelectedFramesContentChanged: this.subscriber.onSelectedFramesContentChanged,\n onSelectedFramesLayoutChanged: this.subscriber.onSelectedFramesLayoutChanged,\n onFramesLayoutChanged: this.subscriber.onFramesLayoutChanged,\n onSelectedLayoutPropertiesChanged: this.subscriber.onSelectedLayoutPropertiesChanged,\n onSelectedLayoutUnitChanged: this.subscriber.onSelectedLayoutUnitChanged,\n onPageSelectionChanged: this.subscriber.onPageSelectionChanged,\n onScrubberPositionChanged: this.subscriber.onAnimationPlaybackChanged,\n onFrameAnimationsChanged: this.subscriber.onAnimationChanged,\n onVariableListChanged: (state) => {\n if (this.enabledNextSubscribers?.onVariableListChanged) {\n this.next.subscriber.onVariableListChanged(state);\n } else {\n this.subscriber.onVariableListChanged(state);\n }\n },\n onSelectedToolChanged: this.subscriber.onSelectedToolChanged,\n onUndoStateChanged: this.subscriber.onUndoStateChanged,\n onSelectedLayoutFramesChanged: this.subscriber.onSelectedLayoutFramesChanged,\n onSelectedTextStyleChanged: this.subscriber.onSelectedTextStyleChanged,\n onColorsChanged: this.subscriber.onColorsChanged,\n onParagraphStylesChanged: this.subscriber.onParagraphStylesChanged,\n onCharacterStylesChanged: this.subscriber.onCharacterStylesChanged,\n onFontFamiliesChanged: this.subscriber.onFontFamiliesChanged,\n onSelectedLayoutIdChanged: this.subscriber.onSelectedLayoutIdChanged,\n onLayoutsChanged: this.subscriber.onLayoutsChanged,\n onConnectorEvent: this.subscriber.onConnectorEvent,\n onConnectorsChanged: (state) => {\n if (this.enabledNextSubscribers?.onConnectorsChanged) {\n this.next.subscriber.onConnectorsChanged(state);\n } else {\n this.subscriber.onConnectorsChanged(state);\n }\n },\n onZoomChanged: this.subscriber.onZoomChanged,\n onSelectedPageIdChanged: this.subscriber.onSelectedPageIdChanged,\n onPagesChanged: this.subscriber.onPagesChanged,\n onPageSnapshotInvalidated: this.subscriber.onPageSnapshotInvalidated,\n onPageSizeChanged: (state) => {\n if (this.enabledNextSubscribers?.onPageSizeChanged) {\n this.next.subscriber.onPageSizeChanged(state);\n } else {\n this.subscriber.onPageSizeChanged(state);\n }\n },\n onShapeCornerRadiusChanged: this.subscriber.onShapeCornerRadiusChanged,\n onCropActiveFrameIdChanged: this.subscriber.onCropActiveFrameIdChanged,\n onAsyncError: this.subscriber.onAsyncError,\n onViewModeChanged: this.subscriber.onViewModeChanged,\n onBarcodeValidationChanged: this.subscriber.onBarcodeValidationChanged,\n onDataSourceIdChanged: this.subscriber.onDataSourceIdChanged,\n onInjectedDataChanged: this.subscriber.onInjectedDataChanged,\n onDocumentIssueListChanged: this.subscriber.onDocumentIssueListChanged,\n onCustomUndoDataChanged: this.subscriber.onCustomUndoDataChanged,\n onEngineEditModeChanged: this.subscriber.onEngineEditModeChanged,\n onBrandKitMediaChanged: this.subscriber.onBrandKitMediaChanged,\n onCanvasFramesManipulated: this.subscriber.onCanvasFramesManipulated,\n },\n this.setConnection,\n this.config.editorId,\n this.config.studioStyling,\n (error) => {\n this.config.onConnectionError?.(error);\n },\n );\n this.editorAPI = connection?.promise.then((editorAPI: unknown) => {\n return editorAPI;\n }) as unknown as EditorAPI;\n\n this.action = this.toInstrumented(new ActionController(this.editorAPI));\n this.layout = this.toInstrumented(new LayoutController(this.editorAPI));\n this.frame = this.toInstrumented(new FrameController(this.editorAPI));\n this.barcode = this.toInstrumented(new BarcodeController(this.editorAPI));\n this.component = this.toInstrumented(new ComponentController(this.editorAPI));\n this.animation = this.toInstrumented(new AnimationController(this.editorAPI));\n this.document = this.toInstrumented(new DocumentController(this.editorAPI));\n this.configuration = this.toInstrumented(new LocalConfigurationDecorator(this.editorAPI, this.localConfig));\n this.utils = this.toInstrumented(new UtilsController(this.editorAPI, this.localConfig));\n this.tool = this.toInstrumented(new ToolController(this.editorAPI));\n this.page = this.toInstrumented(new PageController(this.editorAPI));\n this.debug = this.toInstrumented(new DebugController(this.editorAPI));\n this.undoManager = this.toInstrumented(new UndoManagerController(this.editorAPI, this));\n this.textSelection = this.toInstrumented(new TextStyleController(this.editorAPI));\n this.colorStyle = this.toInstrumented(new ColorStyleController(this.editorAPI));\n this.gradientStyle = this.toInstrumented(new GradientStyleController(this.editorAPI));\n this.paragraphStyle = this.toInstrumented(new ParagraphStyleController(this.editorAPI));\n this.characterStyle = this.toInstrumented(new CharacterStyleController(this.editorAPI));\n this.mediaConnector = this.toInstrumented(new MediaConnectorController(this.editorAPI));\n this.fontConnector = this.toInstrumented(new FontConnectorController(this.editorAPI));\n this.componentConnector = this.toInstrumented(new ComponentConnectorController(this.editorAPI));\n this.dataConnector = this.toInstrumented(new DataConnectorController(this.editorAPI, this.dataItemMappingTools));\n this.dataSource = this.toInstrumented(new DataSourceController(this.editorAPI, this.dataItemMappingTools));\n this.connector = this.toInstrumented(new ConnectorController(this.editorAPI, this.localConfig));\n this.variable = this.toInstrumented(new VariableController(this.editorAPI, this.dataItemMappingTools));\n this.font = this.toInstrumented(new FontController(this.editorAPI));\n this.experiment = this.toInstrumented(new ExperimentController(this.editorAPI));\n this.canvas = this.toInstrumented(new CanvasController(this.editorAPI));\n this.shape = this.toInstrumented(new ShapeController(this.editorAPI));\n this.colorConversion = this.toInstrumented(new ColorConversionController(this.editorAPI));\n this.info = this.toInstrumented(new InfoController());\n this.clipboard = this.toInstrumented(new ClipboardController(this.editorAPI));\n this.brandKit = this.toInstrumented(new BrandKitController(this.editorAPI, this));\n this.componentGrid = this.toInstrumented(new ComponentGridController(this.editorAPI));\n this.next = new NextInitiator(this.config, this.connection, this.editorAPI);\n\n this.applyMethodInstrumentation();\n\n // as soon as the editor loads, provide it with the SDK version\n // used to make it start. This enables engine compatibility checks\n // on the Flutter side\n this.configuration.setValue(WellKnownConfigurationKeys.GraFxStudioSdkVersion, packageInfo.version);\n\n // Makes the engine aware which document type it should render, if this call\n // isn't made, the engine will fall back to the type specified in the document.\n //\n // Loading a template JSON and setting the engine to `project` will cause\n // the document JSON structure to be converted to a project on save.\n // Using `getCurrentDocumentState` will also output the converted document.\n this.configuration.setValue(\n WellKnownConfigurationKeys.GraFxStudioDocumentType,\n this.config.documentType || DocumentType.template,\n );\n\n // Update the engine with the specified options from the config or fall back to the defaults.\n this.configuration.updateStudioOptions(this.config.studioOptions || defaultStudioOptions);\n\n // Whether the engine should cache query calls. This is disabled by default.\n this.configuration.setValue(\n WellKnownConfigurationKeys.QueryCallCacheEnabled,\n this.config.enableQueryCallCache?.toString() || 'false',\n );\n };\n\n setConnection = (newConnection: Connection) => {\n connection = newConnection;\n };\n\n private toInstrumented = <T extends object>(controller: T): Instrumented<T> => {\n markForInstrumentation(controller);\n return controller as unknown as Instrumented<T>;\n };\n\n /**\n * Wraps every controller previously handed to `toInstrumented` with the invocation\n * observer, discovering them by their marker rather than a manually maintained\n * list of property names. Any property assigned via `toInstrumented` is picked up\n * automatically, using its own property key as the controller name.\n */\n private applyMethodInstrumentation = () => {\n const sdkProperties = this as unknown as Record<string, unknown>;\n for (const propertyName of Object.keys(sdkProperties)) {\n const value = sdkProperties[propertyName];\n if (isPendingInstrumentation(value)) {\n sdkProperties[propertyName] = wrapWithInvocationObserver(\n value,\n propertyName,\n this.methodListeners,\n this.sdkEvents,\n this.config.logging?.logger,\n );\n }\n }\n };\n}\n\nexport default SDK;\n"],"names":["engineInfo","DataItemMappingTools","MethodListenerRegistry","Connect","_a","ActionController","LayoutController","FrameController","BarcodeController","ComponentController","AnimationController","DocumentController","LocalConfigurationDecorator","UtilsController","ToolController","PageController","DebugController","UndoManagerController","TextStyleController","ColorStyleController","GradientStyleController","ParagraphStyleController","CharacterStyleController","MediaConnectorController","FontConnectorController","ComponentConnectorController","DataConnectorController","DataSourceController","ConnectorController","VariableController","FontController","ExperimentController","CanvasController","ShapeController","ColorConversionController","InfoController","ClipboardController","BrandKitController","ComponentGridController","NextInitiator","WellKnownConfigurationKeys","packageInfo","DocumentType","defaultStudioOptions","wrapWithInvocationObserver","ConfigHelper","SdkEvents","SubscriberController"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,gBAA2D;AACjE,MAAM,oBAAoB,WAAW,aAAa,WAAWA,aAAAA,QAAW,OAAO;AAE/E,IAAI;AAMJ,MAAM,0BAA0B,OAAO,wBAAwB;AAE/D,MAAM,yBAAyB,CAAC,eAA6B;AACzD,SAAO,eAAe,YAAY,yBAAyB;AAAA,IACvD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,EAAA,CACjB;AACL;AAEA,MAAM,2BAA2B,CAAC,UAAoC;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAS,MAAkC,uBAAuB,MAAM;AAC1H;AAEO,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,EAmEb,YAAY,QAAoB;;AARhC,SAAQ,kCAAkB,IAAA;AAC1B,SAAQ,uBAAuB,IAAIC,0CAAA;AACnC,SAAQ,kBAAkB,IAAIC,6CAAA;AA8D9B,SAAA,aAAa,MAAM;;AACfC,gBAAAA;AAAAA,QACI,KAAK,OAAO,cAAc;AAAA,QAC1B;AAAA,UACI,kBAAkB,KAAK,WAAW;AAAA,UAClC,gBAAgB,KAAK,WAAW;AAAA,UAChC,eAAe,KAAK,WAAW;AAAA,UAC/B,qBAAqB,KAAK,WAAW;AAAA,UACrC,kBAAkB,KAAK,WAAW;AAAA,UAClC,gCAAgC,KAAK,WAAW;AAAA,UAChD,+BAA+B,KAAK,WAAW;AAAA,UAC/C,uBAAuB,KAAK,WAAW;AAAA,UACvC,mCAAmC,KAAK,WAAW;AAAA,UACnD,6BAA6B,KAAK,WAAW;AAAA,UAC7C,wBAAwB,KAAK,WAAW;AAAA,UACxC,2BAA2B,KAAK,WAAW;AAAA,UAC3C,0BAA0B,KAAK,WAAW;AAAA,UAC1C,uBAAuB,CAAC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B;AACpD,SAAK,YAAY,KAAK,eAAe,IAAIC,wCAAoB,KAAK,SAAS,CAAC;AAC5E,SAAK,OAAO,IAAIG,cAAAA,cAAc,KAAK,QAAQ,KAAK,YAAY,KAAK,SAAS;AAC1E,SAAK,yBAAyB,KAAK,OAAO;AAC1C,SAAK,WAAW,KAAK,eAAe,IAAIF,mBAAAA,mBAAmB,KAAK,WAAW,IAAI,CAAC;AAChF,SAAK,gBAAgB,KAAK,eAAe,IAAIC,gDAAwB,KAAK,SAAS,CAAC;AAEpF,SAAK,2BAAA;AAAA,EACT;AAiLJ;;"}
|
|
1
|
+
{"version":3,"file":"sdk.cjs.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { Connection } from 'penpal';\nimport engineInfo from '../editor-engine.json';\nimport packageInfo from '../package.json';\nimport Connect from './interactions/Connector';\nimport { defaultStudioOptions, WellKnownConfigurationKeys } from './types/ConfigurationTypes';\n\nimport type { ConfigType, EditorAPI, RuntimeConfigType } from './types/CommonTypes';\nimport { Instrumented } from './types/MethodInvocationTypes';\nimport { DocumentType } from './types/DocumentTypes';\n\nimport { ActionController } from './controllers/ActionController';\nimport { AnimationController } from './controllers/AnimationController';\nimport { BarcodeController } from './controllers/BarcodeController';\nimport { BrandKitController } from './controllers/BrandKitController';\nimport { CanvasController } from './controllers/CanvasController';\nimport { CharacterStyleController } from './controllers/CharacterStyleController';\nimport { ClipboardController } from './controllers/ClipboardController';\nimport { ColorConversionController } from './controllers/ColorConversionController';\nimport { ColorStyleController } from './controllers/ColorStyleController';\nimport { ConfigurationController } from './controllers/ConfigurationController';\nimport { ConnectorController } from './controllers/ConnectorController';\nimport { DataConnectorController } from './controllers/DataConnectorController';\nimport { DataSourceController } from './controllers/DataSourceController';\nimport { DebugController } from './controllers/DebugController';\nimport { DocumentController } from './controllers/DocumentController';\nimport { ExperimentController } from './controllers/ExperimentController';\nimport { FontConnectorController } from './controllers/FontConnectorController';\nimport { FontController } from './controllers/FontController';\nimport { FrameController } from './controllers/FrameController';\nimport { InfoController } from './controllers/InfoController';\nimport { LayoutController } from './controllers/LayoutController';\nimport { MediaConnectorController } from './controllers/MediaConnectorController';\nimport { PageController } from './controllers/PageController';\nimport { ParagraphStyleController } from './controllers/ParagraphStyleController';\nimport { ShapeController } from './controllers/ShapeController';\nimport { SubscriberController } from './controllers/SubscriberController';\nimport { TextStyleController } from './controllers/TextStyleController';\nimport { ToolController } from './controllers/ToolController';\nimport { UndoManagerController } from './controllers/UndoManagerController';\nimport { UtilsController } from './controllers/UtilsController';\nimport { VariableController } from './controllers/VariableController';\nimport { NextSubscribers } from './next';\nimport { NextInitiator } from './next/NextInitiator';\nimport { ConfigHelper } from './utils/ConfigHelper';\nimport { DataItemMappingTools } from './utils/DataItemMappingTools';\nimport { LocalConfigurationDecorator } from './utils/LocalConfigurationDecorator';\nimport { GradientStyleController } from './controllers/GradientStyleController';\nimport { ComponentConnectorController } from './controllers/ComponentConnectorController';\nimport { ComponentController } from './controllers/ComponentController';\nimport { ComponentGridController } from './controllers/ComponentGridController';\nimport { MethodListenerRegistry, wrapWithInvocationObserver } from './utils/MethodInstrumentation';\nimport { SdkEvents } from './utils/SdkEvents';\n\ndeclare const __ENGINE_DOMAIN__: string;\nconst ENGINE_DOMAIN = typeof __ENGINE_DOMAIN__ !== 'undefined' ? __ENGINE_DOMAIN__ : 'studio-cdn.chiligrafx.com';\nconst FIXED_EDITOR_LINK = `https://${ENGINE_DOMAIN}/editor/${engineInfo.current}/web`;\n\n// Marks a freshly created controller as \"needs instrumentation\" without requiring\n// its property name to be tracked anywhere. `applyMethodInstrumentation` later scans\n// the SDK instance for properties carrying this marker and wraps them automatically,\n// so a controller can never be silently skipped just because a list wasn't updated.\nconst PENDING_INSTRUMENTATION = Symbol('pendingInstrumentation');\n\nconst markForInstrumentation = (controller: object): void => {\n Object.defineProperty(controller, PENDING_INSTRUMENTATION, {\n value: true,\n enumerable: false,\n configurable: true,\n });\n};\n\nconst isPendingInstrumentation = (value: unknown): value is object => {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_INSTRUMENTATION] === true\n );\n};\n\nexport class SDK {\n config: RuntimeConfigType;\n // Set by `loadEditor` via `setConnection`; stays `undefined` until then.\n connection!: Connection;\n\n /**\n * @ignore\n */\n editorAPI: EditorAPI;\n /**\n * SDK method invocation events.\n *\n * Use this to observe which SDK controller method was called and with which parameters/result.\n * These are SDK-level events (SDK -> consumer), separate from engine subscriber events (`config.events`).\n */\n sdkEvents: SdkEvents;\n\n action: Instrumented<ActionController>;\n layout: Instrumented<LayoutController>;\n frame: Instrumented<FrameController>;\n shape: Instrumented<ShapeController>;\n barcode: Instrumented<BarcodeController>;\n /** @experimental */\n component: Instrumented<ComponentController>;\n connector: Instrumented<ConnectorController>;\n mediaConnector: Instrumented<MediaConnectorController>;\n fontConnector: Instrumented<FontConnectorController>;\n /**\n * @experimental This controller is still experimental and might change in future releases.\n */\n componentConnector: Instrumented<ComponentConnectorController>;\n dataConnector: Instrumented<DataConnectorController>;\n dataSource: Instrumented<DataSourceController>;\n animation: Instrumented<AnimationController>;\n document: Instrumented<DocumentController>;\n configuration: Instrumented<ConfigurationController>;\n variable: Instrumented<VariableController>;\n utils: Instrumented<UtilsController>;\n tool: Instrumented<ToolController>;\n page: Instrumented<PageController>;\n debug: Instrumented<DebugController>;\n undoManager: Instrumented<UndoManagerController>;\n textSelection: Instrumented<TextStyleController>;\n paragraphStyle: Instrumented<ParagraphStyleController>;\n characterStyle: Instrumented<CharacterStyleController>;\n colorStyle: Instrumented<ColorStyleController>;\n gradientStyle: Instrumented<GradientStyleController>;\n font: Instrumented<FontController>;\n experiment: Instrumented<ExperimentController>;\n canvas: Instrumented<CanvasController>;\n colorConversion: Instrumented<ColorConversionController>;\n info: Instrumented<InfoController>;\n clipboard: Instrumented<ClipboardController>;\n brandKit: Instrumented<BrandKitController>;\n componentGrid: Instrumented<ComponentGridController>;\n\n next: NextInitiator;\n\n private subscriber: SubscriberController;\n private enabledNextSubscribers: NextSubscribers | undefined;\n private localConfig = new Map<string, string>();\n private dataItemMappingTools = new DataItemMappingTools();\n private methodListeners = new MethodListenerRegistry();\n // Releases this instance's engine frame (iframe + listeners); set by `loadEditor`.\n private teardownFrame: (() => void) | null = null;\n\n /**\n * The SDK should be configured clientside and it exposes all controllers to work with in other applications\n * @param config The configuration object where the SDK and editor can get configured\n */\n constructor(config: ConfigType) {\n this.config = ConfigHelper.createRuntimeConfig(config);\n this.sdkEvents = new SdkEvents(this.config.logging?.logger);\n\n // `this.connection` only exists once `loadEditor` ran, so the controllers\n // created here get no live editorAPI yet; `loadEditor` rebuilds them with one.\n this.editorAPI = this.connection?.promise.then((child: unknown) => {\n return child;\n }) as unknown as EditorAPI;\n\n this.action = this.toInstrumented(new ActionController(this.editorAPI));\n this.layout = this.toInstrumented(new LayoutController(this.editorAPI));\n this.frame = this.toInstrumented(new FrameController(this.editorAPI));\n this.shape = this.toInstrumented(new ShapeController(this.editorAPI));\n this.barcode = this.toInstrumented(new BarcodeController(this.editorAPI));\n this.component = this.toInstrumented(new ComponentController(this.editorAPI));\n this.undoManager = this.toInstrumented(new UndoManagerController(this.editorAPI, this));\n this.connector = this.toInstrumented(new ConnectorController(this.editorAPI, this.localConfig));\n this.mediaConnector = this.toInstrumented(new MediaConnectorController(this.editorAPI));\n this.fontConnector = this.toInstrumented(new FontConnectorController(this.editorAPI));\n this.componentConnector = this.toInstrumented(new ComponentConnectorController(this.editorAPI));\n this.dataConnector = this.toInstrumented(\n new DataConnectorController(this.editorAPI, this.dataItemMappingTools),\n );\n this.dataSource = this.toInstrumented(new DataSourceController(this.editorAPI, this.dataItemMappingTools));\n this.animation = this.toInstrumented(new AnimationController(this.editorAPI));\n this.document = this.toInstrumented(new DocumentController(this.editorAPI));\n\n this.configuration = this.toInstrumented(new LocalConfigurationDecorator(this.editorAPI, this.localConfig));\n this.variable = this.toInstrumented(new VariableController(this.editorAPI, this.dataItemMappingTools));\n this.utils = this.toInstrumented(new UtilsController(this.editorAPI, this.localConfig));\n this.subscriber = new SubscriberController(this.config, this.localConfig);\n this.tool = this.toInstrumented(new ToolController(this.editorAPI));\n this.page = this.toInstrumented(new PageController(this.editorAPI));\n this.debug = this.toInstrumented(new DebugController(this.editorAPI));\n // To be renamed textSelection > textStyle\n this.textSelection = this.toInstrumented(new TextStyleController(this.editorAPI));\n this.colorStyle = this.toInstrumented(new ColorStyleController(this.editorAPI));\n this.gradientStyle = this.toInstrumented(new GradientStyleController(this.editorAPI));\n this.paragraphStyle = this.toInstrumented(new ParagraphStyleController(this.editorAPI));\n this.characterStyle = this.toInstrumented(new CharacterStyleController(this.editorAPI));\n this.font = this.toInstrumented(new FontController(this.editorAPI));\n this.experiment = this.toInstrumented(new ExperimentController(this.editorAPI));\n this.canvas = this.toInstrumented(new CanvasController(this.editorAPI));\n this.colorConversion = this.toInstrumented(new ColorConversionController(this.editorAPI));\n this.info = this.toInstrumented(new InfoController());\n this.clipboard = this.toInstrumented(new ClipboardController(this.editorAPI));\n this.next = new NextInitiator(this.config, this.connection, this.editorAPI);\n this.enabledNextSubscribers = this.config.enableNextSubscribers;\n this.brandKit = this.toInstrumented(new BrandKitController(this.editorAPI, this));\n this.componentGrid = this.toInstrumented(new ComponentGridController(this.editorAPI));\n\n this.applyMethodInstrumentation();\n }\n\n /**\n * This method will initiate the editor, running this will result in the editor restarting\n * It will generate an iframe in the document\n */\n loadEditor = () => {\n // Reloading first releases this instance's previous engine frame, so a second\n // `loadEditor` can never orphan a live engine. Frames loaded by other SDK\n // instances are tracked per instance and stay untouched.\n this.teardownFrame?.();\n this.teardownFrame = Connect(\n this.config.editorLink || FIXED_EDITOR_LINK,\n {\n onActionsChanged: this.subscriber.onActionsChanged,\n onStateChanged: this.subscriber.onStateChanged,\n onAuthExpired: this.subscriber.onAuthExpired,\n onViewportRequested: this.subscriber.onViewportRequested,\n onDocumentLoaded: this.subscriber.onDocumentLoaded,\n onSelectedFramesContentChanged: this.subscriber.onSelectedFramesContentChanged,\n onSelectedFramesLayoutChanged: this.subscriber.onSelectedFramesLayoutChanged,\n onFramesLayoutChanged: this.subscriber.onFramesLayoutChanged,\n onSelectedLayoutPropertiesChanged: this.subscriber.onSelectedLayoutPropertiesChanged,\n onSelectedLayoutUnitChanged: this.subscriber.onSelectedLayoutUnitChanged,\n onPageSelectionChanged: this.subscriber.onPageSelectionChanged,\n onScrubberPositionChanged: this.subscriber.onAnimationPlaybackChanged,\n onFrameAnimationsChanged: this.subscriber.onAnimationChanged,\n onVariableListChanged: (state) => {\n if (this.enabledNextSubscribers?.onVariableListChanged) {\n this.next.subscriber.onVariableListChanged(state);\n } else {\n this.subscriber.onVariableListChanged(state);\n }\n },\n onSelectedToolChanged: this.subscriber.onSelectedToolChanged,\n onUndoStateChanged: this.subscriber.onUndoStateChanged,\n onSelectedLayoutFramesChanged: this.subscriber.onSelectedLayoutFramesChanged,\n onSelectedTextStyleChanged: this.subscriber.onSelectedTextStyleChanged,\n onColorsChanged: this.subscriber.onColorsChanged,\n onParagraphStylesChanged: this.subscriber.onParagraphStylesChanged,\n onCharacterStylesChanged: this.subscriber.onCharacterStylesChanged,\n onFontFamiliesChanged: this.subscriber.onFontFamiliesChanged,\n onSelectedLayoutIdChanged: this.subscriber.onSelectedLayoutIdChanged,\n onLayoutsChanged: this.subscriber.onLayoutsChanged,\n onConnectorEvent: this.subscriber.onConnectorEvent,\n onConnectorsChanged: (state) => {\n if (this.enabledNextSubscribers?.onConnectorsChanged) {\n this.next.subscriber.onConnectorsChanged(state);\n } else {\n this.subscriber.onConnectorsChanged(state);\n }\n },\n onZoomChanged: this.subscriber.onZoomChanged,\n onSelectedPageIdChanged: this.subscriber.onSelectedPageIdChanged,\n onPagesChanged: this.subscriber.onPagesChanged,\n onPageSnapshotInvalidated: this.subscriber.onPageSnapshotInvalidated,\n onPageSizeChanged: (state) => {\n if (this.enabledNextSubscribers?.onPageSizeChanged) {\n this.next.subscriber.onPageSizeChanged(state);\n } else {\n this.subscriber.onPageSizeChanged(state);\n }\n },\n onShapeCornerRadiusChanged: this.subscriber.onShapeCornerRadiusChanged,\n onCropActiveFrameIdChanged: this.subscriber.onCropActiveFrameIdChanged,\n onAsyncError: this.subscriber.onAsyncError,\n onViewModeChanged: this.subscriber.onViewModeChanged,\n onBarcodeValidationChanged: this.subscriber.onBarcodeValidationChanged,\n onDataSourceIdChanged: this.subscriber.onDataSourceIdChanged,\n onInjectedDataChanged: this.subscriber.onInjectedDataChanged,\n onDocumentIssueListChanged: this.subscriber.onDocumentIssueListChanged,\n onCustomUndoDataChanged: this.subscriber.onCustomUndoDataChanged,\n onEngineEditModeChanged: this.subscriber.onEngineEditModeChanged,\n onBrandKitMediaChanged: this.subscriber.onBrandKitMediaChanged,\n onCanvasFramesManipulated: this.subscriber.onCanvasFramesManipulated,\n },\n this.setConnection,\n this.config.editorId,\n this.config.studioStyling,\n (error) => {\n this.config.onConnectionError?.(error);\n },\n );\n // `Connect` invokes `setConnection` synchronously, so `this.connection`\n // already points at the fresh connection here.\n this.editorAPI = this.connection?.promise.then((editorAPI: unknown) => {\n return editorAPI;\n }) as unknown as EditorAPI;\n\n this.action = this.toInstrumented(new ActionController(this.editorAPI));\n this.layout = this.toInstrumented(new LayoutController(this.editorAPI));\n this.frame = this.toInstrumented(new FrameController(this.editorAPI));\n this.barcode = this.toInstrumented(new BarcodeController(this.editorAPI));\n this.component = this.toInstrumented(new ComponentController(this.editorAPI));\n this.animation = this.toInstrumented(new AnimationController(this.editorAPI));\n this.document = this.toInstrumented(new DocumentController(this.editorAPI));\n this.configuration = this.toInstrumented(new LocalConfigurationDecorator(this.editorAPI, this.localConfig));\n this.utils = this.toInstrumented(new UtilsController(this.editorAPI, this.localConfig));\n this.tool = this.toInstrumented(new ToolController(this.editorAPI));\n this.page = this.toInstrumented(new PageController(this.editorAPI));\n this.debug = this.toInstrumented(new DebugController(this.editorAPI));\n this.undoManager = this.toInstrumented(new UndoManagerController(this.editorAPI, this));\n this.textSelection = this.toInstrumented(new TextStyleController(this.editorAPI));\n this.colorStyle = this.toInstrumented(new ColorStyleController(this.editorAPI));\n this.gradientStyle = this.toInstrumented(new GradientStyleController(this.editorAPI));\n this.paragraphStyle = this.toInstrumented(new ParagraphStyleController(this.editorAPI));\n this.characterStyle = this.toInstrumented(new CharacterStyleController(this.editorAPI));\n this.mediaConnector = this.toInstrumented(new MediaConnectorController(this.editorAPI));\n this.fontConnector = this.toInstrumented(new FontConnectorController(this.editorAPI));\n this.componentConnector = this.toInstrumented(new ComponentConnectorController(this.editorAPI));\n this.dataConnector = this.toInstrumented(\n new DataConnectorController(this.editorAPI, this.dataItemMappingTools),\n );\n this.dataSource = this.toInstrumented(new DataSourceController(this.editorAPI, this.dataItemMappingTools));\n this.connector = this.toInstrumented(new ConnectorController(this.editorAPI, this.localConfig));\n this.variable = this.toInstrumented(new VariableController(this.editorAPI, this.dataItemMappingTools));\n this.font = this.toInstrumented(new FontController(this.editorAPI));\n this.experiment = this.toInstrumented(new ExperimentController(this.editorAPI));\n this.canvas = this.toInstrumented(new CanvasController(this.editorAPI));\n this.shape = this.toInstrumented(new ShapeController(this.editorAPI));\n this.colorConversion = this.toInstrumented(new ColorConversionController(this.editorAPI));\n this.info = this.toInstrumented(new InfoController());\n this.clipboard = this.toInstrumented(new ClipboardController(this.editorAPI));\n this.brandKit = this.toInstrumented(new BrandKitController(this.editorAPI, this));\n this.componentGrid = this.toInstrumented(new ComponentGridController(this.editorAPI));\n this.next = new NextInitiator(this.config, this.connection, this.editorAPI);\n\n this.applyMethodInstrumentation();\n\n // as soon as the editor loads, provide it with the SDK version\n // used to make it start. This enables engine compatibility checks\n // on the Flutter side\n this.configuration.setValue(WellKnownConfigurationKeys.GraFxStudioSdkVersion, packageInfo.version);\n\n // Makes the engine aware which document type it should render, if this call\n // isn't made, the engine will fall back to the type specified in the document.\n //\n // Loading a template JSON and setting the engine to `project` will cause\n // the document JSON structure to be converted to a project on save.\n // Using `getCurrentDocumentState` will also output the converted document.\n this.configuration.setValue(\n WellKnownConfigurationKeys.GraFxStudioDocumentType,\n this.config.documentType || DocumentType.template,\n );\n\n // Update the engine with the specified options from the config or fall back to the defaults.\n this.configuration.updateStudioOptions(this.config.studioOptions || defaultStudioOptions);\n\n // Whether the engine should cache query calls. This is disabled by default.\n this.configuration.setValue(\n WellKnownConfigurationKeys.QueryCallCacheEnabled,\n this.config.enableQueryCallCache?.toString() || 'false',\n );\n };\n\n setConnection = (newConnection: Connection) => {\n this.connection = newConnection;\n };\n\n /**\n * Shuts this SDK instance down and releases the engine it loaded.\n *\n * This tears down the postMessage connection, removes the engine iframe from the\n * document and drops the references the SDK itself holds. Removing the iframe is what\n * lets the browser discard the engine realm, which is where the bulk of the memory\n * lives (the Dart heap plus the CanvasKit and QuickJS WASM memory).\n *\n * Call this whenever an integration unmounts an editor it previously created with\n * {@link loadEditor}. Without it every mount leaves a fully live engine behind.\n * The method is safe to call more than once.\n */\n destroy = () => {\n try {\n this.connection?.destroy();\n } catch {\n // A connection that was already destroyed (for example by penpal's own\n // iframe-removal monitor) must not prevent the rest of the teardown.\n }\n\n // Null the handle as well: the closure closes over the iframe, so keeping it\n // would keep the removed engine realm reachable.\n this.teardownFrame?.();\n this.teardownFrame = null;\n };\n\n private toInstrumented = <T extends object>(controller: T): Instrumented<T> => {\n markForInstrumentation(controller);\n return controller as unknown as Instrumented<T>;\n };\n\n /**\n * Wraps every controller previously handed to `toInstrumented` with the invocation\n * observer, discovering them by their marker rather than a manually maintained\n * list of property names. Any property assigned via `toInstrumented` is picked up\n * automatically, using its own property key as the controller name.\n */\n private applyMethodInstrumentation = () => {\n const sdkProperties = this as unknown as Record<string, unknown>;\n for (const propertyName of Object.keys(sdkProperties)) {\n const value = sdkProperties[propertyName];\n if (isPendingInstrumentation(value)) {\n sdkProperties[propertyName] = wrapWithInvocationObserver(\n value,\n propertyName,\n this.methodListeners,\n this.sdkEvents,\n this.config.logging?.logger,\n );\n }\n }\n };\n}\n\nexport default SDK;\n"],"names":["engineInfo","DataItemMappingTools","MethodListenerRegistry","_a","Connect","_b","ActionController","LayoutController","FrameController","BarcodeController","ComponentController","AnimationController","DocumentController","LocalConfigurationDecorator","UtilsController","ToolController","PageController","DebugController","UndoManagerController","TextStyleController","ColorStyleController","GradientStyleController","ParagraphStyleController","CharacterStyleController","MediaConnectorController","FontConnectorController","ComponentConnectorController","DataConnectorController","DataSourceController","ConnectorController","VariableController","FontController","ExperimentController","CanvasController","ShapeController","ColorConversionController","InfoController","ClipboardController","BrandKitController","ComponentGridController","NextInitiator","WellKnownConfigurationKeys","packageInfo","DocumentType","defaultStudioOptions","wrapWithInvocationObserver","ConfigHelper","SdkEvents","SubscriberController"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,gBAA2D;AACjE,MAAM,oBAAoB,WAAW,aAAa,WAAWA,aAAAA,QAAW,OAAO;AAM/E,MAAM,0BAA0B,OAAO,wBAAwB;AAE/D,MAAM,yBAAyB,CAAC,eAA6B;AACzD,SAAO,eAAe,YAAY,yBAAyB;AAAA,IACvD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,EAAA,CACjB;AACL;AAEA,MAAM,2BAA2B,CAAC,UAAoC;AAClE,SACI,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,uBAAuB,MAAM;AAExE;AAEO,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,EAsEb,YAAY,QAAoB;;AAVhC,SAAQ,kCAAkB,IAAA;AAC1B,SAAQ,uBAAuB,IAAIC,0CAAA;AACnC,SAAQ,kBAAkB,IAAIC,6CAAA;AAE9B,SAAQ,gBAAqC;AAiE7C,SAAA,aAAa,MAAM;;AAIf,OAAAC,MAAA,KAAK,kBAAL,gBAAAA,IAAA;AACA,WAAK,gBAAgBC,UAAAA;AAAAA,QACjB,KAAK,OAAO,cAAc;AAAA,QAC1B;AAAA,UACI,kBAAkB,KAAK,WAAW;AAAA,UAClC,gBAAgB,KAAK,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