@polyvharmony/live-scenes-foundation 1.2.0-rc.1
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/CHANGELOG.md +21 -0
- package/Index.d.ets +30 -0
- package/Index.js +28 -0
- package/LICENSE +8 -0
- package/README.md +21 -0
- package/ResourceTable.txt +16 -0
- package/libs/plvjsbridge.har +0 -0
- package/libs/plvsocket.har +0 -0
- package/obfuscation.txt +4 -0
- package/oh-package.json5 +1 -0
- package/package.json +1 -0
- package/src/main/ets/common/IPLVBackwardInterface.d.ets +5 -0
- package/src/main/ets/common/IPLVBackwardInterface.js +1 -0
- package/src/main/ets/common/PLVBasicDataSource.d.ets +30 -0
- package/src/main/ets/common/PLVBasicDataSource.js +172 -0
- package/src/main/ets/common/PLVCallback.d.ets +52 -0
- package/src/main/ets/common/PLVCallback.js +128 -0
- package/src/main/ets/common/PLVCommonConstants.d.ets +13 -0
- package/src/main/ets/common/PLVCommonConstants.js +10 -0
- package/src/main/ets/common/PLVCommonEnums.d.ets +19 -0
- package/src/main/ets/common/PLVCommonEnums.js +22 -0
- package/src/main/ets/common/PLVDeviceUtils.d.ets +4 -0
- package/src/main/ets/common/PLVDeviceUtils.js +9 -0
- package/src/main/ets/common/PLVHashMap.d.ets +4 -0
- package/src/main/ets/common/PLVHashMap.js +7 -0
- package/src/main/ets/common/PLVJSONUtils.d.ets +21 -0
- package/src/main/ets/common/PLVJSONUtils.js +103 -0
- package/src/main/ets/common/PLVNetUtils.d.ets +5 -0
- package/src/main/ets/common/PLVNetUtils.js +29 -0
- package/src/main/ets/common/PLVPreferencesUtils.d.ets +58 -0
- package/src/main/ets/common/PLVPreferencesUtils.js +30 -0
- package/src/main/ets/common/PLVScheduledTask.d.ets +12 -0
- package/src/main/ets/common/PLVScheduledTask.js +44 -0
- package/src/main/ets/common/PLVSimpleBuffer.d.ets +11 -0
- package/src/main/ets/common/PLVSimpleBuffer.js +30 -0
- package/src/main/ets/common/PLVTextUtils.d.ets +9 -0
- package/src/main/ets/common/PLVTextUtils.js +73 -0
- package/src/main/ets/common/PLVTimeUtils.d.ets +8 -0
- package/src/main/ets/common/PLVTimeUtils.js +14 -0
- package/src/main/ets/common/PLVToastUtils.d.ets +7 -0
- package/src/main/ets/common/PLVToastUtils.js +17 -0
- package/src/main/ets/common/PLVType.d.ets +8 -0
- package/src/main/ets/common/PLVType.js +1 -0
- package/src/main/ets/common/PLVUACreator.d.ets +3 -0
- package/src/main/ets/common/PLVUACreator.js +11 -0
- package/src/main/ets/common/PLVUtils.d.ets +25 -0
- package/src/main/ets/common/PLVUtils.js +197 -0
- package/src/main/ets/common/PLVWebUtils.d.ets +6 -0
- package/src/main/ets/common/PLVWebUtils.js +79 -0
- package/src/main/ets/modules/log/PLVLogger.d.ets +20 -0
- package/src/main/ets/modules/log/PLVLogger.js +67 -0
- package/src/main/ets/modules/log/PLVXLogFilePrinter.d.ets +12 -0
- package/src/main/ets/modules/log/PLVXLogFilePrinter.js +37 -0
- package/src/main/ets/modules/log/PLVXLogWorker.d.ets +1 -0
- package/src/main/ets/modules/log/PLVXLogWorker.js +4 -0
- package/src/main/ets/modules/net/PLVApiConstants.d.ets +7 -0
- package/src/main/ets/modules/net/PLVApiConstants.js +7 -0
- package/src/main/ets/modules/net/PLVHttpData.d.ets +8 -0
- package/src/main/ets/modules/net/PLVHttpData.js +8 -0
- package/src/main/ets/modules/net/PLVHttpError.d.ets +5 -0
- package/src/main/ets/modules/net/PLVHttpError.js +13 -0
- package/src/main/ets/modules/net/PLVHttpRequest.d.ets +25 -0
- package/src/main/ets/modules/net/PLVHttpRequest.js +147 -0
- package/src/main/ets/modules/net/PLVRequestSetting.d.ets +9 -0
- package/src/main/ets/modules/net/PLVRequestSetting.js +33 -0
- package/src/main/ets/modules/socket/PLVSocketIO.d.ets +50 -0
- package/src/main/ets/modules/socket/PLVSocketIO.js +164 -0
- package/src/main/ets/modules/web/PLVFailureLayout.d.ets +5 -0
- package/src/main/ets/modules/web/PLVFailureLayout.js +77 -0
- package/src/main/ets/modules/web/PLVLoadingLayout.d.ets +4 -0
- package/src/main/ets/modules/web/PLVLoadingLayout.js +46 -0
- package/src/main/ets/modules/web/PLVNewWindowLayout.d.ets +8 -0
- package/src/main/ets/modules/web/PLVNewWindowLayout.js +62 -0
- package/src/main/ets/modules/web/PLVSimpleWeb.d.ets +14 -0
- package/src/main/ets/modules/web/PLVSimpleWeb.js +260 -0
- package/src/main/ets/modules/web/PLVWebController.d.ets +86 -0
- package/src/main/ets/modules/web/PLVWebController.js +275 -0
- package/src/main/ets/modules/web/PLVWebModel.d.ets +30 -0
- package/src/main/ets/modules/web/PLVWebModel.js +1 -0
- package/src/main/module.json +28 -0
- package/src/main/resources/base/element/color.json +12 -0
- package/src/main/resources/base/element/float.json +40 -0
- package/src/main/resources/base/element/string.json +12 -0
- package/src/main/resources/base/media/plv_web_ic_failure.svg +30 -0
- package/src/main/resources/en_US/element/string.json +12 -0
- package/src/main/resources/zh_CN/element/string.json +12 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { instanceToPlain, plainToClass, plainToClassFromExist } from 'class-transformer';
|
|
2
|
+
export default class PLVJSONUtils {
|
|
3
|
+
static safeStringify(value, replacer) {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.stringify(value || new Object(), replacer);
|
|
6
|
+
}
|
|
7
|
+
catch (e) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
static safeParse(text) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(text || '');
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
static json2Bean(f3, g3) {
|
|
20
|
+
try {
|
|
21
|
+
return plainToClass(f3, JSON.parse(g3), {
|
|
22
|
+
enableImplicitConversion: false, exposeDefaultValues: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
static bean2Json(data) {
|
|
30
|
+
try {
|
|
31
|
+
if (data == null || data == undefined) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
return JSON.stringify(instanceToPlain(data));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static bean2Bean(e3, plain) {
|
|
41
|
+
try {
|
|
42
|
+
return plainToClassFromExist(e3, plain, {
|
|
43
|
+
enableImplicitConversion: false, exposeDefaultValues: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static httpData2Bean(d3, plain) {
|
|
51
|
+
try {
|
|
52
|
+
plain.data = plainToClassFromExist(d3, plain.data, {
|
|
53
|
+
enableImplicitConversion: false, exposeDefaultValues: true
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
plain.data.fill();
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
}
|
|
60
|
+
return plain.data;
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static json2Map(c3) {
|
|
67
|
+
return new Map(Object.entries(JSON.parse(c3)));
|
|
68
|
+
}
|
|
69
|
+
static object2Map(object) {
|
|
70
|
+
return new Map(Object.entries(object));
|
|
71
|
+
}
|
|
72
|
+
static map2json(map) {
|
|
73
|
+
const obj = {};
|
|
74
|
+
map.forEach((value, key) => {
|
|
75
|
+
if (key && value) {
|
|
76
|
+
obj[key] = value;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return obj;
|
|
80
|
+
}
|
|
81
|
+
static map2jsonStr(map, replacer) {
|
|
82
|
+
return PLVJSONUtils.safeStringify(PLVJSONUtils.map2json(map), replacer);
|
|
83
|
+
}
|
|
84
|
+
static toUnescapedData(a3) {
|
|
85
|
+
if (!a3.includes('\\')) {
|
|
86
|
+
return a3;
|
|
87
|
+
}
|
|
88
|
+
return a3.substring(1, a3.length - 1)
|
|
89
|
+
.replace(/\\"/g, '"')
|
|
90
|
+
.replace(/\\\\/g, '\\');
|
|
91
|
+
}
|
|
92
|
+
static toFillData(v2, w2) {
|
|
93
|
+
let z2 = undefined;
|
|
94
|
+
if (typeof w2 === 'string') {
|
|
95
|
+
z2 = PLVJSONUtils.json2Bean(v2, w2);
|
|
96
|
+
}
|
|
97
|
+
else if (typeof w2 === 'object') {
|
|
98
|
+
z2 = PLVJSONUtils.bean2Bean(v2, w2);
|
|
99
|
+
}
|
|
100
|
+
z2?.fill();
|
|
101
|
+
return z2;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class PLVNetUtils {
|
|
2
|
+
static replaceUrl(k3, l3) {
|
|
3
|
+
const m3 = /{(\w+?)}/g;
|
|
4
|
+
let match;
|
|
5
|
+
let n3 = k3;
|
|
6
|
+
while ((match = m3.exec(k3)) !== null) {
|
|
7
|
+
const key = match[1];
|
|
8
|
+
const p3 = l3.get(key);
|
|
9
|
+
if (p3 !== undefined) {
|
|
10
|
+
n3 = n3.replace(match[0], p3);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return n3;
|
|
14
|
+
}
|
|
15
|
+
static formatUrl(j3, record) {
|
|
16
|
+
return PLVNetUtils.replaceUrl(j3, new Map(Object.entries(record)));
|
|
17
|
+
}
|
|
18
|
+
static formatParams(params) {
|
|
19
|
+
let h3 = '';
|
|
20
|
+
if (params) {
|
|
21
|
+
Object.entries(params).forEach((value, index) => {
|
|
22
|
+
if (value?.[0] && value?.[1]) {
|
|
23
|
+
h3 += (index == 0 ? '?' : '&') + value?.[0] + '=' + value?.[1];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return h3;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { preferences } from '@kit.ArkData';
|
|
2
|
+
export declare class PLVPreferencesUtils {
|
|
3
|
+
private constructor();
|
|
4
|
+
/**
|
|
5
|
+
* 将数据缓存
|
|
6
|
+
* @param key
|
|
7
|
+
* @param value
|
|
8
|
+
* @param preferenceName
|
|
9
|
+
*/
|
|
10
|
+
static put(key: string, value: preferences.ValueType, x3?: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* 获取缓存值
|
|
13
|
+
* @param key
|
|
14
|
+
* @param defValue
|
|
15
|
+
* @param preferenceName
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
static get(key: string, defValue: preferences.ValueType, w3?: string): Promise<preferences.ValueType>;
|
|
19
|
+
/**
|
|
20
|
+
* 获取string类型的缓存值
|
|
21
|
+
* @param key
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
static getString(key: string, v3?: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取number类型的缓存值
|
|
27
|
+
* @param key
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
static getNumber(key: string, u3?: string, defaultValue?: number): Promise<number>;
|
|
31
|
+
/**
|
|
32
|
+
* 获取boolean类型的缓存值
|
|
33
|
+
* @param key
|
|
34
|
+
* @param preferenceName
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
static getBoolean(key: string, t3?: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* 检查缓存的Preferences实例中是否包含名为给定Key的存储键值对
|
|
40
|
+
* @param key
|
|
41
|
+
* @param preferenceName
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
static has(key: string, s3?: string): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* 删除缓存值
|
|
47
|
+
* @param key
|
|
48
|
+
* @param preferenceName
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
static delete(key: string, r3?: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* 清空缓存
|
|
54
|
+
* @param preferenceName
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
static clear(q3?: string): Promise<void>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PreferencesUtil } from '@pura/harmony-utils';
|
|
2
|
+
const defaultPreferenceName = "PLV_SP_HARMONY_UTILS_PREFERENCES";
|
|
3
|
+
export class PLVPreferencesUtils {
|
|
4
|
+
constructor() {
|
|
5
|
+
}
|
|
6
|
+
static async put(key, value, x3 = defaultPreferenceName) {
|
|
7
|
+
await PreferencesUtil.put(key, value, x3);
|
|
8
|
+
}
|
|
9
|
+
static async get(key, defValue, w3 = defaultPreferenceName) {
|
|
10
|
+
return PreferencesUtil.get(key, defValue, w3);
|
|
11
|
+
}
|
|
12
|
+
static async getString(key, v3 = defaultPreferenceName) {
|
|
13
|
+
return (await PreferencesUtil.get(key, "", v3));
|
|
14
|
+
}
|
|
15
|
+
static async getNumber(key, u3 = defaultPreferenceName, defaultValue = 0) {
|
|
16
|
+
return (await PreferencesUtil.get(key, defaultValue, u3));
|
|
17
|
+
}
|
|
18
|
+
static async getBoolean(key, t3 = defaultPreferenceName) {
|
|
19
|
+
return (await PreferencesUtil.get(key, false, t3));
|
|
20
|
+
}
|
|
21
|
+
static async has(key, s3 = defaultPreferenceName) {
|
|
22
|
+
return PreferencesUtil.has(key, s3);
|
|
23
|
+
}
|
|
24
|
+
static async delete(key, r3 = defaultPreferenceName) {
|
|
25
|
+
return PreferencesUtil.delete(key, r3);
|
|
26
|
+
}
|
|
27
|
+
static async clear(q3 = defaultPreferenceName) {
|
|
28
|
+
return PreferencesUtil.clear(q3);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class PLVScheduledTask {
|
|
2
|
+
callback: Function;
|
|
3
|
+
delay: number;
|
|
4
|
+
period: number;
|
|
5
|
+
timerId?: number;
|
|
6
|
+
nextExecutionTime: number;
|
|
7
|
+
isRunning: boolean;
|
|
8
|
+
constructor(callback: Function, delay: number, period?: number);
|
|
9
|
+
start(): void;
|
|
10
|
+
scheduleNextExecution(): Promise<void>;
|
|
11
|
+
cancel(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import PLVLogger from '../modules/log/PLVLogger';
|
|
2
|
+
const TAG = '[PLVScheduledTask]';
|
|
3
|
+
export class PLVScheduledTask {
|
|
4
|
+
constructor(callback, delay, period = delay) {
|
|
5
|
+
this.callback = callback;
|
|
6
|
+
this.delay = delay;
|
|
7
|
+
this.period = period;
|
|
8
|
+
this.timerId = undefined;
|
|
9
|
+
this.nextExecutionTime = 0;
|
|
10
|
+
this.isRunning = false;
|
|
11
|
+
}
|
|
12
|
+
start() {
|
|
13
|
+
if (this.isRunning) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.isRunning = true;
|
|
17
|
+
this.nextExecutionTime = Date.now() + this.delay;
|
|
18
|
+
this.scheduleNextExecution();
|
|
19
|
+
}
|
|
20
|
+
async scheduleNextExecution() {
|
|
21
|
+
if (!this.isRunning) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
const y3 = Math.max(0, this.nextExecutionTime - now);
|
|
26
|
+
this.timerId = setTimeout(async () => {
|
|
27
|
+
try {
|
|
28
|
+
await this.callback();
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
PLVLogger.printError(TAG, 'scheduleNextExecution error', error);
|
|
32
|
+
}
|
|
33
|
+
this.nextExecutionTime = Date.now() + this.period;
|
|
34
|
+
this.scheduleNextExecution();
|
|
35
|
+
}, y3);
|
|
36
|
+
}
|
|
37
|
+
cancel() {
|
|
38
|
+
if (!this.isRunning) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
clearTimeout(this.timerId);
|
|
42
|
+
this.isRunning = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PLVCallback } from './PLVCallback';
|
|
2
|
+
export declare class PLVSimpleBuffer<T> {
|
|
3
|
+
private buffer;
|
|
4
|
+
private intervalId?;
|
|
5
|
+
private timespan;
|
|
6
|
+
private isRelease;
|
|
7
|
+
constructor(d4?: number);
|
|
8
|
+
observe(callback?: PLVCallback<T[]>): void;
|
|
9
|
+
release(): void;
|
|
10
|
+
push(b4: T): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const a4 = 500;
|
|
2
|
+
export class PLVSimpleBuffer {
|
|
3
|
+
constructor(d4 = a4) {
|
|
4
|
+
this.buffer = [];
|
|
5
|
+
this.timespan = a4;
|
|
6
|
+
this.isRelease = false;
|
|
7
|
+
this.timespan = d4;
|
|
8
|
+
}
|
|
9
|
+
observe(callback) {
|
|
10
|
+
if (this.intervalId == undefined) {
|
|
11
|
+
this.intervalId = setInterval(() => {
|
|
12
|
+
if (this.buffer.length > 0) {
|
|
13
|
+
callback?.(this.buffer);
|
|
14
|
+
this.buffer.length = 0;
|
|
15
|
+
}
|
|
16
|
+
}, this.timespan);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
release() {
|
|
20
|
+
this.isRelease = true;
|
|
21
|
+
clearInterval(this.intervalId);
|
|
22
|
+
this.buffer.length = 0;
|
|
23
|
+
}
|
|
24
|
+
push(b4) {
|
|
25
|
+
if (this.isRelease) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.buffer.push(b4);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class PLVTextUtils {
|
|
2
|
+
static checkValidDataLength(...str: string[]): boolean;
|
|
3
|
+
static parseString(input?: string): string[];
|
|
4
|
+
static convertSpecialString(input?: string): string;
|
|
5
|
+
static toString(num?: number): string | undefined;
|
|
6
|
+
static toWString(data?: number): string | undefined;
|
|
7
|
+
static fixPic(f4?: string): string;
|
|
8
|
+
static isNumberZero(number?: string): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export class PLVTextUtils {
|
|
2
|
+
static checkValidDataLength(...str) {
|
|
3
|
+
for (const s of str) {
|
|
4
|
+
if (s.length == 0) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
static parseString(input) {
|
|
11
|
+
if (!(input = PLVTextUtils.convertSpecialString(input))) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const g4 = /\[([^\[\]]{1,5})\]/g;
|
|
15
|
+
let match;
|
|
16
|
+
let h4 = 0;
|
|
17
|
+
const result = [];
|
|
18
|
+
while ((match = g4.exec(input)) !== null) {
|
|
19
|
+
const j4 = match[0];
|
|
20
|
+
if (match.index > h4) {
|
|
21
|
+
const k4 = input.slice(h4, match.index);
|
|
22
|
+
result.push(k4);
|
|
23
|
+
}
|
|
24
|
+
result.push(j4);
|
|
25
|
+
h4 = g4.lastIndex;
|
|
26
|
+
}
|
|
27
|
+
if (h4 < input.length) {
|
|
28
|
+
const i4 = input.slice(h4);
|
|
29
|
+
result.push(i4);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
static convertSpecialString(input) {
|
|
34
|
+
return input?.replace(/</g, "<")
|
|
35
|
+
.replace(/</g, "<")
|
|
36
|
+
.replace(/>/g, ">")
|
|
37
|
+
.replace(/>/g, ">")
|
|
38
|
+
.replace(/¥/g, "¥")
|
|
39
|
+
.replace(/¥/g, "¥")
|
|
40
|
+
.replace(/"/g, "\"")
|
|
41
|
+
.replace(/ /g, " ")
|
|
42
|
+
.replace(/'/g, "'")
|
|
43
|
+
.replace(/&/g, "&");
|
|
44
|
+
}
|
|
45
|
+
static toString(num) {
|
|
46
|
+
return (num || num == 0) ? num + '' : undefined;
|
|
47
|
+
}
|
|
48
|
+
static toWString(data) {
|
|
49
|
+
if (data && data > 10000) {
|
|
50
|
+
return (data / 10000).toFixed(1) + 'w';
|
|
51
|
+
}
|
|
52
|
+
return PLVTextUtils.toString(data);
|
|
53
|
+
}
|
|
54
|
+
static fixPic(f4) {
|
|
55
|
+
if (!f4) {
|
|
56
|
+
return f4 || '';
|
|
57
|
+
}
|
|
58
|
+
if (f4.startsWith('//')) {
|
|
59
|
+
return `http:${f4}`;
|
|
60
|
+
}
|
|
61
|
+
else if (f4.startsWith('/')) {
|
|
62
|
+
return `http://livestatic.videocc.net${f4}`;
|
|
63
|
+
}
|
|
64
|
+
return f4;
|
|
65
|
+
}
|
|
66
|
+
static isNumberZero(number) {
|
|
67
|
+
if (!number) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
const e4 = parseFloat(number);
|
|
71
|
+
return e4 === 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class PLVTimeUtils {
|
|
2
|
+
static generateTime(l4, m4) {
|
|
3
|
+
const n4 = Math.floor(l4 / 1000);
|
|
4
|
+
const o4 = n4 % 60;
|
|
5
|
+
const p4 = Math.floor((n4 / 60) % 60);
|
|
6
|
+
const q4 = Math.floor(n4 / 3600);
|
|
7
|
+
if (m4 || q4 > 0) {
|
|
8
|
+
return `${q4.toString().padStart(2, '0')}:${p4.toString().padStart(2, '0')}:${o4.toString().padStart(2, '0')}`;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return `${p4.toString().padStart(2, '0')}:${o4.toString().padStart(2, '0')}`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import promptAction from "@ohos.promptAction";
|
|
2
|
+
import PLVCommonConstants from './PLVCommonConstants';
|
|
3
|
+
export class PLVToastUtils {
|
|
4
|
+
shortShow(message) {
|
|
5
|
+
this.show(message, PLVCommonConstants.LENGTH_SHORT);
|
|
6
|
+
}
|
|
7
|
+
longShow(message) {
|
|
8
|
+
this.show(message, PLVCommonConstants.LENGTH_LONG);
|
|
9
|
+
}
|
|
10
|
+
show(message, duration) {
|
|
11
|
+
promptAction.showToast({
|
|
12
|
+
message: message,
|
|
13
|
+
duration: duration
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export default new PLVToastUtils();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosResponse } from '@ohos/axios';
|
|
2
|
+
import { PLVHttpData } from '../modules/net/PLVHttpData';
|
|
3
|
+
export type PLVResponseObject = AxiosResponse<object>;
|
|
4
|
+
export type PLVResponseData<T> = AxiosResponse<PLVHttpData<T>>;
|
|
5
|
+
export type PLVResponse<T> = PLVResponseData<T> | void;
|
|
6
|
+
export type PLVJSONObject = Record<string, Object | undefined>;
|
|
7
|
+
export type PLVResolve<T> = (value: T | PromiseLike<T>) => void;
|
|
8
|
+
export type PLVReject = (reason?: object) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import deviceInfo from '@ohos.deviceInfo';
|
|
2
|
+
export class PLVUACreator {
|
|
3
|
+
static createUA(r4, s4) {
|
|
4
|
+
let t4 = r4;
|
|
5
|
+
if (s4) {
|
|
6
|
+
t4 += `(${s4})`;
|
|
7
|
+
}
|
|
8
|
+
t4 += ` ohos/${deviceInfo.osFullName} (HarmonyOS ${deviceInfo.osFullName}; ${deviceInfo.brand} ${deviceInfo.productModel};)`;
|
|
9
|
+
return t4;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PLVCallback, PLVCallback2, PLVDisposable } from './PLVCallback';
|
|
2
|
+
import { common } from '@kit.AbilityKit';
|
|
3
|
+
import { window } from '@kit.ArkUI';
|
|
4
|
+
import { PLVReject, PLVResolve } from './PLVType';
|
|
5
|
+
export default class PLVUtils {
|
|
6
|
+
private constructor();
|
|
7
|
+
static init(context: common.UIAbilityContext, windowStage: window.WindowStage): void;
|
|
8
|
+
static getClassTag(tag?: string | Object, f6?: boolean): string | undefined;
|
|
9
|
+
static retryWhen<T = void>(when: PLVCallback<void, T>, retry: PLVCallback<void, T>): Promise<Awaited<T>>;
|
|
10
|
+
static disposablePromise<T>(promise: Promise<T>, e6?: PLVDisposable): Promise<T>;
|
|
11
|
+
static safePromise<T = void>(callback: PLVCallback2<PLVResolve<T>, PLVReject, void>, a6?: PLVDisposable): Promise<T>;
|
|
12
|
+
static retryPromise<T>(w5: number, x5: number, promise: Promise<T>, y5?: PLVDisposable): Promise<T>;
|
|
13
|
+
static delay(delay?: number): Promise<void>;
|
|
14
|
+
static validCallback(callback: string): boolean;
|
|
15
|
+
static getPid(): string;
|
|
16
|
+
static getDeviceId(): string;
|
|
17
|
+
static undefinedToValue<T>(data: T, callback: PLVCallback<T, void>, delay?: number): undefined;
|
|
18
|
+
static copyText(text: string): Promise<void>;
|
|
19
|
+
static changeOrientation(m5: boolean, component?: Object, n5?: window.Window): void;
|
|
20
|
+
static isLandscape(component?: Object): boolean;
|
|
21
|
+
static setWindowFullScreen(isLayoutFullScreen?: boolean, isFullScreen?: boolean, component?: Object, c5?: window.Window): Promise<Object[]>;
|
|
22
|
+
static startScan(component?: Object): Promise<string>;
|
|
23
|
+
static getVideoRectJS(w4: boolean): string;
|
|
24
|
+
static getExitFullScreenJS(u4: boolean): string;
|
|
25
|
+
}
|