@stdex/create 0.0.0-stage → 1.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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -2
  3. package/README_EN.md +67 -0
  4. package/package.json +40 -3
  5. package/src/eslint.config.js +2 -0
  6. package/src/index.js +233 -0
  7. package/templates/base/eslint.config.js +2 -0
  8. package/templates/base/index.js +3 -0
  9. package/templates/base/package.json +16 -0
  10. package/templates/miniprogram/README.md +27 -0
  11. package/templates/miniprogram/_gitignore +3 -0
  12. package/templates/miniprogram/eslint.config.cjs +25 -0
  13. package/templates/miniprogram/gulpfile.js +81 -0
  14. package/templates/miniprogram/package.json +22 -0
  15. package/templates/miniprogram/project.config.json +31 -0
  16. package/templates/miniprogram/project.private.config.json +8 -0
  17. package/templates/miniprogram/src/app.json +16 -0
  18. package/templates/miniprogram/src/app.scss +0 -0
  19. package/templates/miniprogram/src/app.ts +6 -0
  20. package/templates/miniprogram/src/lib/app-data.ts +46 -0
  21. package/templates/miniprogram/src/pages/index/index.json +3 -0
  22. package/templates/miniprogram/src/pages/index/index.scss +11 -0
  23. package/templates/miniprogram/src/pages/index/index.ts +13 -0
  24. package/templates/miniprogram/src/pages/index/index.wxml +1 -0
  25. package/templates/miniprogram/src/sitemap.json +9 -0
  26. package/templates/miniprogram/tsconfig.json +11 -0
  27. package/templates/miniprogram/typings/index.d.ts +5 -0
  28. package/templates/miniprogram/typings/types/index.d.ts +1 -0
  29. package/templates/miniprogram/typings/types/wx/index.d.ts +162 -0
  30. package/templates/miniprogram/typings/types/wx/lib.wx.api.d.ts +32387 -0
  31. package/templates/miniprogram/typings/types/wx/lib.wx.app.d.ts +400 -0
  32. package/templates/miniprogram/typings/types/wx/lib.wx.behavior.d.ts +68 -0
  33. package/templates/miniprogram/typings/types/wx/lib.wx.canvas.d.ts +2623 -0
  34. package/templates/miniprogram/typings/types/wx/lib.wx.cloud.d.ts +1016 -0
  35. package/templates/miniprogram/typings/types/wx/lib.wx.component.d.ts +700 -0
  36. package/templates/miniprogram/typings/types/wx/lib.wx.event.d.ts +1436 -0
  37. package/templates/miniprogram/typings/types/wx/lib.wx.page.d.ts +272 -0
  38. package/templates/miniprogram/typings/types/wx/lib.wx.phys3D.d.ts +409 -0
  39. package/templates/miniprogram/typings/types/wx/lib.wx.wasm.d.ts +152 -0
  40. package/templates/miniprogram/typings/types/wx/lib.wx.xr-frame.d.ts +15631 -0
  41. package/templates/miniprogram/variables.json +11 -0
  42. package/templates/service/README.md +64 -0
  43. package/templates/service/_env +1 -0
  44. package/templates/service/_gitignore +5 -0
  45. package/templates/service/eslint.config.js +2 -0
  46. package/templates/service/package.json +48 -0
  47. package/templates/service/prisma/schema.prisma +40 -0
  48. package/templates/service/prisma/sql/demoTypedSql.sql +1 -0
  49. package/templates/service/prisma.config.ts +12 -0
  50. package/templates/service/setup.js +4 -0
  51. package/templates/service/src/cache.ts +28 -0
  52. package/templates/service/src/config.ts +49 -0
  53. package/templates/service/src/controllers/common.ts +43 -0
  54. package/templates/service/src/controllers/demo-school.ts +7 -0
  55. package/templates/service/src/controllers/demo-student.ts +7 -0
  56. package/templates/service/src/controllers/index.ts +15 -0
  57. package/templates/service/src/database.ts +52 -0
  58. package/templates/service/src/index.ts +15 -0
  59. package/templates/service/src/logger.ts +10 -0
  60. package/templates/service/src/routes/demo-school.ts +9 -0
  61. package/templates/service/src/routes/index.ts +3 -0
  62. package/templates/service/src/routes/router.ts +42 -0
  63. package/templates/service/src/tasks/common.ts +25 -0
  64. package/templates/service/src/tasks/demo-school.ts +10 -0
  65. package/templates/service/src/tasks/index.ts +1 -0
  66. package/templates/service/tsconfig.build.json +9 -0
  67. package/templates/service/tsconfig.json +10 -0
  68. package/templates/site/_gitignore +3 -0
  69. package/templates/site/_pnpm-workspace.yaml +4 -0
  70. package/templates/site/eslint.config.js +19 -0
  71. package/templates/site/package.json +41 -0
  72. package/templates/site/public/favicon.png +0 -0
  73. package/templates/site/src/app/header.tsx +31 -0
  74. package/templates/site/src/app/index.tsx +38 -0
  75. package/templates/site/src/app/layout.tsx +63 -0
  76. package/templates/site/src/app/menu.tsx +115 -0
  77. package/templates/site/src/app/router.tsx +50 -0
  78. package/templates/site/src/app/style.css +9 -0
  79. package/templates/site/src/assets/logo.png +0 -0
  80. package/templates/site/src/components/Breadcrumb.tsx +47 -0
  81. package/templates/site/src/components/DevStatus.tsx +14 -0
  82. package/templates/site/src/index.html +13 -0
  83. package/templates/site/src/index.tsx +5 -0
  84. package/templates/site/src/lib/config.ts +6 -0
  85. package/templates/site/src/lib/init-dayjs.ts +8 -0
  86. package/templates/site/src/lib/logging.ts +5 -0
  87. package/templates/site/src/views/dashboard.tsx +7 -0
  88. package/templates/site/src/views/school-detail.tsx +13 -0
  89. package/templates/site/src/views/school-ranking.tsx +7 -0
  90. package/templates/site/src/views/schools.tsx +43 -0
  91. package/templates/site/src/views/setting.tsx +7 -0
  92. package/templates/site/src/views/student-score.tsx +7 -0
  93. package/templates/site/src/views/students.tsx +7 -0
  94. package/templates/site/tsconfig.json +10 -0
  95. package/templates/site/vite.config.js +60 -0
@@ -0,0 +1,16 @@
1
+ {
2
+ "pages": ["pages/index/index"],
3
+ "window": {},
4
+ "style": "v2",
5
+ "renderer": "skyline",
6
+ "rendererOptions": {
7
+ "skyline": {
8
+ "disableABTest": true,
9
+ "sdkVersionBegin": "3.0.0",
10
+ "sdkVersionEnd": "15.255.255"
11
+ }
12
+ },
13
+ "componentFramework": "glass-easel",
14
+ "sitemapLocation": "sitemap.json",
15
+ "lazyCodeLoading": "requiredComponents"
16
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ import { type AppData, loadAppData } from '@/lib/app-data'
2
+
3
+ App<IAppOption<AppData>>({
4
+ globalData: loadAppData(),
5
+ onLaunch() {},
6
+ })
@@ -0,0 +1,46 @@
1
+ export interface AppData {
2
+ count: number
3
+ }
4
+
5
+ const initialAppData: AppData = {
6
+ count: 0,
7
+ }
8
+
9
+ // -------------------------------
10
+
11
+ const dataKey = 'app-data-v1'
12
+
13
+ export function loadAppData() {
14
+ return wx.getStorageSync<AppData | ''>(dataKey) || initialAppData
15
+ }
16
+
17
+ export function getAppData() {
18
+ return getApp().globalData as AppData
19
+ }
20
+
21
+ function setAppData(data: AppData): void
22
+ function setAppData(callback: (appData: AppData) => AppData): void // eslint-disable-line @typescript-eslint/unified-signatures
23
+ function setAppData(callback: (appData: AppData) => void): void // eslint-disable-line @typescript-eslint/unified-signatures
24
+ function setAppData(
25
+ dataOrCallback: AppData | ((appData: AppData) => AppData) | ((appData: AppData) => void),
26
+ ) {
27
+ let data: AppData
28
+ if (typeof dataOrCallback === 'function') {
29
+ const origData = getAppData()
30
+ const result = dataOrCallback(origData)
31
+ if (typeof result === 'object') data = result
32
+ else data = origData
33
+ } else {
34
+ data = dataOrCallback
35
+ }
36
+
37
+ getApp().globalData = data
38
+ wx.setStorage({
39
+ key: dataKey,
40
+ data,
41
+ fail(e) {
42
+ console.log('保存 appData 失败', e)
43
+ },
44
+ })
45
+ }
46
+ export { setAppData }
@@ -0,0 +1,3 @@
1
+ {
2
+ "usingComponents": {}
3
+ }
@@ -0,0 +1,11 @@
1
+ page {
2
+ align-items: center;
3
+ justify-content: center;
4
+ }
5
+
6
+ .count {
7
+ background-color: #fcfcfc;
8
+ border-radius: 12rpx;
9
+ border: 1px solid #f0f0f0;
10
+ padding: 100rpx 50rpx;
11
+ }
@@ -0,0 +1,13 @@
1
+ import { getAppData, setAppData } from '@/lib/app-data'
2
+
3
+ Page({
4
+ data: {
5
+ count: getAppData().count,
6
+ },
7
+
8
+ click() {
9
+ const count = this.data.count + 1
10
+ this.setData({ count })
11
+ setAppData(current => ({ ...current, count }))
12
+ },
13
+ })
@@ -0,0 +1 @@
1
+ <view class="count" bind:tap="click">当前计数:{{count}}</view>
@@ -0,0 +1,9 @@
1
+ {
2
+ "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3
+ "rules": [
4
+ {
5
+ "action": "allow",
6
+ "page": "*"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,11 @@
1
+ // 以下配置仅用于开发时的类型检查,编译时走的是 swc 配置
2
+ {
3
+ "extends": "./node_modules/@stdex/presets-typescript/tsconfig-base",
4
+ "compilerOptions": {
5
+ "types": ["./typings"],
6
+ "paths": {
7
+ "@/*": ["./src/*"]
8
+ },
9
+ "outDir": "./dist" // 用于 tsc-alias
10
+ }
11
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference path="./types/index.d.ts" />
2
+
3
+ interface IAppOption<Data> {
4
+ globalData: Data
5
+ }
@@ -0,0 +1 @@
1
+ /// <reference path="./wx/index.d.ts" />
@@ -0,0 +1,162 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) 2023 Tencent, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ ***************************************************************************** */
22
+
23
+ /// <reference path="./lib.wx.app.d.ts" />
24
+ /// <reference path="./lib.wx.page.d.ts" />
25
+ /// <reference path="./lib.wx.api.d.ts" />
26
+ /// <reference path="./lib.wx.cloud.d.ts" />
27
+ /// <reference path="./lib.wx.canvas.d.ts" />
28
+ /// <reference path="./lib.wx.component.d.ts" />
29
+ /// <reference path="./lib.wx.behavior.d.ts" />
30
+ /// <reference path="./lib.wx.event.d.ts" />
31
+ /// <reference path="./lib.wx.wasm.d.ts" />
32
+
33
+ declare namespace WechatMiniprogram {
34
+ type IAnyObject = Record<string, any>
35
+ type Optional<F> = F extends (arg: infer P) => infer R ? (arg?: P) => R : F
36
+ type OptionalInterface<T> = { [K in keyof T]: Optional<T[K]> }
37
+ interface AsyncMethodOptionLike {
38
+ success?: (...args: any[]) => void
39
+ }
40
+ type PromisifySuccessResult<P, T extends AsyncMethodOptionLike> = P extends {
41
+ success: any
42
+ }
43
+ ? void
44
+ : P extends { fail: any }
45
+ ? void
46
+ : P extends { complete: any }
47
+ ? void
48
+ : Promise<Parameters<Exclude<T['success'], undefined>>[0]>
49
+
50
+ // TODO: Extract real definition from `lib.dom.d.ts` to replace this
51
+ type IIRFilterNode = any
52
+ type WaveShaperNode = any
53
+ type ConstantSourceNode = any
54
+ type OscillatorNode = any
55
+ type GainNode = any
56
+ type BiquadFilterNode = any
57
+ type PeriodicWaveNode = any
58
+ type AudioNode = any
59
+ type ChannelSplitterNode = any
60
+ type ChannelMergerNode = any
61
+ type DelayNode = any
62
+ type DynamicsCompressorNode = any
63
+ type ScriptProcessorNode = any
64
+ type PannerNode = any
65
+ type AnalyserNode = any
66
+ type AudioListener = any
67
+ type WebGLTexture = any
68
+ type WebGLRenderingContext = any
69
+
70
+ // TODO: fill worklet type
71
+ type WorkletFunction = (...args: any) => any
72
+ type AnimationObject = any
73
+ type SharedValue<T = any> = T
74
+ type DerivedValue<T = any> = T
75
+ }
76
+
77
+ // === Fix: 与 TypeScript 自带的类型冲突
78
+ // declare let console: WechatMiniprogram.Console
79
+
80
+ declare let wx: WechatMiniprogram.Wx
81
+ /** 引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */
82
+ interface Require {
83
+ (
84
+ /** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
85
+ module: string,
86
+ /** 用于异步获取其他分包中的模块的引用结果,详见 [分包异步化]((subpackages/async)) */
87
+ callback?: (moduleExport: any) => void,
88
+ /** 异步获取分包失败时的回调,详见 [分包异步化]((subpackages/async)) */
89
+ errorCallback?: (err: any) => void,
90
+ ): any
91
+ /** 以 Promise 形式异步引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */
92
+ async(
93
+ /** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
94
+ module: string,
95
+ ): Promise<any>
96
+ }
97
+ declare const require: Require
98
+ /** 引入插件。返回插件通过 `main` 暴露的接口。 */
99
+ interface RequirePlugin {
100
+ (
101
+ /** 需要引入的插件的 alias */
102
+ module: string,
103
+ /** 用于异步获取其他分包中的插件的引用结果,详见 [分包异步化]((subpackages/async)) */
104
+ callback?: (pluginExport: any) => void,
105
+ ): any
106
+ /** 以 Promise 形式异步引入插件。返回插件通过 `main` 暴露的接口。 */
107
+ async(
108
+ /** 需要引入的插件的 alias */
109
+ module: string,
110
+ ): Promise<any>
111
+ }
112
+ declare const requirePlugin: RequirePlugin
113
+ /** 插件引入当前使用者小程序。返回使用者小程序通过 [插件配置中 `export` 暴露的接口](https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using.html#%E5%AF%BC%E5%87%BA%E5%88%B0%E6%8F%92%E4%BB%B6)。
114
+ *
115
+ * 该接口只在插件中存在
116
+ *
117
+ * 最低基础库: `2.11.1` */
118
+ declare function requireMiniProgram(): any
119
+ /** 当前模块对象 */
120
+ declare let module: {
121
+ /** 模块向外暴露的对象,使用 `require` 引用该模块时可以获取 */
122
+ exports: any
123
+ }
124
+ /** `module.exports` 的引用 */
125
+ declare let exports: any
126
+
127
+ /** [clearInterval(number intervalID)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/clearInterval.html)
128
+ *
129
+ * 取消由 setInterval 设置的定时器。 */
130
+ declare function clearInterval(
131
+ /** 要取消的定时器的 ID */
132
+ intervalID: number,
133
+ ): void
134
+ /** [clearTimeout(number timeoutID)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/clearTimeout.html)
135
+ *
136
+ * 取消由 setTimeout 设置的定时器。 */
137
+ declare function clearTimeout(
138
+ /** 要取消的定时器的 ID */
139
+ timeoutID: number,
140
+ ): void
141
+ /** [number setInterval(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setInterval.html)
142
+ *
143
+ * 设定一个定时器。按照指定的周期(以毫秒计)来执行注册的回调函数 */
144
+ declare function setInterval(
145
+ /** 回调函数 */
146
+ callback: (...args: any[]) => any,
147
+ /** 执行回调函数之间的时间间隔,单位 ms。 */
148
+ delay?: number,
149
+ /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
150
+ rest?: any,
151
+ ): number
152
+ /** [number setTimeout(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setTimeout.html)
153
+ *
154
+ * 设定一个定时器。在定时到期以后执行注册的回调函数 */
155
+ declare function setTimeout(
156
+ /** 回调函数 */
157
+ callback: (...args: any[]) => any,
158
+ /** 延迟的时间,函数的调用会在该延迟之后发生,单位 ms。 */
159
+ delay?: number,
160
+ /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
161
+ rest?: any,
162
+ ): number