@payabli/components-web 0.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/dist/index.d.ts +21 -0
- package/dist/index.js +45 -0
- package/package.json +40 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentHandle, PayabliConstructor } from '@payabli/component-contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Every partner-facing type is defined once in `@payabli/component-contracts`. The
|
|
4
|
+
* CDN script implements the same types, so the surface this wrapper advertises
|
|
5
|
+
* is the one the script is compiled against.
|
|
6
|
+
*/
|
|
7
|
+
export { ErrorCodes } from '@payabli/component-contracts';
|
|
8
|
+
export type { AppearanceOptions, CardBrand, ComponentEventKey, ComponentEventMap, ComponentHandle, ComponentOptions, ComponentType, CreateOptions, ErrorCode, EventMap, MountOptions, PayInEvents, PayInOptions, PayabliConfig, PayabliConstructor, PayabliInstance, PaymentMethodName, Session, SessionEventKey, SessionEventMap, SessionEventPayload, } from '@payabli/component-contracts';
|
|
9
|
+
export type LoadOptions = {
|
|
10
|
+
scriptSrc?: string;
|
|
11
|
+
integrity?: string;
|
|
12
|
+
nonce?: string;
|
|
13
|
+
};
|
|
14
|
+
declare global {
|
|
15
|
+
interface Window {
|
|
16
|
+
Payabli?: PayabliConstructor;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export declare function loadPayabli(options?: LoadOptions): Promise<PayabliConstructor>;
|
|
20
|
+
export type Payabli = PayabliConstructor;
|
|
21
|
+
export type PayInComponent = ComponentHandle<'payin'>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every partner-facing type is defined once in `@payabli/component-contracts`. The
|
|
3
|
+
* CDN script implements the same types, so the surface this wrapper advertises
|
|
4
|
+
* is the one the script is compiled against.
|
|
5
|
+
*/
|
|
6
|
+
export { ErrorCodes } from '@payabli/component-contracts';
|
|
7
|
+
let loadPromise = null;
|
|
8
|
+
export function loadPayabli(options = {}) {
|
|
9
|
+
if (typeof window === 'undefined') {
|
|
10
|
+
throw new Error('loadPayabli must be called in a browser environment.');
|
|
11
|
+
}
|
|
12
|
+
if (window.Payabli) {
|
|
13
|
+
return Promise.resolve(window.Payabli);
|
|
14
|
+
}
|
|
15
|
+
if (loadPromise) {
|
|
16
|
+
return loadPromise;
|
|
17
|
+
}
|
|
18
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const script = document.createElement('script');
|
|
21
|
+
script.src = (_a = options.scriptSrc) !== null && _a !== void 0 ? _a : 'https://cdn.payabli.com/v2/components-web.js';
|
|
22
|
+
script.async = true;
|
|
23
|
+
if (options.integrity) {
|
|
24
|
+
script.integrity = options.integrity;
|
|
25
|
+
script.crossOrigin = 'anonymous';
|
|
26
|
+
}
|
|
27
|
+
if (options.nonce) {
|
|
28
|
+
script.nonce = options.nonce;
|
|
29
|
+
}
|
|
30
|
+
script.onload = () => {
|
|
31
|
+
if (!window.Payabli) {
|
|
32
|
+
loadPromise = null;
|
|
33
|
+
reject(new Error('Payabli script loaded but global was not found.'));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
resolve(window.Payabli);
|
|
37
|
+
};
|
|
38
|
+
script.onerror = () => {
|
|
39
|
+
loadPromise = null;
|
|
40
|
+
reject(new Error('Failed to load Payabli script.'));
|
|
41
|
+
};
|
|
42
|
+
document.head.appendChild(script);
|
|
43
|
+
});
|
|
44
|
+
return loadPromise;
|
|
45
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@payabli/components-web",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Payabli embedded components SDK for npm. Loads the CDN script and re-exports the typed API.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/payabli/components-web.git",
|
|
10
|
+
"directory": "packages/npm-wrapper"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"module": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"!dist/__tests__"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@payabli/component-contracts": "0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.build.json",
|
|
36
|
+
"lint": "eslint src",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"test": "vitest run"
|
|
39
|
+
}
|
|
40
|
+
}
|