@@ -3,21 +3,26 @@ import {
33 INodeComponent ,
44 BaseNodeInfo ,
55 IThumbNodeComponent ,
6+ GetNodeTaskFactory ,
67} from '@devhelpr/visual-programming-system' ;
78import { Exporter } from './Exporter' ;
89
910import { BaseExporter } from './BaseExporter' ;
1011import { OCWGFile , OCWGNode } from './ocwg/ocwg-schema' ;
1112import { ocwgEmptyFile } from './ocwg/ocwg-empty-file' ;
13+ import { NodeInfo } from '@devhelpr/web-flow-executor' ;
1214
1315interface OCWGInfo {
1416 index : number ;
1517}
1618const nodeInfoPropertyName = '@code-flow-canvas/node-properties' ;
1719
1820export class OCWGExporter extends BaseExporter < OCWGFile , OCWGInfo > {
19- constructor ( exportInfo : Exporter ) {
20- super ( exportInfo ) ;
21+ constructor (
22+ exportInfo : Exporter ,
23+ getNodeTaskFactory : GetNodeTaskFactory < NodeInfo >
24+ ) {
25+ super ( exportInfo , getNodeTaskFactory ) ;
2126 }
2227
2328 override createExportFile ( ) : OCWGFile {
@@ -39,6 +44,29 @@ export class OCWGExporter extends BaseExporter<OCWGFile, OCWGInfo> {
3944 _isRectThumb : boolean ,
4045 parentId ?: string
4146 ) : string {
47+ const ports : string [ ] = [ ] ;
48+ if ( nodeInfo . type ) {
49+ const factory = this . getNodeTaskFactory ( nodeInfo . type ) ;
50+ if ( factory ) {
51+ const nodeTask = factory ( ( ) => {
52+ //
53+ } ) ;
54+ if ( nodeTask ) {
55+ nodeTask . thumbs ?. forEach ( ( thumb ) => {
56+ if ( thumb . name ) {
57+ ports . push ( thumb . name ) ;
58+ }
59+ } ) ;
60+ }
61+ }
62+ }
63+ const portsNode : any [ ] = [ ] ;
64+ if ( ports . length > 0 ) {
65+ portsNode . push ( {
66+ type : '@ocwg/node/ports' ,
67+ ports : ports ,
68+ } ) ;
69+ }
4270 const ocwgNode : OCWGNode = {
4371 id : `shape:${ node . id } ` ,
4472 position : [ node . x , node . y ] ,
@@ -49,6 +77,7 @@ export class OCWGExporter extends BaseExporter<OCWGFile, OCWGInfo> {
4977 type : nodeInfoPropertyName ,
5078 nodeType : nodeInfo . type ,
5179 } ,
80+ ...portsNode ,
5281 ] ,
5382 } ;
5483 if ( this . file ?. nodes ) {
@@ -168,8 +197,11 @@ export class OCWGExporter extends BaseExporter<OCWGFile, OCWGInfo> {
168197 }
169198}
170199
171- export const exportOCWG = ( exportInfo : Exporter ) => {
172- const tldrawExporter = new OCWGExporter ( exportInfo ) ;
200+ export const exportOCWG = (
201+ exportInfo : Exporter ,
202+ getNodeTaskFactory : GetNodeTaskFactory < NodeInfo >
203+ ) => {
204+ const tldrawExporter = new OCWGExporter ( exportInfo , getNodeTaskFactory ) ;
173205 const file = tldrawExporter . convertToExportFile ( ) ;
174206 exportInfo . downloadFile (
175207 JSON . stringify ( file ) ,
0 commit comments