Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: scripts + generated idnex #57

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions scripts/generateExports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { readdir } from "node:fs/promises";

async function listAllExports() {
//Get all typescript files
const tsFiles = (await readdir("./src", { recursive: true })).filter(file =>
[".ts", ".tsx"].some(ext => file.endsWith(ext)),
);

//Split paths into [directory, filename]
const filesToExport = tsFiles.map(path => {
const split = path.split("/");
const directory = split.slice(0, split.length - 1).join("/");
const file = split.slice(-1)[0];

return [directory, file];
});

//Get all unique directoies
const directories = new Set<string>();
for (const dir of filesToExport.map(([dir]) => dir).filter(dir => !dir.includes("routes"))) {
directories.add(dir);
}

//Map directories to export lines
const directoryExportLines = await Promise.all(
Array.from(directories).map(async dir => {
const dirFiles = await Promise.all(
filesToExport
.filter(([_dir]) => _dir === dir)
.map(async ([_, filename]) => {
return [dir, filename, await Bun.file(`./src/${dir}/${filename}`).text()];
}),
);

return [
`/**\n * ${dir}\n */`,
dirFiles
.map(([dir, filename, content]) => {
const name = filename.split(".").slice(0, -1).join(".");
const hasDefaultExports = content.includes("export default ") && !name.includes(".");

return `export * from "./${dir}/${name}";${
hasDefaultExports ? `\nexport { default as ${name} } from "./${dir}/${name}";` : ""
}`;
})
.join("\n"),
"",
].join("\n");
}),
);

return directoryExportLines.join("\n");
}

await Bun.write("./src/index.generated.ts", await listAllExports());
67 changes: 0 additions & 67 deletions src/components.ts

This file was deleted.

Empty file.
191 changes: 158 additions & 33 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,166 @@
import "./style.css";
export * from "./context/Dapp.context";
/**
*
*/
export * from "./color";

/**
* context
*/
export * from "./context/Wallet.context";
export * from "./context/Theme.context";
export { default as Button } from "./components/primitives/Button";
export * from "./utils/tailwind";
export * from "./context/Dapp.context";

export * from "./components";
/**
* theme
*/
export * from "./theme/classes";
export * from "./theme/variables";

/**
* hooks
*/
export * from "./hooks/useClipboard";
export { default as useClipboard } from "./hooks/useClipboard";
export * from "./hooks/useWalletState";
export { default as useWalletState } from "./hooks/useWalletState";

/**
* components
*/
export * from "./components/VisuallyHidden";
export { default as VisuallyHidden } from "./components/VisuallyHidden";

/**
* hooks/events
*/
export * from "./hooks/events/useShortcut";
export * from "./hooks/events/useOverflowing";

/**
* hooks/theming
*/
export * from "./hooks/theming/useThemedVariables";
export { default as useThemedVariables } from "./hooks/theming/useThemedVariables";
export * from "./hooks/theming/useThemableProps";
export { default as useThemableProps } from "./hooks/theming/useThemableProps";
export * from "./hooks/theming/OverrideTheme";
export { default as OverrideTheme } from "./hooks/theming/OverrideTheme";

/**
* components/extenders
*/
export * from "./components/extenders/Modal";
export { default as Modal } from "./components/extenders/Modal";
export * from "./components/extenders/Card";
export { default as Card } from "./components/extenders/Card";
export * from "./components/extenders/Group";
export { default as Group } from "./components/extenders/Group";
export * from "./components/extenders/Select";
export { default as Select } from "./components/extenders/Select";
export * from "./components/extenders/Dropdown";
export { default as Dropdown } from "./components/extenders/Dropdown";
export * from "./components/extenders/Icons";
export { default as Icons } from "./components/extenders/Icons";

/**
* config
*/
export * from "./config/themes";

/**
* components/dapp
*/
export * from "./components/dapp/WalletButton";
export { default as WalletButton } from "./components/dapp/WalletButton";
export * from "./components/dapp/TransactionButton";
export { default as TransactionButton } from "./components/dapp/TransactionButton";
export * from "./components/dapp/WalletConnectors";
export { default as WalletConnectors } from "./components/dapp/WalletConnectors";
export * from "./components/dapp/TransactionHelper";
export { default as TransactionHelper } from "./components/dapp/TransactionHelper";
export * from "./components/dapp/Connected";
export { default as Connected } from "./components/dapp/Connected";
export * from "./components/dapp/Countdown";
export { default as Countdown } from "./components/dapp/Countdown";

/**
* theming
*/
// export * from "./theming/variables";
export * from "./theming/spacing";
export * from "./theming/tailwind";
export * from "./theming/static";
export * from "./theming/coloring";
export * from "./theming/variables";

/**
* components/layout
*/
export * from "./components/layout/Container";
export { default as Container } from "./components/layout/Container";

/**
* components/primitives
*/
export * from "./components/primitives/PrimitiveTag";
export { default as PrimitiveTag } from "./components/primitives/PrimitiveTag";
export * from "./components/primitives/Tabs";
export { default as Tabs } from "./components/primitives/Tabs";
export * from "./components/primitives/Collapsible";
export { default as Collapsible } from "./components/primitives/Collapsible";
export * from "./components/primitives/Slider";
export { default as Slider } from "./components/primitives/Slider";
export * from "./components/primitives/ColorPicker";
export { default as ColorPicker } from "./components/primitives/ColorPicker";
export * from "./components/primitives/Space";
export { default as Space } from "./components/primitives/Space";
export * from "./components/primitives/Block";
export { default as Block } from "./components/primitives/Block";
export * from "./components/primitives/Image";
export { default as Image } from "./components/primitives/Image";
export * from "./components/primitives/Box";
export { default as Box } from "./components/primitives/Box";
export * from "./components/primitives/Tooltip";
export { default as Tooltip } from "./components/primitives/Tooltip";
export * from "./components/primitives/Button";
export { default as Button } from "./components/primitives/Button";
export * from "./components/primitives/Checkbox";
export { default as Checkbox } from "./components/primitives/Checkbox";
export * from "./components/primitives/Icon";
export { default as Icon } from "./components/primitives/Icon";
export * from "./components/primitives/EventBlocker";
export { default as EventBlocker } from "./components/primitives/EventBlocker";
export * from "./components/primitives/Scroll";
export { default as Scroll } from "./components/primitives/Scroll";
export * from "./components/primitives/Value";
export { default as Value } from "./components/primitives/Value";
export * from "./components/primitives/Divider";
export { default as Divider } from "./components/primitives/Divider";
export * from "./components/primitives/Table";
export * from "./components/primitives/Input";
export { default as Input } from "./components/primitives/Input";
export * from "./components/primitives/Notifications";
export { default as Notifications } from "./components/primitives/Notifications";
export * from "./components/primitives/Title";
export { default as Title } from "./components/primitives/Title";
export * from "./components/primitives/Accordion";
export { default as Accordion } from "./components/primitives/Accordion";
export * from "./components/primitives/Bar";
export { default as Bar } from "./components/primitives/Bar";
export * from "./components/primitives/Time";
export { default as Time } from "./components/primitives/Time";
export * from "./components/primitives/List";
export { default as List } from "./components/primitives/List";
export * from "./components/primitives/Hash";
export { default as Hash } from "./components/primitives/Hash";
export * from "./components/primitives/Text";
export { default as Text } from "./components/primitives/Text";

/**
* utils
*/
export * from "./utils/event";
export * from "./utils/tailwind";
export * from "./utils/css";
export * from "./utils/formatter.service";
export * from "./utils/types";

//Primitives
// export * from "./components/primitives/Block";
// export * from "./components/primitives/Box";

// // export * from "./components/primitives/Checkbox";
// export * from "./components/primitives/Divider";
// export * from "./components/primitives/Icon";
// export * from "./components/primitives/Image";
// export * from "./components/primitives/Input";
// // export * from "./components/primitives/Switch";
// export * from "./components/primitives/Text";

// //Extenders
// export { default as Dropdown } from "./components/extenders/Dropdown";
// export * from "./components/extenders/Dropdown";
// export * from "./components/extenders/Group";
// export * from "./components/extenders/Modal";
// export * from "./components/extenders/Select";

// //DApp
// export * from "./context/Dapp.context";
// export * from "./context/Theme.context";
// export * from "./components/dapp/WalletButton";
// // export * from "./components/dapp/WalletConnectors";

// //Utils
export * from "./utils/react";
Loading