glyphix 1.0.13 → 1.0.15
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 +23 -8
- package/package.json +3 -4
- package/types/brightness.d.ts +9 -0
- package/types/device.d.ts +56 -0
- package/types/fetch.d.ts +1 -1
- package/types/index.d.ts +17 -1
- package/types/invoke.d.ts +10 -0
- package/types/prompt.d.ts +14 -0
- package/types/websocketfactory.d.ts +1 -1
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
|
|
234
|
+
function generateEsbuildConfig(rootPath, entriedFullPath, envDefine) {
|
|
233
235
|
const resolveExtensions = [".ts", ".js"];
|
|
234
|
-
|
|
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,
|
|
@@ -254,6 +251,7 @@ function build(rootPath, entriedFullPath) {
|
|
|
254
251
|
target: "node14",
|
|
255
252
|
// 目标平台设置为最新 ECMAScript
|
|
256
253
|
define: envDefine,
|
|
254
|
+
sourcemap: true,
|
|
257
255
|
minify: process.env.GLYPHIX_ENV === "development" ? false : true,
|
|
258
256
|
plugins: [
|
|
259
257
|
{
|
|
@@ -283,7 +281,24 @@ function build(rootPath, entriedFullPath) {
|
|
|
283
281
|
}
|
|
284
282
|
}
|
|
285
283
|
]
|
|
286
|
-
}
|
|
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(() => {
|
|
287
302
|
console.log("Build completed!");
|
|
288
303
|
}).catch((error) => {
|
|
289
304
|
console.error("Build failed:", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glyphix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
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,56 @@
|
|
|
1
|
+
declare module "@system.device" {
|
|
2
|
+
|
|
3
|
+
type IdType = 'device' | 'mac' | 'user' | 'advertising'
|
|
4
|
+
interface DeviceFactory {
|
|
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[]>({types: 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
|
+
*/
|
|
51
|
+
memoryProfile: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const deviceFactory: DeviceFactory;
|
|
55
|
+
export default deviceFactory;
|
|
56
|
+
}
|
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,6 +8,11 @@
|
|
|
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" />
|
|
13
|
+
/// <reference path="./device.d.ts" />
|
|
14
|
+
/// <reference path="./brightness.d.ts" />
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
type ComputedResults<C, D> = {
|
|
13
18
|
readonly [K in keyof C as C[K] extends (this: D) => any
|
|
@@ -49,7 +54,18 @@ type OmitedProps =
|
|
|
49
54
|
| "onShow"
|
|
50
55
|
| "onHide"
|
|
51
56
|
| "onDestroy";
|
|
52
|
-
type
|
|
57
|
+
type ComponentInternals = {
|
|
58
|
+
$element(id: string): Record<string, any> | undefined;
|
|
59
|
+
$valid: boolean;
|
|
60
|
+
$app: Record<string, any>;
|
|
61
|
+
$page: Record<string, any>;
|
|
62
|
+
$component(name: string, url: string): void;
|
|
63
|
+
$emit(name: string, ...args: Array<any>);
|
|
64
|
+
};
|
|
65
|
+
type ComponentProps<D, C, M> = Omit<
|
|
66
|
+
D & ComputedResults<C, D> & M & ComponentInternals,
|
|
67
|
+
OmitedProps
|
|
68
|
+
>;
|
|
53
69
|
type ComponentOptions<
|
|
54
70
|
D extends Data,
|
|
55
71
|
C, // 先不深究 C 的 this 约束
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module "@system.invoke" {
|
|
2
|
+
interface InvokeFactory {
|
|
3
|
+
invoke(name: string, params?: Record<string, any>): Promise<any>;
|
|
4
|
+
queryFeature(name: string): boolean;
|
|
5
|
+
install(name: string, executor: (params?: Record<string, any>) => any);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const invokeFactory: InvokeFactory;
|
|
9
|
+
export default invokeFactory;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module "@system.prompt" {
|
|
2
|
+
interface PromptFactory {
|
|
3
|
+
showToast(options: { message: string, duration?: number }): void;
|
|
4
|
+
showPopup(options: { uri: string, params?: { [k: string]: any } }): void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface DownloadTask {
|
|
8
|
+
complete: Promise<void>;
|
|
9
|
+
cancel(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const promptFactory: PromptFactory;
|
|
13
|
+
export default promptFactory;
|
|
14
|
+
}
|
|
@@ -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?: (
|
|
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
|
}
|