workflow底层UI库整合至项目,优化构建逻辑

This commit is contained in:
2026-02-24 11:20:18 +08:00
parent 094b185c49
commit 12accb2575
91 changed files with 6820 additions and 115 deletions

View File

@@ -0,0 +1,5 @@
module.exports = {
"rules": {
"@typescript-eslint/no-explicit-any": ["off"],
}
};

View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="src/main.ts"></script>
</body>
</html>

View File

@@ -0,0 +1,74 @@
{
"name": "@tinyflow-ai/vue",
"version": "1.2.2",
"type": "module",
"keywords": [
"tinyflow",
"ai",
"ai flow",
"agent flow",
"agents flow"
],
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"browser": "./dist/index.umd.js",
"license": "LGPL-3.0-or-later",
"files": [
"dist",
"LICENSE",
"README.md"
],
"scripts": {
"dev": "vite",
"build": "vite build",
"build:watch": "vite build --watch",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"
},
"dependencies": {
"@tinyflow-ai/ui": "workspace:*"
},
"peerDependencies": {
"vue": "^3.5.13"
},
"devDependencies": {
"@types/node": "^22.18.12",
"@vitejs/plugin-vue": "catalog:",
"autoprefixer": "^10.4.21",
"less": "^4.2.2",
"typescript": "^5.6.2",
"vite": "^7.0.4",
"vite-plugin-dts": "^4.5.3",
"vue": "^3.5.13"
},
"imports": {
"#*": [
"./src/*.ts",
"./src/*.vue"
]
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
},
"./dist/index.css": {
"import": "./dist/index.css",
"require": "./dist/index.css"
}
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/tinyflow-ai/tinyflow"
},
"bugs": {
"url": "https://github.com/tinyflow-ai/tinyflow/issues"
},
"homepage": "https://github.com/tinyflow-ai/tinyflow#readme"
}

View File

@@ -0,0 +1,78 @@
<template>
<div ref="divRef" :class="['tinyflow', className]" :style="style" />
</template>
<script setup lang="ts">
import {Tinyflow as TinyflowNative, TinyflowOptions} from '@tinyflow-ai/ui';
import '@tinyflow-ai/ui/dist/index.css';
import {onMounted, onUnmounted, ref} from 'vue';
const props = defineProps<
{
className?: string;
style?: Record<string, string>;
} & Omit<TinyflowOptions, 'element'>
>();
const divRef = ref<HTMLDivElement | null>(null);
let tinyflow: TinyflowNative | null = null;
// 安全深拷贝工具函数
function safeDeepClone<T>(obj: T): T {
if (obj === null || typeof obj !== 'object') return obj;
try {
return structuredClone(obj);
} catch {
try {
return JSON.parse(JSON.stringify(obj));
} catch {
console.warn('Failed to clone object, returning original (may cause issues)', obj);
return obj;
}
}
}
onMounted(() => {
if (divRef.value) {
// 净化 props.data避免响应式对象或函数污染
const cleanedProps = { ...props } as any;
if ('data' in cleanedProps && cleanedProps.data != null) {
cleanedProps.data = safeDeepClone(cleanedProps.data);
}
tinyflow = new TinyflowNative({
...cleanedProps,
element: divRef.value
});
}
});
onUnmounted(() => {
if (tinyflow) {
tinyflow.destroy();
tinyflow = null;
}
});
const getData = () => {
if (tinyflow) {
return tinyflow.getData();
}
console.warn('Tinyflow instance is not initialized');
return null;
};
const getInstance = () => {
if (tinyflow) {
return tinyflow;
}
console.warn('Tinyflow instance is not initialized');
return null;
};
defineExpose({
getData,
getInstance
});
</script>

View File

@@ -0,0 +1,3 @@
import Tinyflow from './Tinyflow.vue';
export { Tinyflow };

View File

@@ -0,0 +1,4 @@
import {createApp} from 'vue'
import App from './Tinyflow.vue'
createApp(App).mount('#app')

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
}

View File

@@ -0,0 +1,4 @@
{
"files": [],
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
}

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "node",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
},
"include": ["vite.config.ts"]
}

View File

@@ -0,0 +1,39 @@
import {defineConfig} from 'vite';
import {resolve} from 'path';
import vue from '@vitejs/plugin-vue';
import dts from 'vite-plugin-dts';
// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: 'dist',
emptyOutDir: true,
minify: true,
sourcemap: true,
cssCodeSplit: true,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
cssFileName: 'index',
fileName: (format) => {
return format === 'umd' ? 'index.umd.js' : 'index.js';
},
formats: ['es', 'umd'],
name: 'Tinyflow'
},
rollupOptions: {
external: ['vue'], // 排除 Vue 作为外部依赖
output: {
globals: {
vue: 'Vue'
}
}
}
},
plugins: [
vue(),
dts({
rollupTypes: true,
tsconfigPath: './tsconfig.app.json'
})
]
});