@cloudbase/cals 0.4.11-alpha.4 → 0.4.11-alpha.6
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const wedaDTS = "declare namespace $app {\n namespace dataset {\n\n const state: {\n // Global State \u5168\u5C40\u53D8\u91CF - Don't touch me\n }\n }\n\n namespace utils {\n function ABS(num: number): number;\n function Min(...args: number[]): number;\n function Max(...args: number[]): number;\n function Average(...args: number[]): number;\n function Floor(num: number): number;\n function Ceiling(num: number): number;\n function Round(num: number): number;\n function Sum(...args: number[]): number;\n function Rand(num: number): number;\n\n function If(condition: boolean, val1: any, val2: any): any;\n function IsEmpty(text: string | string[]): boolean;\n function NotNull(val: any): boolean;\n function And(...args: boolean[]): boolean;\n function Or(...args: boolean[]): boolean;\n\n function Len(text: string): number;\n function Contains(text1: string, text2: string): boolean;\n function Split(text1: string, text2: string): string[];\n function Trim(text: string): string;\n function Upper(text: string): string;\n function Lower(text: string): string;\n function Concat(...text: string[]): string;\n\n function Now(): number;\n function Timestamp(arg: number | string | Date): number;\n function Second(arg: number | string | Date): number;\n function Minute(arg: number | string | Date): number;\n function Hour(arg: number | string | Date): number;\n function Day(arg: number | string | Date): number;\n function DayOfWeek(arg: number | string | Date): number;\n function Month(arg: number | string | Date): number;\n function Year(arg: number | string | Date): number;\n function GetDate(year: number, month: number, day: number): number;\n function DateTimeValue(arg: string, val: string): number;\n function Age(arg: number | string | Date, val: number | string | Date): number;\n function AgeOfNow(arg: number | string | Date): number;\n function DateAdd(arg: number | string | Date, day: number): number;\n function MonthAdd(arg: number | string | Date, month: number): number;\n function YearAdd(arg: number | string | Date, year: number): number;\n function DateDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function HourDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function MinuteDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function SecondDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function MonthDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function YearDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function DateText(createdTime: number | string | Date, text: string): string;\n function IsToday(date: number | string | Date): boolean;\n\n }\n\n namespace common {\n // Global Common \u5168\u5C40\u65B9\u6CD5 - Don't touch me\n }\n\n \n\ninterface navigatorOptions {\n packageName: string;\n pageId: string;\n data?: Record<string, any>;\n params?: Record<string, any>;\n events?: Record<string, (data: any) => void>;\n success(res: any);\n fail(res: any);\n complete(res: any);\n}\n\ninterface navigateBackOptions {\n delta: number;\n}\n\n// \u8BBE\u7F6E\u72B6\u6001\nfunction setState(userSetState: Record<string, any>): void\n\n// \u7279\u5236\u8DEF\u7531\nfunction navigateTo(options: navigatorOptions)\nfunction redirectTo(options: navigatorOptions)\nfunction reLaunch(options: navigatorOptions)\nfunction navigateBack(options: navigateBackOptions)\n\n// \u663E\u793A\u63D0\u793A\nfunction showToast(options);\n\n// \u663E\u793A\u6A21\u6001\u63D0\u793A\nfunction showModal(options);\n\n// \u663E\u793A loading \u63D0\u793A\nfunction showLoading(options);\n\n// \u9690\u85CF loading \u63D0\u793A\nfunction hideLoading(options);\n\n// \u9690\u85CF\u63D0\u793A\nfunction hideToast(options);\n\n// sacnCode\nfunction scanCode(options: {\n onlyFromCamera?: boolean;\n enableDefaultBehavior?: boolean;\n scanType?: ('barCode' | 'qrCode')[];\n success?: (res: { result: string; scanType: string }) => void;\n fail?: (err: Error) => void;\n complete?: () => void;\n}): Promise<ScanCodeResult> | ScanCodeResult;\n\n\n}\n\ndeclare const app = $app\n\n// Global For Begin\ndeclare const $for: {\n // For \u5FAA\u73AF\u53D8\u91CF - Don't touch me\n}\ndeclare const forItems = $for\n// Global For End\n\ndeclare namespace $page {\n namespace dataset {\n\n const state: {\n // Page State \u9875\u9762\u53D8\u91CF - Don't touch me\n }\n\n const params: {\n // Page Param \u9875\u9762\u53C2\u6570 - Don't touch me\n }\n }\n\n namespace handler {\n // Page Handler \u9875\u9762\u65B9\u6CD5 - Don't touch me\n }\n\n \n\n// \u8BBE\u7F6E\u72B6\u6001\nfunction setState(userSetState: Record<string, any>): void\n\n\n}\n\ndeclare namespace $comp {\n\n namespace props {\n const data: {\n // Comp Prop Data \u7EC4\u4EF6\u5C5E\u6027 - Don't touch me\n }\n\n namespace events {\n // Comp Prop Events \u7EC4\u4EF6\u4E8B\u4EF6 - Don't touch me\n }\n }\n\n namespace dataset {\n\n const state: {\n // Comp State \u7EC4\u4EF6\u53D8\u91CF - Don't touch me\n }\n }\n\n namespace handler {\n // Comp Handler \u7EC4\u4EF6\u65B9\u6CD5 - Don't touch me\n }\n}\n\n// Global Formula Begin\n\ndeclare function ABS(num: number): number;\ndeclare function Min(...args: number[]): number;\ndeclare function Max(...args: number[]): number;\ndeclare function Average(...args: number[]): number;\ndeclare function Floor(num: number): number;\ndeclare function Ceiling(num: number): number;\ndeclare function Round(num: number): number;\ndeclare function Sum(...args: number[]): number;\ndeclare function Rand(num: number): number;\n\ndeclare function If(condition: boolean, val1: any, val2: any): any;\ndeclare function IsEmpty(text: string | string[]): boolean;\ndeclare function NotNull(val: any): boolean;\ndeclare function And(...args: boolean[]): boolean;\ndeclare function Or(...args: boolean[]): boolean;\n\ndeclare function Len(text: string): number;\ndeclare function Contains(text1: string, text2: string): boolean;\ndeclare function Split(text1: string, text2: string): string[];\ndeclare function Trim(text: string): string;\ndeclare function Upper(text: string): string;\ndeclare function Lower(text: string): string;\ndeclare function Concat(...text: string[]): string;\n\ndeclare function Now(): number;\ndeclare function Timestamp(arg: number | string | Date): number;\ndeclare function Second(arg: number | string | Date): number;\ndeclare function Minute(arg: number | string | Date): number;\ndeclare function Hour(arg: number | string | Date): number;\ndeclare function Day(arg: number | string | Date): number;\ndeclare function DayOfWeek(arg: number | string | Date): number;\ndeclare function Month(arg: number | string | Date): number;\ndeclare function Year(arg: number | string | Date): number;\ndeclare function GetDate(year: number, month: number, day: number): number;\ndeclare function DateTimeValue(arg: string, val: string): number;\ndeclare function Age(arg: number | string | Date, val: number | string | Date): number;\ndeclare function AgeOfNow(arg: number | string | Date): number;\ndeclare function DateAdd(arg: number | string | Date, day: number): number;\ndeclare function MonthAdd(arg: number | string | Date, month: number): number;\ndeclare function YearAdd(arg: number | string | Date, year: number): number;\ndeclare function DateDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function HourDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function MinuteDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function SecondDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function MonthDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function YearDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function DateText(createdTime: number | string | Date, text: string): string;\ndeclare function IsToday(date: number | string | Date): boolean;\n\n\n// Global Formula End\n";
|
|
1
|
+
export declare const wedaDTS = "declare namespace $app {\n namespace dataset {\n\n const state: {\n // Global State Inner Begin\n // Global State \u5168\u5C40\u53D8\u91CF - Don't touch me\n // Global State Inner End\n }\n\n }\n\n namespace utils {\n function ABS(num: number): number;\n function Min(...args: number[]): number;\n function Max(...args: number[]): number;\n function Average(...args: number[]): number;\n function Floor(num: number): number;\n function Ceiling(num: number): number;\n function Round(num: number): number;\n function Sum(...args: number[]): number;\n function Rand(num: number): number;\n\n function If(condition: boolean, val1: any, val2: any): any;\n function IsEmpty(text: string | string[]): boolean;\n function NotNull(val: any): boolean;\n function And(...args: boolean[]): boolean;\n function Or(...args: boolean[]): boolean;\n\n function Len(text: string): number;\n function Contains(text1: string, text2: string): boolean;\n function Split(text1: string, text2: string): string[];\n function Trim(text: string): string;\n function Upper(text: string): string;\n function Lower(text: string): string;\n function Concat(...text: string[]): string;\n\n function Now(): number;\n function Timestamp(arg: number | string | Date): number;\n function Second(arg: number | string | Date): number;\n function Minute(arg: number | string | Date): number;\n function Hour(arg: number | string | Date): number;\n function Day(arg: number | string | Date): number;\n function DayOfWeek(arg: number | string | Date): number;\n function Month(arg: number | string | Date): number;\n function Year(arg: number | string | Date): number;\n function GetDate(year: number, month: number, day: number): number;\n function DateTimeValue(arg: string, val: string): number;\n function Age(arg: number | string | Date, val: number | string | Date): number;\n function AgeOfNow(arg: number | string | Date): number;\n function DateAdd(arg: number | string | Date, day: number): number;\n function MonthAdd(arg: number | string | Date, month: number): number;\n function YearAdd(arg: number | string | Date, year: number): number;\n function DateDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function HourDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function MinuteDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function SecondDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function MonthDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function YearDiff(startDay: number | string | Date, endDay: number | string | Date): number;\n function DateText(createdTime: number | string | Date, text: string): string;\n function IsToday(date: number | string | Date): boolean;\n\n }\n\n namespace common {\n // Global Common Inner Begin\n // Global Common \u5168\u5C40\u65B9\u6CD5 - Don't touch me\n // Global Common Inner End\n }\n\n \n\ninterface navigatorOptions {\n packageName: string;\n pageId: string;\n data?: Record<string, any>;\n params?: Record<string, any>;\n events?: Record<string, (data: any) => void>;\n success(res: any);\n fail(res: any);\n complete(res: any);\n}\n\ninterface navigateBackOptions {\n delta: number;\n}\n\n// \u8BBE\u7F6E\u72B6\u6001\nfunction setState(userSetState: Record<string, any>): void\n\n// \u7279\u5236\u8DEF\u7531\nfunction navigateTo(options: navigatorOptions)\nfunction redirectTo(options: navigatorOptions)\nfunction reLaunch(options: navigatorOptions)\nfunction navigateBack(options: navigateBackOptions)\n\n// \u663E\u793A\u63D0\u793A\nfunction showToast(options);\n\n// \u663E\u793A\u6A21\u6001\u63D0\u793A\nfunction showModal(options);\n\n// \u663E\u793A loading \u63D0\u793A\nfunction showLoading(options);\n\n// \u9690\u85CF loading \u63D0\u793A\nfunction hideLoading(options);\n\n// \u9690\u85CF\u63D0\u793A\nfunction hideToast(options);\n\n// sacnCode\nfunction scanCode(options: {\n onlyFromCamera?: boolean;\n enableDefaultBehavior?: boolean;\n scanType?: ('barCode' | 'qrCode')[];\n success?: (res: { result: string; scanType: string }) => void;\n fail?: (err: Error) => void;\n complete?: () => void;\n}): Promise<ScanCodeResult> | ScanCodeResult;\n\n\n}\n\ndeclare const app = $app\n\n// Global For Begin\ndeclare const $for: {\n // Global For Inner Begin\n // For \u5FAA\u73AF\u53D8\u91CF - Don't touch me\n // Global For Inner End\n}\ndeclare const forItems = $for\n// Global For End\n\n// $page Begin\ndeclare namespace $page {\n namespace dataset {\n\n const state: {\n // Page State Inner Begin\n // Page State \u9875\u9762\u53D8\u91CF - Don't touch me\n // Page State Inner End\n }\n\n const params: {\n // Page Param Inner Begin\n // Page Param \u9875\u9762\u53C2\u6570 - Don't touch me\n // Page Param Inner End\n }\n\n }\n\n namespace handler {\n // Page Handler Inner Begin\n // Page Handler \u9875\u9762\u65B9\u6CD5 - Don't touch me\n // Page Handler Inner End\n }\n\n \n\n// \u8BBE\u7F6E\u72B6\u6001\nfunction setState(userSetState: Record<string, any>): void\n\n\n}\n// $page End\n\n// $comp Begin\ndeclare namespace $comp {\n\n namespace props {\n\n const data: {\n // Comp Prop Data Inner Begin\n // Comp Prop Data \u7EC4\u4EF6\u5C5E\u6027 - Don't touch me\n // Comp Prop Data Inner End\n }\n\n namespace events {\n // Comp Prop Events Inner Begin\n // Comp Prop Events \u7EC4\u4EF6\u4E8B\u4EF6 - Don't touch me\n // Comp Prop Events Inner End\n }\n\n }\n\n namespace dataset {\n\n const state: {\n // Comp State Inner Begin\n // Comp State \u7EC4\u4EF6\u53D8\u91CF - Don't touch me\n // Comp State Inner End\n }\n\n }\n\n namespace handler {\n // Comp Handler Inner Begin\n // Comp Handler \u7EC4\u4EF6\u65B9\u6CD5 - Don't touch me\n // Comp Handler Inner End\n }\n\n}\n// $comp End\n\n// Global Formula Begin\n\ndeclare function ABS(num: number): number;\ndeclare function Min(...args: number[]): number;\ndeclare function Max(...args: number[]): number;\ndeclare function Average(...args: number[]): number;\ndeclare function Floor(num: number): number;\ndeclare function Ceiling(num: number): number;\ndeclare function Round(num: number): number;\ndeclare function Sum(...args: number[]): number;\ndeclare function Rand(num: number): number;\n\ndeclare function If(condition: boolean, val1: any, val2: any): any;\ndeclare function IsEmpty(text: string | string[]): boolean;\ndeclare function NotNull(val: any): boolean;\ndeclare function And(...args: boolean[]): boolean;\ndeclare function Or(...args: boolean[]): boolean;\n\ndeclare function Len(text: string): number;\ndeclare function Contains(text1: string, text2: string): boolean;\ndeclare function Split(text1: string, text2: string): string[];\ndeclare function Trim(text: string): string;\ndeclare function Upper(text: string): string;\ndeclare function Lower(text: string): string;\ndeclare function Concat(...text: string[]): string;\n\ndeclare function Now(): number;\ndeclare function Timestamp(arg: number | string | Date): number;\ndeclare function Second(arg: number | string | Date): number;\ndeclare function Minute(arg: number | string | Date): number;\ndeclare function Hour(arg: number | string | Date): number;\ndeclare function Day(arg: number | string | Date): number;\ndeclare function DayOfWeek(arg: number | string | Date): number;\ndeclare function Month(arg: number | string | Date): number;\ndeclare function Year(arg: number | string | Date): number;\ndeclare function GetDate(year: number, month: number, day: number): number;\ndeclare function DateTimeValue(arg: string, val: string): number;\ndeclare function Age(arg: number | string | Date, val: number | string | Date): number;\ndeclare function AgeOfNow(arg: number | string | Date): number;\ndeclare function DateAdd(arg: number | string | Date, day: number): number;\ndeclare function MonthAdd(arg: number | string | Date, month: number): number;\ndeclare function YearAdd(arg: number | string | Date, year: number): number;\ndeclare function DateDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function HourDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function MinuteDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function SecondDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function MonthDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function YearDiff(startDay: number | string | Date, endDay: number | string | Date): number;\ndeclare function DateText(createdTime: number | string | Date, text: string): string;\ndeclare function IsToday(date: number | string | Date): boolean;\n\n\n// Global Formula End\n";
|
|
2
2
|
//# sourceMappingURL=auto-generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-generated.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/auto-generated.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"auto-generated.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/auto-generated.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,gyRAkQnB,CAAA"}
|
|
@@ -5,8 +5,11 @@ exports.wedaDTS = `declare namespace $app {
|
|
|
5
5
|
namespace dataset {
|
|
6
6
|
|
|
7
7
|
const state: {
|
|
8
|
+
// Global State Inner Begin
|
|
8
9
|
// Global State 全局变量 - Don't touch me
|
|
10
|
+
// Global State Inner End
|
|
9
11
|
}
|
|
12
|
+
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
namespace utils {
|
|
@@ -62,7 +65,9 @@ exports.wedaDTS = `declare namespace $app {
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
namespace common {
|
|
68
|
+
// Global Common Inner Begin
|
|
65
69
|
// Global Common 全局方法 - Don't touch me
|
|
70
|
+
// Global Common Inner End
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
|
|
@@ -123,25 +128,35 @@ declare const app = $app
|
|
|
123
128
|
|
|
124
129
|
// Global For Begin
|
|
125
130
|
declare const $for: {
|
|
131
|
+
// Global For Inner Begin
|
|
126
132
|
// For 循环变量 - Don't touch me
|
|
133
|
+
// Global For Inner End
|
|
127
134
|
}
|
|
128
135
|
declare const forItems = $for
|
|
129
136
|
// Global For End
|
|
130
137
|
|
|
138
|
+
// $page Begin
|
|
131
139
|
declare namespace $page {
|
|
132
140
|
namespace dataset {
|
|
133
141
|
|
|
134
142
|
const state: {
|
|
143
|
+
// Page State Inner Begin
|
|
135
144
|
// Page State 页面变量 - Don't touch me
|
|
145
|
+
// Page State Inner End
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
const params: {
|
|
149
|
+
// Page Param Inner Begin
|
|
139
150
|
// Page Param 页面参数 - Don't touch me
|
|
151
|
+
// Page Param Inner End
|
|
140
152
|
}
|
|
153
|
+
|
|
141
154
|
}
|
|
142
155
|
|
|
143
156
|
namespace handler {
|
|
157
|
+
// Page Handler Inner Begin
|
|
144
158
|
// Page Handler 页面方法 - Don't touch me
|
|
159
|
+
// Page Handler Inner End
|
|
145
160
|
}
|
|
146
161
|
|
|
147
162
|
|
|
@@ -151,30 +166,45 @@ function setState(userSetState: Record<string, any>): void
|
|
|
151
166
|
|
|
152
167
|
|
|
153
168
|
}
|
|
169
|
+
// $page End
|
|
154
170
|
|
|
171
|
+
// $comp Begin
|
|
155
172
|
declare namespace $comp {
|
|
156
173
|
|
|
157
174
|
namespace props {
|
|
175
|
+
|
|
158
176
|
const data: {
|
|
177
|
+
// Comp Prop Data Inner Begin
|
|
159
178
|
// Comp Prop Data 组件属性 - Don't touch me
|
|
179
|
+
// Comp Prop Data Inner End
|
|
160
180
|
}
|
|
161
181
|
|
|
162
182
|
namespace events {
|
|
183
|
+
// Comp Prop Events Inner Begin
|
|
163
184
|
// Comp Prop Events 组件事件 - Don't touch me
|
|
185
|
+
// Comp Prop Events Inner End
|
|
164
186
|
}
|
|
187
|
+
|
|
165
188
|
}
|
|
166
189
|
|
|
167
190
|
namespace dataset {
|
|
168
191
|
|
|
169
192
|
const state: {
|
|
193
|
+
// Comp State Inner Begin
|
|
170
194
|
// Comp State 组件变量 - Don't touch me
|
|
195
|
+
// Comp State Inner End
|
|
171
196
|
}
|
|
197
|
+
|
|
172
198
|
}
|
|
173
199
|
|
|
174
200
|
namespace handler {
|
|
201
|
+
// Comp Handler Inner Begin
|
|
175
202
|
// Comp Handler 组件方法 - Don't touch me
|
|
203
|
+
// Comp Handler Inner End
|
|
176
204
|
}
|
|
205
|
+
|
|
177
206
|
}
|
|
207
|
+
// $comp End
|
|
178
208
|
|
|
179
209
|
// Global Formula Begin
|
|
180
210
|
|
package/lib/utils/dts/index.d.ts
CHANGED
|
@@ -3,30 +3,49 @@ interface ICodeItem {
|
|
|
3
3
|
name: string;
|
|
4
4
|
code: string;
|
|
5
5
|
}
|
|
6
|
-
export interface IInputData {
|
|
7
|
-
globalState?: IJsonSchemaObject;
|
|
8
|
-
pageState?: IJsonSchemaObject;
|
|
9
|
-
compState?: IJsonSchemaObject;
|
|
10
|
-
pageParams?: IJsonSchemaObject;
|
|
11
|
-
forState?: IJsonSchemaObject;
|
|
12
|
-
globalCommonCodes?: ICodeItem[];
|
|
13
|
-
pageHandlerCodes?: ICodeItem[];
|
|
14
|
-
compHandlerCodes?: ICodeItem[];
|
|
15
|
-
compPropData?: IJsonSchemaObject;
|
|
16
|
-
compPropEvents?: string[];
|
|
17
|
-
}
|
|
18
6
|
export interface IOptions {
|
|
19
7
|
isCompMode?: boolean;
|
|
20
8
|
needGlobalFormula?: boolean;
|
|
21
9
|
needGlobalFor?: boolean;
|
|
22
10
|
}
|
|
11
|
+
export declare enum IInputDataType {
|
|
12
|
+
globalState = "globalState",
|
|
13
|
+
pageState = "pageState",
|
|
14
|
+
compState = "compState",
|
|
15
|
+
pageParams = "pageParams",
|
|
16
|
+
forState = "forState",
|
|
17
|
+
globalCommonCodes = "globalCommonCodes",
|
|
18
|
+
pageHandlerCodes = "pageHandlerCodes",
|
|
19
|
+
compHandlerCodes = "compHandlerCodes",
|
|
20
|
+
compPropData = "compPropData",
|
|
21
|
+
compPropEvents = "compPropEvents"
|
|
22
|
+
}
|
|
23
|
+
export interface IInputData {
|
|
24
|
+
[IInputDataType.globalState]?: IJsonSchemaObject;
|
|
25
|
+
[IInputDataType.pageState]?: IJsonSchemaObject;
|
|
26
|
+
[IInputDataType.compState]?: IJsonSchemaObject;
|
|
27
|
+
[IInputDataType.pageParams]?: IJsonSchemaObject;
|
|
28
|
+
[IInputDataType.forState]?: IJsonSchemaObject;
|
|
29
|
+
[IInputDataType.globalCommonCodes]?: ICodeItem[];
|
|
30
|
+
[IInputDataType.pageHandlerCodes]?: ICodeItem[];
|
|
31
|
+
[IInputDataType.compHandlerCodes]?: ICodeItem[];
|
|
32
|
+
[IInputDataType.compPropData]?: IJsonSchemaObject;
|
|
33
|
+
[IInputDataType.compPropEvents]?: string[];
|
|
34
|
+
}
|
|
23
35
|
/**
|
|
24
36
|
* 通过该类可以共享同个dts。
|
|
25
37
|
* 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析
|
|
26
38
|
*/
|
|
27
39
|
export declare class WeDaDTS {
|
|
28
40
|
private static _dts;
|
|
41
|
+
/**
|
|
42
|
+
* 全部更新
|
|
43
|
+
*/
|
|
29
44
|
static updateDTS(inputData?: IInputData, options?: Pick<IOptions, "isCompMode">): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* 部分更新 - 只更新一种类型
|
|
47
|
+
*/
|
|
48
|
+
static updateDTSPartial(inputData: IJsonSchemaObject | ICodeItem[] | string[], itemType: IInputDataType): Promise<void>;
|
|
30
49
|
static getDTS(options?: Omit<IOptions, "isCompMode">): string;
|
|
31
50
|
}
|
|
32
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAK/C,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,QAAQ;IAEvB,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,oBAAY,cAAc;IACxB,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;CAClC;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,EAAE,iBAAiB,CAAA;IAChD,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,iBAAiB,CAAA;IAC9C,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,iBAAiB,CAAA;IAC9C,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAAE,iBAAiB,CAAA;IAC/C,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,iBAAiB,CAAA;IAC7C,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAA;IAChD,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAA;IAC/C,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAA;IAC/C,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,EAAE,iBAAiB,CAAA;IACjD,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3C;AA4BD;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAQ;IAE3B;;OAEG;WACU,SAAS,CAAC,SAAS,GAAE,UAAe,EAAE,OAAO,GAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAyB;IAIhH;;OAEG;WACU,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,GAAG,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc;IAK7G,MAAM,CAAC,MAAM,CAAC,OAAO,GAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAsD;CAUzG;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,GAAE,UAAe,EAAE,OAAO,GAAE,QAAgF,GAAG,OAAO,CAAC,MAAM,CAAC,CAoC/K;AAyED,eAAO,MAAM,UAAU,onBAmBtB,CAAA;AA6CD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5D"}
|
package/lib/utils/dts/index.js
CHANGED
|
@@ -32,32 +32,69 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.transpileToDTS = exports.workerCode = exports.generateWeDaAppDTS = exports.WeDaDTS = void 0;
|
|
35
|
+
exports.transpileToDTS = exports.workerCode = exports.generateWeDaAppDTS = exports.WeDaDTS = exports.IInputDataType = void 0;
|
|
36
36
|
const jstt = __importStar(require("json-schema-to-typescript-for-browser/dist/bundle.js"));
|
|
37
37
|
const auto_generated_1 = require("./auto-generated");
|
|
38
38
|
const compile = jstt.compile;
|
|
39
|
+
var IInputDataType;
|
|
40
|
+
(function (IInputDataType) {
|
|
41
|
+
IInputDataType["globalState"] = "globalState";
|
|
42
|
+
IInputDataType["pageState"] = "pageState";
|
|
43
|
+
IInputDataType["compState"] = "compState";
|
|
44
|
+
IInputDataType["pageParams"] = "pageParams";
|
|
45
|
+
IInputDataType["forState"] = "forState";
|
|
46
|
+
IInputDataType["globalCommonCodes"] = "globalCommonCodes";
|
|
47
|
+
IInputDataType["pageHandlerCodes"] = "pageHandlerCodes";
|
|
48
|
+
IInputDataType["compHandlerCodes"] = "compHandlerCodes";
|
|
49
|
+
IInputDataType["compPropData"] = "compPropData";
|
|
50
|
+
IInputDataType["compPropEvents"] = "compPropEvents";
|
|
51
|
+
})(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
|
|
39
52
|
const DtsPlaceholder = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
[IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
|
|
54
|
+
[IInputDataType.pageState]: "// Page State 页面变量 - Don't touch me",
|
|
55
|
+
[IInputDataType.compState]: "// Comp State 组件变量 - Don't touch me",
|
|
56
|
+
[IInputDataType.pageParams]: "// Page Param 页面参数 - Don't touch me",
|
|
57
|
+
[IInputDataType.forState]: "// For 循环变量 - Don't touch me",
|
|
58
|
+
[IInputDataType.globalCommonCodes]: "// Global Common 全局方法 - Don't touch me",
|
|
59
|
+
[IInputDataType.pageHandlerCodes]: "// Page Handler 页面方法 - Don't touch me",
|
|
60
|
+
[IInputDataType.compHandlerCodes]: "// Comp Handler 组件方法 - Don't touch me",
|
|
61
|
+
[IInputDataType.compPropData]: "// Comp Prop Data 组件属性 - Don't touch me",
|
|
62
|
+
[IInputDataType.compPropEvents]: "// Comp Prop Events 组件事件 - Don't touch me",
|
|
63
|
+
};
|
|
64
|
+
const DtsInnerSign = {
|
|
65
|
+
[IInputDataType.globalState]: "Global State Inner",
|
|
66
|
+
[IInputDataType.pageState]: "Page State Inner",
|
|
67
|
+
[IInputDataType.compState]: "Comp State Inner",
|
|
68
|
+
[IInputDataType.pageParams]: "Page Param Inner",
|
|
69
|
+
[IInputDataType.forState]: "Global For Inner",
|
|
70
|
+
[IInputDataType.globalCommonCodes]: "Global Common Inner",
|
|
71
|
+
[IInputDataType.pageHandlerCodes]: "Page Handler Inner",
|
|
72
|
+
[IInputDataType.compHandlerCodes]: "Comp Handler Inner",
|
|
73
|
+
[IInputDataType.compPropData]: "Comp Prop Data Inner",
|
|
74
|
+
[IInputDataType.compPropEvents]: "Comp Prop Events Inner",
|
|
50
75
|
};
|
|
51
76
|
/**
|
|
52
77
|
* 通过该类可以共享同个dts。
|
|
53
78
|
* 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析
|
|
54
79
|
*/
|
|
55
80
|
class WeDaDTS {
|
|
81
|
+
/**
|
|
82
|
+
* 全部更新
|
|
83
|
+
*/
|
|
56
84
|
static updateDTS(inputData = {}, options = { isCompMode: false }) {
|
|
57
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
86
|
WeDaDTS._dts = yield generateWeDaAppDTS(inputData, Object.assign(Object.assign({}, options), { needGlobalFormula: true, needGlobalFor: true }));
|
|
59
87
|
});
|
|
60
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* 部分更新 - 只更新一种类型
|
|
91
|
+
*/
|
|
92
|
+
static updateDTSPartial(inputData, itemType) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const dts = yield _generateOneItemDTS(inputData, itemType);
|
|
95
|
+
WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)$`, 'm'), `$1${dts}$2`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
61
98
|
static getDTS(options = { needGlobalFormula: false, needGlobalFor: false }) {
|
|
62
99
|
let resultDts = WeDaDTS._dts;
|
|
63
100
|
if (!options.needGlobalFormula) {
|
|
@@ -76,20 +113,46 @@ exports.WeDaDTS = WeDaDTS;
|
|
|
76
113
|
function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needGlobalFormula: false, needGlobalFor: false }) {
|
|
77
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
115
|
let resultDts = auto_generated_1.wedaDTS;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
116
|
+
yield Promise.all(Object.keys(inputData).map((key) => __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const placeholder = DtsPlaceholder[key];
|
|
118
|
+
if (placeholder) {
|
|
119
|
+
// 防止某项错误导致全部都错误
|
|
120
|
+
try {
|
|
121
|
+
const dts = yield _generateOneItemDTS(inputData[key], key);
|
|
122
|
+
resultDts = resultDts.replace(placeholder, dts + placeholder);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
console.error(e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})));
|
|
129
|
+
// 根据是否组件模式删除一些类型定义
|
|
130
|
+
if (options === null || options === void 0 ? void 0 : options.isCompMode) {
|
|
131
|
+
resultDts = resultDts.replace(/^\/\/ \$page Begin[\s\S]*^\/\/ \$page End$/m, '');
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
resultDts = resultDts.replace(/^\/\/ \$comp Begin[\s\S]*^\/\/ \$comp End$/m, '');
|
|
135
|
+
}
|
|
136
|
+
// 根据是否需要全局提示函数公式删除一些类型定义
|
|
137
|
+
if (!(options === null || options === void 0 ? void 0 : options.needGlobalFormula)) {
|
|
138
|
+
resultDts = resultDts.replace(/^\/\/ Global Formula Begin[\s\S]*^\/\/ Global Formula End$/m, '');
|
|
139
|
+
}
|
|
140
|
+
// 根据是否需要全局 $for 来删除一些类型定义
|
|
141
|
+
if (!(options === null || options === void 0 ? void 0 : options.needGlobalFor)) {
|
|
142
|
+
resultDts = resultDts.replace(/^\/\/ Global For Begin[\s\S]*^\/\/ Global For End$/m, '');
|
|
143
|
+
}
|
|
144
|
+
// console.log(resultDts)
|
|
145
|
+
return resultDts;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
exports.generateWeDaAppDTS = generateWeDaAppDTS;
|
|
149
|
+
/**
|
|
150
|
+
* 生成指定类型的 DTS
|
|
151
|
+
*/
|
|
152
|
+
function _generateOneItemDTS(inputData, itemType) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
154
|
const hanlderMap = {
|
|
92
|
-
globalCommonCodes: function (inputData) {
|
|
155
|
+
[IInputDataType.globalCommonCodes]: function (inputData) {
|
|
93
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
157
|
const dts = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
95
158
|
const dts = yield transpileToDTS(item.code);
|
|
@@ -98,7 +161,7 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
98
161
|
return dts.join('\n');
|
|
99
162
|
});
|
|
100
163
|
},
|
|
101
|
-
pageHandlerCodes: function (inputData) {
|
|
164
|
+
[IInputDataType.pageHandlerCodes]: function (inputData) {
|
|
102
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
166
|
const IParams = `{
|
|
104
167
|
data?: {
|
|
@@ -127,46 +190,16 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
127
190
|
return dts.join('\n');
|
|
128
191
|
});
|
|
129
192
|
},
|
|
130
|
-
compHandlerCodes: function (inputData) {
|
|
193
|
+
[IInputDataType.compHandlerCodes]: function (inputData) {
|
|
131
194
|
return this.pageHandlerCodes(inputData);
|
|
132
195
|
},
|
|
133
|
-
compPropEvents: function (inputData) {
|
|
196
|
+
[IInputDataType.compPropEvents]: function (inputData) {
|
|
134
197
|
const IData = `any`;
|
|
135
198
|
return inputData.map(eventName => {
|
|
136
199
|
return `function ${eventName}(data?: ${IData}): void`;
|
|
137
200
|
}).join('\n');
|
|
138
201
|
}
|
|
139
202
|
};
|
|
140
|
-
yield Promise.all(Object.keys(inputData).map((key) => __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
const handler = hanlderMap[key];
|
|
142
|
-
let dts = '';
|
|
143
|
-
// 优先判断是否有独立的处理逻辑
|
|
144
|
-
if (handler) {
|
|
145
|
-
dts = yield handler.call(hanlderMap, inputData[key]);
|
|
146
|
-
}
|
|
147
|
-
const placeholder = placeholderMap[key];
|
|
148
|
-
if (placeholder) {
|
|
149
|
-
dts = dts || (yield _compile(inputData[key]));
|
|
150
|
-
resultDts = resultDts.replace(placeholder, dts + placeholder);
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
})));
|
|
154
|
-
// 根据是否组件模式删除一些类型定义
|
|
155
|
-
if (options === null || options === void 0 ? void 0 : options.isCompMode) {
|
|
156
|
-
resultDts = resultDts.replace(/^declare namespace \$page[\s\S]*?^\}$/m, '');
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
resultDts = resultDts.replace(/^declare namespace \$comp[\s\S]*?^\}$/m, '');
|
|
160
|
-
}
|
|
161
|
-
// 根据是否需要全局提示函数公式删除一些类型定义
|
|
162
|
-
if (!(options === null || options === void 0 ? void 0 : options.needGlobalFormula)) {
|
|
163
|
-
resultDts = resultDts.replace(/^\/\/ Global Formula Begin[\s\S]*^\/\/ Global Formula End$/m, '');
|
|
164
|
-
}
|
|
165
|
-
if (!(options === null || options === void 0 ? void 0 : options.needGlobalFor)) {
|
|
166
|
-
resultDts = resultDts.replace(/^\/\/ Global For Begin[\s\S]*^\/\/ Global For End$/m, '');
|
|
167
|
-
}
|
|
168
|
-
// console.log(resultDts)
|
|
169
|
-
return resultDts;
|
|
170
203
|
function _compile(jsonschema) {
|
|
171
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
205
|
let dts = yield compile(jsonschema, 'IWeDa', { additionalProperties: false, bannerComment: '', format: false });
|
|
@@ -175,9 +208,18 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
175
208
|
return dts;
|
|
176
209
|
});
|
|
177
210
|
}
|
|
211
|
+
let dts = '';
|
|
212
|
+
if (!inputData)
|
|
213
|
+
return dts;
|
|
214
|
+
const handler = hanlderMap[itemType];
|
|
215
|
+
// 优先判断是否有独立的处理逻辑
|
|
216
|
+
if (handler) {
|
|
217
|
+
dts = yield handler.call(hanlderMap, inputData);
|
|
218
|
+
}
|
|
219
|
+
dts = dts || (yield _compile(inputData));
|
|
220
|
+
return dts;
|
|
178
221
|
});
|
|
179
222
|
}
|
|
180
|
-
exports.generateWeDaAppDTS = generateWeDaAppDTS;
|
|
181
223
|
// 仅仅为了与 unittest 共享,外部请不要使用
|
|
182
224
|
exports.workerCode = `
|
|
183
225
|
importScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');
|