@vue.ts/complex-types 0.5.0 → 1.0.0-beta.1

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