jubo-sdk 1.0.2

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.
@@ -0,0 +1,70 @@
1
+ export declare enum systemTypeEnum {
2
+ /** windows */
3
+ 'windows' = "windows",
4
+ /** mac */
5
+ 'mac' = "mac",
6
+ /** linux */
7
+ 'linux' = "linux",
8
+ /** ios */
9
+ 'ios' = "ios",
10
+ /** android */
11
+ 'android' = "android"
12
+ }
13
+ export declare enum supporterTypeEnum {
14
+ /** chrome */
15
+ 'chrome' = "chrome",
16
+ /** safari */
17
+ 'safari' = "safari",
18
+ /** firefox */
19
+ 'firefox' = "firefox",
20
+ /** opera */
21
+ 'opera' = "opera",
22
+ /** ie */
23
+ 'ie' = "ie",
24
+ /** edge */
25
+ 'edge' = "edge"
26
+ }
27
+ export declare enum shellTypeEnum {
28
+ /** 微信 */
29
+ 'wechat' = "wechat",
30
+ /** 微信小程序 */
31
+ 'wechat-miniprogram' = "wechat-miniprogram",
32
+ /** qq */
33
+ 'qq' = "qq",
34
+ /** uc */
35
+ 'uc' = "uc"
36
+ }
37
+ export type systemType = keyof typeof systemTypeEnum;
38
+ export type supporterType = keyof typeof supporterTypeEnum;
39
+ export type shellType = keyof typeof shellTypeEnum;
40
+ export interface systemArrItem<T = any> {
41
+ system: systemType | T;
42
+ systemRegexp: RegExp;
43
+ systemVersionArr?: {
44
+ systemVersion: string;
45
+ systemVersionRegexp: RegExp;
46
+ }[];
47
+ systemVersionRegexp?: RegExp;
48
+ }
49
+ export interface supporterArrItem<T = any> {
50
+ supporter: supporterType | T;
51
+ supporterRegexp: RegExp;
52
+ supporterVersionRegexp: RegExp;
53
+ }
54
+ /** 外壳item */
55
+ export interface shellArrItem<T = any> {
56
+ /** shell类型 */
57
+ shell: shellType | T;
58
+ /** shell正则 */
59
+ shellRegexp: RegExp;
60
+ /** shell版本正则 */
61
+ shellValueRegexp: RegExp;
62
+ }
63
+ export interface shellDataArrItem<T = any> {
64
+ /** shell类型 */
65
+ shell: shellType | T;
66
+ value: string;
67
+ }
68
+ export interface browserTypePlugins<T> {
69
+ shellArr: shellArrItem<T>[];
70
+ }
@@ -0,0 +1,3 @@
1
+ export * from './browserType';
2
+ export * from './juboSdk';
3
+ export * from './utils';
@@ -0,0 +1,162 @@
1
+ export declare enum AppNameEnum {
2
+ /** 元气玛特 */
3
+ Airmart = "Airmart",
4
+ /** 赛高 */
5
+ Saigo = "Saigo"
6
+ }
7
+ export type AppName = keyof typeof AppNameEnum;
8
+ export type OjbRouter = {
9
+ key: string;
10
+ remark?: string;
11
+ val: string;
12
+ };
13
+ export interface JuboSdkOptions {
14
+ /** app名称 */
15
+ name: AppName;
16
+ /** app旧版本, 用于判断是否使用新版sdk */
17
+ oldAppVersion: string;
18
+ /** 跳转的首页 */
19
+ appHome?: string;
20
+ /** 小程序的登录页 */
21
+ miniProgramLogin?: string;
22
+ /** 小程序tabBar页面列表 */
23
+ miniProgramTabBar?: string[];
24
+ /** 小程序支付页 */
25
+ miniProgramPayPage?: string;
26
+ /** ojb路由 */
27
+ ojbRouter?: OjbRouter[];
28
+ }
29
+ export interface setWebIsFullOptions {
30
+ /**
31
+ * 是否全屏
32
+ * @default false
33
+ */
34
+ isFull: boolean;
35
+ /**
36
+ * 是否立即执行,否延迟1秒执行
37
+ * @default true
38
+ */
39
+ isInit?: boolean;
40
+ }
41
+ export interface ShareMiniProgramOptions {
42
+ /** 小程序路径 */
43
+ webpage: string;
44
+ /** 分享图 */
45
+ thumbImage?: string;
46
+ /** 分享标题 */
47
+ title: string;
48
+ /** 分享描述 */
49
+ descr?: string;
50
+ /**
51
+ * base64分享图
52
+ * @description 仅app有效, 与thumbImage二选一
53
+ * @environment [ios, android]
54
+ */
55
+ base64?: string;
56
+ /** 活动id */
57
+ activity_id?: string;
58
+ /** 活动名称 */
59
+ activity_name?: string;
60
+ /** 商品id */
61
+ product_id?: string;
62
+ /** 商品名称 */
63
+ product_name?: string;
64
+ /** 神策埋点数据 */
65
+ saInfo?: any;
66
+ /**
67
+ * 分享选项
68
+ * @description 仅小程序有效
69
+ * @environment [wx]
70
+ */
71
+ shareOptions?: {
72
+ /** 是否刷新 */
73
+ isRefresh?: boolean;
74
+ [key: string]: any;
75
+ };
76
+ }
77
+ export type ShareMiniProgramTrackData = {
78
+ /** */
79
+ event: string;
80
+ data: Record<string, any>;
81
+ };
82
+ export interface ToPayPageOptions {
83
+ /** 充值金额 */
84
+ amount: number;
85
+ /** 活动ID */
86
+ activityId: string;
87
+ /**
88
+ * 支付成功的回调地址
89
+ * @environment [wx]
90
+ */
91
+ success?: string;
92
+ /**
93
+ * 支付失败的回调地址
94
+ * @environment [wx]
95
+ */
96
+ fail?: string;
97
+ }
98
+ export interface ShareData {
99
+ /** 标题 */
100
+ title: string;
101
+ /** 描述 */
102
+ dec: string;
103
+ /** url */
104
+ url: string;
105
+ /** 分享图 */
106
+ image: string;
107
+ /** 分享方式 (0 = 好友列表 1 = 朋友圈 2 = 收藏) */
108
+ type?: 0 | 1 | 2;
109
+ }
110
+ /** 分享方式 (0 = 好友列表 1 = 朋友圈 2 = 收藏) */
111
+ export type WXShareType = 0 | 1 | 2;
112
+ export interface ShareImgData {
113
+ /** img base64 */
114
+ base64: string;
115
+ /**
116
+ * 分享方式
117
+ * @default 0
118
+ */
119
+ type?: WXShareType;
120
+ }
121
+ export interface ShareHtmlOptions {
122
+ /** 分享标题 */
123
+ title: string;
124
+ /** 分享描述 */
125
+ desc: string;
126
+ /** 分享链接 */
127
+ url: string;
128
+ /** 分享图 */
129
+ imageUrl: string;
130
+ /**
131
+ * 分享方式
132
+ * @default 0
133
+ */
134
+ type?: WXShareType;
135
+ }
136
+ /**
137
+ * 网络状态
138
+ * @default 0 无网络 1 手机网络 2 wifi
139
+ */
140
+ export type NetStatus = 0 | 1 | 2;
141
+ export interface HcAuthorizationOptions {
142
+ /** 授权页面标题 */
143
+ title: string;
144
+ /** 访问token */
145
+ access_token: string;
146
+ /**
147
+ * 成功的回调地址
148
+ * @description 旧版sdk使用
149
+ */
150
+ redirect_url?: string;
151
+ /**
152
+ * 失败的回调地址
153
+ * @description 旧版sdk使用
154
+ */
155
+ error_redirect_url?: string;
156
+ }
157
+ export interface HcAuthorizationData {
158
+ /** 授权成功后有值 */
159
+ loginCode?: string;
160
+ /** 是否成功 */
161
+ isSuccess: boolean;
162
+ }
@@ -0,0 +1,2 @@
1
+ /** -1: 小于, 0: 等于, 1: 大于 */
2
+ export type CompareVersionsDataType = -1 | 0 | 1;
@@ -0,0 +1,30 @@
1
+ import type { browserTypePlugins, shellArrItem, shellType } from '../types/browserType';
2
+ export declare function BrowserType<T>(plugins?: browserTypePlugins<T>): {
3
+ readonly system: "windows" | "mac" | "linux" | "ios" | "android";
4
+ readonly systemVersion: string;
5
+ readonly platform: "desktop" | "mobile";
6
+ readonly engine: string;
7
+ readonly engineVersion: string;
8
+ readonly supporter: "chrome" | "safari" | "firefox" | "opera" | "ie" | "edge";
9
+ readonly supporterVersion: string;
10
+ readonly shell: "wechat" | "wechat-miniprogram" | "qq" | "uc" | T;
11
+ readonly shellVersion: "unknown";
12
+ readonly shellArr: shellArrItem<T>[];
13
+ readonly isShell: (shell: shellType | T) => boolean;
14
+ readonly getShell: (shell: shellType | T) => string | undefined;
15
+ };
16
+ declare const browserType: {
17
+ readonly system: "windows" | "mac" | "linux" | "ios" | "android";
18
+ readonly systemVersion: string;
19
+ readonly platform: "desktop" | "mobile";
20
+ readonly engine: string;
21
+ readonly engineVersion: string;
22
+ readonly supporter: "chrome" | "safari" | "firefox" | "opera" | "ie" | "edge";
23
+ readonly supporterVersion: string;
24
+ readonly shell: "wechat" | "wechat-miniprogram" | "qq" | "uc" | "airmart" | "channel";
25
+ readonly shellVersion: "unknown";
26
+ readonly shellArr: shellArrItem<"airmart" | "channel">[];
27
+ readonly isShell: (shell: "wechat" | "wechat-miniprogram" | "qq" | "uc" | "airmart" | "channel") => boolean;
28
+ readonly getShell: (shell: "wechat" | "wechat-miniprogram" | "qq" | "uc" | "airmart" | "channel") => string | undefined;
29
+ };
30
+ export default browserType;
@@ -0,0 +1,29 @@
1
+ import { CompareVersionsDataType } from '@/types/utils';
2
+ /**
3
+ * 判断版本号大小 [-1, 0, 1]
4
+ * @param version1 第一个版本
5
+ * @param version2 第二个版本
6
+ * @returns -1: 小于, 0: 等于, 1: 大于
7
+ */
8
+ export declare function compareVersions(version1: string, version2: string): CompareVersionsDataType;
9
+ /**
10
+ * 解析url参数
11
+ * @param url string
12
+ * @returns
13
+ */
14
+ export declare function urlToParams(url: string): {
15
+ [key: string]: string;
16
+ };
17
+ /**
18
+ * 获取最新版本号
19
+ * @param name npm包名
20
+ * @returns Promise<string>
21
+ */
22
+ export declare function latestVersion(name: string): Promise<string>;
23
+ /**
24
+ * 更新通知
25
+ * @param name npm包名
26
+ * @param version npm包当前版本
27
+ * @returns -1: 小于, 0: 等于, 1: 大于
28
+ */
29
+ export declare function updateNotifier(name: string, version: string): Promise<CompareVersionsDataType>;
@@ -0,0 +1,4 @@
1
+ import { OjbRouter } from '@/types/juboSdk';
2
+ export declare const compareVersion: (nowVersion: string, oldVersion: string) => 0 | 1 | -1;
3
+ export declare const version: any;
4
+ export declare const getOjbUrlFn: (url: string, newOjbRouterArr?: OjbRouter[]) => string;
@@ -0,0 +1,39 @@
1
+ export interface WebStorageOptions {
2
+ /** 前缀 */
3
+ prefixKey?: string;
4
+ /**
5
+ * 默认缓存时间 (单位秒)
6
+ * @default 30 * 24 * 60 * 60
7
+ */
8
+ cacheTime?: number;
9
+ }
10
+ export declare class WebStorage {
11
+ private storage;
12
+ private options;
13
+ constructor(storage?: Storage, options?: WebStorageOptions);
14
+ private getKey;
15
+ /**
16
+ * 设置缓存
17
+ * @param key string 缓存键
18
+ * @param value any 缓存值
19
+ * @param expire number | null 过期时间 (单位秒) -1: 永久
20
+ */
21
+ set(key: string, value: any, expire?: number): void;
22
+ /**
23
+ * 获取缓存
24
+ * @param key string 缓存键
25
+ * @param def any 默认值
26
+ * @returns 缓存值
27
+ */
28
+ get(key: string, def?: any): any;
29
+ /**
30
+ * 移除缓存
31
+ * @param key string 缓存键
32
+ */
33
+ remove(key: string): void;
34
+ /**
35
+ * 清空缓存
36
+ */
37
+ clear(): void;
38
+ }
39
+ export declare const createStorage: (storage?: Storage, options?: WebStorageOptions) => WebStorage;
@@ -0,0 +1,3 @@
1
+ export declare const ls: import("./Storage").WebStorage;
2
+ export declare const ss: import("./Storage").WebStorage;
3
+ export default ls;
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "jubo-sdk",
3
+ "version": "1.0.2",
4
+ "description": "juboSDK",
5
+ "keywords": [
6
+ "juboSDK",
7
+ "jubo",
8
+ "sdk",
9
+ "typescript"
10
+ ],
11
+ "main": "dist/index.cjs.js",
12
+ "module": "dist/index.esm.js",
13
+ "browser": "dist/index.js",
14
+ "typings": "dist/index.d.ts",
15
+ "types": "dist/index.d.ts",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "engines": {
20
+ "node": ">=16.19.0"
21
+ },
22
+ "engineStrict": true,
23
+ "scripts": {
24
+ "build": "rimraf dist/ && rollup -c rollup.config.ts --configPlugin typescript",
25
+ "build:tsc": "rimraf dist/ && tsc --module esnext && npm run build",
26
+ "publish": "npm run build:tsc && yalc push",
27
+ "watch": "nodemon --ignore dist/ --ignore node_modules/ --watch src/ -C -e js,jsx,ts,tsx,css,less --debug -x npm run publish",
28
+ "test": "echo \"Error: no test specified\" && exit 1",
29
+ "rimraf": "rimraf dist/",
30
+ "prepare": "husky install",
31
+ "commit": "git add . && git-cz"
32
+ },
33
+ "author": "Lanrri <lanrri@163.com>",
34
+ "license": "ISC",
35
+ "devDependencies": {
36
+ "@babel/core": "^7.21.3",
37
+ "@babel/plugin-transform-runtime": "^7.21.0",
38
+ "@babel/preset-env": "^7.20.2",
39
+ "@commitlint/cli": "^17.4.4",
40
+ "@commitlint/config-conventional": "^17.4.4",
41
+ "@rollup/plugin-babel": "^6.0.3",
42
+ "@rollup/plugin-commonjs": "^24.0.1",
43
+ "@rollup/plugin-json": "^6.0.0",
44
+ "@rollup/plugin-node-resolve": "^15.0.1",
45
+ "@rollup/plugin-terser": "^0.4.0",
46
+ "@rollup/plugin-typescript": "^11.0.0",
47
+ "@types/node": "^18.15.3",
48
+ "@types/rollup-plugin-json": "^3.0.3",
49
+ "@typescript-eslint/eslint-plugin": "^5.55.0",
50
+ "@typescript-eslint/parser": "^5.55.0",
51
+ "commitizen": "^4.3.0",
52
+ "cz-customizable": "^7.0.0",
53
+ "eslint": "^8.36.0",
54
+ "eslint-config-prettier": "^8.7.0",
55
+ "eslint-plugin-prettier": "^4.2.1",
56
+ "husky": "^8.0.3",
57
+ "lint-staged": "^13.2.0",
58
+ "nodemon": "^2.0.22",
59
+ "prettier": "^2.8.4",
60
+ "rimraf": "^4.4.1",
61
+ "rollup": "^3.19.1",
62
+ "rollup-plugin-dts": "^5.3.0",
63
+ "rollup-plugin-sourcemaps": "^0.6.3",
64
+ "ts-node": "^10.9.1",
65
+ "tslib": "^2.5.0",
66
+ "typescript": "^5.0.2"
67
+ },
68
+ "dependencies": {
69
+ "core-js": "^3.30.1",
70
+ "dsbridge": "^3.1.4",
71
+ "weixin-js-sdk": "^1.6.0"
72
+ },
73
+ "config": {
74
+ "commitizen": {
75
+ "path": "./node_modules/cz-customizable"
76
+ }
77
+ },
78
+ "lint-staged": {
79
+ "*.{js,jsx,ts,tsx}": [
80
+ "eslint --fix",
81
+ "prettier --write"
82
+ ],
83
+ "{!(package)*.json,*.code-snippets}": [
84
+ "prettier --write--parser json"
85
+ ],
86
+ "package.json": [
87
+ "prettier --write"
88
+ ],
89
+ "*.vue": [
90
+ "eslint --fix",
91
+ "prettier --write",
92
+ "stylelint --fix"
93
+ ],
94
+ "*.{scss,less,styl}": [
95
+ "stylelint --fix",
96
+ "prettier --write"
97
+ ],
98
+ "*.md": [
99
+ "prettier --write"
100
+ ]
101
+ }
102
+ }