Skip to content

Commit 521ffe4

Browse files
authored
0.3.0. (#9)
1 parent 9b271d2 commit 521ffe4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+531
-378
lines changed

.github/workflows/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- main
6+
- develop
67
jobs:
78
build:
89
name: Build

.gitignore

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
.yarn/
12
build/
23
node_modules/
34
coverage/
45
.vscode/
5-
designer.js
6-
designer.d.ts
7-
designer.js.map
8-
6+
lib/
7+
dist/

CHANGELOG.md

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
11
## 0.3.0
22

3-
This version introduces component extensions. By this it's possible to create own components. Breaking changes:
4-
5-
* Static method `Designer.utils.getParents()` is deleted. You should use the `getStepParents()` method from the `Designer` class. Example: `designer.getStepParents(needleStep)`
6-
* The `ComponentType` is not an enum anymore. It's type (`string`). This change doesn't affect serialized JSONs.
3+
This version introduces new build formats (ESM, UMD) of the package.
4+
5+
🤩 For more advanced use cases we prepared **the paid pro package**. The package is in the early stage. Currently it contains advanced components for steps. [Here](https://github.com/nocode-js/sequential-workflow-designer-pro-demo) you can find more information and examples.
6+
7+
#### Breaking Changes
8+
9+
* Default export of the `Designer` class is removed. Now you should import directly the `Designer` class.
10+
```ts
11+
import { Designer } from 'sequential-workflow-designer';
12+
Designer.create(/* ... */);
13+
```
14+
15+
This affects CDN usage too.
16+
17+
```html
18+
<script src="https://cdn.jsdelivr.net/..."></script>
19+
<script>
20+
sequentialWorkflowDesigner.Designer.create(/* ... */);
21+
</script>
22+
```
23+
* The package now contains two type of build: ESM and UMD. ESM build is located in the `lib` folder. UMD build is located in the `dist` folder. That means the URL to the CDN is also changed.
24+
25+
```html
26+
<script src="https://cdn.jsdelivr.net/.../dist/index.umd.js"></script>
27+
```
28+
* Static method `Designer.utils.nextId()` is deleted. You should use the `next()` from the `Uid` class. Example:
29+
30+
```ts
31+
import { Uid } from 'sequential-workflow-designer';
32+
Uid.next();
33+
```
34+
35+
* Static method `Designer.utils.getParents()` is deleted. You should use the `getStepParents()` method from the `Designer` class. Example:
36+
37+
```ts
38+
designer.getStepParents(needleStep);
39+
```
40+
* The `ComponentType` is not an enum anymore. It's a type (`string`). This change doesn't affect serialized JSONs.
741

842
## 0.2.3
943

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2022 Bartlomiej Tadych
3+
Copyright (c) 2022 N4NO.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Sequential Workflow Designer
44

5-
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fb4rtaz%2Fsequential-workflow-designer%2Fbadge%3Fref%3Dmain&style=flat-square)](https://actions-badge.atrox.dev/b4rtaz/sequential-workflow-designer/goto?ref=main) [![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](/LICENSE) [![View this project on NPM](https://img.shields.io/npm/v/sequential-workflow-designer.svg)](https://npmjs.org/package/sequential-workflow-designer) [![Twitter: b4rtaz](https://img.shields.io/twitter/follow/b4rtaz.svg?style=social)](https://twitter.com/b4rtaz)
5+
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fb4rtaz%2Fsequential-workflow-designer%2Fbadge%3Fref%3Dmain&style=flat-square)](https://actions-badge.atrox.dev/b4rtaz/sequential-workflow-designer/goto?ref=main) [![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](/LICENSE) [![View this project on NPM](https://img.shields.io/npm/v/sequential-workflow-designer.svg)](https://npmjs.org/package/sequential-workflow-designer)
66

77
Sequential workflow designer with no dependencies for web. It's written in pure TypeScript and uses SVG for rendering. This designer is not associated with any workflow engine. It's full generic. You may create any kind application by this, from graphical programming languages to workflow designers.
88

@@ -37,7 +37,7 @@ Install this package by [NPM](https://www.npmjs.com/) command:
3737
To import the package:
3838

3939
```ts
40-
import Designer from 'sequential-workflow-designer';
40+
import { Designer } from 'sequential-workflow-designer';
4141
```
4242

4343
If you use [css-loader](https://webpack.js.org/loaders/css-loader/) or similar, you can add CSS files to your boundle:
@@ -62,24 +62,24 @@ Add the below code to your head section in HTML document.
6262
```html
6363
<head>
6464
...
65-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.3/css/designer.css" rel="stylesheet">
66-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.3/css/designer-light.css" rel="stylesheet">
67-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.3/css/designer-dark.css" rel="stylesheet">
68-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.3/lib/designer.js"></script>
65+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.3.0/css/designer.css" rel="stylesheet">
66+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.3.0/css/designer-light.css" rel="stylesheet">
67+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.3.0/css/designer-dark.css" rel="stylesheet">
68+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.3.0/dist/index.umd.js"></script>
6969
```
7070

7171
Call the designer by:
7272

7373
```js
74-
sequentialWorkflowDesigner.create(placeholder, definition, configuration);
74+
sequentialWorkflowDesigner.Designer.create(placeholder, definition, configuration);
7575
```
7676

7777
## 🎬 Usage
7878

7979
Check [examples](/examples) directory.
8080

8181
```ts
82-
import Designer from 'sequential-workflow-designer';
82+
import { Designer } from 'sequential-workflow-designer';
8383

8484
const placeholder = document.getElementById('placeholder');
8585

designer/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
README.md
2+
LICENSE

designer/package.json

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
22
"name": "sequential-workflow-designer",
3-
"version": "0.2.3",
4-
"main": "./lib/designer.js",
5-
"types": "./lib/designer.d.ts",
3+
"version": "0.3.0",
4+
"main": "./lib/index.mjs",
5+
"types": "./lib/index.d.ts",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/b4rtaz/sequential-workflow-designer.git"
8+
"url": "https://github.com/nocode-js/sequential-workflow-designer.git"
99
},
1010
"files": [
1111
"lib/",
12+
"dist/",
1213
"css/"
1314
],
1415
"publishConfig": {
1516
"registry": "https://registry.npmjs.org/"
1617
},
1718
"scripts": {
19+
"prepare": "cp ../LICENSE LICENSE && cp ../README.md README.md",
1820
"start": "rollup -c --watch",
1921
"start:clean": "rm -rf lib && rm -rf build && npm run start",
2022
"build": "rollup -c",
@@ -24,23 +26,23 @@
2426
"prettier": "prettier --check ./src",
2527
"prettier:fix": "prettier --write ./src"
2628
},
27-
"author": "b4rtaz",
29+
"author": "N4NO.com",
2830
"license": "MIT",
2931
"devDependencies": {
30-
"@types/jasmine": "^4.0.3",
31-
"@typescript-eslint/eslint-plugin": "^5.40.0",
32-
"@typescript-eslint/parser": "^5.40.0",
33-
"eslint": "^8.25.0",
34-
"karma": "^6.3.20",
32+
"@types/jasmine": "^4.3.1",
33+
"@typescript-eslint/eslint-plugin": "^5.47.0",
34+
"@typescript-eslint/parser": "^5.47.0",
35+
"eslint": "^8.30.0",
36+
"karma": "^6.4.1",
3537
"karma-chrome-launcher": "^3.1.1",
36-
"karma-jasmine": "^5.0.1",
37-
"karma-spec-reporter": "^0.0.34",
38+
"karma-jasmine": "^5.1.0",
39+
"karma-spec-reporter": "^0.0.36",
3840
"karma-typescript": "^5.5.3",
39-
"prettier": "^2.6.2",
40-
"rollup": "^2.75.3",
41-
"rollup-plugin-dts": "^4.2.2",
41+
"prettier": "^2.8.1",
42+
"rollup": "^3.7.5",
43+
"rollup-plugin-dts": "^5.0.0",
4244
"rollup-plugin-typescript2": "^0.34.1",
43-
"typescript": "^4.8.4"
45+
"typescript": "^4.9.4"
4446
},
4547
"keywords": [
4648
"workflow",

designer/rollup.config.js

-30
This file was deleted.

designer/rollup.config.mjs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import dts from 'rollup-plugin-dts';
2+
import typescript from 'rollup-plugin-typescript2';
3+
4+
const ts = typescript({
5+
useTsconfigDeclarationDir: true
6+
});
7+
8+
export default [
9+
{
10+
input: './src/index.ts',
11+
plugins: [ts],
12+
output: [
13+
{
14+
file: './lib/index.mjs',
15+
format: 'es'
16+
}
17+
]
18+
},
19+
{
20+
input: './src/index.ts',
21+
plugins: [ts],
22+
output: [
23+
{
24+
file: './dist/index.umd.js',
25+
format: 'umd',
26+
name: 'sequentialWorkflowDesigner'
27+
}
28+
]
29+
},
30+
{
31+
input: './build/index.d.ts',
32+
output: [
33+
{
34+
file: './lib/index.d.ts',
35+
format: 'es'
36+
}
37+
],
38+
plugins: [dts()],
39+
}
40+
];

designer/src/core/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './dom';
2+
export * from './vector';
3+
export * from './uid';

designer/src/core/steps-traverser.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('StepsTraverser', () => {
4949
let traverser: StepsTraverser;
5050

5151
beforeAll(() => {
52-
const extensions = StepExtensionsResolver.resolve({});
52+
const extensions = StepExtensionsResolver.resolve([]);
5353
traverser = new StepsTraverser(extensions);
5454
});
5555

designer/src/core/steps-traverser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class StepsTraverser {
2222
const children = extension.getChildren(step);
2323
if (children) {
2424
switch (children.type) {
25-
case StepChildrenType.sequence:
25+
case StepChildrenType.singleSequence:
2626
{
2727
const sequence = children.sequences as Sequence;
2828
if (

designer/src/designer-configuration.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface DesignerConfiguration {
1010
toolbox: ToolboxConfiguration;
1111
steps: StepsConfiguration;
1212
editors: EditorsConfiguration;
13+
14+
extensions?: DesignerExtension[];
1315
}
1416

1517
export interface ToolboxConfiguration {
@@ -25,8 +27,6 @@ export interface ToolboxGroupConfiguration {
2527
}
2628

2729
export interface StepsConfiguration {
28-
extensions?: StepExtension[];
29-
3030
canInsertStep?: (step: Step, targetSequence: Sequence, targetIndex: number) => boolean;
3131
canMoveStep?: (sourceSequence: Sequence, step: Step, targetSequence: Sequence, targetIndex: number) => boolean;
3232
canDeleteStep?: (step: Step, parentSequence: Sequence) => boolean;
@@ -35,6 +35,11 @@ export interface StepsConfiguration {
3535
validator?: StepValidator;
3636
}
3737

38+
export interface DesignerExtension {
39+
name: string;
40+
steps: StepExtension[];
41+
}
42+
3843
export interface StepExtension<S extends Step = Step> {
3944
componentType: ComponentType;
4045
createComponent(parentElement: SVGElement, step: S, parentSequence: Sequence, componentContext: ComponentContext): StepComponent;
@@ -47,7 +52,7 @@ export interface StepChildren {
4752
}
4853

4954
export enum StepChildrenType {
50-
sequence = 1,
55+
singleSequence = 1,
5156
branches = 2
5257
}
5358

designer/src/designer.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ControlBar } from './control-bar/control-bar';
22
import { Dom } from './core/dom';
3-
import Designer from './designer';
3+
import { Designer } from './designer';
44
import { SmartEditor } from './smart-editor/smart-editor';
55
import { createDefinitionStub, createDesignerConfigurationStub } from './test-tools/stubs';
66
import { Toolbox } from './toolbox/toolbox';

designer/src/designer.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@ import { Definition, Sequence, Step } from './definition';
33
import { DesignerConfiguration } from './designer-configuration';
44
import { DesignerContext } from './designer-context';
55
import { DesignerView } from './designer-view';
6-
import { Utils } from './utils';
76
import { DesignerState } from './designer-state';
87
import { DefinitionModifier } from './definition-modifier';
98
import { WorkspaceController } from './workspace/workspace-controller';
109
import { ComponentContext } from './workspace/component-context';
1110
import { StepExtensionsResolver } from './workspace/step-extensions-resolver';
1211
import { StepsTraverser } from './core/steps-traverser';
1312

14-
export default class Designer {
15-
public static readonly utils = Utils;
16-
17-
public static create(parent: HTMLElement, startDefinition: Definition, configuration: DesignerConfiguration): Designer {
18-
const stepExtensions = StepExtensionsResolver.resolve(configuration.steps);
19-
20-
const designerContext = DesignerContext.create(parent, startDefinition, configuration, stepExtensions);
13+
export class Designer {
14+
/**
15+
* Creates a designer.
16+
* @param placeholder Placeholder where a designer will be attached.
17+
* @param startDefinition Start definition of a flow.
18+
* @param configuration Designer's configuration.
19+
* @returns An instance of a designer.
20+
*/
21+
public static create(placeholder: HTMLElement, startDefinition: Definition, configuration: DesignerConfiguration): Designer {
22+
const stepExtensions = StepExtensionsResolver.resolve(configuration.extensions);
23+
24+
const designerContext = DesignerContext.create(placeholder, startDefinition, configuration, stepExtensions);
2125
const componentContext = ComponentContext.create(configuration.steps, stepExtensions);
2226

23-
const view = DesignerView.create(parent, designerContext, componentContext, designerContext.layoutController, configuration);
27+
const view = DesignerView.create(placeholder, designerContext, componentContext, designerContext.layoutController, configuration);
2428
const designer = new Designer(
2529
view,
2630
designerContext.state,

designer/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './core';
2+
export * from './workspace';
3+
export * from './definition';
4+
export * from './designer-configuration';
5+
export * from './designer';

designer/src/test-tools/stubs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export function createDefinitionStub(): Definition {
3636

3737
export function createDesignerContextStub(): DesignerContext {
3838
const parent = document.createElement('div');
39-
const extensions = StepExtensionsResolver.resolve({});
39+
const extensions = StepExtensionsResolver.resolve([]);
4040
return DesignerContext.create(parent, createDefinitionStub(), createDesignerConfigurationStub(), extensions);
4141
}
4242

4343
export function createComponentContextStub(): ComponentContext {
44-
const extensions = StepExtensionsResolver.resolve({});
44+
const extensions = StepExtensionsResolver.resolve([]);
4545
return ComponentContext.create(createDesignerConfigurationStub().steps, extensions);
4646
}

designer/src/utils.spec.ts

-7
This file was deleted.

0 commit comments

Comments
 (0)