@vue.ts/complex-types 0.4.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.
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/dist/astro.cjs +22 -0
- package/dist/astro.d.cts +13 -0
- package/dist/astro.d.mts +13 -0
- package/dist/astro.d.ts +13 -0
- package/dist/astro.mjs +20 -0
- package/dist/esbuild.cjs +13 -0
- package/dist/esbuild.d.cts +9 -0
- package/dist/esbuild.d.mts +9 -0
- package/dist/esbuild.d.ts +9 -0
- package/dist/esbuild.mjs +11 -0
- package/dist/index.cjs +228 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +221 -0
- package/dist/nuxt.cjs +35 -0
- package/dist/nuxt.d.cts +9 -0
- package/dist/nuxt.d.mts +9 -0
- package/dist/nuxt.d.ts +9 -0
- package/dist/nuxt.mjs +33 -0
- package/dist/rollup.cjs +13 -0
- package/dist/rollup.d.cts +9 -0
- package/dist/rollup.d.mts +9 -0
- package/dist/rollup.d.ts +9 -0
- package/dist/rollup.mjs +11 -0
- package/dist/rspack.cjs +13 -0
- package/dist/rspack.d.cts +8 -0
- package/dist/rspack.d.mts +8 -0
- package/dist/rspack.d.ts +8 -0
- package/dist/rspack.mjs +11 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +30 -0
- package/dist/types.d.mts +30 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.mjs +1 -0
- package/dist/vite.cjs +13 -0
- package/dist/vite.d.cts +9 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.d.ts +9 -0
- package/dist/vite.mjs +11 -0
- package/dist/webpack.cjs +13 -0
- package/dist/webpack.d.cts +9 -0
- package/dist/webpack.d.mts +9 -0
- package/dist/webpack.d.ts +9 -0
- package/dist/webpack.mjs +11 -0
- package/package.json +107 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { createFilter } from '@vue.ts/common';
|
|
2
|
+
import { getLanguage, ensureLanguage } from '@vue.ts/language';
|
|
3
|
+
import { createUnplugin } from 'unplugin';
|
|
4
|
+
import MagicString from 'magic-string';
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
const resolveOptions = (rawOptions) => ({
|
|
9
|
+
include: rawOptions.include ?? ["**/*.vue"],
|
|
10
|
+
exclude: rawOptions.exclude ?? ["node_modules/**"],
|
|
11
|
+
tsconfigPath: rawOptions.tsconfigPath ?? join(process.cwd(), "tsconfig.json"),
|
|
12
|
+
defineEmits: rawOptions.defineEmits ?? true,
|
|
13
|
+
defineProps: rawOptions.defineProps ?? true
|
|
14
|
+
});
|
|
15
|
+
const quotesReg = /"/g;
|
|
16
|
+
const escapeQuotes = (s) => s.replace(quotesReg, '\\"');
|
|
17
|
+
|
|
18
|
+
class Printer {
|
|
19
|
+
constructor(checker) {
|
|
20
|
+
this.checker = checker;
|
|
21
|
+
}
|
|
22
|
+
getBaseType(nodeOrType) {
|
|
23
|
+
if ("kind" in nodeOrType) {
|
|
24
|
+
nodeOrType = this.checker.getTypeAtLocation(nodeOrType);
|
|
25
|
+
}
|
|
26
|
+
return this.checker.getBaseConstraintOfType(nodeOrType) ?? this.checker.getBaseTypeOfLiteralType(nodeOrType);
|
|
27
|
+
}
|
|
28
|
+
printIntersectionTypeNode(node) {
|
|
29
|
+
return node.types.map((t) => this.printTypeArg(t)).join(" & ");
|
|
30
|
+
}
|
|
31
|
+
printUnionTypeNode(node) {
|
|
32
|
+
return node.types.map((t) => this.printTypeArg(t)).join(" | ");
|
|
33
|
+
}
|
|
34
|
+
printTypeLiteralNode(node) {
|
|
35
|
+
const parts = ["{"];
|
|
36
|
+
for (const member of node.members) {
|
|
37
|
+
if (ts.isPropertySignature(member)) {
|
|
38
|
+
const stringBaseType = member.type ? this.checker.typeToString(this.getBaseType(member.type)) : "any";
|
|
39
|
+
parts.push(
|
|
40
|
+
[
|
|
41
|
+
member.name.getText(),
|
|
42
|
+
member.questionToken?.getText(),
|
|
43
|
+
": ",
|
|
44
|
+
stringBaseType
|
|
45
|
+
].filter(Boolean).join("")
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
parts.push("}");
|
|
50
|
+
return parts.join("\n");
|
|
51
|
+
}
|
|
52
|
+
printByType(node) {
|
|
53
|
+
const type = this.checker.getTypeAtLocation(node);
|
|
54
|
+
const properties = type.getProperties();
|
|
55
|
+
const parts = ["{"];
|
|
56
|
+
let questionToken = "";
|
|
57
|
+
if (ts.isMappedTypeNode(node)) {
|
|
58
|
+
questionToken = node.questionToken?.getText() ?? "";
|
|
59
|
+
}
|
|
60
|
+
for (const property of properties) {
|
|
61
|
+
const valueType = this.checker.getTypeOfSymbol(property);
|
|
62
|
+
const stringValueType = this.checker.typeToString(
|
|
63
|
+
this.getBaseType(valueType)
|
|
64
|
+
);
|
|
65
|
+
parts.push(
|
|
66
|
+
`${this.checker.symbolToString(
|
|
67
|
+
property
|
|
68
|
+
)}${questionToken}: ${stringValueType}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
parts.push("}");
|
|
72
|
+
return parts.join("\n");
|
|
73
|
+
}
|
|
74
|
+
printTypeArg(node) {
|
|
75
|
+
if (ts.isIntersectionTypeNode(node)) {
|
|
76
|
+
return this.printIntersectionTypeNode(node);
|
|
77
|
+
} else if (ts.isUnionTypeNode(node)) {
|
|
78
|
+
return this.printUnionTypeNode(node);
|
|
79
|
+
} else if (ts.isTypeLiteralNode(node)) {
|
|
80
|
+
return this.printTypeLiteralNode(node);
|
|
81
|
+
} else if (ts.isMappedTypeNode(node) || ts.isTypeReferenceNode(node)) {
|
|
82
|
+
return this.printByType(node);
|
|
83
|
+
} else {
|
|
84
|
+
console.error(
|
|
85
|
+
`[unplugin-vue-complex-types] \`${ts.SyntaxKind[node.kind]}\` is not supported.`
|
|
86
|
+
);
|
|
87
|
+
return node.getText();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
printEventsByCallSignatures(callSignatures) {
|
|
91
|
+
return callSignatures.map((c) => {
|
|
92
|
+
const parameters = c.getParameters();
|
|
93
|
+
const event = parameters[0];
|
|
94
|
+
return this.checker.typeToString(this.checker.getTypeOfSymbol(event));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
printEventsByMembers(members) {
|
|
98
|
+
return members.map((m) => `"${escapeQuotes(m.getName())}"`);
|
|
99
|
+
}
|
|
100
|
+
printEventsRuntimeArg(node) {
|
|
101
|
+
const parts = [];
|
|
102
|
+
const type = this.checker.getTypeAtLocation(node);
|
|
103
|
+
const callSignatures = type.getCallSignatures();
|
|
104
|
+
const members = type.getProperties();
|
|
105
|
+
if (callSignatures.length > 0 && members.length > 0) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
"[unplugin-vue-complex-types] You may not use old style `defineEmits` and `defineEmits` shorthand together."
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
if (members.length > 0) {
|
|
111
|
+
parts.push(...this.printEventsByMembers(members));
|
|
112
|
+
} else {
|
|
113
|
+
parts.push(...this.printEventsByCallSignatures(callSignatures));
|
|
114
|
+
}
|
|
115
|
+
return `[${parts.join(", ")}]`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const transformDefineEmits = (printer, s, id) => {
|
|
120
|
+
const language = getLanguage();
|
|
121
|
+
const defineEmits = language.findNodeByRange(
|
|
122
|
+
id,
|
|
123
|
+
(scriptSetupRanges) => scriptSetupRanges.emits.define
|
|
124
|
+
);
|
|
125
|
+
if (!defineEmits) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const scriptSetupAst = language.getScriptSetupAst(id);
|
|
129
|
+
const {
|
|
130
|
+
scriptNode: defineEmitsNode,
|
|
131
|
+
virtualFileNode: virtualFileDefineEmitsNode,
|
|
132
|
+
offset
|
|
133
|
+
} = defineEmits;
|
|
134
|
+
const defineEmitsTypeArg = ts.isCallExpression(virtualFileDefineEmitsNode) && virtualFileDefineEmitsNode.typeArguments?.[0];
|
|
135
|
+
const defineEmitsRuntimeArg = ts.isCallExpression(virtualFileDefineEmitsNode) && virtualFileDefineEmitsNode.arguments[0];
|
|
136
|
+
if (!defineEmitsTypeArg) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (defineEmitsRuntimeArg) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
"[unplugin-vue-complex-types] `defineEmits` cannot accept both runtime argument and type argument."
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
const tokens = defineEmitsNode.getChildren(scriptSetupAst);
|
|
145
|
+
const lessThanToken = tokens.find(
|
|
146
|
+
(t) => t.kind === ts.SyntaxKind.LessThanToken
|
|
147
|
+
);
|
|
148
|
+
const greaterThanToken = tokens.find(
|
|
149
|
+
(t) => t.kind === ts.SyntaxKind.GreaterThanToken
|
|
150
|
+
);
|
|
151
|
+
const openParenToken = tokens.find(
|
|
152
|
+
(t) => t.kind === ts.SyntaxKind.OpenParenToken
|
|
153
|
+
);
|
|
154
|
+
if (!lessThanToken || !greaterThanToken || !openParenToken) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const defineEmitsTypeArgRange = [
|
|
158
|
+
offset + lessThanToken.pos,
|
|
159
|
+
offset + greaterThanToken.end
|
|
160
|
+
];
|
|
161
|
+
const runtimeArgPos = offset + openParenToken.end;
|
|
162
|
+
const printedRuntimeArg = printer.printEventsRuntimeArg(defineEmitsTypeArg);
|
|
163
|
+
s.remove(...defineEmitsTypeArgRange);
|
|
164
|
+
s.appendRight(runtimeArgPos, printedRuntimeArg);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const transformDefineProps = (printer, s, id) => {
|
|
168
|
+
const language = getLanguage();
|
|
169
|
+
const definePropsTypeArg = language.findNodeByRange(
|
|
170
|
+
id,
|
|
171
|
+
(scriptSetupRanges) => scriptSetupRanges.props.define?.typeArg
|
|
172
|
+
);
|
|
173
|
+
if (!definePropsTypeArg) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const { virtualFileNode: typeArgNode, setupRange: typeArgRange } = definePropsTypeArg;
|
|
177
|
+
const printedType = printer.printTypeArg(typeArgNode);
|
|
178
|
+
s.overwrite(typeArgRange.start, typeArgRange.end, printedType);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const transformers = [
|
|
182
|
+
["defineEmits", transformDefineEmits],
|
|
183
|
+
["defineProps", transformDefineProps]
|
|
184
|
+
];
|
|
185
|
+
const getTransformers = (options) => transformers.filter(([key]) => !!options[key]);
|
|
186
|
+
|
|
187
|
+
function transform(code, id, options) {
|
|
188
|
+
const s = new MagicString(code);
|
|
189
|
+
const language = getLanguage();
|
|
190
|
+
const typeChecker = language.__internal__.typeChecker;
|
|
191
|
+
const printer = new Printer(typeChecker);
|
|
192
|
+
const transformers = getTransformers(options);
|
|
193
|
+
for (const [, transform2] of transformers) {
|
|
194
|
+
transform2(printer, s, id);
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
code: s.toString(),
|
|
198
|
+
map: s.generateMap({ hires: true })
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const unplugin = createUnplugin((options = {}) => ({
|
|
203
|
+
name: "@vue.ts/complex-types",
|
|
204
|
+
buildStart() {
|
|
205
|
+
const resolvedOptions = resolveOptions(options);
|
|
206
|
+
ensureLanguage(resolvedOptions.tsconfigPath);
|
|
207
|
+
},
|
|
208
|
+
transform(code, id) {
|
|
209
|
+
const resolvedOptions = resolveOptions(options);
|
|
210
|
+
const filter = createFilter(
|
|
211
|
+
resolvedOptions.include,
|
|
212
|
+
resolvedOptions.exclude
|
|
213
|
+
);
|
|
214
|
+
if (!filter(id)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
return transform(code, id, resolvedOptions);
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
|
|
221
|
+
export { unplugin as default };
|
package/dist/nuxt.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const kit = require('@nuxt/kit');
|
|
4
|
+
const vite = require('./vite.cjs');
|
|
5
|
+
const webpack = require('./webpack.cjs');
|
|
6
|
+
require('./index.cjs');
|
|
7
|
+
require('@vue.ts/common');
|
|
8
|
+
require('@vue.ts/language');
|
|
9
|
+
require('unplugin');
|
|
10
|
+
require('magic-string');
|
|
11
|
+
require('typescript');
|
|
12
|
+
require('node:path');
|
|
13
|
+
|
|
14
|
+
const name = "@vue.ts/complex-types";
|
|
15
|
+
const version = "0.4.0";
|
|
16
|
+
|
|
17
|
+
const nuxt = kit.defineNuxtModule({
|
|
18
|
+
meta: {
|
|
19
|
+
name,
|
|
20
|
+
version,
|
|
21
|
+
configKey: "complexTypes",
|
|
22
|
+
compatibility: {
|
|
23
|
+
bridge: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
defaults: {
|
|
27
|
+
tsconfigPath: "tsconfig.json"
|
|
28
|
+
},
|
|
29
|
+
setup(options) {
|
|
30
|
+
kit.addVitePlugin(vite(options));
|
|
31
|
+
kit.addWebpackPlugin(webpack(options));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
module.exports = nuxt;
|
package/dist/nuxt.d.cts
ADDED
package/dist/nuxt.d.mts
ADDED
package/dist/nuxt.d.ts
ADDED
package/dist/nuxt.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineNuxtModule, addVitePlugin, addWebpackPlugin } from '@nuxt/kit';
|
|
2
|
+
import VitePlugin from './vite.mjs';
|
|
3
|
+
import WebpackPlugin from './webpack.mjs';
|
|
4
|
+
import './index.mjs';
|
|
5
|
+
import '@vue.ts/common';
|
|
6
|
+
import '@vue.ts/language';
|
|
7
|
+
import 'unplugin';
|
|
8
|
+
import 'magic-string';
|
|
9
|
+
import 'typescript';
|
|
10
|
+
import 'node:path';
|
|
11
|
+
|
|
12
|
+
const name = "@vue.ts/complex-types";
|
|
13
|
+
const version = "0.4.0";
|
|
14
|
+
|
|
15
|
+
const nuxt = defineNuxtModule({
|
|
16
|
+
meta: {
|
|
17
|
+
name,
|
|
18
|
+
version,
|
|
19
|
+
configKey: "complexTypes",
|
|
20
|
+
compatibility: {
|
|
21
|
+
bridge: true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaults: {
|
|
25
|
+
tsconfigPath: "tsconfig.json"
|
|
26
|
+
},
|
|
27
|
+
setup(options) {
|
|
28
|
+
addVitePlugin(VitePlugin(options));
|
|
29
|
+
addWebpackPlugin(WebpackPlugin(options));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { nuxt as default };
|
package/dist/rollup.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
require('@vue.ts/common');
|
|
5
|
+
require('@vue.ts/language');
|
|
6
|
+
require('unplugin');
|
|
7
|
+
require('magic-string');
|
|
8
|
+
require('typescript');
|
|
9
|
+
require('node:path');
|
|
10
|
+
|
|
11
|
+
const rollup = index.rollup;
|
|
12
|
+
|
|
13
|
+
module.exports = rollup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as rollup from 'rollup';
|
|
2
|
+
import { Options } from './types.cjs';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as rollup from 'rollup';
|
|
2
|
+
import { Options } from './types.mjs';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
package/dist/rollup.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as rollup from 'rollup';
|
|
2
|
+
import { Options } from './types.js';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
package/dist/rollup.mjs
ADDED
package/dist/rspack.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
require('@vue.ts/common');
|
|
5
|
+
require('@vue.ts/language');
|
|
6
|
+
require('unplugin');
|
|
7
|
+
require('magic-string');
|
|
8
|
+
require('typescript');
|
|
9
|
+
require('node:path');
|
|
10
|
+
|
|
11
|
+
const rspack = index.rspack;
|
|
12
|
+
|
|
13
|
+
module.exports = rspack;
|
package/dist/rspack.d.ts
ADDED
package/dist/rspack.mjs
ADDED
package/dist/types.cjs
ADDED
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseOptions } from '@vue.ts/common';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
declare class Printer {
|
|
6
|
+
private checker;
|
|
7
|
+
constructor(checker: ts.TypeChecker);
|
|
8
|
+
private getBaseType;
|
|
9
|
+
private printIntersectionTypeNode;
|
|
10
|
+
private printUnionTypeNode;
|
|
11
|
+
private printTypeLiteralNode;
|
|
12
|
+
private printByType;
|
|
13
|
+
printTypeArg(node: ts.Node): string;
|
|
14
|
+
private printEventsByCallSignatures;
|
|
15
|
+
private printEventsByMembers;
|
|
16
|
+
printEventsRuntimeArg(node: ts.Node): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ValidTransforms = "defineEmits" | "defineProps";
|
|
20
|
+
type Options = {
|
|
21
|
+
tsconfigPath?: string;
|
|
22
|
+
} & {
|
|
23
|
+
[Transform in ValidTransforms]?: boolean;
|
|
24
|
+
} & BaseOptions;
|
|
25
|
+
type ResolvedOptions = Required<Options>;
|
|
26
|
+
type TransformOptions = Pick<ResolvedOptions, ValidTransforms>;
|
|
27
|
+
type Transformer = (printer: Printer, s: MagicString, id: string) => void;
|
|
28
|
+
type Transformers = [ValidTransforms, Transformer][];
|
|
29
|
+
|
|
30
|
+
export type { Options, ResolvedOptions, TransformOptions, Transformer, Transformers, ValidTransforms };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseOptions } from '@vue.ts/common';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
declare class Printer {
|
|
6
|
+
private checker;
|
|
7
|
+
constructor(checker: ts.TypeChecker);
|
|
8
|
+
private getBaseType;
|
|
9
|
+
private printIntersectionTypeNode;
|
|
10
|
+
private printUnionTypeNode;
|
|
11
|
+
private printTypeLiteralNode;
|
|
12
|
+
private printByType;
|
|
13
|
+
printTypeArg(node: ts.Node): string;
|
|
14
|
+
private printEventsByCallSignatures;
|
|
15
|
+
private printEventsByMembers;
|
|
16
|
+
printEventsRuntimeArg(node: ts.Node): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ValidTransforms = "defineEmits" | "defineProps";
|
|
20
|
+
type Options = {
|
|
21
|
+
tsconfigPath?: string;
|
|
22
|
+
} & {
|
|
23
|
+
[Transform in ValidTransforms]?: boolean;
|
|
24
|
+
} & BaseOptions;
|
|
25
|
+
type ResolvedOptions = Required<Options>;
|
|
26
|
+
type TransformOptions = Pick<ResolvedOptions, ValidTransforms>;
|
|
27
|
+
type Transformer = (printer: Printer, s: MagicString, id: string) => void;
|
|
28
|
+
type Transformers = [ValidTransforms, Transformer][];
|
|
29
|
+
|
|
30
|
+
export type { Options, ResolvedOptions, TransformOptions, Transformer, Transformers, ValidTransforms };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseOptions } from '@vue.ts/common';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
declare class Printer {
|
|
6
|
+
private checker;
|
|
7
|
+
constructor(checker: ts.TypeChecker);
|
|
8
|
+
private getBaseType;
|
|
9
|
+
private printIntersectionTypeNode;
|
|
10
|
+
private printUnionTypeNode;
|
|
11
|
+
private printTypeLiteralNode;
|
|
12
|
+
private printByType;
|
|
13
|
+
printTypeArg(node: ts.Node): string;
|
|
14
|
+
private printEventsByCallSignatures;
|
|
15
|
+
private printEventsByMembers;
|
|
16
|
+
printEventsRuntimeArg(node: ts.Node): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ValidTransforms = "defineEmits" | "defineProps";
|
|
20
|
+
type Options = {
|
|
21
|
+
tsconfigPath?: string;
|
|
22
|
+
} & {
|
|
23
|
+
[Transform in ValidTransforms]?: boolean;
|
|
24
|
+
} & BaseOptions;
|
|
25
|
+
type ResolvedOptions = Required<Options>;
|
|
26
|
+
type TransformOptions = Pick<ResolvedOptions, ValidTransforms>;
|
|
27
|
+
type Transformer = (printer: Printer, s: MagicString, id: string) => void;
|
|
28
|
+
type Transformers = [ValidTransforms, Transformer][];
|
|
29
|
+
|
|
30
|
+
export type { Options, ResolvedOptions, TransformOptions, Transformer, Transformers, ValidTransforms };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
require('@vue.ts/common');
|
|
5
|
+
require('@vue.ts/language');
|
|
6
|
+
require('unplugin');
|
|
7
|
+
require('magic-string');
|
|
8
|
+
require('typescript');
|
|
9
|
+
require('node:path');
|
|
10
|
+
|
|
11
|
+
const VitePlugin = index.vite;
|
|
12
|
+
|
|
13
|
+
module.exports = VitePlugin;
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Options } from './types.cjs';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Options } from './types.mjs';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Options } from './types.js';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import unplugin from './index.mjs';
|
|
2
|
+
import '@vue.ts/common';
|
|
3
|
+
import '@vue.ts/language';
|
|
4
|
+
import 'unplugin';
|
|
5
|
+
import 'magic-string';
|
|
6
|
+
import 'typescript';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
|
|
9
|
+
const VitePlugin = unplugin.vite;
|
|
10
|
+
|
|
11
|
+
export { VitePlugin as default };
|
package/dist/webpack.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
require('@vue.ts/common');
|
|
5
|
+
require('@vue.ts/language');
|
|
6
|
+
require('unplugin');
|
|
7
|
+
require('magic-string');
|
|
8
|
+
require('typescript');
|
|
9
|
+
require('node:path');
|
|
10
|
+
|
|
11
|
+
const WebpackPlugin = index.webpack;
|
|
12
|
+
|
|
13
|
+
module.exports = WebpackPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { Options } from './types.cjs';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options: Options) => WebpackPluginInstance;
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { Options } from './types.mjs';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options: Options) => WebpackPluginInstance;
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { Options } from './types.js';
|
|
3
|
+
import '@vue.ts/common';
|
|
4
|
+
import 'magic-string';
|
|
5
|
+
import 'typescript';
|
|
6
|
+
|
|
7
|
+
declare const _default: (options: Options) => WebpackPluginInstance;
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
package/dist/webpack.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import unplugin from './index.mjs';
|
|
2
|
+
import '@vue.ts/common';
|
|
3
|
+
import '@vue.ts/language';
|
|
4
|
+
import 'unplugin';
|
|
5
|
+
import 'magic-string';
|
|
6
|
+
import 'typescript';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
|
|
9
|
+
const WebpackPlugin = unplugin.webpack;
|
|
10
|
+
|
|
11
|
+
export { WebpackPlugin as default };
|