@fgz/wxmini-sdk 1.0.0 → 1.0.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/dist/index.d.cts CHANGED
@@ -472,6 +472,38 @@ interface WxMiniAppInfo {
472
472
  appId?: string;
473
473
  appSecret?: string;
474
474
  }
475
+ interface UserProfileDto {
476
+ nickName?: string;
477
+ gender?: number;
478
+ language?: string;
479
+ city?: string;
480
+ province?: string;
481
+ country?: string;
482
+ avatarUrl?: string;
483
+ is_demote?: boolean;
484
+ }
485
+ interface PhoneNumDto {
486
+ encryptedData?: string;
487
+ code?: string;
488
+ iv?: string;
489
+ appId?: string;
490
+ }
491
+ interface ScanCodeDto {
492
+ /** 所扫码的内容 */
493
+ result?: string;
494
+ /** 所扫码的类型 */
495
+ scanType?: string;
496
+ /** 所扫码的字符集 */
497
+ charSet?: string;
498
+ /** 当所扫的码为当前小程序二维码时,会返回此字段,内容为二维码携带的 path */
499
+ path?: string;
500
+ /** 原始数据,base64编码 */
501
+ rawData?: string;
502
+ }
503
+ interface ReadLocalFileDto {
504
+ /** 文件内容 */
505
+ data?: string | ArrayBuffer;
506
+ }
475
507
  interface GetUserProfileOptions extends BaseOptions {
476
508
  /** 显示在确认授权对话框里的文字信息 */
477
509
  message: string;
@@ -660,11 +692,11 @@ declare class WxMiniApi {
660
692
  /**
661
693
  * 通过微信小程序接口, 获取用户信息(昵称/头像等)
662
694
  */
663
- getUserProfile(opts: GetUserProfileOptions): Promise<string>;
695
+ getUserProfile(opts: GetUserProfileOptions): Promise<UserProfileDto>;
664
696
  /**
665
697
  * 通过微信小程序接口,获取用户手机号码
666
698
  */
667
- getPhoneNum(opts: GetPhoneNumOptions): Promise<string>;
699
+ getPhoneNum(opts: GetPhoneNumOptions): Promise<PhoneNumDto>;
668
700
  /**
669
701
  * 拨打电话
670
702
  */
@@ -676,12 +708,12 @@ declare class WxMiniApi {
676
708
  /**
677
709
  * 扫描二维码,返回二维码内容
678
710
  */
679
- scanCode(opts?: BaseOptions): Promise<string>;
711
+ scanCode(opts?: BaseOptions): Promise<ScanCodeDto>;
680
712
  /**
681
713
  * 读取本地文件内容
682
714
  * @warning 文件超过 60K 会导致链接中断,适合小文件
683
715
  */
684
- readLocalFile(opts: ReadLocalFileOptions): Promise<string>;
716
+ readLocalFile(opts: ReadLocalFileOptions): Promise<ReadLocalFileDto>;
685
717
  /**
686
718
  * 下载文件,返回临时文件路径
687
719
  */
@@ -745,15 +777,15 @@ declare class WxMiniApi {
745
777
  /**
746
778
  * 保存扩展的工程配置参数到小程序本地(页面启动时会自动合并传入)
747
779
  */
748
- saveExtProjectConfig(opts: SaveExtProjectConfigOptions): Promise<void>;
780
+ private saveExtProjectConfig;
749
781
  /**
750
782
  * 读取保存在小程序本地的扩展工程配置参数
751
783
  */
752
- loadExtProjectConfig(opts?: BaseOptions): Promise<Record<string, string>>;
784
+ private loadExtProjectConfig;
753
785
  /**
754
786
  * 查询小程序 App 的 GlobalData
755
787
  */
756
- queryAppGlobalData<T = any>(opts?: BaseOptions): Promise<T>;
788
+ private queryAppGlobalData;
757
789
  /**
758
790
  * 设置分享页信息(用于分享转发,全局一份)
759
791
  */
@@ -884,4 +916,4 @@ declare function getPlatform(): string;
884
916
  /** 获取浏览器名称 */
885
917
  declare function getBrowserName(): string;
886
918
 
887
- export { type BaseOptions, BinBlock, Bytes, CRpcCallbackCmd, CRpcCallbackRsp, CRpcFeCmd, CRpcFeRsp, type ChooseLocationOptions, type ChooseMediaOptions, type ChooseMessageFileOptions, type ConnectOptions, Cson, CsonBean, CsonPojo, type DownloadFileOptions, FeAbilityExecuteException, FeException, FeJavaException, FePojo, FeWxMiniCmdException, type GetLocationOptions, type GetPhoneNumOptions, type GetUserProfileOptions, type GpsLocationDto, IWxMiniBridgeService, JavaFactory, type MakePhoneCallOptions, type NavigateBackOptions, type NavigateToOptions, NullPojo, type OpenDocumentOptions, type OpenLocationOptions, PartitionTable, PingResult, PingStatus, QuerySceneFromWxMiniParams, QueryWxMiniParam, type ReLaunchOptions, type ReadLocalFileOptions, type RedirectToOptions, RpcCodec, type SaveExtProjectConfigOptions, type SaveToAlbumOptions, type ServerCallbackHandler, type SetClipboardDataOptions, type SetSharePageMessageOptions, type ShareFileMessageOptions, type ShowShareImageMenuOptions, type StartAudioRecordOptions, SystemCallback, type UploadFileOptions, type UserProfileQueryType, Utils, ValuePojo, WebSocketConnectError, WebSocketError, WsClient, WsService, type WxLocalFile, WxMiniApi, type WxMiniApiConfig, type WxMiniAppInfo, WxMiniBridge, WxMiniBridgeCommand, WxMiniCmd, WxMiniCommand, WxMiniConfigDto, type WxSharePageInfo, clients, getBrowserName, getPlatform, isTouchDevice, isWxMiniprogram };
919
+ export { type BaseOptions, BinBlock, Bytes, CRpcCallbackCmd, CRpcCallbackRsp, CRpcFeCmd, CRpcFeRsp, type ChooseLocationOptions, type ChooseMediaOptions, type ChooseMessageFileOptions, type ConnectOptions, Cson, CsonBean, CsonPojo, type DownloadFileOptions, FeAbilityExecuteException, FeException, FeJavaException, FePojo, FeWxMiniCmdException, type GetLocationOptions, type GetPhoneNumOptions, type GetUserProfileOptions, type GpsLocationDto, IWxMiniBridgeService, JavaFactory, type MakePhoneCallOptions, type NavigateBackOptions, type NavigateToOptions, NullPojo, type OpenDocumentOptions, type OpenLocationOptions, PartitionTable, type PhoneNumDto, PingResult, PingStatus, QuerySceneFromWxMiniParams, QueryWxMiniParam, type ReLaunchOptions, type ReadLocalFileDto, type ReadLocalFileOptions, type RedirectToOptions, RpcCodec, type SaveExtProjectConfigOptions, type SaveToAlbumOptions, type ScanCodeDto, type ServerCallbackHandler, type SetClipboardDataOptions, type SetSharePageMessageOptions, type ShareFileMessageOptions, type ShowShareImageMenuOptions, type StartAudioRecordOptions, SystemCallback, type UploadFileOptions, type UserProfileDto, type UserProfileQueryType, Utils, ValuePojo, WebSocketConnectError, WebSocketError, WsClient, WsService, type WxLocalFile, WxMiniApi, type WxMiniApiConfig, type WxMiniAppInfo, WxMiniBridge, WxMiniBridgeCommand, WxMiniCmd, WxMiniCommand, WxMiniConfigDto, type WxSharePageInfo, clients, getBrowserName, getPlatform, isTouchDevice, isWxMiniprogram };
package/dist/index.d.ts CHANGED
@@ -472,6 +472,38 @@ interface WxMiniAppInfo {
472
472
  appId?: string;
473
473
  appSecret?: string;
474
474
  }
475
+ interface UserProfileDto {
476
+ nickName?: string;
477
+ gender?: number;
478
+ language?: string;
479
+ city?: string;
480
+ province?: string;
481
+ country?: string;
482
+ avatarUrl?: string;
483
+ is_demote?: boolean;
484
+ }
485
+ interface PhoneNumDto {
486
+ encryptedData?: string;
487
+ code?: string;
488
+ iv?: string;
489
+ appId?: string;
490
+ }
491
+ interface ScanCodeDto {
492
+ /** 所扫码的内容 */
493
+ result?: string;
494
+ /** 所扫码的类型 */
495
+ scanType?: string;
496
+ /** 所扫码的字符集 */
497
+ charSet?: string;
498
+ /** 当所扫的码为当前小程序二维码时,会返回此字段,内容为二维码携带的 path */
499
+ path?: string;
500
+ /** 原始数据,base64编码 */
501
+ rawData?: string;
502
+ }
503
+ interface ReadLocalFileDto {
504
+ /** 文件内容 */
505
+ data?: string | ArrayBuffer;
506
+ }
475
507
  interface GetUserProfileOptions extends BaseOptions {
476
508
  /** 显示在确认授权对话框里的文字信息 */
477
509
  message: string;
@@ -660,11 +692,11 @@ declare class WxMiniApi {
660
692
  /**
661
693
  * 通过微信小程序接口, 获取用户信息(昵称/头像等)
662
694
  */
663
- getUserProfile(opts: GetUserProfileOptions): Promise<string>;
695
+ getUserProfile(opts: GetUserProfileOptions): Promise<UserProfileDto>;
664
696
  /**
665
697
  * 通过微信小程序接口,获取用户手机号码
666
698
  */
667
- getPhoneNum(opts: GetPhoneNumOptions): Promise<string>;
699
+ getPhoneNum(opts: GetPhoneNumOptions): Promise<PhoneNumDto>;
668
700
  /**
669
701
  * 拨打电话
670
702
  */
@@ -676,12 +708,12 @@ declare class WxMiniApi {
676
708
  /**
677
709
  * 扫描二维码,返回二维码内容
678
710
  */
679
- scanCode(opts?: BaseOptions): Promise<string>;
711
+ scanCode(opts?: BaseOptions): Promise<ScanCodeDto>;
680
712
  /**
681
713
  * 读取本地文件内容
682
714
  * @warning 文件超过 60K 会导致链接中断,适合小文件
683
715
  */
684
- readLocalFile(opts: ReadLocalFileOptions): Promise<string>;
716
+ readLocalFile(opts: ReadLocalFileOptions): Promise<ReadLocalFileDto>;
685
717
  /**
686
718
  * 下载文件,返回临时文件路径
687
719
  */
@@ -745,15 +777,15 @@ declare class WxMiniApi {
745
777
  /**
746
778
  * 保存扩展的工程配置参数到小程序本地(页面启动时会自动合并传入)
747
779
  */
748
- saveExtProjectConfig(opts: SaveExtProjectConfigOptions): Promise<void>;
780
+ private saveExtProjectConfig;
749
781
  /**
750
782
  * 读取保存在小程序本地的扩展工程配置参数
751
783
  */
752
- loadExtProjectConfig(opts?: BaseOptions): Promise<Record<string, string>>;
784
+ private loadExtProjectConfig;
753
785
  /**
754
786
  * 查询小程序 App 的 GlobalData
755
787
  */
756
- queryAppGlobalData<T = any>(opts?: BaseOptions): Promise<T>;
788
+ private queryAppGlobalData;
757
789
  /**
758
790
  * 设置分享页信息(用于分享转发,全局一份)
759
791
  */
@@ -884,4 +916,4 @@ declare function getPlatform(): string;
884
916
  /** 获取浏览器名称 */
885
917
  declare function getBrowserName(): string;
886
918
 
887
- export { type BaseOptions, BinBlock, Bytes, CRpcCallbackCmd, CRpcCallbackRsp, CRpcFeCmd, CRpcFeRsp, type ChooseLocationOptions, type ChooseMediaOptions, type ChooseMessageFileOptions, type ConnectOptions, Cson, CsonBean, CsonPojo, type DownloadFileOptions, FeAbilityExecuteException, FeException, FeJavaException, FePojo, FeWxMiniCmdException, type GetLocationOptions, type GetPhoneNumOptions, type GetUserProfileOptions, type GpsLocationDto, IWxMiniBridgeService, JavaFactory, type MakePhoneCallOptions, type NavigateBackOptions, type NavigateToOptions, NullPojo, type OpenDocumentOptions, type OpenLocationOptions, PartitionTable, PingResult, PingStatus, QuerySceneFromWxMiniParams, QueryWxMiniParam, type ReLaunchOptions, type ReadLocalFileOptions, type RedirectToOptions, RpcCodec, type SaveExtProjectConfigOptions, type SaveToAlbumOptions, type ServerCallbackHandler, type SetClipboardDataOptions, type SetSharePageMessageOptions, type ShareFileMessageOptions, type ShowShareImageMenuOptions, type StartAudioRecordOptions, SystemCallback, type UploadFileOptions, type UserProfileQueryType, Utils, ValuePojo, WebSocketConnectError, WebSocketError, WsClient, WsService, type WxLocalFile, WxMiniApi, type WxMiniApiConfig, type WxMiniAppInfo, WxMiniBridge, WxMiniBridgeCommand, WxMiniCmd, WxMiniCommand, WxMiniConfigDto, type WxSharePageInfo, clients, getBrowserName, getPlatform, isTouchDevice, isWxMiniprogram };
919
+ export { type BaseOptions, BinBlock, Bytes, CRpcCallbackCmd, CRpcCallbackRsp, CRpcFeCmd, CRpcFeRsp, type ChooseLocationOptions, type ChooseMediaOptions, type ChooseMessageFileOptions, type ConnectOptions, Cson, CsonBean, CsonPojo, type DownloadFileOptions, FeAbilityExecuteException, FeException, FeJavaException, FePojo, FeWxMiniCmdException, type GetLocationOptions, type GetPhoneNumOptions, type GetUserProfileOptions, type GpsLocationDto, IWxMiniBridgeService, JavaFactory, type MakePhoneCallOptions, type NavigateBackOptions, type NavigateToOptions, NullPojo, type OpenDocumentOptions, type OpenLocationOptions, PartitionTable, type PhoneNumDto, PingResult, PingStatus, QuerySceneFromWxMiniParams, QueryWxMiniParam, type ReLaunchOptions, type ReadLocalFileDto, type ReadLocalFileOptions, type RedirectToOptions, RpcCodec, type SaveExtProjectConfigOptions, type SaveToAlbumOptions, type ScanCodeDto, type ServerCallbackHandler, type SetClipboardDataOptions, type SetSharePageMessageOptions, type ShareFileMessageOptions, type ShowShareImageMenuOptions, type StartAudioRecordOptions, SystemCallback, type UploadFileOptions, type UserProfileDto, type UserProfileQueryType, Utils, ValuePojo, WebSocketConnectError, WebSocketError, WsClient, WsService, type WxLocalFile, WxMiniApi, type WxMiniApiConfig, type WxMiniAppInfo, WxMiniBridge, WxMiniBridgeCommand, WxMiniCmd, WxMiniCommand, WxMiniConfigDto, type WxSharePageInfo, clients, getBrowserName, getPlatform, isTouchDevice, isWxMiniprogram };
package/dist/index.js CHANGED
@@ -1250,7 +1250,14 @@ var WxMiniBridge = class {
1250
1250
  try {
1251
1251
  const jsonMap = JSON.parse(result);
1252
1252
  if (isWxMiniBridgeCommandResult(jsonMap)) {
1253
- return jsonMap.data;
1253
+ let data = jsonMap.data;
1254
+ if (typeof data === "string") {
1255
+ try {
1256
+ data = JSON.parse(data);
1257
+ } catch (e) {
1258
+ }
1259
+ }
1260
+ return data;
1254
1261
  }
1255
1262
  } catch (error) {
1256
1263
  }
@@ -1443,7 +1450,7 @@ var WxMiniApi = class {
1443
1450
  [WxMiniCommand.getUserProfile_BUTTON]: opts.buttonLabel,
1444
1451
  [WxMiniCommand.getUserProfile_QUERY_TYPE]: opts.type ?? "All"
1445
1452
  });
1446
- return this.execute(command);
1453
+ return this.executeAs(command);
1447
1454
  }
1448
1455
  // ========================= 手机号 =========================
1449
1456
  /**
@@ -1455,7 +1462,7 @@ var WxMiniApi = class {
1455
1462
  [WxMiniCommand.getPhoneNum_BUTTON]: opts.buttonLabel,
1456
1463
  [WxMiniCommand.getPhoneNum_REJECT_BUTTON]: opts.rejectButtonLabel ?? null
1457
1464
  });
1458
- return this.execute(command);
1465
+ return this.executeAs(command);
1459
1466
  }
1460
1467
  // ========================= 拨打电话 =========================
1461
1468
  /**
@@ -1496,7 +1503,7 @@ var WxMiniApi = class {
1496
1503
  */
1497
1504
  async scanCode(opts = {}) {
1498
1505
  const command = buildCmd("scanCode" /* scanCode */, opts);
1499
- return this.execute(command);
1506
+ return this.executeAs(command);
1500
1507
  }
1501
1508
  // ========================= 文件操作 =========================
1502
1509
  /**
@@ -1507,7 +1514,7 @@ var WxMiniApi = class {
1507
1514
  const command = buildCmd("readLocalFile" /* readLocalFile */, opts, {
1508
1515
  [WxMiniCommand.PARAM_FILE_PATH]: opts.filePath
1509
1516
  });
1510
- return this.execute(command);
1517
+ return this.executeAs(command);
1511
1518
  }
1512
1519
  /**
1513
1520
  * 下载文件,返回临时文件路径