Skip to content

Commit

Permalink
fix(logger): support set logger to null
Browse files Browse the repository at this point in the history
  • Loading branch information
Littleor committed Oct 26, 2022
1 parent 1223fa0 commit 9458f2c
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist/anyweb-js-sdk.umd.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/anyweb-js-sdk.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@idealight-labs/anyweb-js-sdk",
"description": "AnyWeb JavaScript Software Development Kit",
"version": "1.3.3",
"version": "1.3.4",
"license": "LGPL-3.0",
"author": "[email protected]",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion dist/src/interface/provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IRequestArguments {
readonly chainId?: number;
}
export interface IBaseProviderOptions {
logger?: ConsoleLike;
logger?: ConsoleLike | null;
appId: string;
global?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/src/provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ConsoleLike } from './utils/types';
* const provider = new Provider()
*/
export declare class Provider implements IProvider {
logger?: ConsoleLike;
logger: ConsoleLike | null;
readonly appId: string;
private chainId;
private static instance;
Expand Down
1 change: 1 addition & 0 deletions dist/src/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const address_1 = require("./utils/address");
*/
class Provider {
constructor({ logger = console, appId, global = false }, appUrl = 'https://app.anyweb.cc/#/') {
this.logger = console;
this.chainId = 1;
this.events = {};
if (global) {
Expand Down
2 changes: 1 addition & 1 deletion dist/src/utils/address.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export declare enum AddressType {
* @param address
* @param logger
*/
export declare const getAddressType: (address: string, logger?: ConsoleLike) => AddressType;
export declare const getAddressType: (address: string, logger?: ConsoleLike | null) => AddressType;
2 changes: 1 addition & 1 deletion dist/src/utils/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var AddressType;
*/
const getAddressType = (address, logger = console) => {
const decodeResult = (0, conflux_address_js_1.decode)(address);
logger.debug('[AnyWeb] decodeResult', decodeResult);
logger === null || logger === void 0 ? void 0 : logger.debug('[AnyWeb] decodeResult', decodeResult);
if (Object.keys(decodeResult).includes('type')) {
return decodeResult.type;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/src/utils/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export declare function sha512(str: string): string;
export declare const isObject: (obj: unknown) => boolean;
export declare const sendMessageToApp: ({ data, type, success, code, }: IIframeData) => void;
export declare const sendMessage: (localWindow: any, { data, type, success, code, message }: IIframeData) => any;
export declare const createIframe: (url: string, appUrl: string, logger?: ConsoleLike | undefined) => Promise<void>;
export declare const createIframe: (url: string, appUrl: string, logger?: ConsoleLike | null | undefined) => Promise<void>;
export declare const getIframe: (method: IMethodType, appUrl: string, params: Record<any, any>, onClose: () => void, silence?: boolean, logger?: ConsoleLike | undefined) => Promise<() => void>;
export declare const callIframe: (method: IMethodType, { appId, params, chainId, scopes, waitResult, silence, }: IIframeOptions, provider: Provider) => Promise<unknown>;
export declare const writeStorage: (key: string, content: Record<string, unknown>, expiresTime?: number) => void;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@idealight-labs/anyweb-js-sdk",
"description": "AnyWeb JavaScript Software Development Kit",
"version": "1.3.3",
"version": "1.3.4",
"license": "LGPL-3.0",
"author": "[email protected]",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/interface/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface IRequestArguments {
}

export interface IBaseProviderOptions {
logger?: ConsoleLike
logger?: ConsoleLike | null
appId: string
global?: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ConsoleLike } from './utils/types'
* const provider = new Provider()
*/
export class Provider implements IProvider {
logger?: ConsoleLike
logger: ConsoleLike | null = console
public readonly appId!: string
private chainId = 1
private static instance: Provider
Expand Down
4 changes: 2 additions & 2 deletions src/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export enum AddressType {
*/
export const getAddressType = (
address: string,
logger: ConsoleLike = console
logger: ConsoleLike | null = console
): AddressType => {
const decodeResult = decode(address)
logger.debug('[AnyWeb] decodeResult', decodeResult)
logger?.debug('[AnyWeb] decodeResult', decodeResult)
if (Object.keys(decodeResult).includes('type')) {
return decodeResult.type as AddressType
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const sendMessage = (
export const createIframe = async (
url: string,
appUrl: string,
logger?: ConsoleLike
logger?: ConsoleLike | null
) => {
logger?.debug('[AnyWeb] createIframe', url)
const mask = document.createElement('div')
Expand Down

0 comments on commit 9458f2c

Please sign in to comment.