├── .prettierrc.json ├── .prettierignore ├── vite-env.d.ts ├── src ├── index.d.ts ├── index.css ├── init.tsx ├── favicon.svg ├── index.html ├── components │ ├── BlockComponent.tsx │ ├── ErrorBoundary.tsx │ ├── PageWrapper.tsx │ └── Block.tsx └── utils.ts ├── .gitignore ├── utils ├── index.ts ├── lib │ └── index.ts ├── types │ └── index.ts ├── components │ └── block-picker.tsx └── extensionToLanguage.json ├── scripts ├── config │ ├── paths.js │ ├── vite.config.dev.js │ └── env.js ├── start.js └── build.js ├── tsup.config.ts ├── tsconfig.json ├── bin └── blocks.js ├── README.md ├── package.json └── yarn.lock /.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | -------------------------------------------------------------------------------- /vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | type Asset = { 2 | name: string; 3 | content: string; 4 | }; 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist-ssr 4 | *.local 5 | .yalc.lock 6 | .yalc 7 | dist -------------------------------------------------------------------------------- /utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./lib"; 3 | export * from "./components/block-picker"; 4 | -------------------------------------------------------------------------------- /scripts/config/paths.js: -------------------------------------------------------------------------------- 1 | const paths = { 2 | blocks: "node_modules/@githubnext/blocks/", 3 | userRoot: "./", 4 | blocksFolder: "./blocks", 5 | }; 6 | 7 | module.exports = paths; -------------------------------------------------------------------------------- /tsup.config.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from "tsup"; 2 | export const tsup: Options = { 3 | clean: true, 4 | format: ["cjs", "esm"], 5 | entryPoints: ["utils/index.ts"], 6 | external: ["react", "react-dom"], // necessary to prevent "multiple React" errors in the dev env 7 | }; 8 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | padding: 0; 4 | margin: 0; 5 | height: 100%; 6 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 7 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 8 | } 9 | 10 | #root { 11 | height: 100%; 12 | } 13 | -------------------------------------------------------------------------------- /src/init.tsx: -------------------------------------------------------------------------------- 1 | import ReactDOM from "react-dom/client"; 2 | import App from "./components/PageWrapper"; 3 | import "./index.css"; 4 | 5 | if (window === window.top) { 6 | window.location.href = `https://blocks.githubnext.com/?devServer=${encodeURIComponent( 7 | window.location.href 8 | )}`; 9 | } else { 10 | const root = ReactDOM.createRoot(document.getElementById("root")!); 11 | root.render(); 12 | } 13 | -------------------------------------------------------------------------------- /src/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | GitHub Blocks: Custom Blocks 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": false, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx", 18 | "paths": { 19 | "@utils": ["./utils"], 20 | "@user": ["./"] 21 | }, 22 | "types": ["vite/client"] 23 | }, 24 | "include": ["./src", "./utils"] 25 | } 26 | -------------------------------------------------------------------------------- /src/components/BlockComponent.tsx: -------------------------------------------------------------------------------- 1 | import type { Block, FileContext, FolderContext } from "@utils"; 2 | 3 | export type BlockComponentProps = { 4 | context: FileContext | FolderContext; 5 | block: Block; 6 | }; 7 | export const BlockComponent = ({ block, context }: BlockComponentProps) => { 8 | const { owner, repo, id, type } = block; 9 | const hash = encodeURIComponent( 10 | JSON.stringify({ block: { owner, repo, id, type }, context }) 11 | ); 12 | return ( 13 |