@vue/language-core 3.2.4 → 3.2.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.
- package/README.md +160 -0
- package/lib/plugins/vue-template-html.js +6 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @vue/language-core
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@vue/language-core"><img src="https://img.shields.io/npm/v/@vue/language-core.svg?labelColor=18181B&color=1584FC" alt="NPM version"></a>
|
|
5
|
+
<a href="https://github.com/vuejs/language-tools/blob/master/LICENSE"><img src="https://img.shields.io/github/license/vuejs/language-tools.svg?labelColor=18181B&color=1584FC" alt="License"></a>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
The core module for Vue Language Tools, responsible for parsing Vue Single File Components (SFCs) and transforming them into virtual code structures that TypeScript can understand. This package is a low-level dependency for `@vue/language-server` and `vue-tsc`.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @vue/language-core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Core API
|
|
17
|
+
|
|
18
|
+
### `createVueLanguagePlugin`
|
|
19
|
+
|
|
20
|
+
Creates a Vue language plugin for integration with Volar language services.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createVueLanguagePlugin } from '@vue/language-core';
|
|
24
|
+
import type { LanguagePlugin } from '@volar/language-core';
|
|
25
|
+
import ts from 'typescript';
|
|
26
|
+
|
|
27
|
+
const plugin: LanguagePlugin<string> = createVueLanguagePlugin(
|
|
28
|
+
ts,
|
|
29
|
+
compilerOptions, // ts.CompilerOptions
|
|
30
|
+
vueCompilerOptions, // VueCompilerOptions
|
|
31
|
+
(scriptId) => scriptId // asFileName: Converts scriptId to a file name
|
|
32
|
+
);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `createParsedCommandLine`
|
|
36
|
+
|
|
37
|
+
Parses TypeScript and Vue compiler options from `tsconfig.json`.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { createParsedCommandLine } from '@vue/language-core';
|
|
41
|
+
import ts from 'typescript';
|
|
42
|
+
|
|
43
|
+
const parsed = createParsedCommandLine(ts, ts.sys, '/path/to/tsconfig.json');
|
|
44
|
+
// parsed.options: ts.CompilerOptions
|
|
45
|
+
// parsed.vueOptions: VueCompilerOptions
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### `parse`
|
|
49
|
+
|
|
50
|
+
Parses Vue SFC source code and returns an `SFCParseResult`.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { parse } from '@vue/language-core';
|
|
54
|
+
|
|
55
|
+
const result = parse(`
|
|
56
|
+
<template>
|
|
57
|
+
<div>{{ msg }}</div>
|
|
58
|
+
</template>
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
const msg = 'Hello'
|
|
61
|
+
</script>
|
|
62
|
+
`);
|
|
63
|
+
|
|
64
|
+
// result.descriptor.template
|
|
65
|
+
// result.descriptor.scriptSetup
|
|
66
|
+
// result.descriptor.styles
|
|
67
|
+
// result.errors
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## `vueCompilerOptions`
|
|
71
|
+
|
|
72
|
+
Configure Vue compiler behavior through the `vueCompilerOptions` field in `tsconfig.json`:
|
|
73
|
+
|
|
74
|
+
```jsonc
|
|
75
|
+
{
|
|
76
|
+
"compilerOptions": { /* ... */ },
|
|
77
|
+
"vueCompilerOptions": {
|
|
78
|
+
"target": 3.5,
|
|
79
|
+
"strictTemplates": true,
|
|
80
|
+
"plugins": ["@vue/language-plugin-pug"]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### File Handling Options
|
|
86
|
+
|
|
87
|
+
| Option | Type | Default | Description |
|
|
88
|
+
| :--- | :--- | :--- | :--- |
|
|
89
|
+
| `target` | `number \| 'auto'` | `'auto'` | Vue version. `'auto'` reads from `node_modules/vue/package.json`. |
|
|
90
|
+
| `extensions` | `string[]` | `['.vue']` | File extensions to be treated as Vue SFCs. |
|
|
91
|
+
| `vitePressExtensions` | `string[]` | `[]` | File extensions to be treated as VitePress Markdown. |
|
|
92
|
+
| `petiteVueExtensions` | `string[]` | `[]` | File extensions to be treated as Petite Vue HTML. |
|
|
93
|
+
| `plugins` | `string[]` | `[]` | Custom language plugins, e.g., [`@vue/language-plugin-pug`](../language-plugin-pug). |
|
|
94
|
+
|
|
95
|
+
### Type Checking Options
|
|
96
|
+
|
|
97
|
+
| Option | Type | Default | Description |
|
|
98
|
+
| :--- | :--- | :--- | :--- |
|
|
99
|
+
| `strictTemplates` | `boolean` | `false` | A convenience option that enables the four `check*` options below and `strictVModel`. |
|
|
100
|
+
| `checkUnknownProps` | `boolean` | `false` | Check for unknown props. |
|
|
101
|
+
| `checkUnknownEvents` | `boolean` | `false` | Check for unknown events. |
|
|
102
|
+
| `checkUnknownComponents` | `boolean` | `false` | Check for unknown components. |
|
|
103
|
+
| `checkUnknownDirectives` | `boolean` | `false` | Check for unknown directives. |
|
|
104
|
+
| `strictVModel` | `boolean` | `false` | Strictly check v-model bindings. |
|
|
105
|
+
| `strictCssModules` | `boolean` | `false` | Strictly check CSS Modules class names (not affected by `strictTemplates`). |
|
|
106
|
+
|
|
107
|
+
### Advanced Options
|
|
108
|
+
|
|
109
|
+
| Option | Type | Default | Description |
|
|
110
|
+
| :--- | :--- | :--- | :--- |
|
|
111
|
+
| `lib` | `string` | `'vue'` | Vue package name, used for generating import statements. |
|
|
112
|
+
| `skipTemplateCodegen` | `boolean` | `false` | Skip virtual code generation for templates. |
|
|
113
|
+
| `fallthroughAttributes` | `boolean` | `false` | Enable type inference for fallthrough attributes. |
|
|
114
|
+
| `jsxSlots` | `boolean` | `false` | Use JSX-style slots types. |
|
|
115
|
+
| `dataAttributes` | `string[]` | `[]` | Allowed data-* attribute patterns. |
|
|
116
|
+
| `htmlAttributes` | `string[]` | `['aria-*']` | Allowed HTML attribute patterns. |
|
|
117
|
+
| `resolveStyleImports` | `boolean` | `false` | Resolve import statements in styles. |
|
|
118
|
+
| `resolveStyleClassNames` | `boolean \| 'scoped'` | `'scoped'` | Resolve class names in styles. |
|
|
119
|
+
|
|
120
|
+
## Built-in Plugins
|
|
121
|
+
|
|
122
|
+
This package includes the following built-in plugins to handle different file types and blocks:
|
|
123
|
+
|
|
124
|
+
### File Parsing Plugins
|
|
125
|
+
|
|
126
|
+
| Plugin | Function | Controlled By |
|
|
127
|
+
| :--- | :--- | :--- |
|
|
128
|
+
| `file-vue` | Parses `.vue` files into an SFC structure. | `extensions` |
|
|
129
|
+
| `file-md` | Parses Markdown files into an SFC structure. | `vitePressExtensions` |
|
|
130
|
+
| `file-html` | Parses HTML files into an SFC structure. | `petiteVueExtensions` |
|
|
131
|
+
|
|
132
|
+
### Virtual Code Generation Plugins
|
|
133
|
+
|
|
134
|
+
| Plugin | Function |
|
|
135
|
+
| :--- | :--- |
|
|
136
|
+
| `vue-tsx` | Generates TypeScript virtual code from an SFC. |
|
|
137
|
+
| `vue-template-html` | Compiles HTML templates. |
|
|
138
|
+
| `vue-template-inline-ts` | Handles TypeScript expressions in templates. |
|
|
139
|
+
| `vue-template-inline-css` | Handles inline styles in templates. |
|
|
140
|
+
| `vue-style-css` | Compiles CSS styles. |
|
|
141
|
+
| `vue-script-js` | Handles JavaScript script blocks. |
|
|
142
|
+
|
|
143
|
+
### Embedded Code Extraction Plugins
|
|
144
|
+
|
|
145
|
+
| Plugin | Function |
|
|
146
|
+
| :--- | :--- |
|
|
147
|
+
| `vue-sfc-template` | Extracts the `<template>` block. |
|
|
148
|
+
| `vue-sfc-styles` | Extracts `<style>` blocks. |
|
|
149
|
+
| `vue-sfc-scripts` | Extracts `<script>` blocks (for formatting). |
|
|
150
|
+
| `vue-sfc-customblocks` | Extracts custom blocks. |
|
|
151
|
+
|
|
152
|
+
## Related Packages
|
|
153
|
+
|
|
154
|
+
- [`@vue/language-server`](../language-server) - Language Server
|
|
155
|
+
- [`@vue/language-service`](../language-service) - Language Service
|
|
156
|
+
- [`vue-tsc`](../tsc) - Command-line Type Checker
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
[MIT](https://github.com/vuejs/language-tools/blob/master/LICENSE) License
|
|
@@ -152,6 +152,12 @@ const plugin = ({ modules }) => {
|
|
|
152
152
|
if (!tryUpdateNode(node.content)) {
|
|
153
153
|
return false;
|
|
154
154
|
}
|
|
155
|
+
if (node.content.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
156
|
+
const { content } = node.content;
|
|
157
|
+
if (content.includes('{{') || content.includes('}}')) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
155
161
|
}
|
|
156
162
|
else if (node.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
157
163
|
if (withinChangeRange(node.loc)) { // TODO: review this (slot name?)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "2.4.
|
|
16
|
+
"@volar/language-core": "2.4.28",
|
|
17
17
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
18
|
"@vue/shared": "^3.5.0",
|
|
19
19
|
"alien-signals": "^3.0.0",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/node": "^22.10.4",
|
|
26
26
|
"@types/path-browserify": "^1.0.1",
|
|
27
27
|
"@types/picomatch": "^4.0.0",
|
|
28
|
-
"@volar/typescript": "2.4.
|
|
28
|
+
"@volar/typescript": "2.4.28",
|
|
29
29
|
"@vue/compiler-sfc": "^3.5.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "ee5041d27940cf6f9a5150635d3b13140a9dff54"
|
|
32
32
|
}
|