@cloudbase/cals 0.5.6-alpha.2 → 0.5.7-alpha.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/lib/utils/CSSProperty.d.ts +0 -1
- package/lib/utils/CSSProperty.d.ts.map +1 -1
- package/lib/utils/CSSProperty.js +0 -1
- package/lib/utils/dts/auto-generated.d.ts +1 -1
- package/lib/utils/dts/auto-generated.d.ts.map +1 -1
- package/lib/utils/dts/auto-generated.js +92 -1
- package/lib/utils/dts/build.js +2 -0
- package/lib/utils/dts/index.d.ts +31 -4
- package/lib/utils/dts/index.d.ts.map +1 -1
- package/lib/utils/dts/index.js +150 -18
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -3
- package/package.json +3 -5
- package/lib/utils/version-migrations/common.d.ts +0 -5
- package/lib/utils/version-migrations/common.d.ts.map +0 -1
- package/lib/utils/version-migrations/common.js +0 -29
- package/lib/utils/version-migrations/version4.d.ts +0 -3
- package/lib/utils/version-migrations/version4.d.ts.map +0 -1
- package/lib/utils/version-migrations/version4.js +0 -194
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CSSProperty.d.ts","sourceRoot":"","sources":["../../src/utils/CSSProperty.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AAEH;;GAEG;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6B3B;;;OAGG
|
|
1
|
+
{"version":3,"file":"CSSProperty.d.ts","sourceRoot":"","sources":["../../src/utils/CSSProperty.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AAEH;;GAEG;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6B3B;;;OAGG;;;;;;;;;;;;;;;;CAmBJ,CAAC"}
|
package/lib/utils/CSSProperty.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 namespace auth {\n const currentUser: {\n userId?: string\n phone?: string\n type?: number\n relatedRoles?: {\n id?: string\n envId?: string\n name?: string\n roleIdentity?: string\n }[]\n openId?: string\n name?: string\n nickName?: string\n email?: string\n mainOrg?: {\n id?: string\n name?: string\n }\n orgs?: {\n id?: string\n name?: string\n }[]\n}\n\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";
|
|
1
|
+
export declare const wedaDTS = "\ndeclare class UserWidget {\n // \u5185\u7F6E\u547D\u540D\u7A7A\u95F4\n get sys(): {\n readonly id: string;\n readonly module: string;\n readonly component: string;\n readonly parent: UserWidget;\n readonly children: UserWidget[];\n\n closest(filter?: (parentWidget: UserWidget) => boolean): UserWidget | null;\n };\n\n // \u81EA\u5B9A\u4E49\u547D\u540D\u7A7A\u95F4\n get custom(): { [key: string]: any };\n\n // ========== \u5FEB\u6377\u8BBF\u95EE\u65B9\u5F0F ========== //\n\n readonly id: string;\n readonly module: string;\n readonly component: string;\n readonly parent: UserWidget;\n readonly children: UserWidget[];\n\n closest(filter?: (parentWidget: UserWidget) => boolean): UserWidget | null;\n}\n\n// Used Components Inner Begin\n// Used Components - Don't touch me\n// Used Components Inner End\n\ndeclare 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 namespace auth {\n const currentUser: {\n userId?: string\n phone?: string\n type?: number\n relatedRoles?: {\n id?: string\n envId?: string\n name?: string\n roleIdentity?: string\n }[]\n openId?: string\n name?: string\n nickName?: string\n email?: string\n mainOrg?: {\n id?: string\n name?: string\n }\n orgs?: {\n id?: string\n name?: string\n }[]\n}\n\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\ndeclare namespace $w {\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 // used widgets Inner Begin\n // used widgets - Don't touch me\n // used widgets Inner End\n\n // repeater scope Inner Begin\n // repeater scope - Don't touch me\n // repeater scope Inner End\n}\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,+xZAwXnB,CAAA"}
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wedaDTS = void 0;
|
|
4
|
-
exports.wedaDTS = `
|
|
4
|
+
exports.wedaDTS = `
|
|
5
|
+
declare class UserWidget {
|
|
6
|
+
// 内置命名空间
|
|
7
|
+
get sys(): {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly module: string;
|
|
10
|
+
readonly component: string;
|
|
11
|
+
readonly parent: UserWidget;
|
|
12
|
+
readonly children: UserWidget[];
|
|
13
|
+
|
|
14
|
+
closest(filter?: (parentWidget: UserWidget) => boolean): UserWidget | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// 自定义命名空间
|
|
18
|
+
get custom(): { [key: string]: any };
|
|
19
|
+
|
|
20
|
+
// ========== 快捷访问方式 ========== //
|
|
21
|
+
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly module: string;
|
|
24
|
+
readonly component: string;
|
|
25
|
+
readonly parent: UserWidget;
|
|
26
|
+
readonly children: UserWidget[];
|
|
27
|
+
|
|
28
|
+
closest(filter?: (parentWidget: UserWidget) => boolean): UserWidget | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Used Components Inner Begin
|
|
32
|
+
// Used Components - Don't touch me
|
|
33
|
+
// Used Components Inner End
|
|
34
|
+
|
|
35
|
+
declare namespace $app {
|
|
5
36
|
namespace dataset {
|
|
6
37
|
|
|
7
38
|
const state: {
|
|
@@ -153,6 +184,66 @@ function scanCode(options: {
|
|
|
153
184
|
|
|
154
185
|
declare const app = $app
|
|
155
186
|
|
|
187
|
+
declare namespace $w {
|
|
188
|
+
function ABS(num: number): number;
|
|
189
|
+
function Min(...args: number[]): number;
|
|
190
|
+
function Max(...args: number[]): number;
|
|
191
|
+
function Average(...args: number[]): number;
|
|
192
|
+
function Floor(num: number): number;
|
|
193
|
+
function Ceiling(num: number): number;
|
|
194
|
+
function Round(num: number): number;
|
|
195
|
+
function Sum(...args: number[]): number;
|
|
196
|
+
function Rand(num: number): number;
|
|
197
|
+
|
|
198
|
+
function If(condition: boolean, val1: any, val2: any): any;
|
|
199
|
+
function IsEmpty(text: string | string[]): boolean;
|
|
200
|
+
function NotNull(val: any): boolean;
|
|
201
|
+
function And(...args: boolean[]): boolean;
|
|
202
|
+
function Or(...args: boolean[]): boolean;
|
|
203
|
+
|
|
204
|
+
function Len(text: string): number;
|
|
205
|
+
function Contains(text1: string, text2: string): boolean;
|
|
206
|
+
function Split(text1: string, text2: string): string[];
|
|
207
|
+
function Trim(text: string): string;
|
|
208
|
+
function Upper(text: string): string;
|
|
209
|
+
function Lower(text: string): string;
|
|
210
|
+
function Concat(...text: string[]): string;
|
|
211
|
+
|
|
212
|
+
function Now(): number;
|
|
213
|
+
function Timestamp(arg: number | string | Date): number;
|
|
214
|
+
function Second(arg: number | string | Date): number;
|
|
215
|
+
function Minute(arg: number | string | Date): number;
|
|
216
|
+
function Hour(arg: number | string | Date): number;
|
|
217
|
+
function Day(arg: number | string | Date): number;
|
|
218
|
+
function DayOfWeek(arg: number | string | Date): number;
|
|
219
|
+
function Month(arg: number | string | Date): number;
|
|
220
|
+
function Year(arg: number | string | Date): number;
|
|
221
|
+
function GetDate(year: number, month: number, day: number): number;
|
|
222
|
+
function DateTimeValue(arg: string, val: string): number;
|
|
223
|
+
function Age(arg: number | string | Date, val: number | string | Date): number;
|
|
224
|
+
function AgeOfNow(arg: number | string | Date): number;
|
|
225
|
+
function DateAdd(arg: number | string | Date, day: number): number;
|
|
226
|
+
function MonthAdd(arg: number | string | Date, month: number): number;
|
|
227
|
+
function YearAdd(arg: number | string | Date, year: number): number;
|
|
228
|
+
function DateDiff(startDay: number | string | Date, endDay: number | string | Date): number;
|
|
229
|
+
function HourDiff(startDay: number | string | Date, endDay: number | string | Date): number;
|
|
230
|
+
function MinuteDiff(startDay: number | string | Date, endDay: number | string | Date): number;
|
|
231
|
+
function SecondDiff(startDay: number | string | Date, endDay: number | string | Date): number;
|
|
232
|
+
function MonthDiff(startDay: number | string | Date, endDay: number | string | Date): number;
|
|
233
|
+
function YearDiff(startDay: number | string | Date, endDay: number | string | Date): number;
|
|
234
|
+
function DateText(createdTime: number | string | Date, text: string): string;
|
|
235
|
+
function IsToday(date: number | string | Date): boolean;
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
// used widgets Inner Begin
|
|
239
|
+
// used widgets - Don't touch me
|
|
240
|
+
// used widgets Inner End
|
|
241
|
+
|
|
242
|
+
// repeater scope Inner Begin
|
|
243
|
+
// repeater scope - Don't touch me
|
|
244
|
+
// repeater scope Inner End
|
|
245
|
+
}
|
|
246
|
+
|
|
156
247
|
// Global For Begin
|
|
157
248
|
declare const $for: {
|
|
158
249
|
// Global For Inner Begin
|
package/lib/utils/dts/build.js
CHANGED
|
@@ -79,6 +79,8 @@ function groupDTSs({ wedaFrameworkDTS = '', wedaAPIDTS = '', wedaAuthDTS = '', f
|
|
|
79
79
|
resultDts = resultDts.replace("// Formula 函数公式 - Don't touch me", formulaDTS.replace(/export/g, ''));
|
|
80
80
|
// 函数公式:全局变量提示
|
|
81
81
|
resultDts = resultDts.replace("// Global Formula 全局函数公式- Don't touch me", formulaDTS.replace(/export/g, 'declare'));
|
|
82
|
+
// 函数公式:$w.xxx
|
|
83
|
+
resultDts = resultDts.replace("// $w global APIs - Don't touch me", formulaDTS.replace(/export/g, ''));
|
|
82
84
|
// 增加 API
|
|
83
85
|
const appAPIDTS = wedaAPIDTS.replace(/[\s\S]*\/\/ ============ App API Begin ============ \/\/([\s\S]*?)\/\/ ============ App API End ============ \/\/[\s\S]*/, '$1');
|
|
84
86
|
resultDts = resultDts.replace("// App API - Don't touch me", appAPIDTS);
|
package/lib/utils/dts/index.d.ts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
import { IJsonSchemaObject } from '../../types';
|
|
1
|
+
import { IJsonSchemaAny, IJsonSchemaObject } from '../../types';
|
|
2
2
|
export interface IDTSCodeItem {
|
|
3
3
|
name: string;
|
|
4
4
|
code: string;
|
|
5
5
|
}
|
|
6
|
+
export interface IInputDataUsedComponents {
|
|
7
|
+
module: string;
|
|
8
|
+
component: string;
|
|
9
|
+
exportProperties?: IJsonSchemaObject;
|
|
10
|
+
exportMethods?: {
|
|
11
|
+
name: string;
|
|
12
|
+
input?: IJsonSchemaObject;
|
|
13
|
+
output?: IJsonSchemaAny;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
export interface IInputDataWidgetItem {
|
|
17
|
+
module: string;
|
|
18
|
+
component: string;
|
|
19
|
+
idList: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface IInputDataRepeaterItem {
|
|
22
|
+
currentItemAlias: string;
|
|
23
|
+
currentIndexAlias: string;
|
|
24
|
+
itemData: IJsonSchemaAny;
|
|
25
|
+
}
|
|
6
26
|
export interface IOptions {
|
|
7
27
|
isCompMode?: boolean;
|
|
8
28
|
needGlobalFormula?: boolean;
|
|
9
29
|
needGlobalFor?: boolean;
|
|
30
|
+
needRepeaterScope?: boolean;
|
|
10
31
|
}
|
|
11
32
|
export declare enum IInputDataType {
|
|
12
33
|
globalState = "globalState",
|
|
@@ -18,7 +39,10 @@ export declare enum IInputDataType {
|
|
|
18
39
|
pageHandlerCodes = "pageHandlerCodes",
|
|
19
40
|
compHandlerCodes = "compHandlerCodes",
|
|
20
41
|
compPropData = "compPropData",
|
|
21
|
-
compPropEvents = "compPropEvents"
|
|
42
|
+
compPropEvents = "compPropEvents",
|
|
43
|
+
usedComponents = "usedComponents",
|
|
44
|
+
usedWidgets = "usedWidgets",
|
|
45
|
+
repeaterScope = "repeaterScope"
|
|
22
46
|
}
|
|
23
47
|
export interface IInputData {
|
|
24
48
|
[IInputDataType.globalState]?: IJsonSchemaObject;
|
|
@@ -31,6 +55,9 @@ export interface IInputData {
|
|
|
31
55
|
[IInputDataType.compHandlerCodes]?: IDTSCodeItem[];
|
|
32
56
|
[IInputDataType.compPropData]?: IJsonSchemaObject;
|
|
33
57
|
[IInputDataType.compPropEvents]?: string[];
|
|
58
|
+
[IInputDataType.usedComponents]?: IInputDataUsedComponents[];
|
|
59
|
+
[IInputDataType.usedWidgets]?: IInputDataWidgetItem[];
|
|
60
|
+
[IInputDataType.repeaterScope]?: IInputDataRepeaterItem[];
|
|
34
61
|
}
|
|
35
62
|
/**
|
|
36
63
|
* 通过该类可以共享同个dts。
|
|
@@ -45,7 +72,7 @@ export declare class WeDaDTS {
|
|
|
45
72
|
/**
|
|
46
73
|
* 部分更新 - 只更新一种类型
|
|
47
74
|
*/
|
|
48
|
-
static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[], itemType: IInputDataType, options?: {
|
|
75
|
+
static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[], itemType: IInputDataType, options?: {
|
|
49
76
|
setEmptyIfError: boolean;
|
|
50
77
|
}): Promise<void>;
|
|
51
78
|
static getDTS(options?: Omit<IOptions, "isCompMode">): string;
|
|
@@ -54,7 +81,7 @@ export declare class WeDaDTS {
|
|
|
54
81
|
* 生成 WeDa 应用的低码代码提示的 dts 类型声明内容
|
|
55
82
|
*/
|
|
56
83
|
export declare function generateWeDaAppDTS(inputData?: IInputData, options?: IOptions): Promise<string>;
|
|
57
|
-
export declare const workerCode = "\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');\n\
|
|
84
|
+
export declare const workerCode = "\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/ts-lib.min.js');\n\nconst files = {\n \"foo.ts\": '',\n \"lib.d.ts\": libFileMap['lib.es5.d.ts']\n};\n\nfunction createLanguageService() {\n return ts.createLanguageService({\n getCompilationSettings() {\n return {};\n },\n getScriptFileNames() {\n return [\"foo.ts\", \"lib.d.ts\"];\n },\n getScriptVersion(_fileName) {\n // \u8FD9\u6837\u53EF\u907F\u514D\u4F7F\u7528\u7F13\u5B58\n if (_fileName === 'foo.ts')\n return 'v_' + Math.random();\n return ''\n },\n getScriptSnapshot(fileName) {\n if (fileName === \".ts\") {\n return ts.ScriptSnapshot.fromString(\"\");\n }\n return ts.ScriptSnapshot.fromString(files[fileName] || \"\");\n },\n getCurrentDirectory: () => \".\",\n getDefaultLibFileName(options) {\n return 'lib.d.ts'\n },\n fileExists: name => !!files[name],\n readFile: name => {\n return files[name]\n }\n });\n}\nconst languageService = createLanguageService();\n\nfunction transpile(code) {\n files[\"foo.ts\"] = code\n const result = languageService.getEmitOutput(\n \"foo.ts\",\n /*emitOnlyDtsFiles*/ true,\n /*forceDtsEmit*/ true\n )\n return result.outputFiles[0].text.trim()\n}\n\naddEventListener('message', (message) => {\n const {action, data: {id, code}} = message.data\n switch(action) {\n case 'dts':\n const dts = transpile(code)\n postMessage({action: 'dts_back', data: {id, dts}})\n break\n default:\n break\n }\n})\n";
|
|
58
85
|
/**
|
|
59
86
|
* 通过 js/ts 代码生成 dts
|
|
60
87
|
*/
|
|
@@ -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;AAK/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAK/D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,iBAAiB,CAAA;IACpC,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;QAAC,MAAM,CAAC,EAAE,cAAc,CAAA;KAAE,EAAE,CAAA;CACvF;AACD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AACD,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,cAAc,CAAA;CACzB;AAED,MAAM,WAAW,QAAQ;IAEvB,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;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;IACjC,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;CAChC;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,YAAY,EAAE,CAAA;IACnD,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAA;IAClD,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAA;IAClD,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,EAAE,iBAAiB,CAAA;IACjD,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1C,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,EAAE,wBAAwB,EAAE,CAAA;IAC5D,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACrD,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,EAAE,sBAAsB,EAAE,CAAA;CAC1D;AAkCD;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAa;IAEhC;;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,YAAY,EAAE,GAAG,MAAM,EAAE,GAAG,wBAAwB,EAAE,GAAG,oBAAoB,EAAE,GAAG,sBAAsB,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,GAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAA+B;IAYrQ,MAAM,CAAC,MAAM,CAAC,OAAO,GAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAgF;CAanI;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,GAAE,UAAe,EAAE,OAAO,GAAE,QAA0G,GAAG,OAAO,CAAC,MAAM,CAAC,CAyCzM;AAkJD,eAAO,MAAM,UAAU,6yDA8DtB,CAAA;AA6CD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5D"}
|
package/lib/utils/dts/index.js
CHANGED
|
@@ -48,6 +48,9 @@ var IInputDataType;
|
|
|
48
48
|
IInputDataType["compHandlerCodes"] = "compHandlerCodes";
|
|
49
49
|
IInputDataType["compPropData"] = "compPropData";
|
|
50
50
|
IInputDataType["compPropEvents"] = "compPropEvents";
|
|
51
|
+
IInputDataType["usedComponents"] = "usedComponents";
|
|
52
|
+
IInputDataType["usedWidgets"] = "usedWidgets";
|
|
53
|
+
IInputDataType["repeaterScope"] = "repeaterScope";
|
|
51
54
|
})(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
|
|
52
55
|
const DtsPlaceholder = {
|
|
53
56
|
[IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
|
|
@@ -60,6 +63,9 @@ const DtsPlaceholder = {
|
|
|
60
63
|
[IInputDataType.compHandlerCodes]: "// Comp Handler 组件方法 - Don't touch me",
|
|
61
64
|
[IInputDataType.compPropData]: "// Comp Prop Data 组件属性 - Don't touch me",
|
|
62
65
|
[IInputDataType.compPropEvents]: "// Comp Prop Events 组件事件 - Don't touch me",
|
|
66
|
+
[IInputDataType.usedComponents]: "// Used Components - Don't touch me",
|
|
67
|
+
[IInputDataType.usedWidgets]: "// used widgets - Don't touch me",
|
|
68
|
+
[IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
|
|
63
69
|
};
|
|
64
70
|
const DtsInnerSign = {
|
|
65
71
|
[IInputDataType.globalState]: "Global State Inner",
|
|
@@ -72,6 +78,9 @@ const DtsInnerSign = {
|
|
|
72
78
|
[IInputDataType.compHandlerCodes]: "Comp Handler Inner",
|
|
73
79
|
[IInputDataType.compPropData]: "Comp Prop Data Inner",
|
|
74
80
|
[IInputDataType.compPropEvents]: "Comp Prop Events Inner",
|
|
81
|
+
[IInputDataType.usedComponents]: "Used Components Inner",
|
|
82
|
+
[IInputDataType.usedWidgets]: "used widgets Inner",
|
|
83
|
+
[IInputDataType.repeaterScope]: "repeater scope Inner"
|
|
75
84
|
};
|
|
76
85
|
/**
|
|
77
86
|
* 通过该类可以共享同个dts。
|
|
@@ -83,7 +92,7 @@ class WeDaDTS {
|
|
|
83
92
|
*/
|
|
84
93
|
static updateDTS(inputData = {}, options = { isCompMode: false }) {
|
|
85
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
WeDaDTS._dts = yield generateWeDaAppDTS(inputData, Object.assign(Object.assign({}, options), { needGlobalFormula: true, needGlobalFor: true }));
|
|
95
|
+
WeDaDTS._dts = yield generateWeDaAppDTS(inputData, Object.assign(Object.assign({}, options), { needGlobalFormula: true, needGlobalFor: true, needRepeaterScope: true }));
|
|
87
96
|
});
|
|
88
97
|
}
|
|
89
98
|
/**
|
|
@@ -103,7 +112,7 @@ class WeDaDTS {
|
|
|
103
112
|
}
|
|
104
113
|
});
|
|
105
114
|
}
|
|
106
|
-
static getDTS(options = { needGlobalFormula: false, needGlobalFor: false }) {
|
|
115
|
+
static getDTS(options = { needGlobalFormula: false, needGlobalFor: false, needRepeaterScope: false }) {
|
|
107
116
|
let resultDts = WeDaDTS._dts;
|
|
108
117
|
if (!options.needGlobalFormula) {
|
|
109
118
|
resultDts = resultDts.replace(/^\/\/ Global Formula Begin[\s\S]*^\/\/ Global Formula End$/m, '');
|
|
@@ -111,6 +120,9 @@ class WeDaDTS {
|
|
|
111
120
|
if (!options.needGlobalFor) {
|
|
112
121
|
resultDts = resultDts.replace(/^\/\/ Global For Begin[\s\S]*^\/\/ Global For End$/m, '');
|
|
113
122
|
}
|
|
123
|
+
if (!options.needRepeaterScope) {
|
|
124
|
+
resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
|
|
125
|
+
}
|
|
114
126
|
return resultDts;
|
|
115
127
|
}
|
|
116
128
|
}
|
|
@@ -119,7 +131,7 @@ WeDaDTS._dts = '';
|
|
|
119
131
|
/**
|
|
120
132
|
* 生成 WeDa 应用的低码代码提示的 dts 类型声明内容
|
|
121
133
|
*/
|
|
122
|
-
function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needGlobalFormula: false, needGlobalFor: false }) {
|
|
134
|
+
function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needGlobalFormula: false, needGlobalFor: false, needRepeaterScope: false }) {
|
|
123
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
136
|
let resultDts = auto_generated_1.wedaDTS;
|
|
125
137
|
yield Promise.all(Object.keys(inputData).map((key) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -150,6 +162,10 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
150
162
|
if (!(options === null || options === void 0 ? void 0 : options.needGlobalFor)) {
|
|
151
163
|
resultDts = resultDts.replace(/^\/\/ Global For Begin[\s\S]*^\/\/ Global For End$/m, '');
|
|
152
164
|
}
|
|
165
|
+
// 根据是否需要 Repeater 作用域来删除一些类型定义
|
|
166
|
+
if (!(options === null || options === void 0 ? void 0 : options.needRepeaterScope)) {
|
|
167
|
+
resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
|
|
168
|
+
}
|
|
153
169
|
// console.log(resultDts)
|
|
154
170
|
return resultDts;
|
|
155
171
|
});
|
|
@@ -207,16 +223,70 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
207
223
|
return inputData.map(eventName => {
|
|
208
224
|
return `function ${eventName}(data?: ${IData}): void`;
|
|
209
225
|
}).join('\n');
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
226
|
+
},
|
|
227
|
+
[IInputDataType.usedComponents]: function (inputData) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
// 属性
|
|
231
|
+
let exportPropertiesDTS = '';
|
|
232
|
+
if (item.exportProperties) {
|
|
233
|
+
exportPropertiesDTS = yield _compile(item.exportProperties);
|
|
234
|
+
}
|
|
235
|
+
// 方法
|
|
236
|
+
let exportMethodsDTS = '';
|
|
237
|
+
if (item.exportMethods) {
|
|
238
|
+
const results = yield Promise.all(item.exportMethods.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
let inputDTS = '';
|
|
240
|
+
if (item.input) {
|
|
241
|
+
inputDTS = yield _compile(item.input);
|
|
242
|
+
}
|
|
243
|
+
let outputDTS = 'void';
|
|
244
|
+
if (item.output) {
|
|
245
|
+
outputDTS = yield _compile(item.output, true);
|
|
246
|
+
}
|
|
247
|
+
return `${item.name}: (${inputDTS.trim().replace(/\n/g, ',')}) => ${outputDTS}`;
|
|
248
|
+
})));
|
|
249
|
+
exportMethodsDTS = results.join('\n');
|
|
250
|
+
}
|
|
251
|
+
return `
|
|
252
|
+
declare class ${_genCompInterfaceName(item.module, item.component)} extends UserWidget {
|
|
253
|
+
get custom(): {
|
|
254
|
+
${exportPropertiesDTS}
|
|
255
|
+
|
|
256
|
+
${exportMethodsDTS}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
${exportPropertiesDTS}
|
|
260
|
+
|
|
261
|
+
${exportMethodsDTS}
|
|
219
262
|
}
|
|
263
|
+
`;
|
|
264
|
+
})));
|
|
265
|
+
return results.join('\n');
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
[IInputDataType.usedWidgets]: function (inputData) {
|
|
269
|
+
return inputData.map(item => {
|
|
270
|
+
if (item.idList && item.idList.length > 0) {
|
|
271
|
+
const interfaceName = _genCompInterfaceName(item.module, item.component);
|
|
272
|
+
return item.idList.map(id => `const ${id}: ${interfaceName}`).join('\n');
|
|
273
|
+
}
|
|
274
|
+
return '';
|
|
275
|
+
}).join('\n');
|
|
276
|
+
},
|
|
277
|
+
[IInputDataType.repeaterScope]: function (inputData) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
280
|
+
let itemDataDTS = yield _compile(item.itemData, true);
|
|
281
|
+
return `
|
|
282
|
+
const ${item.currentItemAlias}: ${itemDataDTS}
|
|
283
|
+
const ${item.currentIndexAlias}: number
|
|
284
|
+
`;
|
|
285
|
+
})));
|
|
286
|
+
return results.join('\n');
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
};
|
|
220
290
|
let dts = '';
|
|
221
291
|
if (!inputData)
|
|
222
292
|
return dts;
|
|
@@ -227,22 +297,84 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
227
297
|
}
|
|
228
298
|
dts = dts || (yield _compile(inputData));
|
|
229
299
|
return dts;
|
|
300
|
+
function _genCompInterfaceName(module, component) {
|
|
301
|
+
return `${module.replace(/-/g, '_')}_${component}`;
|
|
302
|
+
}
|
|
303
|
+
function _compile(jsonschema, isObjNeedWrapper = false) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
let dts = yield compile(jsonschema, 'IWeDa', { additionalProperties: false, bannerComment: '', format: false });
|
|
306
|
+
if (dts.search(/^export interface IWeDa/) >= 0) {
|
|
307
|
+
dts = dts.replace(/^export interface.*$/m, '');
|
|
308
|
+
dts = dts.substring(0, dts.length - 2);
|
|
309
|
+
if (isObjNeedWrapper) {
|
|
310
|
+
dts = `{${dts}}`;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
dts = dts.replace(/^export type IWeDa =/m, '');
|
|
315
|
+
}
|
|
316
|
+
return dts;
|
|
317
|
+
});
|
|
318
|
+
}
|
|
230
319
|
});
|
|
231
320
|
}
|
|
232
321
|
// 仅仅为了与 unittest 共享,外部请不要使用
|
|
233
322
|
exports.workerCode = `
|
|
234
323
|
importScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');
|
|
324
|
+
importScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/ts-lib.min.js');
|
|
325
|
+
|
|
326
|
+
const files = {
|
|
327
|
+
"foo.ts": '',
|
|
328
|
+
"lib.d.ts": libFileMap['lib.es5.d.ts']
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
function createLanguageService() {
|
|
332
|
+
return ts.createLanguageService({
|
|
333
|
+
getCompilationSettings() {
|
|
334
|
+
return {};
|
|
335
|
+
},
|
|
336
|
+
getScriptFileNames() {
|
|
337
|
+
return ["foo.ts", "lib.d.ts"];
|
|
338
|
+
},
|
|
339
|
+
getScriptVersion(_fileName) {
|
|
340
|
+
// 这样可避免使用缓存
|
|
341
|
+
if (_fileName === 'foo.ts')
|
|
342
|
+
return 'v_' + Math.random();
|
|
343
|
+
return ''
|
|
344
|
+
},
|
|
345
|
+
getScriptSnapshot(fileName) {
|
|
346
|
+
if (fileName === ".ts") {
|
|
347
|
+
return ts.ScriptSnapshot.fromString("");
|
|
348
|
+
}
|
|
349
|
+
return ts.ScriptSnapshot.fromString(files[fileName] || "");
|
|
350
|
+
},
|
|
351
|
+
getCurrentDirectory: () => ".",
|
|
352
|
+
getDefaultLibFileName(options) {
|
|
353
|
+
return 'lib.d.ts'
|
|
354
|
+
},
|
|
355
|
+
fileExists: name => !!files[name],
|
|
356
|
+
readFile: name => {
|
|
357
|
+
return files[name]
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
const languageService = createLanguageService();
|
|
362
|
+
|
|
363
|
+
function transpile(code) {
|
|
364
|
+
files["foo.ts"] = code
|
|
365
|
+
const result = languageService.getEmitOutput(
|
|
366
|
+
"foo.ts",
|
|
367
|
+
/*emitOnlyDtsFiles*/ true,
|
|
368
|
+
/*forceDtsEmit*/ true
|
|
369
|
+
)
|
|
370
|
+
return result.outputFiles[0].text.trim()
|
|
371
|
+
}
|
|
235
372
|
|
|
236
|
-
ts.transpileOptionValueCompilerOptions.forEach(item => {
|
|
237
|
-
if (['emitDeclarationOnly', 'declaration'].includes(item.name)) {
|
|
238
|
-
item.transpileOptionValue = true
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
373
|
addEventListener('message', (message) => {
|
|
242
374
|
const {action, data: {id, code}} = message.data
|
|
243
375
|
switch(action) {
|
|
244
376
|
case 'dts':
|
|
245
|
-
const dts =
|
|
377
|
+
const dts = transpile(code)
|
|
246
378
|
postMessage({action: 'dts_back', data: {id, dts}})
|
|
247
379
|
break
|
|
248
380
|
default:
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/utils/index.js
CHANGED
|
@@ -14,12 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isUnitlessNumber =
|
|
17
|
+
exports.isUnitlessNumber = void 0;
|
|
18
18
|
__exportStar(require("../parser"), exports);
|
|
19
19
|
__exportStar(require("../types/index"), exports);
|
|
20
20
|
__exportStar(require("./constant"), exports);
|
|
21
21
|
__exportStar(require("./dts/index"), exports);
|
|
22
|
-
var version4_1 = require("./version-migrations/version4");
|
|
23
|
-
Object.defineProperty(exports, "version4", { enumerable: true, get: function () { return version4_1.version4; } });
|
|
24
22
|
var CSSProperty_1 = require("./CSSProperty");
|
|
25
23
|
Object.defineProperty(exports, "isUnitlessNumber", { enumerable: true, get: function () { return CSSProperty_1.isUnitlessNumber; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cals",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7-alpha.0",
|
|
4
4
|
"description": "Common application specifications",
|
|
5
5
|
"main": "lib/utils/index.js",
|
|
6
6
|
"source": "src/utils/index.ts",
|
|
@@ -31,9 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"acorn": "^8.0.4",
|
|
33
33
|
"json-schema-to-typescript-for-browser": "^11.0.3",
|
|
34
|
-
"lodash": "^4.17.20"
|
|
35
|
-
"postcss": "^8.4.20",
|
|
36
|
-
"postcss-less": "^6.0.0"
|
|
34
|
+
"lodash": "^4.17.20"
|
|
37
35
|
},
|
|
38
36
|
"devDependencies": {
|
|
39
37
|
"@types/acorn": "^4.0.5",
|
|
@@ -53,4 +51,4 @@
|
|
|
53
51
|
"typescript": "^4.7.4",
|
|
54
52
|
"typescript-json-schema": "^0.53.0"
|
|
55
53
|
}
|
|
56
|
-
}
|
|
54
|
+
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function semverComp(a: string, b: string): number;
|
|
2
|
-
export declare function toFixed(num: number, precision: number): number;
|
|
3
|
-
export declare const OFFICIAL_COMPONENT_LIB_NAME = "CLOUDBASE_STANDARD";
|
|
4
|
-
export declare const OFFICIAL_MATERIAL_LIB_NAME = "gsd-h5-react";
|
|
5
|
-
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/version-migrations/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAChE,eAAO,MAAM,0BAA0B,iBAAiB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OFFICIAL_MATERIAL_LIB_NAME = exports.OFFICIAL_COMPONENT_LIB_NAME = exports.toFixed = exports.semverComp = void 0;
|
|
4
|
-
function semverComp(a, b) {
|
|
5
|
-
const pa = a.split('.');
|
|
6
|
-
const pb = b.split('.');
|
|
7
|
-
for (let i = 0; i < 3; i++) {
|
|
8
|
-
const na = Number(pa[i]);
|
|
9
|
-
const nb = Number(pb[i]);
|
|
10
|
-
if (na > nb)
|
|
11
|
-
return 1;
|
|
12
|
-
if (nb > na)
|
|
13
|
-
return -1;
|
|
14
|
-
if (!isNaN(na) && isNaN(nb))
|
|
15
|
-
return 1;
|
|
16
|
-
if (isNaN(na) && !isNaN(nb))
|
|
17
|
-
return -1;
|
|
18
|
-
}
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
exports.semverComp = semverComp;
|
|
22
|
-
function toFixed(num, precision) {
|
|
23
|
-
const multiplier = Math.pow(10, (precision + 1));
|
|
24
|
-
const wholeNumber = Math.floor(num * multiplier);
|
|
25
|
-
return (Math.round(wholeNumber / 10) * 10) / multiplier;
|
|
26
|
-
}
|
|
27
|
-
exports.toFixed = toFixed;
|
|
28
|
-
exports.OFFICIAL_COMPONENT_LIB_NAME = 'CLOUDBASE_STANDARD';
|
|
29
|
-
exports.OFFICIAL_MATERIAL_LIB_NAME = 'gsd-h5-react';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version4.d.ts","sourceRoot":"","sources":["../../../src/utils/version-migrations/version4.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAGhE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,OAAO,EAClB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,GAC/D,YAAY,CAEd"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.version4 = void 0;
|
|
7
|
-
const postcss_1 = __importDefault(require("postcss"));
|
|
8
|
-
const postcss_less_1 = __importDefault(require("postcss-less"));
|
|
9
|
-
const __1 = require("..");
|
|
10
|
-
const common_1 = require("./common");
|
|
11
|
-
function version4(cals, isUpgrade, setSchemaVersionCallback) {
|
|
12
|
-
return transformPxLowcodeCompAndSourceComp(cals, isUpgrade, setSchemaVersionCallback);
|
|
13
|
-
}
|
|
14
|
-
exports.version4 = version4;
|
|
15
|
-
const transformPxLowcodeCompAndSourceComp = (cals, isUpgrade, setSchemaVersionCallback) => {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
17
|
-
{
|
|
18
|
-
function transformCals(items, isUpgradeToPx) {
|
|
19
|
-
return items.map((item) => {
|
|
20
|
-
var _a;
|
|
21
|
-
// 对于表单操作区的按钮组件的父容器添加.wd-form__action, 兼容组件规范化按钮升级样式
|
|
22
|
-
if ((item === null || item === void 0 ? void 0 : item.module) === common_1.OFFICIAL_COMPONENT_LIB_NAME && (item === null || item === void 0 ? void 0 : item.component) === 'Form') {
|
|
23
|
-
item = addClassToButtonContainer(item);
|
|
24
|
-
}
|
|
25
|
-
if ((_a = item === null || item === void 0 ? void 0 : item.extra) === null || _a === void 0 ? void 0 : _a.commonStyle) {
|
|
26
|
-
item.extra.commonStyle = convertCommonStyle(item.extra.commonStyle, isUpgradeToPx);
|
|
27
|
-
if (item.extra.commonStyle.self) {
|
|
28
|
-
// 处理 margin padding shorthand 同步
|
|
29
|
-
const newSelf = (0, __1.processCommonStyle2CSSProperties)(item.extra.commonStyle, {
|
|
30
|
-
toRem: false,
|
|
31
|
-
ignoreSelf: true,
|
|
32
|
-
addPXUnit: true,
|
|
33
|
-
});
|
|
34
|
-
['margin', 'padding', 'border'].forEach((k) => {
|
|
35
|
-
if (item.extra.commonStyle.self[k]) {
|
|
36
|
-
item.extra.commonStyle.self[k] = newSelf[k];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (item === null || item === void 0 ? void 0 : item.resources) {
|
|
42
|
-
item.resources = item.resources.map((n) => {
|
|
43
|
-
if (n.codeType === 'style') {
|
|
44
|
-
n = convertLowCodesStyle(n, isUpgradeToPx);
|
|
45
|
-
return n;
|
|
46
|
-
}
|
|
47
|
-
return n;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (item.items) {
|
|
51
|
-
item.items = transformCals(item.items, isUpgradeToPx);
|
|
52
|
-
}
|
|
53
|
-
return item;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
let pages = cals['items'];
|
|
57
|
-
let isDivision;
|
|
58
|
-
if (isUpgrade && (0, common_1.semverComp)((_a = cals['schemaVersion']) !== null && _a !== void 0 ? _a : '3.0.0', '4.0.0') < 0) {
|
|
59
|
-
// 组件库版本高于目标版本,且schemaVersion小于4, 将应用 CALS 数据中的 CSS 和 style 中的无单位和有单位的小写 px统一改写为 1/2 px
|
|
60
|
-
isDivision = true;
|
|
61
|
-
pages = transformCals(pages, isDivision);
|
|
62
|
-
cals.resources = (_b = cals.resources) === null || _b === void 0 ? void 0 : _b.map((n) => {
|
|
63
|
-
if (n.codeType === 'style') {
|
|
64
|
-
n = convertLowCodesStyle(n, isDivision);
|
|
65
|
-
return n;
|
|
66
|
-
}
|
|
67
|
-
return n;
|
|
68
|
-
});
|
|
69
|
-
cals['schemaVersion'] = '4.0.0';
|
|
70
|
-
setSchemaVersionCallback === null || setSchemaVersionCallback === void 0 ? void 0 : setSchemaVersionCallback('4.0.0');
|
|
71
|
-
}
|
|
72
|
-
else if (!isUpgrade && (0, common_1.semverComp)((_c = cals['schemaVersion']) !== null && _c !== void 0 ? _c : '3.0.0', '4.0.0') >= 0) {
|
|
73
|
-
// 组件库低于目标版本,并且schemaVersion大于4 将应用 CALS 数据中的 CSS 和 style 中的无单位和有单位的小写 px统一改写为 2倍 px
|
|
74
|
-
isDivision = false;
|
|
75
|
-
pages = transformCals(pages, isDivision);
|
|
76
|
-
cals.resources = (_d = cals.resources) === null || _d === void 0 ? void 0 : _d.map((n) => {
|
|
77
|
-
if (n.codeType === 'style') {
|
|
78
|
-
n = convertLowCodesStyle(n, isDivision);
|
|
79
|
-
return n;
|
|
80
|
-
}
|
|
81
|
-
return n;
|
|
82
|
-
});
|
|
83
|
-
delete cals['schemaVersion'];
|
|
84
|
-
setSchemaVersionCallback === null || setSchemaVersionCallback === void 0 ? void 0 : setSchemaVersionCallback(undefined);
|
|
85
|
-
}
|
|
86
|
-
cals['items'] = pages;
|
|
87
|
-
return cals;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
function hasSubmitButton(item) {
|
|
91
|
-
var _a;
|
|
92
|
-
if ((_a = item === null || item === void 0 ? void 0 : item.items) === null || _a === void 0 ? void 0 : _a.length) {
|
|
93
|
-
const children = item.items;
|
|
94
|
-
return children.some((i) => { var _a; return (i === null || i === void 0 ? void 0 : i.module) === common_1.OFFICIAL_COMPONENT_LIB_NAME && i.component === 'Button' && ((_a = i === null || i === void 0 ? void 0 : i.attributes) === null || _a === void 0 ? void 0 : _a.formType) === 'submit'; });
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
function addClassToButtonContainer(item) {
|
|
99
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
100
|
-
if ((item === null || item === void 0 ? void 0 : item.module) === common_1.OFFICIAL_MATERIAL_LIB_NAME && item.component === 'Container') {
|
|
101
|
-
if (hasSubmitButton(item)) {
|
|
102
|
-
if (((_a = item.attributes) === null || _a === void 0 ? void 0 : _a.class) && !((_b = item.attributes) === null || _b === void 0 ? void 0 : _b.class.includes('wd-form__action'))) {
|
|
103
|
-
if (typeof ((_c = item.attributes) === null || _c === void 0 ? void 0 : _c.class) === 'string') {
|
|
104
|
-
item.attributes = Object.assign(Object.assign({}, item.attributes), { class: `${(_d = item.attributes) === null || _d === void 0 ? void 0 : _d.class} wd-form__action` });
|
|
105
|
-
}
|
|
106
|
-
else if (Array.isArray((_e = item.attributes) === null || _e === void 0 ? void 0 : _e.class)) {
|
|
107
|
-
item.attributes = Object.assign(Object.assign({}, item.attributes), { class: [...(_f = item.attributes) === null || _f === void 0 ? void 0 : _f.class, 'wd-form__action'] });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (!((_g = item.attributes) === null || _g === void 0 ? void 0 : _g.class)) {
|
|
111
|
-
item.attributes = Object.assign(Object.assign({}, item.attributes), { class: 'wd-form__action' });
|
|
112
|
-
}
|
|
113
|
-
// 移除旧的padding配置
|
|
114
|
-
if ((_j = (_h = item === null || item === void 0 ? void 0 : item.extra) === null || _h === void 0 ? void 0 : _h.commonStyle) === null || _j === void 0 ? void 0 : _j.padding) {
|
|
115
|
-
delete item.extra.commonStyle.padding;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if ((_k = item === null || item === void 0 ? void 0 : item.items) === null || _k === void 0 ? void 0 : _k.length) {
|
|
120
|
-
item.items = item.items.map((i) => addClassToButtonContainer(i));
|
|
121
|
-
}
|
|
122
|
-
return item;
|
|
123
|
-
}
|
|
124
|
-
function jsonTranverse(json, reviver) {
|
|
125
|
-
return JSON.parse(JSON.stringify(json, reviver, 2));
|
|
126
|
-
}
|
|
127
|
-
function convertCommonStyle(value, isUpgrade) {
|
|
128
|
-
return jsonTranverse(value, (key, value) => {
|
|
129
|
-
if (__1.isUnitlessNumber[key]) {
|
|
130
|
-
return value;
|
|
131
|
-
}
|
|
132
|
-
if (typeof value === 'number') {
|
|
133
|
-
value = value / 2;
|
|
134
|
-
}
|
|
135
|
-
else if (/^((\d+\.)?\d+)(px)?$/.test(value)) {
|
|
136
|
-
value = !value ? value : value === null || value === void 0 ? void 0 : value.replace('px', '');
|
|
137
|
-
// console.log(key, value, Number(value) / 2);
|
|
138
|
-
if (isUpgrade) {
|
|
139
|
-
value = !value ? value : `${(0, common_1.toFixed)(Number(value) / 2, 3)}px`;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
value = !value ? value : `${Number(value) * 2}px`;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return value;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
const rem2PxPlugin = (opts) => {
|
|
149
|
-
const rem2pxSym = Symbol('rem2pxSym');
|
|
150
|
-
const { isUpgrade } = opts;
|
|
151
|
-
return {
|
|
152
|
-
postcssPlugin: 'postcss-rem2px',
|
|
153
|
-
Declaration(decl, rule) {
|
|
154
|
-
const pxRegex = /"[^"]+"|'[^']+'|(\d*\.?\d+)px/gm;
|
|
155
|
-
if (decl.value.indexOf('px') < 0) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (decl[rem2pxSym]) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (isUpgrade) {
|
|
162
|
-
const value = decl.value.replace(pxRegex, (match, p1) => {
|
|
163
|
-
if (p1 !== null && p1 !== undefined) {
|
|
164
|
-
const r = (0, common_1.toFixed)(Number(p1) / 2, 3);
|
|
165
|
-
const rs = r.toString();
|
|
166
|
-
return `${rs}px`;
|
|
167
|
-
}
|
|
168
|
-
return match;
|
|
169
|
-
});
|
|
170
|
-
decl.value = value;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
const value = decl.value.replace(pxRegex, (match, p1) => {
|
|
174
|
-
if (p1 !== null && p1 !== undefined) {
|
|
175
|
-
return `${Number(p1) * 2}px`;
|
|
176
|
-
}
|
|
177
|
-
return match;
|
|
178
|
-
});
|
|
179
|
-
decl.value = value;
|
|
180
|
-
}
|
|
181
|
-
decl[rem2pxSym] = true;
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
rem2PxPlugin.postcss = true;
|
|
186
|
-
function convertLowCodesStyle(value, isUpgrade) {
|
|
187
|
-
// Modified From https://github.com/cuth/postcss-pxtorem/blob/122649015322214f8e9d1ac852eb11c0791b634b/lib/pixel-unit-regex.js#L9
|
|
188
|
-
// eslint-disable-next-line no-useless-escape
|
|
189
|
-
const result = (0, postcss_1.default)([rem2PxPlugin({ isUpgrade })]).process(value.code, {
|
|
190
|
-
syntax: postcss_less_1.default,
|
|
191
|
-
});
|
|
192
|
-
value.code = result.css;
|
|
193
|
-
return value;
|
|
194
|
-
}
|