houwenjian 1.0.6 → 1.0.9

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.
@@ -0,0 +1,26 @@
1
+ import { ref as c, openBlock as _, createElementBlock as r, createElementVNode as o } from "vue";
2
+ const u = (t, n) => {
3
+ const e = t.__vccOpts || t;
4
+ for (const [l, s] of n)
5
+ e[l] = s;
6
+ return e;
7
+ }, d = {
8
+ __name: "test",
9
+ setup(t) {
10
+ return c("hello world"), (n, e) => (_(), r("div", null, [...e[0] || (e[0] = [
11
+ o("h2", null, "npm module test", -1),
12
+ o("h2", null, "作者 侯文建", -1),
13
+ o("div", null, [
14
+ o("button", { class: "buttons" }, "提交")
15
+ ], -1)
16
+ ])]));
17
+ }
18
+ }, p = /* @__PURE__ */ u(d, [["__scopeId", "data-v-3254c07f"]]), i = {
19
+ install(t) {
20
+ t.component("RichEditor", p);
21
+ }
22
+ };
23
+ export {
24
+ p as RichEditor,
25
+ i as default
26
+ };
@@ -0,0 +1 @@
1
+ (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.houwenjian={},t.Vue))})(this,function(t,e){"use strict";const r="",s=((n,c)=>{const o=n.__vccOpts||n;for(const[i,d]of c)o[i]=d;return o})({__name:"test",setup(n){return e.ref("hello world"),(c,o)=>(e.openBlock(),e.createElementBlock("div",null,[...o[0]||(o[0]=[e.createElementVNode("h2",null,"npm module test",-1),e.createElementVNode("h2",null,"作者 侯文建",-1),e.createElementVNode("div",null,[e.createElementVNode("button",{class:"buttons"},"提交")],-1)])]))}},[["__scopeId","data-v-3254c07f"]]),l={install(n){n.component("RichEditor",s)}};t.RichEditor=s,t.default=l,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .buttons[data-v-3254c07f]{color:red}
package/package.json CHANGED
@@ -1,24 +1,40 @@
1
1
  {
2
2
  "name": "houwenjian",
3
- "version": "1.0.6",
4
- "main": "vite.config.js",
3
+ "version": "1.0.9",
4
+ "description": "Vue-based npm package built with Vite (JavaScript version)",
5
+ "main": "dist/houwenjian.umd.js",
6
+ "module": "dist/houwenjian.es.js",
7
+ "types": "dist/houwenjian.d.ts",
8
+ "scripts": {
9
+ "dev": "vite build --watch",
10
+ "build": "vite build",
11
+ "test": "vitest --environment jsdom",
12
+ "prepublishOnly": "npm run build && npm test"
13
+ },
5
14
  "dependencies": {
6
- "csstype": "^3.2.3",
7
- "entities": "^7.0.0",
8
- "estree-walker": "^2.0.2",
9
- "magic-string": "^0.30.21",
10
- "nanoid": "^3.3.11",
11
- "picocolors": "^1.1.1",
12
- "postcss": "^8.5.6",
13
- "source-map-js": "^1.2.1",
14
- "vue": "^3.5.26",
15
- "rollup-plugin-peer-deps-external": "^2.2.4"
15
+ "vue": "^3.2.0"
16
16
  },
17
- "devDependencies": {},
18
- "scripts": {
19
- "test": "echo \"Error: no test specified\" && exit 1"
17
+ "devDependencies": {
18
+ "@vitejs/plugin-vue": "^4.0.0",
19
+ "@vue/test-utils": "^2.4.6",
20
+ "jsdom": "^22.1.0",
21
+ "vite": "^4.0.0",
22
+ "vitest": "^0.34.6"
20
23
  },
21
- "author": "",
24
+ "author": "HOU WEN JIAN",
22
25
  "license": "ISC",
23
- "description": ""
26
+ "vitest": {
27
+ "coverage": {
28
+ "reporter": [
29
+ "text",
30
+ "json",
31
+ "html"
32
+ ],
33
+ "thresholds": {
34
+ "functions": 100,
35
+ "branches": 100,
36
+ "lines": 100
37
+ }
38
+ }
39
+ }
24
40
  }
package/src/index.js CHANGED
@@ -1,13 +1,10 @@
1
- import RichEditor from './components/RichEditor.vue';
1
+ import RichEditor from './test.vue';
2
2
 
3
3
  // 定义插件安装方法(Vue3标准方式)
4
4
  export default {
5
5
  install(app) {
6
6
  // 注册全局组件
7
7
  app.component('RichEditor', RichEditor);
8
-
9
- // 可选:暴露其他功能(如指令、服务等)
10
- // app.config.globalProperties.$editor = ...;
11
8
  }
12
9
  };
13
10
 
package/src/test.vue ADDED
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <div>
3
+ <h2>npm module test</h2>
4
+ <h2>作者 侯文建</h2>
5
+ <div>
6
+ <button class="buttons">提交</button>
7
+ </div>
8
+ </div>
9
+ </template>
10
+ <script setup>
11
+ import { ref } from 'vue';
12
+ const message = ref("hello world")
13
+ </script>
14
+
15
+ <style scoped>
16
+ .buttons{
17
+ color:red;
18
+ }
19
+ </style>
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { mount } from '@vue/test-utils';
3
+ import { RichEditor } from '../src/index';
4
+
5
+ describe('RichEditor', () => {
6
+ // 基础渲染测试
7
+ it('renders correctly', () => {
8
+ const wrapper = mount(RichEditor);
9
+
10
+ // 获取所有h2元素
11
+ const h2Elements = wrapper.findAll('h2');
12
+
13
+ // 验证组件渲染的DOM结构
14
+ expect(h2Elements[0].text()).toContain('npm module test');
15
+ expect(h2Elements[1].text()).toContain('作者 侯文建');
16
+ });
17
+
18
+ // 组件属性测试
19
+ it('handles props correctly', async () => {
20
+ // 如果有需要测试的props,在这里添加具体用例
21
+ const wrapper = mount(RichEditor);
22
+ });
23
+
24
+ // 组件事件测试
25
+ it('emits events correctly', async () => {
26
+ // 如果有需要测试的事件,在这里添加具体用例
27
+ const wrapper = mount(RichEditor);
28
+ });
29
+ });
package/vite.config.js CHANGED
@@ -1,23 +1,25 @@
1
1
  import { defineConfig } from 'vite';
2
2
  import vue from '@vitejs/plugin-vue';
3
- import peerDepsExternal from 'rollup-plugin-peer-deps-external';
4
3
 
5
4
  export default defineConfig({
5
+ plugins: [vue()],
6
6
  build: {
7
7
  lib: {
8
- entry: './src/index.js', // 入口文件
9
- name: 'houwenjian', // 全局变量名(UMD模式)
10
- fileName: (format) => `houwenjian.${format}.js`,
8
+ entry: './src/index.js',
9
+ name: 'houwenjian',
10
+ fileName: (format) => `houwenjian.${format}.js`
11
11
  },
12
12
  rollupOptions: {
13
- external: ['vue'], // 将vue作为peerDependency
14
- plugins: [peerDepsExternal()],
13
+ external: ['vue'],
15
14
  output: {
16
15
  globals: {
17
- vue: 'Vue' // UMD模式下映射vue到全局变量
16
+ vue: 'Vue'
18
17
  }
19
18
  }
20
19
  }
21
20
  },
22
- plugins: [vue()]
23
- });
21
+ test: {
22
+ environment: 'jsdom', // 配置测试环境为JSDOM
23
+ globals: true
24
+ }
25
+ });
@@ -1,11 +0,0 @@
1
- <template>
2
- <div>
3
- <ColorView></ColorView>
4
- <div contenteditable>
5
-
6
- </div>
7
- </div>
8
- </template>
9
- <script setup>
10
- import ColorView from "./coloreditor.vue"
11
- </script>
@@ -1,14 +0,0 @@
1
- <template>
2
- <div>
3
- <h2>标题:hello world </h2>
4
- <p>{{ message }}</p>
5
- </div>
6
- </template>
7
- <script setup>
8
- import {ref} from 'vue'
9
- const message = ref("houwenjian")
10
- </script>
11
-
12
-
13
-
14
-