Skip to content
This repository was archived by the owner on Dec 16, 2020. It is now read-only.
This repository was archived by the owner on Dec 16, 2020. It is now read-only.

Defects of the current npm package #29

Description

@hungtcs

1. typeRoots only detect subfolders

"typeRoots": [
    "node_modules/@types",
    "node_modules/mxgraph-type-definitions"
]

for instance: mxClient is declared in node_modules/mxgraph-type-definitions/mxClient.d.ts, but typescript can not detect this, packages in @types/* not have this problem.

Possible solution:

  1. move all definition files to a subfolder.
  2. put mxgraph-type-definitions package under a npm organization.
  3. merge this project to DefinitelyTyped.

2. Should we create a factory package to match mxgraph-type-definitions

Simple implementation:

import mxgraph from 'mxgraph';

type mxGraphOptions = {
  mxBasePath?: string,
  mxImageBasePath?: string,
  mxLanguage?: string,
  mxDefaultLanguage?: string,
  mxLoadResources?: boolean,
  mxLoadStylesheets?: boolean,
};

type mxGraphExportObject = {
  mxClient: any,
  mxLog: typeof mxLog,
  mxObjectIdentity: any,
  mxDictionary: typeof mxDictionary,
  mxResources: typeof mxResources,
  mxPoint: typeof mxPoint,
  mxRectangle: typeof mxRectangle,
  mxEffects: any,
  mxUtils: typeof mxUtils,
  mxConstants: typeof mxConstants,
  mxEventObject: typeof mxEventObject,
  mxMouseEvent: typeof mxMouseEvent,
  mxEventSource: typeof mxEventSource,
  mxEvent: typeof mxEvent,
  mxXmlRequest: typeof mxXmlRequest,
  mxClipboard: any,
  mxWindow: any,
  mxForm: any,
  mxImage: typeof mxImage,
  mxDivResizer: any,
  mxDragSource: typeof mxDragSource,
  mxToolbar: any,
  mxUndoableEdit: typeof mxUndoableEdit,
  mxUndoManager: any,
  mxUrlConverter: typeof mxUrlConverter,
  mxPanningManager: typeof mxPanningManager,
  mxPopupMenu: typeof mxPopupMenu,
  mxAutoSaveManager: any,
  mxAnimation: any,
  mxMorphing: typeof mxMorphing,
  mxImageBundle: typeof mxImageBundle,
  mxImageExport: any,
  mxAbstractCanvas2D: typeof mxAbstractCanvas2D,
  mxXmlCanvas2D: typeof mxXmlCanvas2D,
  mxSvgCanvas2D: typeof mxSvgCanvas2D,
  mxVmlCanvas2D: typeof mxVmlCanvas2D,
  mxGuide: typeof mxGuide,
  mxShape: typeof mxShape,
  mxStencil: typeof mxStencil,
  mxStencilRegistry: typeof mxStencilRegistry,
  mxMarker: typeof mxMarker,
  mxActor: typeof mxActor,
  mxCloud: typeof mxCloud,
  mxRectangleShape: typeof mxRectangleShape,
  mxEllipse: typeof mxEllipse,
  mxDoubleEllipse: typeof mxDoubleEllipse,
  mxRhombus: typeof mxRhombus,
  mxPolyline: typeof mxPolyline,
  mxArrow: typeof mxArrow,
  mxArrowConnector: typeof mxArrowConnector,
  mxText: typeof mxText,
  mxTriangle: typeof mxTriangle,
  mxHexagon: typeof mxHexagon,
  mxLine: typeof mxLine,
  mxImageShape: typeof mxImageShape,
  mxLabel: typeof mxLabel,
  mxCylinder: typeof mxCylinder,
  mxConnector: typeof mxConnector,
  mxSwimlane: typeof mxSwimlane,
  mxGraphLayout: typeof mxGraphLayout,
  mxStackLayout: typeof mxStackLayout,
  mxPartitionLayout: any,
  mxCompactTreeLayout: typeof mxCompactTreeLayout,
  mxRadialTreeLayout: typeof mxRadialTreeLayout,
  mxFastOrganicLayout: typeof mxFastOrganicLayout,
  mxCircleLayout: typeof mxCircleLayout,
  mxParallelEdgeLayout: typeof mxParallelEdgeLayout,
  mxCompositeLayout: typeof mxCompositeLayout,
  mxEdgeLabelLayout: typeof mxEdgeLabelLayout,
  mxGraphAbstractHierarchyCell: typeof mxGraphAbstractHierarchyCell,
  mxGraphHierarchyNode: typeof mxGraphHierarchyNode,
  mxGraphHierarchyEdge: typeof mxGraphHierarchyEdge,
  mxGraphHierarchyModel: typeof mxGraphHierarchyModel,
  mxSwimlaneModel: typeof mxSwimlaneModel,
  mxHierarchicalLayoutStage: typeof mxHierarchicalLayoutStage,
  mxMedianHybridCrossingReduction: typeof mxMedianHybridCrossingReduction,
  mxMinimumCycleRemover: typeof mxMinimumCycleRemover,
  mxCoordinateAssignment: typeof mxCoordinateAssignment,
  mxSwimlaneOrdering: typeof mxSwimlaneOrdering,
  mxHierarchicalLayout: typeof mxHierarchicalLayout,
  mxSwimlaneLayout: typeof mxSwimlaneLayout,
  mxGraphModel: typeof mxGraphModel,
  mxCell: typeof mxCell,
  mxGeometry: typeof mxGeometry,
  mxCellPath: typeof mxCellPath,
  mxPerimeter: typeof mxPerimeter,
  mxPrintPreview: typeof mxPrintPreview,
  mxStylesheet: typeof mxStylesheet,
  mxCellState: typeof mxCellState,
  mxGraphSelectionModel: typeof mxGraphSelectionModel,
  mxCellEditor: typeof mxCellEditor,
  mxCellRenderer: typeof mxCellRenderer,
  mxEdgeStyle: typeof mxEdgeStyle,
  mxStyleRegistry: typeof mxStyleRegistry,
  mxGraphView: typeof mxGraphView,
  mxGraph: typeof mxGraph,
  mxCellOverlay: typeof mxCellOverlay,
  mxOutline: typeof mxOutline,
  mxMultiplicity: typeof mxMultiplicity,
  mxLayoutManager: typeof mxLayoutManager,
  mxSwimlaneManager: typeof mxSwimlaneManager,
  mxTemporaryCellStates: typeof mxTemporaryCellStates,
  mxCellStatePreview: any,
  mxConnectionConstraint: typeof mxConnectionConstraint,
  mxGraphHandler: typeof mxGraphHandler,
  mxPanningHandler: typeof mxPanningHandler,
  mxPopupMenuHandler: typeof mxPopupMenuHandler,
  mxCellMarker: typeof mxCellMarker,
  mxSelectionCellsHandler: typeof mxSelectionCellsHandler,
  mxConnectionHandler: typeof mxConnectionHandler,
  mxConstraintHandler: typeof mxConstraintHandler,
  mxRubberband: typeof mxRubberband,
  mxHandle: any,
  mxVertexHandler: typeof mxVertexHandler,
  mxEdgeHandler: typeof mxEdgeHandler,
  mxElbowEdgeHandler: typeof mxElbowEdgeHandler,
  mxEdgeSegmentHandler: typeof mxEdgeSegmentHandler,
  mxKeyHandler: typeof mxKeyHandler,
  mxTooltipHandler: typeof mxTooltipHandler,
  mxCellTracker: typeof mxCellTracker,
  mxCellHighlight: typeof mxCellHighlight,
  mxDefaultKeyHandler: any,
  mxDefaultPopupMenu: any,
  mxDefaultToolbar: any,
  mxEditor: any,
  mxCodecRegistry: typeof mxCodecRegistry,
  mxCodec: typeof mxCodec,
  mxObjectCodec: typeof mxObjectCodec,
  mxCellCodec: any,
  mxModelCodec: any,
  mxRootChangeCodec: any,
  mxChildChangeCodec: any,
  mxTerminalChangeCodec: any,
  mxGenericChangeCodec: any,
  mxGraphCodec: any,
  mxGraphViewCodec: any,
  mxStylesheetCodec: any,
  mxDefaultKeyHandlerCodec: any,
  mxDefaultToolbarCodec: any,
  mxDefaultPopupMenuCodec: any,
  mxEditorCodec: any,
};

export default function (options: mxGraphOptions) {
  Object.entries(options).forEach(([key, value]) => {
    window[key] = value;
  });
  const mx = mxgraph(options);
  return mx as mxGraphExportObject;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions