Skip to content

Commit bd4eda1

Browse files
authored
feat: vue-devtools plugin (#126)
* setup vue-devtools-api * formatting * add custom inspector * add emitter * WIP: timeline implementation * updates * update * add compile error events to timeline * remove not used codes * updates
1 parent 9a68b1f commit bd4eda1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3543
-164
lines changed

devtools-test/assets/logo.png

10.3 KB
Loading

devtools-test/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title></title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.ts"></script>
11+
</body>
12+
</html>

devtools-test/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "devtools-test",
3+
"private": true,
4+
"version": "0.0.0",
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build"
8+
},
9+
"dependencies": {
10+
"vue": "^3.0.0",
11+
"vue-i18n": "link:.."
12+
},
13+
"devDependencies": {
14+
"vite": "^1.0.0-rc.4",
15+
"@intlify/vite-plugin-vue-i18n": "^1.0.0-alpha.1",
16+
"@types/js-yaml": "^3.12.4",
17+
"@types/json5": "^0.0.30",
18+
"js-yaml": "^3.14.0",
19+
"json5": "^2.1.3",
20+
"typescript": "^4.0.2",
21+
"@vue/compiler-sfc": "^3.0.0"
22+
}
23+
}

devtools-test/src/App.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<img alt="Vue I18n logo" src="../assets/logo.png" />
3+
<form>
4+
<label>{{ $t('language') }}</label>
5+
<select v-model="$i18n.locale">
6+
<option value="en">en</option>
7+
<option value="ja">ja</option>
8+
</select>
9+
</form>
10+
<HelloI18n />
11+
</template>
12+
13+
<script lang="ts">
14+
import { defineComponent } from 'vue'
15+
import HelloI18n from './components/HelloI18n.vue'
16+
17+
export default defineComponent({
18+
name: 'App',
19+
components: {
20+
HelloI18n
21+
}
22+
})
23+
</script>
24+
25+
<style scoped>
26+
form {
27+
margin-top: 48px;
28+
}
29+
30+
label {
31+
margin-right: 8px;
32+
}
33+
</style>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<h1>{{ t('hello') }}</h1>
3+
<button @click="count++">{{ t('count', { count }) }}</button>
4+
</template>
5+
6+
<script lang="ts">
7+
import { ref, defineComponent } from 'vue'
8+
import { useI18n } from 'vue-i18n'
9+
10+
export default defineComponent({
11+
name: 'HelloI18n',
12+
setup() {
13+
const count = ref(0)
14+
15+
// use local composer
16+
const { t } = useI18n({
17+
// `locale` inherit from global composer
18+
inheritLocale: true
19+
})
20+
21+
return { count, t }
22+
}
23+
})
24+
</script>
25+
26+
<i18n>
27+
{
28+
"en": {
29+
"hello": "Hello Vue I18n 9.0 🌏!",
30+
"count": "count is: {count}"
31+
},
32+
"ja": {
33+
"hello": "こんにちは Vue I18n 9.0 🌏!",
34+
"count": "カウントは{count}です"
35+
}
36+
}
37+
</i18n>

devtools-test/src/index.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#app {
2+
font-family: Avenir, Helvetica, Arial, sans-serif;
3+
-webkit-font-smoothing: antialiased;
4+
-moz-osx-font-smoothing: grayscale;
5+
text-align: center;
6+
color: #2c3e50;
7+
margin-top: 60px;
8+
}

devtools-test/src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"language": "Languages"
3+
}

devtools-test/src/locales/ja.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"language": "言語"
3+
}

devtools-test/src/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createApp } from 'vue'
2+
import { createI18n } from 'vue-i18n'
3+
import App from './App.vue'
4+
import './index.css'
5+
import en from './locales/en.json'
6+
import ja from './locales/ja.json'
7+
8+
const i18n = createI18n({
9+
locale: 'en',
10+
messages: {
11+
en,
12+
ja
13+
}
14+
})
15+
16+
createApp(App).use(i18n).mount('#app')

devtools-test/tsconfig.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
5+
/* Basic Options */
6+
// "incremental": true, /* Enable incremental compilation */
7+
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8+
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9+
"lib": ["dom", "esnext"], /* Specify library files to be included in the compilation. */
10+
// "allowJs": true, /* Allow javascript files to be compiled. */
11+
// "checkJs": true, /* Report errors in .js files. */
12+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
14+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15+
// "sourceMap": true, /* Generates corresponding '.map' file. */
16+
// "outFile": "./", /* Concatenate and emit output to single file. */
17+
// "outDir": "./", /* Redirect output structure to the directory. */
18+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19+
// "composite": true, /* Enable project compilation */
20+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21+
// "removeComments": true, /* Do not emit comments to output. */
22+
// "noEmit": true, /* Do not emit outputs. */
23+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
24+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26+
27+
/* Strict Type-Checking Options */
28+
"strict": true, /* Enable all strict type-checking options. */
29+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30+
// "strictNullChecks": true, /* Enable strict null checks. */
31+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
32+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36+
37+
/* Additional Checks */
38+
// "noUnusedLocals": true, /* Report errors on unused locals. */
39+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
40+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42+
43+
/* Module Resolution Options */
44+
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
45+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
48+
// "typeRoots": [], /* List of folders to include type definitions from. */
49+
"types": [
50+
"./node_modules/@types",
51+
"./node_modules/vite/dist",
52+
"./node_modules/vue-i18n/dist"
53+
], /* Type declaration files to be included in compilation. */
54+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
55+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
56+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
57+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
58+
59+
/* Source Map Options */
60+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
61+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
62+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
63+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
64+
65+
/* Experimental Options */
66+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
67+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
68+
69+
/* Advanced Options */
70+
"skipLibCheck": true, /* Skip type checking of declaration files. */
71+
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
72+
73+
"resolveJsonModule": true
74+
},
75+
"exclude": ["node_modules", "dist"]
76+
}

0 commit comments

Comments
 (0)