@alipay/ams-checkout 0.0.1720509876-dev.3 → 0.0.1720509876-dev.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/esm/util/index.js CHANGED
@@ -261,4 +261,70 @@ function parseBase64ToString(base64) {
261
261
  return null;
262
262
  }
263
263
  }
264
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString };
264
+ function loadSDKScript(_ref, logger) {
265
+ var _this2 = this;
266
+ var src = _ref.src,
267
+ _ref$attrOptions = _ref.attrOptions,
268
+ attrOptions = _ref$attrOptions === void 0 ? {} : _ref$attrOptions,
269
+ _ref$timeOut = _ref.timeOut,
270
+ timeOut = _ref$timeOut === void 0 ? 3 : _ref$timeOut,
271
+ _ref$loadCallback = _ref.loadCallback,
272
+ loadCallback = _ref$loadCallback === void 0 ? null : _ref$loadCallback;
273
+ return new Promise(function (resolve, reject) {
274
+ // 创建 script 标签
275
+ logger.logInfo({
276
+ title: 'load_item_sdk_start'
277
+ }, {
278
+ src: src,
279
+ attrOptions: JSON.stringify(attrOptions)
280
+ });
281
+ console.time();
282
+ var script = document.createElement('script');
283
+ var timer = null;
284
+ script.type = 'text/javascript';
285
+
286
+ // 监听加载完成事件
287
+ script.onload = function () {
288
+ // 当脚本加载完毕时,执行回调函数
289
+ logger.logInfo({
290
+ title: 'load_item_sdk_end'
291
+ }, {
292
+ src: src,
293
+ attrOptions: JSON.stringify(attrOptions)
294
+ });
295
+ console.timeEnd();
296
+ clearTimeout(timer);
297
+ if (loadCallback) loadCallback();
298
+ resolve(true);
299
+ };
300
+
301
+ // 监听加载失败事件
302
+ script.onerror = function () {
303
+ logger.logError({
304
+ title: 'load_item_sdk_error'
305
+ }, {
306
+ src: src,
307
+ attrOptions: JSON.stringify(attrOptions)
308
+ });
309
+ clearTimeout(timer);
310
+ console.error('The script ' + src + ' is not accessible.');
311
+ reject(false);
312
+ };
313
+ timer = setTimeout(function () {
314
+ _this2.logger.logError({
315
+ title: 'load_item_sdk_timeout'
316
+ }, {
317
+ src: src,
318
+ attrOptions: JSON.stringify(attrOptions)
319
+ });
320
+ reject(false);
321
+ }, timeOut * 1000);
322
+ script.src = src;
323
+ attrOptions && Object.keys(attrOptions).forEach(function (key) {
324
+ script.setAttribute(key, attrOptions[key]);
325
+ });
326
+ // 将 script 标签添加到页面中
327
+ document.head.appendChild(script);
328
+ });
329
+ }
330
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
@@ -27,13 +27,13 @@ export declare function isGreyscaleMatch(item: UpgradeItem, randomGreyscale: num
27
27
  export declare const getMatchAppVersion: (_extendInfo: string, sdkInfo: UpgradeSdkInfo) => string;
28
28
  /**
29
29
  * 获取保存的加载版本
30
- * @param productScene
30
+ * @param versionKey
31
31
  * @returns
32
32
  */
33
- export declare const getLastAppVersion: (productScene: string) => string;
33
+ export declare const getLastAppVersion: (versionKey: string) => string;
34
34
  /**
35
35
  * 保存指定场景的加载版本供下次使用
36
- * @param productScene
36
+ * @param versionKey
37
37
  * @returns
38
38
  */
39
- export declare const setLastAppVersion: (productScene: string, appVersion: string) => boolean;
39
+ export declare const setLastAppVersion: (versionKey: string, appVersion: string) => boolean;
@@ -89,12 +89,12 @@ export var getMatchAppVersion = function getMatchAppVersion(_extendInfo, sdkInfo
89
89
 
90
90
  /**
91
91
  * 获取保存的加载版本
92
- * @param productScene
92
+ * @param versionKey
93
93
  * @returns
94
94
  */
95
- export var getLastAppVersion = function getLastAppVersion(productScene) {
95
+ export var getLastAppVersion = function getLastAppVersion(versionKey) {
96
96
  try {
97
- var key = "Antom_".concat(productScene, "_LastAppVersion");
97
+ var key = "Antom_".concat(versionKey, "_LastAppVersion");
98
98
  return getStorageString(key, '');
99
99
  } catch (error) {
100
100
  return '';
@@ -102,12 +102,12 @@ export var getLastAppVersion = function getLastAppVersion(productScene) {
102
102
  };
103
103
  /**
104
104
  * 保存指定场景的加载版本供下次使用
105
- * @param productScene
105
+ * @param versionKey
106
106
  * @returns
107
107
  */
108
- export var setLastAppVersion = function setLastAppVersion(productScene, appVersion) {
108
+ export var setLastAppVersion = function setLastAppVersion(versionKey, appVersion) {
109
109
  try {
110
- var key = "Antom_".concat(productScene, "_LastAppVersion");
110
+ var key = "Antom_".concat(versionKey, "_LastAppVersion");
111
111
  return setStorageString(key, appVersion);
112
112
  } catch (error) {
113
113
  return false;
package/package.json CHANGED
@@ -1,56 +1 @@
1
- {
2
- "name": "@alipay/ams-checkout",
3
- "version": "0.0.1720509876-dev.3",
4
- "description": "",
5
- "author": "",
6
- "main": "esm/index.js",
7
- "module": "esm/index.js",
8
- "typings": "esm/index.d.ts",
9
- "files": [
10
- "dist",
11
- "esm",
12
- "LEGAL.md",
13
- "LICENSE",
14
- "README.md"
15
- ],
16
- "scripts": {
17
- "build": "father build",
18
- "ci": "npm run lint",
19
- "cov": "jest --coverage",
20
- "format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
21
- "lint": "eslint ./src",
22
- "test": "jest"
23
- },
24
- "dependencies": {
25
- "axios": "^1.3.4",
26
- "uuid": "^9.0.0"
27
- },
28
- "devDependencies": {
29
- "@babel/core": "^7.20.7",
30
- "@babel/preset-env": "^7.20.2",
31
- "@testing-library/jest-dom": "^5.1.1",
32
- "@testing-library/react": "^9.5.0",
33
- "@types/jest": "^29.2.4",
34
- "@types/uuid": "^9.0.0",
35
- "@typescript-eslint/eslint-plugin": "latest",
36
- "@typescript-eslint/parser": "^5.60.0",
37
- "babel-jest": "^29.3.1",
38
- "babel-loader": "^9.1.0",
39
- "babel-plugin-import": "^1.13.0",
40
- "eslint": "^8.36.0",
41
- "eslint-plugin-prettier": "latest",
42
- "father": "^4.2.3",
43
- "jest": "^29.5.0",
44
- "jest-environment-jsdom": "^29.3.1",
45
- "prettier": "^2.8.4",
46
- "prettier-plugin-organize-imports": "^3.2.3",
47
- "prettier-plugin-packagejson": "^2.4.5",
48
- "ts-jest": "^29.0.3",
49
- "ts-node": "^10.9.1",
50
- "typescript": "^4.9.5"
51
- },
52
- "engines": {},
53
- "publishConfig": {
54
- "access": "public"
55
- }
56
- }
1
+ {"name":"@alipay/ams-checkout","version":"0.0.1720509876-dev.6","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}