glyphix 1.0.9 → 1.0.11
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/{glyphix.js → bin/glyphix.js} +86 -26
- package/libs/index.js +1 -0
- package/package.json +14 -3
- package/types/file.d.ts +1 -1
- package/types/index.d.ts +60 -0
- package/types/launch.d.ts +1 -1
- package/types/media.d.ts +2 -2
- package/types/router.d.ts +2 -1
- package/types/websocketfactory.d.ts +5 -2
|
@@ -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) {
|
|
@@ -117,6 +117,9 @@ function buildGlyphix(args) {
|
|
|
117
117
|
(_b = childProcess.stderr) == null ? void 0 : _b.on("data", (data) => {
|
|
118
118
|
console.error(data);
|
|
119
119
|
});
|
|
120
|
+
childProcess.on("error", (err) => {
|
|
121
|
+
console.error(err);
|
|
122
|
+
});
|
|
120
123
|
childProcess.on("exit", () => {
|
|
121
124
|
console.log("exit");
|
|
122
125
|
});
|
|
@@ -125,7 +128,7 @@ function buildGlyphix(args) {
|
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
// src/command/generate.ts
|
|
131
|
+
// src/cli/command/generate.ts
|
|
129
132
|
var import_esbuild = __toESM(require("esbuild"));
|
|
130
133
|
var import_node_path3 = require("path");
|
|
131
134
|
var import_node_fs = require("fs");
|
|
@@ -134,6 +137,32 @@ var import_eslint = require("eslint");
|
|
|
134
137
|
var import_glob = require("glob");
|
|
135
138
|
var import_chalk2 = __toESM(require("chalk"));
|
|
136
139
|
var import_node_process = require("process");
|
|
140
|
+
var import_dotenv = __toESM(require("dotenv"));
|
|
141
|
+
function loadEnv() {
|
|
142
|
+
const dotenvTags = [
|
|
143
|
+
// 本地环境
|
|
144
|
+
"development",
|
|
145
|
+
// 测试环境
|
|
146
|
+
// 比如:单元测试
|
|
147
|
+
"test",
|
|
148
|
+
// 部署环境
|
|
149
|
+
// 比如:日常、预发、线上
|
|
150
|
+
"production"
|
|
151
|
+
];
|
|
152
|
+
if (!dotenvTags.includes(process.env.GLYPHIX_ENV ?? "")) {
|
|
153
|
+
process.env.GLYPHIX_ENV = dotenvTags[0];
|
|
154
|
+
}
|
|
155
|
+
const dotenvPath = (0, import_node_path3.resolve)(".env");
|
|
156
|
+
const dotenvFiles = [
|
|
157
|
+
dotenvPath,
|
|
158
|
+
`${dotenvPath}.local`,
|
|
159
|
+
`${dotenvPath}.${process.env.GLYPHIX_ENV}`,
|
|
160
|
+
`${dotenvPath}.${process.env.GLYPHIX_ENV}.local`
|
|
161
|
+
].filter(import_node_fs.existsSync);
|
|
162
|
+
dotenvFiles.reverse().forEach((dotenvFile) => {
|
|
163
|
+
import_dotenv.default.config({ path: dotenvFile });
|
|
164
|
+
});
|
|
165
|
+
}
|
|
137
166
|
function getOriginFilePath(filePath, rootPath) {
|
|
138
167
|
const relativePath = (0, import_node_path3.relative)(rootPath, filePath);
|
|
139
168
|
const projectRoot = process.cwd();
|
|
@@ -195,15 +224,6 @@ function dealResource() {
|
|
|
195
224
|
const entries = entryFileContent.entry;
|
|
196
225
|
(0, import_fs_extra2.removeSync)((0, import_node_path3.resolve)(rootPath, ".vite-dist"));
|
|
197
226
|
let entriedFullPath = entries.map((item) => (0, import_node_path3.resolve)(rootPath, item));
|
|
198
|
-
entriedFullPath = entriedFullPath.map((item) => {
|
|
199
|
-
if ((0, import_node_fs.existsSync)(item)) {
|
|
200
|
-
const dest = item.replace(".js", ".ts");
|
|
201
|
-
if ((0, import_node_fs.existsSync)(dest)) (0, import_fs_extra2.removeSync)(dest);
|
|
202
|
-
(0, import_fs_extra2.moveSync)(item, dest);
|
|
203
|
-
return dest;
|
|
204
|
-
}
|
|
205
|
-
return item;
|
|
206
|
-
});
|
|
207
227
|
return {
|
|
208
228
|
root: rootPath,
|
|
209
229
|
entry: entriedFullPath
|
|
@@ -211,6 +231,11 @@ function dealResource() {
|
|
|
211
231
|
}
|
|
212
232
|
function build(rootPath, entriedFullPath) {
|
|
213
233
|
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
|
+
});
|
|
214
239
|
import_esbuild.default.build({
|
|
215
240
|
entryPoints: entriedFullPath,
|
|
216
241
|
// 入口文件
|
|
@@ -228,6 +253,7 @@ function build(rootPath, entriedFullPath) {
|
|
|
228
253
|
platform: "node",
|
|
229
254
|
target: "node14",
|
|
230
255
|
// 目标平台设置为最新 ECMAScript
|
|
256
|
+
define: envDefine,
|
|
231
257
|
minify: process.env.GLYPHIX_ENV === "development" ? false : true,
|
|
232
258
|
plugins: [
|
|
233
259
|
{
|
|
@@ -265,6 +291,7 @@ function build(rootPath, entriedFullPath) {
|
|
|
265
291
|
}
|
|
266
292
|
function generateGlyphix() {
|
|
267
293
|
const config = dealResource();
|
|
294
|
+
loadEnv();
|
|
268
295
|
lintFile(config.root).then((res) => {
|
|
269
296
|
if (res.length) {
|
|
270
297
|
(0, import_node_process.exit)(1);
|
|
@@ -273,26 +300,59 @@ function generateGlyphix() {
|
|
|
273
300
|
});
|
|
274
301
|
}
|
|
275
302
|
|
|
276
|
-
// src/index.ts
|
|
277
|
-
import_yargs.default.
|
|
303
|
+
// src/cli/index.ts
|
|
304
|
+
import_yargs.default.command("create", "create a glyphix project", {}, (args) => {
|
|
278
305
|
console.debug("create project", __dirname);
|
|
279
306
|
if (args._.length < 2) {
|
|
280
307
|
console.error("miss project name");
|
|
281
308
|
return;
|
|
282
309
|
}
|
|
283
310
|
createProject(process.cwd(), args._[1] + "");
|
|
284
|
-
}).command("generate", "compiler glyphix project", {}, generateGlyphix).command(
|
|
285
|
-
"
|
|
286
|
-
"
|
|
311
|
+
}).command("generate", "compiler glyphix project", {}, generateGlyphix).command(
|
|
312
|
+
"build",
|
|
313
|
+
"build glyphix project",
|
|
287
314
|
(yargs2) => {
|
|
288
|
-
return yargs2.
|
|
289
|
-
describe: "
|
|
290
|
-
type: "string"
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
return yargs2.options("device", {
|
|
316
|
+
describe: "The name of the device to use when building.\nThereafter, emulation and packaging will use this\nconfiguration.",
|
|
317
|
+
type: "string",
|
|
318
|
+
alias: "d"
|
|
319
|
+
}).options("emulator", {
|
|
320
|
+
describe: "Build packages for the emulator, not the target device",
|
|
321
|
+
type: "boolean",
|
|
322
|
+
alias: "e"
|
|
323
|
+
}).options("image-rules", {
|
|
324
|
+
describe: "Use the specified image rules description file\n(default is config/image-rules.json).",
|
|
325
|
+
type: "string",
|
|
326
|
+
alias: "r"
|
|
327
|
+
}).options("full", {
|
|
328
|
+
describe: "Rebuild all the files for the project.",
|
|
293
329
|
type: "string",
|
|
294
|
-
|
|
330
|
+
alias: "f"
|
|
331
|
+
}).options("dump", {
|
|
332
|
+
describe: "Dump details of the build process to aid debugging.",
|
|
333
|
+
type: "boolean"
|
|
295
334
|
}).help().argv;
|
|
296
335
|
},
|
|
297
336
|
buildGlyphix
|
|
298
|
-
).
|
|
337
|
+
).command("emu", "run emulator", (yargs2) => {
|
|
338
|
+
return yargs2.options("device", {
|
|
339
|
+
describe: "The name of the device to use when building,\nemulation and packaging.",
|
|
340
|
+
type: "string",
|
|
341
|
+
alias: "d",
|
|
342
|
+
demandOption: false
|
|
343
|
+
}).options("emulator-exe", {
|
|
344
|
+
describe: "Path to the glyphix-emu executable",
|
|
345
|
+
type: "string",
|
|
346
|
+
alias: "e",
|
|
347
|
+
normalize: true,
|
|
348
|
+
demandOption: false
|
|
349
|
+
}).options("language", {
|
|
350
|
+
describe: "Set the system language name. The default value is zh-CN.",
|
|
351
|
+
type: "string",
|
|
352
|
+
alias: "l"
|
|
353
|
+
}).options("inspector", {
|
|
354
|
+
describe: "Scale the window size to real device screen.",
|
|
355
|
+
type: "string",
|
|
356
|
+
alias: "l"
|
|
357
|
+
}).help().argv;
|
|
358
|
+
}).help().alias("help", "h").argv;
|
package/libs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(e){return e}export{o as defineComponent};
|
package/package.json
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glyphix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
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",
|
|
30
|
+
"dotenv": "^16.4.7",
|
|
21
31
|
"esbuild": "^0.24.2",
|
|
32
|
+
"esbuild-plugin-d.ts": "^1.3.1",
|
|
22
33
|
"eslint": "^9.18.0",
|
|
23
34
|
"fs-extra": "^11.2.0",
|
|
24
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
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,7 +59,7 @@ 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
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module "@system.websocketfactory" {
|
|
2
2
|
interface WebSocketFactory {
|
|
3
|
-
create(options: {
|
|
3
|
+
create(options: {
|
|
4
|
+
url: string;
|
|
5
|
+
header: { [key: string]: any };
|
|
6
|
+
}): WebSocketInstance;
|
|
4
7
|
}
|
|
5
8
|
|
|
6
9
|
export interface WebSocketInstance {
|