create-rezor 0.1.0 → 0.2.0
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/outfile.js +26 -3
- package/package.json +12 -9
- package/template/base/_gitignore +1 -2
- package/template/base/package.json.ejs +26 -29
- package/template/base/project.config.json +4 -13
- package/template/base/src/app.json +1 -0
- package/template/base/src/components/count-button/index.css +3 -0
- package/template/base/src/components/count-button/index.html +1 -1
- package/template/base/src/pages/home/index.css +7 -6
- package/template/base/src/pages/home/index.html +1 -3
- package/template/base/src/pages/mine/index.css +7 -6
- package/template/base/src/pages/mine/index.html +1 -3
- package/template/javascript/babel.config.js +4 -3
- package/template/javascript/build.js +6 -6
- package/template/skyline/src/app.json +40 -0
- package/template/skyline/src/pages/home/index.css +32 -0
- package/template/skyline/src/pages/home/index.html +9 -0
- package/template/skyline/src/pages/mine/index.css +32 -0
- package/template/skyline/src/pages/mine/index.html +9 -0
- package/template/skyline-javascript/src/pages/home/index.js +35 -0
- package/template/skyline-javascript/src/pages/mine/index.js +35 -0
- package/template/skyline-typescript/src/pages/home/index.ts +37 -0
- package/template/skyline-typescript/src/pages/mine/index.ts +37 -0
- package/template/typescript/babel.config.js +4 -3
- package/template/typescript/build.js +6 -6
- package/template/base/_npmrc +0 -1
package/outfile.js
CHANGED
|
@@ -90,12 +90,18 @@ function renderTemplate(src, dest, result) {
|
|
|
90
90
|
if (filename === 'project.config.json') {
|
|
91
91
|
const project = JSON.parse(fs.readFileSync(src, 'utf8'));
|
|
92
92
|
project.projectname = result.packageName;
|
|
93
|
+
if (result.needsSkyline) {
|
|
94
|
+
project.setting.compileWorklet = true;
|
|
95
|
+
project.setting.skylineRenderEnable = true;
|
|
96
|
+
}
|
|
93
97
|
fs.writeFileSync(dest, JSON.stringify(project, null, 2) + '\n');
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
100
|
if (filename === 'app.json') {
|
|
97
101
|
const app = JSON.parse(fs.readFileSync(src, 'utf8'));
|
|
98
|
-
|
|
102
|
+
if (!result.needsSkyline) {
|
|
103
|
+
app.window.navigationBarTitleText = result.packageName;
|
|
104
|
+
}
|
|
99
105
|
fs.writeFileSync(dest, JSON.stringify(app, null, 2) + '\n');
|
|
100
106
|
return;
|
|
101
107
|
}
|
|
@@ -233,6 +239,14 @@ async function init() {
|
|
|
233
239
|
initial: () => toValidPackageName(targetDir),
|
|
234
240
|
validate: (dir) => isValidPackageName(dir) || '无效的 package.json 名称',
|
|
235
241
|
},
|
|
242
|
+
{
|
|
243
|
+
name: 'needsSkyline',
|
|
244
|
+
type: 'toggle',
|
|
245
|
+
message: '是否使用 Skyline 渲染?',
|
|
246
|
+
initial: false,
|
|
247
|
+
active: '是',
|
|
248
|
+
inactive: '否',
|
|
249
|
+
},
|
|
236
250
|
{
|
|
237
251
|
name: 'needsTypeScript',
|
|
238
252
|
type: 'toggle',
|
|
@@ -286,7 +300,7 @@ async function init() {
|
|
|
286
300
|
}
|
|
287
301
|
// `initial` won't take effect if the prompt type is null
|
|
288
302
|
// so we still have to assign the default values here
|
|
289
|
-
const { projectName, shouldOverwrite = false, packageName = projectName ?? defaultProjectName, needsTypeScript = false, needsVitest = false, needsEslint = false, needsStylelint = false, needsPrettier = false, } = result;
|
|
303
|
+
const { projectName, shouldOverwrite = false, packageName = projectName ?? defaultProjectName, needsSkyline = false, needsTypeScript = false, needsVitest = false, needsEslint = false, needsStylelint = false, needsPrettier = false, } = result;
|
|
290
304
|
const root = path.join(cwd, targetDir);
|
|
291
305
|
if (fs.existsSync(root) && shouldOverwrite) {
|
|
292
306
|
emptyDir(root);
|
|
@@ -306,12 +320,12 @@ async function init() {
|
|
|
306
320
|
const render = (templateName) => {
|
|
307
321
|
renderTemplate(path.resolve(templateRoot, templateName), root, {
|
|
308
322
|
packageName,
|
|
323
|
+
needsSkyline,
|
|
309
324
|
needsTypeScript,
|
|
310
325
|
needsVitest,
|
|
311
326
|
needsEslint,
|
|
312
327
|
needsStylelint,
|
|
313
328
|
needsPrettier,
|
|
314
|
-
packageManager: ['npm', 'bun'].includes(packageManager) ? '' : (userAgent.split(' ')[0].replace('/', '@')),
|
|
315
329
|
});
|
|
316
330
|
};
|
|
317
331
|
render('base');
|
|
@@ -321,6 +335,15 @@ async function init() {
|
|
|
321
335
|
else {
|
|
322
336
|
render('javascript');
|
|
323
337
|
}
|
|
338
|
+
if (needsSkyline) {
|
|
339
|
+
render('skyline');
|
|
340
|
+
if (needsTypeScript) {
|
|
341
|
+
render('skyline-typescript');
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
render('skyline-javascript');
|
|
345
|
+
}
|
|
346
|
+
}
|
|
324
347
|
if (needsEslint) {
|
|
325
348
|
render('eslint');
|
|
326
349
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rezor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rezor 脚手架",
|
|
6
6
|
"bin": {
|
|
@@ -11,25 +11,28 @@
|
|
|
11
11
|
"template"
|
|
12
12
|
],
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": "
|
|
14
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/rezorjs/create-rezor.git"
|
|
15
19
|
},
|
|
16
|
-
"repository": "https://github.com/rezorjs/create-rezor.git",
|
|
17
20
|
"author": "Yang Mingshan <y.mingshan3@gmail.com>",
|
|
18
21
|
"license": "MIT",
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"ejs": "^
|
|
23
|
+
"ejs": "^6.0.1",
|
|
21
24
|
"kolorist": "^1.8.0",
|
|
22
25
|
"prompts": "^2.4.2"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@eslint/js": "^10.0.1",
|
|
26
29
|
"@types/ejs": "^3.1.5",
|
|
27
|
-
"@types/node": "^
|
|
30
|
+
"@types/node": "^26.2.0",
|
|
28
31
|
"@types/prompts": "^2.4.9",
|
|
29
|
-
"eslint": "^10.1
|
|
30
|
-
"prettier": "^3.
|
|
31
|
-
"typescript": "^6.0.
|
|
32
|
-
"typescript-eslint": "^8.
|
|
32
|
+
"eslint": "^10.8.1",
|
|
33
|
+
"prettier": "^3.9.6",
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"typescript-eslint": "^8.67.0"
|
|
33
36
|
},
|
|
34
37
|
"scripts": {
|
|
35
38
|
"format": "prettier --check \"**/*.{js,ts,json,md}\"",
|
package/template/base/_gitignore
CHANGED
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
|
-
<%_ if (packageManager) { _%>
|
|
7
|
-
"packageManager": "<%- packageManager %>",
|
|
8
|
-
<%_ } _%>
|
|
9
6
|
"engines": {
|
|
10
|
-
"node": "
|
|
7
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
11
8
|
},
|
|
12
9
|
"scripts": {
|
|
13
10
|
<%_ if (needsPrettier) { _%>
|
|
@@ -29,69 +26,69 @@
|
|
|
29
26
|
"build": "cross-env NODE_ENV=production node build.js"
|
|
30
27
|
},
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"@babel/runtime": "^
|
|
33
|
-
"rezor": "^0.
|
|
29
|
+
"@babel/runtime": "^8.0.0",
|
|
30
|
+
"rezor": "^0.5.0",
|
|
34
31
|
trailing-comma
|
|
35
32
|
},
|
|
36
33
|
"devDependencies": {
|
|
37
|
-
"@babel/core": "^
|
|
38
|
-
"@babel/plugin-transform-runtime": "^
|
|
39
|
-
"@babel/preset-env": "^
|
|
34
|
+
"@babel/core": "^8.0.1",
|
|
35
|
+
"@babel/plugin-transform-runtime": "^8.0.1",
|
|
36
|
+
"@babel/preset-env": "^8.0.2",
|
|
40
37
|
<%_ if (needsTypeScript) { _%>
|
|
41
|
-
"@babel/preset-typescript": "^
|
|
38
|
+
"@babel/preset-typescript": "^8.0.1",
|
|
42
39
|
<%_ } _%>
|
|
43
|
-
"@babel/traverse": "^
|
|
44
|
-
"@babel/types": "^
|
|
40
|
+
"@babel/traverse": "^8.0.4",
|
|
41
|
+
"@babel/types": "^8.0.4",
|
|
45
42
|
<%_ if (needsEslint) { _%>
|
|
46
43
|
"@eslint/js": "^10.0.1",
|
|
47
44
|
<%_ } _%>
|
|
48
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
45
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
49
46
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
50
47
|
"@rollup/plugin-replace": "^6.0.3",
|
|
51
48
|
"@rollup/plugin-terser": "^1.0.0",
|
|
52
49
|
<%_ if (needsTypeScript && needsVitest) { _%>
|
|
53
|
-
"@types/node": "^
|
|
50
|
+
"@types/node": "^26.2.0",
|
|
54
51
|
<%_ } _%>
|
|
55
52
|
<%_ if (needsVitest) { _%>
|
|
56
|
-
"@vitest/coverage-v8": "^4.1.
|
|
53
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
57
54
|
<%_ } _%>
|
|
58
|
-
"babel-plugin-autocomplete-index": "^0.
|
|
55
|
+
"babel-plugin-autocomplete-index": "^0.3.0",
|
|
56
|
+
"babel-plugin-inline-env-var": "^0.1.0",
|
|
59
57
|
"babel-plugin-module-resolver": "^5.0.3",
|
|
60
|
-
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
61
58
|
"chokidar": "^5.0.0",
|
|
62
59
|
"cross-env": "^10.1.0",
|
|
63
60
|
<%_ if (needsEslint) { _%>
|
|
64
|
-
"eslint": "^10.
|
|
61
|
+
"eslint": "^10.8.1",
|
|
65
62
|
<%_ if (needsPrettier) { _%>
|
|
66
63
|
"eslint-config-prettier": "^10.1.8",
|
|
67
64
|
<%_ } _%>
|
|
68
65
|
<%_ } _%>
|
|
69
|
-
"fs-extra": "^11.
|
|
66
|
+
"fs-extra": "^11.4.0",
|
|
70
67
|
<%_ if (needsEslint) { _%>
|
|
71
|
-
"globals": "^17.
|
|
68
|
+
"globals": "^17.11.0",
|
|
72
69
|
<%_ } _%>
|
|
73
70
|
"kolorist": "^1.8.0",
|
|
74
|
-
"local-pkg": "^1.1
|
|
75
|
-
"postcss": "^8.5.
|
|
71
|
+
"local-pkg": "^1.2.1",
|
|
72
|
+
"postcss": "^8.5.26",
|
|
76
73
|
"postcss-load-config": "^6.0.1",
|
|
77
74
|
"postcss-pxtorpx-pro": "^2.0.0",
|
|
78
75
|
<%_ if (needsPrettier) { _%>
|
|
79
|
-
"prettier": "^3.
|
|
76
|
+
"prettier": "^3.9.6",
|
|
80
77
|
<%_ } _%>
|
|
81
|
-
"rollup": "^4.
|
|
78
|
+
"rollup": "^4.62.4",
|
|
82
79
|
<%_ if (needsStylelint) { _%>
|
|
83
|
-
"stylelint": "^17.
|
|
80
|
+
"stylelint": "^17.14.1",
|
|
84
81
|
"stylelint-config-standard": "^40.0.0",
|
|
85
82
|
<%_ } _%>
|
|
86
|
-
"terser": "^5.
|
|
83
|
+
"terser": "^5.50.0",
|
|
87
84
|
<%_ if (needsTypeScript) { _%>
|
|
88
|
-
"typescript": "^6.0.
|
|
85
|
+
"typescript": "^6.0.3",
|
|
89
86
|
<%_ } _%>
|
|
90
87
|
<%_ if (needsTypeScript && needsEslint) { _%>
|
|
91
|
-
"typescript-eslint": "^8.
|
|
88
|
+
"typescript-eslint": "^8.67.0",
|
|
92
89
|
<%_ } _%>
|
|
93
90
|
<%_ if (needsVitest) { _%>
|
|
94
|
-
"vitest": "^4.1.
|
|
91
|
+
"vitest": "^4.1.10",
|
|
95
92
|
<%_ } _%>
|
|
96
93
|
trailing-comma
|
|
97
94
|
},
|
|
@@ -12,29 +12,20 @@
|
|
|
12
12
|
"postcss": false,
|
|
13
13
|
"preloadBackgroundData": false,
|
|
14
14
|
"minified": false,
|
|
15
|
-
"newFeature": true,
|
|
16
15
|
"coverView": true,
|
|
17
|
-
"nodeModules": false,
|
|
18
16
|
"autoAudits": false,
|
|
19
17
|
"showShadowRootInWxmlPanel": false,
|
|
20
|
-
"scopeDataCheck": false,
|
|
21
18
|
"uglifyFileName": false,
|
|
22
19
|
"checkInvalidKey": true,
|
|
23
|
-
"checkSiteMap": true,
|
|
24
20
|
"uploadWithSourceMap": false,
|
|
25
21
|
"compileHotReLoad": true,
|
|
26
22
|
"lazyloadPlaceholderEnable": false,
|
|
27
|
-
"useMultiFrameRuntime": true,
|
|
28
23
|
"useApiHook": true,
|
|
29
|
-
"useApiHostProcess": true,
|
|
30
24
|
"babelSetting": {
|
|
31
25
|
"ignore": [],
|
|
32
26
|
"disablePlugins": [],
|
|
33
27
|
"outputPath": ""
|
|
34
28
|
},
|
|
35
|
-
"useIsolateContext": false,
|
|
36
|
-
"userConfirmedUseIsolateContext": false,
|
|
37
|
-
"userConfirmedBundleSwitch": false,
|
|
38
29
|
"packNpmManually": false,
|
|
39
30
|
"packNpmRelationList": [],
|
|
40
31
|
"minifyWXSS": true,
|
|
@@ -46,16 +37,16 @@
|
|
|
46
37
|
"compileWorklet": false,
|
|
47
38
|
"localPlugins": false,
|
|
48
39
|
"condition": false,
|
|
49
|
-
"
|
|
50
|
-
"disableSWC": true,
|
|
40
|
+
"disableSWC": false,
|
|
51
41
|
"skylineRenderEnable": false,
|
|
52
42
|
"useStaticServer": false,
|
|
53
43
|
"useLanDebug": false,
|
|
54
44
|
"ignoreDevUnusedFiles": true,
|
|
55
|
-
"bigPackageSizeSupport": false
|
|
45
|
+
"bigPackageSizeSupport": false,
|
|
46
|
+
"useGlassEaselForWxml": false
|
|
56
47
|
},
|
|
57
48
|
"compileType": "miniprogram",
|
|
58
|
-
"libVersion": "
|
|
49
|
+
"libVersion": "latest",
|
|
59
50
|
"appid": "",
|
|
60
51
|
"projectname": "rezor-project",
|
|
61
52
|
"simulatorType": "wechat",
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
.home {
|
|
2
|
-
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
.logo {
|
|
6
|
-
margin:
|
|
8
|
+
margin-top: 100px;
|
|
7
9
|
width: 400px;
|
|
8
10
|
height: 400px;
|
|
9
11
|
font-size: 64px;
|
|
10
12
|
line-height: 400px;
|
|
11
13
|
font-weight: bold;
|
|
14
|
+
text-align: center;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
.greeting {
|
|
@@ -17,12 +20,10 @@
|
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
.theme {
|
|
20
|
-
margin-top:
|
|
23
|
+
margin-top: 40px;
|
|
21
24
|
font-size: 48px;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
.count {
|
|
25
|
-
margin-top:
|
|
26
|
-
display: flex;
|
|
27
|
-
justify-content: center;
|
|
28
|
+
margin-top: 40px;
|
|
28
29
|
}
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
<view class="logo">LOGO</view>
|
|
3
3
|
<view class="greeting">欢迎使用 Rezor</view>
|
|
4
4
|
<view class="theme">当前主题: {{ themeText }}</view>
|
|
5
|
-
<
|
|
6
|
-
<count-button count="{{ count }}" bind:increment="increment" />
|
|
7
|
-
</view>
|
|
5
|
+
<count-button class="count" count="{{ count }}" bind:increment="increment" />
|
|
8
6
|
</view>
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
.mine {
|
|
2
|
-
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
.logo {
|
|
6
|
-
margin:
|
|
8
|
+
margin-top: 100px;
|
|
7
9
|
width: 400px;
|
|
8
10
|
height: 400px;
|
|
9
11
|
font-size: 64px;
|
|
10
12
|
line-height: 400px;
|
|
11
13
|
font-weight: bold;
|
|
14
|
+
text-align: center;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
.greeting {
|
|
@@ -17,12 +20,10 @@
|
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
.theme {
|
|
20
|
-
margin-top:
|
|
23
|
+
margin-top: 40px;
|
|
21
24
|
font-size: 48px;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
.count {
|
|
25
|
-
margin-top:
|
|
26
|
-
display: flex;
|
|
27
|
-
justify-content: center;
|
|
28
|
+
margin-top: 40px;
|
|
28
29
|
}
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
<view class="logo">LOGO</view>
|
|
3
3
|
<view class="greeting">希望你会喜欢</view>
|
|
4
4
|
<view class="theme">当前主题: {{ themeText }}</view>
|
|
5
|
-
<
|
|
6
|
-
<count-button count="{{ count }}" bind:increment="increment" />
|
|
7
|
-
</view>
|
|
5
|
+
<count-button class="count" count="{{ count }}" bind:increment="increment" />
|
|
8
6
|
</view>
|
|
@@ -20,9 +20,11 @@ const config = {
|
|
|
20
20
|
mutableTemplateObject: true,
|
|
21
21
|
noClassCalls: true,
|
|
22
22
|
noDocumentAll: true,
|
|
23
|
+
noIncompleteNsImportDetection: true,
|
|
23
24
|
noNewArrows: true,
|
|
25
|
+
noUninitializedPrivateFieldAccess: true,
|
|
24
26
|
objectRestNoSymbols: true,
|
|
25
|
-
|
|
27
|
+
privateFieldsAsSymbols: true,
|
|
26
28
|
pureGetters: true,
|
|
27
29
|
setClassMethods: true,
|
|
28
30
|
setComputedProperties: true,
|
|
@@ -35,7 +37,6 @@ const config = {
|
|
|
35
37
|
[
|
|
36
38
|
'@babel/preset-env',
|
|
37
39
|
{
|
|
38
|
-
bugfixes: true,
|
|
39
40
|
modules: 'commonjs',
|
|
40
41
|
},
|
|
41
42
|
],
|
|
@@ -47,7 +48,7 @@ const config = {
|
|
|
47
48
|
version: runtimeVersion,
|
|
48
49
|
},
|
|
49
50
|
],
|
|
50
|
-
'
|
|
51
|
+
'inline-env-var',
|
|
51
52
|
[
|
|
52
53
|
'module-resolver',
|
|
53
54
|
{
|
|
@@ -7,9 +7,9 @@ import path from 'node:path';
|
|
|
7
7
|
import process from 'node:process';
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import chokidar from 'chokidar';
|
|
10
|
-
import
|
|
10
|
+
import { transformFileAsync } from '@babel/core';
|
|
11
11
|
import traverse from '@babel/traverse';
|
|
12
|
-
import
|
|
12
|
+
import { isStringLiteral } from '@babel/types';
|
|
13
13
|
import { minify } from 'terser';
|
|
14
14
|
import postcss from 'postcss';
|
|
15
15
|
import postcssrc from 'postcss-load-config';
|
|
@@ -89,11 +89,11 @@ async function bundleModule(module, pkg) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function traverseAST(ast, pkg, babelOnly = false) {
|
|
92
|
-
traverse
|
|
92
|
+
traverse(ast, {
|
|
93
93
|
CallExpression({ node }) {
|
|
94
94
|
if (
|
|
95
95
|
node.callee.name !== 'require' ||
|
|
96
|
-
!
|
|
96
|
+
!isStringLiteral(node.arguments[0]) ||
|
|
97
97
|
node.arguments[0].value.startsWith('.') ||
|
|
98
98
|
(babelOnly && !node.arguments[0].value.startsWith('@babel/runtime'))
|
|
99
99
|
) {
|
|
@@ -156,7 +156,7 @@ async function buildComponentLibrary(name) {
|
|
|
156
156
|
return new Promise((resolve) => {
|
|
157
157
|
const jobs = [];
|
|
158
158
|
const tnm = async (filePath) => {
|
|
159
|
-
const result = await
|
|
159
|
+
const result = await transformFileAsync(filePath, { ast: true });
|
|
160
160
|
traverseAST(result.ast, 'src', true);
|
|
161
161
|
const code = __PROD__
|
|
162
162
|
? (await minify(result.code, terserOptions)).code
|
|
@@ -201,7 +201,7 @@ async function scanDependencies() {
|
|
|
201
201
|
async function processScript(filePath) {
|
|
202
202
|
let ast, code;
|
|
203
203
|
try {
|
|
204
|
-
const result = await
|
|
204
|
+
const result = await transformFileAsync(path.resolve(filePath), {
|
|
205
205
|
ast: true,
|
|
206
206
|
});
|
|
207
207
|
ast = result.ast;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"darkmode": true,
|
|
3
|
+
"themeLocation": "theme.json",
|
|
4
|
+
"pages": ["pages/home/index", "pages/mine/index"],
|
|
5
|
+
"window": {
|
|
6
|
+
"backgroundColor": "@bgColor",
|
|
7
|
+
"backgroundColorTop": "@bgColor",
|
|
8
|
+
"backgroundColorBottom": "@bgColor"
|
|
9
|
+
},
|
|
10
|
+
"tabBar": {
|
|
11
|
+
"color": "@color",
|
|
12
|
+
"selectedColor": "@color",
|
|
13
|
+
"backgroundColor": "@bgColor",
|
|
14
|
+
"borderStyle": "@style",
|
|
15
|
+
"list": [
|
|
16
|
+
{
|
|
17
|
+
"text": "主页",
|
|
18
|
+
"pagePath": "pages/home/index",
|
|
19
|
+
"iconPath": "@homeIcon",
|
|
20
|
+
"selectedIconPath": "@homeSelectedIcon"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"text": "我",
|
|
24
|
+
"pagePath": "pages/mine/index",
|
|
25
|
+
"iconPath": "@mineIcon",
|
|
26
|
+
"selectedIconPath": "@mineSelectedIcon"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"style": "v2",
|
|
31
|
+
"sitemapLocation": "sitemap.json",
|
|
32
|
+
"lazyCodeLoading": "requiredComponents",
|
|
33
|
+
"renderer": "skyline",
|
|
34
|
+
"componentFramework": "glass-easel",
|
|
35
|
+
"rendererOptions": {
|
|
36
|
+
"skyline": {
|
|
37
|
+
"disableABTest": true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.home {
|
|
2
|
+
align-items: center;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.logo {
|
|
6
|
+
margin-top: 200px;
|
|
7
|
+
width: 400px;
|
|
8
|
+
height: 400px;
|
|
9
|
+
font-size: 64px;
|
|
10
|
+
line-height: 400px;
|
|
11
|
+
font-weight: bold;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.greeting {
|
|
16
|
+
font-size: 64px;
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.theme {
|
|
21
|
+
margin-top: 40px;
|
|
22
|
+
font-size: 48px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.count {
|
|
26
|
+
margin-top: 40px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.hint {
|
|
30
|
+
margin-top: 20px;
|
|
31
|
+
font-size: 24px;
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<view class="home">
|
|
2
|
+
<pan-gesture-handler worklet:ongesture="pan">
|
|
3
|
+
<view class="logo">LOGO</view>
|
|
4
|
+
</pan-gesture-handler>
|
|
5
|
+
<view class="greeting">欢迎使用 Rezor</view>
|
|
6
|
+
<view class="theme">当前主题: {{ themeText }}</view>
|
|
7
|
+
<count-button class="count" count="{{ count }}" bind:increment="increment" />
|
|
8
|
+
<view class="hint">Logo 可以拖动哦!</view>
|
|
9
|
+
</view>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.mine {
|
|
2
|
+
align-items: center;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.logo {
|
|
6
|
+
margin-top: 200px;
|
|
7
|
+
width: 400px;
|
|
8
|
+
height: 400px;
|
|
9
|
+
font-size: 64px;
|
|
10
|
+
line-height: 400px;
|
|
11
|
+
font-weight: bold;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.greeting {
|
|
16
|
+
font-size: 64px;
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.theme {
|
|
21
|
+
margin-top: 40px;
|
|
22
|
+
font-size: 48px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.count {
|
|
26
|
+
margin-top: 40px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.hint {
|
|
30
|
+
margin-top: 20px;
|
|
31
|
+
font-size: 24px;
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<view class="mine">
|
|
2
|
+
<pan-gesture-handler worklet:ongesture="pan">
|
|
3
|
+
<view class="logo">LOGO</view>
|
|
4
|
+
</pan-gesture-handler>
|
|
5
|
+
<view class="greeting">希望你会喜欢</view>
|
|
6
|
+
<view class="theme">当前主题: {{ themeText }}</view>
|
|
7
|
+
<count-button class="count" count="{{ count }}" bind:increment="increment" />
|
|
8
|
+
<view class="hint">Logo 可以拖动哦!</view>
|
|
9
|
+
</view>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineComponent, useContext, useState } from 'rezor';
|
|
2
|
+
import { ThemeContext } from '@/contexts/theme';
|
|
3
|
+
|
|
4
|
+
defineComponent((_, context) => {
|
|
5
|
+
const theme = useContext(ThemeContext);
|
|
6
|
+
const [count, setCount] = useState(0);
|
|
7
|
+
|
|
8
|
+
const themeText = theme === 'light' ? '浅色' : '深色';
|
|
9
|
+
|
|
10
|
+
const increment = () => {
|
|
11
|
+
setCount(count + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const offset = wx.worklet.shared({ x: 0, y: 0 });
|
|
15
|
+
|
|
16
|
+
const pan = (event) => {
|
|
17
|
+
'worklet';
|
|
18
|
+
if (event.state === 0 || event.state === 1) return;
|
|
19
|
+
if (event.state === 2) {
|
|
20
|
+
offset.value = {
|
|
21
|
+
x: offset.value.x + event.deltaX,
|
|
22
|
+
y: offset.value.y + event.deltaY,
|
|
23
|
+
};
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
offset.value = { x: 0, y: 0 };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
context.applyAnimatedStyle('.logo', () => {
|
|
30
|
+
'worklet';
|
|
31
|
+
return { transform: `translate(${offset.value.x}px, ${offset.value.y}px)` };
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return { themeText, count, increment, pan };
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineComponent, useContext, useState } from 'rezor';
|
|
2
|
+
import { ThemeContext } from '@/contexts/theme';
|
|
3
|
+
|
|
4
|
+
defineComponent((_, context) => {
|
|
5
|
+
const theme = useContext(ThemeContext);
|
|
6
|
+
const [count, setCount] = useState(0);
|
|
7
|
+
|
|
8
|
+
const themeText = theme === 'light' ? '浅色' : '深色';
|
|
9
|
+
|
|
10
|
+
const increment = () => {
|
|
11
|
+
setCount(count + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const offset = wx.worklet.shared({ x: 0, y: 0 });
|
|
15
|
+
|
|
16
|
+
const pan = (event) => {
|
|
17
|
+
'worklet';
|
|
18
|
+
if (event.state === 0 || event.state === 1) return;
|
|
19
|
+
if (event.state === 2) {
|
|
20
|
+
offset.value = {
|
|
21
|
+
x: offset.value.x + event.deltaX,
|
|
22
|
+
y: offset.value.y + event.deltaY,
|
|
23
|
+
};
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
offset.value = { x: 0, y: 0 };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
context.applyAnimatedStyle('.logo', () => {
|
|
30
|
+
'worklet';
|
|
31
|
+
return { transform: `translate(${offset.value.x}px, ${offset.value.y}px)` };
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return { themeText, count, increment, pan };
|
|
35
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineComponent, useContext, useState } from 'rezor';
|
|
2
|
+
import { ThemeContext } from '@/contexts/theme';
|
|
3
|
+
|
|
4
|
+
defineComponent((_, context) => {
|
|
5
|
+
const theme = useContext(ThemeContext);
|
|
6
|
+
const [count, setCount] = useState(0);
|
|
7
|
+
|
|
8
|
+
const themeText = theme === 'light' ? '浅色' : '深色';
|
|
9
|
+
|
|
10
|
+
const increment = () => {
|
|
11
|
+
setCount(count + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const offset = wx.worklet.shared({ x: 0, y: 0 }) as {
|
|
15
|
+
value: { x: number; y: number };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const pan = (event: { state: number; deltaX: number; deltaY: number }) => {
|
|
19
|
+
'worklet';
|
|
20
|
+
if (event.state === 0 || event.state === 1) return;
|
|
21
|
+
if (event.state === 2) {
|
|
22
|
+
offset.value = {
|
|
23
|
+
x: offset.value.x + event.deltaX,
|
|
24
|
+
y: offset.value.y + event.deltaY,
|
|
25
|
+
};
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
offset.value = { x: 0, y: 0 };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
context.applyAnimatedStyle('.logo', () => {
|
|
32
|
+
'worklet';
|
|
33
|
+
return { transform: `translate(${offset.value.x}px, ${offset.value.y}px)` };
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return { themeText, count, increment, pan };
|
|
37
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineComponent, useContext, useState } from 'rezor';
|
|
2
|
+
import { ThemeContext } from '@/contexts/theme';
|
|
3
|
+
|
|
4
|
+
defineComponent((_, context) => {
|
|
5
|
+
const theme = useContext(ThemeContext);
|
|
6
|
+
const [count, setCount] = useState(0);
|
|
7
|
+
|
|
8
|
+
const themeText = theme === 'light' ? '浅色' : '深色';
|
|
9
|
+
|
|
10
|
+
const increment = () => {
|
|
11
|
+
setCount(count + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const offset = wx.worklet.shared({ x: 0, y: 0 }) as {
|
|
15
|
+
value: { x: number; y: number };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const pan = (event: { state: number; deltaX: number; deltaY: number }) => {
|
|
19
|
+
'worklet';
|
|
20
|
+
if (event.state === 0 || event.state === 1) return;
|
|
21
|
+
if (event.state === 2) {
|
|
22
|
+
offset.value = {
|
|
23
|
+
x: offset.value.x + event.deltaX,
|
|
24
|
+
y: offset.value.y + event.deltaY,
|
|
25
|
+
};
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
offset.value = { x: 0, y: 0 };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
context.applyAnimatedStyle('.logo', () => {
|
|
32
|
+
'worklet';
|
|
33
|
+
return { transform: `translate(${offset.value.x}px, ${offset.value.y}px)` };
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return { themeText, count, increment, pan };
|
|
37
|
+
});
|
|
@@ -20,9 +20,11 @@ const config = {
|
|
|
20
20
|
mutableTemplateObject: true,
|
|
21
21
|
noClassCalls: true,
|
|
22
22
|
noDocumentAll: true,
|
|
23
|
+
noIncompleteNsImportDetection: true,
|
|
23
24
|
noNewArrows: true,
|
|
25
|
+
noUninitializedPrivateFieldAccess: true,
|
|
24
26
|
objectRestNoSymbols: true,
|
|
25
|
-
|
|
27
|
+
privateFieldsAsSymbols: true,
|
|
26
28
|
pureGetters: true,
|
|
27
29
|
setClassMethods: true,
|
|
28
30
|
setComputedProperties: true,
|
|
@@ -35,7 +37,6 @@ const config = {
|
|
|
35
37
|
[
|
|
36
38
|
'@babel/preset-env',
|
|
37
39
|
{
|
|
38
|
-
bugfixes: true,
|
|
39
40
|
modules: 'commonjs',
|
|
40
41
|
},
|
|
41
42
|
],
|
|
@@ -48,7 +49,7 @@ const config = {
|
|
|
48
49
|
version: runtimeVersion,
|
|
49
50
|
},
|
|
50
51
|
],
|
|
51
|
-
'
|
|
52
|
+
'inline-env-var',
|
|
52
53
|
[
|
|
53
54
|
'module-resolver',
|
|
54
55
|
{
|
|
@@ -7,9 +7,9 @@ import path from 'node:path';
|
|
|
7
7
|
import process from 'node:process';
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import chokidar from 'chokidar';
|
|
10
|
-
import
|
|
10
|
+
import { transformFileAsync } from '@babel/core';
|
|
11
11
|
import traverse from '@babel/traverse';
|
|
12
|
-
import
|
|
12
|
+
import { isStringLiteral } from '@babel/types';
|
|
13
13
|
import { minify } from 'terser';
|
|
14
14
|
import postcss from 'postcss';
|
|
15
15
|
import postcssrc from 'postcss-load-config';
|
|
@@ -89,11 +89,11 @@ async function bundleModule(module, pkg) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function traverseAST(ast, pkg, babelOnly = false) {
|
|
92
|
-
traverse
|
|
92
|
+
traverse(ast, {
|
|
93
93
|
CallExpression({ node }) {
|
|
94
94
|
if (
|
|
95
95
|
node.callee.name !== 'require' ||
|
|
96
|
-
!
|
|
96
|
+
!isStringLiteral(node.arguments[0]) ||
|
|
97
97
|
node.arguments[0].value.startsWith('.') ||
|
|
98
98
|
(babelOnly && !node.arguments[0].value.startsWith('@babel/runtime'))
|
|
99
99
|
) {
|
|
@@ -156,7 +156,7 @@ async function buildComponentLibrary(name) {
|
|
|
156
156
|
return new Promise((resolve) => {
|
|
157
157
|
const jobs = [];
|
|
158
158
|
const tnm = async (filePath) => {
|
|
159
|
-
const result = await
|
|
159
|
+
const result = await transformFileAsync(filePath, { ast: true });
|
|
160
160
|
traverseAST(result.ast, 'src', true);
|
|
161
161
|
const code = __PROD__
|
|
162
162
|
? (await minify(result.code, terserOptions)).code
|
|
@@ -201,7 +201,7 @@ async function scanDependencies() {
|
|
|
201
201
|
async function processScript(filePath) {
|
|
202
202
|
let ast, code;
|
|
203
203
|
try {
|
|
204
|
-
const result = await
|
|
204
|
+
const result = await transformFileAsync(path.resolve(filePath), {
|
|
205
205
|
ast: true,
|
|
206
206
|
});
|
|
207
207
|
ast = result.ast;
|
package/template/base/_npmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
registry=https://registry.npmmirror.com/
|