@pioneer-platform/pioneer-react 0.0.1 → 0.2.32

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.
Files changed (93) hide show
  1. package/.eslintrc.js +24 -0
  2. package/.github/workflows/release.yml +22 -0
  3. package/.github/workflows/update-license.yml +11 -0
  4. package/.lintstagedrc.json +6 -0
  5. package/.prettierrc +7 -0
  6. package/.vscode/extensions.json +8 -0
  7. package/CHANGELOG.md +5 -0
  8. package/LICENSE +21 -0
  9. package/README.md +40 -0
  10. package/commitlint.config.js +3 -0
  11. package/dist/assets/404 Error-rafiki.svg +1 -0
  12. package/dist/assets/Building blocks-amico.svg +1 -0
  13. package/dist/assets/chakra-ui-logomark-colored.svg +10 -0
  14. package/dist/assets/favicon.svg +0 -0
  15. package/dist/assets/react-icon.svg +7 -0
  16. package/dist/assets/ts-logo-512.svg +1 -0
  17. package/dist/assets/vite-logo.svg +15 -0
  18. package/dist/index.js +384249 -0
  19. package/dist/index_3bde86fb.js +205 -0
  20. package/dist/index_49fce0b0.js +384033 -0
  21. package/dist/index_d01e819c.css +63 -0
  22. package/dist/manifest.json +12 -0
  23. package/dist/robots.txt +6 -0
  24. package/index.html +13 -0
  25. package/netlify.toml +10 -0
  26. package/package.json +70 -10
  27. package/public/assets/404 Error-rafiki.svg +1 -0
  28. package/public/assets/Building blocks-amico.svg +1 -0
  29. package/public/assets/chakra-ui-logomark-colored.svg +10 -0
  30. package/public/assets/favicon.svg +0 -0
  31. package/public/assets/react-icon.svg +7 -0
  32. package/public/assets/ts-logo-512.svg +1 -0
  33. package/public/assets/vite-logo.svg +15 -0
  34. package/public/manifest.json +12 -0
  35. package/public/robots.txt +6 -0
  36. package/renovate.json +11 -0
  37. package/src/App.tsx +21 -0
  38. package/src/index.tsx +41 -0
  39. package/src/lib/assets/Icons/KeepKeyIcon.tsx +13 -0
  40. package/src/lib/assets/Icons/KeplrIcon.tsx +140 -0
  41. package/src/lib/assets/Icons/MetaMaskIcon.tsx +126 -0
  42. package/src/lib/assets/Icons/TallyHoIcon.tsx +17 -0
  43. package/src/lib/assets/Icons/XDEFIIcon.tsx +32 -0
  44. package/src/lib/assets/favicon.ico +0 -0
  45. package/src/lib/assets/png/keepkey.png +0 -0
  46. package/src/lib/assets/png/keplr.png +0 -0
  47. package/src/lib/assets/png/metamask.png +0 -0
  48. package/src/lib/assets/png/pioneer.png +0 -0
  49. package/src/lib/components/AssetSelect/index.tsx +166 -0
  50. package/src/lib/components/BlockchainSelect/index.tsx +166 -0
  51. package/src/lib/components/MiddleEllipsis/index.tsx +27 -0
  52. package/src/lib/components/WalletSelect/index.tsx +112 -0
  53. package/src/lib/components/auth/RequireAuth.tsx +22 -0
  54. package/src/lib/components/modals/AssetModal.tsx +67 -0
  55. package/src/lib/components/modals/SettingsModal.tsx +76 -0
  56. package/src/lib/components/pioneer/Pioneer/Balances.tsx +266 -0
  57. package/src/lib/components/pioneer/Pioneer/MiddleEllipsis.tsx +27 -0
  58. package/src/lib/components/pioneer/Pioneer/Nodes.tsx +0 -0
  59. package/src/lib/components/pioneer/Pioneer/Paths.tsx +290 -0
  60. package/src/lib/components/pioneer/Pioneer/Pubkey.tsx +67 -0
  61. package/src/lib/components/pioneer/Pioneer/Pubkeys.tsx +265 -0
  62. package/src/lib/components/pioneer/Pioneer/Receive.tsx +26 -0
  63. package/src/lib/components/pioneer/Pioneer/Send.tsx +135 -0
  64. package/src/lib/components/pioneer/Pioneer/View.tsx +44 -0
  65. package/src/lib/components/pioneer/Pioneer/Wallets.tsx +166 -0
  66. package/src/lib/components/pioneer/index.tsx +525 -0
  67. package/src/lib/components/utils/index.tsx +47 -0
  68. package/src/lib/context/Pioneer/index.tsx +420 -0
  69. package/src/lib/layout/Footer.tsx +22 -0
  70. package/src/lib/layout/Header.tsx +38 -0
  71. package/src/lib/layout/Meta.tsx +25 -0
  72. package/src/lib/layout/Pioneer/Balances.tsx +290 -0
  73. package/src/lib/layout/Pioneer/MiddleEllipsis.tsx +27 -0
  74. package/src/lib/layout/Pioneer/Pubkey.tsx +67 -0
  75. package/src/lib/layout/Pioneer/Receive.tsx +26 -0
  76. package/src/lib/layout/Pioneer/Send.tsx +135 -0
  77. package/src/lib/layout/Pioneer/View.tsx +44 -0
  78. package/src/lib/layout/Pioneer/Wallets.tsx +166 -0
  79. package/src/lib/layout/ThemeToggle.tsx +16 -0
  80. package/src/lib/layout/index.tsx +29 -0
  81. package/src/lib/pages/404/index.tsx +36 -0
  82. package/src/lib/pages/home/components/CTASection.tsx +36 -0
  83. package/src/lib/pages/home/components/SomeImage.tsx +36 -0
  84. package/src/lib/pages/home/components/SomeText.tsx +16 -0
  85. package/src/lib/pages/home/index.tsx +87 -0
  86. package/src/lib/router/Routings.tsx +45 -0
  87. package/src/lib/router/routes.tsx +13 -0
  88. package/src/lib/styles/theme/config.ts +5 -0
  89. package/src/lib/styles/theme/index.ts +17 -0
  90. package/tsconfig.json +19 -9
  91. package/turbo.json +17 -0
  92. package/vercel.json +4 -0
  93. package/vite.config.ts +110 -0
@@ -0,0 +1,166 @@
1
+ import {
2
+ Avatar,
3
+ AvatarBadge,
4
+ Box,
5
+ Button,
6
+ HStack,
7
+ Stack,
8
+ Image,
9
+ Modal,
10
+ ModalOverlay,
11
+ ModalContent,
12
+ ModalHeader,
13
+ ModalCloseButton,
14
+ ModalBody,
15
+ ModalFooter,
16
+ useDisclosure,
17
+ InputGroup,
18
+ InputLeftElement,
19
+ Input,
20
+ Text,
21
+ } from "@chakra-ui/react";
22
+ import React, { useState, useEffect } from "react";
23
+
24
+ // Import icons
25
+ // @ts-ignore
26
+ import KEEPKEY_ICON from "lib/assets/png/keepkey.png";
27
+ // @ts-ignore
28
+ import METAMASK_ICON from "lib/assets/png/metamask.png";
29
+ // @ts-ignore
30
+ import PIONEER_ICON from "lib/assets/png/pioneer.png";
31
+ import { usePioneer } from "lib/context/Pioneer";
32
+
33
+ import MiddleEllipsis from "./MiddleEllipsis";
34
+
35
+ interface Wallet {
36
+ context: string;
37
+ type: string;
38
+ valueUsdContext: number;
39
+ icon: any; // @ts-ignore
40
+ paired: boolean;
41
+ }
42
+
43
+ const getWalletBadgeContent = (walletType: string) => {
44
+ const icons: any = {
45
+ metamask: METAMASK_ICON,
46
+ keepkey: KEEPKEY_ICON,
47
+ native: PIONEER_ICON,
48
+ };
49
+
50
+ const icon = icons[walletType];
51
+
52
+ if (!icon) {
53
+ return null;
54
+ }
55
+
56
+ return (
57
+ <AvatarBadge boxSize="1.25em" bg="green.500">
58
+ <Image rounded="full" src={icon} />
59
+ </AvatarBadge>
60
+ );
61
+ };
62
+
63
+ export default function Wallets({ wallets }: { wallets: Wallet[] }) {
64
+ const { state, dispatch } = usePioneer();
65
+ const { user } = state;
66
+ const [currentPage, setCurrentPage] = useState(1);
67
+ const [walletsWithIcons, setWalletsWithIcons] = useState([]);
68
+ const { isOpen, onOpen, onClose } = useDisclosure();
69
+ const walletsPerPage = 3;
70
+
71
+ const handlePageChange = (pageNumber: any) => {
72
+ setCurrentPage(pageNumber);
73
+ };
74
+
75
+ for (let i = 0; i < wallets.length; i++) {
76
+ const wallet = wallets[i];
77
+ if (wallet.type === "native") {
78
+ wallets[i].icon = PIONEER_ICON;
79
+ } else if (wallet.type === "metamask") {
80
+ wallets[i].icon = METAMASK_ICON;
81
+ } else if (wallet.type === "keepkey") {
82
+ wallets[i].icon = KEEPKEY_ICON;
83
+ }
84
+ }
85
+
86
+ const currentWallets = wallets.slice(
87
+ (currentPage - 1) * walletsPerPage,
88
+ currentPage * walletsPerPage
89
+ );
90
+ const totalPages = Math.ceil(wallets.length / walletsPerPage);
91
+
92
+ // Function to generate custom pagination array
93
+ const generatePaginationArray = () => {
94
+ const paginationArray = [];
95
+ const totalPageButtons = 5; // Number of page buttons to display around the current page
96
+
97
+ if (totalPages <= totalPageButtons) {
98
+ // If total pages are less than or equal to totalPageButtons, show all page numbers
99
+ for (let i = 1; i <= totalPages; i++) {
100
+ paginationArray.push(i);
101
+ }
102
+ } else {
103
+ // If total pages are more than totalPageButtons, generate custom pagination
104
+ const middleButton = Math.floor(totalPageButtons / 2);
105
+ const startPage = Math.max(currentPage - middleButton, 1);
106
+ const endPage = Math.min(currentPage + middleButton, totalPages);
107
+
108
+ if (startPage > 1) {
109
+ // Add the first page and ellipsis if the current page is far enough from the first page
110
+ paginationArray.push(1, "...");
111
+ }
112
+
113
+ // Add page numbers between startPage and endPage (inclusive)
114
+ for (let i = startPage; i <= endPage; i++) {
115
+ paginationArray.push(i);
116
+ }
117
+
118
+ if (endPage < totalPages) {
119
+ // Add the last page and ellipsis if the current page is far enough from the last page
120
+ paginationArray.push("...", totalPages);
121
+ }
122
+ }
123
+
124
+ return paginationArray;
125
+ };
126
+
127
+ return (
128
+ <Stack spacing={4}>
129
+ {/* <Text fontSize='xl'>Wallets Tracked</Text> */}
130
+ {currentWallets.map((wallet: Wallet, index: number) => (
131
+ <Box key={index}>
132
+ <HStack spacing={4} alignItems="center">
133
+ <Avatar src={wallet.icon} />
134
+ <Box>
135
+ <small>
136
+ Context: <MiddleEllipsis text={wallet?.context} />
137
+ </small>
138
+ <br />
139
+ <small>Type: {wallet.type}</small>
140
+ <br />
141
+ <small>Value (USD): {wallet.valueUsdContext}</small>
142
+ <br />
143
+ <small>Paired: {wallet.paired ? "Yes" : "No"}</small>
144
+ <br />
145
+ </Box>
146
+ </HStack>
147
+ <HStack mt={2} spacing={2}>
148
+ {/* ... (rest of the buttons and click handlers) */}
149
+ </HStack>
150
+ </Box>
151
+ ))}
152
+ <Box mt={4}>
153
+ {generatePaginationArray().map((page, index) => (
154
+ <Button
155
+ key={index}
156
+ size="sm"
157
+ variant={currentPage === page ? "solid" : "outline"}
158
+ onClick={() => handlePageChange(page)}
159
+ >
160
+ {page === "..." ? "..." : page}
161
+ </Button>
162
+ ))}
163
+ </Box>
164
+ </Stack>
165
+ );
166
+ }
@@ -0,0 +1,16 @@
1
+ import { IconButton, useColorMode } from "@chakra-ui/react";
2
+ import { RiMoonFill, RiSunLine } from "react-icons/ri";
3
+
4
+ const ThemeToggle = () => {
5
+ const { colorMode, toggleColorMode } = useColorMode();
6
+
7
+ return (
8
+ <IconButton
9
+ aria-label="theme toggle"
10
+ icon={colorMode === "light" ? <RiMoonFill /> : <RiSunLine />}
11
+ onClick={toggleColorMode}
12
+ />
13
+ );
14
+ };
15
+
16
+ export default ThemeToggle;
@@ -0,0 +1,29 @@
1
+ import { Box, Flex } from "@chakra-ui/react";
2
+ import type { ReactNode } from "react";
3
+
4
+ import Footer from "./Footer";
5
+ import Header from "./Header";
6
+ import Meta from "./Meta";
7
+
8
+ type LayoutProps = {
9
+ children: ReactNode;
10
+ };
11
+
12
+ const Layout = ({ children }: LayoutProps) => {
13
+ return (
14
+ <div>
15
+ <Header />
16
+ <Box margin="0 auto" maxWidth={800} transition="0.5s ease-out">
17
+ <Meta />
18
+ <Flex wrap="wrap" margin="8" minHeight="90vh">
19
+ <Box width="full" as="main" marginY={22}>
20
+ {children}
21
+ </Box>
22
+ <Footer />
23
+ </Flex>
24
+ </Box>
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default Layout;
@@ -0,0 +1,36 @@
1
+ import {
2
+ Box,
3
+ Button,
4
+ Grid,
5
+ Heading,
6
+ Image,
7
+ Link,
8
+ Text,
9
+ } from "@chakra-ui/react";
10
+ import { useNavigate } from "react-router-dom";
11
+
12
+ const Page404 = () => {
13
+ const navigate = useNavigate();
14
+
15
+ const handleBackToHome = () => navigate("/");
16
+
17
+ return (
18
+ <Grid gap={4} textAlign="center">
19
+ <Heading>Page not Found</Heading>
20
+
21
+ <Box maxWidth={[280, 400]} marginX="auto">
22
+ <Image width={400} src="/assets/404 Error-rafiki.svg" />
23
+ <Link fontSize="xs" href="https://stories.freepik.com/web" isExternal>
24
+ Illustration by Freepik Stories
25
+ </Link>
26
+ </Box>
27
+
28
+ <Box>
29
+ <Text>It&apos;s Okay!</Text>
30
+ <Button onClick={handleBackToHome}>Let&apos;s Head Back</Button>
31
+ </Box>
32
+ </Grid>
33
+ );
34
+ };
35
+
36
+ export default Page404;
@@ -0,0 +1,36 @@
1
+ import { Box, Button, Flex, Image, Link } from "@chakra-ui/react";
2
+ import { AiFillGithub } from "react-icons/ai";
3
+
4
+ const CTASection = () => (
5
+ <Box textAlign="center">
6
+ <Link
7
+ _hover={undefined}
8
+ href="https://github.com/BitHighlander/pioneer-template"
9
+ >
10
+ <Button leftIcon={<AiFillGithub />} size="sm">
11
+ Open in Github
12
+ </Button>
13
+ </Link>
14
+ <Flex marginY={4} justifyContent="center" gridGap={2}>
15
+ <Link
16
+ aria-label="Deploy to Vercel"
17
+ isExternal
18
+ href="https://vercel.com/import/git?s=https://github.com/BitHighlander/pioneer-template"
19
+ >
20
+ <Image src="https://vercel.com/button" alt="Vercel deploy button" />
21
+ </Link>
22
+ <Link
23
+ aria-label="Deploy to Netlify"
24
+ isExternal
25
+ href="https://app.netlify.com/start/deploy?repository=https://github.com/BitHighlander/pioneer-template"
26
+ >
27
+ <Image
28
+ src="https://www.netlify.com/img/deploy/button.svg"
29
+ alt="Netlify deploy button"
30
+ />
31
+ </Link>
32
+ </Flex>
33
+ </Box>
34
+ );
35
+
36
+ export default CTASection;
@@ -0,0 +1,36 @@
1
+ import { Flex, Image } from "@chakra-ui/react";
2
+
3
+ const ICON_SIZE = 22;
4
+
5
+ const SomeImage = () => {
6
+ return (
7
+ <Flex marginY={4} justifyContent="center" alignItems="center" gridGap={2}>
8
+ <Image
9
+ src="/assets/vite-logo.svg"
10
+ title="vite"
11
+ height={ICON_SIZE}
12
+ width={ICON_SIZE}
13
+ />
14
+ <Image
15
+ src="/assets/react-icon.svg"
16
+ title="react"
17
+ height={ICON_SIZE}
18
+ width={ICON_SIZE}
19
+ />
20
+ <Image
21
+ src="/assets/chakra-ui-logomark-colored.svg"
22
+ title="Chakra UI"
23
+ height={ICON_SIZE}
24
+ width={ICON_SIZE}
25
+ />
26
+ <Image
27
+ src="/assets/ts-logo-512.svg"
28
+ title="TypeScript"
29
+ height={ICON_SIZE}
30
+ width={ICON_SIZE}
31
+ />
32
+ </Flex>
33
+ );
34
+ };
35
+
36
+ export default SomeImage;
@@ -0,0 +1,16 @@
1
+ import { Grid, Heading, Text } from "@chakra-ui/react";
2
+
3
+ const SomeText = () => {
4
+ return (
5
+ <Grid textAlign="center" gap={2}>
6
+ <Heading fontSize="2xl" fontWeight="extrabold">
7
+ Pioneer Template
8
+ </Heading>
9
+ <Text color="gray.500" fontSize="sm">
10
+ The Most Powerful Template for Building on Crypto
11
+ </Text>
12
+ </Grid>
13
+ );
14
+ };
15
+
16
+ export default SomeText;
@@ -0,0 +1,87 @@
1
+ import {
2
+ Button,
3
+ useDisclosure,
4
+ Modal,
5
+ ModalFooter,
6
+ ModalBody,
7
+ ModalCloseButton,
8
+ ModalOverlay,
9
+ ModalContent,
10
+ ModalHeader,
11
+ } from "@chakra-ui/react";
12
+ import React, { useEffect, useState } from "react";
13
+ import { usePioneer } from "lib/context/Pioneer";
14
+ import AssetSelect from "lib/components/AssetSelect";
15
+ import BlockchainSelect from "lib/components/BlockchainSelect";
16
+ import WalletSelect from "lib/components/WalletSelect";
17
+
18
+ const Home = () => {
19
+ const { state } = usePioneer();
20
+ const { api, app, context, assetContext, blockchainContext, pubkeyContext } =
21
+ state;
22
+ const [address, setAddress] = useState("");
23
+ const [modalType, setModalType] = useState("");
24
+ const { isOpen, onOpen, onClose } = useDisclosure();
25
+
26
+ useEffect(() => {
27
+ console.log("2 pubkeyContext: ", pubkeyContext);
28
+ setAddress(pubkeyContext.master || pubkeyContext.pubkey || pubkeyContext);
29
+ }, [pubkeyContext]);
30
+
31
+ const openModal = (type: any) => {
32
+ setModalType(type);
33
+ onOpen();
34
+ };
35
+
36
+ return (
37
+ <div>
38
+ <Modal isOpen={isOpen} onClose={() => onClose()} size="xl">
39
+ <ModalOverlay />
40
+ <ModalContent>
41
+ <ModalHeader>{modalType}</ModalHeader>
42
+ <ModalCloseButton />
43
+ <ModalBody>
44
+ {/* Render content based on modalType */}
45
+ {modalType === "Select wallet" && (
46
+ <div>
47
+ <WalletSelect onClose={onClose}></WalletSelect>
48
+ </div>
49
+ )}
50
+ {modalType === "Select Asset" && (
51
+ <div>
52
+ <AssetSelect onClose={onClose}></AssetSelect>
53
+ </div>
54
+ )}
55
+ {modalType === "Select Blockchain" && (
56
+ <div>
57
+ <BlockchainSelect onClose={onClose}></BlockchainSelect>
58
+ </div>
59
+ )}
60
+ {modalType === "View Address" && <div>address: {address}</div>}
61
+ </ModalBody>
62
+ <ModalFooter>
63
+ <Button colorScheme="blue" onClick={onClose}>
64
+ Close
65
+ </Button>
66
+ </ModalFooter>
67
+ </ModalContent>
68
+ </Modal>
69
+ Context: {context}
70
+ <Button onClick={() => openModal("Select wallet")}>Select wallet</Button>
71
+ <br />
72
+ Asset Context: {assetContext?.name}
73
+ <Button onClick={() => openModal("Select Asset")}>Select Asset</Button>
74
+ <br />
75
+ Blockchain Context: {blockchainContext?.name}
76
+ <Button onClick={() => openModal("Select Blockchain")}>
77
+ Select Blockchain
78
+ </Button>
79
+ <br />
80
+ Address: {address}
81
+ <Button onClick={() => openModal("View Address")}>View Address</Button>
82
+ <br />
83
+ </div>
84
+ );
85
+ };
86
+
87
+ export default Home;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @note
3
+ * for hook alternative of route element composition:
4
+ * - https://reactrouter.com/docs/en/v6/upgrading/v5#use-useroutes-instead-of-react-router-config
5
+ * - https://reactrouter.com/docs/en/v6/examples/route-objects
6
+ *
7
+ * might need to take notes on:
8
+ * - https://reactrouter.com/docs/en/v6/upgrading/v5#note-on-link-to-values
9
+ */
10
+
11
+ import { Suspense } from "react";
12
+ import { Routes, Route } from "react-router-dom";
13
+
14
+ import RequireAuth from "lib/components/auth/RequireAuth";
15
+ import Page404 from "lib/pages/404";
16
+
17
+ import { routes, privateRoutes } from "./routes";
18
+
19
+ const Routings = () => {
20
+ return (
21
+ <Suspense>
22
+ <Routes>
23
+ {routes.map((routeProps) => (
24
+ <Route {...routeProps} key={routeProps.path as string} />
25
+ ))}
26
+ {privateRoutes.map(({ element, ...privateRouteProps }) => (
27
+ <Route
28
+ element={
29
+ <RequireAuth
30
+ redirectTo={`/login?redirectTo=${privateRouteProps.path}`}
31
+ >
32
+ {element}
33
+ </RequireAuth>
34
+ }
35
+ {...privateRouteProps}
36
+ key={`privateRoute-${privateRouteProps.path}`}
37
+ />
38
+ ))}
39
+ <Route path="*" element={<Page404 />} />
40
+ </Routes>
41
+ </Suspense>
42
+ );
43
+ };
44
+
45
+ export default Routings;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import type { PathRouteProps } from "react-router-dom";
3
+
4
+ const Home = React.lazy(() => import("lib/pages/home"));
5
+
6
+ export const routes: Array<PathRouteProps> = [
7
+ {
8
+ path: "/",
9
+ element: <Home />,
10
+ },
11
+ ];
12
+
13
+ export const privateRoutes: Array<PathRouteProps> = [];
@@ -0,0 +1,5 @@
1
+ import type { ThemeConfig } from "@chakra-ui/react";
2
+
3
+ export const config: ThemeConfig = {
4
+ disableTransitionOnChange: false,
5
+ };
@@ -0,0 +1,17 @@
1
+ import { extendTheme } from "@chakra-ui/react";
2
+
3
+ import { config } from "./config";
4
+
5
+ export const theme = extendTheme({
6
+ initialColorMode: "dark",
7
+ useSystemColorMode: false,
8
+ fonts: {
9
+ heading: "Plus Jakarta Sans, sans-serif",
10
+ body: "Plus Jakarta Sans, sans-serif",
11
+ },
12
+ components: {
13
+ // Button: {
14
+ // }
15
+ },
16
+ config,
17
+ });
package/tsconfig.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es5",
4
- "module": "commonjs",
5
- "lib": ["es6", "es2015", "dom"],
6
- "declaration": true,
7
- "outDir": "lib",
8
- "rootDir": "src",
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
+ "allowJs": false,
7
+ "skipLibCheck": true,
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true,
9
10
  "strict": true,
10
- "types": ["node"],
11
- "esModuleInterop": true
12
- }
11
+ "forceConsistentCasingInFileNames": true,
12
+ "module": "ESNext",
13
+ "moduleResolution": "Node",
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "noEmit": false,
17
+ "declaration": true, // Add this line to generate .d.ts files
18
+ "outDir": "./dist", // Add this line to specify the output directory
19
+ "jsx": "react-jsx",
20
+ "baseUrl": "./src",
21
+ },
22
+ "include": ["./src"]
13
23
  }
package/turbo.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://turbo.build/schema.json",
3
+ "pipeline": {
4
+ "type-check": {
5
+ "outputs": ["*.tsbuildinfo"]
6
+ },
7
+ "build": {
8
+ "dependsOn": ["type-check"],
9
+ "outputs": ["dist/**", "public/**"],
10
+ "env": []
11
+ },
12
+ "lint": {
13
+ "outputs": [],
14
+ "inputs": [".eslintrc.*", "src/**"]
15
+ }
16
+ }
17
+ }
package/vercel.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "rewrites": [{ "source": "/(.*)", "destination": "/" }],
3
+ "buildCommand": "yarn build:turbo"
4
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,110 @@
1
+ require('dotenv').config();
2
+ import react from "@vitejs/plugin-react";
3
+ import { resolve } from "path";
4
+ import { defineConfig } from "vite";
5
+ import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
6
+ import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
7
+ import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
8
+ // import inject from '@rollup/plugin-inject'
9
+ // import wasm from 'vite-plugin-wasm'
10
+
11
+ // @ts-ignore
12
+ export default defineConfig(({}) => {
13
+ // Load env file based on `mode` in the current working directory.
14
+ // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
15
+ // const env = loadEnv(mode, process.cwd(), '')
16
+ return {
17
+ // vite config
18
+ define: {
19
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
20
+ },
21
+ plugins: [react()],
22
+ resolve: {
23
+ alias: {
24
+ lib: resolve(__dirname, "src/lib"),
25
+ routes: resolve(__dirname, "src/routes"),
26
+ util: 'rollup-plugin-node-polyfills/polyfills/util',
27
+ sys: 'util',
28
+ events: 'rollup-plugin-node-polyfills/polyfills/events',
29
+ //stream: 'rollup-plugin-node-polyfills/polyfills/stream',
30
+ stream: 'stream-browserify',
31
+ path: 'rollup-plugin-node-polyfills/polyfills/path',
32
+ querystring: 'rollup-plugin-node-polyfills/polyfills/qs',
33
+ punycode: 'rollup-plugin-node-polyfills/polyfills/punycode',
34
+ url: 'rollup-plugin-node-polyfills/polyfills/url',
35
+ http: 'rollup-plugin-node-polyfills/polyfills/http',
36
+ https: 'rollup-plugin-node-polyfills/polyfills/http',
37
+ os: 'rollup-plugin-node-polyfills/polyfills/os',
38
+ assert: 'rollup-plugin-node-polyfills/polyfills/assert',
39
+ constants: 'rollup-plugin-node-polyfills/polyfills/constants',
40
+ _stream_duplex:
41
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/duplex',
42
+ _stream_passthrough:
43
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough',
44
+ _stream_readable:
45
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/readable',
46
+ _stream_writable:
47
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/writable',
48
+ _stream_transform:
49
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/transform',
50
+ timers: 'rollup-plugin-node-polyfills/polyfills/timers',
51
+ console: 'rollup-plugin-node-polyfills/polyfills/console',
52
+ vm: 'rollup-plugin-node-polyfills/polyfills/vm',
53
+ zlib: 'rollup-plugin-node-polyfills/polyfills/zlib',
54
+ tty: 'rollup-plugin-node-polyfills/polyfills/tty',
55
+ domain: 'rollup-plugin-node-polyfills/polyfills/domain'
56
+ },
57
+ },
58
+ optimizeDeps: {
59
+ esbuildOptions: {
60
+ // Node.js global to browser globalThis
61
+ define: {
62
+ global: 'globalThis'
63
+ },
64
+ // Enable esbuild polyfill plugins
65
+ plugins: [
66
+ NodeGlobalsPolyfillPlugin({
67
+ process: true,
68
+ buffer: true
69
+ }),
70
+ // NodeModulesPolyfillPlugin()
71
+ ],
72
+ }
73
+ },
74
+ build: {
75
+ outDir: "dist",
76
+ minify: false,
77
+ lib: {
78
+ entry: resolve(__dirname, "src/lib/index.tsx"), // Set the entry file of your library
79
+ name: "PioneerLib", // Set the name of your library
80
+ fileName: (format) => `my-library.${format}.js` // Set the fileName of your library
81
+ },
82
+ rollupOptions: {
83
+ input: {
84
+ main: resolve(__dirname, "src/index.tsx"),
85
+ },
86
+ output: {
87
+ entryFileNames: 'index.js',
88
+ chunkFileNames: 'index_[hash].js',
89
+ assetFileNames: 'index_[hash][extname]',
90
+ format: "es",
91
+ globals: {
92
+ 'react': 'React',
93
+ 'react-dom': 'ReactDOM',
94
+ '@chakra-ui/react': 'Chakra',
95
+ '@emotion/react': 'emotion'
96
+ },
97
+ keepNames: true,
98
+ },
99
+ external: ['react', 'react-dom', '@chakra-ui/react', '@emotion/react'],
100
+ plugins: [
101
+ NodeGlobalsPolyfillPlugin({
102
+ process: true,
103
+ buffer: true
104
+ }),
105
+ rollupNodePolyFill()
106
+ ],
107
+ }
108
+ },
109
+ }
110
+ })