glyphix 1.0.30 → 1.0.32

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
@@ -136,7 +136,6 @@ var import_fs_extra2 = require("fs-extra");
136
136
  var import_eslint = require("eslint");
137
137
  var import_glob = require("glob");
138
138
  var import_chalk2 = __toESM(require("chalk"));
139
- var import_node_process = require("process");
140
139
  var import_dotenv = __toESM(require("dotenv"));
141
140
  var import_lodash = require("lodash");
142
141
  function loadEnv() {
@@ -164,65 +163,6 @@ function loadEnv() {
164
163
  import_dotenv.default.config({ path: dotenvFile });
165
164
  });
166
165
  }
167
- function getOriginFilePath(filePath, rootPath) {
168
- const relativePath = (0, import_node_path3.relative)(rootPath, filePath);
169
- const projectRoot = process.cwd();
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;
178
- }
179
- function outErrorLog(results, filepath) {
180
- results.messages.forEach((item) => {
181
- console.log(
182
- `${filepath}:${item.line}:${item.column}`,
183
- "\n ",
184
- import_chalk2.default.red("error"),
185
- " ",
186
- item.message,
187
- " ",
188
- import_chalk2.default.gray(item.ruleId)
189
- );
190
- });
191
- }
192
- function lintFile(rootPath) {
193
- const distPath = (0, import_node_path3.join)(rootPath, ".vite-dist");
194
- if ((0, import_node_fs.existsSync)(distPath)) {
195
- (0, import_fs_extra2.removeSync)(distPath);
196
- }
197
- const sources = (0, import_glob.sync)([
198
- `${(0, import_node_path3.resolve)(rootPath)}/**/*.ts`,
199
- `${(0, import_node_path3.resolve)(rootPath)}/**/*.js`
200
- ]);
201
- const eslint = new import_eslint.ESLint({
202
- warnIgnored: true,
203
- overrideConfig: {
204
- rules: {
205
- "no-console": "off",
206
- "prettier/prettier": "off",
207
- "@typescript-eslint/ban-ts-comment": "warn",
208
- "@typescript-eslint/no-explicit-any": "off",
209
- "@typescript-eslint/no-unused-vars": "warn",
210
- quotes: "off"
211
- }
212
- }
213
- });
214
- return eslint.lintFiles(sources).then((res) => {
215
- return res.filter((item) => item.errorCount).map((item) => {
216
- return item;
217
- }).flat();
218
- }).then((res) => {
219
- res.forEach((item) => {
220
- const originPath = getOriginFilePath(item.filePath, rootPath);
221
- outErrorLog(item, originPath);
222
- });
223
- return res;
224
- });
225
- }
226
166
  function dealResource() {
227
167
  if (!process.env["VITE_BUILD_DIR"])
228
168
  throw Error("not set glyphix project path");
@@ -314,12 +254,7 @@ function build(rootPath, entriedFullPath) {
314
254
  function generateGlyphix() {
315
255
  const config = dealResource();
316
256
  loadEnv();
317
- lintFile(config.root).then((res) => {
318
- if (res.length) {
319
- (0, import_node_process.exit)(1);
320
- }
321
- build(config.root, config.entry);
322
- });
257
+ build(config.root, config.entry);
323
258
  }
324
259
 
325
260
  // src/cli/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "files": [
package/types/index.d.ts CHANGED
@@ -17,43 +17,37 @@
17
17
  /// <reference path="./exchange.d.ts" />
18
18
  /// <reference path="./audiokit.d.ts" />
19
19
 
20
+
20
21
  declare global {
21
22
  function $t(key: string): string;
22
23
  }
23
24
 
24
- // 基础 Data 类型定义
25
- type Data<T extends Record<string, any> = Record<string, any>> = T;
26
25
 
27
- // 其他类型定义保持不变
28
- type ComputedResults<C, D extends Data> = {
26
+ type ComputedResults<C, D> = {
29
27
  readonly [K in keyof C as C[K] extends (this: D) => any
30
28
  ? K
31
29
  : never]: C[K] extends () => infer R ? R : never;
32
30
  } & {
33
31
  [K in keyof C]: C[K] extends ComputedField<infer R> ? R : never;
34
32
  };
35
-
36
33
  type ComputedField<T> =
37
34
  | {
38
35
  get(): T;
39
36
  set(x: T): void;
40
37
  }
41
38
  | (() => T);
42
-
43
- type Computed<C, D extends Data> = {
39
+ type Data = Record<string, any>;
40
+ type Computed<C, D> = {
44
41
  [K in keyof C]: K extends keyof D ? never : ComputedField<C[K]>;
45
42
  } & ThisType<D>;
46
-
47
43
  type Watches<W, D extends Data> = {
48
44
  [K in keyof W]: K extends keyof D
49
45
  ? ((newValue: D[K], oldValue: D[K]) => void) | undefined
50
- : any;
46
+ : never;
51
47
  };
52
-
53
- type Methods<M, D extends Data> = {
48
+ type Methods<M, D> = {
54
49
  [K in keyof M]: K extends keyof D ? never : M[K];
55
50
  };
56
-
57
51
  type LifeCycleHooks = {
58
52
  onInit?: () => void;
59
53
  onReady?: () => void;
@@ -61,7 +55,6 @@ type LifeCycleHooks = {
61
55
  onHide?: () => void;
62
56
  onDestroy?: () => void;
63
57
  };
64
-
65
58
  type OmitedProps =
66
59
  | "data"
67
60
  | "computed"
@@ -70,7 +63,6 @@ type OmitedProps =
70
63
  | "onShow"
71
64
  | "onHide"
72
65
  | "onDestroy";
73
-
74
66
  type ComponentInternals = {
75
67
  $element(id: string): Record<string, any> | undefined;
76
68
  $valid: boolean;
@@ -79,31 +71,26 @@ type ComponentInternals = {
79
71
  $component(name: string, url: string): void;
80
72
  $emit(name: string, ...args: Array<any>);
81
73
  };
82
-
83
- type ComponentProps<D extends Data, C, M> = Omit<
74
+ type ComponentProps<D, C, M> = Omit<
84
75
  D & ComputedResults<C, D> & M & ComponentInternals,
85
76
  OmitedProps
86
77
  >;
87
-
88
- // 修正 ComponentOptions 类型
89
78
  type ComponentOptions<
90
- T extends Record<string, any>,
91
- C = any,
92
- W = any,
93
- M = any
79
+ D extends Data,
80
+ C, // 先不深究 C 的 this 约束
81
+ W,
82
+ M
94
83
  > = {
95
- data: T;
96
- computed?: Computed<C, T>;
97
- watch?: Watches<W, T>;
84
+ data: D;
85
+ computed?: Computed<C, D>;
86
+ watch?: Watches<W, D>;
98
87
  } & LifeCycleHooks &
99
- Methods<M, T> &
100
- ThisType<ComponentProps<T, Computed<C, T & Methods<M, T>>, M>>;
101
-
88
+ Methods<M, D> &
89
+ ThisType<ComponentProps<D, Computed<C, D & Methods<M, D>>, M>>;
102
90
  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
-
91
+ D extends Data,
92
+ C, // 计算属性可能依赖于 data 和 methods
93
+ W,
94
+ M
95
+ >(options: ComponentOptions<D, C, W, M>): ComponentOptions<D, C, W, M>;
109
96
  export {};