glyphix 1.0.10 → 1.0.12

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.
@@ -23,10 +23,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  mod
24
24
  ));
25
25
 
26
- // src/index.ts
26
+ // src/cli/index.ts
27
27
  var import_yargs = __toESM(require("yargs"));
28
28
 
29
- // src/utils/logger.ts
29
+ // src/cli/utils/logger.ts
30
30
  var import_chalk = __toESM(require("chalk"));
31
31
  var { log: originLog } = console;
32
32
  console.debug = function(...args) {
@@ -42,7 +42,7 @@ console.error = function(...args) {
42
42
  originLog(import_chalk.default.red(...args));
43
43
  };
44
44
 
45
- // src/command/new.ts
45
+ // src/cli/command/new.ts
46
46
  var import_fs_extra = require("fs-extra");
47
47
  var import_child_process = require("child_process");
48
48
  var import_node_path = require("path");
@@ -75,7 +75,7 @@ function createProject(cwd, name) {
75
75
  (0, import_child_process.spawnSync)("git", ["init"], { cwd: targetFullPath });
76
76
  }
77
77
 
78
- // src/command/buildEmu.ts
78
+ // src/cli/command/buildEmu.ts
79
79
  var import_child_process2 = require("child_process");
80
80
  var import_node_path2 = require("path");
81
81
  function reconstructArgs(argv) {
@@ -108,7 +108,6 @@ function findGlyphixTools() {
108
108
  }
109
109
  function buildGlyphix(args) {
110
110
  var _a, _b;
111
- console.log(findGlyphixTools(), reconstructArgs(args));
112
111
  const childProcess = (0, import_child_process2.execFile)(findGlyphixTools(), reconstructArgs(args), {
113
112
  cwd: process.cwd()
114
113
  });
@@ -129,7 +128,7 @@ function buildGlyphix(args) {
129
128
  });
130
129
  }
131
130
 
132
- // src/command/generate.ts
131
+ // src/cli/command/generate.ts
133
132
  var import_esbuild = __toESM(require("esbuild"));
134
133
  var import_node_path3 = require("path");
135
134
  var import_node_fs = require("fs");
@@ -301,7 +300,7 @@ function generateGlyphix() {
301
300
  });
302
301
  }
303
302
 
304
- // src/index.ts
303
+ // src/cli/index.ts
305
304
  import_yargs.default.command("create", "create a glyphix project", {}, (args) => {
306
305
  console.debug("create project", __dirname);
307
306
  if (args._.length < 2) {
package/libs/index.js ADDED
@@ -0,0 +1 @@
1
+ function o(e){return e}export{o as defineComponent};
package/package.json CHANGED
@@ -1,25 +1,35 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "files": [
7
7
  "glyphix.js",
8
8
  "types/",
9
9
  "template/",
10
- "script/"
10
+ "script/",
11
+ "libs/"
11
12
  ],
12
13
  "scripts": {
13
14
  "postinstall": "node ./script/install.js"
14
15
  },
15
16
  "bin": {
16
- "glyphix": "./glyphix.js"
17
+ "glyphix": "./bin/glyphix.js"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./types/index.d.ts",
23
+ "default": "./libs/index.js"
24
+ }
25
+ }
17
26
  },
18
27
  "dependencies": {
19
28
  "adm-zip": "^0.5.16",
20
29
  "chalk": "^4.1.2",
21
30
  "dotenv": "^16.4.7",
22
31
  "esbuild": "^0.24.2",
32
+ "esbuild-plugin-d.ts": "^1.3.1",
23
33
  "eslint": "^9.18.0",
24
34
  "fs-extra": "^11.2.0",
25
35
  "glob": "^11.0.1",
package/types/file.d.ts CHANGED
@@ -25,7 +25,7 @@ declare module "@system.file" {
25
25
 
26
26
  rename(params: { oldUri: string; newUri: string }): Promise<void>;
27
27
 
28
- list(params: { uri: string }): Promise<Array>;
28
+ list(params: { uri: string }): Promise<Array<string>>;
29
29
 
30
30
  access(params: { uri: string }): Promise<boolean>;
31
31
 
package/types/index.d.ts CHANGED
@@ -9,3 +9,63 @@
9
9
  /// <reference path="./network.d.ts" />
10
10
  /// <reference path="./cipher.d.ts" />
11
11
 
12
+ type ComputedResults<C, D> = {
13
+ readonly [K in keyof C as C[K] extends (this: D) => any
14
+ ? K
15
+ : never]: C[K] extends () => infer R ? R : never;
16
+ } & {
17
+ [K in keyof C]: C[K] extends ComputedField<infer R> ? R : never;
18
+ };
19
+ type ComputedField<T> =
20
+ | {
21
+ get(): T;
22
+ set(x: T): void;
23
+ }
24
+ | (() => T);
25
+ type Data = Record<string, any>;
26
+ type Computed<C, D> = {
27
+ [K in keyof C]: K extends keyof D ? never : ComputedField<C[K]>;
28
+ } & ThisType<D>;
29
+ type Watches<W, D extends Data> = {
30
+ [K in keyof W]: K extends keyof D
31
+ ? ((newValue: D[K], oldValue: D[K]) => void) | undefined
32
+ : never;
33
+ };
34
+ type Methods<M, D> = {
35
+ [K in keyof M]: K extends keyof D ? never : M[K];
36
+ };
37
+ type LifeCycleHooks = {
38
+ onInit?: () => void;
39
+ onReady?: () => void;
40
+ onShow?: () => void;
41
+ onHide?: () => void;
42
+ onDestroy?: () => void;
43
+ };
44
+ type OmitedProps =
45
+ | "data"
46
+ | "computed"
47
+ | "onInit"
48
+ | "onReady"
49
+ | "onShow"
50
+ | "onHide"
51
+ | "onDestroy";
52
+ type ComponentProps<D, C, M> = Omit<D & ComputedResults<C, D> & M, OmitedProps>;
53
+ type ComponentOptions<
54
+ D extends Data,
55
+ C, // 先不深究 C 的 this 约束
56
+ W,
57
+ M
58
+ > = {
59
+ data: D;
60
+ computed?: Computed<C, D>;
61
+ watch?: Watches<W, D>;
62
+ } & LifeCycleHooks &
63
+ Methods<M, D> &
64
+ ThisType<ComponentProps<D, Computed<C, D & Methods<M, D>>, M>>;
65
+ export declare function defineComponent<
66
+ D extends Data,
67
+ C, // 计算属性可能依赖于 data 和 methods
68
+ W,
69
+ M
70
+ >(options: ComponentOptions<D, C, W, M>): ComponentOptions<D, C, W, M>;
71
+ export {};
package/types/launch.d.ts CHANGED
@@ -6,7 +6,7 @@ declare module "@system.launch" {
6
6
  * 返回的 Promise 表示应用是否加载成功
7
7
  * @param app 应用 id
8
8
  */
9
- launch(app: string): Promise<bool>;
9
+ launch(app: string): Promise<Boolean>;
10
10
  /**
11
11
  * 将应用切换到后台
12
12
  * @param app 应用 id
package/types/media.d.ts CHANGED
@@ -50,9 +50,9 @@ declare module "@system.media" {
50
50
  channel?: 1 | 2;
51
51
  success?: () => void;
52
52
  failed?: () => void;
53
- });
53
+ }): void;
54
54
 
55
- read(options: { callback: (buffer: ArrayBuffer) => void });
55
+ read(options: { callback: (buffer: ArrayBuffer) => void }): void;
56
56
 
57
57
  stop(): void;
58
58
  release(): void;
package/types/router.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare module "@system.router" {
2
+ interface Component {}
2
3
  interface RouterFactory {
3
4
  /**
4
5
  * 跳转到应用内的指定页面
@@ -58,11 +59,11 @@ declare module "@system.router" {
58
59
 
59
60
  /**
60
61
  * 获取页面栈中名为 name 的所有页面索引,页面索引值的顺序和页面栈的顺序相同
61
- * @param name
62
+ * @param name
62
63
  */
63
64
  queryIndex(name: string): number[];
64
65
  }
65
66
 
66
67
  const router: RouterFactory;
67
- export default RouterFactory;
68
+ export default router;
68
69
  }
@@ -1,6 +1,9 @@
1
- declare module '@system.websocketfactory' {
1
+ declare module "@system.websocketfactory" {
2
2
  interface WebSocketFactory {
3
- create(options: { url: string; header: { [key: string]: any } });
3
+ create(options: {
4
+ url: string;
5
+ header: { [key: string]: any };
6
+ }): WebSocketInstance;
4
7
  }
5
8
 
6
9
  export interface WebSocketInstance {