@cloudbase/cals 0.5.7-alpha.0 → 0.5.8
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 +1 -0
- package/lib/utils/CSSProperty.d.ts.map +1 -1
- package/lib/utils/CSSProperty.js +1 -0
- 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 +1 -92
- package/lib/utils/dts/build.js +0 -2
- package/lib/utils/dts/index.d.ts +4 -31
- package/lib/utils/dts/index.d.ts.map +1 -1
- package/lib/utils/dts/index.js +18 -150
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +3 -1
- package/lib/utils/version-migrations/common.d.ts +5 -0
- package/lib/utils/version-migrations/common.d.ts.map +1 -0
- package/lib/utils/version-migrations/common.js +29 -0
- package/lib/utils/version-migrations/version4.d.ts +3 -0
- package/lib/utils/version-migrations/version4.d.ts.map +1 -0
- package/lib/utils/version-migrations/version4.js +199 -0
- package/package.json +5 -3
|
@@ -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;;;;;;;;;;;;;;;;;CAoBJ,CAAC"}
|
package/lib/utils/CSSProperty.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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";
|
|
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";
|
|
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,wrSA6RnB,CAAA"}
|
|
@@ -1,38 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wedaDTS = void 0;
|
|
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 {
|
|
4
|
+
exports.wedaDTS = `declare namespace $app {
|
|
36
5
|
namespace dataset {
|
|
37
6
|
|
|
38
7
|
const state: {
|
|
@@ -184,66 +153,6 @@ function scanCode(options: {
|
|
|
184
153
|
|
|
185
154
|
declare const app = $app
|
|
186
155
|
|
|
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
|
-
|
|
247
156
|
// Global For Begin
|
|
248
157
|
declare const $for: {
|
|
249
158
|
// Global For Inner Begin
|
package/lib/utils/dts/build.js
CHANGED
|
@@ -79,8 +79,6 @@ 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, ''));
|
|
84
82
|
// 增加 API
|
|
85
83
|
const appAPIDTS = wedaAPIDTS.replace(/[\s\S]*\/\/ ============ App API Begin ============ \/\/([\s\S]*?)\/\/ ============ App API End ============ \/\/[\s\S]*/, '$1');
|
|
86
84
|
resultDts = resultDts.replace("// App API - Don't touch me", appAPIDTS);
|
package/lib/utils/dts/index.d.ts
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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
|
-
}
|
|
26
6
|
export interface IOptions {
|
|
27
7
|
isCompMode?: boolean;
|
|
28
8
|
needGlobalFormula?: boolean;
|
|
29
9
|
needGlobalFor?: boolean;
|
|
30
|
-
needRepeaterScope?: boolean;
|
|
31
10
|
}
|
|
32
11
|
export declare enum IInputDataType {
|
|
33
12
|
globalState = "globalState",
|
|
@@ -39,10 +18,7 @@ export declare enum IInputDataType {
|
|
|
39
18
|
pageHandlerCodes = "pageHandlerCodes",
|
|
40
19
|
compHandlerCodes = "compHandlerCodes",
|
|
41
20
|
compPropData = "compPropData",
|
|
42
|
-
compPropEvents = "compPropEvents"
|
|
43
|
-
usedComponents = "usedComponents",
|
|
44
|
-
usedWidgets = "usedWidgets",
|
|
45
|
-
repeaterScope = "repeaterScope"
|
|
21
|
+
compPropEvents = "compPropEvents"
|
|
46
22
|
}
|
|
47
23
|
export interface IInputData {
|
|
48
24
|
[IInputDataType.globalState]?: IJsonSchemaObject;
|
|
@@ -55,9 +31,6 @@ export interface IInputData {
|
|
|
55
31
|
[IInputDataType.compHandlerCodes]?: IDTSCodeItem[];
|
|
56
32
|
[IInputDataType.compPropData]?: IJsonSchemaObject;
|
|
57
33
|
[IInputDataType.compPropEvents]?: string[];
|
|
58
|
-
[IInputDataType.usedComponents]?: IInputDataUsedComponents[];
|
|
59
|
-
[IInputDataType.usedWidgets]?: IInputDataWidgetItem[];
|
|
60
|
-
[IInputDataType.repeaterScope]?: IInputDataRepeaterItem[];
|
|
61
34
|
}
|
|
62
35
|
/**
|
|
63
36
|
* 通过该类可以共享同个dts。
|
|
@@ -72,7 +45,7 @@ export declare class WeDaDTS {
|
|
|
72
45
|
/**
|
|
73
46
|
* 部分更新 - 只更新一种类型
|
|
74
47
|
*/
|
|
75
|
-
static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[]
|
|
48
|
+
static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[], itemType: IInputDataType, options?: {
|
|
76
49
|
setEmptyIfError: boolean;
|
|
77
50
|
}): Promise<void>;
|
|
78
51
|
static getDTS(options?: Omit<IOptions, "isCompMode">): string;
|
|
@@ -81,7 +54,7 @@ export declare class WeDaDTS {
|
|
|
81
54
|
* 生成 WeDa 应用的低码代码提示的 dts 类型声明内容
|
|
82
55
|
*/
|
|
83
56
|
export declare function generateWeDaAppDTS(inputData?: IInputData, options?: IOptions): Promise<string>;
|
|
84
|
-
export declare const workerCode = "\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');\
|
|
57
|
+
export declare const workerCode = "\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');\n\nts.transpileOptionValueCompilerOptions.forEach(item => {\n if (['emitDeclarationOnly', 'declaration'].includes(item.name)) {\n item.transpileOptionValue = true\n }\n})\naddEventListener('message', (message) => {\n const {action, data: {id, code}} = message.data\n switch(action) {\n case 'dts':\n const dts = ts.transpile(code, {})\n postMessage({action: 'dts_back', data: {id, dts}})\n break\n default:\n break\n }\n})\n";
|
|
85
58
|
/**
|
|
86
59
|
* 通过 js/ts 代码生成 dts
|
|
87
60
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
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,MAAM,WAAW,YAAY;IAC3B,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,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;CAC3C;AA4BD;;;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,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,GAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAA+B;IAYpL,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
|
@@ -48,9 +48,6 @@ 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";
|
|
54
51
|
})(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
|
|
55
52
|
const DtsPlaceholder = {
|
|
56
53
|
[IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
|
|
@@ -63,9 +60,6 @@ const DtsPlaceholder = {
|
|
|
63
60
|
[IInputDataType.compHandlerCodes]: "// Comp Handler 组件方法 - Don't touch me",
|
|
64
61
|
[IInputDataType.compPropData]: "// Comp Prop Data 组件属性 - Don't touch me",
|
|
65
62
|
[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"
|
|
69
63
|
};
|
|
70
64
|
const DtsInnerSign = {
|
|
71
65
|
[IInputDataType.globalState]: "Global State Inner",
|
|
@@ -78,9 +72,6 @@ const DtsInnerSign = {
|
|
|
78
72
|
[IInputDataType.compHandlerCodes]: "Comp Handler Inner",
|
|
79
73
|
[IInputDataType.compPropData]: "Comp Prop Data Inner",
|
|
80
74
|
[IInputDataType.compPropEvents]: "Comp Prop Events Inner",
|
|
81
|
-
[IInputDataType.usedComponents]: "Used Components Inner",
|
|
82
|
-
[IInputDataType.usedWidgets]: "used widgets Inner",
|
|
83
|
-
[IInputDataType.repeaterScope]: "repeater scope Inner"
|
|
84
75
|
};
|
|
85
76
|
/**
|
|
86
77
|
* 通过该类可以共享同个dts。
|
|
@@ -92,7 +83,7 @@ class WeDaDTS {
|
|
|
92
83
|
*/
|
|
93
84
|
static updateDTS(inputData = {}, options = { isCompMode: false }) {
|
|
94
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
WeDaDTS._dts = yield generateWeDaAppDTS(inputData, Object.assign(Object.assign({}, options), { needGlobalFormula: true, needGlobalFor: true
|
|
86
|
+
WeDaDTS._dts = yield generateWeDaAppDTS(inputData, Object.assign(Object.assign({}, options), { needGlobalFormula: true, needGlobalFor: true }));
|
|
96
87
|
});
|
|
97
88
|
}
|
|
98
89
|
/**
|
|
@@ -112,7 +103,7 @@ class WeDaDTS {
|
|
|
112
103
|
}
|
|
113
104
|
});
|
|
114
105
|
}
|
|
115
|
-
static getDTS(options = { needGlobalFormula: false, needGlobalFor: false
|
|
106
|
+
static getDTS(options = { needGlobalFormula: false, needGlobalFor: false }) {
|
|
116
107
|
let resultDts = WeDaDTS._dts;
|
|
117
108
|
if (!options.needGlobalFormula) {
|
|
118
109
|
resultDts = resultDts.replace(/^\/\/ Global Formula Begin[\s\S]*^\/\/ Global Formula End$/m, '');
|
|
@@ -120,9 +111,6 @@ class WeDaDTS {
|
|
|
120
111
|
if (!options.needGlobalFor) {
|
|
121
112
|
resultDts = resultDts.replace(/^\/\/ Global For Begin[\s\S]*^\/\/ Global For End$/m, '');
|
|
122
113
|
}
|
|
123
|
-
if (!options.needRepeaterScope) {
|
|
124
|
-
resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
|
|
125
|
-
}
|
|
126
114
|
return resultDts;
|
|
127
115
|
}
|
|
128
116
|
}
|
|
@@ -131,7 +119,7 @@ WeDaDTS._dts = '';
|
|
|
131
119
|
/**
|
|
132
120
|
* 生成 WeDa 应用的低码代码提示的 dts 类型声明内容
|
|
133
121
|
*/
|
|
134
|
-
function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needGlobalFormula: false, needGlobalFor: false
|
|
122
|
+
function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needGlobalFormula: false, needGlobalFor: false }) {
|
|
135
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
124
|
let resultDts = auto_generated_1.wedaDTS;
|
|
137
125
|
yield Promise.all(Object.keys(inputData).map((key) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -162,10 +150,6 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
162
150
|
if (!(options === null || options === void 0 ? void 0 : options.needGlobalFor)) {
|
|
163
151
|
resultDts = resultDts.replace(/^\/\/ Global For Begin[\s\S]*^\/\/ Global For End$/m, '');
|
|
164
152
|
}
|
|
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
|
-
}
|
|
169
153
|
// console.log(resultDts)
|
|
170
154
|
return resultDts;
|
|
171
155
|
});
|
|
@@ -223,70 +207,16 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
223
207
|
return inputData.map(eventName => {
|
|
224
208
|
return `function ${eventName}(data?: ${IData}): void`;
|
|
225
209
|
}).join('\n');
|
|
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}
|
|
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
|
-
},
|
|
210
|
+
}
|
|
289
211
|
};
|
|
212
|
+
function _compile(jsonschema) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
let dts = yield compile(jsonschema, 'IWeDa', { additionalProperties: false, bannerComment: '', format: false });
|
|
215
|
+
dts = dts.replace(/^export interface.*$/m, '');
|
|
216
|
+
dts = dts.substring(0, dts.length - 2);
|
|
217
|
+
return dts;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
290
220
|
let dts = '';
|
|
291
221
|
if (!inputData)
|
|
292
222
|
return dts;
|
|
@@ -297,84 +227,22 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
297
227
|
}
|
|
298
228
|
dts = dts || (yield _compile(inputData));
|
|
299
229
|
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
|
-
}
|
|
319
230
|
});
|
|
320
231
|
}
|
|
321
232
|
// 仅仅为了与 unittest 共享,外部请不要使用
|
|
322
233
|
exports.workerCode = `
|
|
323
234
|
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
|
-
}
|
|
372
235
|
|
|
236
|
+
ts.transpileOptionValueCompilerOptions.forEach(item => {
|
|
237
|
+
if (['emitDeclarationOnly', 'declaration'].includes(item.name)) {
|
|
238
|
+
item.transpileOptionValue = true
|
|
239
|
+
}
|
|
240
|
+
})
|
|
373
241
|
addEventListener('message', (message) => {
|
|
374
242
|
const {action, data: {id, code}} = message.data
|
|
375
243
|
switch(action) {
|
|
376
244
|
case 'dts':
|
|
377
|
-
const dts = transpile(code)
|
|
245
|
+
const dts = ts.transpile(code, {})
|
|
378
246
|
postMessage({action: 'dts_back', data: {id, dts}})
|
|
379
247
|
break
|
|
380
248
|
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,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
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,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/utils/index.js
CHANGED
|
@@ -14,10 +14,12 @@ 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 = void 0;
|
|
17
|
+
exports.isUnitlessNumber = exports.version4 = 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; } });
|
|
22
24
|
var CSSProperty_1 = require("./CSSProperty");
|
|
23
25
|
Object.defineProperty(exports, "isUnitlessNumber", { enumerable: true, get: function () { return CSSProperty_1.isUnitlessNumber; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,199 @@
|
|
|
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
|
+
if (isUpgrade) {
|
|
134
|
+
value = value / 2;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
value = value * 2;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (/^((\d+\.)?\d+)(px)?$/.test(value)) {
|
|
141
|
+
value = !value ? value : value === null || value === void 0 ? void 0 : value.replace('px', '');
|
|
142
|
+
if (isUpgrade) {
|
|
143
|
+
// console.log(key, value, Number(value) / 2);
|
|
144
|
+
value = !value ? value : `${(0, common_1.toFixed)(Number(value) / 2, 3)}px`;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
value = !value ? value : `${Number(value) * 2}px`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return value;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const rem2PxPlugin = (opts) => {
|
|
154
|
+
const rem2pxSym = Symbol('rem2pxSym');
|
|
155
|
+
const { isUpgrade } = opts;
|
|
156
|
+
return {
|
|
157
|
+
postcssPlugin: 'postcss-rem2px',
|
|
158
|
+
Declaration(decl, rule) {
|
|
159
|
+
// Modified From https://github.com/cuth/postcss-pxtorem/blob/122649015322214f8e9d1ac852eb11c0791b634b/lib/pixel-unit-regex.js#L9
|
|
160
|
+
// eslint-disable-next-line no-useless-escape
|
|
161
|
+
const pxRegex = /"[^"]+"|'[^']+'|(\d*\.?\d+)px/gm;
|
|
162
|
+
if (decl.value.indexOf('px') < 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (decl[rem2pxSym]) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (isUpgrade) {
|
|
169
|
+
const value = decl.value.replace(pxRegex, (match, p1) => {
|
|
170
|
+
if (p1 !== null && p1 !== undefined) {
|
|
171
|
+
const r = (0, common_1.toFixed)(Number(p1) / 2, 3);
|
|
172
|
+
const rs = r.toString();
|
|
173
|
+
return `${rs}px`;
|
|
174
|
+
}
|
|
175
|
+
return match;
|
|
176
|
+
});
|
|
177
|
+
decl.value = value;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const value = decl.value.replace(pxRegex, (match, p1) => {
|
|
181
|
+
if (p1 !== null && p1 !== undefined) {
|
|
182
|
+
return `${Number(p1) * 2}px`;
|
|
183
|
+
}
|
|
184
|
+
return match;
|
|
185
|
+
});
|
|
186
|
+
decl.value = value;
|
|
187
|
+
}
|
|
188
|
+
decl[rem2pxSym] = true;
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
rem2PxPlugin.postcss = true;
|
|
193
|
+
function convertLowCodesStyle(value, isUpgrade) {
|
|
194
|
+
const result = (0, postcss_1.default)([rem2PxPlugin({ isUpgrade })]).process(value.code, {
|
|
195
|
+
syntax: postcss_less_1.default,
|
|
196
|
+
});
|
|
197
|
+
value.code = result.css;
|
|
198
|
+
return value;
|
|
199
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cals",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Common application specifications",
|
|
5
5
|
"main": "lib/utils/index.js",
|
|
6
6
|
"source": "src/utils/index.ts",
|
|
@@ -31,7 +31,9 @@
|
|
|
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"
|
|
34
|
+
"lodash": "^4.17.20",
|
|
35
|
+
"postcss": "^8.4.20",
|
|
36
|
+
"postcss-less": "^6.0.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@types/acorn": "^4.0.5",
|
|
@@ -51,4 +53,4 @@
|
|
|
51
53
|
"typescript": "^4.7.4",
|
|
52
54
|
"typescript-json-schema": "^0.53.0"
|
|
53
55
|
}
|
|
54
|
-
}
|
|
56
|
+
}
|