Skip to content

Commit

Permalink
chore: make diagram options optional
Browse files Browse the repository at this point in the history
* options are optional
* core module is added by default
  • Loading branch information
philippfromme committed Mar 1, 2023
1 parent 6519fd4 commit 2ba1a7f
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/Diagram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type DiagramOptions = {
* @param injector An (optional) injector to bootstrap the diagram with.
*/
export default class Diagram {
constructor(options: DiagramOptions, injector?: Injector);
constructor(options?: DiagramOptions, injector?: Injector);

/**
* Resolves a diagram service.
Expand Down
4 changes: 2 additions & 2 deletions lib/Diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function bootstrap(modules) {
/**
* Creates an injector from passed options.
*
* @param {DiagramOptions} options
* @param {DiagramOptions} [options]
*
* @return {Injector}
*/
Expand Down Expand Up @@ -90,7 +90,7 @@ function createInjector(options) {
*
* // 'shape ... was added to the diagram' logged to console
*
* @param {DiagramOptions} options
* @param {DiagramOptions} [options]
* @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
*/
Expand Down
4 changes: 3 additions & 1 deletion lib/Diagram.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import EventBus from './core/EventBus';
import ModelingModule from './features/modeling';
import Modeling from './features/modeling/Modeling';

const diagram = new Diagram({
let diagram = new Diagram();

diagram = new Diagram({
modules: [
CoreModule,
CommandModule,
Expand Down
7 changes: 1 addition & 6 deletions lib/core/Canvas.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import Diagram from '../Diagram';

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

const diagram = new Diagram({
modules: [
CoreModule
]
});
const diagram = new Diagram();

const shapeLike = {
id: 'shapeLike',
Expand Down
7 changes: 1 addition & 6 deletions lib/core/ElementFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import Diagram from '../Diagram';

import CoreModule from '.';
import ElementFactory from './ElementFactory';

const diagram = new Diagram({
modules: [
CoreModule
]
});
const diagram = new Diagram();

const elementFactory = diagram.get<ElementFactory>('elementFactory');

Expand Down
7 changes: 1 addition & 6 deletions lib/core/ElementRegistry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import Diagram from '../Diagram';

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

const diagram = new Diagram({
modules: [
CoreModule
]
});
const diagram = new Diagram();

const elementFactory = diagram.get<ElementFactory>('elementFactory'),
elementRegistry = diagram.get<ElementRegistry>('elementRegistry'),
Expand Down
7 changes: 1 addition & 6 deletions lib/core/EventBus.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import Diagram from '../Diagram';

import CoreModule from '.';
import EventBus, { Event } from './EventBus';

const diagram = new Diagram({
modules: [
CoreModule
]
});
const diagram = new Diagram();

const eventBus = diagram.get<EventBus>('eventBus');

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

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

const diagram = new Diagram({
modules: [
CoreModule
]
});
const diagram = new Diagram();

const elementFactory = diagram.get<ElementFactory>('elementFactory'),
graphicsFactory = diagram.get<GraphicsFactory>('graphicsFactory');
Expand Down
2 changes: 0 additions & 2 deletions lib/draw/BaseRenderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Base, Connection, Shape } from '../model';

import Diagram from '../Diagram';

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

Expand Down Expand Up @@ -32,7 +31,6 @@ class CustomRenderer extends BaseRenderer {

const diagram = new Diagram({
modules: [
CoreModule,
{
__init__: [ 'customRenderer' ],
customRenderer: [ 'type', CustomRenderer ]
Expand Down
2 changes: 1 addition & 1 deletion lib/features/overlays/Overlays.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Diagram from '../../Diagram';

import OverlaysModule from '.';
import ElementFactory from '../../core/ElementFactory';

import OverlaysModule from '.';
import Overlays, { OverlayAttrs } from './Overlays';

const diagram = new Diagram({
Expand Down

0 comments on commit 2ba1a7f

Please sign in to comment.