Skip to content

Commit

Permalink
chore: import explicit files
Browse files Browse the repository at this point in the history
This prepares us to migrate diagram-js to an ES module.

Related to #863
  • Loading branch information
nikku committed Mar 12, 2024
1 parent 7cfc91d commit a675bd7
Show file tree
Hide file tree
Showing 217 changed files with 1,049 additions and 1,049 deletions.
2 changes: 1 addition & 1 deletion lib/Diagram.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injector } from 'didi';

import CoreModule from './core';
import CoreModule from './core/index.js';

/**
* @typedef {import('didi').InjectionContext} InjectionContext
Expand Down
12 changes: 6 additions & 6 deletions lib/Diagram.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Diagram from './Diagram';
import Diagram from './Diagram.js';

import CommandModule from './command';
import CommandModule from './command/index.js';

import CoreModule from './core';
import EventBus from './core/EventBus';
import CoreModule from './core/index.js';
import EventBus from './core/EventBus.js';

import ModelingModule from './features/modeling';
import Modeling from './features/modeling/Modeling';
import ModelingModule from './features/modeling/index.js';
import Modeling from './features/modeling/Modeling.js';

let diagram = new Diagram();

Expand Down
6 changes: 3 additions & 3 deletions lib/command/CommandHandler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CommandHandler from './CommandHandler';
import { CommandContext } from './CommandStack';
import CommandHandler from './CommandHandler.js';
import { CommandContext } from './CommandStack.js';

import Canvas from '../core/Canvas';
import Canvas from '../core/Canvas.js';

export class AddShapeHandler implements CommandHandler {
private _canvas: Canvas;
Expand Down
4 changes: 2 additions & 2 deletions lib/command/CommandHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ElementLike } from "../core/Types";
import { CommandContext } from "./CommandStack";
import { ElementLike } from '../core/Types.js';
import { CommandContext } from './CommandStack.js';

/**
* A command handler that may be registered via
Expand Down
8 changes: 4 additions & 4 deletions lib/command/CommandInterceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
} from 'min-dash';

/**
* @typedef {import('../core/Types').ElementLike} ElementLike
* @typedef {import('../core/EventBus').default} EventBus
* @typedef {import('./CommandStack').CommandContext} CommandContext
* @typedef {import('../core/Types.js').ElementLike} ElementLike
* @typedef {import('../core/EventBus.js').default} EventBus
* @typedef {import('./CommandStack.js').CommandContext} CommandContext
*
* @typedef {string|string[]} Events
* @typedef { (context: CommandContext) => ElementLike[] | void } HandlerFunction
Expand All @@ -28,7 +28,7 @@ var DEFAULT_PRIORITY = 1000;
* @example
*
* ```javascript
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor.js';
*
* class CommandLogger extends CommandInterceptor {
* constructor(eventBus) {
Expand Down
6 changes: 3 additions & 3 deletions lib/command/CommandInterceptor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import CommandInterceptor from './CommandInterceptor';
import CommandInterceptor from './CommandInterceptor.js';

import EventBus from '../core/EventBus';
import EventBus from '../core/EventBus.js';

import Modeling from '../features/modeling/Modeling';
import Modeling from '../features/modeling/Modeling.js';

export class AddShapeBehavior extends CommandInterceptor {
static $inject = [ 'eventBus', 'modeling' ];
Expand Down
6 changes: 3 additions & 3 deletions lib/command/CommandStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
/**
* @typedef {import('didi').Injector} Injector
*
* @typedef {import('../core/Types').ElementLike} ElementLike
* @typedef {import('../core/Types.js').ElementLike} ElementLike
*
* @typedef {import('../core/EventBus').default} EventBus
* @typedef {import('./CommandHandler').default} CommandHandler
* @typedef {import('../core/EventBus.js').default} EventBus
* @typedef {import('./CommandHandler.js').default} CommandHandler
*
* @typedef { any } CommandContext
* @typedef { {
Expand Down
8 changes: 4 additions & 4 deletions lib/command/CommandStack.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import CommandModule from '.';
import CommandStack from './CommandStack';
import CommandModule from './index.js';
import CommandStack from './CommandStack.js';

import { AddShapeHandler } from './CommandHandler.spec';
import { AddShapeHandler } from './CommandHandler.spec.js';

const diagram = new Diagram({
modules: [
Expand Down
2 changes: 1 addition & 1 deletion lib/command/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CommandStack from './CommandStack';
import CommandStack from './CommandStack.js';

/**
* @type { import('didi').ModuleDeclaration }
Expand Down
28 changes: 14 additions & 14 deletions lib/core/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import {
import {
add as collectionAdd,
remove as collectionRemove
} from '../util/Collections';
} from '../util/Collections.js';

import {
getType,
getBBox as getBoundingBox
} from '../util/Elements';
} from '../util/Elements.js';

import { asTRBL } from '../layout/LayoutUtil';
import { asTRBL } from '../layout/LayoutUtil.js';

import {
append as svgAppend,
Expand All @@ -38,10 +38,10 @@ import { createMatrix as createMatrix } from 'tiny-svg';


/**
* @typedef {import('./Types').ConnectionLike} ConnectionLike
* @typedef {import('./Types').RootLike} RootLike
* @typedef {import('./Types').ParentLike } ParentLike
* @typedef {import('./Types').ShapeLike} ShapeLike
* @typedef {import('./Types.js').ConnectionLike} ConnectionLike
* @typedef {import('./Types.js').RootLike} RootLike
* @typedef {import('./Types.js').ParentLike } ParentLike
* @typedef {import('./Types.js').ShapeLike} ShapeLike
*
* @typedef { {
* container?: HTMLElement;
Expand All @@ -67,14 +67,14 @@ import { createMatrix as createMatrix } from 'tiny-svg';
* outer: Dimensions;
* } & Rect } CanvasViewbox
*
* @typedef {import('./ElementRegistry').default} ElementRegistry
* @typedef {import('./EventBus').default} EventBus
* @typedef {import('./GraphicsFactory').default} GraphicsFactory
* @typedef {import('./ElementRegistry.js').default} ElementRegistry
* @typedef {import('./EventBus.js').default} EventBus
* @typedef {import('./GraphicsFactory.js').default} GraphicsFactory
*
* @typedef {import('../util/Types').Dimensions} Dimensions
* @typedef {import('../util/Types').Point} Point
* @typedef {import('../util/Types').Rect} Rect
* @typedef {import('../util/Types').RectTRBL} RectTRBL
* @typedef {import('../util/Types.js').Dimensions} Dimensions
* @typedef {import('../util/Types.js').Point} Point
* @typedef {import('../util/Types.js').Rect} Rect
* @typedef {import('../util/Types.js').RectTRBL} RectTRBL
*/

function round(number, resolution) {
Expand Down
6 changes: 3 additions & 3 deletions lib/core/Canvas.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import Canvas from './Canvas';
import ElementFactory from './ElementFactory';
import Canvas from './Canvas.js';
import ElementFactory from './ElementFactory.js';

const diagram = new Diagram();

Expand Down
12 changes: 6 additions & 6 deletions lib/core/ElementFactory.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
create
} from '../model';
} from '../model/index.js';

import { assign } from 'min-dash';

/**
* @typedef {import('../model/Types').Element} Element
* @typedef {import('../model/Types').Connection} Connection
* @typedef {import('../model/Types').Label} Label
* @typedef {import('../model/Types').Root} Root
* @typedef {import('../model/Types').Shape} Shape
* @typedef {import('../model/Types.js').Element} Element
* @typedef {import('../model/Types.js').Connection} Connection
* @typedef {import('../model/Types.js').Label} Label
* @typedef {import('../model/Types.js').Root} Root
* @typedef {import('../model/Types.js').Shape} Shape
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/core/ElementFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import ElementFactory from './ElementFactory';
import ElementFactory from './ElementFactory.js';

import {
Connection,
Label,
Root,
Shape
} from '../model/Types';
} from '../model/Types.js';

const diagram = new Diagram();

Expand Down
4 changes: 2 additions & 2 deletions lib/core/ElementRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ var ELEMENT_ID = 'data-element-id';
import { attr as svgAttr } from 'tiny-svg';

/**
* @typedef {import('./Types').ElementLike} ElementLike
* @typedef {import('./Types.js').ElementLike} ElementLike
*
* @typedef {import('./EventBus').default} EventBus
* @typedef {import('./EventBus.js').default} EventBus
*
* @typedef { (element: ElementLike, gfx: SVGElement) => boolean|any } ElementRegistryFilterCallback
* @typedef { (element: ElementLike, gfx: SVGElement) => any } ElementRegistryForEachCallback
Expand Down
8 changes: 4 additions & 4 deletions lib/core/ElementRegistry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import ElementFactory from './ElementFactory';
import ElementRegistry from './ElementRegistry';
import GraphicsFactory from './GraphicsFactory';
import ElementFactory from './ElementFactory.js';
import ElementRegistry from './ElementRegistry.js';
import GraphicsFactory from './GraphicsFactory.js';

const diagram = new Diagram();

Expand Down
4 changes: 2 additions & 2 deletions lib/core/EventBus.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import EventBus from './EventBus';
import EventBus from './EventBus.js';

const diagram = new Diagram();

Expand Down
16 changes: 8 additions & 8 deletions lib/core/GraphicsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
import {
getChildren,
getVisual
} from '../util/GraphicsUtil';
} from '../util/GraphicsUtil.js';

import { translate } from '../util/SvgTransformUtil';
import { translate } from '../util/SvgTransformUtil.js';

import { clear as domClear } from 'min-dom';

Expand All @@ -22,15 +22,15 @@ import {

import {
isFrameElement
} from '../util/Elements';
} from '../util/Elements.js';

/**
* @typedef {import('./Types').ConnectionLike} ConnectionLike
* @typedef {import('./Types').ElementLike} ElementLike
* @typedef {import('./Types').ShapeLike} ShapeLike
* @typedef {import('./Types.js').ConnectionLike} ConnectionLike
* @typedef {import('./Types.js').ElementLike} ElementLike
* @typedef {import('./Types.js').ShapeLike} ShapeLike
*
* @typedef {import('./ElementRegistry').default} ElementRegistry
* @typedef {import('./EventBus').default} EventBus
* @typedef {import('./ElementRegistry.js').default} ElementRegistry
* @typedef {import('./EventBus.js').default} EventBus
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/core/GraphicsFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import ElementFactory from './ElementFactory';
import GraphicsFactory from './GraphicsFactory';
import ElementFactory from './ElementFactory.js';
import GraphicsFactory from './GraphicsFactory.js';

const diagram = new Diagram();

Expand Down
2 changes: 1 addition & 1 deletion lib/core/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export type {
RootLike,
ConnectionLike,
LabelLike
} from '../model/Types';
} from '../model/Types.js';
12 changes: 6 additions & 6 deletions lib/core/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import DrawModule from '../draw';
import DrawModule from '../draw/index.js';

import Canvas from './Canvas';
import ElementRegistry from './ElementRegistry';
import ElementFactory from './ElementFactory';
import EventBus from './EventBus';
import GraphicsFactory from './GraphicsFactory';
import Canvas from './Canvas.js';
import ElementRegistry from './ElementRegistry.js';
import ElementFactory from './ElementFactory.js';
import EventBus from './EventBus.js';
import GraphicsFactory from './GraphicsFactory.js';

/**
* @type { import('didi').ModuleDeclaration }
Expand Down
8 changes: 4 additions & 4 deletions lib/draw/BaseRenderer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var DEFAULT_RENDER_PRIORITY = 1000;

/**
* @typedef {import('../core/Types').ElementLike} Element
* @typedef {import('../core/Types').ConnectionLike} Connection
* @typedef {import('../core/Types').ShapeLike} Shape
* @typedef {import('../core/Types.js').ElementLike} Element
* @typedef {import('../core/Types.js').ConnectionLike} Connection
* @typedef {import('../core/Types.js').ShapeLike} Shape
*
* @typedef {import('../core/EventBus').default} EventBus
* @typedef {import('../core/EventBus.js').default} EventBus
*/

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/draw/BaseRenderer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Element, Connection, Shape } from '../model';
import { Element, Connection, Shape } from '../model/index.js';

import Diagram from '../Diagram';
import Diagram from '../Diagram.js';

import ElementFactory from '../core/ElementFactory';
import GraphicsFactory from '../core/GraphicsFactory';
import ElementFactory from '../core/ElementFactory.js';
import GraphicsFactory from '../core/GraphicsFactory.js';

import BaseRenderer from './BaseRenderer';
import BaseRenderer from './BaseRenderer.js';

class CustomRenderer extends BaseRenderer {
canRender(element: Element): boolean {
Expand Down
10 changes: 5 additions & 5 deletions lib/draw/DefaultRenderer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import inherits from 'inherits-browser';

import BaseRenderer from './BaseRenderer';
import BaseRenderer from './BaseRenderer.js';

import {
componentsToPath,
createLine
} from '../util/RenderUtil';
} from '../util/RenderUtil.js';

import {
append as svgAppend,
Expand All @@ -17,11 +17,11 @@ import { assign } from 'min-dash';

import {
isFrameElement
} from '../util/Elements';
} from '../util/Elements.js';

/**
* @typedef {import('../core/EventBus').default} EventBus
* @typedef {import('./Styles').default} Styles
* @typedef {import('../core/EventBus.js').default} EventBus
* @typedef {import('./Styles.js').default} Styles
*/

// apply default renderer with lowest possible priority
Expand Down
8 changes: 4 additions & 4 deletions lib/draw/DefaultRenderer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Diagram from "../Diagram";
import Diagram from '../Diagram.js';

import DefaultRenderer from "./DefaultRenderer";
import DefaultRenderer from './DefaultRenderer.js';

import ElementFactory from "../core/ElementFactory";
import GraphicsFactory from "../core/GraphicsFactory";
import ElementFactory from '../core/ElementFactory.js';
import GraphicsFactory from '../core/GraphicsFactory.js';

const diagram = new Diagram();

Expand Down
Loading

0 comments on commit a675bd7

Please sign in to comment.