@paykka/card-checkout-ui 0.11.4 → 0.11.6
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/card-checkout-ui.js +12 -12
- package/dist/card-checkout-ui.umd.cjs +12 -12
- package/dist/es/api/modules/checkout/index.js +5 -7
- package/dist/es/components/GooglePay/index.js +1 -0
- package/dist/es/utils/request-cache-manager.js +32 -0
- package/dist/types/api/modules/checkout/index.d.ts +1 -1
- package/dist/types/utils/request-cache-manager.d.ts +12 -0
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestCacheManager } from "../../../utils/request-cache-manager.js";
|
|
1
2
|
import { http } from "../../http.js";
|
|
2
3
|
import { getBrowserParams } from "../get-browser-params.js";
|
|
3
4
|
import { checkoutMap } from "./map.js";
|
|
@@ -16,13 +17,10 @@ const getCheckoutInfo = async ({ sessionId, clientKey }, options) => {
|
|
|
16
17
|
const checkoutInfo = await queryCheckout({ sessionId, clientKey }, options);
|
|
17
18
|
return checkoutMap({ ...checkoutInfo, ...checkoutInfo == null ? void 0 : checkoutInfo.support_methods });
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
const onceGetCheckoutInfo = async (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} else {
|
|
24
|
-
return getCheckoutInfoIns;
|
|
25
|
-
}
|
|
20
|
+
const requestCacheManager = new RequestCacheManager();
|
|
21
|
+
const onceGetCheckoutInfo = async (params, options) => {
|
|
22
|
+
const request = getCheckoutInfo(params, options);
|
|
23
|
+
return requestCacheManager.cacheRequest(JSON.stringify(params), request);
|
|
26
24
|
};
|
|
27
25
|
export {
|
|
28
26
|
onceGetCheckoutInfo
|
|
@@ -162,6 +162,7 @@ function createGooglePay(checkout, pay, onClick, onCanUse) {
|
|
|
162
162
|
const loadGooglePayJS = (onload, onerror) => {
|
|
163
163
|
var _a;
|
|
164
164
|
if ((_a = window.google) == null ? void 0 : _a.payments) {
|
|
165
|
+
onload == null ? void 0 : onload();
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
168
|
loadScript({
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
class RequestCacheManager {
|
|
8
|
+
constructor() {
|
|
9
|
+
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 缓存请求
|
|
13
|
+
* @param key 任意格式,自己控制
|
|
14
|
+
* @param request 请求函数
|
|
15
|
+
*/
|
|
16
|
+
cacheRequest(key, request) {
|
|
17
|
+
const cachedRequest = this.cache.get(key);
|
|
18
|
+
if (cachedRequest) {
|
|
19
|
+
return cachedRequest;
|
|
20
|
+
}
|
|
21
|
+
const promise = request;
|
|
22
|
+
const wrappedPromise = promise.catch((error) => {
|
|
23
|
+
this.cache.delete(key);
|
|
24
|
+
throw error;
|
|
25
|
+
});
|
|
26
|
+
this.cache.set(key, wrappedPromise);
|
|
27
|
+
return wrappedPromise;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
RequestCacheManager
|
|
32
|
+
};
|
|
@@ -3,4 +3,4 @@ import type { CheckoutRes, QueryCheckoutParams } from './type';
|
|
|
3
3
|
export * from './type';
|
|
4
4
|
export * from './map';
|
|
5
5
|
export declare const getCheckoutInfo: ({ sessionId, clientKey }: QueryCheckoutParams, options?: RequestOptions) => Promise<CheckoutRes>;
|
|
6
|
-
export declare const onceGetCheckoutInfo: (
|
|
6
|
+
export declare const onceGetCheckoutInfo: (params: QueryCheckoutParams, options?: RequestOptions) => Promise<CheckoutRes>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykka/card-checkout-ui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/paykka-card-checkout-ui.umd.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"release:prod": "pnpm build && pnpm changeset:release",
|
|
34
34
|
"release:noprod": "pnpm build && pnpm changeset:pre-exit && pnpm changeset:prelease",
|
|
35
35
|
"type-check": "tsc --noEmit -p tsconfig.json --composite false",
|
|
36
|
-
"release:npm": "npm publish --registry=https://registry.npmjs.org --access public"
|
|
36
|
+
"release:npm": "pnpm build && npm publish --registry=https://registry.npmjs.org --access public"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"registry": "https://packages.aliyun.com/640edee5a84870ae9d591e48/npm/npm-registry/"
|