@tosspayments/tosspayments-sdk 0.1.1-alpha.1 → 0.1.1-alpha.1.0
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/README.md +2 -2
- package/dist/index.cjs.js +49 -25
- package/dist/index.esm.js +49 -25
- package/package.json +7 -8
- package/types/clearTossPayments.d.ts +0 -10
package/README.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -8,53 +8,77 @@ function clearTossPayments() {
|
|
|
8
8
|
var _script$parentElement;
|
|
9
9
|
|
|
10
10
|
var script = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
|
|
11
|
-
script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script);
|
|
11
|
+
script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
|
|
12
14
|
window.TossPayments = undefined;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
var cachedPromise;
|
|
17
|
+
var cachedPromise = null;
|
|
16
18
|
function loadScript(src, namespace) {
|
|
17
19
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
18
|
-
var existingElement = document.querySelector("[src=\"".concat(src, "\"]"));
|
|
19
20
|
|
|
20
|
-
if (
|
|
21
|
+
if (cachedPromise != null) {
|
|
21
22
|
return cachedPromise;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
var promise = new Promise(function (resolve, reject) {
|
|
26
|
+
try {
|
|
27
|
+
var onLoad = function onLoad() {
|
|
28
|
+
if (getNamespace(namespace) != null) {
|
|
29
|
+
resolve(getNamespace(namespace));
|
|
30
|
+
} else {
|
|
31
|
+
reject(new Error("[TossPayments SDK] ".concat(namespace, " is not available")));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var onError = function onError() {
|
|
36
|
+
reject(new Error("[TossPayments SDK] Failed to load script: [".concat(src, "]")));
|
|
37
|
+
};
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
40
|
+
return resolve(null);
|
|
41
|
+
}
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
if (getNamespace(namespace) != null) {
|
|
44
|
+
return resolve(getNamespace(namespace));
|
|
45
|
+
}
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
script.onload = function () {
|
|
37
|
-
var loadedNamespace = getNamespace(namespace);
|
|
47
|
+
var existingScript = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
38
48
|
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
if (existingScript != null) {
|
|
50
|
+
var _existingScript$paren;
|
|
51
|
+
|
|
52
|
+
existingScript.removeEventListener('load', onLoad);
|
|
53
|
+
existingScript.removeEventListener('error', onError);
|
|
54
|
+
(_existingScript$paren = existingScript.parentElement) === null || _existingScript$paren === void 0 ? void 0 : _existingScript$paren.removeChild(existingScript);
|
|
43
55
|
}
|
|
44
|
-
};
|
|
45
56
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
var script = document.createElement('script');
|
|
58
|
+
script.src = src;
|
|
59
|
+
script.addEventListener('load', onLoad);
|
|
60
|
+
script.addEventListener('error', onError);
|
|
61
|
+
|
|
62
|
+
if (options.priority != null) {
|
|
63
|
+
script.fetchPriority = options.priority;
|
|
64
|
+
}
|
|
49
65
|
|
|
50
|
-
|
|
66
|
+
document.head.appendChild(script);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
reject(error);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
cachedPromise = promise["catch"](function (error) {
|
|
73
|
+
cachedPromise = null;
|
|
74
|
+
return Promise.reject(error);
|
|
51
75
|
});
|
|
52
76
|
return cachedPromise;
|
|
53
77
|
}
|
|
54
78
|
|
|
55
79
|
function getNamespace(name) {
|
|
56
80
|
return window[name];
|
|
57
|
-
}
|
|
81
|
+
} // Test용
|
|
58
82
|
|
|
59
83
|
function loadTossPayments(clientKey) {
|
|
60
84
|
var loadOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
package/dist/index.esm.js
CHANGED
|
@@ -4,53 +4,77 @@ function clearTossPayments() {
|
|
|
4
4
|
var _script$parentElement;
|
|
5
5
|
|
|
6
6
|
var script = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
|
|
7
|
-
script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script);
|
|
7
|
+
script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
|
|
8
10
|
window.TossPayments = undefined;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
var cachedPromise;
|
|
13
|
+
var cachedPromise = null;
|
|
12
14
|
function loadScript(src, namespace) {
|
|
13
15
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
14
|
-
var existingElement = document.querySelector("[src=\"".concat(src, "\"]"));
|
|
15
16
|
|
|
16
|
-
if (
|
|
17
|
+
if (cachedPromise != null) {
|
|
17
18
|
return cachedPromise;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var promise = new Promise(function (resolve, reject) {
|
|
22
|
+
try {
|
|
23
|
+
var onLoad = function onLoad() {
|
|
24
|
+
if (getNamespace(namespace) != null) {
|
|
25
|
+
resolve(getNamespace(namespace));
|
|
26
|
+
} else {
|
|
27
|
+
reject(new Error("[TossPayments SDK] ".concat(namespace, " is not available")));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var onError = function onError() {
|
|
32
|
+
reject(new Error("[TossPayments SDK] Failed to load script: [".concat(src, "]")));
|
|
33
|
+
};
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
36
|
+
return resolve(null);
|
|
37
|
+
}
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
if (getNamespace(namespace) != null) {
|
|
40
|
+
return resolve(getNamespace(namespace));
|
|
41
|
+
}
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
script.onload = function () {
|
|
33
|
-
var loadedNamespace = getNamespace(namespace);
|
|
43
|
+
var existingScript = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
34
44
|
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
if (existingScript != null) {
|
|
46
|
+
var _existingScript$paren;
|
|
47
|
+
|
|
48
|
+
existingScript.removeEventListener('load', onLoad);
|
|
49
|
+
existingScript.removeEventListener('error', onError);
|
|
50
|
+
(_existingScript$paren = existingScript.parentElement) === null || _existingScript$paren === void 0 ? void 0 : _existingScript$paren.removeChild(existingScript);
|
|
39
51
|
}
|
|
40
|
-
};
|
|
41
52
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
var script = document.createElement('script');
|
|
54
|
+
script.src = src;
|
|
55
|
+
script.addEventListener('load', onLoad);
|
|
56
|
+
script.addEventListener('error', onError);
|
|
57
|
+
|
|
58
|
+
if (options.priority != null) {
|
|
59
|
+
script.fetchPriority = options.priority;
|
|
60
|
+
}
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
document.head.appendChild(script);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
reject(error);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
cachedPromise = promise["catch"](function (error) {
|
|
69
|
+
cachedPromise = null;
|
|
70
|
+
return Promise.reject(error);
|
|
47
71
|
});
|
|
48
72
|
return cachedPromise;
|
|
49
73
|
}
|
|
50
74
|
|
|
51
75
|
function getNamespace(name) {
|
|
52
76
|
return window[name];
|
|
53
|
-
}
|
|
77
|
+
} // Test용
|
|
54
78
|
|
|
55
79
|
function loadTossPayments(clientKey) {
|
|
56
80
|
var loadOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tosspayments/tosspayments-sdk",
|
|
3
3
|
"description": "TossPayments.js Tosspayments SDK.",
|
|
4
|
-
"version": "0.1.1-alpha.1",
|
|
4
|
+
"version": "0.1.1-alpha.1.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly --declaration --declarationDir types",
|
|
11
11
|
"prepack": "yarn build",
|
|
12
|
-
"test": "
|
|
12
|
+
"test": "vitest",
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
@@ -20,16 +20,15 @@
|
|
|
20
20
|
"@rollup/plugin-babel": "^5.3.0",
|
|
21
21
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
22
22
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
23
|
-
"@tosspayments/sdk-loader": "1.2.1-alpha.0",
|
|
23
|
+
"@tosspayments/sdk-loader": "1.2.1-alpha.1.0",
|
|
24
24
|
"@tosspayments/standard-public-interfaces": "2.0.0-next.24",
|
|
25
|
-
"
|
|
26
|
-
"jest": "^27.0.7",
|
|
25
|
+
"happy-dom": "^14.12.3",
|
|
27
26
|
"prettier": "^2.0.2",
|
|
28
27
|
"rollup": "^2.60.0",
|
|
29
28
|
"rollup-plugin-babel": "^4.4.0",
|
|
30
|
-
"ts-jest": "^27.0.7",
|
|
31
29
|
"tslib": "^1.11.1",
|
|
32
|
-
"typescript": "5.2.2"
|
|
30
|
+
"typescript": "5.2.2",
|
|
31
|
+
"vitest": "^1.6.0"
|
|
33
32
|
},
|
|
34
33
|
"files": [
|
|
35
34
|
"dist",
|
|
@@ -38,5 +37,5 @@
|
|
|
38
37
|
"publishConfig": {
|
|
39
38
|
"access": "public"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "b50d0d5975b9d6e8dec619a72ab468d0059586c3"
|
|
42
41
|
}
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import type { TossPayments } from '@tosspayments/standard-public-interfaces';
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
TossPayments?: TossPayments & {
|
|
5
|
-
version: string;
|
|
6
|
-
isV2: boolean;
|
|
7
|
-
ANONYMOUS: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
1
|
export declare function clearTossPayments(): void;
|