@tosspayments/tosspayments-sdk 0.1.1-alpha.0 → 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 +62 -34
- package/dist/index.esm.js +62 -33
- package/package.json +8 -11
- package/types/clearTossPayments.d.ts +1 -0
- package/types/clearTossPayments.test.d.ts +1 -0
- package/types/index.d.ts +2 -3
- package/types/loadTossPayments.test.d.ts +1 -0
- package/types/clearPaymentWidget.d.ts +0 -11
- /package/types/{loadTossPayment.d.ts → loadTossPayments.d.ts} +0 -0
package/README.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -2,44 +2,83 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
|
|
6
|
+
|
|
7
|
+
function clearTossPayments() {
|
|
8
|
+
var _script$parentElement;
|
|
9
|
+
|
|
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); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
|
|
14
|
+
window.TossPayments = undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var cachedPromise = null;
|
|
6
18
|
function loadScript(src, namespace) {
|
|
7
19
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8
|
-
var existingElement = document.querySelector("[src=\"".concat(src, "\"]"));
|
|
9
20
|
|
|
10
|
-
if (
|
|
21
|
+
if (cachedPromise != null) {
|
|
11
22
|
return cachedPromise;
|
|
12
23
|
}
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
};
|
|
38
|
+
|
|
39
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
40
|
+
return resolve(null);
|
|
41
|
+
}
|
|
17
42
|
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
if (getNamespace(namespace) != null) {
|
|
44
|
+
return resolve(getNamespace(namespace));
|
|
45
|
+
}
|
|
20
46
|
|
|
21
|
-
|
|
22
|
-
script.fetchPriority = options.priority;
|
|
23
|
-
}
|
|
47
|
+
var existingScript = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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);
|
|
55
|
+
}
|
|
56
|
+
|
|
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;
|
|
32
64
|
}
|
|
33
|
-
|
|
65
|
+
|
|
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);
|
|
34
75
|
});
|
|
35
76
|
return cachedPromise;
|
|
36
77
|
}
|
|
37
78
|
|
|
38
79
|
function getNamespace(name) {
|
|
39
80
|
return window[name];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
|
|
81
|
+
} // Test용
|
|
43
82
|
|
|
44
83
|
function loadTossPayments(clientKey) {
|
|
45
84
|
var loadOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -57,16 +96,5 @@ function loadTossPayments(clientKey) {
|
|
|
57
96
|
});
|
|
58
97
|
}
|
|
59
98
|
|
|
60
|
-
|
|
61
|
-
var _script$parentElement;
|
|
62
|
-
|
|
63
|
-
var script = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
|
|
64
|
-
script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script);
|
|
65
|
-
window.TossPayments = undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var ANONYMOUS = '@@ANONYMOUS';
|
|
69
|
-
|
|
70
|
-
exports.ANONYMOUS = ANONYMOUS;
|
|
71
|
-
exports.clearPaymentWidget = clearPaymentWidget;
|
|
99
|
+
exports.clearTossPayments = clearTossPayments;
|
|
72
100
|
exports.loadTossPayments = loadTossPayments;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,41 +1,80 @@
|
|
|
1
|
-
var
|
|
1
|
+
var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
|
|
2
|
+
|
|
3
|
+
function clearTossPayments() {
|
|
4
|
+
var _script$parentElement;
|
|
5
|
+
|
|
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); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
|
|
10
|
+
window.TossPayments = undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var cachedPromise = null;
|
|
2
14
|
function loadScript(src, namespace) {
|
|
3
15
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
4
|
-
var existingElement = document.querySelector("[src=\"".concat(src, "\"]"));
|
|
5
16
|
|
|
6
|
-
if (
|
|
17
|
+
if (cachedPromise != null) {
|
|
7
18
|
return cachedPromise;
|
|
8
19
|
}
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
|
13
30
|
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
var onError = function onError() {
|
|
32
|
+
reject(new Error("[TossPayments SDK] Failed to load script: [".concat(src, "]")));
|
|
33
|
+
};
|
|
16
34
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
36
|
+
return resolve(null);
|
|
37
|
+
}
|
|
20
38
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
window.addEventListener("TossPayments:initialize:".concat(namespace), function () {
|
|
24
|
-
if (getNamespace(namespace) !== undefined) {
|
|
25
|
-
resolve(getNamespace(namespace));
|
|
26
|
-
} else {
|
|
27
|
-
reject(new Error("[TossPayments SDK] Failed to load script: [".concat(src, "]")));
|
|
39
|
+
if (getNamespace(namespace) != null) {
|
|
40
|
+
return resolve(getNamespace(namespace));
|
|
28
41
|
}
|
|
29
|
-
|
|
42
|
+
|
|
43
|
+
var existingScript = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
44
|
+
|
|
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);
|
|
51
|
+
}
|
|
52
|
+
|
|
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
|
+
}
|
|
61
|
+
|
|
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);
|
|
30
71
|
});
|
|
31
72
|
return cachedPromise;
|
|
32
73
|
}
|
|
33
74
|
|
|
34
75
|
function getNamespace(name) {
|
|
35
76
|
return window[name];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
|
|
77
|
+
} // Test용
|
|
39
78
|
|
|
40
79
|
function loadTossPayments(clientKey) {
|
|
41
80
|
var loadOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -53,14 +92,4 @@ function loadTossPayments(clientKey) {
|
|
|
53
92
|
});
|
|
54
93
|
}
|
|
55
94
|
|
|
56
|
-
|
|
57
|
-
var _script$parentElement;
|
|
58
|
-
|
|
59
|
-
var script = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
|
|
60
|
-
script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script);
|
|
61
|
-
window.TossPayments = undefined;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
var ANONYMOUS = '@@ANONYMOUS';
|
|
65
|
-
|
|
66
|
-
export { ANONYMOUS, clearPaymentWidget, loadTossPayments };
|
|
95
|
+
export { clearTossPayments, loadTossPayments };
|
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.0",
|
|
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,13 +9,10 @@
|
|
|
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",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@tosspayments/standard-public-interfaces": "2.0.0-next.24"
|
|
18
|
-
},
|
|
19
16
|
"devDependencies": {
|
|
20
17
|
"@babel/core": "^7.11.6",
|
|
21
18
|
"@babel/preset-env": "^7.11.5",
|
|
@@ -23,15 +20,15 @@
|
|
|
23
20
|
"@rollup/plugin-babel": "^5.3.0",
|
|
24
21
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
25
22
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
26
|
-
"@tosspayments/sdk-loader": "1.2.0",
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
23
|
+
"@tosspayments/sdk-loader": "1.2.1-alpha.1.0",
|
|
24
|
+
"@tosspayments/standard-public-interfaces": "2.0.0-next.24",
|
|
25
|
+
"happy-dom": "^14.12.3",
|
|
29
26
|
"prettier": "^2.0.2",
|
|
30
27
|
"rollup": "^2.60.0",
|
|
31
28
|
"rollup-plugin-babel": "^4.4.0",
|
|
32
|
-
"ts-jest": "^27.0.7",
|
|
33
29
|
"tslib": "^1.11.1",
|
|
34
|
-
"typescript": "5.2.2"
|
|
30
|
+
"typescript": "5.2.2",
|
|
31
|
+
"vitest": "^1.6.0"
|
|
35
32
|
},
|
|
36
33
|
"files": [
|
|
37
34
|
"dist",
|
|
@@ -40,5 +37,5 @@
|
|
|
40
37
|
"publishConfig": {
|
|
41
38
|
"access": "public"
|
|
42
39
|
},
|
|
43
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "b50d0d5975b9d6e8dec619a72ab468d0059586c3"
|
|
44
41
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clearTossPayments(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export declare const ANONYMOUS = "@@ANONYMOUS";
|
|
1
|
+
export { clearTossPayments } from './clearTossPayments';
|
|
2
|
+
export { loadTossPayments } from './loadTossPayments';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { 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
|
-
export declare function clearPaymentWidget(): void;
|
|
File without changes
|