glyphix 1.0.14 → 1.0.16

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
@@ -138,6 +138,7 @@ var import_glob = require("glob");
138
138
  var import_chalk2 = __toESM(require("chalk"));
139
139
  var import_node_process = require("process");
140
140
  var import_dotenv = __toESM(require("dotenv"));
141
+ var import_lodash = require("lodash");
141
142
  function loadEnv() {
142
143
  const dotenvTags = [
143
144
  // 本地环境
@@ -194,6 +195,7 @@ function lintFile(rootPath) {
194
195
  warnIgnored: true,
195
196
  overrideConfig: {
196
197
  rules: {
198
+ "no-console": "off",
197
199
  "prettier/prettier": "warn",
198
200
  "@typescript-eslint/ban-ts-comment": "warn",
199
201
  "@typescript-eslint/no-explicit-any": "warn",
@@ -229,14 +231,9 @@ function dealResource() {
229
231
  entry: entriedFullPath
230
232
  };
231
233
  }
232
- function build(rootPath, entriedFullPath) {
234
+ function generateEsbuildConfig(rootPath, entriedFullPath, envDefine) {
233
235
  const resolveExtensions = [".ts", ".js"];
234
- let envDefine = {};
235
- Array.from(Object.keys(process.env)).forEach((key) => {
236
- if (key.startsWith("GLYPHIX"))
237
- envDefine[`process.env.${key}`] = JSON.stringify(process.env[key]);
238
- });
239
- import_esbuild.default.build({
236
+ const internalConfig = {
240
237
  entryPoints: entriedFullPath,
241
238
  // 入口文件
242
239
  bundle: true,
@@ -284,7 +281,24 @@ function build(rootPath, entriedFullPath) {
284
281
  }
285
282
  }
286
283
  ]
287
- }).then(() => {
284
+ };
285
+ const customConfigPath = (0, import_node_path3.resolve)(process.cwd(), "glyphix.config.js");
286
+ if (!(0, import_node_fs.existsSync)(customConfigPath)) return internalConfig;
287
+ try {
288
+ const useConfig = require(customConfigPath);
289
+ return (0, import_lodash.merge)(internalConfig, useConfig);
290
+ } catch (error) {
291
+ console.error(error);
292
+ }
293
+ return internalConfig;
294
+ }
295
+ function build(rootPath, entriedFullPath) {
296
+ let envDefine = {};
297
+ Array.from(Object.keys(process.env)).forEach((key) => {
298
+ if (key.startsWith("GLYPHIX"))
299
+ envDefine[`process.env.${key}`] = JSON.stringify(process.env[key]);
300
+ });
301
+ import_esbuild.default.build(generateEsbuildConfig(rootPath, entriedFullPath, envDefine)).then(() => {
288
302
  console.log("Build completed!");
289
303
  }).catch((error) => {
290
304
  console.error("Build failed:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "files": [
@@ -10,9 +10,7 @@
10
10
  "script/",
11
11
  "libs/"
12
12
  ],
13
- "scripts": {
14
- "postinstall": "node ./script/install.js"
15
- },
13
+ "scripts": {},
16
14
  "bin": {
17
15
  "glyphix": "./bin/glyphix.js"
18
16
  },
@@ -34,6 +32,7 @@
34
32
  "eslint": "^9.18.0",
35
33
  "fs-extra": "^11.2.0",
36
34
  "glob": "^11.0.1",
35
+ "lodash": "^4.17.21",
37
36
  "yargs": "^17.7.2"
38
37
  }
39
38
  }
@@ -0,0 +1,9 @@
1
+ declare module "@system.brightness" {
2
+ interface BrightnessFactory {
3
+ setKeepScreenOn(status: boolean): void;
4
+ }
5
+
6
+ const brightnessFactory: BrightnessFactory;
7
+ export default brightnessFactory;
8
+ }
9
+
package/types/device.d.ts CHANGED
@@ -1,34 +1,53 @@
1
1
  declare module "@system.device" {
2
+
3
+ type IdType = 'device' | 'mac' | 'user' | 'advertising'
2
4
  interface DeviceFactory {
3
- getInfo
4
- (): Promise<{
5
- brand: string,
6
- manufacturer: string,
7
- model: string,
8
- product: string,
9
- osType: string,
10
- osVersionName: string
11
- }>,
12
- getId
13
- (types: ('device' | 'mac' | 'user' | 'advertising')[])
14
- : Promise<{
15
- device?: string,
16
- mac?: string,
17
- user?: string,
18
- advertising?: string
19
- }>,
20
- getDeviceId
21
- (): Promise<{ deviceId: string }>,
22
- getSerial
23
- (): Promise<{ serial: string }>,
24
- getTotalStorage
25
- (): Promise<{ totalStorage: number }>,
26
- getAvailableStorage
27
- (): Promise<{ availableStorage: number }>,
28
- screenWidth: number,
29
- screenHeight: number,
30
- screenDensity: number,
31
- screenShape: 'rect' | 'circle',
5
+ getInfo(): Promise<{
6
+ brand: string,
7
+ manufacturer: string,
8
+ model: string,
9
+ product: string,
10
+ osType: string,
11
+ osVersionName: string
12
+ }>
13
+
14
+ getId<T extends IdType[]>({type: T}): Promise<{[K in T[number]]: string}>
15
+ getDeviceId(): Promise<{ deviceId: string }>
16
+
17
+ // 获取设备唯一标识。
18
+ getDeviceId(): Promise<{ deviceId: string }>
19
+
20
+ // 获取设备序列号。
21
+ getSerial(): Promise<{ serial: string }>
22
+
23
+ // 获取存储空间的总大小。
24
+ getTotalStorage(): Promise<{ totalStorage: number }>
25
+
26
+ // 获取存储空间的可用大小。
27
+ getAvailableStorage(): Promise<{ availableStorage: number }>
28
+
29
+ // 设备的屏幕宽度,单位为像素。
30
+ screenWidth: number
31
+
32
+
33
+ // 设备的屏幕高度,单位为像素。
34
+ //
35
+ screenHeight: number
36
+
37
+ //设备的屏幕像素密度,单位为 PPI。
38
+ screenDensity: number
39
+
40
+ /**
41
+ * //设备的屏幕形状,值的含义如下:
42
+ 'rect': 设备具有矩形屏幕。
43
+ 'circle': 设备具有圆形屏幕。
44
+ */
45
+
46
+ screenShape: 'rect' | 'circle'
47
+ /**
48
+ * 获取设备的内存配置文件属性。这个属性是 memory-profile 媒体查询属性的 JavaScript API 版本,具体请参考媒体查询属性的文档。
49
+ * 与 memory-profile 媒体查询属性不同,memoryProfile 属性的值是一个整数,单位固定为 KiB
50
+ */
32
51
  memoryProfile: number
33
52
  }
34
53
 
package/types/fetch.d.ts CHANGED
@@ -6,7 +6,7 @@ declare module "@system.fetch" {
6
6
  header?: { [key: string]: string };
7
7
  params?: { [key: string]: string | number };
8
8
  data?: string | ArrayBuffer | { [key: string]: any };
9
- responseType?: "text" | "json" | "arraybuffer";
9
+ responseType?: "text" | "json" | "arraybuffer" | 'formdata';
10
10
  timeout?: number;
11
11
  }): Promise<{
12
12
  code: number;
package/types/index.d.ts CHANGED
@@ -8,7 +8,10 @@
8
8
  /// <reference path="./file.d.ts" />
9
9
  /// <reference path="./network.d.ts" />
10
10
  /// <reference path="./cipher.d.ts" />
11
+ /// <reference path="./invoke.d.ts" />
12
+ /// <reference path="./prompt.d.ts" />
11
13
  /// <reference path="./device.d.ts" />
14
+ /// <reference path="./brightness.d.ts" />
12
15
 
13
16
 
14
17
  type ComputedResults<C, D> = {
@@ -11,7 +11,7 @@ declare module "@system.websocketfactory" {
11
11
  close(params: { code: number; reason: string }): void;
12
12
 
13
13
  onopen?: () => void;
14
- onmessage?: (msg: string | ArrayBuffer) => void;
14
+ onmessage?: (data: {data: string | ArrayBuffer}) => void;
15
15
  onclose?: (event: { code: number; reason: string }) => void;
16
16
  onerror?: (error: { code: number; reason: string }) => void;
17
17
  }