Skip to content

Commit 223835d

Browse files
committed
Update for yFiles for HTML 2.5
1 parent 45b9dff commit 223835d

17 files changed

+233
-167
lines changed

.eslintrc.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-env node */
2+
require("@rushstack/eslint-patch/modern-module-resolution");
3+
4+
module.exports = {
5+
"root": true,
6+
"extends": [
7+
"plugin:vue/vue3-essential",
8+
"eslint:recommended",
9+
"@vue/eslint-config-typescript/recommended"
10+
]
11+
}

.gitignore

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
.DS_Store
2-
node_modules
3-
/dist
4-
license.json
5-
6-
# local env files
7-
.env.local
8-
.env.*.local
9-
10-
# Log files
1+
# Logs
2+
logs
3+
*.log
114
npm-debug.log*
125
yarn-debug.log*
136
yarn-error.log*
147
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
/cypress/videos/
18+
/cypress/screenshots/
1519

1620
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
1723
.idea
18-
.vscode
1924
*.suo
2025
*.ntvs*
2126
*.njsproj

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<img src="./src/assets/yfiles-logo.svg" alt="yFiles logo" height="100"/>
22

3-
# yFiles integration for Vue CLI
3+
# yFiles integration for create-vue
44

5-
This sample application serves as a basic scaffold of how to integrate [yFiles for HTML](https://www.yworks.com/products/yfiles-for-html) in a [Vue CLI](https://cli.vuejs.org/) application.
5+
This sample application serves as a basic scaffold of how to integrate [yFiles for HTML](https://www.yworks.com/products/yfiles-for-html) in a [create-vue](https://vuejs.org/guide/quick-start.html#with-build-tools) application.
66

77
**To run this project, a valid [yFiles for HTML](https://www.yworks.com/products/yfiles-for-html) version is required. You can evaluate yFiles 60 days free of charge on [my.yworks.com](https://my.yworks.com/signup?product=YFILES_HTML_EVAL).**
88

99
## Version Information
1010

11-
- Vue CLI v4.5
12-
- yFiles for HTML 2.4
11+
- create-vue v3.3
12+
- yFiles for HTML 2.5
1313

1414
## Getting Started
1515

@@ -25,15 +25,15 @@ Then, extract a yFiles Evaluation package beside it and run
2525
npm install
2626
```
2727

28-
You can serve the application on [http://localhost:8080/](http://localhost:8080/) with
28+
You can serve the application on [http://localhost:5173/](http://localhost:5173/) with
2929

3030
```
31-
npm run serve
31+
npm run dev
3232
```
3333

3434
## Under the Hood
3535

36-
This project is a default Vue CLI application, where yFiles was added as an additional dependency to integrate a basic graph component.
36+
This project is a basic create-vue application, where yFiles was added as an additional dependency to integrate a basic graph component.
3737

3838
A step-by-step description of how to integrate yFiles in a Vue application can be found [here](integration-howto.md).
3939

@@ -56,5 +56,5 @@ and customize the interaction with the graph. Generate Vue code for your prototy
5656

5757
## Support
5858

59-
If you need help with your setup or a certain feature, don't hesitate to contact our support
60-
through the [Customer Center](https://my.yworks.com/) or by email [yfileshtml@yworks.com](mailto:yfileshtml@yworks.com).
59+
If you need help with your setup or a certain feature, don't hesitate to contact our support through
60+
the [Customer Center](https://my.yworks.com/) or by email [yfileshtml@yworks.com](mailto:yfileshtml@yworks.com).

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>yfiles-vue-integration</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.ts"></script>
11+
</body>
12+
</html>

integration-howto.md

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,72 @@
22

33
This is a step-by-step description of how to add a yFiles graph component to a basic Vue application.
44

5-
TL;DR Add yFiles as a dependency in the `package.json` and start importing yFiles classes in your project.
5+
TL;DR Add `yfiles` as a dependency in the `package.json`,
6+
[include your license](https://docs.yworks.com/yfileshtml/#/dguide/licensing#_general_concept),
7+
and start importing yFiles classes in your project.
68

7-
## Create a default Vue CLI application
9+
## Create a default create-vue application
810

9-
At first, create a default Vue CLI app by running `> vue create yfiles-vue-integration-basic` with the default option: `default ([Vue 2] babel, eslint)`.
11+
At first, create a basic `create-vue` app by running `> npm init vue@latest`, e.g., with
12+
the following options:
1013

11-
## Add yFiles as a dependency
14+
- `Project name:` yfiles-vue-integration-basic
15+
- `Add TypeScript?` Yes
16+
- `Add JSX Support?` No
17+
- `Add Vue Router for Single Page Application development?` No
18+
- `Add Pinia for state management?` No
19+
- `Add Vitest for Unit testing?` No
20+
- `Add Cypress for both Unit and End-to-End testing?` No
21+
- `Add ESLint for code quality?` Yes
22+
- `Add Prettier for code formatting?` No
1223

13-
Adding yFiles as a dependency is as easy as installing an external library from the npm registry:
24+
## Add yFiles as a dependency
1425

15-
1. Add yFiles for HTML as npm dependency to the created project:
26+
Adding yFiles as a dependency is almost as easy as installing an external library from the npm registry:
1627

17-
- If you have a fresh yFiles for HTML package, you need to prepare the library package first by running `npm install` in the
18-
package folder. This creates the development library and a tarball that can be installed as npm dependency in
19-
other projects. See also [Working with the yFiles npm Module](https://docs.yworks.com/yfileshtml/#/dguide/yfiles_npm_module#yfiles_npm_module).
28+
1. Add yFiles for HTML as npm dependency to the created project, for example like this:
2029

21-
Note: This sample project runs `npm install` as `preinstall` script in the `package.json`.
30+
```
31+
"dependencies": {
32+
...
33+
"yfiles": "../yFiles-for-HTML-Complete-2.5-Evaluation/lib-dev/yfiles-25.0.0+eval-dev.tgz"
34+
},
35+
```
2236

23-
- Reference the packed library in the `package.json` of the project:
24-
```
25-
"dependencies": {
26-
...
27-
"yfiles": "../yFiles-for-HTML-Complete-2.4.0.6-Evaluation/lib-dev/es-modules/yfiles-24.0.6-eval-dev.tgz"
28-
},
29-
```
37+
2. Install the newly added dependency with `npm install`.
3038

31-
2. Now install the newly added dependency with `npm install`.
39+
3. Include your yFiles license by copying the `license.json` file into your project. For more options,
40+
see the [developer's guide](https://docs.yworks.com/yfileshtml/#/dguide/licensing#_general_concept)
3241

33-
After installing the dependency, you can import classes from `yfiles` in your project. Since yFiles is installed as proper npm dependency, IDEs provide full code-completion and automatic imports out of the box to easily work with the library.
42+
After installing the dependency, you can import classes from `yfiles` in your project. Since yFiles
43+
is installed as proper npm dependency, IDEs provide full code-completion and automatic imports out
44+
of the box to easily work with the library.
3445

3546
## Integrate a basic yFiles graph component
3647

3748
With the yFiles dependency, you can easily create a new Vue component with a yFiles graph component.
3849

39-
1. Create a new `GraphComponent.vue` file in `/src/components/` which instantiates a new yFiles graph component and optionally add an input mode for basic editing and a sample graph.
50+
1. Create a new `GraphComponent.vue` file in `/src/components/` which instantiates a new yFiles
51+
graph component and optionally add an input mode for basic editing and a sample graph.
4052

4153
See the contents of `/src/components/GraphComponent.vue` in this repository for the implementation.
4254

43-
There are two things to look out for:
44-
45-
- Make sure to configure your `license.json` for the library. This project assumes that there is a yFiles package next to the project's root. Therefore, you may need to change the referenced path in `GraphComponent.vue`.
55+
Make sure to configure your license data as described above. This project assumes that there is
56+
a yFiles evaluation package with a license file next to the project's root. Otherwise, you need
57+
to change the setting of the license data in `GraphComponent.vue`.
4658

4759
2. Add the new Vue component to the `App.vue` that was created by the Vue CLI.
4860

49-
And that's it. Run `npm run serve` to serve the application with a basic yFiles component.
61+
And that's it. Run `npm run dev` to serve the application with a basic yFiles component.
5062

5163
## Development Mode
5264

53-
This project uses the yFiles development library from the yFiles package. The development library adds additional
54-
type runtime checks to yFiles related method calls and
55-
yields readable exception messages to identify problems in JavaScript code more easily.
56-
For more details see [Development Mode](http://docs.yworks.com/yfileshtml/#/dguide/yfiles_development_mode).
65+
This project uses the yFiles development library from the yFiles package. The development library
66+
adds additional type runtime checks to yFiles related method calls and yields readable exception
67+
messages to identify problems in JavaScript code more easily.
68+
For more details, see the [Development Mode section](http://docs.yworks.com/yfileshtml/#/dguide/yfiles_development_mode).
5769

58-
Please note that these additional checks degrade the performance of the application slightly, therefore it should only be used during development. See also [Preparing the Development Mode Library for Production](https://docs.yworks.com/yfileshtml/#/dguide/deployment#dev-deployment) in Webpack to learn how to switch between development and production mode.
70+
Please note that these additional checks slightly affect the performance of the application,
71+
therefore it should only be used during development.
72+
See also [Preparing the Development Mode Library for Production](https://docs.yworks.com/yfileshtml/#/dguide/deployment#dev-deployment)
73+
in Webpack to learn how to switch between development and production mode.

package.json

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,30 @@
44
"author": "yWorks GmbH <yfileshtml@yworks.com>",
55
"private": true,
66
"scripts": {
7-
"preinstall": "cd ../yFiles-for-HTML-Complete-2.4.0.6-Evaluation && npm run prepare-package",
8-
"postinstall": "node -e \"require('fs').copyFileSync('../yFiles-for-HTML-Complete-2.4.0.6-Evaluation/lib/license.json','./src/license.json')\"",
9-
"serve": "vue-cli-service serve",
10-
"build": "vue-cli-service build",
11-
"lint": "vue-cli-service lint"
7+
"dev": "vite",
8+
"build": "run-p type-check build-only",
9+
"preview": "vite preview --port 4173",
10+
"build-only": "vite build",
11+
"type-check": "vue-tsc --noEmit",
12+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
13+
"postinstall": "npm run copy-eval-license",
14+
"copy-eval-license": "node -e \"require('fs').copyFileSync('../yFiles-for-HTML-Complete-2.5-Evaluation/lib/license.json','./src/license.json')\""
1215
},
1316
"dependencies": {
14-
"core-js": "^3.21.0",
15-
"vue": "^2.6.14",
16-
"yfiles": "../yFiles-for-HTML-Complete-2.4.0.6-Evaluation/lib-dev/es-modules/yfiles-24.0.6-eval-dev.tgz"
17+
"vue": "^3.2.37",
18+
"yfiles": "../yFiles-for-HTML-Complete-2.5-Evaluation/lib-dev/yfiles-25.0.0+eval-dev.tgz"
1719
},
1820
"devDependencies": {
19-
"@vue/cli-plugin-babel": "^4.5.13",
20-
"@vue/cli-plugin-eslint": "^4.5.13",
21-
"@vue/cli-service": "^4.5.13",
22-
"babel-eslint": "^10.1.0",
23-
"eslint": "^6.8.0",
24-
"eslint-plugin-vue": "^7.20.0",
25-
"vue-template-compiler": "^2.6.14"
26-
},
27-
"eslintConfig": {
28-
"root": true,
29-
"env": {
30-
"node": true
31-
},
32-
"extends": [
33-
"plugin:vue/essential",
34-
"eslint:recommended"
35-
],
36-
"rules": {},
37-
"parserOptions": {
38-
"parser": "babel-eslint"
39-
}
40-
},
41-
"browserslist": [
42-
"> 1%",
43-
"last 2 versions"
44-
]
21+
"@rushstack/eslint-patch": "^1.1.0",
22+
"@types/node": "^16.11.45",
23+
"@vitejs/plugin-vue": "^3.0.1",
24+
"@vue/eslint-config-typescript": "^11.0.0",
25+
"@vue/tsconfig": "^0.1.3",
26+
"eslint": "^8.5.0",
27+
"eslint-plugin-vue": "^9.0.0",
28+
"npm-run-all": "^4.1.5",
29+
"typescript": "~4.7.4",
30+
"vite": "^3.0.1",
31+
"vue-tsc": "^0.38.8"
32+
}
4533
}

public/index.html

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/App.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script setup lang="ts">
2+
import GraphComponent from './components/GraphComponent.vue'
3+
</script>
4+
15
<template>
26
<div id="app">
37
<div class="header">
@@ -8,18 +12,7 @@
812
</div>
913
</template>
1014

11-
<script>
12-
import GraphComponent from './components/GraphComponent.vue'
13-
14-
export default {
15-
name: 'app',
16-
components: {
17-
GraphComponent,
18-
},
19-
}
20-
</script>
21-
22-
<style>
15+
<style scoped>
2316
#app {
2417
font-family: 'Avenir', Helvetica, Arial, sans-serif;
2518
-webkit-font-smoothing: antialiased;

0 commit comments

Comments
 (0)