From beb72e43089f2607e43608deb8884225a0a82221 Mon Sep 17 00:00:00 2001
From: xjccc <546534045@qq.com>
Date: Thu, 15 Jun 2023 17:49:55 +0800
Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=BE=AE?=
=?UTF-8?q?=E4=BF=A1=E6=8B=89=E8=B5=B7app\=E5=B0=8F=E7=A8=8B=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 2 +
README.md | 169 +++++++++++++++++++++++++++++++++++++++++++--
package.json | 20 +-----
src/browser.ts | 8 ++-
src/evoke.ts | 2 +-
src/generate.ts | 58 +++++++++++++++-
src/index.ts | 160 ++++++++++++++++++++++++++++++++++++++++--
src/types.ts | 42 ++++++++++-
types/globals.d.ts | 7 ++
9 files changed, 436 insertions(+), 32 deletions(-)
diff --git a/.gitignore b/.gitignore
index 33a7995..8bec2c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ node_modules
package-lock.json
dist
+
+pnpm-lock.yaml
\ No newline at end of file
diff --git a/README.md b/README.md
index 509144b..c2d3e76 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,71 @@ callLib.open({
});
```
+## 微信原生标签使用
+
+```html
+
+
+
+```
+
+```js
+const options = {
+ key1: 'xxx',
+ key2: 'xxx',
+};
+const lib = new CallApp(options);
+
+> 如果使用该方法,需要提供挂载标签,提前进行注册,非click时调用
+
+lib.signup([
+ {
+ id: 'open-app',
+ path: '',
+ height?: '40',
+ param?: {
+ type: 'article',
+ id: 163355,
+ }
+ },
+ {
+ id: 'open-minapp',
+ type: 'minapp', // 'app' | 'minapp' 默认'app'
+ path: '',
+ height?: '40px',
+ appid?: '', // 所需跳转的小程序appid,即小程序对应的以wx开头的id, 不写使用weappId
+ username?: '', // 所需跳转的小程序原始id,即小程序对应的以gh_开头的id(跳转时,有appid会优先使用appid,没有appid才会使用username)
+ wePath?: '', // 所需跳转的小程序内页面路径及参数
+ envVersion?: 'release' | 'devlop' | 'trial'; // 跳转小程序版本 默认 release
+ extraData?: '' // 以JSON格式字符串向所需跳转的小程序传递数据
+ }
+]);
+```
+
## 答疑
对常见的一些问题进行了[汇总](https://www.yuque.com/egm961/nmf9nm/llbg79),如果这些问答无法解决你的疑惑,加钉钉群,按照提问模板进行提问
@@ -176,11 +241,34 @@ APP 的 App Store 地址,例: `https://itunes.apple.com/cn/app/id1383186862`
APP 的应用宝地址,例:`'//a.app.qq.com/o/simple.jsp?pkgname=com.youku.shortvideo'`。如果不填写,则安卓微信中会直接跳转 fallback
+### useWxNative
+
+类型:`boolean`
+必填: ❎
+默认:true
+
+拉起其他 app,默认微信端使用微信原生标签,微信版本 `8.0.8` 以上版本支持使用
+
+### wxAppid
+
+类型:`string`
+必填: ❎
+
+useWxNative: true, 微信内使用原生标签注册,必填。否则不需要
+
+### weappId
+
+类型:`string`
+必填: ❎
+
+全局微信小程序 appid
+
### isSupportWeibo
类型: `boolean`
-必填: ❎
+必填: ❎
默认值: false
+
是否支持微博,默认不支持
### timeout
@@ -204,13 +292,15 @@ APP 的应用宝地址,例:`'//a.app.qq.com/o/simple.jsp?pkgname=com.youku.s
必填: ❎
```js
-(status: 'pending' | 'failure') => void;
+(status: 'pending' | 'failure', wxTagFailure?) => void;
```
埋点入口函数。运营同学可能会希望我们在唤端的时候做埋点,将你的埋点函数传递进来,不管唤端成功与否,它都会被执行。当然,你也可以将这个函数另作他用。
这个回调函数会回执行两次,第一次是触发 open 方法,第二次是唤端失败,它有一个入参 status ,它有两个值 `pending` 和 `failure`,分别代表函数触发及唤端失败。
+在微信标签使用中,触发时机是唤端`wx.error|唤端失败`wxTagFailure 返回相应信息,唤端失败返回微信返回的失败信息。wx.error 返回`{errMsg: 'error'}`
+
### buildScheme
类型: `function`
@@ -226,7 +316,7 @@ url scheme 自定义拼接函数,内置的 buildScheme 函数是按照 uri 规
- path
- 类型: `string`
+ 类型: `string`
必填: ✅
需要打开的页面对应的值,URL Scheme 中的 path 部分,参照 [H5 唤起 APP 指南](https://suanmei.github.io/2018/08/23/h5_call_app/) 一文中的解释。
@@ -241,8 +331,8 @@ url scheme 自定义拼接函数,内置的 buildScheme 函数是按照 uri 规
打开 APP 某个页面,它需要接收的参数。
- callback
- 必填: ❎
+ 必填: ❎
类型: `function`
自定义唤端失败回调函数。传递 `callback` 会覆盖 _callapp-lib_ 库中默认的唤端失败处理逻辑。
@@ -266,6 +356,77 @@ url scheme 自定义拼接函数,内置的 buildScheme 函数是按照 uri 规
生成 Universal Link,接收参数同 `generateScheme` 方法参数。
+### signup
+
+在微信环境下使用`微信原生标签`进行 app 跳转,其他环境下进行 dom 的点击事件绑定`open`方法
+[微信公众号满足条件](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_H5_Launch_APP.html)
+需要微信 jssdk [1.6.0](https://res.wx.qq.com/open/js/jweixin-1.6.0.js) 版本以上
+
+注意拉起 app:
+
+1. wx 注册 config 需要绑定的公众号
+2. 域名需要开放平台绑定的域名
+3. 微信注册 config 需要添加`openTagList: ['wx-open-launch-app', 'wx-open-launch-weapp']`
+
+> 拉起小程序,仅需保证是安全域名
+
+- id
+
+ 必填:✅
+
+ 用于微信自定义标签插入,最好根据父级进行定位,如果跳转失败会给该元素绑定点击事件(lib.open)
+
+- height
+
+ 必填:❎
+ 默认:40px
+
+ 必须设置高度,无固定高度无法点击跳转
+
+> 其他参数同 open 方法
+
+注意拉起小程序:
+
+- type
+
+ 必填: ❎
+ 默认: 'app'
+
+ 拉起小程序需要改成'minapp'
+
+ > 非微信环境,minapp 不会注册事件
+
+- appid
+
+ 必填: ❎
+
+ 所需跳转的小程序 appid,即小程序对应的以 wx 开头的 id, 不写使用 weappId
+
+- username
+
+ 必填: ❎
+
+ 所需跳转的小程序原始 id,即小程序对应的以 gh\_开头的 id(跳转时,有 appid 会优先使用 appid,没有 appid 才会使用 username)
+
+- wePath?: ''
+
+ 必填: ❎
+
+ 所需跳转的小程序内页面路径及参数
+
+- env
+
+ 必填: ❎
+ 默认: 'release'
+
+ 'release' | 'develop' | 'trial'
+
+- extraData
+
+ 必填: ❎
+
+ 默认传入 object, 会进行 encodeURIComponent 处理,以 JSON 格式字符串向所需跳转的小程序传递数据。小程序可在 App.onLaunch、App.onShow 等中获取;小游戏可在 wx.onAppShow、wx.getLaunchOptionsSync 等中获取(支持的微信版本:iOS 8.0.18 及以上、Android 8.0.19 及以上)
+
## 打赏
如果刚好解决了你的问题,如果你心情还不错,如果尚有余粮,可以给作者打赏一杯咖啡哦,爱宁~
diff --git a/package.json b/package.json
index bf3ee77..fa1fda0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "callapp-lib",
- "version": "3.5.3",
+ "version": "3.5.4",
"description": "call native webview from webpage",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
@@ -9,9 +9,7 @@
"directories": {
"dist": "dist"
},
- "files": [
- "dist"
- ],
+ "files": ["dist"],
"scripts": {
"lint-eslint": "eslint --cache --ext .ts ./src",
"check-types": "tsc --noEmit",
@@ -29,16 +27,7 @@
"type": "git",
"url": "git+https://github.com/suanmei/callapp-lib.git"
},
- "keywords": [
- "rollup",
- "callapp",
- "schema",
- "scheme",
- "universalLink",
- "intent",
- "native",
- "h5"
- ],
+ "keywords": ["rollup", "callapp", "schema", "scheme", "universalLink", "intent", "native", "h5"],
"author": {
"name": "suanmei",
"email": "code_lee@sina.com",
@@ -71,8 +60,5 @@
"prettier": "^2.0.5",
"rollup": "^2.15.0",
"typescript": "^3.9.5"
- },
- "dependencies": {
- "http-server": "^14.1.0"
}
}
diff --git a/src/browser.ts b/src/browser.ts
index 8e5197a..0fa7c1b 100644
--- a/src/browser.ts
+++ b/src/browser.ts
@@ -26,7 +26,7 @@ export const semverCompare = (verionA: string, versionB: string): -1 | 0 | 1 =>
* 获取 ios 大版本号
*/
export const getIOSVersion = (): number => {
- const version = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/) as string[];
+ const version = navigator.appVersion.match(/[ ,OSX] (\d+)_(\d+)_?(\d+)?/) as string[];
return Number.parseInt(version[1], 10);
};
@@ -40,7 +40,11 @@ export const getWeChatVersion = (): string => {
export const isAndroid = /android/i.test(ua);
-export const isIos = /iphone|ipad|ipod/i.test(ua);
+export const isIos = /iphone|ipod/i.test(ua);
+
+export const isIpad =
+ navigator.userAgent.match(/(iPad)/) ||
+ (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
export const isWechat = /micromessenger\/([\d.]+)/i.test(ua);
diff --git a/src/evoke.ts b/src/evoke.ts
index 146f438..a10bec2 100644
--- a/src/evoke.ts
+++ b/src/evoke.ts
@@ -62,7 +62,7 @@ export function evokeByIFrame(uri: string): void {
if (!iframe) {
iframe = document.createElement('iframe');
iframe.style.cssText = 'display:none;border:0;width:0;height:0;';
- document.body.appendChild(iframe);
+ document.body.append(iframe);
}
iframe.src = uri;
diff --git a/src/generate.ts b/src/generate.ts
index 6c496e8..1e0cf24 100644
--- a/src/generate.ts
+++ b/src/generate.ts
@@ -1,4 +1,4 @@
-import { CallappConfig, CallappOptions, Intent } from './types';
+import { CallappConfig, CallappOptions, Intent, WeappConfig, WxTagOption } from './types';
// 根据 param 生成 queryString
function generateQS(param?: Record): string {
@@ -86,3 +86,59 @@ export function generateYingYongBao(config: CallappConfig, options: CallappOptio
// 支持 AppLink
return `${options.yingyongbao}&android_schema=${encodeURIComponent(url)}`;
}
+
+function transformUnit(val: string) {
+ if (!/[a-z]$/.test(val)) {
+ val += 'px';
+ }
+ return val;
+}
+
+// 生成微信tag
+export function generateWxTag(
+ config: CallappConfig & WxTagOption,
+ options: CallappOptions
+): string {
+ const { id, height = '40px', btnText = '立即打开' } = config;
+ const { wxAppid } = options;
+ const h = transformUnit(height);
+ return `
+
+ `;
+}
+
+// 生成微信小程序tag
+export function generateWeappTag(config: WeappConfig, options: CallappOptions): string {
+ const {
+ id,
+ height = '40px',
+ appid,
+ wePath,
+ username,
+ env,
+ extraData,
+ btnText = '打开小程序',
+ } = config;
+ const { weappId } = options;
+ if (!weappId && !appid) {
+ throw new Error('need weapp appid');
+ }
+ const h = transformUnit(height);
+ const extra =
+ extraData && (typeof extraData === 'string' ? extraData : encodeURIComponent(extraData));
+ return `
+
+ `;
+}
diff --git a/src/index.ts b/src/index.ts
index 4cc5437..6249949 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,14 +1,26 @@
import * as Browser from './browser';
import * as generate from './generate';
import { evokeByLocation, evokeByTagA, evokeByIFrame, checkOpen } from './evoke';
-import { CallappConfig, CallappOptions } from './types';
+import {
+ CallappConfig,
+ CallappOptions,
+ WxTagFailure,
+ WxTagErrorEvent,
+ DomListType,
+ WxTagOption,
+ WeappConfig,
+} from './types';
class CallApp {
private readonly options: CallappOptions & { timeout: number };
+ private domList: DomListType[] = [];
+
+ private hasApp = false;
+
// Create an instance of CallApp
constructor(options: CallappOptions) {
- const defaultOptions = { timeout: 2000 };
+ const defaultOptions = { useWxNative: true, timeout: 2000 };
this.options = Object.assign(defaultOptions, options);
}
@@ -32,6 +44,14 @@ class CallApp {
return generate.generateYingYongBao(config, this.options);
}
+ public generateWxTag(config: CallappConfig & WxTagOption): string {
+ return generate.generateWxTag(config, this.options);
+ }
+
+ public generateWeappTag(config: CallappConfig & WeappConfig): string {
+ return generate.generateWeappTag(config, this.options);
+ }
+
checkOpen(failure: () => void): void {
const { logFunc, timeout } = this.options;
@@ -65,6 +85,129 @@ class CallApp {
});
}
+ wxTagFailure(reason: WxTagFailure | undefined): void {
+ const { logFunc } = this.options;
+ if (typeof logFunc !== 'undefined') {
+ logFunc('failure', reason);
+ }
+ }
+
+ signup(config: (CallappConfig & WeappConfig) | Array): void {
+ const { useWxNative, wxAppid } = this.options;
+ if (Browser.isWechat && useWxNative && !wxAppid) {
+ throw new Error('use wx-tag need wxAppid in the options');
+ }
+
+ const list = !Array.isArray(config) ? [config] : config;
+ const domList: DomListType[] = [];
+ list.forEach((c) => this.registeDom(c, domList));
+ // 注册微信打开app
+ this.registeWxApp(domList);
+
+ if (!useWxNative || !window.wx) return;
+
+ wx.error(() => {
+ this.wxTagFailure({
+ errMsg: 'wx register fail',
+ });
+ });
+
+ document.addEventListener('WeixinOpenTagsError', (e: Event & WxTagErrorEvent) => {
+ // 无法使用开放标签的错误原因,需回退兼容。仅无法使用开放标签,JS-SDK其他功能不受影响
+ this.wxTagFailure(e.detail);
+ });
+ }
+
+ registeDom(config: CallappConfig & WeappConfig, domList: DomListType[]): DomListType[] {
+ if (!config.id) {
+ throw new Error('use dom you need id parameter to register');
+ }
+ if (config.type === 'minapp' && !config.appid && !this.options.weappId) {
+ throw new Error('minapp need appid');
+ }
+ const dom = document.querySelector(`#${config.id}`);
+ if (!dom) {
+ throw new Error(`make sure the dom by #${config.id} is exists`);
+ }
+ const index = this.domList.findIndex((obj) => obj.config.id === config.id);
+ if (index !== -1) {
+ throw new Error(`the #${config.id} is not only`);
+ }
+ config.type = config.type ?? 'app';
+ if (config.type === 'minapp') {
+ config.env = config.env ?? 'release';
+ config.appid = config.appid ?? this.options.weappId;
+ }
+
+ const obj = {
+ btn: dom as HTMLElement,
+ type: config.type,
+ config,
+ isRegister: false,
+ isWxNativeReady: false,
+ };
+ domList.push(obj);
+ return domList;
+ }
+
+ // dom事件注册
+ bindClickEvent(obj: DomListType): void {
+ if (!obj.isRegister && obj.type === 'app') {
+ obj.btn.addEventListener('click', () => {
+ const notUseWxNative = Browser.isWechat && !this.options.useWxNative;
+ const wxNativeError = Browser.isWechat && !this.hasApp;
+ const ready = Browser.isWechat && this.options.useWxNative && obj.isWxNativeReady;
+ if (ready) return;
+ if (!Browser.isWechat || notUseWxNative || wxNativeError) {
+ this.open(obj.config);
+ }
+ });
+ obj.isRegister = true;
+ }
+ }
+
+ registeWxApp(domList: DomListType[]): void {
+ if (!Browser.isWechat) {
+ domList.forEach((obj) => {
+ this.bindClickEvent(obj);
+ });
+ return;
+ }
+
+ const tagType = {
+ app: 'generateWxTag',
+ minapp: 'generateWeappTag',
+ } as const;
+ wx.ready(() => {
+ domList.forEach((obj) => {
+ this.bindClickEvent(obj);
+ if (!this.options.useWxNative && obj.type === 'app') return;
+
+ const { btn, type } = obj;
+ btn.innerHTML = this[tagType[type]](obj.config);
+ const wxBtn = btn.firstChild as HTMLElement;
+
+ wxBtn.addEventListener('ready', () => {
+ obj.isWxNativeReady = true;
+ });
+ // e: Event & WxTagErrorEvent
+ wxBtn.addEventListener('launch', () => {
+ if (obj.type === 'app') {
+ this.hasApp = true;
+ }
+ });
+ wxBtn.addEventListener('error', (e: Event & WxTagErrorEvent) => {
+ // 如果微信打开失败,证明没有应用,在ios需要打开app store。不能跳转universal link
+ this.wxTagFailure(e.detail);
+ if (type === 'app') {
+ this.hasApp = false;
+ this.open(obj.config);
+ }
+ });
+ });
+ });
+ }
+
/**
* 唤起客户端
* 根据不同 browser 执行不同唤端策略
@@ -79,15 +222,17 @@ class CallApp {
if (typeof logFunc !== 'undefined') {
logFunc('pending');
}
+
const isSupportWeibo = !!this.options.isSupportWeibo;
- if (Browser.isIos) {
+ if (Browser.isIos || Browser.isIpad) {
// ios qq 禁止了 universalLink 唤起app,安卓不受影响 - 18年12月23日
// ios qq 浏览器禁止了 universalLink - 19年5月1日
// ios 微信自 7.0.5 版本放开了 Universal Link 的限制
// ios 微博禁止了 universalLink
if (
(Browser.isWechat && Browser.semverCompare(Browser.getWeChatVersion(), '7.0.5') === -1) ||
- (Browser.isWeibo && !isSupportWeibo)
+ (Browser.isWeibo && !isSupportWeibo) ||
+ (Browser.isWechat && this.options.useWxNative && !this.hasApp)
) {
evokeByLocation(appstore);
} else if (Browser.getIOSVersion() < 9) {
@@ -111,7 +256,12 @@ class CallApp {
evokeByLocation(schemeURL);
checkOpenFall = this.fallToFbUrl;
}
- } else if (Browser.isWechat || Browser.isBaidu || (Browser.isWeibo && !isSupportWeibo) || Browser.isQzone) {
+ } else if (
+ Browser.isWechat ||
+ Browser.isBaidu ||
+ (Browser.isWeibo && !isSupportWeibo) ||
+ Browser.isQzone
+ ) {
evokeByLocation(this.options.fallback);
} else {
evokeByIFrame(schemeURL);
diff --git a/src/types.ts b/src/types.ts
index f60918a..bbb2710 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -4,6 +4,41 @@ export interface CallappConfig> {
callback?: () => void;
}
+export interface WxTagOption {
+ id: string;
+ type?: 'app' | 'minapp';
+ height?: string;
+ btnText?: string;
+}
+
+export interface WeappConfig extends WxTagOption {
+ appid?: string;
+ username?: string;
+ wePath?: string;
+ env?: 'release' | 'develop' | 'trial';
+ extraData?: string;
+}
+
+export interface DomListType {
+ btn: HTMLElement;
+ type: 'app' | 'minapp';
+ config: CallappConfig & WeappConfig;
+ isRegister: boolean;
+ isWxNativeReady: boolean;
+}
+
+export interface WxTagErrorEvent {
+ detail?: WxTagFailure;
+}
+
+export interface WxTagFailure {
+ errMsg?: string;
+ appId?: string;
+ extInfo?: string;
+ // weapp
+ userName?: string;
+ path?: string;
+}
export interface CallappOptions {
scheme: {
protocol: string;
@@ -20,12 +55,15 @@ export interface CallappOptions {
host: string;
pathKey?: string;
};
+ useWxNative?: boolean;
+ wxAppid?: string;
+ weappId?: string;
appstore: string;
yingyongbao?: string;
- isSupportWeibo?:boolean;
+ isSupportWeibo?: boolean;
fallback: string;
timeout?: number;
- logFunc?: (status: 'pending' | 'failure') => void;
+ logFunc?: (status: 'pending' | 'failure', wxTagFailure?: WxTagFailure) => void;
buildScheme?: (config: CallappConfig, options: CallappOptions) => string;
}
diff --git a/types/globals.d.ts b/types/globals.d.ts
index b737ecb..e9cb802 100644
--- a/types/globals.d.ts
+++ b/types/globals.d.ts
@@ -1,3 +1,10 @@
+declare const wx: {
+ ready: (callback: () => void) => void;
+ error: (callback: () => void) => void;
+};
+declare interface Window {
+ wx: typeof wx;
+}
interface Document {
webkitHidden?: boolean;
msHidden?: boolean;
From 8ea40f65e68e51960298af65f44d39f9fd8873a9 Mon Sep 17 00:00:00 2001
From: xjccc <546534045@qq.com>
Date: Mon, 19 Jun 2023 09:38:47 +0800
Subject: [PATCH 2/6] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9type:minapp?=
=?UTF-8?q?=20->=20weapp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 8 ++++----
src/index.ts | 8 ++++----
src/types.ts | 4 ++--
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index c2d3e76..39449b8 100644
--- a/README.md
+++ b/README.md
@@ -103,8 +103,8 @@ lib.signup([
}
},
{
- id: 'open-minapp',
- type: 'minapp', // 'app' | 'minapp' 默认'app'
+ id: 'open-weapp',
+ type: 'weapp', // 'app' | 'weapp' 默认'app'
path: '',
height?: '40px',
appid?: '', // 所需跳转的小程序appid,即小程序对应的以wx开头的id, 不写使用weappId
@@ -392,9 +392,9 @@ url scheme 自定义拼接函数,内置的 buildScheme 函数是按照 uri 规
必填: ❎
默认: 'app'
- 拉起小程序需要改成'minapp'
+ 拉起小程序需要改成'weapp'
- > 非微信环境,minapp 不会注册事件
+ > 非微信环境,weapp 不会注册事件
- appid
diff --git a/src/index.ts b/src/index.ts
index 6249949..a455b7d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -122,8 +122,8 @@ class CallApp {
if (!config.id) {
throw new Error('use dom you need id parameter to register');
}
- if (config.type === 'minapp' && !config.appid && !this.options.weappId) {
- throw new Error('minapp need appid');
+ if (config.type === 'weapp' && !config.appid && !this.options.weappId) {
+ throw new Error('weapp need appid');
}
const dom = document.querySelector(`#${config.id}`);
if (!dom) {
@@ -134,7 +134,7 @@ class CallApp {
throw new Error(`the #${config.id} is not only`);
}
config.type = config.type ?? 'app';
- if (config.type === 'minapp') {
+ if (config.type === 'weapp') {
config.env = config.env ?? 'release';
config.appid = config.appid ?? this.options.weappId;
}
@@ -176,7 +176,7 @@ class CallApp {
const tagType = {
app: 'generateWxTag',
- minapp: 'generateWeappTag',
+ weapp: 'generateWeappTag',
} as const;
wx.ready(() => {
domList.forEach((obj) => {
diff --git a/src/types.ts b/src/types.ts
index bbb2710..a82656b 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -6,7 +6,7 @@ export interface CallappConfig> {
export interface WxTagOption {
id: string;
- type?: 'app' | 'minapp';
+ type?: 'app' | 'weapp';
height?: string;
btnText?: string;
}
@@ -21,7 +21,7 @@ export interface WeappConfig extends WxTagOption {
export interface DomListType {
btn: HTMLElement;
- type: 'app' | 'minapp';
+ type: 'app' | 'weapp';
config: CallappConfig & WeappConfig;
isRegister: boolean;
isWxNativeReady: boolean;
From 53b84ce90d59eaaf175e4aa3d70026f8ad893b2f Mon Sep 17 00:00:00 2001
From: xjccc <546534045@qq.com>
Date: Mon, 19 Jun 2023 19:07:02 +0800
Subject: [PATCH 3/6] =?UTF-8?q?refactor:=20=E6=8A=BD=E7=A6=BBwx=E7=9B=B8?=
=?UTF-8?q?=E5=85=B3=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/generate.ts | 99 ++++++++++++++++++++---------------
src/index.ts | 135 +++++++-----------------------------------------
src/types.ts | 4 +-
src/wx.ts | 116 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 192 insertions(+), 162 deletions(-)
create mode 100644 src/wx.ts
diff --git a/src/generate.ts b/src/generate.ts
index 1e0cf24..138c690 100644
--- a/src/generate.ts
+++ b/src/generate.ts
@@ -94,51 +94,64 @@ function transformUnit(val: string) {
return val;
}
-// 生成微信tag
-export function generateWxTag(
- config: CallappConfig & WxTagOption,
- options: CallappOptions
+function setAttrs(ele: HTMLElement, attrs: Record) {
+ Object.keys(attrs).forEach((key) => {
+ ele.setAttribute(key, attrs[key]);
+ });
+}
+
+// 生成微信原生标签
+export function generateWxOriginTag(
+ config: CallappConfig & WeappConfig,
+ options: CallappOptions,
+ type: WeappConfig['type'] = 'app'
): string {
+ const tags = {
+ app: 'launch-app',
+ weapp: 'launch-weapp',
+ };
const { id, height = '40px', btnText = '立即打开' } = config;
- const { wxAppid } = options;
const h = transformUnit(height);
- return `
-
- `;
-}
-
-// 生成微信小程序tag
-export function generateWeappTag(config: WeappConfig, options: CallappOptions): string {
- const {
- id,
- height = '40px',
- appid,
- wePath,
- username,
- env,
- extraData,
- btnText = '打开小程序',
- } = config;
- const { weappId } = options;
- if (!weappId && !appid) {
- throw new Error('need weapp appid');
+ const ele = document.createElement(`wx-open-${tags[type]}`);
+
+ if (type === 'app') {
+ const { wxAppid } = options;
+ if (!wxAppid) {
+ throw new Error('open app from wx wxAppid is needed');
+ }
+ setAttrs(ele, {
+ id: `launch_${id}`,
+ appid: wxAppid,
+ extinfo: buildScheme(config, options),
+ });
+ } else if (type === 'weapp') {
+ const { weappId } = options;
+ const {
+ appid = weappId,
+ wePath = 'pages/index',
+ username = '',
+ env = 'release',
+ extraData = '',
+ } = config;
+ if (!appid) {
+ throw new Error('need appid or weappId');
+ }
+
+ const extra =
+ extraData && (typeof extraData === 'string' ? extraData : encodeURIComponent(extraData));
+ setAttrs(ele, {
+ id: `weapp_${id}`,
+ appid,
+ path: wePath,
+ username,
+ 'env-version': env,
+ 'extra-data': extra,
+ });
}
- const h = transformUnit(height);
- const extra =
- extraData && (typeof extraData === 'string' ? extraData : encodeURIComponent(extraData));
- return `
-
- `;
+ ele.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;';
+ ele.innerHTML = ``;
+ return ele.outerHTML;
}
diff --git a/src/index.ts b/src/index.ts
index a455b7d..6fd96b5 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -4,23 +4,19 @@ import { evokeByLocation, evokeByTagA, evokeByIFrame, checkOpen } from './evoke'
import {
CallappConfig,
CallappOptions,
- WxTagFailure,
WxTagErrorEvent,
DomListType,
WxTagOption,
WeappConfig,
} from './types';
+import { registeDom, registeWxApp, wxTagFailure } from './wx';
class CallApp {
- private readonly options: CallappOptions & { timeout: number };
-
- private domList: DomListType[] = [];
-
- private hasApp = false;
+ private readonly options: CallappOptions & { hasApp: boolean };
// Create an instance of CallApp
constructor(options: CallappOptions) {
- const defaultOptions = { useWxNative: true, timeout: 2000 };
+ const defaultOptions = { useWxNative: true, timeout: 2000, hasApp: false };
this.options = Object.assign(defaultOptions, options);
}
@@ -44,12 +40,11 @@ class CallApp {
return generate.generateYingYongBao(config, this.options);
}
- public generateWxTag(config: CallappConfig & WxTagOption): string {
- return generate.generateWxTag(config, this.options);
- }
-
- public generateWeappTag(config: CallappConfig & WeappConfig): string {
- return generate.generateWeappTag(config, this.options);
+ public generateWxOriginTag(
+ config: CallappConfig & WeappConfig,
+ type: WxTagOption['type']
+ ): string {
+ return generate.generateWxOriginTag(config, this.options, type);
}
checkOpen(failure: () => void): void {
@@ -85,13 +80,6 @@ class CallApp {
});
}
- wxTagFailure(reason: WxTagFailure | undefined): void {
- const { logFunc } = this.options;
- if (typeof logFunc !== 'undefined') {
- logFunc('failure', reason);
- }
- }
-
signup(config: (CallappConfig & WeappConfig) | Array): void {
const { useWxNative, wxAppid } = this.options;
if (Browser.isWechat && useWxNative && !wxAppid) {
@@ -100,111 +88,24 @@ class CallApp {
const list = !Array.isArray(config) ? [config] : config;
const domList: DomListType[] = [];
- list.forEach((c) => this.registeDom(c, domList));
+ list.forEach((c) => registeDom(c, this.options, domList));
// 注册微信打开app
- this.registeWxApp(domList);
+ registeWxApp(domList, this.options, this.open.bind(this));
if (!useWxNative || !window.wx) return;
wx.error(() => {
- this.wxTagFailure({
- errMsg: 'wx register fail',
- });
+ wxTagFailure(
+ {
+ errMsg: 'wx register fail',
+ },
+ this.options
+ );
});
document.addEventListener('WeixinOpenTagsError', (e: Event & WxTagErrorEvent) => {
// 无法使用开放标签的错误原因,需回退兼容。仅无法使用开放标签,JS-SDK其他功能不受影响
- this.wxTagFailure(e.detail);
- });
- }
-
- registeDom(config: CallappConfig & WeappConfig, domList: DomListType[]): DomListType[] {
- if (!config.id) {
- throw new Error('use dom you need id parameter to register');
- }
- if (config.type === 'weapp' && !config.appid && !this.options.weappId) {
- throw new Error('weapp need appid');
- }
- const dom = document.querySelector(`#${config.id}`);
- if (!dom) {
- throw new Error(`make sure the dom by #${config.id} is exists`);
- }
- const index = this.domList.findIndex((obj) => obj.config.id === config.id);
- if (index !== -1) {
- throw new Error(`the #${config.id} is not only`);
- }
- config.type = config.type ?? 'app';
- if (config.type === 'weapp') {
- config.env = config.env ?? 'release';
- config.appid = config.appid ?? this.options.weappId;
- }
-
- const obj = {
- btn: dom as HTMLElement,
- type: config.type,
- config,
- isRegister: false,
- isWxNativeReady: false,
- };
- domList.push(obj);
- return domList;
- }
-
- // dom事件注册
- bindClickEvent(obj: DomListType): void {
- if (!obj.isRegister && obj.type === 'app') {
- obj.btn.addEventListener('click', () => {
- const notUseWxNative = Browser.isWechat && !this.options.useWxNative;
- const wxNativeError = Browser.isWechat && !this.hasApp;
- const ready = Browser.isWechat && this.options.useWxNative && obj.isWxNativeReady;
- if (ready) return;
- if (!Browser.isWechat || notUseWxNative || wxNativeError) {
- this.open(obj.config);
- }
- });
- obj.isRegister = true;
- }
- }
-
- registeWxApp(domList: DomListType[]): void {
- if (!Browser.isWechat) {
- domList.forEach((obj) => {
- this.bindClickEvent(obj);
- });
- return;
- }
-
- const tagType = {
- app: 'generateWxTag',
- weapp: 'generateWeappTag',
- } as const;
- wx.ready(() => {
- domList.forEach((obj) => {
- this.bindClickEvent(obj);
- if (!this.options.useWxNative && obj.type === 'app') return;
-
- const { btn, type } = obj;
- btn.innerHTML = this[tagType[type]](obj.config);
- const wxBtn = btn.firstChild as HTMLElement;
-
- wxBtn.addEventListener('ready', () => {
- obj.isWxNativeReady = true;
- });
- // e: Event & WxTagErrorEvent
- wxBtn.addEventListener('launch', () => {
- if (obj.type === 'app') {
- this.hasApp = true;
- }
- });
- wxBtn.addEventListener('error', (e: Event & WxTagErrorEvent) => {
- // 如果微信打开失败,证明没有应用,在ios需要打开app store。不能跳转universal link
- this.wxTagFailure(e.detail);
- if (type === 'app') {
- this.hasApp = false;
- this.open(obj.config);
- }
- });
- });
+ wxTagFailure(e.detail, this.options);
});
}
@@ -232,7 +133,7 @@ class CallApp {
if (
(Browser.isWechat && Browser.semverCompare(Browser.getWeChatVersion(), '7.0.5') === -1) ||
(Browser.isWeibo && !isSupportWeibo) ||
- (Browser.isWechat && this.options.useWxNative && !this.hasApp)
+ (Browser.isWechat && this.options.useWxNative && !this.options.hasApp)
) {
evokeByLocation(appstore);
} else if (Browser.getIOSVersion() < 9) {
diff --git a/src/types.ts b/src/types.ts
index a82656b..ac86cd9 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -14,7 +14,7 @@ export interface WxTagOption {
export interface WeappConfig extends WxTagOption {
appid?: string;
username?: string;
- wePath?: string;
+ wePath: string;
env?: 'release' | 'develop' | 'trial';
extraData?: string;
}
@@ -62,7 +62,7 @@ export interface CallappOptions {
yingyongbao?: string;
isSupportWeibo?: boolean;
fallback: string;
- timeout?: number;
+ timeout: number;
logFunc?: (status: 'pending' | 'failure', wxTagFailure?: WxTagFailure) => void;
buildScheme?: (config: CallappConfig, options: CallappOptions) => string;
}
diff --git a/src/wx.ts b/src/wx.ts
new file mode 100644
index 0000000..db21bd8
--- /dev/null
+++ b/src/wx.ts
@@ -0,0 +1,116 @@
+import * as Browser from './browser';
+import { generateWxOriginTag } from './generate';
+import {
+ CallappConfig,
+ CallappOptions,
+ DomListType,
+ WeappConfig,
+ WxTagErrorEvent,
+ WxTagFailure,
+} from './types';
+
+type Open = (config: CallappConfig) => void;
+
+export function wxTagFailure(reason: WxTagFailure | undefined, options: CallappOptions): void {
+ const { logFunc } = options;
+ if (typeof logFunc !== 'undefined') {
+ logFunc('failure', reason);
+ }
+}
+// dom事件注册
+export function bindClickEvent(
+ obj: DomListType,
+ options: CallappOptions & { hasApp: boolean },
+ open: Open
+): void {
+ if (!obj.isRegister && obj.type === 'app') {
+ obj.btn.addEventListener('click', () => {
+ const notUseWxNative = Browser.isWechat && !options.useWxNative;
+ const wxNativeError = Browser.isWechat && !options.hasApp;
+ const ready = Browser.isWechat && options.useWxNative && obj.isWxNativeReady;
+ if (ready) return;
+ if (!Browser.isWechat || notUseWxNative || wxNativeError) {
+ open(obj.config);
+ }
+ });
+ obj.isRegister = true;
+ }
+}
+
+export function registeWxApp(
+ domList: DomListType[],
+ options: CallappOptions & { hasApp: boolean },
+ open: Open
+): void {
+ if (!Browser.isWechat) {
+ domList.forEach((obj) => {
+ bindClickEvent(obj, options, open);
+ });
+ return;
+ }
+
+ wx.ready(() => {
+ domList.forEach((obj) => {
+ bindClickEvent(obj, options, open);
+ if (!options.useWxNative && obj.type === 'app') return;
+
+ const { btn, type, config } = obj;
+ btn.innerHTML = generateWxOriginTag(config, options, type);
+ const wxBtn = btn.firstChild as HTMLElement;
+
+ wxBtn.addEventListener('ready', () => {
+ obj.isWxNativeReady = true;
+ });
+ // e: Event & WxTagErrorEvent
+ wxBtn.addEventListener('launch', () => {
+ if (obj.type === 'app') {
+ options.hasApp = true;
+ }
+ });
+ wxBtn.addEventListener('error', (e: Event & WxTagErrorEvent) => {
+ // 如果微信打开失败,证明没有应用,在ios需要打开app store。不能跳转universal link
+ wxTagFailure(e.detail, options);
+ if (type === 'app') {
+ options.hasApp = e.detail?.errMsg !== 'launch:fail';
+ open(obj.config);
+ }
+ });
+ });
+ });
+}
+
+export function registeDom(
+ config: CallappConfig & WeappConfig,
+ options: CallappOptions,
+ domList: DomListType[]
+): DomListType[] {
+ if (!config.id) {
+ throw new Error('use dom you need id parameter to register');
+ }
+ if (config.type === 'weapp' && !config.appid && !options.weappId) {
+ throw new Error('weapp need appid');
+ }
+ const dom = document.querySelector(`#${config.id}`);
+ if (!dom) {
+ throw new Error(`make sure the dom by #${config.id} is exists`);
+ }
+ const index = domList.findIndex((obj) => obj.config.id === config.id);
+ if (index !== -1) {
+ throw new Error(`the #${config.id} is not only`);
+ }
+ config.type = config.type ?? 'app';
+ if (config.type === 'weapp') {
+ config.env = config.env ?? 'release';
+ config.appid = config.appid ?? options.weappId;
+ }
+
+ const obj = {
+ btn: dom as HTMLElement,
+ type: config.type,
+ config,
+ isRegister: false,
+ isWxNativeReady: false,
+ };
+ domList.push(obj);
+ return domList;
+}
From 938ec445ad0a0fcac605be55b409024b92bd384f Mon Sep 17 00:00:00 2001
From: xjccc <546534045@qq.com>
Date: Mon, 19 Jun 2023 19:07:57 +0800
Subject: [PATCH 4/6] =?UTF-8?q?chore:=20=E5=8E=BB=E9=99=A4=E6=9C=AA?=
=?UTF-8?q?=E4=BD=BF=E7=94=A8type?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/generate.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/generate.ts b/src/generate.ts
index 138c690..78aaee6 100644
--- a/src/generate.ts
+++ b/src/generate.ts
@@ -1,4 +1,4 @@
-import { CallappConfig, CallappOptions, Intent, WeappConfig, WxTagOption } from './types';
+import { CallappConfig, CallappOptions, Intent, WeappConfig } from './types';
// 根据 param 生成 queryString
function generateQS(param?: Record): string {
From 9d7509771c4406935e5ec549f47ca1b4d1000f91 Mon Sep 17 00:00:00 2001
From: xjccc <546534045@qq.com>
Date: Tue, 20 Jun 2023 15:16:12 +0800
Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9signup=20-=20confi?=
=?UTF-8?q?g=20=E7=B1=BB=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package-lock.json | 614 +++-------------------------------------------
package.json | 15 +-
src/generate.ts | 12 +-
src/index.ts | 9 +-
src/types.ts | 6 +-
src/wx.ts | 7 +-
6 files changed, 58 insertions(+), 605 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 60ca11c..e0b8d1e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,16 +1,13 @@
{
"name": "callapp-lib",
- "version": "3.5.1",
+ "version": "3.5.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "callapp-lib",
- "version": "3.5.1",
+ "version": "3.5.4",
"license": "MIT",
- "dependencies": {
- "http-server": "^14.1.0"
- },
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/plugin-proposal-class-properties": "^7.10.1",
@@ -2310,14 +2307,6 @@
"node": ">=8"
}
},
- "node_modules/async": {
- "version": "2.6.4",
- "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
- "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
- "dependencies": {
- "lodash": "^4.17.14"
- }
- },
"node_modules/at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
@@ -2390,17 +2379,6 @@
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
- "node_modules/basic-auth": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
- "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
- "dependencies": {
- "safe-buffer": "5.1.2"
- },
- "engines": {
- "node": ">= 0.8"
- }
- },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -2443,18 +2421,6 @@
"node": ">=6"
}
},
- "node_modules/call-bind": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
- "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
- "dependencies": {
- "function-bind": "^1.1.1",
- "get-intrinsic": "^1.0.2"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/caller-callsite": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz",
@@ -2710,14 +2676,6 @@
"semver": "bin/semver.js"
}
},
- "node_modules/corser": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
- "integrity": "sha1-jtolLsqrWEDc2XXOuQ2TcMgZ/4c=",
- "engines": {
- "node": ">= 0.4.0"
- }
- },
"node_modules/cosmiconfig": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
@@ -3710,11 +3668,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/eventemitter3": {
- "version": "4.0.7",
- "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
- "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
- },
"node_modules/execa": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
@@ -3801,25 +3754,6 @@
"integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==",
"dev": true
},
- "node_modules/follow-redirects": {
- "version": "1.15.0",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz",
- "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==",
- "funding": [
- {
- "type": "individual",
- "url": "https://github.com/sponsors/RubenVerborgh"
- }
- ],
- "engines": {
- "node": ">=4.0"
- },
- "peerDependenciesMeta": {
- "debug": {
- "optional": true
- }
- }
- },
"node_modules/fs-extra": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
@@ -3857,7 +3791,8 @@
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
- "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
+ "dev": true
},
"node_modules/functional-red-black-tree": {
"version": "1.0.1",
@@ -3883,19 +3818,6 @@
"node": "6.* || 8.* || >= 10.*"
}
},
- "node_modules/get-intrinsic": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
- "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
- "dependencies": {
- "function-bind": "^1.1.1",
- "has": "^1.0.3",
- "has-symbols": "^1.0.1"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/get-stdin": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz",
@@ -4008,6 +3930,7 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "dev": true,
"dependencies": {
"function-bind": "^1.1.1"
},
@@ -4028,138 +3951,17 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
+ "dev": true,
"engines": {
"node": ">= 0.4"
}
},
- "node_modules/he": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
- "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
- "bin": {
- "he": "bin/he"
- }
- },
"node_modules/hosted-git-info": {
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
- "node_modules/html-encoding-sniffer": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
- "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",
- "dependencies": {
- "whatwg-encoding": "^2.0.0"
- },
- "engines": {
- "node": ">=12"
- }
- },
- "node_modules/http-proxy": {
- "version": "1.18.1",
- "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
- "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
- "dependencies": {
- "eventemitter3": "^4.0.0",
- "follow-redirects": "^1.0.0",
- "requires-port": "^1.0.0"
- },
- "engines": {
- "node": ">=8.0.0"
- }
- },
- "node_modules/http-server": {
- "version": "14.1.0",
- "resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.0.tgz",
- "integrity": "sha512-5lYsIcZtf6pdR8tCtzAHTWrAveo4liUlJdWc7YafwK/maPgYHs+VNP6KpCClmUnSorJrARVMXqtT055zBv11Yg==",
- "dependencies": {
- "basic-auth": "^2.0.1",
- "chalk": "^4.1.2",
- "corser": "^2.0.1",
- "he": "^1.2.0",
- "html-encoding-sniffer": "^3.0.0",
- "http-proxy": "^1.18.1",
- "mime": "^1.6.0",
- "minimist": "^1.2.5",
- "opener": "^1.5.1",
- "portfinder": "^1.0.28",
- "secure-compare": "3.0.1",
- "union": "~0.5.0",
- "url-join": "^4.0.1"
- },
- "bin": {
- "http-server": "bin/http-server"
- },
- "engines": {
- "node": ">=12"
- }
- },
- "node_modules/http-server/node_modules/ansi-styles": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
- "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
- "dependencies": {
- "color-convert": "^2.0.1"
- },
- "engines": {
- "node": ">=8"
- },
- "funding": {
- "url": "https://github.com/chalk/ansi-styles?sponsor=1"
- }
- },
- "node_modules/http-server/node_modules/chalk": {
- "version": "4.1.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
- "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
- "dependencies": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- },
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "url": "https://github.com/chalk/chalk?sponsor=1"
- }
- },
- "node_modules/http-server/node_modules/color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dependencies": {
- "color-name": "~1.1.4"
- },
- "engines": {
- "node": ">=7.0.0"
- }
- },
- "node_modules/http-server/node_modules/color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
- },
- "node_modules/http-server/node_modules/has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/http-server/node_modules/supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dependencies": {
- "has-flag": "^4.0.0"
- },
- "engines": {
- "node": ">=8"
- }
- },
"node_modules/husky": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/husky/-/husky-1.3.1.tgz",
@@ -4279,17 +4081,6 @@
"node": ">=6"
}
},
- "node_modules/iconv-lite": {
- "version": "0.6.3",
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
- "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
- "dependencies": {
- "safer-buffer": ">= 2.1.2 < 3.0.0"
- },
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
@@ -4700,7 +4491,8 @@
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
- "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+ "dev": true
},
"node_modules/lodash.clonedeep": {
"version": "4.5.0",
@@ -4832,17 +4624,6 @@
"node": ">=10"
}
},
- "node_modules/mime": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
- "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
- "bin": {
- "mime": "cli.js"
- },
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/min-indent": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz",
@@ -4867,7 +4648,8 @@
"node_modules/minimist": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
+ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
+ "dev": true
},
"node_modules/minimist-options": {
"version": "4.1.0",
@@ -4883,21 +4665,11 @@
"node": ">= 6"
}
},
- "node_modules/mkdirp": {
- "version": "0.5.6",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
- "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
- "dependencies": {
- "minimist": "^1.2.6"
- },
- "bin": {
- "mkdirp": "bin/cmd.js"
- }
- },
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
- "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+ "dev": true
},
"node_modules/multimap": {
"version": "1.1.0",
@@ -4951,6 +4723,7 @@
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.1.tgz",
"integrity": "sha512-Y/jF6vnvEtOPGiKD1+q+X0CiUYRQtEHp89MLLUJ7TUivtH8Ugn2+3A7Rynqk7BRsAoqeOQWnFnjpDrKSxDgIGA==",
+ "dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@@ -5017,14 +4790,6 @@
"wrappy": "1"
}
},
- "node_modules/opener": {
- "version": "1.5.2",
- "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz",
- "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==",
- "bin": {
- "opener": "bin/opener-bin.js"
- }
- },
"node_modules/optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
@@ -5268,27 +5033,6 @@
"node": ">=4"
}
},
- "node_modules/portfinder": {
- "version": "1.0.28",
- "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz",
- "integrity": "sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==",
- "dependencies": {
- "async": "^2.6.2",
- "debug": "^3.1.1",
- "mkdirp": "^0.5.5"
- },
- "engines": {
- "node": ">= 0.12.0"
- }
- },
- "node_modules/portfinder/node_modules/debug": {
- "version": "3.2.7",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
- "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
- "dependencies": {
- "ms": "^2.1.1"
- }
- },
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@@ -5360,20 +5104,6 @@
"teleport": ">=0.2.0"
}
},
- "node_modules/qs": {
- "version": "6.10.3",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
- "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==",
- "dependencies": {
- "side-channel": "^1.0.4"
- },
- "engines": {
- "node": ">=0.6"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/quick-lru": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz",
@@ -5570,11 +5300,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/requires-port": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
- "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
- },
"node_modules/reserved-words": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz",
@@ -5660,7 +5385,8 @@
"node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+ "dev": true
},
"node_modules/safe-regex": {
"version": "2.1.1",
@@ -5671,16 +5397,6 @@
"regexp-tree": "~0.1.1"
}
},
- "node_modules/safer-buffer": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
- "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
- },
- "node_modules/secure-compare": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz",
- "integrity": "sha1-8aAymzCLIh+uN7mXTz1XjQypmeM="
- },
"node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
@@ -5717,19 +5433,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/side-channel": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
- "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
- "dependencies": {
- "call-bind": "^1.0.0",
- "get-intrinsic": "^1.0.2",
- "object-inspect": "^1.9.0"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/signal-exit": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
@@ -6201,17 +5904,6 @@
"node": ">=4"
}
},
- "node_modules/union": {
- "version": "0.5.0",
- "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz",
- "integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==",
- "dependencies": {
- "qs": "^6.4.0"
- },
- "engines": {
- "node": ">= 0.8.0"
- }
- },
"node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
@@ -6230,11 +5922,6 @@
"punycode": "^2.1.0"
}
},
- "node_modules/url-join": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",
- "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
- },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -6257,17 +5944,6 @@
"spdx-expression-parse": "^3.0.0"
}
},
- "node_modules/whatwg-encoding": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
- "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
- "dependencies": {
- "iconv-lite": "0.6.3"
- },
- "engines": {
- "node": ">=12"
- }
- },
"node_modules/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@@ -8243,14 +7919,6 @@
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
"dev": true
},
- "async": {
- "version": "2.6.4",
- "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
- "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
- "requires": {
- "lodash": "^4.17.14"
- }
- },
"at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
@@ -8310,14 +7978,6 @@
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
- "basic-auth": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
- "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
- "requires": {
- "safe-buffer": "5.1.2"
- }
- },
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -8347,15 +8007,6 @@
"integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==",
"dev": true
},
- "call-bind": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
- "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
- "requires": {
- "function-bind": "^1.1.1",
- "get-intrinsic": "^1.0.2"
- }
- },
"caller-callsite": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz",
@@ -8566,11 +8217,6 @@
}
}
},
- "corser": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
- "integrity": "sha1-jtolLsqrWEDc2XXOuQ2TcMgZ/4c="
- },
"cosmiconfig": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
@@ -9354,11 +9000,6 @@
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true
},
- "eventemitter3": {
- "version": "4.0.7",
- "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
- "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
- },
"execa": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
@@ -9433,11 +9074,6 @@
"integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==",
"dev": true
},
- "follow-redirects": {
- "version": "1.15.0",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz",
- "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ=="
- },
"fs-extra": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
@@ -9466,7 +9102,8 @@
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
- "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
+ "dev": true
},
"functional-red-black-tree": {
"version": "1.0.1",
@@ -9486,16 +9123,6 @@
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true
},
- "get-intrinsic": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
- "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
- "requires": {
- "function-bind": "^1.1.1",
- "has": "^1.0.3",
- "has-symbols": "^1.0.1"
- }
- },
"get-stdin": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz",
@@ -9578,6 +9205,7 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "dev": true,
"requires": {
"function-bind": "^1.1.1"
}
@@ -9591,12 +9219,8 @@
"has-symbols": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
- "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg=="
- },
- "he": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
- "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
+ "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
+ "dev": true
},
"hosted-git-info": {
"version": "2.8.9",
@@ -9604,89 +9228,6 @@
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
- "html-encoding-sniffer": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
- "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",
- "requires": {
- "whatwg-encoding": "^2.0.0"
- }
- },
- "http-proxy": {
- "version": "1.18.1",
- "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
- "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
- "requires": {
- "eventemitter3": "^4.0.0",
- "follow-redirects": "^1.0.0",
- "requires-port": "^1.0.0"
- }
- },
- "http-server": {
- "version": "14.1.0",
- "resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.0.tgz",
- "integrity": "sha512-5lYsIcZtf6pdR8tCtzAHTWrAveo4liUlJdWc7YafwK/maPgYHs+VNP6KpCClmUnSorJrARVMXqtT055zBv11Yg==",
- "requires": {
- "basic-auth": "^2.0.1",
- "chalk": "^4.1.2",
- "corser": "^2.0.1",
- "he": "^1.2.0",
- "html-encoding-sniffer": "^3.0.0",
- "http-proxy": "^1.18.1",
- "mime": "^1.6.0",
- "minimist": "^1.2.5",
- "opener": "^1.5.1",
- "portfinder": "^1.0.28",
- "secure-compare": "3.0.1",
- "union": "~0.5.0",
- "url-join": "^4.0.1"
- },
- "dependencies": {
- "ansi-styles": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
- "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
- "requires": {
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
- "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
- },
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "requires": {
- "has-flag": "^4.0.0"
- }
- }
- }
- },
"husky": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/husky/-/husky-1.3.1.tgz",
@@ -9777,14 +9318,6 @@
}
}
},
- "iconv-lite": {
- "version": "0.6.3",
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
- "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
- "requires": {
- "safer-buffer": ">= 2.1.2 < 3.0.0"
- }
- },
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
@@ -10099,7 +9632,8 @@
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
- "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+ "dev": true
},
"lodash.clonedeep": {
"version": "4.5.0",
@@ -10206,11 +9740,6 @@
}
}
},
- "mime": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
- "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
- },
"min-indent": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz",
@@ -10229,7 +9758,8 @@
"minimist": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
+ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
+ "dev": true
},
"minimist-options": {
"version": "4.1.0",
@@ -10242,18 +9772,11 @@
"kind-of": "^6.0.3"
}
},
- "mkdirp": {
- "version": "0.5.6",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
- "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
- "requires": {
- "minimist": "^1.2.6"
- }
- },
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
- "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+ "dev": true
},
"multimap": {
"version": "1.1.0",
@@ -10303,7 +9826,8 @@
"object-inspect": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.1.tgz",
- "integrity": "sha512-Y/jF6vnvEtOPGiKD1+q+X0CiUYRQtEHp89MLLUJ7TUivtH8Ugn2+3A7Rynqk7BRsAoqeOQWnFnjpDrKSxDgIGA=="
+ "integrity": "sha512-Y/jF6vnvEtOPGiKD1+q+X0CiUYRQtEHp89MLLUJ7TUivtH8Ugn2+3A7Rynqk7BRsAoqeOQWnFnjpDrKSxDgIGA==",
+ "dev": true
},
"object-keys": {
"version": "1.1.1",
@@ -10355,11 +9879,6 @@
"wrappy": "1"
}
},
- "opener": {
- "version": "1.5.2",
- "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz",
- "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A=="
- },
"optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
@@ -10542,26 +10061,6 @@
"integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==",
"dev": true
},
- "portfinder": {
- "version": "1.0.28",
- "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz",
- "integrity": "sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==",
- "requires": {
- "async": "^2.6.2",
- "debug": "^3.1.1",
- "mkdirp": "^0.5.5"
- },
- "dependencies": {
- "debug": {
- "version": "3.2.7",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
- "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
- "requires": {
- "ms": "^2.1.1"
- }
- }
- }
- },
"prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@@ -10611,14 +10110,6 @@
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=",
"dev": true
},
- "qs": {
- "version": "6.10.3",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
- "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==",
- "requires": {
- "side-channel": "^1.0.4"
- }
- },
"quick-lru": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz",
@@ -10776,11 +10267,6 @@
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"dev": true
},
- "requires-port": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
- "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
- },
"reserved-words": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz",
@@ -10839,7 +10325,8 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+ "dev": true
},
"safe-regex": {
"version": "2.1.1",
@@ -10850,16 +10337,6 @@
"regexp-tree": "~0.1.1"
}
},
- "safer-buffer": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
- "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
- },
- "secure-compare": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz",
- "integrity": "sha1-8aAymzCLIh+uN7mXTz1XjQypmeM="
- },
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
@@ -10887,16 +10364,6 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
- "side-channel": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
- "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
- "requires": {
- "call-bind": "^1.0.0",
- "get-intrinsic": "^1.0.2",
- "object-inspect": "^1.9.0"
- }
- },
"signal-exit": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
@@ -11264,14 +10731,6 @@
"integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==",
"dev": true
},
- "union": {
- "version": "0.5.0",
- "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz",
- "integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==",
- "requires": {
- "qs": "^6.4.0"
- }
- },
"universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
@@ -11287,11 +10746,6 @@
"punycode": "^2.1.0"
}
},
- "url-join": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",
- "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
- },
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -11314,14 +10768,6 @@
"spdx-expression-parse": "^3.0.0"
}
},
- "whatwg-encoding": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
- "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
- "requires": {
- "iconv-lite": "0.6.3"
- }
- },
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
diff --git a/package.json b/package.json
index fa1fda0..abda6a3 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,9 @@
"directories": {
"dist": "dist"
},
- "files": ["dist"],
+ "files": [
+ "dist"
+ ],
"scripts": {
"lint-eslint": "eslint --cache --ext .ts ./src",
"check-types": "tsc --noEmit",
@@ -27,7 +29,16 @@
"type": "git",
"url": "git+https://github.com/suanmei/callapp-lib.git"
},
- "keywords": ["rollup", "callapp", "schema", "scheme", "universalLink", "intent", "native", "h5"],
+ "keywords": [
+ "rollup",
+ "callapp",
+ "schema",
+ "scheme",
+ "universalLink",
+ "intent",
+ "native",
+ "h5"
+ ],
"author": {
"name": "suanmei",
"email": "code_lee@sina.com",
diff --git a/src/generate.ts b/src/generate.ts
index 78aaee6..450c70f 100644
--- a/src/generate.ts
+++ b/src/generate.ts
@@ -1,4 +1,4 @@
-import { CallappConfig, CallappOptions, Intent, WeappConfig } from './types';
+import { CallappConfig, CallappOptions, Intent, UnionConfig, WeappConfig } from './types';
// 根据 param 生成 queryString
function generateQS(param?: Record): string {
@@ -102,7 +102,7 @@ function setAttrs(ele: HTMLElement, attrs: Record) {
// 生成微信原生标签
export function generateWxOriginTag(
- config: CallappConfig & WeappConfig,
+ config: UnionConfig,
options: CallappOptions,
type: WeappConfig['type'] = 'app'
): string {
@@ -126,13 +126,7 @@ export function generateWxOriginTag(
});
} else if (type === 'weapp') {
const { weappId } = options;
- const {
- appid = weappId,
- wePath = 'pages/index',
- username = '',
- env = 'release',
- extraData = '',
- } = config;
+ const { appid = weappId, wePath, username = '', env = 'release', extraData = '' } = config;
if (!appid) {
throw new Error('need appid or weappId');
}
diff --git a/src/index.ts b/src/index.ts
index 6fd96b5..bda33aa 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -7,7 +7,7 @@ import {
WxTagErrorEvent,
DomListType,
WxTagOption,
- WeappConfig,
+ UnionConfig,
} from './types';
import { registeDom, registeWxApp, wxTagFailure } from './wx';
@@ -40,10 +40,7 @@ class CallApp {
return generate.generateYingYongBao(config, this.options);
}
- public generateWxOriginTag(
- config: CallappConfig & WeappConfig,
- type: WxTagOption['type']
- ): string {
+ public generateWxOriginTag(config: UnionConfig, type: WxTagOption['type']): string {
return generate.generateWxOriginTag(config, this.options, type);
}
@@ -80,7 +77,7 @@ class CallApp {
});
}
- signup(config: (CallappConfig & WeappConfig) | Array): void {
+ signup(config: UnionConfig | UnionConfig[]): void {
const { useWxNative, wxAppid } = this.options;
if (Browser.isWechat && useWxNative && !wxAppid) {
throw new Error('use wx-tag need wxAppid in the options');
diff --git a/src/types.ts b/src/types.ts
index ac86cd9..8af3695 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -14,15 +14,17 @@ export interface WxTagOption {
export interface WeappConfig extends WxTagOption {
appid?: string;
username?: string;
- wePath: string;
+ wePath?: string;
env?: 'release' | 'develop' | 'trial';
extraData?: string;
}
+export type UnionConfig> = CallappConfig & WeappConfig;
+
export interface DomListType {
btn: HTMLElement;
type: 'app' | 'weapp';
- config: CallappConfig & WeappConfig;
+ config: UnionConfig;
isRegister: boolean;
isWxNativeReady: boolean;
}
diff --git a/src/wx.ts b/src/wx.ts
index db21bd8..5228b0a 100644
--- a/src/wx.ts
+++ b/src/wx.ts
@@ -4,7 +4,7 @@ import {
CallappConfig,
CallappOptions,
DomListType,
- WeappConfig,
+ UnionConfig,
WxTagErrorEvent,
WxTagFailure,
} from './types';
@@ -80,7 +80,7 @@ export function registeWxApp(
}
export function registeDom(
- config: CallappConfig & WeappConfig,
+ config: UnionConfig,
options: CallappOptions,
domList: DomListType[]
): DomListType[] {
@@ -90,6 +90,9 @@ export function registeDom(
if (config.type === 'weapp' && !config.appid && !options.weappId) {
throw new Error('weapp need appid');
}
+ if (config.type === 'weapp' && !config.wePath) {
+ throw new Error('weapp need wePath');
+ }
const dom = document.querySelector(`#${config.id}`);
if (!dom) {
throw new Error(`make sure the dom by #${config.id} is exists`);
From a80c6d4148ee34a2b09e08a15e1a81dffa27b8cf Mon Sep 17 00:00:00 2001
From: xjccc <546534045@qq.com>
Date: Thu, 7 Sep 2023 18:36:35 +0800
Subject: [PATCH 6/6] chore: edit WxTagErrorEvent
---
src/types.ts | 2 +-
src/wx.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/types.ts b/src/types.ts
index 8af3695..c423060 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -29,7 +29,7 @@ export interface DomListType {
isWxNativeReady: boolean;
}
-export interface WxTagErrorEvent {
+export class WxTagErrorEvent extends Event {
detail?: WxTagFailure;
}
diff --git a/src/wx.ts b/src/wx.ts
index 5228b0a..892c2b0 100644
--- a/src/wx.ts
+++ b/src/wx.ts
@@ -67,7 +67,7 @@ export function registeWxApp(
options.hasApp = true;
}
});
- wxBtn.addEventListener('error', (e: Event & WxTagErrorEvent) => {
+ wxBtn.addEventListener('error', (e: WxTagErrorEvent) => {
// 如果微信打开失败,证明没有应用,在ios需要打开app store。不能跳转universal link
wxTagFailure(e.detail, options);
if (type === 'app') {