@melt-js/comps-vue3 0.0.1 → 2026.11.6-1

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/scripts/meta.js CHANGED
@@ -1,53 +1,53 @@
1
- /*
2
- |--------------------------------------------------------------------------
3
- |
4
- | 生成 hel-meta.json(写入 hel_dist)
5
- |
6
- |--------------------------------------------------------------------------
7
- */
8
- const fs = require('fs')
9
- const path = require('path')
10
- const helDevUtils = require('hel-dev-utils')
11
- const packageJson = require('../package.json')
12
- const appInfo = require('../appInfo')
13
-
14
- const META_PATH = path.join(__dirname, '../hel_dist/hel-meta.json')
15
-
16
- /**
17
- * hel-dev-utils 在 Windows 下会把 dist 扫描出来的资源路径拼成反斜杠形式,
18
- * 形如 https://unpkg.com/xxx/hel_dist/\js\app.js,CDN 上是无效地址。
19
- * 这里统一转成 / 并去重,保证发布的 hel-meta.json 在 Windows 构建也正确。
20
- */
21
- function normalizePathSeparators(value) {
22
- if (typeof value === 'string') {
23
- return value
24
- .replace(/\\/g, '/')
25
- .replace(/([^:])\/{2,}/g, '$1/')
26
- }
27
- if (Array.isArray(value)) {
28
- return [...new Set(value.map(normalizePathSeparators))]
29
- }
30
- if (value && typeof value === 'object') {
31
- return Object.fromEntries(
32
- Object.entries(value).map(([key, val]) => [key, normalizePathSeparators(val)]),
33
- )
34
- }
35
- return value
36
- }
37
-
38
- async function main() {
39
- const meta = await helDevUtils.extractHelMetaJson({
40
- appInfo,
41
- buildDirFullPath: path.join(__dirname, '../hel_dist'),
42
- packageJson,
43
- })
44
-
45
- const normalizedMeta = normalizePathSeparators(meta)
46
- fs.writeFileSync(META_PATH, JSON.stringify(normalizedMeta, null, 2))
47
- console.log('[comps-vue3] hel-meta.json 生成完成')
48
- }
49
-
50
- main().catch((err) => {
51
- console.error('[comps-vue3] hel-meta.json 生成失败:', err)
52
- process.exit(-1)
53
- })
1
+ /*
2
+ |--------------------------------------------------------------------------
3
+ |
4
+ | 生成 hel-meta.json(写入 hel_dist)
5
+ |
6
+ |--------------------------------------------------------------------------
7
+ */
8
+ const fs = require('fs')
9
+ const path = require('path')
10
+ const helDevUtils = require('hel-dev-utils')
11
+ const packageJson = require('../package.json')
12
+ const appInfo = require('../appInfo')
13
+
14
+ const META_PATH = path.join(__dirname, '../hel_dist/hel-meta.json')
15
+
16
+ /**
17
+ * hel-dev-utils 在 Windows 下会把 dist 扫描出来的资源路径拼成反斜杠形式,
18
+ * 形如 https://unpkg.com/xxx/hel_dist/\js\app.js,CDN 上是无效地址。
19
+ * 这里统一转成 / 并去重,保证发布的 hel-meta.json 在 Windows 构建也正确。
20
+ */
21
+ function normalizePathSeparators(value) {
22
+ if (typeof value === 'string') {
23
+ return value
24
+ .replace(/\\/g, '/')
25
+ .replace(/([^:])\/{2,}/g, '$1/')
26
+ }
27
+ if (Array.isArray(value)) {
28
+ return [...new Set(value.map(normalizePathSeparators))]
29
+ }
30
+ if (value && typeof value === 'object') {
31
+ return Object.fromEntries(
32
+ Object.entries(value).map(([key, val]) => [key, normalizePathSeparators(val)]),
33
+ )
34
+ }
35
+ return value
36
+ }
37
+
38
+ async function main() {
39
+ const meta = await helDevUtils.extractHelMetaJson({
40
+ appInfo,
41
+ buildDirFullPath: path.join(__dirname, '../hel_dist'),
42
+ packageJson,
43
+ })
44
+
45
+ const normalizedMeta = normalizePathSeparators(meta)
46
+ fs.writeFileSync(META_PATH, JSON.stringify(normalizedMeta, null, 2))
47
+ console.log('[comps-vue3] hel-meta.json 生成完成')
48
+ }
49
+
50
+ main().catch((err) => {
51
+ console.error('[comps-vue3] hel-meta.json 生成失败:', err)
52
+ process.exit(-1)
53
+ })
@@ -1,27 +1,27 @@
1
- /*
2
- |--------------------------------------------------------------------------
3
- | npm publish 前检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
4
- |--------------------------------------------------------------------------
5
- */
6
-
7
- const pkg = require('../package.json')
8
- const fs = require('fs')
9
- const path = require('path')
10
-
11
- const helDistPath = path.resolve(__dirname, '../hel_dist/hel-meta.json')
12
- const existHelMeata = fs.existsSync(helDistPath)
13
-
14
- // 检查是否执行 pnpm run build 打包命令
15
- if (!existHelMeata) {
16
- console.log("Run the 'pnpm run build' command first.\n")
17
- process.exit(1)
18
- }
19
-
20
- const { app } = JSON.parse(fs.readFileSync(helDistPath, 'utf-8'))
21
- // 检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
22
- if (app?.build_version !== pkg.version) {
23
- console.log(
24
- 'The package.json version number and the hel_dist/hel-meta.json version number must be the same.\n',
25
- )
26
- process.exit(1)
27
- }
1
+ /*
2
+ |--------------------------------------------------------------------------
3
+ | npm publish 前检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
4
+ |--------------------------------------------------------------------------
5
+ */
6
+
7
+ const pkg = require('../package.json')
8
+ const fs = require('fs')
9
+ const path = require('path')
10
+
11
+ const helDistPath = path.resolve(__dirname, '../hel_dist/hel-meta.json')
12
+ const existHelMeata = fs.existsSync(helDistPath)
13
+
14
+ // 检查是否执行 pnpm run build 打包命令
15
+ if (!existHelMeata) {
16
+ console.log("Run the 'pnpm run build' command first.\n")
17
+ process.exit(1)
18
+ }
19
+
20
+ const { app } = JSON.parse(fs.readFileSync(helDistPath, 'utf-8'))
21
+ // 检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
22
+ if (app?.build_version !== pkg.version) {
23
+ console.log(
24
+ 'The package.json version number and the hel_dist/hel-meta.json version number must be the same.\n',
25
+ )
26
+ process.exit(1)
27
+ }
@@ -1,71 +1,72 @@
1
- /*
2
- |--------------------------------------------------------------------------
3
- | 本地预览 hel_dist 构建产物(默认 7002,带 CORS)
4
- |--------------------------------------------------------------------------
5
- | 预览前请先执行 `pnpm run build:local`,让产物里的资源地址指向
6
- | http://localhost:7002,否则 index.html 会引用 unpkg 上的线上地址。
7
- */
8
- const http = require('node:http')
9
- const fs = require('node:fs')
10
- const path = require('node:path')
11
-
12
- const PORT = Number(process.env.PORT) || 7002
13
- const ROOT = path.resolve(__dirname, '../hel_dist')
14
-
15
- const MIME = {
16
- '.html': 'text/html; charset=utf-8',
17
- '.js': 'text/javascript; charset=utf-8',
18
- '.mjs': 'text/javascript; charset=utf-8',
19
- '.css': 'text/css; charset=utf-8',
20
- '.json': 'application/json; charset=utf-8',
21
- '.map': 'application/json; charset=utf-8',
22
- '.png': 'image/png',
23
- '.jpg': 'image/jpeg',
24
- '.jpeg': 'image/jpeg',
25
- '.gif': 'image/gif',
26
- '.svg': 'image/svg+xml',
27
- '.ico': 'image/x-icon',
28
- '.woff': 'font/woff',
29
- '.woff2': 'font/woff2',
30
- }
31
-
32
- function send(res, status, body, headers = {}) {
33
- res.writeHead(status, {
34
- 'Access-Control-Allow-Origin': '*',
35
- 'Access-Control-Allow-Methods': '*',
36
- 'Access-Control-Allow-Headers': '*',
37
- ...headers,
38
- })
39
- res.end(body)
40
- }
41
-
42
- http
43
- .createServer((req, res) => {
44
- const urlPath = decodeURIComponent((req.url || '/').split('?')[0])
45
- const relativePath = urlPath === '/' ? 'index.html' : urlPath.replace(/^\/+/, '')
46
- let filePath = path.resolve(ROOT, relativePath)
47
-
48
- // 防止路径穿越
49
- if (filePath !== ROOT && !filePath.startsWith(`${ROOT}${path.sep}`)) {
50
- send(res, 403, 'Forbidden')
51
- return
52
- }
53
-
54
- fs.stat(filePath, (statErr, stat) => {
55
- if (!statErr && stat.isDirectory()) {
56
- filePath = path.join(filePath, 'index.html')
57
- }
58
-
59
- fs.readFile(filePath, (readErr, content) => {
60
- if (readErr) {
61
- send(res, 404, 'Not Found')
62
- return
63
- }
64
- const contentType = MIME[path.extname(filePath).toLowerCase()] || 'application/octet-stream'
65
- send(res, 200, content, { 'Content-Type': contentType })
66
- })
67
- })
68
- })
69
- .listen(PORT, () => {
70
- console.log(`[comps-vue3] preview: http://localhost:${PORT}`)
71
- })
1
+ /*
2
+ |--------------------------------------------------------------------------
3
+ | 本地预览 hel_dist 构建产物(默认 20020,带 CORS)
4
+ |--------------------------------------------------------------------------
5
+ | 预览前请先执行 `pnpm run build:local`,让产物里的资源地址指向
6
+ | http://localhost:20020,否则 index.html 会引用 unpkg 上的线上地址。
7
+ */
8
+ const http = require('node:http')
9
+ const fs = require('node:fs')
10
+ const path = require('node:path')
11
+
12
+ // 端口写死,保证本包脱离 monorepo 也能独立运行(全局规则见根目录 ports.json)
13
+ const PORT = Number(process.env.PORT) || 20020
14
+ const ROOT = path.resolve(__dirname, '../hel_dist')
15
+
16
+ const MIME = {
17
+ '.html': 'text/html; charset=utf-8',
18
+ '.js': 'text/javascript; charset=utf-8',
19
+ '.mjs': 'text/javascript; charset=utf-8',
20
+ '.css': 'text/css; charset=utf-8',
21
+ '.json': 'application/json; charset=utf-8',
22
+ '.map': 'application/json; charset=utf-8',
23
+ '.png': 'image/png',
24
+ '.jpg': 'image/jpeg',
25
+ '.jpeg': 'image/jpeg',
26
+ '.gif': 'image/gif',
27
+ '.svg': 'image/svg+xml',
28
+ '.ico': 'image/x-icon',
29
+ '.woff': 'font/woff',
30
+ '.woff2': 'font/woff2',
31
+ }
32
+
33
+ function send(res, status, body, headers = {}) {
34
+ res.writeHead(status, {
35
+ 'Access-Control-Allow-Origin': '*',
36
+ 'Access-Control-Allow-Methods': '*',
37
+ 'Access-Control-Allow-Headers': '*',
38
+ ...headers,
39
+ })
40
+ res.end(body)
41
+ }
42
+
43
+ http
44
+ .createServer((req, res) => {
45
+ const urlPath = decodeURIComponent((req.url || '/').split('?')[0])
46
+ const relativePath = urlPath === '/' ? 'index.html' : urlPath.replace(/^\/+/, '')
47
+ let filePath = path.resolve(ROOT, relativePath)
48
+
49
+ // 防止路径穿越
50
+ if (filePath !== ROOT && !filePath.startsWith(`${ROOT}${path.sep}`)) {
51
+ send(res, 403, 'Forbidden')
52
+ return
53
+ }
54
+
55
+ fs.stat(filePath, (statErr, stat) => {
56
+ if (!statErr && stat.isDirectory()) {
57
+ filePath = path.join(filePath, 'index.html')
58
+ }
59
+
60
+ fs.readFile(filePath, (readErr, content) => {
61
+ if (readErr) {
62
+ send(res, 404, 'Not Found')
63
+ return
64
+ }
65
+ const contentType = MIME[path.extname(filePath).toLowerCase()] || 'application/octet-stream'
66
+ send(res, 200, content, { 'Content-Type': contentType })
67
+ })
68
+ })
69
+ })
70
+ .listen(PORT, () => {
71
+ console.log(`[comps-vue3] preview: http://localhost:${PORT}`)
72
+ })
package/src/App.vue CHANGED
@@ -14,13 +14,13 @@ export default defineComponent({
14
14
  })
15
15
  </script>
16
16
 
17
- <style>
17
+ <style scoped>
18
18
  #app {
19
19
  font-family: Avenir, Helvetica, Arial, sans-serif;
20
20
  -webkit-font-smoothing: antialiased;
21
21
  -moz-osx-font-smoothing: grayscale;
22
22
  text-align: center;
23
23
  color: #2c3e50;
24
- margin-top: 60px;
24
+ /* margin-top: 60px; */
25
25
  }
26
26
  </style>
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "name": "items",
4
+ "type": "CircularMenuItem[]",
5
+ "description": "菜单项,label 是文案,href 给了就走链接,active 是高亮态",
6
+ "default": "",
7
+ "required": true,
8
+ "version": "",
9
+ "isEvent": false,
10
+ "bindable": false
11
+ },
12
+ {
13
+ "name": "variant",
14
+ "type": "'wheel' | 'fan'",
15
+ "description": "形态:wheel 贴视口底部展开半环,fan 在定位祖先内展开整环",
16
+ "default": "\"wheel\"",
17
+ "required": false,
18
+ "version": "",
19
+ "isEvent": false,
20
+ "bindable": true,
21
+ "value": "wheel",
22
+ "control": {
23
+ "options": {
24
+ "wheel": "wheel",
25
+ "fan": "fan"
26
+ }
27
+ }
28
+ },
29
+ {
30
+ "name": "overlay",
31
+ "type": "boolean",
32
+ "description": "wheel 形态下是否显示半透明遮罩",
33
+ "default": "false",
34
+ "required": false,
35
+ "version": "",
36
+ "isEvent": false,
37
+ "bindable": true,
38
+ "value": false
39
+ },
40
+ {
41
+ "name": "openText",
42
+ "type": "string",
43
+ "description": "展开时的按钮文案,不传则按形态用默认符号",
44
+ "default": "",
45
+ "required": false,
46
+ "version": "",
47
+ "isEvent": false,
48
+ "bindable": true,
49
+ "value": ""
50
+ },
51
+ {
52
+ "name": "closeText",
53
+ "type": "string",
54
+ "description": "收起时的按钮文案,不传则按形态用默认符号",
55
+ "default": "",
56
+ "required": false,
57
+ "version": "",
58
+ "isEvent": false,
59
+ "bindable": true,
60
+ "value": ""
61
+ }
62
+ ]