@haluo/util 2.0.32 → 2.0.33-beta.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.
Files changed (37) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +2 -0
  3. package/dist/modules/app-call/configs.d.ts +9 -0
  4. package/dist/modules/app-call/configs.js +39 -0
  5. package/dist/modules/app-call/core.d.ts +53 -0
  6. package/dist/modules/app-call/core.js +166 -0
  7. package/dist/modules/app-call/extensions.d.ts +186 -0
  8. package/dist/modules/app-call/extensions.js +1226 -0
  9. package/dist/modules/app-call/index.d.ts +16 -0
  10. package/dist/modules/app-call/index.js +84 -0
  11. package/dist/modules/app-call/offline.d.ts +12 -0
  12. package/dist/modules/app-call/offline.js +211 -0
  13. package/dist/modules/app-call/partner-bridge.d.ts +5 -0
  14. package/dist/modules/app-call/partner-bridge.js +68 -0
  15. package/dist/modules/app-call/types.d.ts +53 -0
  16. package/dist/modules/app-call/types.js +4 -0
  17. package/dist/modules/open-app/index.d.ts +2 -7
  18. package/dist/modules/tools/index.d.ts +3 -3
  19. package/dist/modules/upload/aliOss.js +3 -1
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +1 -1
  22. package/dist/types/modules/cookie/index.d.ts +0 -27
  23. package/dist/types/modules/date/index.d.ts +0 -52
  24. package/dist/types/modules/dom/index.d.ts +0 -28
  25. package/dist/types/modules/filter/index.d.ts +0 -24
  26. package/dist/types/modules/format/index.d.ts +0 -15
  27. package/dist/types/modules/match/index.d.ts +0 -12
  28. package/dist/types/modules/monitor/index.d.ts +0 -3
  29. package/dist/types/modules/monitor/lib/jsError.d.ts +0 -1
  30. package/dist/types/modules/monitor/lib/timing.d.ts +0 -1
  31. package/dist/types/modules/monitor/lib/xhr.d.ts +0 -1
  32. package/dist/types/modules/monitor/utils/onload.d.ts +0 -1
  33. package/dist/types/modules/monitor/utils/tracker.d.ts +0 -7
  34. package/dist/types/modules/number/index.d.ts +0 -41
  35. package/dist/types/modules/sentry/index.d.ts +0 -15
  36. package/dist/types/modules/tools/index.d.ts +0 -166
  37. package/dist/types/types/index.d.ts +0 -3
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ import tools from './modules/tools';
10
10
  import upload from './modules/upload';
11
11
  import monitor from './modules/monitor';
12
12
  export * from './modules/monitor';
13
+ export * from './modules/app-call';
13
14
  interface Modules {
14
15
  cookie: typeof cookie;
15
16
  date: typeof date;
@@ -37,3 +38,4 @@ interface Utils extends Modules {
37
38
  declare const _default: Utils;
38
39
  export default _default;
39
40
  export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
41
+ export * from './modules/app-call';
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import tools from './modules/tools';
10
10
  import upload from './modules/upload';
11
11
  import monitor from './modules/monitor';
12
12
  export * from './modules/monitor';
13
+ export * from './modules/app-call';
13
14
  const modules = {
14
15
  cookie,
15
16
  date,
@@ -41,3 +42,4 @@ class Utils {
41
42
  }
42
43
  export default new Utils();
43
44
  export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
45
+ export * from './modules/app-call';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 各项目的默认配置
3
+ */
4
+ import type { AppCallConfig } from './types';
5
+ export declare const projectConfigs: Record<string, Partial<AppCallConfig>>;
6
+ /**
7
+ * 创建项目配置
8
+ */
9
+ export declare function createProjectConfig(projectType: keyof typeof projectConfigs, overrides?: Partial<AppCallConfig>): AppCallConfig;
@@ -0,0 +1,39 @@
1
+ export const projectConfigs = {
2
+ motorfans: {
3
+ projectName: '摩托范',
4
+ domain: '58moto.com',
5
+ defaultImage: 'https://wap.58moto.com/static/img/common/motuofan_small.png',
6
+ defaultDesc: '摩托范,摩托发烧友的交流的平台,摩托维修、保养、配件等知识与经验分享社区。',
7
+ supportHarmonyos: true
8
+ },
9
+ emotofine: {
10
+ projectName: '电摩范',
11
+ domain: 'emotofine.com',
12
+ defaultImage: 'https://wap.emotofine.com/static/img/common/motuofan_small.png',
13
+ defaultDesc: '电摩范,摩托发烧友的交流的平台,摩托维修、保养、配件等知识与经验分享社区。',
14
+ supportHarmonyos: true
15
+ },
16
+ iwc: {
17
+ projectName: '手表范',
18
+ domain: 'biaofine.com',
19
+ defaultImage: 'https://wap.biaofine.com/static/img/common/motuofan_small.png',
20
+ defaultDesc: '手表范,表又发烧友的交流的平台,手表维修、保养等知识与经验分享社区。'
21
+ },
22
+ dronefine: {
23
+ projectName: '无人机之家',
24
+ domain: 'dronefine.com',
25
+ defaultImage: 'https://wap.dronefine.com/static/img/common/motuofan_small.png',
26
+ defaultDesc: '无人机之家,无人机发烧友的交流的平台,无人机维修、保养、配件等知识与经验分享社区。',
27
+ supportHarmonyos: true
28
+ }
29
+ };
30
+ /**
31
+ * 创建项目配置
32
+ */
33
+ export function createProjectConfig(projectType, overrides) {
34
+ const baseConfig = projectConfigs[projectType] || projectConfigs.motorfans;
35
+ return {
36
+ ...baseConfig,
37
+ ...overrides
38
+ };
39
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * AppCall 核心实现
3
+ */
4
+ import type { AppCallConfig, AppCallCore } from './types';
5
+ declare global {
6
+ interface Window {
7
+ NativeCall?: any;
8
+ WebViewJavascriptBridge?: any;
9
+ setupWebViewJavascriptBridge?: (callback: (bridge: any) => void) => void;
10
+ WVJBCallbacks?: Array<(bridge: any) => void>;
11
+ bridge?: any;
12
+ Toast?: (options: {
13
+ position?: string;
14
+ message: string;
15
+ duration?: number;
16
+ }) => void;
17
+ isClient?: boolean;
18
+ isIOS?: boolean;
19
+ isAndroid?: boolean;
20
+ isHarmonyos?: boolean;
21
+ isWX?: boolean;
22
+ isQQ?: boolean;
23
+ isShare?: boolean;
24
+ isMiniprogram?: boolean;
25
+ isFile?: boolean;
26
+ isEmotofine?: boolean;
27
+ isBiaofine?: boolean;
28
+ isdronefine?: boolean;
29
+ AppCall?: any;
30
+ __wxjs_environment?: string;
31
+ }
32
+ }
33
+ export declare class AppCallCoreClass implements AppCallCore {
34
+ private config;
35
+ private iOSInterface;
36
+ private ua;
37
+ private isIOS;
38
+ private isAndroid;
39
+ private isHarmonyos;
40
+ private isClient;
41
+ private showTip;
42
+ constructor(config: AppCallConfig);
43
+ private initGlobalVars;
44
+ call(): any;
45
+ has(name: string): boolean;
46
+ extend(obj: Record<string, any>): AppCallCore;
47
+ callIOSHandler(name: string, params: any[], callback1?: Function): boolean;
48
+ allParamsToString(params: Record<string, any>): Record<string, string>;
49
+ setIOSInterface(interfaces: string): void;
50
+ getIOSInterface(): string;
51
+ getConfig(): AppCallConfig;
52
+ getIsClient(): boolean;
53
+ }
@@ -0,0 +1,166 @@
1
+ export class AppCallCoreClass {
2
+ config;
3
+ iOSInterface = '';
4
+ ua;
5
+ isIOS;
6
+ isAndroid;
7
+ isHarmonyos;
8
+ isClient;
9
+ showTip;
10
+ constructor(config) {
11
+ this.config = config;
12
+ this.ua = navigator.userAgent.toLowerCase();
13
+ this.isIOS = this.ua.indexOf('mac') > -1;
14
+ this.isAndroid = this.ua.indexOf('android') > -1;
15
+ this.isHarmonyos = this.ua.indexOf('harmonyos') > -1;
16
+ this.isClient =
17
+ this.ua.indexOf('motor/ios') > -1 ||
18
+ this.ua.indexOf('motor/android') > -1 ||
19
+ (this.isHarmonyos && this.ua.indexOf('motor/harmonyos') > -1) ||
20
+ location.href.includes('isClient=true');
21
+ this.showTip = config.showTip || false;
22
+ // 设置 system 属性(实例属性,在构造函数中初始化)
23
+ if (this.isIOS) {
24
+ ;
25
+ this.system = this.ua.indexOf('iphone') > -1 ? 'iPhone' : 'iOS';
26
+ }
27
+ else if (this.isAndroid || this.isHarmonyos) {
28
+ ;
29
+ this.system = 'Android';
30
+ }
31
+ this.initGlobalVars();
32
+ }
33
+ initGlobalVars() {
34
+ window.isEmotofine = location.host.includes('emotofine');
35
+ window.bridge = window.bridge || {};
36
+ window.Toast = window.Toast || (() => { });
37
+ window.isClient = location.href.includes('isClient=false') ? false : this.isClient;
38
+ window.isFile = location.href.includes('file://');
39
+ window.isIOS = this.isIOS;
40
+ window.isAndroid = this.isAndroid;
41
+ window.isHarmonyos = this.isHarmonyos;
42
+ window.isWX = this.ua.indexOf('micromessenger') > -1;
43
+ window.isQQ =
44
+ !window.isWX &&
45
+ this.ua.indexOf('micromessenger') === -1 &&
46
+ (this.ua.indexOf('qbwebviewtype') > -1 || this.ua.indexOf('qq') > -1);
47
+ window.isShare = window.location.href.indexOf('share=true') > -1;
48
+ window.isMiniprogram = this.ua.indexOf('miniprogram') > -1;
49
+ [100, 200, 500].forEach((delay) => {
50
+ setTimeout(() => {
51
+ window.isMiniprogram = window.__wxjs_environment === 'miniprogram';
52
+ }, delay);
53
+ });
54
+ }
55
+ call() {
56
+ const arr = [...arguments];
57
+ const name = arr.shift();
58
+ let callback;
59
+ let data;
60
+ if (!this.isClient) {
61
+ return;
62
+ }
63
+ // 提取回调函数
64
+ if (arr.length > 0 && typeof arr[arr.length - 1] === 'function') {
65
+ callback = arr.pop();
66
+ }
67
+ else {
68
+ callback = function () { };
69
+ }
70
+ if (this.showTip && window.Toast) {
71
+ window.Toast({
72
+ position: 'top',
73
+ message: `请求方法名:${name}:${JSON.stringify(arr)}`
74
+ });
75
+ }
76
+ try {
77
+ if (this.isAndroid || this.isHarmonyos) {
78
+ if (this.has(name)) {
79
+ data = window.NativeCall?.[name]?.apply(window.NativeCall, arr) || null;
80
+ if (this.showTip && window.Toast) {
81
+ window.Toast({
82
+ position: 'middle',
83
+ message: '方法已回调:' + (data || '安卓无返回信息'),
84
+ duration: 5000
85
+ });
86
+ }
87
+ if (data && typeof callback === 'function') {
88
+ callback(data);
89
+ }
90
+ return data;
91
+ }
92
+ }
93
+ else if (this.isIOS) {
94
+ if (this.has(name)) {
95
+ return this.callIOSHandler(name, arr, callback);
96
+ }
97
+ }
98
+ }
99
+ catch (error) {
100
+ if (this.showTip && window.Toast) {
101
+ window.Toast({
102
+ position: 'middle',
103
+ message: String(error),
104
+ duration: 5000
105
+ });
106
+ }
107
+ }
108
+ return false;
109
+ }
110
+ has(name) {
111
+ if (this.isAndroid || this.isHarmonyos) {
112
+ return !!(window.NativeCall && window.NativeCall[name]);
113
+ }
114
+ else if (this.isIOS && this.iOSInterface && this.iOSInterface.indexOf(name) > -1) {
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+ extend(obj) {
120
+ for (const key in obj) {
121
+ ;
122
+ this[key] = obj[key];
123
+ }
124
+ return this;
125
+ }
126
+ callIOSHandler(name, params, callback1) {
127
+ const obj = {};
128
+ for (let i = 0; i < params.length; i++) {
129
+ obj['arg' + (i + 1)] = params[i];
130
+ }
131
+ if (this.showTip && window.Toast) {
132
+ setTimeout(() => {
133
+ window.Toast?.({
134
+ position: 'top',
135
+ message: `请求方法名及参数:${name}:${JSON.stringify(obj)}`
136
+ });
137
+ }, 50);
138
+ }
139
+ if (this.isIOS && window.setupWebViewJavascriptBridge) {
140
+ window.setupWebViewJavascriptBridge((bridge) => {
141
+ bridge.callHandler(name, obj, callback1);
142
+ });
143
+ return true;
144
+ }
145
+ return false;
146
+ }
147
+ allParamsToString(params) {
148
+ const keys = Object.keys(params);
149
+ keys.forEach((key) => {
150
+ params[key] = String(params[key]);
151
+ });
152
+ return params;
153
+ }
154
+ setIOSInterface(interfaces) {
155
+ this.iOSInterface = interfaces;
156
+ }
157
+ getIOSInterface() {
158
+ return this.iOSInterface;
159
+ }
160
+ getConfig() {
161
+ return this.config;
162
+ }
163
+ getIsClient() {
164
+ return this.isClient;
165
+ }
166
+ }
@@ -0,0 +1,186 @@
1
+ /**
2
+ * AppCall 所有扩展方法
3
+ * 整合了所有项目的扩展方法,供所有项目共享使用
4
+ */
5
+ import type { AppCallInstance, AppCallConfig } from './types';
6
+ /**
7
+ * 创建所有扩展方法
8
+ */
9
+ export declare function createAllExtensions(appCall: AppCallInstance, config: AppCallConfig): {
10
+ selectDeliveryAddress(data: any): any;
11
+ paySuccess(on: boolean): any;
12
+ pay(params?: any): any;
13
+ payNew(params?: any): any;
14
+ alert(text: any): any;
15
+ hideTitle(on: boolean): any;
16
+ setHeadState(type: any): any;
17
+ open(url: string, title?: string): any;
18
+ close(): any;
19
+ back(step?: number): any;
20
+ openAppStoreUrl(params: any): any;
21
+ openOtherAppUrlRouter(params: {
22
+ appScheme?: string;
23
+ appStoreUrl?: string;
24
+ appUrlRouter: string;
25
+ appBundleId?: string;
26
+ }): any;
27
+ setTitle(title?: string): void;
28
+ haloService(params?: any): any;
29
+ qiyuService(params?: any): any;
30
+ voteSuccess(params?: any): any;
31
+ openMotorStylePhotosPage(carData: any): any;
32
+ seeImageViewer(imageData: any): any;
33
+ saveImg(imgUrl: string): any;
34
+ saveImgData(imgUrl: string, callback?: ((res: any) => void) | undefined): any;
35
+ modifyShare(data: any, callback?: ((res: any) => void) | undefined): any;
36
+ carDetail(detail: any): void;
37
+ newCircle(obj: any): void;
38
+ publishWatchExperience(obj: any): any;
39
+ navigate(action?: any): any;
40
+ navigateByEnergy(action: any): any;
41
+ messageInteraction(action?: any): any;
42
+ getReservePrice(action?: any): any;
43
+ decryptAgencyPhone(action?: any): any;
44
+ bookTestDrive(action?: any): any;
45
+ getYZAccessToken(): any;
46
+ openShareLayer(type?: string): any;
47
+ openNewShareLayer(type: string): any;
48
+ openCarScore(params: any): any;
49
+ share(params?: any): void;
50
+ goShare(params: any): any;
51
+ goShareImageData(params: any): any;
52
+ shareText(params: any): any;
53
+ shareActivity(id: number | string): void;
54
+ report(params: any): any;
55
+ vehicleCertification(params?: any): any;
56
+ /**
57
+ * ios 打开上传图片,解决ios黑版本的选择图片问题,现已没有此问题,暂时不用
58
+ * type = all img\all 弹出上传图片或预览, img直接上传
59
+ * num = 1个数 ,限制 1
60
+ */
61
+ iosOpenInput(params?: any): any;
62
+ getOSPhotosWithCount(params: any): any;
63
+ setOSPhotosSelectType(params: any): any;
64
+ goToComment(params: any): any;
65
+ informationData(detail: any): void;
66
+ setEncryption(params: any): Promise<unknown>;
67
+ mapNavigation(params: any): any;
68
+ showMapNavigation(params: any): any;
69
+ navigationRightArea(params: any): any;
70
+ uploadVideo(params: any): any;
71
+ getProvinces(params: any): any;
72
+ setLocationPermission(): any;
73
+ postDurationTack(params: any): void;
74
+ goPersonalLetter(params: any): any;
75
+ notificationMessage(params: any): any;
76
+ setSafetyStatus(): any;
77
+ setRefreshShopOrder(): any;
78
+ requestAdvideo(action?: any): any;
79
+ openMall(action?: any): any;
80
+ priceCustomerService(params?: any): any;
81
+ shopWechat(params?: any): any;
82
+ getQueryInfo(callback?: ((data: any) => void) | undefined): any;
83
+ saveQueryInfo(params: any): any;
84
+ jumpToReleaseStory(params?: any): any;
85
+ jumpToReleaseStoryUgc(params?: any): any;
86
+ jumpToReleaseVideo(params?: any): any;
87
+ /**
88
+ * 改变电池栏颜色
89
+ * type(1、黑色;2、白色)
90
+ */
91
+ changeStatusBarColor(params?: any): any;
92
+ navigationGrowOfficer(): any;
93
+ navigationMall(): any;
94
+ navigationEnergyMall(): any;
95
+ navigationCoupon(params?: any): any;
96
+ navigationSelectAddress(callback?: ((data: any) => void) | undefined): any;
97
+ liveSignResultCall(params?: any): any;
98
+ navigationDelivery(params?: any): any;
99
+ articleHtmlAction(action?: any, callback?: ((res: any) => void) | undefined): any;
100
+ getOfflinePackageVersion(action?: any, callback?: ((res: any) => void) | undefined): any;
101
+ getDroneEmList(parmas: any, callback?: ((res: any) => void) | undefined): any;
102
+ toRefitWebView(params: any): any;
103
+ navigateRealPersonCertification(action?: any): any;
104
+ secondHandReporterComplete(): any;
105
+ viewHistoryCount(day: number): any;
106
+ searchHistoryCount(): any;
107
+ mnPositionNavigation(params?: any): any;
108
+ mnSiteSelection(params?: any): any;
109
+ jumpApplet(url?: string): any;
110
+ mnPositionSelection(params?: any): any;
111
+ commentOfficerTab(params?: any): any;
112
+ jumpCyclingRoute(params?: any): any;
113
+ jumpPunchPoint(params?: any): any;
114
+ interactivePopEnable(params?: number): any;
115
+ interactiveSideslip(params?: number): any;
116
+ getStoreKey(params: any, callback?: ((res: any) => void) | undefined): void;
117
+ setStoreKeyValue(params: any, callback?: ((res: any) => void) | undefined): void;
118
+ selectImageToUpload(callback?: ((res: any) => void) | undefined): void;
119
+ uploadImageFinish(params: any): void;
120
+ request(params: {
121
+ method?: string | undefined;
122
+ url: string;
123
+ hash?: number | undefined;
124
+ params?: any;
125
+ callback?: ((res: any) => void) | undefined;
126
+ }): any;
127
+ replaceJsonValue(str: string): string;
128
+ getUserData(callback?: ((data: any) => void) | undefined): any;
129
+ getUserDataDriving(callback?: ((data: any) => void) | undefined): any;
130
+ getDeviceData(callback?: ((data: any) => void) | undefined): any;
131
+ getLocation(params?: {
132
+ needPermission?: number;
133
+ }): void;
134
+ getAppPlatform(): any;
135
+ getAppPackage(): any;
136
+ getAppVersion(): any;
137
+ isAppVersionGreatThan(version: string): boolean;
138
+ setStatusBarColor(color: string): any;
139
+ haloMallCustomer(): any;
140
+ launchEmallMiniProgramWithUrl(data: any): any;
141
+ launchEmallMiniProgram(): any;
142
+ changeOrientation(params: any): any;
143
+ watchInOut(type: number): any;
144
+ hasNetwork(): Promise<number>;
145
+ sendEventMsg({ eId, eventContent }: {
146
+ eId: string;
147
+ eventContent: any;
148
+ }): Promise<any>;
149
+ hasNewQuestions(callback: (res: any) => void): any;
150
+ updateQuestions(params: any, callback?: ((res: any) => void) | undefined): any;
151
+ goPersonPage(params: any): any;
152
+ goCommentDetail(params: any): any;
153
+ reportComment(params: any): any;
154
+ getDrivingTestImage(params?: {
155
+ item: {
156
+ _id: string;
157
+ pic?: string;
158
+ };
159
+ }, callback?: ((base64Img: string) => void) | undefined): any;
160
+ drivetestFeedbackAction(params: any): any;
161
+ drivetestContactService(params: any): any;
162
+ drivetestDealerCredentials(params: any): any;
163
+ drivetestWechatAndCall(params: any): any;
164
+ boolIsLogin(callback: (res: any) => void): any;
165
+ loginSucessGoon(callback: (res: any) => void): any;
166
+ drivetestGetQueryInfo(callback: (res: any) => void): any;
167
+ drivertestOneKeyBlindMobile(callback: (res: any) => void): any;
168
+ priceProtocolDefault(callback: (res: any) => void): any;
169
+ getGarageLocation(callback: (res: any) => void): any;
170
+ drivetestGetAdAndBuinessData(params: any, callback: (res: any) => void): any;
171
+ checkLocationEnable(callback: (res: any) => void): any;
172
+ checkLocationPermission(callback: (res: any) => void): any;
173
+ jumpToLocationSetting(callback: (res: any) => void): any;
174
+ drivetestGetAdBanner(params: any, callback: (res: any) => void): any;
175
+ getDayNightStyle(callback: (res: any) => void): any;
176
+ onBackAction(callback: (res: any) => void): any;
177
+ getStatusBarHeight(params: any, callback: (res: any) => void): any;
178
+ loadLocalWeb(params?: any): any;
179
+ getExamVipQuestions(params: any, callback?: ((res: any) => void) | undefined): any;
180
+ saveEmCoupon(params?: any): any;
181
+ getEmCoupon(params: any, callback?: ((res: any) => void) | undefined): any;
182
+ getUserWinInfo(params: any): any;
183
+ login(params?: Record<string, any>): any;
184
+ register(callback?: ((data: any) => void) | undefined): any;
185
+ closeAccount(): any;
186
+ };