-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: devtools #24
base: main
Are you sure you want to change the base?
feat: devtools #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"name": "@vue-termui/devtools", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"type": "module", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"stub": "unbuild --stub", | ||
"build": "tsup", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l @vue-termui/devtools -r 1" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./*": "./*" | ||
}, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"bin": { | ||
"vtui-devtools": "./node_modules/.bin/vue-devtools" | ||
}, | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.mjs", | ||
"dist/**/*.cjs", | ||
"dist/**/*.d.ts", | ||
"vtui.mjs" | ||
], | ||
"keywords": [ | ||
"devtools", | ||
"@vue/devtools" | ||
], | ||
"funding": "https://github.com/vue-terminal/vue-termui?sponsor=1", | ||
"license": "MIT", | ||
"author": "webfansplz", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/vue-terminal/vue-termui.git", | ||
"directory": "packages/devtools" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/vue-terminal/vue-termui/issues" | ||
}, | ||
"homepage": "https://github.com/vue-terminal/vue-termui#readme", | ||
"dependencies": { | ||
"@vue/devtools": "^6.4.5", | ||
"express": "^4.18.2", | ||
"launch-editor-middleware": "^2.6.0" | ||
}, | ||
"unbuild": { | ||
"entries": [ | ||
"src/index" | ||
], | ||
"rollup": { | ||
"emitCJS": true | ||
}, | ||
"clean": true | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.14" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare global { | ||
var document: { | ||
title: string | ||
createElement: () => {} | ||
querySelector: () => {} | ||
querySelectorAll: () => [] | ||
} | ||
var VUE_DEVTOOLS_CONFIG: { | ||
openInEditorHost: string | ||
} | ||
} | ||
|
||
export {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import devtools from '@vue/devtools' | ||
import express from 'express' | ||
// @ts-ignore | ||
import launchMiddleware from 'launch-editor-middleware' | ||
|
||
export interface DevtoolsOptions { | ||
title?: string | ||
host?: string | ||
openInEditor?: boolean | ||
} | ||
|
||
const SERVER_PORT = 8098 | ||
|
||
export function createDevtools(options: DevtoolsOptions = {}) { | ||
const { | ||
host = 'http://localhost', | ||
openInEditor = true, | ||
title = 'vue-termui devtools', | ||
} = options | ||
|
||
// workaround for @vue/devtools | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be fixable in @vue/devtools as it has been done in the past like https://github.com/vuejs/devtools/pull/1780/files |
||
global.document = { | ||
title, | ||
createElement: () => ({}), | ||
querySelector: () => ({}), | ||
querySelectorAll: () => [], | ||
} | ||
|
||
if (openInEditor) { | ||
global.VUE_DEVTOOLS_CONFIG = { | ||
openInEditorHost: `${host}:${SERVER_PORT}/`, | ||
} | ||
const app = express() | ||
app.use('/__open-in-editor', launchMiddleware()) | ||
app.listen(SERVER_PORT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reused the I think reused the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah If we move this server to the cli we can probably ensure it's always created before the app starts. It would also ensure only one express app is created even when restarting the app (force reload that isn't yet implemented) |
||
} | ||
|
||
return { | ||
devtools, | ||
connect() { | ||
devtools.connect(host, SERVER_PORT) | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "esnext", | ||
"sourceMap": true, | ||
"lib": ["esnext"] | ||
}, | ||
"include": ["src/*.ts", "src/*.d.ts"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from 'tsup' | ||
import { dependencies } from './package.json' | ||
|
||
export default defineConfig({ | ||
clean: true, | ||
target: 'node14', | ||
format: ['esm', 'cjs'], | ||
dts: true, | ||
esbuildOptions(options) { | ||
if (options.format === 'esm') options.outExtension = { '.js': '.mjs' } | ||
}, | ||
entry: ['src/index.ts'], | ||
external: [...Object.keys(dependencies)], | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
// import devtools from '@vue/devtools' | ||
// import devtools from '@vue/devtools/node' | ||
if (process.env.NODE_ENV === 'development') { | ||
import('@vue-termui/devtools').then(({ createDevtools }) => { | ||
createDevtools().connect() | ||
}) | ||
} | ||
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird it needs to be first though 🤔 if it goes after the othor imports, it gives an error about the port being already used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should probably find a way to add this directly from the |
||
import { createApp } from 'vue-termui' | ||
// import App from './Focusables.vue' | ||
// import App from './Fragments.vue' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add one of these for later: