update: use vue-demi again to add compatability to vue2

* add vite.config.app.ts for demo generation
This commit is contained in:
Braks
2021-07-10 11:51:01 +02:00
parent 6a5496c60f
commit 92caccfd6e
39 changed files with 67 additions and 42 deletions

2
.gitignore vendored
View File

@@ -95,3 +95,5 @@ hasura/db_data/
# Codegen types
types/types.ts
build

View File

@@ -8,7 +8,8 @@
},
"license": "MIT",
"author": "Burak Cakmakoglu",
"main": "dist/revue-flow.es.js",
"main": "dist/index.js",
"module": "dist/revue-flow.es.js",
"types": "dist/index.d.ts",
"files": [
"dist",
@@ -18,6 +19,7 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build && yarn build:dist",
"build:dist": "rollup -c --environment NODE_ENV:production",
"build:app": "vite build -c vite.config.app.ts",
"serve": "vite preview",
"prepublishOnly": "yarn build",
"test": "exit 0;",
@@ -31,7 +33,7 @@
"d3-zoom": "^3.0.0",
"fast-deep-equal": "^3.1.3",
"pinia": "^2.0.0-beta.3",
"vue": "^3.0.5"
"vue-demi": "latest"
},
"devDependencies": {
"@babel/core": "^7.14.6",
@@ -67,7 +69,12 @@
"rollup-plugin-typescript2": "^0.30.0",
"typescript": "^4.3.5",
"vite": "^2.3.8",
"vue-tsc": "^0.0.24"
"vue-tsc": "^0.0.24",
"vue": "^3.0.5"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.13",
"vue": "^2.6.0 || >=3.0.5"
},
"publishConfig": {
"access": "public",

View File

@@ -14,7 +14,7 @@ const processEnv = isProd || isTesting ? 'production' : 'development';
export const baseConfig = ({ injectCSS = true } = {}) => ({
input: 'src/index.ts',
external: ['vue', (id) => id.includes('@babel/runtime')],
external: ['vue-demi', (id) => id.includes('@babel/runtime')],
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);

View File

@@ -6,7 +6,7 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { defineComponent } from 'vue-demi';
import Basic from './Basic';
export default defineComponent({

View File

@@ -2,7 +2,7 @@ import { Connection, Edge, Elements, FlowElement, Node, OnLoadParams } from './t
import { addEdge, isNode, removeElements } from './utils/graph';
import RevueFlow from './container/RevueFlow';
import { MiniMap, Controls, Background } from './additional-components';
import { defineComponent, ref } from 'vue';
import { defineComponent, ref } from 'vue-demi';
const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node);
const onElementClick = (_: MouseEvent, element: FlowElement) => console.log('click', element);

View File

@@ -1,6 +1,6 @@
import { BackgroundVariant } from '../../types';
import { createGridDotsPath, createGridLinesPath } from './utils';
import { computed, defineComponent, HTMLAttributes, PropType } from 'vue';
import { computed, defineComponent, HTMLAttributes, PropType } from 'vue-demi';
import store from '../../store';
export interface BackgroundProps extends HTMLAttributes {

View File

@@ -1,6 +1,6 @@
import useZoomPanHelper from '../../hooks/useZoomPanHelper';
import { FitViewParams } from '../../types';
import { defineComponent, HTMLAttributes, onMounted, PropType, ref } from 'vue';
import { defineComponent, HTMLAttributes, onMounted, PropType, ref } from 'vue-demi';
import store from '../../store';
export interface ControlProps extends HTMLAttributes {

View File

@@ -1,4 +1,4 @@
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
interface MiniMapNodeProps {
x: number;

View File

@@ -1,7 +1,7 @@
import { getRectOfNodes, getBoundsofRects } from '../../utils/graph';
import { Node, Rect } from '../../types';
import MiniMapNode from './MiniMapNode';
import { computed, defineComponent, HTMLAttributes, PropType } from 'vue';
import { computed, defineComponent, HTMLAttributes, PropType } from 'vue-demi';
import store from '../../store';
type StringFunc = (node: Node) => string;

View File

@@ -1,4 +1,4 @@
import { ref, defineComponent, CSSProperties, PropType, computed } from 'vue';
import { ref, defineComponent, CSSProperties, PropType, computed } from 'vue-demi';
import { getBezierPath } from '../Edges/BezierEdge';
import { getSmoothStepPath } from '../Edges/SmoothStepEdge';

View File

@@ -1,4 +1,4 @@
import { computed, CSSProperties, defineComponent, PropType } from 'vue';
import { computed, CSSProperties, defineComponent, PropType } from 'vue-demi';
import EdgeText from './EdgeText';

View File

@@ -1,5 +1,5 @@
import { Position } from '../../types';
import { defineComponent, HTMLAttributes, PropType } from 'vue';
import { defineComponent, HTMLAttributes, PropType } from 'vue-demi';
const shiftX = (x: number, shift: number, position: Position): number => {
if (position === Position.Left) return x - shift;

View File

@@ -1,5 +1,5 @@
import { EdgeTextProps, Rect } from '../../types';
import { defineComponent, PropType, ref, watch } from 'vue';
import { defineComponent, PropType, ref, watch } from 'vue-demi';
const EdgeText = defineComponent({
props: {

View File

@@ -1,4 +1,4 @@
import { defineComponent } from 'vue';
import { defineComponent } from 'vue-demi';
import EdgeText from './EdgeText';
import { getMarkerEnd, getCenter } from './utils';

View File

@@ -1,4 +1,4 @@
import { defineComponent } from 'vue';
import { defineComponent } from 'vue-demi';
import { EdgeSmoothStepProps } from '../../types';
import SmoothStepEdge from './SmoothStepEdge';

View File

@@ -1,4 +1,4 @@
import { defineComponent } from 'vue';
import { defineComponent } from 'vue-demi';
import EdgeText from './EdgeText';
import { getMarkerEnd } from './utils';

View File

@@ -1,4 +1,4 @@
import { Component, computed, defineComponent, ref } from 'vue';
import { Component, computed, defineComponent, ref } from 'vue-demi';
import store from '../../store';
import { Edge, EdgeProps, Position, WrapEdgeProps } from '../../types';

View File

@@ -1,6 +1,6 @@
import { Connection, ElementId, Position } from '../../types';
import { onMouseDown, ValidConnectionFunc } from './handler';
import { defineComponent, inject, PropType } from 'vue';
import { defineComponent, inject, PropType } from 'vue-demi';
import store from '../../store';
const alwaysValid = () => true;

View File

@@ -1,6 +1,6 @@
import Handle from '../../components/Handle';
import { NodeProps, Position } from '../../types';
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
const DefaultNode = defineComponent({
name: 'DefaultNode',

View File

@@ -1,6 +1,6 @@
import Handle from '../../components/Handle';
import { NodeProps, Position } from '../../types';
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
const InputNode = defineComponent({
name: 'InputNode',

View File

@@ -1,6 +1,6 @@
import Handle from '../../components/Handle';
import { NodeProps, Position } from '../../types';
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
const OutputNode = defineComponent({
name: 'OutputNode',

View File

@@ -1,5 +1,5 @@
import { Node, WrapNodeProps } from '../../types';
import { computed, CSSProperties, defineComponent, onMounted, provide, ref } from 'vue';
import { computed, CSSProperties, defineComponent, onMounted, provide, ref } from 'vue-demi';
import store from '../../store';
export default (NodeComponent: any) => {

View File

@@ -2,7 +2,7 @@
* The user selection rectangle gets displayed when a user drags the mouse while pressing shift
*/
import { XYPosition } from '../../types';
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
import store from '../../store';
type UserSelectionProps = {

View File

@@ -1,4 +1,4 @@
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
interface MarkerProps {
id: string;

View File

@@ -13,7 +13,7 @@ import {
Transform,
OnEdgeUpdateFunc
} from '../../types';
import { computed, CSSProperties, defineComponent, PropType } from 'vue';
import { computed, CSSProperties, defineComponent, PropType } from 'vue-demi';
import store from '../../store';
interface EdgeRendererProps {

View File

@@ -3,7 +3,7 @@ import wrapEdge from '../../components/Edges/wrapEdge';
import { rectToBox } from '../../utils/graph';
import { EdgeTypesType, EdgeProps, Position, Node, XYPosition, ElementId, HandleElement, Transform, Edge } from '../../types';
import { Component } from 'vue';
import { Component } from 'vue-demi';
export function createEdgeTypes(edgeTypes: EdgeTypesType): EdgeTypesType {
const standardTypes: EdgeTypesType = {

View File

@@ -1,7 +1,7 @@
import { GraphViewProps } from '../GraphView';
import ZoomPane from '../ZoomPane';
import UserSelection from '../../components/UserSelection';
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue-demi';
import store from '../../store';
type FlowRendererProps = Omit<

View File

@@ -4,7 +4,7 @@ import EdgeRenderer from '../EdgeRenderer';
import { onLoadProject, onLoadGetElements, onLoadToObject } from '../../utils/graph';
import { RevueFlowProps } from '../RevueFlow';
import { NodeTypesType, EdgeTypesType, ConnectionLineType, KeyCode } from '../../types';
import { CSSProperties, defineComponent, onBeforeMount, onMounted, PropType, ref } from 'vue';
import { CSSProperties, defineComponent, onBeforeMount, onMounted, PropType, ref } from 'vue-demi';
import store from '../../store';
import useZoomPanHelper from '../../hooks/useZoomPanHelper';

View File

@@ -1,6 +1,6 @@
import { getNodesInside } from '../../utils/graph';
import { Node, NodeTypesType, Edge } from '../../types';
import { computed, defineComponent, PropType } from 'vue';
import { computed, defineComponent, PropType } from 'vue-demi';
import store from '../../store';
interface NodeRendererProps {

View File

@@ -1,4 +1,4 @@
import { computed, CSSProperties, defineComponent, HTMLAttributes, onUpdated, PropType } from 'vue';
import { computed, CSSProperties, defineComponent, HTMLAttributes, onUpdated, PropType } from 'vue-demi';
import GraphView from '../GraphView';
import DefaultNode from '../../components/Nodes/DefaultNode';
import InputNode from '../../components/Nodes/InputNode';

View File

@@ -3,7 +3,7 @@ import { select, pointer } from 'd3-selection';
import { clamp } from '../../utils';
import { FlowTransform, TranslateExtent, PanOnScrollMode, KeyCode } from '../../types';
import { defineComponent, onMounted, PropType, ref, watch } from 'vue';
import { defineComponent, onMounted, PropType, ref, watch } from 'vue-demi';
import store from '../../store';
import useKeyPress from '../../hooks/useKeyPress';
import useResizeHandler from '../../hooks/useResizeHandler';

View File

@@ -2,7 +2,7 @@ import useKeyPress from './useKeyPress';
import { isNode, getConnectedEdges } from '../utils/graph';
import { Elements, KeyCode, ElementId, FlowElement } from '../types';
import store from '../store';
import { onMounted } from 'vue';
import { onMounted } from 'vue-demi';
interface HookParams {
deleteKeyCode: KeyCode;

View File

@@ -1,6 +1,6 @@
import { isInputDOMNode } from '../utils';
import { KeyCode } from '../types';
import { onMounted, ref } from 'vue';
import { onMounted, ref } from 'vue-demi';
export default (keyCode?: KeyCode): boolean => {
const keyPressed = ref<boolean>(false);

View File

@@ -1,4 +1,4 @@
import { createApp } from 'vue';
import { createApp } from 'vue-demi';
import App from './App.vue';
const app = createApp(App);

2
src/shims-vue.d.ts vendored
View File

@@ -1,5 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue';
import { DefineComponent } from 'vue-demi';
// eslint-disable-next-line @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;

View File

@@ -1,5 +1,5 @@
import { Selection as D3Selection, ZoomBehavior } from 'd3';
import { Component, HTMLAttributes, PropType, VNode } from 'vue';
import { Component, HTMLAttributes, PropType, VNode } from 'vue-demi';
export type ElementId = string;

16
vite.config.app.ts Normal file
View File

@@ -0,0 +1,16 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: 'build'
},
plugins: [
vue(),
vueJsx({
// options are passed on to @vue/babel-plugin-jsx
})
]
});

View File

@@ -13,12 +13,12 @@ export default defineConfig({
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ['vue'],
external: ['vue-demi'],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
'vue': 'Vue'
'vue-demi': 'VueDemi'
},
dir: 'dist',
sourcemap: true,
@@ -28,7 +28,7 @@ export default defineConfig({
}
},
optimizeDeps: {
exclude: ['vue']
exclude: ['vue-demi']
},
plugins: [
vue(),

View File

@@ -6599,9 +6599,9 @@ vite@^2.3.8:
optionalDependencies:
fsevents "~2.3.2"
vue@latest:
vue-demi@latest:
version "0.10.1"
resolved "https://registry.yarnpkg.com/vue/-/vue-0.10.1.tgz#229b81395510f02f4ee255344557a12cc0120930"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.10.1.tgz#229b81395510f02f4ee255344557a12cc0120930"
integrity sha512-L6Oi+BvmMv6YXvqv5rJNCFHEKSVu7llpWWJczqmAQYOdmPPw5PNYoz1KKS//Fxhi+4QP64dsPjtmvnYGo1jemA==
vue-eslint-parser@^7.0.0, vue-eslint-parser@^7.1.1, vue-eslint-parser@^7.6.0: