@valaxyjs/devtools 0.18.0-beta.2 → 0.18.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.
@@ -7,9 +7,58 @@ export {}
7
7
 
8
8
  declare module 'vue' {
9
9
  export interface GlobalComponents {
10
+ AGUIAccordion: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/accordion/AGUIAccordion.vue')['default']
11
+ AGUIAccordionItem: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/accordion/AGUIAccordionItem.vue')['default']
12
+ AGUIApp: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUIApp.vue')['default']
13
+ AGUIAssetsExplorer: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/explorer/AGUIAssetsExplorer.vue')['default']
14
+ AGUIBreadcrumb: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/breadcrumb/AGUIBreadcrumb.vue')['default']
15
+ AGUIButton: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/button/AGUIButton.vue')['default']
16
+ AGUICheckbox: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUICheckbox.vue')['default']
17
+ AGUIColorPicker: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUIColorPicker.vue')['default']
18
+ AGUIContextMenu: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/context-menu/AGUIContextMenu.vue')['default']
19
+ AGUIContextMenuItem: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/context-menu/AGUIContextMenuItem.vue')['default']
20
+ AGUIDetails: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUIDetails.vue')['default']
21
+ AGUIExplorerControls: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/explorer/AGUIExplorerControls.vue')['default']
22
+ AGUIFileHandler: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/file/AGUIFileHandler.vue')['default']
23
+ AGUIFileItem: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/explorer/AGUIFileItem.vue')['default']
24
+ AGUIFileList: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/explorer/AGUIFileList.vue')['default']
25
+ AGUIForm: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/form/AGUIForm.vue')['default']
26
+ AGUIFormItem: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/form/AGUIFormItem.vue')['default']
27
+ AGUIHr: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/common/AGUIHr.vue')['default']
28
+ AGUIIcon: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/icon/AGUIIcon.vue')['default']
29
+ AGUIIconButton: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/button/AGUIIconButton.vue')['default']
30
+ AGUIInnerInput: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/input/AGUIInnerInput.vue')['default']
31
+ AGUIInput: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/input/AGUIInput.vue')['default']
32
+ AGUIInputNumber: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/input/AGUIInputNumber.vue')['default']
33
+ AGUIInputVector: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/input/AGUIInputVector.vue')['default']
34
+ AGUILayout: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/layout/AGUILayout.vue')['default']
35
+ AGUIMenubar: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/menu/AGUIMenubar.vue')['default']
36
+ AGUIMenubarMenu: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/menu/AGUIMenubarMenu.vue')['default']
37
+ AGUINumberField: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUINumberField.vue')['default']
38
+ AGUINumberSlider: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUINumberSlider.vue')['default']
39
+ AGUIOpenDirectory: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/explorer/AGUIOpenDirectory.vue')['default']
40
+ AGUIOverlay: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUIOverlay.vue')['default']
41
+ AGUIPanel: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUIPanel.vue')['default']
42
+ AGUIPropertiesForm: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/panel/AGUIPropertiesForm.vue')['default']
43
+ AGUIPropertiesPanel: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/panel/AGUIPropertiesPanel.vue')['default']
44
+ AGUIProperty: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUIProperty.vue')['default']
45
+ AGUISelect: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/select/AGUISelect.vue')['default']
46
+ AGUISlider: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/AGUISlider.vue')['default']
47
+ AGUITabPanel: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/tabs/AGUITabPanel.vue')['default']
48
+ AGUITabs: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/tabs/AGUITabs.vue')['default']
49
+ AGUIToast: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/toast/AGUIToast.vue')['default']
50
+ AGUIToggleIcon: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/button/AGUIToggleIcon.vue')['default']
51
+ AGUIToolbar: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/toolbar/AGUIToolbar.vue')['default']
52
+ AGUITree: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/tree/AGUITree.vue')['default']
53
+ AGUITreeNode: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/tree/AGUITreeNode.vue')['default']
54
+ BIconChevronLeft: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/icons/BIconChevronLeft.vue')['default']
55
+ BIconChevronRight: typeof import('./../../../../node_modules/.pnpm/@advjs+gui@0.0.5-beta.0_vue@3.4.19/node_modules/@advjs/gui/client/components/icons/BIconChevronRight.vue')['default']
10
56
  PageFrontmatter: typeof import('./components/PageFrontmatter.vue')['default']
57
+ PostPanel: typeof import('./components/PostPanel.vue')['default']
11
58
  RouterLink: typeof import('vue-router')['RouterLink']
12
59
  RouterView: typeof import('vue-router')['RouterView']
60
+ VDPostCategories: typeof import('./components/VDPostCategories.vue')['default']
13
61
  VDPostList: typeof import('./components/VDPostList.vue')['default']
62
+ VDTag: typeof import('./components/VDTag.vue')['default']
14
63
  }
15
64
  }
@@ -1,3 +1,10 @@
1
+ import type { PageData, PostFrontMatter } from 'valaxy'
1
2
  import { ref } from 'vue'
2
3
 
3
- export const frontmatter = ref<object>({})
4
+ import type { Router } from 'vue-router'
5
+
6
+ export const devtoolsRouter = ref<Router>()
7
+ export const activePath = ref('')
8
+
9
+ export const frontmatter = ref<PostFrontMatter>()
10
+ export const pageData = ref<PageData>()
@@ -1,25 +1,18 @@
1
1
  <script lang="ts" setup>
2
2
  import { Pane, Splitpanes } from 'splitpanes'
3
3
  import { onMounted } from 'vue'
4
- import { getWindowProperty, isStaticMode } from '../utils'
5
-
6
- import type { BlogWindow } from '../types'
7
- import { frontmatter } from '../composables/app'
4
+ import { isStaticMode } from '../utils'
8
5
 
9
6
  onMounted(() => {
10
7
  if (isStaticMode)
11
8
  document.title = 'Valaxy DevTools (Production)'
12
-
13
- const $frontmatter = getWindowProperty('$frontmatter') as BlogWindow['$frontmatter']
14
- if ($frontmatter)
15
- frontmatter.value = $frontmatter
16
9
  })
17
10
  </script>
18
11
 
19
12
  <template>
20
13
  <main class="h-full" flex="~ col" text="gray-700 dark:gray-200">
21
- <div class="w-full border-b shadow flex justify-end">
22
- <a href="https://valaxy.site" target="_blank" class="bg-gray-100 inline-flex justify-center items-center w-8 h-8">
14
+ <div class="w-full border-b shadow flex justify-end" dark="border-b-black">
15
+ <a href="https://valaxy.site" target="_blank" class="bg-gray-100 dark:bg-gray-900 inline-flex justify-center items-center w-8 h-8">
23
16
  <div i-ri-book-line />
24
17
  </a>
25
18
  </div>
@@ -30,7 +23,7 @@ onMounted(() => {
30
23
  <VDPostList />
31
24
  </Pane>
32
25
  <Pane>
33
- <PageFrontmatter :frontmatter="frontmatter" />
26
+ <PostPanel />
34
27
  </Pane>
35
28
  </Splitpanes>
36
29
  </div>
@@ -2,3 +2,7 @@ html,
2
2
  body {
3
3
  height: 100%;
4
4
  }
5
+
6
+ .dark {
7
+ background-color: rgba(12, 16, 21);
8
+ }
@@ -1,3 +1,4 @@
1
+ export * from './init'
1
2
  export * from './api'
2
3
  export * from './get'
3
4
 
@@ -0,0 +1,27 @@
1
+ import { nextTick, onMounted } from 'vue'
2
+ import type { Router } from 'vue-router'
3
+ import { activePath, devtoolsRouter, frontmatter, pageData } from '../composables/app'
4
+ import { getWindowProperty } from './get'
5
+
6
+ export function initDevtoolsClient() {
7
+ const __VUE_DEVTOOLS_ROUTER__ = getWindowProperty('__VUE_DEVTOOLS_ROUTER__') as Router
8
+ devtoolsRouter.value = __VUE_DEVTOOLS_ROUTER__
9
+
10
+ devtoolsRouter.value.beforeEach((to, _from, next) => {
11
+ activePath.value = to.path
12
+ next()
13
+ })
14
+
15
+ // init $frontmatter and $pageData
16
+ onMounted(() => {
17
+ frontmatter.value = getWindowProperty('$frontmatter')
18
+ pageData.value = getWindowProperty('$pageData')
19
+ })
20
+
21
+ devtoolsRouter.value.afterEach(async () => {
22
+ await nextTick()
23
+ // get target post $frontmatter
24
+ frontmatter.value = getWindowProperty('$frontmatter')
25
+ pageData.value = getWindowProperty('$pageData')
26
+ })
27
+ }
@@ -4,6 +4,7 @@ import Vue from '@vitejs/plugin-vue'
4
4
  import VueRouter from 'unplugin-vue-router/vite'
5
5
  import VueComponents from 'unplugin-vue-components/vite'
6
6
  import Unocss from 'unocss/vite'
7
+ import { componentsDir } from '@advjs/gui/node'
7
8
  import { unoConfig } from '../../../../uno.config'
8
9
 
9
10
  export default defineConfig({
@@ -57,7 +58,7 @@ export default defineConfig({
57
58
  include: [/\.vue$/, /\.md$/],
58
59
  }),
59
60
  VueComponents({
60
- dirs: ['components'],
61
+ dirs: ['components', componentsDir],
61
62
  dts: join(__dirname, 'components.d.ts'),
62
63
  }),
63
64
  Unocss(unoConfig),
@@ -0,0 +1,35 @@
1
+ import type { ResolvedConfig, ViteDevServer } from 'vite'
2
+ import bodyParser from 'body-parser'
3
+
4
+ import matter from 'gray-matter'
5
+ import fs from 'fs-extra'
6
+
7
+ const prefix = '/valaxy-devtools-api'
8
+
9
+ export function registerApi(server: ViteDevServer, _viteConfig: ResolvedConfig) {
10
+ const app = server.middlewares
11
+
12
+ app.use(bodyParser.json())
13
+
14
+ app.use(`${prefix}/frontmatter`, async (req, _res) => {
15
+ // update
16
+ if (req.method === 'POST') {
17
+ const { pageData, frontmatter: newFm } = await (req as any).body
18
+ // filePath
19
+ const path = pageData.path
20
+ if (fs.existsSync(path)) {
21
+ const rawMd = await fs.readFile(path, 'utf-8')
22
+ const matterFile = matter(rawMd)
23
+
24
+ // update frontmatter
25
+ matterFile.data = newFm
26
+ const newMd = matter.stringify(matterFile.content, matterFile.data)
27
+ await fs.writeFile(path, newMd)
28
+ }
29
+ }
30
+
31
+ // console.log('update', url, frontmatter)
32
+
33
+ // console.log('frontmatter', req.url, res)
34
+ })
35
+ }
package/src/node/index.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'
2
2
  import c from 'picocolors'
3
3
  import sirv from 'sirv'
4
+ import { createProxyMiddleware } from 'http-proxy-middleware'
4
5
  import { DIR_CLIENT } from '../dir'
5
6
  import type { ValaxyDevtoolsOptions } from './types'
7
+ import { registerApi } from './api'
6
8
 
7
9
  const NAME = 'valaxy:devtools'
8
10
 
11
+ // import.meta.env.VITE_DEV_VALAXY_DEVTOOLS = 'true'
12
+
9
13
  export default function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plugin {
10
14
  let config: ResolvedConfig
11
15
 
@@ -13,10 +17,19 @@ export default function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plu
13
17
  const _print = server.printUrls
14
18
  const base = (options.base ?? server.config.base) || '/'
15
19
 
16
- server.middlewares.use(`${base}__valaxy_devtools__`, sirv(DIR_CLIENT, {
17
- single: true,
18
- dev: true,
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
+ }
20
33
 
21
34
  server.printUrls = () => {
22
35
  let host = `${config.server.https ? 'https' : 'http'}://localhost:${config.server.port || '80'}`
@@ -39,11 +52,15 @@ export default function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plu
39
52
  // eslint-disable-next-line no-console
40
53
  console.log(` ${c.green('➜')} ${c.bold('Inspect')}: ${colorUrl(`${host}${base}__inspect/`)}`)
41
54
  }
55
+
56
+ registerApi(server, config)
42
57
  }
43
58
 
44
59
  const plugin = <Plugin>{
45
60
  name: NAME,
46
61
 
62
+ enforce: 'pre',
63
+
47
64
  configResolved(_config) {
48
65
  config = _config
49
66
  },