@vue.ts/complex-types 1.0.0-beta.7 → 1.0.0-beta.9

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/dist/astro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
2
 
3
3
  //#region src/astro.d.ts
4
4
  declare const _default: (options: Options) => {
package/dist/astro.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
 
4
4
  //#region src/astro.ts
package/dist/esbuild.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as esbuild0 from "esbuild";
4
4
 
5
5
  //#region src/esbuild.d.ts
package/dist/esbuild.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createEsbuildPlugin } from "unplugin";
3
3
 
4
4
  //#region src/esbuild.ts
package/dist/farm.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as _farmfe_core0 from "@farmfe/core";
4
4
 
5
5
  //#region src/farm.d.ts
package/dist/farm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createFarmPlugin } from "unplugin";
3
3
 
4
4
  //#region src/farm.ts
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
2
  import * as unplugin0 from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
 
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as unplugin, r as unpluginFactory, t as src_default } from "./src-BrjMgGhR.js";
1
+ import { n as unplugin, r as unpluginFactory, t as src_default } from "./src-wLNIJnZT.js";
2
2
 
3
3
  export { src_default as default, unplugin, unpluginFactory };
package/dist/nuxt.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as _nuxt_schema0 from "@nuxt/schema";
4
4
 
5
5
  //#region src/nuxt.d.ts
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./src-BrjMgGhR.js";
2
- import { t as vite_default } from "./vite-ji592KVg.js";
3
- import { t as webpack_default } from "./webpack-BxPL7HeA.js";
1
+ import "./src-wLNIJnZT.js";
2
+ import { t as vite_default } from "./vite-B7R6skxU.js";
3
+ import { t as webpack_default } from "./webpack-CVxLsdbd.js";
4
4
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
5
5
 
6
6
  //#region src/nuxt.ts
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as rolldown0 from "rolldown";
4
4
 
5
5
  //#region src/rolldown.d.ts
package/dist/rolldown.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createRolldownPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rolldown.ts
package/dist/rollup.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as rollup0 from "rollup";
4
4
 
5
5
  //#region src/rollup.d.ts
package/dist/rollup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createRollupPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rollup.ts
package/dist/rspack.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
 
4
4
  //#region src/rspack.d.ts
5
5
  declare const _default: (options?: Options | undefined) => RspackPluginInstance;
package/dist/rspack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createRspackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rspack.ts
@@ -1,10 +1,12 @@
1
1
  import { createUnplugin } from "unplugin";
2
2
  import { ensureLanguage, getLanguage } from "@vue.ts/language";
3
- import { createFilter, normalizePath } from "@vue.ts/shared";
3
+ import { createFilter } from "unplugin-utils";
4
4
  import MagicString from "magic-string";
5
5
  import ts from "typescript";
6
6
  import { join } from "node:path";
7
7
  import { defu } from "defu";
8
+ import { normalizePath } from "@vue.ts/shared";
9
+ import { isReservedProp } from "@vue/shared";
8
10
 
9
11
  //#region src/core/utils.ts
10
12
  const defaultOptions = {
@@ -27,17 +29,17 @@ var Printer = class {
27
29
  typeToString(type) {
28
30
  return this.checker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
29
31
  }
30
- printUnionOrIntersection(type, separator, inner) {
31
- return [...new Set(type.types.map((t) => this.printType(t, inner)).filter(Boolean))].join(separator);
32
+ printUnionOrIntersection(type, separator, isPropertyBlacklisted, inner) {
33
+ return [...new Set(type.types.map((t) => this.printType(t, isPropertyBlacklisted, inner)).filter(Boolean))].join(separator);
32
34
  }
33
- containsUndefined(type) {
34
- return type.isUnion() ? type.types.some((t) => t.flags & ts.TypeFlags.Undefined) : !!(type.flags & ts.TypeFlags.Undefined);
35
+ isSymbolOptional(symbol) {
36
+ return !!(symbol.flags & ts.SymbolFlags.Optional);
35
37
  }
36
- printConditionType(type, inner) {
38
+ printConditionType(type, isPropertyBlacklisted, inner) {
37
39
  const { trueType, falseType } = type.root.node;
38
40
  const trueTypeNode = this.checker.getTypeAtLocation(trueType);
39
41
  const falseTypeNode = this.checker.getTypeAtLocation(falseType);
40
- return `${this.printType(trueTypeNode, inner)} | ${this.printType(falseTypeNode, inner)}`;
42
+ return `${this.printType(trueTypeNode, isPropertyBlacklisted, inner)} | ${this.printType(falseTypeNode, isPropertyBlacklisted, inner)}`;
41
43
  }
42
44
  printPrimitiveType(type) {
43
45
  if (type.flags & ts.TypeFlags.BooleanLiteral) return "boolean";
@@ -49,9 +51,9 @@ var Printer = class {
49
51
  else if (type.flags & ts.TypeFlags.Null) return "null";
50
52
  return "";
51
53
  }
52
- printType(type, inner = false) {
53
- if (type.isUnion()) return this.printUnionOrIntersection(type, " | ", inner);
54
- else if (type.isIntersection()) return this.printUnionOrIntersection(type, " & ", inner);
54
+ printType(type, isPropertyBlacklisted, inner = false) {
55
+ if (type.isUnion()) return this.printUnionOrIntersection(type, " | ", isPropertyBlacklisted, inner);
56
+ else if (type.isIntersection()) return this.printUnionOrIntersection(type, " & ", isPropertyBlacklisted, inner);
55
57
  if (this.checker.isArrayType(type)) return "Array";
56
58
  else if (type.flags & ts.TypeFlags.Object) {
57
59
  const decl = type.getSymbol()?.declarations?.[0];
@@ -61,9 +63,11 @@ var Printer = class {
61
63
  const props = {};
62
64
  for (const prop of properties) {
63
65
  const propType = this.checker.getTypeOfSymbol(prop);
64
- props[prop.getName()] = {
65
- value: this.printType(propType, true),
66
- isOptional: this.containsUndefined(propType)
66
+ const name = prop.getName();
67
+ if (isPropertyBlacklisted(name)) continue;
68
+ props[name] = {
69
+ value: this.printType(propType, isPropertyBlacklisted, true),
70
+ isOptional: this.isSymbolOptional(prop)
67
71
  };
68
72
  }
69
73
  const parts = [];
@@ -74,20 +78,20 @@ var Printer = class {
74
78
  return Object.keys(props).length > 0 ? `{\n${parts.join("\n")}\n}` : "";
75
79
  } else if (type.isLiteral() || type.flags & ts.TypeFlags.BooleanLiteral || type.flags & ts.TypeFlags.String || type.flags & ts.TypeFlags.Number || type.flags & ts.TypeFlags.BigInt || type.flags & ts.TypeFlags.Any || type.flags & ts.TypeFlags.Unknown || type.flags & ts.TypeFlags.Null) return this.printPrimitiveType(type);
76
80
  else if (type.flags & ts.TypeFlags.Undefined) return "";
77
- else if (type.flags & ts.TypeFlags.Conditional) return this.printConditionType(type, inner);
81
+ else if (type.flags & ts.TypeFlags.Conditional) return this.printConditionType(type, isPropertyBlacklisted, inner);
78
82
  else if (type.isTypeParameter()) {
79
83
  const decl = type.getSymbol()?.declarations?.[0];
80
84
  if (!decl || !ts.isTypeParameterDeclaration(decl)) return "";
81
85
  const ref = ts.getEffectiveConstraintOfTypeParameter(decl);
82
86
  if (!ref) return "";
83
87
  const refType = this.checker.getTypeAtLocation(ref);
84
- return this.printType(refType, inner);
88
+ return this.printType(refType, isPropertyBlacklisted, inner);
85
89
  }
86
90
  return this.typeToString(type);
87
91
  }
88
- printPropsTypeArg(node) {
92
+ printPropsTypeArg(node, isPropertyBlacklisted) {
89
93
  const type = this.checker.getTypeAtLocation(node);
90
- return this.printType(type);
94
+ return this.printType(type, isPropertyBlacklisted);
91
95
  }
92
96
  printEventsByCallSignatures(callSignatures) {
93
97
  return callSignatures.map((c) => {
@@ -148,7 +152,7 @@ const transformDefineProps = (printer, s, id) => {
148
152
  const scriptSetupDefinePropsTypeRange = language.parseScriptSetupRanges(scriptSetupAst).defineProps?.typeArg;
149
153
  const virtualFileDefinePropsTypeNode = language.findNodeByName(virtualFileAst, "__VLS_Props");
150
154
  if (!scriptSetupDefinePropsTypeRange || !virtualFileDefinePropsTypeNode) return;
151
- const printedType = printer.printPropsTypeArg(virtualFileDefinePropsTypeNode);
155
+ const printedType = printer.printPropsTypeArg(virtualFileDefinePropsTypeNode, isReservedProp);
152
156
  const offset = scriptSetupBlock.startTagEnd;
153
157
  s.overwrite(offset + scriptSetupDefinePropsTypeRange.start, offset + scriptSetupDefinePropsTypeRange.end, printedType);
154
158
  };
@@ -174,18 +178,47 @@ function transform(code, id, options) {
174
178
 
175
179
  //#endregion
176
180
  //#region src/index.ts
181
+ const languageExtRegexp = /\.((?:c|m)?(?:j|t)sx?|d\.ts|vue)$/i;
177
182
  const unpluginFactory = (options = {}) => {
178
183
  const resolvedOptions = resolveOptions(options);
179
184
  const filter = createFilter(resolvedOptions.include, resolvedOptions.exclude);
180
185
  return {
181
186
  name: "@vue.ts/complex-types",
182
187
  enforce: "pre",
188
+ vite: { async handleHotUpdate(ctx) {
189
+ const { file } = ctx;
190
+ if (!languageExtRegexp.test(file)) return;
191
+ const language = getLanguage();
192
+ const { read } = ctx;
193
+ async function readAndUpdateLanguage() {
194
+ const content = await read();
195
+ language.updateFile(file, content);
196
+ return content;
197
+ }
198
+ if (!filter(file)) {
199
+ await readAndUpdateLanguage();
200
+ return;
201
+ }
202
+ let cached;
203
+ ctx.read = async () => {
204
+ cached ??= (async () => {
205
+ const code = await readAndUpdateLanguage();
206
+ return transform(code, file, resolvedOptions)?.code ?? code;
207
+ })();
208
+ return cached;
209
+ };
210
+ for (const mod of ctx.modules) ctx.server.moduleGraph.invalidateModule(mod);
211
+ return ctx.modules;
212
+ } },
183
213
  buildStart() {
184
214
  ensureLanguage(resolveOptions(options).tsconfigPath);
185
215
  },
186
- transform(code, id) {
187
- if (!filter(id)) return;
188
- return transform(code, id, resolvedOptions);
216
+ transform: {
217
+ filter: { id: {
218
+ include: resolvedOptions.include,
219
+ exclude: resolvedOptions.exclude
220
+ } },
221
+ handler: (code, id) => transform(code, id, resolvedOptions)
189
222
  }
190
223
  };
191
224
  };
@@ -1,6 +1,6 @@
1
+ import { FilterPattern } from "unplugin";
1
2
  import MagicString from "magic-string";
2
3
  import ts from "typescript";
3
- import { FilterPattern } from "@rollup/pluginutils";
4
4
 
5
5
  //#region ../shared/src/types.d.ts
6
6
  interface BaseOptions {
@@ -14,11 +14,11 @@ declare class Printer {
14
14
  constructor(checker: ts.TypeChecker);
15
15
  private typeToString;
16
16
  private printUnionOrIntersection;
17
- private containsUndefined;
17
+ private isSymbolOptional;
18
18
  private printConditionType;
19
19
  private printPrimitiveType;
20
20
  private printType;
21
- printPropsTypeArg(node: ts.Node): string;
21
+ printPropsTypeArg(node: ts.Node, isPropertyBlacklisted: (prop: string) => boolean): string;
22
22
  private printEventsByCallSignatures;
23
23
  private printEventsByMembers;
24
24
  printEventsRuntimeArg(node: ts.Node): string;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as Transformers, i as Transformer, n as ResolvedOptions, o as ValidTransforms, r as TransformOptions, t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { a as Transformers, i as Transformer, n as ResolvedOptions, o as ValidTransforms, r as TransformOptions, t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  export { Options, ResolvedOptions, TransformOptions, Transformer, Transformers, ValidTransforms };
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
 
4
4
  //#region src/vite.ts
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as vite0 from "vite";
4
4
 
5
5
  //#region src/vite.d.ts
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-BrjMgGhR.js";
2
- import { t as vite_default } from "./vite-ji592KVg.js";
1
+ import "./src-wLNIJnZT.js";
2
+ import { t as vite_default } from "./vite-B7R6skxU.js";
3
3
 
4
4
  export { vite_default as default };
@@ -1,4 +1,4 @@
1
- import { r as unpluginFactory } from "./src-BrjMgGhR.js";
1
+ import { r as unpluginFactory } from "./src-wLNIJnZT.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/webpack.ts
package/dist/webpack.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Options } from "./types-DoyG2eeQ.js";
2
- import "./types-B3d3HWOR.js";
1
+ import { t as Options } from "./types-B0cfnWIB.js";
2
+ import "./types-u_Hr5uXA.js";
3
3
  import * as webpack0 from "webpack";
4
4
 
5
5
  //#region src/webpack.d.ts
package/dist/webpack.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-BrjMgGhR.js";
2
- import { t as webpack_default } from "./webpack-BxPL7HeA.js";
1
+ import "./src-wLNIJnZT.js";
2
+ import { t as webpack_default } from "./webpack-CVxLsdbd.js";
3
3
 
4
4
  export { webpack_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue.ts/complex-types",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0-beta.9",
4
4
  "author": "Ray <i@mk1.io> (@so1ve)",
5
5
  "type": "module",
6
6
  "description": "Resolve complex types in Vue SFCs.",
@@ -63,18 +63,20 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@nuxt/kit": "^4.2.0",
66
+ "@vue/shared": "^3.5.22",
66
67
  "defu": "^6.1.4",
67
68
  "magic-string": "^0.30.21",
68
- "unplugin": "^2.3.10",
69
- "@vue.ts/language": "1.0.0-beta.7",
70
- "@vue.ts/shared": "1.0.0-beta.7"
69
+ "unplugin": "2.3.10",
70
+ "unplugin-utils": "^0.3.1",
71
+ "@vue.ts/language": "1.0.0-beta.9",
72
+ "@vue.ts/shared": "1.0.0-beta.9"
71
73
  },
72
74
  "devDependencies": {
73
75
  "@nuxt/schema": "^4.2.0",
74
76
  "@vue-macros/better-define": "^3.1.1",
75
- "rolldown": "1.0.0-beta.27",
77
+ "rolldown": "1.0.0-beta.45",
76
78
  "rollup": "^4.52.5",
77
- "vite": "^7.1.12",
79
+ "vite": "7.1.12",
78
80
  "webpack": "^5.102.1"
79
81
  },
80
82
  "peerDependencies": {
@@ -1,24 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- export { };