@getpara/graz-integration 2.0.0-dev.10
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/chunk-IV3L3JVM.js +46 -0
- package/dist/connector.d.ts +18 -0
- package/dist/connector.js +63 -0
- package/dist/connectorModal.d.ts +4 -0
- package/dist/connectorModal.js +79 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +13 -0
- package/dist/package.json +4 -0
- package/package.json +28 -0
- package/scripts/build.mjs +36 -0
- package/src/connector.ts +67 -0
- package/src/connectorModal.tsx +83 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +13 -0
- package/vitest.config.js +22 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __async = (__this, __arguments, generator) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
var fulfilled = (value) => {
|
|
24
|
+
try {
|
|
25
|
+
step(generator.next(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var rejected = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.throw(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
__spreadValues,
|
|
44
|
+
__spreadProps,
|
|
45
|
+
__async
|
|
46
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChainInfo } from '@keplr-wallet/types';
|
|
2
|
+
import { ParaGrazConnector as CoreParaGrazConnector, ParaGrazConfig as CoreParaGrazConfig } from '@getpara/graz-connector';
|
|
3
|
+
import { ParaModalProps as CoreParaModalProps } from '@getpara/react-sdk-lite';
|
|
4
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
export type ParaModalProps = Omit<CoreParaModalProps, 'isOpen' | 'para'> & {
|
|
6
|
+
appName: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ParaGrazConfig extends CoreParaGrazConfig {
|
|
9
|
+
modalProps?: ParaModalProps;
|
|
10
|
+
queryClient?: QueryClient;
|
|
11
|
+
}
|
|
12
|
+
export declare class ParaGrazConnector extends CoreParaGrazConnector {
|
|
13
|
+
protected isModalClosed: boolean;
|
|
14
|
+
protected config: ParaGrazConfig;
|
|
15
|
+
constructor(config: ParaGrazConfig, chains?: ChainInfo[] | null);
|
|
16
|
+
protected waitForLogin(timeoutMs?: number): Promise<void>;
|
|
17
|
+
enable(chainIdsInput: string | string[]): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "./chunk-IV3L3JVM.js";
|
|
5
|
+
import {
|
|
6
|
+
ParaGrazConnector as CoreParaGrazConnector,
|
|
7
|
+
toArray
|
|
8
|
+
} from "@getpara/graz-connector";
|
|
9
|
+
import { renderModal } from "./connectorModal";
|
|
10
|
+
class ParaGrazConnector extends CoreParaGrazConnector {
|
|
11
|
+
constructor(config, chains) {
|
|
12
|
+
super(config, chains);
|
|
13
|
+
this.isModalClosed = true;
|
|
14
|
+
}
|
|
15
|
+
waitForLogin(timeoutMs = 6e4) {
|
|
16
|
+
return __async(this, null, function* () {
|
|
17
|
+
const deadline = Date.now() + timeoutMs;
|
|
18
|
+
let delay = 500;
|
|
19
|
+
const MAX_DELAY = 5e3;
|
|
20
|
+
while (true) {
|
|
21
|
+
if (yield this.paraWebClient.isFullyLoggedIn()) return;
|
|
22
|
+
if (this.isModalClosed) throw new Error("Para connector: user closed login modal");
|
|
23
|
+
if (Date.now() >= deadline) throw new Error("Para connector: login timeout");
|
|
24
|
+
yield new Promise((r) => setTimeout(r, delay));
|
|
25
|
+
delay = Math.min(delay * 1.5, MAX_DELAY);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
enable(chainIdsInput) {
|
|
30
|
+
return __async(this, null, function* () {
|
|
31
|
+
var _a, _b, _c, _d, _e;
|
|
32
|
+
const chainIds = toArray(chainIdsInput);
|
|
33
|
+
const previousEnabled = new Set(this.enabledChainIds);
|
|
34
|
+
try {
|
|
35
|
+
chainIds.forEach((id) => this.enabledChainIds.add(id));
|
|
36
|
+
if (yield this.hasCosmosWallet()) {
|
|
37
|
+
(_b = (_a = this.events) == null ? void 0 : _a.onEnabled) == null ? void 0 : _b.call(_a, chainIds, this);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.isModalClosed = false;
|
|
41
|
+
yield renderModal(
|
|
42
|
+
this.paraWebClient,
|
|
43
|
+
(_c = this.config.modalProps) != null ? _c : {},
|
|
44
|
+
() => {
|
|
45
|
+
this.isModalClosed = true;
|
|
46
|
+
},
|
|
47
|
+
this.config.queryClient
|
|
48
|
+
);
|
|
49
|
+
yield this.waitForLogin();
|
|
50
|
+
yield this.waitForAccounts();
|
|
51
|
+
(_e = (_d = this.events) == null ? void 0 : _d.onEnabled) == null ? void 0 : _e.call(_d, chainIds, this);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
this.enabledChainIds = previousEnabled;
|
|
54
|
+
throw err;
|
|
55
|
+
} finally {
|
|
56
|
+
this.isModalClosed = true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
ParaGrazConnector
|
|
63
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import ParaWeb from '@getpara/react-sdk-lite';
|
|
2
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { ParaModalProps } from './connector';
|
|
4
|
+
export declare function renderModal(para: ParaWeb, modalProps: Partial<ParaModalProps> | undefined, onCloseArg: () => void, queryClient: QueryClient): Promise<void>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "./chunk-IV3L3JVM.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { setIsOpen } from "@getpara/react-sdk-lite";
|
|
9
|
+
let rendererPromise = null;
|
|
10
|
+
function getRenderer() {
|
|
11
|
+
if (!rendererPromise) {
|
|
12
|
+
rendererPromise = (() => __async(this, null, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const { createRoot } = yield import("react-dom/client");
|
|
15
|
+
return { createRoot: (el) => createRoot(el) };
|
|
16
|
+
} catch (e) {
|
|
17
|
+
const ReactDOM = yield import("react-dom");
|
|
18
|
+
return {
|
|
19
|
+
legacyRender: ReactDOM.render,
|
|
20
|
+
legacyUnmount: ReactDOM.unmountComponentAtNode
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}))();
|
|
24
|
+
}
|
|
25
|
+
return rendererPromise;
|
|
26
|
+
}
|
|
27
|
+
function renderModal(para, modalProps, onCloseArg, queryClient) {
|
|
28
|
+
return __async(this, null, function* () {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
if (typeof window === "undefined") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const props = modalProps != null ? modalProps : {};
|
|
34
|
+
const containerId = "para-modal";
|
|
35
|
+
let container = document.getElementById(containerId);
|
|
36
|
+
if (!container) {
|
|
37
|
+
container = document.createElement("div");
|
|
38
|
+
container.id = containerId;
|
|
39
|
+
document.body.appendChild(container);
|
|
40
|
+
}
|
|
41
|
+
const renderer = yield getRenderer();
|
|
42
|
+
let root = (_a = container.__paraRoot) != null ? _a : null;
|
|
43
|
+
if (!root && renderer.createRoot) {
|
|
44
|
+
root = renderer.createRoot(container);
|
|
45
|
+
container.__paraRoot = root;
|
|
46
|
+
}
|
|
47
|
+
const { ParaProvider } = yield import("@getpara/react-sdk-lite");
|
|
48
|
+
const { QueryClientProvider } = yield import("@tanstack/react-query");
|
|
49
|
+
const handleClose = () => {
|
|
50
|
+
var _a2, _b2;
|
|
51
|
+
onCloseArg();
|
|
52
|
+
(_a2 = props.onClose) == null ? void 0 : _a2.call(props);
|
|
53
|
+
setIsOpen(false);
|
|
54
|
+
if (root) {
|
|
55
|
+
root.unmount();
|
|
56
|
+
} else {
|
|
57
|
+
(_b2 = renderer.legacyUnmount) == null ? void 0 : _b2.call(renderer, container);
|
|
58
|
+
}
|
|
59
|
+
container == null ? void 0 : container.remove();
|
|
60
|
+
};
|
|
61
|
+
const element = /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(
|
|
62
|
+
ParaProvider,
|
|
63
|
+
{
|
|
64
|
+
paraClientConfig: para,
|
|
65
|
+
config: { appName: (_b = props.appName) != null ? _b : "" },
|
|
66
|
+
paraModalConfig: __spreadProps(__spreadValues({}, props), { onClose: handleClose })
|
|
67
|
+
}
|
|
68
|
+
) });
|
|
69
|
+
if (root) {
|
|
70
|
+
root.render(element);
|
|
71
|
+
} else {
|
|
72
|
+
(_c = renderer.legacyRender) == null ? void 0 : _c.call(renderer, element, container);
|
|
73
|
+
}
|
|
74
|
+
setIsOpen(true);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
renderModal
|
|
79
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ParaGrazConnector } from './connector';
|
|
2
|
+
export type { ParaModalProps, ParaGrazConfig } from './connector';
|
|
3
|
+
export type { ParaGrazConfig as CoreParaGrazConfig } from '@getpara/graz-connector';
|
|
4
|
+
export { ParaWeb, Environment, WalletType, AuthLayout, AuthMethod, OAuthMethod } from '@getpara/react-sdk-lite';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./chunk-IV3L3JVM.js";
|
|
3
|
+
import { ParaGrazConnector } from "./connector";
|
|
4
|
+
import { ParaWeb, Environment, WalletType, AuthLayout, AuthMethod, OAuthMethod } from "@getpara/react-sdk-lite";
|
|
5
|
+
export {
|
|
6
|
+
AuthLayout,
|
|
7
|
+
AuthMethod,
|
|
8
|
+
Environment,
|
|
9
|
+
OAuthMethod,
|
|
10
|
+
ParaGrazConnector,
|
|
11
|
+
ParaWeb,
|
|
12
|
+
WalletType
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getpara/graz-integration",
|
|
3
|
+
"version": "2.0.0-dev.10",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
|
|
10
|
+
"test": "vitest run --coverage",
|
|
11
|
+
"typegen": "tsc --emitDeclarationOnly"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@getpara/graz-connector": "2.0.0-dev.10",
|
|
15
|
+
"@getpara/react-sdk-lite": "2.0.0-alpha.42"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@tanstack/react-query": "^5.74.0",
|
|
19
|
+
"graz": "^0.3.3",
|
|
20
|
+
"typescript": "5.1.6"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@tanstack/react-query": "^5.74.0",
|
|
24
|
+
"graz": "^0.3.3",
|
|
25
|
+
"react": ">=18",
|
|
26
|
+
"react-dom": ">=18"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, resolve } from 'path';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
|
+
|
|
7
|
+
const entryPoints = await glob('src/**/*.{ts,tsx,js,jsx}');
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const distDir = resolve(__dirname, '../dist');
|
|
11
|
+
|
|
12
|
+
await fs.mkdir(distDir, { recursive: true });
|
|
13
|
+
await fs.writeFile(`${distDir}/package.json`, JSON.stringify({ type: 'module', sideEffects: false }, null, 2));
|
|
14
|
+
|
|
15
|
+
/** @type {import('esbuild').BuildOptions} */
|
|
16
|
+
await esbuild.build({
|
|
17
|
+
banner: {
|
|
18
|
+
js: '"use client";', // Required for Next 13 App Router
|
|
19
|
+
},
|
|
20
|
+
bundle: false,
|
|
21
|
+
write: true,
|
|
22
|
+
format: 'esm',
|
|
23
|
+
loader: {
|
|
24
|
+
'.png': 'dataurl',
|
|
25
|
+
'.svg': 'dataurl',
|
|
26
|
+
'.json': 'text',
|
|
27
|
+
},
|
|
28
|
+
platform: 'browser',
|
|
29
|
+
entryPoints,
|
|
30
|
+
outdir: distDir,
|
|
31
|
+
allowOverwrite: true,
|
|
32
|
+
splitting: true, // Required for tree shaking
|
|
33
|
+
minify: false,
|
|
34
|
+
target: ['es2015'],
|
|
35
|
+
packages: 'external',
|
|
36
|
+
});
|
package/src/connector.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ChainInfo } from '@keplr-wallet/types';
|
|
2
|
+
import {
|
|
3
|
+
ParaGrazConnector as CoreParaGrazConnector,
|
|
4
|
+
ParaGrazConfig as CoreParaGrazConfig,
|
|
5
|
+
toArray,
|
|
6
|
+
} from '@getpara/graz-connector';
|
|
7
|
+
import { ParaModalProps as CoreParaModalProps } from '@getpara/react-sdk-lite';
|
|
8
|
+
import { renderModal } from './connectorModal';
|
|
9
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
10
|
+
|
|
11
|
+
export type ParaModalProps = Omit<CoreParaModalProps, 'isOpen' | 'para'> & { appName: string };
|
|
12
|
+
|
|
13
|
+
export interface ParaGrazConfig extends CoreParaGrazConfig {
|
|
14
|
+
modalProps?: ParaModalProps;
|
|
15
|
+
queryClient?: QueryClient;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class ParaGrazConnector extends CoreParaGrazConnector {
|
|
19
|
+
protected isModalClosed = true;
|
|
20
|
+
declare protected config: ParaGrazConfig;
|
|
21
|
+
|
|
22
|
+
constructor(config: ParaGrazConfig, chains?: ChainInfo[] | null) {
|
|
23
|
+
super(config, chains);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async waitForLogin(timeoutMs = 60_000): Promise<void> {
|
|
27
|
+
const deadline = Date.now() + timeoutMs;
|
|
28
|
+
let delay = 500;
|
|
29
|
+
const MAX_DELAY = 5_000;
|
|
30
|
+
while (true) {
|
|
31
|
+
if (await this.paraWebClient.isFullyLoggedIn()) return;
|
|
32
|
+
if (this.isModalClosed) throw new Error('Para connector: user closed login modal');
|
|
33
|
+
if (Date.now() >= deadline) throw new Error('Para connector: login timeout');
|
|
34
|
+
await new Promise(r => setTimeout(r, delay));
|
|
35
|
+
delay = Math.min(delay * 1.5, MAX_DELAY);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async enable(chainIdsInput: string | string[]): Promise<void> {
|
|
40
|
+
const chainIds = toArray(chainIdsInput);
|
|
41
|
+
const previousEnabled = new Set(this.enabledChainIds);
|
|
42
|
+
try {
|
|
43
|
+
chainIds.forEach(id => this.enabledChainIds.add(id));
|
|
44
|
+
if (await this.hasCosmosWallet()) {
|
|
45
|
+
this.events?.onEnabled?.(chainIds, this);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.isModalClosed = false;
|
|
49
|
+
await renderModal(
|
|
50
|
+
this.paraWebClient,
|
|
51
|
+
this.config.modalProps ?? {},
|
|
52
|
+
() => {
|
|
53
|
+
this.isModalClosed = true;
|
|
54
|
+
},
|
|
55
|
+
this.config.queryClient!,
|
|
56
|
+
);
|
|
57
|
+
await this.waitForLogin();
|
|
58
|
+
await this.waitForAccounts();
|
|
59
|
+
this.events?.onEnabled?.(chainIds, this);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
this.enabledChainIds = previousEnabled;
|
|
62
|
+
throw err;
|
|
63
|
+
} finally {
|
|
64
|
+
this.isModalClosed = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import ParaWeb, { setIsOpen } from '@getpara/react-sdk-lite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { ParaModalProps } from './connector';
|
|
5
|
+
|
|
6
|
+
type Root = { render(node: React.ReactNode): void; unmount(): void };
|
|
7
|
+
|
|
8
|
+
let rendererPromise: Promise<{
|
|
9
|
+
createRoot?: (el: HTMLElement) => Root;
|
|
10
|
+
legacyRender?: (node: React.ReactNode, el: HTMLElement) => void;
|
|
11
|
+
legacyUnmount?: (el: HTMLElement) => void;
|
|
12
|
+
}> | null = null;
|
|
13
|
+
|
|
14
|
+
function getRenderer() {
|
|
15
|
+
if (!rendererPromise) {
|
|
16
|
+
rendererPromise = (async () => {
|
|
17
|
+
try {
|
|
18
|
+
const { createRoot } = await import('react-dom/client');
|
|
19
|
+
return { createRoot: (el: HTMLElement) => createRoot(el) };
|
|
20
|
+
} catch {
|
|
21
|
+
const ReactDOM = await import('react-dom');
|
|
22
|
+
return {
|
|
23
|
+
legacyRender: ReactDOM.render,
|
|
24
|
+
legacyUnmount: ReactDOM.unmountComponentAtNode,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
}
|
|
29
|
+
return rendererPromise;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function renderModal(
|
|
33
|
+
para: ParaWeb,
|
|
34
|
+
modalProps: Partial<ParaModalProps> | undefined,
|
|
35
|
+
onCloseArg: () => void,
|
|
36
|
+
queryClient: QueryClient,
|
|
37
|
+
): Promise<void> {
|
|
38
|
+
if (typeof window === 'undefined') {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const props = modalProps ?? {};
|
|
42
|
+
const containerId = 'para-modal';
|
|
43
|
+
let container = document.getElementById(containerId) as HTMLElement | null;
|
|
44
|
+
if (!container) {
|
|
45
|
+
container = document.createElement('div');
|
|
46
|
+
container.id = containerId;
|
|
47
|
+
document.body.appendChild(container);
|
|
48
|
+
}
|
|
49
|
+
const renderer = await getRenderer();
|
|
50
|
+
let root: Root | null = (container as any).__paraRoot ?? null;
|
|
51
|
+
if (!root && renderer.createRoot) {
|
|
52
|
+
root = renderer.createRoot(container);
|
|
53
|
+
(container as any).__paraRoot = root;
|
|
54
|
+
}
|
|
55
|
+
const { ParaProvider } = await import('@getpara/react-sdk-lite');
|
|
56
|
+
const { QueryClientProvider } = await import('@tanstack/react-query');
|
|
57
|
+
const handleClose = () => {
|
|
58
|
+
onCloseArg();
|
|
59
|
+
props.onClose?.();
|
|
60
|
+
setIsOpen(false);
|
|
61
|
+
if (root) {
|
|
62
|
+
root.unmount();
|
|
63
|
+
} else {
|
|
64
|
+
renderer.legacyUnmount?.(container!);
|
|
65
|
+
}
|
|
66
|
+
container?.remove();
|
|
67
|
+
};
|
|
68
|
+
const element = (
|
|
69
|
+
<QueryClientProvider client={queryClient}>
|
|
70
|
+
<ParaProvider
|
|
71
|
+
paraClientConfig={para}
|
|
72
|
+
config={{ appName: props.appName ?? '' }}
|
|
73
|
+
paraModalConfig={{ ...props, onClose: handleClose }}
|
|
74
|
+
/>
|
|
75
|
+
</QueryClientProvider>
|
|
76
|
+
);
|
|
77
|
+
if (root) {
|
|
78
|
+
root.render(element);
|
|
79
|
+
} else {
|
|
80
|
+
renderer.legacyRender?.(element, container!);
|
|
81
|
+
}
|
|
82
|
+
setIsOpen(true);
|
|
83
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ParaGrazConnector } from './connector';
|
|
2
|
+
export type { ParaModalProps, ParaGrazConfig } from './connector';
|
|
3
|
+
export type { ParaGrazConfig as CoreParaGrazConfig } from '@getpara/graz-connector';
|
|
4
|
+
export { ParaWeb, Environment, WalletType, AuthLayout, AuthMethod, OAuthMethod } from '@getpara/react-sdk-lite';
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
6
|
+
"jsx": "react-jsx",
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./dist"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
12
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx", "__tests__"]
|
|
13
|
+
}
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { mergeConfig } from 'vite';
|
|
2
|
+
import baseConfig from '../../vitest.config.js';
|
|
3
|
+
|
|
4
|
+
export default mergeConfig(baseConfig, {
|
|
5
|
+
test: {
|
|
6
|
+
environment: 'jsdom',
|
|
7
|
+
coverage: {
|
|
8
|
+
provider: 'v8',
|
|
9
|
+
reporter: ['html', 'text'],
|
|
10
|
+
all: true,
|
|
11
|
+
include: ['src/**/*.{ts,tsx,js,jsx}'],
|
|
12
|
+
thresholds: {
|
|
13
|
+
lines: 98,
|
|
14
|
+
functions: 90,
|
|
15
|
+
branches: 98,
|
|
16
|
+
statements: 98,
|
|
17
|
+
},
|
|
18
|
+
reportOnFailure: true,
|
|
19
|
+
exclude: ['src/index.ts'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|