glyphix 1.0.29 → 1.0.31

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/bin/glyphix.js CHANGED
@@ -167,7 +167,14 @@ function loadEnv() {
167
167
  function getOriginFilePath(filePath, rootPath) {
168
168
  const relativePath = (0, import_node_path3.relative)(rootPath, filePath);
169
169
  const projectRoot = process.cwd();
170
- return (0, import_node_path3.resolve)(projectRoot, "src", relativePath);
170
+ const originPath = (0, import_node_path3.resolve)(projectRoot, "src", relativePath);
171
+ if (originPath.endsWith(".ts")) {
172
+ const uxOrigin = originPath.slice(0, -3) + ".ux";
173
+ if ((0, import_node_fs.existsSync)(uxOrigin)) {
174
+ return uxOrigin;
175
+ }
176
+ }
177
+ return originPath;
171
178
  }
172
179
  function outErrorLog(results, filepath) {
173
180
  results.messages.forEach((item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "files": [
package/types/index.d.ts CHANGED
@@ -21,39 +21,31 @@ declare global {
21
21
  function $t(key: string): string;
22
22
  }
23
23
 
24
- // 基础 Data 类型定义
25
- type Data<T extends Record<string, any> = Record<string, any>> = T;
26
-
27
- // 其他类型定义保持不变
28
- type ComputedResults<C, D extends Data> = {
24
+ type ComputedResults<C, D> = {
29
25
  readonly [K in keyof C as C[K] extends (this: D) => any
30
26
  ? K
31
27
  : never]: C[K] extends () => infer R ? R : never;
32
28
  } & {
33
29
  [K in keyof C]: C[K] extends ComputedField<infer R> ? R : never;
34
30
  };
35
-
36
31
  type ComputedField<T> =
37
32
  | {
38
33
  get(): T;
39
34
  set(x: T): void;
40
35
  }
41
36
  | (() => T);
42
-
43
- type Computed<C, D extends Data> = {
37
+ type Data = Record<string, any>;
38
+ type Computed<C, D> = {
44
39
  [K in keyof C]: K extends keyof D ? never : ComputedField<C[K]>;
45
40
  } & ThisType<D>;
46
-
47
41
  type Watches<W, D extends Data> = {
48
42
  [K in keyof W]: K extends keyof D
49
43
  ? ((newValue: D[K], oldValue: D[K]) => void) | undefined
50
- : any;
44
+ : never;
51
45
  };
52
-
53
- type Methods<M, D extends Data> = {
46
+ type Methods<M, D> = {
54
47
  [K in keyof M]: K extends keyof D ? never : M[K];
55
48
  };
56
-
57
49
  type LifeCycleHooks = {
58
50
  onInit?: () => void;
59
51
  onReady?: () => void;
@@ -61,7 +53,6 @@ type LifeCycleHooks = {
61
53
  onHide?: () => void;
62
54
  onDestroy?: () => void;
63
55
  };
64
-
65
56
  type OmitedProps =
66
57
  | "data"
67
58
  | "computed"
@@ -70,7 +61,6 @@ type OmitedProps =
70
61
  | "onShow"
71
62
  | "onHide"
72
63
  | "onDestroy";
73
-
74
64
  type ComponentInternals = {
75
65
  $element(id: string): Record<string, any> | undefined;
76
66
  $valid: boolean;
@@ -79,31 +69,26 @@ type ComponentInternals = {
79
69
  $component(name: string, url: string): void;
80
70
  $emit(name: string, ...args: Array<any>);
81
71
  };
82
-
83
- type ComponentProps<D extends Data, C, M> = Omit<
72
+ type ComponentProps<D, C, M> = Omit<
84
73
  D & ComputedResults<C, D> & M & ComponentInternals,
85
74
  OmitedProps
86
75
  >;
87
-
88
- // 修正 ComponentOptions 类型
89
76
  type ComponentOptions<
90
- T extends Record<string, any>,
91
- C = any,
92
- W = any,
93
- M = any
77
+ D extends Data,
78
+ C, // 先不深究 C 的 this 约束
79
+ W,
80
+ M
94
81
  > = {
95
- data: T;
96
- computed?: Computed<C, T>;
97
- watch?: Watches<W, T>;
82
+ data: D;
83
+ computed?: Computed<C, D>;
84
+ watch?: Watches<W, D>;
98
85
  } & LifeCycleHooks &
99
- Methods<M, T> &
100
- ThisType<ComponentProps<T, Computed<C, T & Methods<M, T>>, M>>;
101
-
86
+ Methods<M, D> &
87
+ ThisType<ComponentProps<D, Computed<C, D & Methods<M, D>>, M>>;
102
88
  export declare function defineComponent<
103
- T extends Record<string, any>,
104
- C = any,
105
- W = any,
106
- M = any
107
- >(options: ComponentOptions<T, C, W, M>): ComponentOptions<T, C, W, M>;
108
-
89
+ D extends Data,
90
+ C, // 计算属性可能依赖于 data 和 methods
91
+ W,
92
+ M
93
+ >(options: ComponentOptions<D, C, W, M>): ComponentOptions<D, C, W, M>;
109
94
  export {};