Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: separate export default from function declaration #858

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Injector } from 'didi';

import CoreModule from './core';

export default Diagram;

/**
* @typedef {import('didi').InjectionContext} InjectionContext
* @typedef {import('didi').LocalsMap} LocalsMap
Expand Down Expand Up @@ -99,7 +101,7 @@ function createInjector(options) {
* @param {DiagramOptions} [options]
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
*/
export default function Diagram(options, injector) {
export function Diagram(options, injector) {

this._injector = injector = injector || createInjector(options);

Expand Down
4 changes: 3 additions & 1 deletion lib/command/CommandInterceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
isObject
} from 'min-dash';

export default CommandInterceptor;

/**
* @typedef {import('../core/Types').ElementLike} ElementLike
* @typedef {import('../core/EventBus').default} EventBus
Expand Down Expand Up @@ -42,7 +44,7 @@ var DEFAULT_PRIORITY = 1000;
*
* @param {EventBus} eventBus
*/
export default function CommandInterceptor(eventBus) {
export function CommandInterceptor(eventBus) {

/**
* @type {EventBus}
Expand Down
4 changes: 3 additions & 1 deletion lib/command/CommandStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
isArray
} from 'min-dash';

export default CommandStack;

/**
* @typedef {import('didi').Injector} Injector
*
Expand Down Expand Up @@ -107,7 +109,7 @@ import {
* @param {EventBus} eventBus
* @param {Injector} injector
*/
export default function CommandStack(eventBus, injector) {
export function CommandStack(eventBus, injector) {

/**
* A map of all registered command handlers.
Expand Down
4 changes: 3 additions & 1 deletion lib/core/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
import { createMatrix as createMatrix } from 'tiny-svg';


export default Canvas;

/**
* @typedef {import('./Types').ConnectionLike} ConnectionLike
* @typedef {import('./Types').RootLike} RootLike
Expand Down Expand Up @@ -163,7 +165,7 @@ const REQUIRED_MODEL_ATTRS = {
* @param {GraphicsFactory} graphicsFactory
* @param {ElementRegistry} elementRegistry
*/
export default function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
export function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
this._eventBus = eventBus;
this._elementRegistry = elementRegistry;
this._graphicsFactory = graphicsFactory;
Expand Down
4 changes: 3 additions & 1 deletion lib/core/ElementFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {

import { assign } from 'min-dash';

export default ElementFactory;

/**
* @typedef {import('../model/Types').Element} Element
* @typedef {import('../model/Types').Connection} Connection
Expand All @@ -20,7 +22,7 @@ import { assign } from 'min-dash';
* @template {Root} [V=Root]
* @template {Shape} [W=Shape]
*/
export default function ElementFactory() {
export function ElementFactory() {
this._uid = 12;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/core/ElementRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ var ELEMENT_ID = 'data-element-id';

import { attr as svgAttr } from 'tiny-svg';

export default ElementRegistry;

/**
* @typedef {import('./Types').ElementLike} ElementLike
*
Expand All @@ -19,7 +21,7 @@ import { attr as svgAttr } from 'tiny-svg';
*
* @param {EventBus} eventBus
*/
export default function ElementRegistry(eventBus) {
export function ElementRegistry(eventBus) {

/**
* @type { {
Expand Down
4 changes: 3 additions & 1 deletion lib/core/EventBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var DEFAULT_PRIORITY = 1000;

var slice = Array.prototype.slice;

export default EventBus;

/**
* @typedef { {
* stopPropagation(): void;
Expand Down Expand Up @@ -119,7 +121,7 @@ var slice = Array.prototype.slice;
* console.log(sum); // 3
* ```
*/
export default function EventBus() {
export function EventBus() {

/**
* @type { Record<string, EventBusListener> }
Expand Down
4 changes: 3 additions & 1 deletion lib/core/GraphicsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
isFrameElement
} from '../util/Elements';

export default GraphicsFactory;

/**
* @typedef {import('./Types').ConnectionLike} ConnectionLike
* @typedef {import('./Types').ElementLike} ElementLike
Expand All @@ -39,7 +41,7 @@ import {
* @param {EventBus} eventBus
* @param {ElementRegistry} elementRegistry
*/
export default function GraphicsFactory(eventBus, elementRegistry) {
export function GraphicsFactory(eventBus, elementRegistry) {
this._eventBus = eventBus;
this._elementRegistry = elementRegistry;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/draw/BaseRenderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var DEFAULT_RENDER_PRIORITY = 1000;

export default BaseRenderer;

/**
* @typedef {import('../core/Types').ElementLike} Element
* @typedef {import('../core/Types').ConnectionLike} Connection
Expand All @@ -14,7 +16,7 @@ var DEFAULT_RENDER_PRIORITY = 1000;
* @param {EventBus} eventBus
* @param {number} [renderPriority=1000]
*/
export default function BaseRenderer(eventBus, renderPriority) {
export function BaseRenderer(eventBus, renderPriority) {
var self = this;

renderPriority = renderPriority || DEFAULT_RENDER_PRIORITY;
Expand Down
4 changes: 3 additions & 1 deletion lib/draw/DefaultRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
isFrameElement
} from '../util/Elements';

export default DefaultRenderer;

/**
* @typedef {import('../core/EventBus').default} EventBus
* @typedef {import('./Styles').default} Styles
Expand All @@ -34,7 +36,7 @@ var DEFAULT_RENDER_PRIORITY = 1;
* @param {EventBus} eventBus
* @param {Styles} styles
*/
export default function DefaultRenderer(eventBus, styles) {
export function DefaultRenderer(eventBus, styles) {

BaseRenderer.call(this, eventBus, DEFAULT_RENDER_PRIORITY);

Expand Down
4 changes: 3 additions & 1 deletion lib/draw/Styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {
} from 'min-dash';


export default Styles;

/**
* A component that manages shape styles
*/
export default function Styles() {
export function Styles() {

var defaultTraits = {

Expand Down
4 changes: 3 additions & 1 deletion lib/features/align-elements/AlignElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
sortBy
} from 'min-dash';

export default AlignElements;

/**
* @typedef {import('../../model/Types').Element} Element
*
Expand Down Expand Up @@ -51,7 +53,7 @@ var ALIGNMENT_SORTING = {
* @param {Modeling} modeling
* @param {Rules} rules
*/
export default function AlignElements(modeling, rules) {
export function AlignElements(modeling, rules) {
this._modeling = modeling;
this._rules = rules;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/features/attach-support/AttachSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import inherits from 'inherits-browser';

import CommandInterceptor from '../../command/CommandInterceptor';

export default AttachSupport;

/**
* @typedef {import('didi').Injector} Injector
*
Expand Down Expand Up @@ -47,7 +49,7 @@ var MARKER_ATTACH = 'attach-ok';
* @param {Rules} rules
* @param {Modeling} modeling
*/
export default function AttachSupport(injector, eventBus, canvas, rules, modeling) {
export function AttachSupport(injector, eventBus, canvas, rules, modeling) {

CommandInterceptor.call(this, eventBus);

Expand Down
4 changes: 3 additions & 1 deletion lib/features/auto-place/AutoPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {

import { DEFAULT_DISTANCE } from './AutoPlaceUtil';

export default AutoPlace;

/**
* @typedef {import('../../core/Types').ShapeLike} Shape
*
Expand All @@ -26,7 +28,7 @@ var LOW_PRIORITY = 100;
* @param {Modeling} modeling
* @param {Canvas} canvas
*/
export default function AutoPlace(eventBus, modeling, canvas) {
export function AutoPlace(eventBus, modeling, canvas) {

eventBus.on('autoPlace', LOW_PRIORITY, function(context) {
var shape = context.shape,
Expand Down
4 changes: 3 additions & 1 deletion lib/features/auto-place/AutoPlaceSelectionBehavior.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default AutoPlaceSelectionBehavior;

/**
* @typedef {import('../../core/EventBus').default} EventBus
* @typedef {import('../selection/Selection').default} Selection
Expand All @@ -9,7 +11,7 @@
* @param {EventBus} eventBus
* @param {Selection} selection
*/
export default function AutoPlaceSelectionBehavior(eventBus, selection) {
export function AutoPlaceSelectionBehavior(eventBus, selection) {

eventBus.on('autoPlace.end', 500, function(e) {
selection.select(e.shape);
Expand Down
4 changes: 3 additions & 1 deletion lib/features/auto-resize/AutoResize.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {

import CommandInterceptor from '../../command/CommandInterceptor';

export default AutoResize;

/**
* @typedef {import('../../model/Types').Element} Element
* @typedef {import('../../model/Types').Shape} Shape
Expand All @@ -44,7 +46,7 @@ import CommandInterceptor from '../../command/CommandInterceptor';
* @param {Modeling} modeling
* @param {Rules} rules
*/
export default function AutoResize(eventBus, elementRegistry, modeling, rules) {
export function AutoResize(eventBus, elementRegistry, modeling, rules) {

CommandInterceptor.call(this, eventBus);

Expand Down
4 changes: 3 additions & 1 deletion lib/features/auto-resize/AutoResizeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import RuleProvider from '../rules/RuleProvider';

import inherits from 'inherits-browser';

export default AutoResizeProvider;

/**
* @typedef {import('../../model/Types').Shape} Shape
*
Expand All @@ -13,7 +15,7 @@ import inherits from 'inherits-browser';
*
* @param {EventBus} eventBus
*/
export default function AutoResizeProvider(eventBus) {
export function AutoResizeProvider(eventBus) {

RuleProvider.call(this, eventBus);

Expand Down
4 changes: 3 additions & 1 deletion lib/features/auto-scroll/AutoScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
toPoint
} from '../../util/Event';

export default AutoScroll;

/**
* @typedef {import('../../util/Types').Point} Point
*
Expand All @@ -29,7 +31,7 @@ import {
* @param {EventBus} eventBus
* @param {Canvas} canvas
*/
export default function AutoScroll(config, eventBus, canvas) {
export function AutoScroll(config, eventBus, canvas) {

this._canvas = canvas;

Expand Down
4 changes: 3 additions & 1 deletion lib/features/bendpoints/BendpointMove.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { filterRedundantWaypoints } from '../../layout/LayoutUtil';

export default BendpointMove;

/**
* @typedef {import('didi').Injector} Injector
*
Expand Down Expand Up @@ -27,7 +29,7 @@ var RECONNECT_START = 'reconnectStart',
* @param {Rules} rules
* @param {Modeling} modeling
*/
export default function BendpointMove(injector, eventBus, canvas, dragging, rules, modeling) {
export function BendpointMove(injector, eventBus, canvas, dragging, rules, modeling) {
this._injector = injector;

this.start = function(event, connection, bendpointIndex, insert) {
Expand Down
4 changes: 3 additions & 1 deletion lib/features/bendpoints/BendpointMovePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { translate } from '../../util/SvgTransformUtil';

import { isReverse } from './BendpointMove';

export default BendpointMovePreview;

/**
* @typedef {import('didi').Injector} Injector
*
Expand Down Expand Up @@ -37,7 +39,7 @@ var HIGH_PRIORITY = 1100;
* @param {EventBus} eventBus
* @param {Canvas} canvas
*/
export default function BendpointMovePreview(bendpointMove, injector, eventBus, canvas) {
export function BendpointMovePreview(bendpointMove, injector, eventBus, canvas) {
this._injector = injector;

var connectionPreview = injector.get('connectionPreview', false);
Expand Down
4 changes: 3 additions & 1 deletion lib/features/bendpoints/BendpointSnapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { getClosestPointOnConnection } from './BendpointUtil';

import { isConnection } from '../../util/ModelUtil';

export default BendpointSnapping;

/**
* @typedef {import('../../core/EventBus').default} EventBus
*/
Expand All @@ -21,7 +23,7 @@ var TOLERANCE = 10;
/**
* @param {EventBus} eventBus
*/
export default function BendpointSnapping(eventBus) {
export function BendpointSnapping(eventBus) {

function snapTo(values, value) {

Expand Down
4 changes: 3 additions & 1 deletion lib/features/bendpoints/Bendpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import {
translate
} from '../../util/SvgTransformUtil';

export default Bendpoints;

/**
* @typedef {import('../bendpoints/BendpointMove').default} BendpointMove
* @typedef {import('../../core/Canvas').default} Canvas
Expand All @@ -57,7 +59,7 @@ import {
* @param {BendpointMove} bendpointMove
* @param {ConnectionSegmentMove} connectionSegmentMove
*/
export default function Bendpoints(
export function Bendpoints(
eventBus, canvas, interactionEvents,
bendpointMove, connectionSegmentMove) {

Expand Down
Loading