@valaxyjs/devtools 0.22.3 → 0.22.5-beta.4

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
@@ -1,87 +0,0 @@
1
- import { join, resolve } from 'node:path'
2
- import { componentsDir } from '@advjs/gui/node'
3
- import Vue from '@vitejs/plugin-vue'
4
- import Unocss from 'unocss/vite'
5
- import VueComponents from 'unplugin-vue-components/vite'
6
- import VueRouter from 'unplugin-vue-router/vite'
7
- import { defineConfig } from 'vite'
8
- import { unoConfig } from '../../../../uno.config'
9
-
10
- export default defineConfig({
11
- base: './',
12
-
13
- css: {
14
- preprocessorOptions: {
15
- scss: {
16
- api: 'modern-compiler',
17
- },
18
- },
19
- },
20
-
21
- resolve: {
22
- alias: {
23
- '~/': __dirname,
24
- },
25
- },
26
-
27
- plugins: [
28
- {
29
- name: 'local-object-transform',
30
- transform: {
31
- order: 'post',
32
- async handler(code) {
33
- return `${code}\n/* Injected with object hook! */`
34
- },
35
- },
36
- },
37
- {
38
- name: 'generate-error',
39
- load(id) {
40
- if (id === '/__LOAD_ERROR')
41
- throw new Error('Load error')
42
- if (id === '/__TRANSFORM_ERROR')
43
- return 'transform'
44
- },
45
- transform(code, id) {
46
- if (id === '/__TRANSFORM_ERROR')
47
- throw new SyntaxError('Transform error')
48
- },
49
- },
50
-
51
- {
52
- name: 'no-change',
53
- transform: {
54
- order: 'post',
55
- async handler(code) {
56
- return code
57
- },
58
- },
59
- },
60
-
61
- VueRouter({
62
- routesFolder: join(__dirname, 'pages'),
63
- dts: join(__dirname, 'typed-routes.d.ts'),
64
- }),
65
- Vue({
66
- include: [/\.vue$/, /\.md$/],
67
- }),
68
- VueComponents({
69
- dirs: ['components', componentsDir],
70
- dts: join(__dirname, 'components.d.ts'),
71
- }),
72
- Unocss(unoConfig),
73
- ],
74
-
75
- optimizeDeps: {
76
- exclude: [
77
- 'vite-hot-client',
78
- ],
79
- },
80
-
81
- build: {
82
- target: 'esnext',
83
- outDir: resolve(__dirname, '../../dist/client'),
84
- minify: false, // 'esbuild',
85
- emptyOutDir: true,
86
- },
87
- })
package/src/dir.ts DELETED
@@ -1,10 +0,0 @@
1
- import { dirname, resolve } from 'node:path'
2
- import { fileURLToPath } from 'node:url'
3
-
4
- export const DIR_DIST = typeof __dirname !== 'undefined'
5
- ? __dirname
6
- : dirname(fileURLToPath(import.meta.url))
7
-
8
- const DEVTOOLS_CLIENT_FOLDER = resolve(DIR_DIST, '../dist/client')
9
-
10
- export const DIR_CLIENT = DEVTOOLS_CLIENT_FOLDER
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './node/index'
2
- export { default } from './node/index'
@@ -1,3 +0,0 @@
1
- # Valaxy Devtools
2
-
3
- A vite plugin for valaxy.
@@ -1,82 +0,0 @@
1
- import type { ResolvedConfig, ViteDevServer } from 'vite'
2
- import bodyParser from 'body-parser'
3
-
4
- import fs from 'fs-extra'
5
- import matter from 'gray-matter'
6
- import { JSON_SCHEMA } from 'js-yaml'
7
-
8
- const prefix = '/valaxy-devtools-api'
9
-
10
- /**
11
- * migration
12
- * @param path
13
- * @param frontmatter
14
- */
15
- export async function migration(path: string, frontmatter: { [key: string]: string }) {
16
- if (fs.existsSync(path)) {
17
- const rawMd = await fs.readFile(path, 'utf-8')
18
- const matterFile = matter(rawMd, { schema: JSON_SCHEMA } as any)
19
- let mod = false
20
- for (const key in frontmatter) {
21
- if (key in matterFile.data) {
22
- matterFile.data[frontmatter[key]] = matterFile.data[key]
23
- delete matterFile.data[key]
24
- mod = true
25
- }
26
- }
27
- if (mod) {
28
- const newMd = matter.stringify(matterFile.content, matterFile.data)
29
- await fs.writeFile(path, newMd)
30
- }
31
- }
32
- else {
33
- // console.error(`post not exist:${path}`)
34
- }
35
- }
36
-
37
- export function registerApi(server: ViteDevServer, _viteConfig: ResolvedConfig) {
38
- const app = server.middlewares
39
-
40
- app.use(bodyParser.json())
41
-
42
- app.use(`${prefix}/frontmatter`, async (req, _res) => {
43
- // update
44
- if (req.method === 'POST') {
45
- const { pageData, frontmatter: newFm } = await (req as any).body
46
- // filePath
47
- const path = pageData.path
48
- if (fs.existsSync(path)) {
49
- const rawMd = await fs.readFile(path, 'utf-8')
50
- const matterFile = matter(rawMd)
51
-
52
- // update frontmatter
53
- matterFile.data = newFm
54
- const newMd = matter.stringify(matterFile.content, matterFile.data)
55
- await fs.writeFile(path, newMd)
56
- }
57
- }
58
- })
59
-
60
- app.use(`${prefix}/migration`, async (req, _res) => {
61
- // update
62
- if (req.method === 'POST') {
63
- const { pageData, frontmatter } = await (req as any).body
64
- // filePath
65
- const worker: Promise<void>[] = []
66
-
67
- for (const item of pageData) {
68
- const path = item
69
- worker.push(migration(path, frontmatter))
70
- }
71
- // worker.push(migration(`${userRoot.root}/pages${item}.md`, frontmatter))
72
- // for (const item of pageData)
73
- // worker.push(migration(item, frontmatter))
74
-
75
- Promise.all(worker).then(() => {
76
- _res.end('ok')
77
- }).catch((_) => {
78
- _res.end('migration error')
79
- })
80
- }
81
- })
82
- }
package/src/node/index.ts DELETED
@@ -1,74 +0,0 @@
1
- import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'
2
- import type { ValaxyDevtoolsOptions } from './types'
3
- import { createProxyMiddleware } from 'http-proxy-middleware'
4
- import c from 'picocolors'
5
- import sirv from 'sirv'
6
- import { DIR_CLIENT } from '../dir'
7
- import { registerApi } from './api'
8
-
9
- const NAME = 'valaxy:devtools'
10
-
11
- // import.meta.env.VITE_DEV_VALAXY_DEVTOOLS = 'true'
12
-
13
- export default function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plugin {
14
- let config: ResolvedConfig
15
-
16
- function configureServer(server: ViteDevServer) {
17
- const _print = server.printUrls
18
- const base = (options.base ?? server.config.base) || '/'
19
-
20
- const devtoolsUrl = `${base}__valaxy_devtools__/`
21
- if (import.meta.env?.VITE_DEV_VALAXY_DEVTOOLS === 'true') {
22
- server.middlewares.use(devtoolsUrl, createProxyMiddleware({
23
- target: 'http://localhost:5001/#/',
24
- changeOrigin: true,
25
- }) as any)
26
- }
27
- else {
28
- server.middlewares.use(devtoolsUrl, sirv(DIR_CLIENT, {
29
- single: true,
30
- dev: true,
31
- }))
32
- }
33
-
34
- server.printUrls = () => {
35
- let host = `${config.server.https ? 'https' : 'http'}://localhost:${config.server.port || '80'}`
36
-
37
- const url = server.resolvedUrls?.local[0]
38
-
39
- if (url) {
40
- try {
41
- const u = new URL(url)
42
- host = `${u.protocol}//${u.host}`
43
- }
44
- catch (error) {
45
- console.warn('Parse resolved url failed:', error)
46
- }
47
- }
48
-
49
- _print()
50
-
51
- const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
52
- // eslint-disable-next-line no-console
53
- console.log(` ${c.green('➜')} ${c.bold('Inspect')}: ${colorUrl(`${host}${base}__inspect/`)}`)
54
- }
55
-
56
- registerApi(server, config)
57
- }
58
-
59
- const plugin = <Plugin>{
60
- name: NAME,
61
-
62
- enforce: 'pre',
63
-
64
- configResolved(_config) {
65
- config = _config
66
- },
67
-
68
- configureServer(server) {
69
- configureServer(server)
70
- },
71
- }
72
-
73
- return plugin
74
- }
package/src/node/types.ts DELETED
@@ -1,4 +0,0 @@
1
- export interface ValaxyDevtoolsOptions {
2
- userRoot?: string
3
- base?: string
4
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "lib": [
5
- "ESNext",
6
- "DOM"
7
- ],
8
- "baseUrl": ".",
9
- "module": "ESNext",
10
- "moduleResolution": "Bundler",
11
- "resolveJsonModule": true,
12
- "types": [
13
- "vite/client",
14
- "unplugin-vue-router/client"
15
- ],
16
- "strict": true,
17
- "strictNullChecks": true,
18
- "esModuleInterop": true,
19
- "skipDefaultLibCheck": true,
20
- "skipLibCheck": true
21
- },
22
- "include": [
23
- "./src/client/typed-routes.d.ts",
24
- "./src/**/*.ts"
25
- ]
26
- }