@valaxyjs/devtools 0.22.4 → 0.22.5-beta.5

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.
Files changed (56) hide show
  1. package/README.md +13 -0
  2. package/dist/client/assets/{about-DG1GsLHQ.js → about-YZW2X-7U.js} +1 -2
  3. package/dist/client/assets/{categories-Bm7oRFJy.js → categories-DjKct1de.js} +1 -2
  4. package/dist/client/assets/en-DQc-k8eq.js +13 -0
  5. package/dist/client/assets/index-60_bCGDF.css +428 -0
  6. package/dist/client/assets/index-B_Bc_zX6.js +8909 -0
  7. package/dist/client/assets/index-Clg7HLhF.js +22396 -0
  8. package/dist/client/assets/index-DKnSvpEK.css +7 -0
  9. package/dist/client/assets/{migration-CLNK0vJL.js → migration-BXXS7zuk.js} +2 -2
  10. package/dist/client/assets/{splitpanes.es-C0nkbxNz.js → splitpanes.es-B_iwNZlc.js} +1 -1
  11. package/dist/client/assets/{tags-hRXnGE0o.js → tags-DyKgUFNV.js} +1 -2
  12. package/dist/client/assets/zh-CN-DrQHTX9V.js +32 -0
  13. package/dist/client/index.html +2 -2
  14. package/dist/index.d.mts +6 -1
  15. package/dist/index.d.ts +6 -1
  16. package/dist/index.mjs +100 -37
  17. package/package.json +21 -5
  18. package/rpc.d.ts +21 -0
  19. package/build.config.ts +0 -20
  20. package/dist/client/assets/_plugin-vue_export-helper-DgDhiqFL.js +0 -11
  21. package/dist/client/assets/index-BsE069b2.css +0 -61
  22. package/dist/client/assets/index-CGiiZwdq.css +0 -396
  23. package/dist/client/assets/index-DERgnaDy.js +0 -8572
  24. package/dist/client/assets/index-DjRUnZlz.js +0 -830
  25. package/src/client/App.vue +0 -20
  26. package/src/client/components/PageFrontmatter.vue +0 -67
  27. package/src/client/components/PostPanel.vue +0 -22
  28. package/src/client/components/VDHeader.vue +0 -57
  29. package/src/client/components/VDPostCategories.vue +0 -26
  30. package/src/client/components/VDPostList.vue +0 -31
  31. package/src/client/components/VDTag.vue +0 -9
  32. package/src/client/components.d.ts +0 -66
  33. package/src/client/composables/app.ts +0 -10
  34. package/src/client/index.html +0 -32
  35. package/src/client/main.ts +0 -37
  36. package/src/client/pages/about.vue +0 -5
  37. package/src/client/pages/categories.vue +0 -5
  38. package/src/client/pages/index.vue +0 -21
  39. package/src/client/pages/migration.vue +0 -73
  40. package/src/client/pages/tags.vue +0 -5
  41. package/src/client/shims.d.ts +0 -12
  42. package/src/client/styles/index.css +0 -8
  43. package/src/client/typed-routes.d.ts +0 -27
  44. package/src/client/types/index.ts +0 -3
  45. package/src/client/utils/api.ts +0 -18
  46. package/src/client/utils/get.ts +0 -25
  47. package/src/client/utils/index.ts +0 -5
  48. package/src/client/utils/init.ts +0 -27
  49. package/src/client/vite.config.ts +0 -87
  50. package/src/dir.ts +0 -10
  51. package/src/index.ts +0 -2
  52. package/src/node/README.md +0 -3
  53. package/src/node/api/index.ts +0 -82
  54. package/src/node/index.ts +0 -74
  55. package/src/node/types.ts +0 -4
  56. package/tsconfig.json +0 -26
@@ -0,0 +1,7 @@
1
+ .bottom-gradient[data-v-2102e92e] {
2
+ height: 100px;
3
+ bottom: 0;
4
+ left: 0;
5
+ right: 0;
6
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, var(--va-c-bg) 77.94%);
7
+ }
@@ -1,5 +1,5 @@
1
- import { d as defineComponent, e as ref, f as onMounted, y as getGlobalValaxyProperty, o as openBlock, j as createBlock, w as withCtx, u as unref, m as createVNode, h as createBaseVNode, a as createElementBlock, k as renderList, F as Fragment, B as withDirectives, C as vModelCheckbox, t as toDisplayString, D as vModelText } from './index-DERgnaDy.js';
2
- import { g, M, a as axios } from './splitpanes.es-C0nkbxNz.js';
1
+ import { S as defineComponent, U as ref, ap as onMounted, av as getGlobalValaxyProperty, C as openBlock, O as createBlock, R as withCtx, X as unref, W as createVNode, E as createBaseVNode, D as createElementBlock, N as renderList, M as Fragment, A as withDirectives, aw as vModelCheckbox, I as toDisplayString, ax as vModelText } from './index-Clg7HLhF.js';
2
+ import { g, M, a as axios } from './splitpanes.es-B_iwNZlc.js';
3
3
 
4
4
  const _hoisted_1 = {
5
5
  class: "h-full",
@@ -1,4 +1,4 @@
1
- import { E as h, o as openBlock, a as createElementBlock, r as renderSlot, G as normalizeStyle } from './index-DERgnaDy.js';
1
+ import { ay as h, C as openBlock, D as createElementBlock, F as renderSlot, ac as normalizeStyle } from './index-Clg7HLhF.js';
2
2
 
3
3
  function bind(fn, thisArg) {
4
4
  return function wrap() {
@@ -1,5 +1,4 @@
1
- import { _ as _export_sfc } from './_plugin-vue_export-helper-DgDhiqFL.js';
2
- import { a as createElementBlock, o as openBlock } from './index-DERgnaDy.js';
1
+ import { _ as _export_sfc, D as createElementBlock, C as openBlock } from './index-Clg7HLhF.js';
3
2
 
4
3
  /* unplugin-vue-components disabled */const _sfc_main = {};
5
4
 
@@ -0,0 +1,32 @@
1
+ const resource = {
2
+ "button": {
3
+ "about": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"关于"}},
4
+ "back": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"返回"}},
5
+ "go": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"确定"}},
6
+ "home": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"首页"}},
7
+ "toggle_dark": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"切换深色模式"}},
8
+ "toggle_langs": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"切换语言"}}
9
+ },
10
+ "frontmatter": {
11
+ "title": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"标题"}},
12
+ "title_zh": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"中文标题"}},
13
+ "time_warning": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"过期警告"}},
14
+ "hide": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"是否隐藏"}},
15
+ "date": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"创建日期"}},
16
+ "updated": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"更新日期"}},
17
+ "cover": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"封面"}},
18
+ "categories": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"分类"}},
19
+ "tags": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"标签"}},
20
+ "excerpt": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"摘要"}},
21
+ "excerpt_type": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"摘要类型"}},
22
+ "toc": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"是否展示目录"}},
23
+ "password": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"密码"}},
24
+ "password_hint": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"密码提示"}},
25
+ "type": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"自定义文章类型"}},
26
+ "end": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"是否完结"}},
27
+ "draft": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"是否为草稿"}}
28
+ }
29
+ };
30
+ /* Injected with object hook! */
31
+
32
+ export { resource as default };
@@ -16,8 +16,8 @@
16
16
  document.documentElement.classList.toggle('dark', true)
17
17
  })()
18
18
  </script>
19
- <script type="module" crossorigin src="./assets/index-DERgnaDy.js"></script>
20
- <link rel="stylesheet" crossorigin href="./assets/index-CGiiZwdq.css">
19
+ <script type="module" crossorigin src="./assets/index-Clg7HLhF.js"></script>
20
+ <link rel="stylesheet" crossorigin href="./assets/index-60_bCGDF.css">
21
21
  </head>
22
22
 
23
23
  <body data-vite-inspect-mode="DEV">
package/dist/index.d.mts CHANGED
@@ -7,4 +7,9 @@ interface ValaxyDevtoolsOptions {
7
7
 
8
8
  declare function ValaxyDevtools(options?: ValaxyDevtoolsOptions): Plugin;
9
9
 
10
- export { ValaxyDevtools as default };
10
+ /**
11
+ * icons safelist
12
+ */
13
+ declare const safelist: string[];
14
+
15
+ export { ValaxyDevtools, ValaxyDevtools as default, safelist };
package/dist/index.d.ts CHANGED
@@ -7,4 +7,9 @@ interface ValaxyDevtoolsOptions {
7
7
 
8
8
  declare function ValaxyDevtools(options?: ValaxyDevtoolsOptions): Plugin;
9
9
 
10
- export { ValaxyDevtools as default };
10
+ /**
11
+ * icons safelist
12
+ */
13
+ declare const safelist: string[];
14
+
15
+ export { ValaxyDevtools, ValaxyDevtools as default, safelist };
package/dist/index.mjs CHANGED
@@ -1,18 +1,22 @@
1
- import { createProxyMiddleware } from 'http-proxy-middleware';
2
1
  import c from 'picocolors';
3
2
  import sirv from 'sirv';
4
- import { dirname, resolve } from 'node:path';
3
+ import { createRPCServer } from 'vite-dev-rpc';
4
+ import path, { dirname, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import bodyParser from 'body-parser';
7
7
  import fs from 'fs-extra';
8
8
  import matter from 'gray-matter';
9
9
  import { JSON_SCHEMA } from 'js-yaml';
10
+ import process from 'node:process';
11
+ import dayjs from 'dayjs';
12
+ import fg from 'fast-glob';
13
+
14
+ const NAMESPACE = "valaxy:devtools";
10
15
 
11
16
  const DIR_DIST = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
12
17
  const DEVTOOLS_CLIENT_FOLDER = resolve(DIR_DIST, "../dist/client");
13
18
  const DIR_CLIENT = DEVTOOLS_CLIENT_FOLDER;
14
19
 
15
- const prefix = "/valaxy-devtools-api";
16
20
  async function migration(path, frontmatter) {
17
21
  if (fs.existsSync(path)) {
18
22
  const rawMd = await fs.readFile(path, "utf-8");
@@ -31,52 +35,108 @@ async function migration(path, frontmatter) {
31
35
  }
32
36
  }
33
37
  }
38
+
39
+ const prefix = "/valaxy-devtools-api";
40
+ const apis = [
41
+ {
42
+ route: "/frontmatter",
43
+ fn: async (req, res) => {
44
+ if (req.method === "POST") {
45
+ const { pageData, frontmatter: newFm } = await req.body;
46
+ const path = pageData.path;
47
+ if (fs.existsSync(path)) {
48
+ const rawMd = await fs.readFile(path, "utf-8");
49
+ const matterFile = matter(rawMd);
50
+ matterFile.data = newFm;
51
+ const newMd = matter.stringify(matterFile.content, matterFile.data);
52
+ await fs.writeFile(path, newMd);
53
+ }
54
+ }
55
+ }
56
+ },
57
+ {
58
+ route: "/migration",
59
+ fn: async (req, res) => {
60
+ if (req.method === "POST") {
61
+ const { pageData, frontmatter } = await req.body;
62
+ const worker = [];
63
+ for (const item of pageData) {
64
+ const path = item;
65
+ worker.push(migration(path, frontmatter));
66
+ }
67
+ Promise.all(worker).then(() => {
68
+ res.end("ok");
69
+ }).catch((_) => {
70
+ res.end("migration error");
71
+ });
72
+ }
73
+ }
74
+ }
75
+ ];
34
76
  function registerApi(server, _viteConfig) {
35
77
  const app = server.middlewares;
36
78
  app.use(bodyParser.json());
37
- app.use(`${prefix}/frontmatter`, async (req, _res) => {
38
- if (req.method === "POST") {
39
- const { pageData, frontmatter: newFm } = await req.body;
40
- const path = pageData.path;
41
- if (fs.existsSync(path)) {
42
- const rawMd = await fs.readFile(path, "utf-8");
43
- const matterFile = matter(rawMd);
44
- matterFile.data = newFm;
45
- const newMd = matter.stringify(matterFile.content, matterFile.data);
46
- await fs.writeFile(path, newMd);
47
- }
48
- }
79
+ apis.forEach(({ route, fn }) => {
80
+ app.use(prefix + route, fn);
49
81
  });
50
- app.use(`${prefix}/migration`, async (req, _res) => {
51
- if (req.method === "POST") {
52
- const { pageData, frontmatter } = await req.body;
53
- const worker = [];
54
- for (const item of pageData) {
55
- const path = item;
56
- worker.push(migration(path, frontmatter));
82
+ }
83
+
84
+ function getFunctions(server, devtoolsOptions) {
85
+ const userRoot = devtoolsOptions.userRoot || process.cwd();
86
+ function getRoutePath(filePath) {
87
+ return path.relative(path.resolve(userRoot, "pages"), filePath).slice(0, -".md".length);
88
+ }
89
+ return {
90
+ async getOptions() {
91
+ return {
92
+ userRoot
93
+ };
94
+ },
95
+ async getPostList() {
96
+ const files = await fg(`${userRoot}/pages/posts/**/*.md`);
97
+ const posts = [];
98
+ for await (const file of files) {
99
+ const md = await fs.readFile(file, "utf-8");
100
+ const { data } = matter(md);
101
+ posts.push({
102
+ frontmatter: data,
103
+ filePath: file,
104
+ routePath: path.relative(path.resolve(userRoot, "pages"), file).slice(0, -".md".length)
105
+ });
57
106
  }
58
- Promise.all(worker).then(() => {
59
- _res.end("ok");
60
- }).catch((_) => {
61
- _res.end("migration error");
62
- });
107
+ return {
108
+ // sort by updated
109
+ posts: posts.sort((a, b) => {
110
+ const bDateValue = dayjs(b.frontmatter.date).valueOf();
111
+ const aDateValue = dayjs(a.frontmatter.date).valueOf();
112
+ return bDateValue - aDateValue;
113
+ }),
114
+ root: userRoot
115
+ };
116
+ },
117
+ async getPageData(pagePath) {
118
+ const relativePath = pagePath.startsWith("/") ? pagePath.slice(1) : pagePath;
119
+ const file = path.resolve(userRoot, relativePath);
120
+ const { data } = matter(file);
121
+ return {
122
+ routePath: getRoutePath(file),
123
+ filePath: file,
124
+ frontmatter: data
125
+ };
63
126
  }
64
- });
127
+ };
65
128
  }
66
129
 
67
- const NAME = "valaxy:devtools";
68
130
  function ValaxyDevtools(options = {}) {
69
131
  let config;
132
+ const isDevDevtools = import.meta.env?.VITE_VALAXY_DEVTOOLS_DEV === "true";
70
133
  function configureServer(server) {
71
134
  const _print = server.printUrls;
72
135
  const base = (options.base ?? server.config.base) || "/";
136
+ const functions = getFunctions(server, options);
137
+ createRPCServer(NAMESPACE, server.ws, functions);
73
138
  const devtoolsUrl = `${base}__valaxy_devtools__/`;
74
- if (import.meta.env?.VITE_DEV_VALAXY_DEVTOOLS === "true") {
75
- server.middlewares.use(devtoolsUrl, createProxyMiddleware({
76
- target: "http://localhost:5001/#/",
77
- changeOrigin: true
78
- }));
79
- } else {
139
+ if (!isDevDevtools) {
80
140
  server.middlewares.use(devtoolsUrl, sirv(DIR_CLIENT, {
81
141
  single: true,
82
142
  dev: true
@@ -100,8 +160,9 @@ function ValaxyDevtools(options = {}) {
100
160
  registerApi(server);
101
161
  }
102
162
  const plugin = {
103
- name: NAME,
163
+ name: NAMESPACE,
104
164
  enforce: "pre",
165
+ // config: () => { },
105
166
  configResolved(_config) {
106
167
  config = _config;
107
168
  },
@@ -112,4 +173,6 @@ function ValaxyDevtools(options = {}) {
112
173
  return plugin;
113
174
  }
114
175
 
115
- export { ValaxyDevtools as default };
176
+ const safelist = [];
177
+
178
+ export { ValaxyDevtools, ValaxyDevtools as default, safelist };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@valaxyjs/devtools",
3
3
  "type": "module",
4
- "version": "0.22.4",
4
+ "version": "0.22.5-beta.5",
5
5
  "repository": {
6
6
  "url": "https://github.com/YunYouJun/valaxy"
7
7
  },
@@ -10,33 +10,49 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "default": "./dist/index.mjs"
12
12
  },
13
+ "./rpc": "./rpc.d.ts",
14
+ "./client": "./dist/client",
13
15
  "./*": "./*"
14
16
  },
15
17
  "main": "dist/index.mjs",
16
18
  "module": "dist/index.mjs",
17
19
  "types": "dist/index.d.ts",
20
+ "files": [
21
+ "dist",
22
+ "rpc.d.ts"
23
+ ],
18
24
  "dependencies": {
19
25
  "@rollup/pluginutils": "^5.1.4",
20
26
  "axios": "^1.7.9",
21
27
  "body-parser": "^2.0.2",
28
+ "cors": "^2.8.5",
22
29
  "http-proxy-middleware": "^3.0.3",
23
30
  "js-yaml": "^4.1.0",
31
+ "pathe": "^1.1.2",
24
32
  "picocolors": "^1.1.1",
25
- "sirv": "^3.0.0"
33
+ "sirv": "^3.0.0",
34
+ "vite-dev-rpc": "^0.1.7"
26
35
  },
27
36
  "devDependencies": {
28
- "@advjs/gui": "0.0.7-beta.1",
37
+ "@advjs/gui": "0.0.7-beta.7",
29
38
  "@iconify-json/ri": "^1.2.5",
39
+ "@intlify/unplugin-vue-i18n": "^6.0.2",
40
+ "@primevue/themes": "^4.2.5",
30
41
  "@types/body-parser": "^1.19.5",
31
42
  "@types/splitpanes": "^2.2.6",
43
+ "@types/wicg-file-system-access": "^2023.10.5",
32
44
  "gray-matter": "^4.0.3",
45
+ "primevue": "^4.2.5",
33
46
  "splitpanes": "^3.1.5",
34
- "typescript": "5.6",
47
+ "typescript": "^5.7.2",
35
48
  "unbuild": "^3.0.1",
36
49
  "unplugin-vue-router": "^0.10.9",
37
- "vite": "^6.0.3"
50
+ "vite": "^6.0.5",
51
+ "vue-i18n": "^11.0.0",
52
+ "zod": "^3.24.1"
38
53
  },
39
54
  "scripts": {
55
+ "clean": "rimraf dist",
40
56
  "build": "rimraf dist && run-s build:*",
41
57
  "build:client": "vite build src/client",
42
58
  "build:node": "unbuild",
package/rpc.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { ClientOptions, ClientPageData, ClientPostList } from './client/types'
2
+
3
+ export interface ServerFunctions {
4
+ // add: (a: number, b: number) => number
5
+ /**
6
+ * 获取基础配置
7
+ */
8
+ getOptions: () => Promise<ClientOptions>
9
+ /**
10
+ * 获取文章列表
11
+ */
12
+ getPostList: () => Promise<ClientPostList>
13
+ /**
14
+ * 获取页面 pageData
15
+ */
16
+ getPageData: (pagePath: string) => Promise<ClientPageData>
17
+ }
18
+
19
+ export interface ClientFunctions {
20
+ // alert: (message: string) => void
21
+ }
package/build.config.ts DELETED
@@ -1,20 +0,0 @@
1
- import { defineBuildConfig } from 'unbuild'
2
-
3
- export default defineBuildConfig({
4
- entries: [
5
- './src/index',
6
- ],
7
- clean: false,
8
- declaration: true,
9
- externals: [
10
- // in valaxy
11
- 'vite',
12
- 'gray-matter',
13
- 'fs-extra',
14
- ],
15
- rollup: {
16
- dts: {
17
- respectExternal: true,
18
- },
19
- },
20
- })
@@ -1,11 +0,0 @@
1
- const _export_sfc = (sfc, props) => {
2
- const target = sfc.__vccOpts || sfc;
3
- for (const [key, val] of props) {
4
- target[key] = val;
5
- }
6
- return target;
7
- };
8
-
9
- /* Injected with object hook! */
10
-
11
- export { _export_sfc as _ };
@@ -1,61 +0,0 @@
1
- .agui-button {
2
- --border-radius: 2px;
3
- }
4
- .agui-button {
5
- display: inline-flex;
6
- align-items: center;
7
- justify-content: center;
8
- padding: 0 6px;
9
- font-size: 12px;
10
- appearance: none;
11
- background: rgb(88, 88, 88) no-repeat center center;
12
- color: #e6e6e6;
13
- cursor: pointer;
14
- border-radius: var(--border-radius);
15
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
16
- }
17
- .agui-button[data-location=ALONE] {
18
- border-radius: var(--border-radius);
19
- }
20
- .agui-button[data-location=LEFT] {
21
- border-top-left-radius: var(--border-radius) var(--border-radius);
22
- border-bottom-left-radius: var(--border-radius) var(--border-radius);
23
- border-top-right-radius: 0;
24
- border-bottom-right-radius: 0;
25
- }
26
- .agui-button[data-location=RIGHT] {
27
- border-top-right-radius: var(--border-radius) var(--border-radius);
28
- border-bottom-right-radius: var(--border-radius) var(--border-radius);
29
- border-top-left-radius: 0;
30
- border-bottom-left-radius: 0;
31
- }
32
- .agui-button:hover {
33
- background: rgb(100, 100, 100);
34
- color: #ffffff;
35
- }
36
- .agui-button.pressed, .agui-button:active {
37
- background-color: #4772b3;
38
- color: #ffffff;
39
- }
40
- .agui-button.mini {
41
- font-size: 9px;
42
- }.agui-input {
43
- --agui-input-c-bg: rgba(42, 42, 42, 1);
44
- color: var(--agui-c-label);
45
- background-color: var(--agui-input-c-bg, rgb(42, 42, 42));
46
- border: 1px solid var(--agui-c-border);
47
- border-radius: 3px;
48
- font-size: 13px;
49
- height: 20px;
50
- box-sizing: border-box;
51
- transition: border-color 0.2s ease-in-out;
52
- }
53
- .agui-input:focus {
54
- outline: none;
55
- border-color: var(--agui-c-active);
56
- }
57
- .agui-input:disabled {
58
- opacity: 0.5;
59
- color: var(--agui-c-text-3);
60
- border-color: var(--agui-c-border);
61
- }