yui-image-editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +8 -0
- package/.gitattributes +1 -0
- package/.nrmrc +1 -0
- package/.oxlintrc.json +10 -0
- package/.prettierrc.json +6 -0
- package/.vscode/extensions.json +11 -0
- package/README.md +73 -0
- package/dist/types/index.d.ts +1 -0
- package/dist-app/assets/css/main-Dn6XCgL-.css +1 -0
- package/dist-app/assets/js/main-Bo-yvzk4.js +3 -0
- package/dist-app/favicon.ico +0 -0
- package/dist-app/index.html +14 -0
- package/e2e/tsconfig.json +4 -0
- package/e2e/vue.spec.ts +8 -0
- package/env.d.ts +1 -0
- package/eslint.config.ts +38 -0
- package/index.html +13 -0
- package/package.json +94 -0
- package/playwright.config.ts +110 -0
- package/public/favicon.ico +0 -0
- package/src/App.vue +165 -0
- package/src/assets/annotation/hjjd.svg +33 -0
- package/src/assets/annotation/kjjd.svg +38 -0
- package/src/assets/annotation/zbz.svg +19 -0
- package/src/assets/base.css +86 -0
- package/src/assets/logo.svg +1 -0
- package/src/assets/main.css +28 -0
- package/src/assets/variable.scss +15 -0
- package/src/components/ImageEditor/index.ts +220 -0
- package/src/components/ImageEditor/index.vue +344 -0
- package/src/components/icons/IconCommunity.vue +7 -0
- package/src/components/icons/IconDocumentation.vue +7 -0
- package/src/components/icons/IconEcosystem.vue +7 -0
- package/src/components/icons/IconSupport.vue +7 -0
- package/src/components/icons/IconTooling.vue +19 -0
- package/src/index.ts +25 -0
- package/src/main.ts +11 -0
- package/src/router/index.ts +30 -0
- package/src/stores/counter.ts +12 -0
- package/src/types/index.ts +196 -0
- package/src/types/tui.d.ts +27 -0
- package/src/utils/specialMapTool.ts +358 -0
- package/src/views/HomeView.vue +12 -0
- package/src/views/MapPluginView.vue +16 -0
- package/src/views/TestView.vue +12 -0
- package/tsconfig.app.json +18 -0
- package/tsconfig.json +14 -0
- package/tsconfig.node.json +28 -0
- package/tsconfig.vitest.json +19 -0
- package/vite.config.ts +124 -0
- package/vitest.config.ts +27 -0
- package/yui-image-editor-1.0.0.tgz +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// TSConfig for modules that run in Node.js environment via either transpilation or type-stripping.
|
|
2
|
+
{
|
|
3
|
+
"extends": "@tsconfig/node24/tsconfig.json",
|
|
4
|
+
"include": [
|
|
5
|
+
"vite.config.*",
|
|
6
|
+
"vitest.config.*",
|
|
7
|
+
"cypress.config.*",
|
|
8
|
+
"nightwatch.conf.*",
|
|
9
|
+
"playwright.config.*",
|
|
10
|
+
"eslint.config.*"
|
|
11
|
+
],
|
|
12
|
+
"compilerOptions": {
|
|
13
|
+
// Most tools use transpilation instead of Node.js's native type-stripping.
|
|
14
|
+
// Bundler mode provides a smoother developer experience.
|
|
15
|
+
"module": "preserve",
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
|
|
18
|
+
// Include Node.js types and avoid accidentally including other `@types/*` packages.
|
|
19
|
+
"types": ["node"],
|
|
20
|
+
|
|
21
|
+
// Disable emitting output during `vue-tsc --build`, which is used for type-checking only.
|
|
22
|
+
"noEmit": true,
|
|
23
|
+
|
|
24
|
+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
|
25
|
+
// Specified here to keep it out of the root directory.
|
|
26
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.app.json",
|
|
3
|
+
|
|
4
|
+
// Override to include only test files and clear exclusions.
|
|
5
|
+
// Application code imported in tests is automatically included via module resolution.
|
|
6
|
+
"include": ["src/**/__tests__/*", "env.d.ts"],
|
|
7
|
+
"exclude": [],
|
|
8
|
+
|
|
9
|
+
"compilerOptions": {
|
|
10
|
+
// Vitest runs in a different environment than the application code.
|
|
11
|
+
// Adjust lib and types accordingly.
|
|
12
|
+
"lib": [],
|
|
13
|
+
"types": ["node", "jsdom"],
|
|
14
|
+
|
|
15
|
+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
|
16
|
+
// Specified here to keep it out of the root directory.
|
|
17
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
5
|
+
import { ConfigEnv, defineConfig, loadEnv, UserConfig } from 'vite';
|
|
6
|
+
import dts from 'vite-plugin-dts';
|
|
7
|
+
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
8
|
+
// 新增:体积分析插件、样式抽离无需额外插件(vite内置)
|
|
9
|
+
// import { visualizer } from 'rollup-plugin-visualizer/es';
|
|
10
|
+
|
|
11
|
+
// 基础配置(不变,抽离公共逻辑)
|
|
12
|
+
const baseConfig: UserConfig = {
|
|
13
|
+
plugins: [vue(), vueJsx(), vueDevTools()],
|
|
14
|
+
resolve: {
|
|
15
|
+
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
|
16
|
+
},
|
|
17
|
+
build: { target: 'es2020', sourcemap: false },
|
|
18
|
+
// 新增:css预处理器配置(若用scss/less,统一配置)
|
|
19
|
+
css: {
|
|
20
|
+
preprocessorOptions: {
|
|
21
|
+
scss: { additionalData: '@import "@/assets/variable.scss";' }, // 全局样式变量
|
|
22
|
+
less: { globalVars: { primary: '#165DFF' } },
|
|
23
|
+
},
|
|
24
|
+
devSourcemap: true, // 开发环境css sourcemap
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 库模式配置(核心优化)
|
|
29
|
+
const libraryConfig: UserConfig = {
|
|
30
|
+
...baseConfig,
|
|
31
|
+
plugins: [
|
|
32
|
+
...(baseConfig.plugins || []),
|
|
33
|
+
// 类型声明优化:精准生成,排除测试文件,自动生成types入口
|
|
34
|
+
dts({
|
|
35
|
+
tsconfigPath: './tsconfig.json',
|
|
36
|
+
outDir: 'dist/types',
|
|
37
|
+
include: ['src/**/*.ts', 'src/**/*.vue', 'src/index.ts'], // 仅包含源码
|
|
38
|
+
exclude: ['src/**/__tests__/**', 'src/**/*.test.ts', 'src/main.ts'], // 排除测试/应用入口
|
|
39
|
+
staticImport: true,
|
|
40
|
+
insertTypesEntry: true, // 生成index.d.ts入口,方便用户类型引入
|
|
41
|
+
cleanVueFileName: true, // 移除vue文件的.d.ts后缀中的.vue
|
|
42
|
+
copyDtsFiles: true, // 复制外部d.ts文件到dist
|
|
43
|
+
}),
|
|
44
|
+
// 新增:包体积分析(执行build时生成stats.html,查看体积占比)
|
|
45
|
+
// visualizer({
|
|
46
|
+
// filename: 'dist/stats.html',
|
|
47
|
+
// open: false,
|
|
48
|
+
// gzipSize: true,
|
|
49
|
+
// brotliSize: true,
|
|
50
|
+
// }),
|
|
51
|
+
],
|
|
52
|
+
build: {
|
|
53
|
+
...baseConfig.build,
|
|
54
|
+
lib: {
|
|
55
|
+
entry: resolve(__dirname, 'src/index.ts'), // 包入口(必须导出所有公共组件/方法)
|
|
56
|
+
name: 'YuiImageEditor', // 改为你的包名(大驼峰,全局变量名)
|
|
57
|
+
fileName: (format) => {
|
|
58
|
+
// 规范包文件名:支持es/cjs/umd,适配不同打包工具
|
|
59
|
+
if (format === 'es') return 'yui-image-editor.esm.js';
|
|
60
|
+
if (format === 'cjs') return 'yui-image-editor.cjs.js';
|
|
61
|
+
return 'yui-image-editor.umd.js';
|
|
62
|
+
},
|
|
63
|
+
formats: ['es', 'umd', 'cjs'], // 保留主流格式,删除不必要的
|
|
64
|
+
},
|
|
65
|
+
rollupOptions: {
|
|
66
|
+
// 优化外部依赖:除了vue,若有vue-router/element-plus等,也加入(避免打包进库)
|
|
67
|
+
external: ['vue', 'vue-router'],
|
|
68
|
+
output: {
|
|
69
|
+
globals: { vue: 'Vue', 'vue-router': 'VueRouter' }, // 对应外部依赖的全局变量
|
|
70
|
+
exports: 'named', // 命名导出,支持import { xxx } from '包名'
|
|
71
|
+
// 新增:库模式样式单独抽离(关键!避免用户使用时样式丢失)
|
|
72
|
+
assetFileNames: 'yui-image-editor.css', // 统一样式文件名,方便用户引入
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
outDir: 'yui-image-editor/dist',
|
|
76
|
+
emptyOutDir: true,
|
|
77
|
+
minify: 'terser',
|
|
78
|
+
// sourcemap: true, // 库模式生成sourcemap,方便用户调试
|
|
79
|
+
// // 新增:关闭css代码分割,合并为单个css文件
|
|
80
|
+
cssCodeSplit: false,
|
|
81
|
+
},
|
|
82
|
+
// 新增:库模式关闭devtools,避免打包冗余代码
|
|
83
|
+
define: { __VUE_DEVTOOLS_GLOBAL_HOOK__: 'undefined' },
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// 应用模式配置(现有逻辑微调,保持本地开发体验)
|
|
87
|
+
const appConfig: UserConfig = {
|
|
88
|
+
...baseConfig,
|
|
89
|
+
base: './',
|
|
90
|
+
server: { port: 3000, open: true, host: true },
|
|
91
|
+
build: {
|
|
92
|
+
...baseConfig.build,
|
|
93
|
+
outDir: 'dist-app',
|
|
94
|
+
assetsDir: 'assets',
|
|
95
|
+
emptyOutDir: true,
|
|
96
|
+
minify: 'terser',
|
|
97
|
+
terserOptions: { compress: { drop_console: true, drop_debugger: true } },
|
|
98
|
+
rollupOptions: {
|
|
99
|
+
input: { main: resolve(__dirname, 'index.html') },
|
|
100
|
+
output: {
|
|
101
|
+
assetFileNames: (assetInfo) => {
|
|
102
|
+
const extType = assetInfo.name?.split('.')[1];
|
|
103
|
+
let assetType = 'others';
|
|
104
|
+
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType || '')) assetType = 'images';
|
|
105
|
+
else if (/woff2?|eot|ttf|otf/i.test(extType || '')) assetType = 'fonts';
|
|
106
|
+
else if (/css/i.test(extType || '')) assetType = 'css';
|
|
107
|
+
return `assets/${assetType}/[name]-[hash][extname]`;
|
|
108
|
+
},
|
|
109
|
+
chunkFileNames: 'assets/js/[name]-[hash].js',
|
|
110
|
+
entryFileNames: 'assets/js/[name]-[hash].js',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// 环境判断(不变,保持双模式切换)
|
|
117
|
+
export default defineConfig((configEnv: ConfigEnv) => {
|
|
118
|
+
const { mode } = configEnv;
|
|
119
|
+
const env = loadEnv(mode, process.cwd(), '');
|
|
120
|
+
const isLib = env.BUILD_TARGET === 'lib' || mode === 'lib';
|
|
121
|
+
console.log(`🚀 Building in ${isLib ? 'library' : 'application'} mode`);
|
|
122
|
+
console.log(`📁 Environment: ${mode}`);
|
|
123
|
+
return isLib ? libraryConfig : appConfig;
|
|
124
|
+
});
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
3
|
+
import viteConfig from './vite.config';
|
|
4
|
+
|
|
5
|
+
// export default mergeConfig(
|
|
6
|
+
// viteConfig,
|
|
7
|
+
// defineConfig({
|
|
8
|
+
// test: {
|
|
9
|
+
// environment: 'jsdom',
|
|
10
|
+
// exclude: [...configDefaults.exclude, 'e2e/**'],
|
|
11
|
+
// root: fileURLToPath(new URL('./', import.meta.url)),
|
|
12
|
+
// },
|
|
13
|
+
// }),
|
|
14
|
+
// )
|
|
15
|
+
// 如果 vite.config.ts 导出的是函数
|
|
16
|
+
export default defineConfig(async (configEnv) => {
|
|
17
|
+
const viteConfigObj = typeof viteConfig === 'function'
|
|
18
|
+
? await viteConfig(configEnv)
|
|
19
|
+
: viteConfig;
|
|
20
|
+
return mergeConfig(viteConfigObj, {
|
|
21
|
+
test: {
|
|
22
|
+
globals: true,
|
|
23
|
+
environment: 'jsdom',
|
|
24
|
+
root: fileURLToPath(new URL('./', import.meta.url)),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
});
|
|
Binary file
|