glyphix 1.0.6 → 1.0.7

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 CHANGED
@@ -1,2 +1,295 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var d=Object.create;var h=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var I=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of m(t))!y.call(e,i)&&i!==r&&h(e,i,{get:()=>t[i],enumerable:!(s=f(t,i))||s.enumerable});return e};var g=(e,t,r)=>(r=e!=null?d(v(e)):{},I(t||!e||!e.__esModule?h(r,"default",{value:e,enumerable:!0}):r,e));var u=g(require("esbuild")),o=require("path"),n=require("fs"),p=require("fs-extra");if(!process.env.VITE_BUILD_DIR)throw Error("not set glyphix project path");var l=(0,o.resolve)(process.cwd(),process.env.VITE_BUILD_DIR),x=JSON.parse((0,n.readFileSync)((0,o.resolve)(l,"entry.vite.json")).toString()),a=[".ts",".js"],E=x.entry;(0,p.removeSync)((0,o.resolve)(l,".vite-dist"));var c=E.map(e=>(0,o.resolve)(l,e));c=c.map(e=>{if((0,n.existsSync)(e)){let t=e.replace(".js",".ts");return(0,n.existsSync)(t)&&(0,p.removeSync)(t),(0,p.moveSync)(e,t),t}return e});u.default.build({entryPoints:c,bundle:!0,outdir:(0,o.resolve)(l,".vite-dist"),splitting:!0,format:"esm",resolveExtensions:a,external:["@system*"],platform:"node",target:"node14",minify:process.env.GLYPHIX_ENV!=="development",plugins:[{name:"glyphix-resolve-path",setup(e){e.onResolve({filter:/^\//},t=>{if((0,n.existsSync)(t.path))return{path:t.path};for(let r=0;r<a.length;r++){let s=(0,o.join)(l,`${t.path}${a[r]}`);if((0,n.existsSync)(s))return{path:s}}return{path:t.path}})}}]}).then(()=>{console.log("Build completed!")}).catch(e=>{console.error("Build failed:",e)});
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/index.ts
27
+ var import_yargs = __toESM(require("yargs"));
28
+
29
+ // src/utils/logger.ts
30
+ var import_chalk = __toESM(require("chalk"));
31
+ var { log: originLog } = console;
32
+ console.debug = function(...args) {
33
+ originLog(import_chalk.default.gray(...args));
34
+ };
35
+ console.info = function(...args) {
36
+ originLog(import_chalk.default.white(...args));
37
+ };
38
+ console.warn = function(...args) {
39
+ originLog(import_chalk.default.yellow(...args));
40
+ };
41
+ console.error = function(...args) {
42
+ originLog(import_chalk.default.red(...args));
43
+ };
44
+
45
+ // src/command/new.ts
46
+ var import_fs_extra = require("fs-extra");
47
+ var import_child_process = require("child_process");
48
+ var import_node_path = require("path");
49
+ function isValidDirectoryName(name) {
50
+ const illegalChars = /[<>:"/\\|?*\x00-\x1F]/;
51
+ const reservedNames = /^(CON|PRN|AUX|NUL|COM\d|LPT\d)$/i;
52
+ if (!name || name.trim() === "" || illegalChars.test(name) || reservedNames.test(name)) {
53
+ return false;
54
+ }
55
+ if (name.endsWith(" ") || name.endsWith(".")) {
56
+ return false;
57
+ }
58
+ return true;
59
+ }
60
+ function createProject(cwd, name) {
61
+ const targetFullPath = (0, import_node_path.resolve)(cwd, name);
62
+ if ((0, import_fs_extra.existsSync)(targetFullPath)) {
63
+ console.error(`Target directory "SimpleApp" is not empty`);
64
+ return;
65
+ }
66
+ if (!isValidDirectoryName(name)) {
67
+ console.error("project name invalid: " + name);
68
+ return;
69
+ }
70
+ let sourceRootPath = __dirname;
71
+ if (process.env.NODE_ENV === "development") {
72
+ sourceRootPath = cwd;
73
+ }
74
+ (0, import_fs_extra.copySync)((0, import_node_path.resolve)(sourceRootPath, "template/ts"), targetFullPath);
75
+ (0, import_child_process.spawnSync)("git", ["init"], { cwd: targetFullPath });
76
+ }
77
+
78
+ // src/command/buildEmu.ts
79
+ var import_child_process2 = require("child_process");
80
+ var import_node_path2 = require("path");
81
+ function reconstructArgs(argv) {
82
+ var _a;
83
+ const constructArg = [];
84
+ if ((_a = argv._) == null ? void 0 : _a.length) {
85
+ constructArg.push(...argv._);
86
+ }
87
+ Object.keys(argv).forEach((key) => {
88
+ if (key === "_" || key === "$0") {
89
+ return;
90
+ }
91
+ const val = argv[key];
92
+ let prefix = "-";
93
+ if (key.length > 1) {
94
+ prefix = "--";
95
+ }
96
+ if (typeof val === "boolean") {
97
+ constructArg.push(`${prefix}${key}`);
98
+ } else {
99
+ constructArg.push(...[`${prefix}${key}`, val]);
100
+ }
101
+ });
102
+ return constructArg;
103
+ }
104
+ function findGlyphixTools() {
105
+ const cwd = process.cwd();
106
+ const glyphixTools = (0, import_node_path2.resolve)(cwd, "node_modules/glyphix", "emu/bin/gx");
107
+ return glyphixTools;
108
+ }
109
+ function buildGlyphix(args) {
110
+ var _a, _b;
111
+ const childProcess = (0, import_child_process2.execFile)(findGlyphixTools(), reconstructArgs(args), {
112
+ cwd: process.cwd()
113
+ });
114
+ (_a = childProcess.stdout) == null ? void 0 : _a.on("data", (data) => {
115
+ console.log(data);
116
+ });
117
+ (_b = childProcess.stderr) == null ? void 0 : _b.on("data", (data) => {
118
+ console.error(data);
119
+ });
120
+ childProcess.on("exit", () => {
121
+ console.log("exit");
122
+ });
123
+ childProcess.on("close", () => {
124
+ console.log("close");
125
+ });
126
+ }
127
+
128
+ // src/command/generate.ts
129
+ var import_esbuild = __toESM(require("esbuild"));
130
+ var import_node_path3 = require("path");
131
+ var import_node_fs = require("fs");
132
+ var import_fs_extra2 = require("fs-extra");
133
+ var import_eslint = require("eslint");
134
+ var import_glob = require("glob");
135
+ var import_chalk2 = __toESM(require("chalk"));
136
+ var import_node_process = require("process");
137
+ function getOriginFilePath(filePath, rootPath) {
138
+ const relativePath = (0, import_node_path3.relative)(rootPath, filePath);
139
+ const projectRoot = process.cwd();
140
+ return (0, import_node_path3.resolve)(projectRoot, "src", relativePath);
141
+ }
142
+ function outErrorLog(results, filepath) {
143
+ results.messages.forEach((item) => {
144
+ console.log(
145
+ `${filepath}:${item.line}:${item.column}`,
146
+ "\n ",
147
+ import_chalk2.default.red("error"),
148
+ " ",
149
+ item.message,
150
+ " ",
151
+ import_chalk2.default.gray(item.ruleId)
152
+ );
153
+ });
154
+ }
155
+ function lintFile(rootPath) {
156
+ const distPath = (0, import_node_path3.join)(rootPath, ".vite-dist");
157
+ if ((0, import_node_fs.existsSync)(distPath)) {
158
+ (0, import_fs_extra2.removeSync)(distPath);
159
+ }
160
+ const sources = (0, import_glob.sync)([
161
+ `${(0, import_node_path3.resolve)(rootPath)}/**/*.ts`,
162
+ `${(0, import_node_path3.resolve)(rootPath)}/**/*.js`
163
+ ]);
164
+ const eslint = new import_eslint.ESLint({
165
+ warnIgnored: true,
166
+ overrideConfig: {
167
+ rules: {
168
+ "prettier/prettier": "off",
169
+ "@typescript-eslint/ban-ts-comment": "off"
170
+ }
171
+ }
172
+ });
173
+ return eslint.lintFiles(sources).then((res) => {
174
+ return res.filter((item) => item.errorCount).map((item) => {
175
+ return item;
176
+ }).flat();
177
+ }).then((res) => {
178
+ res.forEach((item) => {
179
+ const originPath = getOriginFilePath(item.filePath, rootPath);
180
+ outErrorLog(item, originPath);
181
+ });
182
+ return res;
183
+ });
184
+ }
185
+ function dealResource() {
186
+ if (!process.env["VITE_BUILD_DIR"])
187
+ throw Error("not set glyphix project path");
188
+ const rootPath = (0, import_node_path3.resolve)(process.cwd(), process.env["VITE_BUILD_DIR"]);
189
+ const entryFileContent = JSON.parse(
190
+ (0, import_node_fs.readFileSync)((0, import_node_path3.resolve)(rootPath, "entry.vite.json")).toString()
191
+ );
192
+ const entries = entryFileContent.entry;
193
+ (0, import_fs_extra2.removeSync)((0, import_node_path3.resolve)(rootPath, ".vite-dist"));
194
+ let entriedFullPath = entries.map((item) => (0, import_node_path3.resolve)(rootPath, item));
195
+ entriedFullPath = entriedFullPath.map((item) => {
196
+ if ((0, import_node_fs.existsSync)(item)) {
197
+ const dest = item.replace(".js", ".ts");
198
+ if ((0, import_node_fs.existsSync)(dest)) (0, import_fs_extra2.removeSync)(dest);
199
+ (0, import_fs_extra2.moveSync)(item, dest);
200
+ return dest;
201
+ }
202
+ return item;
203
+ });
204
+ return {
205
+ root: rootPath,
206
+ entry: entriedFullPath
207
+ };
208
+ }
209
+ function build(rootPath, entriedFullPath) {
210
+ const resolveExtensions = [".ts", ".js"];
211
+ import_esbuild.default.build({
212
+ entryPoints: entriedFullPath,
213
+ // 入口文件
214
+ bundle: true,
215
+ // 启用打包
216
+ outdir: (0, import_node_path3.resolve)(rootPath, ".vite-dist"),
217
+ // 输出目录
218
+ splitting: true,
219
+ // 启用代码分割
220
+ format: "esm",
221
+ // 输出为 ESM 格式
222
+ resolveExtensions,
223
+ external: ["@system*"],
224
+ // 将 lodash 和 axios 作为外部依赖
225
+ platform: "node",
226
+ target: "node14",
227
+ // 目标平台设置为最新 ECMAScript
228
+ minify: process.env.GLYPHIX_ENV === "development" ? false : true,
229
+ plugins: [
230
+ {
231
+ name: "glyphix-resolve-path",
232
+ setup(build2) {
233
+ build2.onResolve({ filter: /^\// }, (args) => {
234
+ if ((0, import_node_fs.existsSync)(args.path)) {
235
+ return {
236
+ path: args.path
237
+ };
238
+ }
239
+ for (let i = 0; i < resolveExtensions.length; i++) {
240
+ const fullPath = (0, import_node_path3.join)(
241
+ rootPath,
242
+ `${args.path}${resolveExtensions[i]}`
243
+ );
244
+ if ((0, import_node_fs.existsSync)(fullPath)) {
245
+ return {
246
+ path: fullPath
247
+ };
248
+ }
249
+ }
250
+ return {
251
+ path: args.path
252
+ };
253
+ });
254
+ }
255
+ }
256
+ ]
257
+ }).then(() => {
258
+ console.log("Build completed!");
259
+ }).catch((error) => {
260
+ console.error("Build failed:", error);
261
+ });
262
+ }
263
+ function generateGlyphix() {
264
+ const config = dealResource();
265
+ lintFile(config.root).then((res) => {
266
+ if (res.length) {
267
+ (0, import_node_process.exit)(1);
268
+ }
269
+ build(config.root, config.entry);
270
+ });
271
+ }
272
+
273
+ // src/index.ts
274
+ import_yargs.default.option("create", { describe: "create a new project" }).command("create", "create a glyphix project", {}, (args) => {
275
+ console.debug("create project", __dirname);
276
+ if (args._.length < 2) {
277
+ console.error("miss project name");
278
+ return;
279
+ }
280
+ createProject(process.cwd(), args._[1] + "");
281
+ }).command("generate", "compiler glyphix project", {}, generateGlyphix).command("build", "build glyphix project", {}, buildGlyphix).command(
282
+ "emu",
283
+ "run emulator",
284
+ (yargs2) => {
285
+ return yargs2.positional("glyphix emu [OPTIONS]", {
286
+ describe: "213",
287
+ type: "string"
288
+ }).options("device", {
289
+ alias: "d",
290
+ type: "string",
291
+ description: "The name of the device to use when building, \n emulation and packaging"
292
+ }).help().argv;
293
+ },
294
+ buildGlyphix
295
+ ).help().alias("help", "h").argv;
package/package.json CHANGED
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
+ "files": [
7
+ "glyphix.js",
8
+ "types/",
9
+ "template/"
10
+ ],
11
+ "scripts": {
12
+ "postinstall": "node ./script/install.js"
13
+ },
6
14
  "bin": {
7
15
  "glyphix": "./glyphix.js"
8
16
  },
9
17
  "dependencies": {
18
+ "adm-zip": "^0.5.16",
19
+ "chalk": "^4.1.2",
10
20
  "esbuild": "^0.24.2",
11
- "fs-extra": "^11.2.0"
21
+ "eslint": "^9.18.0",
22
+ "fs-extra": "^11.2.0",
23
+ "glob": "^11.0.1",
24
+ "yargs": "^17.7.2"
12
25
  }
13
26
  }
@@ -0,0 +1,21 @@
1
+ //此处的规则供参考,其中多半其实都是默认值,可以根据个人习惯改写
2
+ module.exports = {
3
+ printWidth: 80, //单行长度
4
+ tabWidth: 2, //缩进长度
5
+ useTabs: false, //使用空格代替tab缩进
6
+ semi: true, //句末使用分号
7
+ singleQuote: true, //使用单引号
8
+ quoteProps: 'as-needed', //仅在必需时为对象的key添加引号
9
+ jsxSingleQuote: true, // jsx中使用单引号
10
+ trailingComma: 'all', //多行时尽可能打印尾随逗号
11
+ bracketSpacing: true, //在对象前后添加空格-eg: { foo: bar }
12
+ jsxBracketSameLine: true, //多属性html标签的‘>’折行放置
13
+ arrowParens: 'always', //单参数箭头函数参数周围使用圆括号-eg: (x) => x
14
+ requirePragma: false, //无需顶部注释即可格式化
15
+ insertPragma: false, //在已被preitter格式化的文件顶部加上标注
16
+ proseWrap: 'preserve', //不知道怎么翻译
17
+ htmlWhitespaceSensitivity: 'ignore', //对HTML全局空白不敏感
18
+ vueIndentScriptAndStyle: false, //不对vue中的script及style标签缩进
19
+ endOfLine: 'lf', //结束行形式
20
+ embeddedLanguageFormatting: 'auto', //对引用代码进行格式化
21
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "eslint.run": "onSave",
4
+ "files.exclude": {
5
+ ".glyphix-work": true,
6
+ ".husky": true
7
+ }
8
+ }
@@ -0,0 +1,47 @@
1
+ import typescriptEslint from '@typescript-eslint/eslint-plugin';
2
+ import prettier from 'eslint-plugin-prettier';
3
+ import globals from 'globals';
4
+ import tsParser from '@typescript-eslint/parser';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import js from '@eslint/js';
8
+ import { FlatCompat } from '@eslint/eslintrc';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const compat = new FlatCompat({
13
+ baseDirectory: __dirname,
14
+ recommendedConfig: js.configs.recommended,
15
+ allConfig: js.configs.all,
16
+ });
17
+
18
+ export default [
19
+ ...compat.extends(
20
+ 'eslint:recommended',
21
+ 'plugin:@typescript-eslint/recommended',
22
+ 'plugin:prettier/recommended',
23
+ ),
24
+ {
25
+ plugins: {
26
+ '@typescript-eslint': typescriptEslint,
27
+ prettier,
28
+ },
29
+
30
+ languageOptions: {
31
+ globals: {
32
+ ...globals.browser,
33
+ ...globals.node,
34
+ },
35
+
36
+ parser: tsParser,
37
+ ecmaVersion: 2020,
38
+ sourceType: 'module',
39
+ },
40
+
41
+ rules: {
42
+ 'no-undef': 'error',
43
+ 'prettier/prettier': 'error',
44
+ quotes: [0, 'double'],
45
+ },
46
+ },
47
+ ];
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "test-app",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build:dev": "cross-env GLYPHIX_ENV=development gx build -e",
8
+ "build:pro": "cross-env GLYPHIX_ENV=production gx build -e"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "devDependencies": {
14
+ "@typescript-eslint/eslint-plugin": "^8.19.1",
15
+ "@typescript-eslint/parser": "^8.19.1",
16
+ "cross-env": "^7.0.3",
17
+ "eslint": "^9.18.0",
18
+ "eslint-config-prettier": "^9.1.0",
19
+ "eslint-plugin-import": "^2.31.0",
20
+ "eslint-plugin-prettier": "^5.2.1",
21
+ "eslint-plugin-promise": "^7.2.1",
22
+ "eslint-plugin-vue": "^9.32.0",
23
+ "glyphix": "^1.0.6",
24
+ "lint-staged": "^15.3.0",
25
+ "prettier": "^3.4.2",
26
+ "typescript": "^5.7.3"
27
+ }
28
+ }
@@ -0,0 +1,21 @@
1
+ export default {
2
+ onCreate() {
3
+ console.info('Application onCreate');
4
+ },
5
+ onShow() {
6
+ console.info('Application onShow');
7
+ },
8
+ onHide() {
9
+ console.info('Application onHide');
10
+ },
11
+ onDestroy() {
12
+ console.info('Application onDestroy');
13
+ },
14
+ onError() {
15
+ console.log('Application onError');
16
+ },
17
+ onPageNotFound(params) {
18
+ const { uri = '' } = params;
19
+ console.error('error uri', uri);
20
+ },
21
+ };
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <p>{{ text }}</p>
3
+ </template>
4
+
5
+ <style>
6
+ p {
7
+ font-size: 48px;
8
+ text-align: center;
9
+ }
10
+ </style>
11
+
12
+ <script>
13
+ export default {
14
+ data: {
15
+ text: "123"
16
+ },
17
+ onInit() {
18
+ },
19
+ };
20
+ </script>
@@ -0,0 +1,18 @@
1
+ {
2
+ "package": "com.example.app",
3
+ "name": "Example App",
4
+ "versionName": "1.0.0",
5
+ "versionCode": 1,
6
+ "features": [],
7
+ "router": {
8
+ "entry": "main",
9
+ "pages": {
10
+ "main": {
11
+ "component": "index"
12
+ }
13
+ }
14
+ },
15
+ "config": {
16
+ "designWidth": 410
17
+ }
18
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2021",
4
+ "module": "commonjs",
5
+ "baseUrl": "./",
6
+ "paths": {
7
+ "/*": ["src/*"]
8
+ },
9
+ "types": ["node_modules/glyphix/types/index.d.ts"],
10
+ "allowImportingTsExtensions": true,
11
+ "checkJs": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "emitDeclarationOnly": true,
15
+ "esModuleInterop": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "skipLibCheck": true
20
+ },
21
+ "include": [
22
+ "node_modules/glyphix/types/index.d.ts",
23
+ "src/**/*.ts",
24
+ "src/**/*.ux",
25
+ "src/**/*.js"
26
+ ]
27
+ }
@@ -0,0 +1,21 @@
1
+ //此处的规则供参考,其中多半其实都是默认值,可以根据个人习惯改写
2
+ module.exports = {
3
+ printWidth: 80, //单行长度
4
+ tabWidth: 2, //缩进长度
5
+ useTabs: false, //使用空格代替tab缩进
6
+ semi: true, //句末使用分号
7
+ singleQuote: true, //使用单引号
8
+ quoteProps: 'as-needed', //仅在必需时为对象的key添加引号
9
+ jsxSingleQuote: true, // jsx中使用单引号
10
+ trailingComma: 'all', //多行时尽可能打印尾随逗号
11
+ bracketSpacing: true, //在对象前后添加空格-eg: { foo: bar }
12
+ jsxBracketSameLine: true, //多属性html标签的‘>’折行放置
13
+ arrowParens: 'always', //单参数箭头函数参数周围使用圆括号-eg: (x) => x
14
+ requirePragma: false, //无需顶部注释即可格式化
15
+ insertPragma: false, //在已被preitter格式化的文件顶部加上标注
16
+ proseWrap: 'preserve', //不知道怎么翻译
17
+ htmlWhitespaceSensitivity: 'ignore', //对HTML全局空白不敏感
18
+ vueIndentScriptAndStyle: false, //不对vue中的script及style标签缩进
19
+ endOfLine: 'lf', //结束行形式
20
+ embeddedLanguageFormatting: 'auto', //对引用代码进行格式化
21
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "eslint.run": "onSave",
4
+ "files.exclude": {
5
+ ".glyphix-work": true,
6
+ ".husky": true
7
+ }
8
+ }
@@ -0,0 +1,48 @@
1
+ import typescriptEslint from '@typescript-eslint/eslint-plugin';
2
+ import prettier from 'eslint-plugin-prettier';
3
+ import globals from 'globals';
4
+ import tsParser from '@typescript-eslint/parser';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import js from '@eslint/js';
8
+ import { FlatCompat } from '@eslint/eslintrc';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const compat = new FlatCompat({
13
+ baseDirectory: __dirname,
14
+ recommendedConfig: js.configs.recommended,
15
+ allConfig: js.configs.all,
16
+ });
17
+
18
+ export default [
19
+ ...compat.extends(
20
+ 'eslint:recommended',
21
+ 'plugin:@typescript-eslint/recommended',
22
+ 'plugin:prettier/recommended',
23
+ ),
24
+ {
25
+ plugins: {
26
+ '@typescript-eslint': typescriptEslint,
27
+ prettier,
28
+ },
29
+
30
+ languageOptions: {
31
+ globals: {
32
+ ...globals.browser,
33
+ ...globals.node,
34
+ },
35
+
36
+ parser: tsParser,
37
+ ecmaVersion: 2020,
38
+ sourceType: 'module',
39
+ },
40
+
41
+ rules: {
42
+ 'no-undef': 'error',
43
+ 'prettier/prettier': 'error',
44
+ quotes: [0, 'double'],
45
+ '@typescript-eslint/no-explicit-any': 'warn',
46
+ },
47
+ },
48
+ ];
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "test-app",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build:dev": "cross-env GLYPHIX_ENV=development gx build -e",
8
+ "build:pro": "cross-env GLYPHIX_ENV=production gx build -e"
9
+ },
10
+
11
+ "keywords": [],
12
+ "author": "",
13
+ "license": "ISC",
14
+ "devDependencies": {
15
+ "@typescript-eslint/eslint-plugin": "^8.19.1",
16
+ "@typescript-eslint/parser": "^8.19.1",
17
+ "cross-env": "^7.0.3",
18
+ "eslint": "^9.18.0",
19
+ "eslint-config-prettier": "^9.1.0",
20
+ "eslint-plugin-import": "^2.31.0",
21
+ "eslint-plugin-prettier": "^5.2.1",
22
+ "eslint-plugin-promise": "^7.2.1",
23
+ "eslint-plugin-vue": "^9.32.0",
24
+ "glyphix": "^1.0.6",
25
+ "lint-staged": "^15.3.0",
26
+ "prettier": "^3.4.2",
27
+ "typescript": "^5.7.3"
28
+ }
29
+ }
@@ -0,0 +1,22 @@
1
+ export default {
2
+ onCreate() {
3
+ console.info('Application onCreate');
4
+ },
5
+ onShow() {
6
+ console.info('Application onShow');
7
+ },
8
+ onHide() {
9
+ console.info('Application onHide');
10
+ },
11
+ onDestroy() {
12
+ console.info('Application onDestroy');
13
+ },
14
+ onError() {
15
+ console.log('Application onError');
16
+ },
17
+ // @ts-ignore
18
+ onPageNotFound(params) {
19
+ const { uri = '' } = params;
20
+ console.error('error uri', uri);
21
+ },
22
+ };
@@ -0,0 +1,3 @@
1
+ export function test() {
2
+ return 123;
3
+ }
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <p>{{ text }}</p>
3
+ </template>
4
+
5
+ <style>
6
+ p {
7
+ font-size: 48px;
8
+ text-align: center;
9
+ }
10
+ </style>
11
+
12
+ <script lang="ts">
13
+ import { test } from '/libs/test';
14
+ export default {
15
+ data: {
16
+ text: "123"
17
+ },
18
+ onInit() {
19
+ console.log(test());
20
+ },
21
+ };
22
+ </script>
@@ -0,0 +1,18 @@
1
+ {
2
+ "package": "com.example.app",
3
+ "name": "Example App",
4
+ "versionName": "1.0.0",
5
+ "versionCode": 1,
6
+ "features": [],
7
+ "router": {
8
+ "entry": "main",
9
+ "pages": {
10
+ "main": {
11
+ "component": "index"
12
+ }
13
+ }
14
+ },
15
+ "config": {
16
+ "designWidth": 410
17
+ }
18
+ }
@@ -0,0 +1,111 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve" /* Specify what JSX code is generated. */,
17
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "commonjs" /* Specify what module code is generated. */,
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ "baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */,
32
+ "paths": {
33
+ "/*": ["src/*"]
34
+ } /* Specify a set of entries that re-map imports to additional lookup locations. */,
35
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
36
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
37
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
38
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
39
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
40
+ "allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
41
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
+ // "resolveJsonModule": true, /* Enable importing .json files. */
45
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
46
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
47
+
48
+ /* JavaScript Support */
49
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
50
+ "checkJs": true /* Enable error reporting in type-checked JavaScript files. */,
51
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
52
+
53
+ /* Emit */
54
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
55
+ "declarationMap": true /* Create sourcemaps for d.ts files. */,
56
+ "emitDeclarationOnly": true /* Only output d.ts files and not JavaScript files. */,
57
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
58
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
60
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
61
+ // "removeComments": true, /* Disable emitting comments. */
62
+ // "noEmit": true, /* Disable emitting files from a compilation. */
63
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
64
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
65
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
66
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
67
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
68
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
69
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
70
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
71
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
72
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
73
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
74
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
75
+
76
+ /* Interop Constraints */
77
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
78
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
79
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
80
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
81
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
82
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
83
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
84
+
85
+ /* Type Checking */
86
+ "strict": true /* Enable all strict type-checking options. */,
87
+ "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
88
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
89
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
91
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
93
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
94
+ // "alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
95
+ "noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
96
+ "noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
97
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
98
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
99
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
100
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
101
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
102
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
103
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
104
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
105
+
106
+ /* Completeness */
107
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
109
+ },
110
+ "exclude": ["node_modules", "eslint.config.mjs"]
111
+ }