├── .npmrc ├── .gitattributes ├── vitest.workspace.ts ├── global.css ├── packages ├── htmldocs │ ├── src │ │ ├── cli │ │ │ ├── utils │ │ │ │ ├── index.ts │ │ │ │ ├── preview │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── get-env-variables-for-preview-app.ts │ │ │ │ │ ├── hot-reloading │ │ │ │ │ │ └── get-imported-modules.ts │ │ │ │ │ └── serve-static-file.ts │ │ │ │ ├── close-ora-on-sigint.ts │ │ │ │ └── token.ts │ │ │ ├── commands │ │ │ │ ├── dev.ts │ │ │ │ ├── init.ts │ │ │ │ ├── build.ts │ │ │ │ └── login.ts │ │ │ └── index.ts │ │ ├── app │ │ │ ├── components │ │ │ │ ├── sidebar │ │ │ │ │ ├── index.ts │ │ │ │ │ └── sidebar-directory.tsx │ │ │ │ ├── theme-provider.tsx │ │ │ │ ├── ui │ │ │ │ │ ├── collapsible.tsx │ │ │ │ │ ├── label.tsx │ │ │ │ │ ├── input.tsx │ │ │ │ │ ├── tooltip.tsx │ │ │ │ │ ├── switch.tsx │ │ │ │ │ ├── badge.tsx │ │ │ │ │ ├── scroll-area.tsx │ │ │ │ │ ├── button.tsx │ │ │ │ │ └── tabs.tsx │ │ │ │ ├── icons │ │ │ │ │ ├── icon-arrow-down.tsx │ │ │ │ │ ├── icon-base.tsx │ │ │ │ │ ├── icon-file.tsx │ │ │ │ │ ├── icon-folder.tsx │ │ │ │ │ ├── icon-hide-sidebar.tsx │ │ │ │ │ └── icon-folder-open.tsx │ │ │ │ ├── preview.tsx │ │ │ │ └── theme-toggle.tsx │ │ │ ├── favicon.ico │ │ │ ├── lib │ │ │ │ ├── version.ts │ │ │ │ ├── utils.ts │ │ │ │ ├── types.ts │ │ │ │ └── logger.ts │ │ │ ├── preview │ │ │ │ └── [...slug] │ │ │ │ │ ├── loading.tsx │ │ │ │ │ ├── rendering-error.tsx │ │ │ │ │ └── page.tsx │ │ │ ├── actions │ │ │ │ ├── get-document-schema.ts │ │ │ │ ├── get-document-path-from-slug.ts │ │ │ │ ├── render-document-to-pdf.ts │ │ │ │ └── render-document-by-path.tsx │ │ │ ├── hooks │ │ │ │ ├── use-hot-reload.ts │ │ │ │ └── use-rendering-metadata.ts │ │ │ ├── page.tsx │ │ │ ├── layout.tsx │ │ │ ├── globals.css │ │ │ └── contexts │ │ │ │ └── document-context.tsx │ │ └── utils │ │ │ ├── paths.ts │ │ │ ├── types │ │ │ ├── hot-reload-event.ts │ │ │ ├── hot-reload-change.ts │ │ │ └── error-object.ts │ │ │ └── documents-directory-absolute-path.tsx │ ├── bun.lockb │ ├── public │ │ └── template │ │ │ ├── index.css │ │ │ ├── documents │ │ │ ├── static │ │ │ │ ├── fonts │ │ │ │ │ └── PPEiko-Medium.otf │ │ │ │ ├── axis.svg │ │ │ │ ├── logo.svg │ │ │ │ └── placeholder.svg │ │ │ └── templates │ │ │ │ └── Book.tsx │ │ │ ├── tsconfig.json │ │ │ ├── package.json │ │ │ ├── tailwind.config.js │ │ │ └── CHANGELOG.md │ ├── .npmignore │ ├── postcss.config.mjs │ ├── components.json │ ├── next.config.mjs │ ├── .gitignore │ ├── build-preview-server.mjs │ ├── tsup.config.ts │ ├── tsconfig.json │ ├── CHANGELOG.md │ └── tailwind.config.mjs ├── render │ ├── src │ │ ├── index.ts │ │ ├── css │ │ │ ├── index.scss │ │ │ ├── paper.scss │ │ │ └── normalize.scss │ │ ├── types │ │ │ └── index.ts │ │ └── util │ │ │ ├── static-node-modules-for-vm.ts │ │ │ ├── improve-error-with-sourcemap.ts │ │ │ └── index.ts │ ├── build.ts │ ├── tsconfig.json │ ├── CHANGELOG.md │ └── package.json ├── eslint-config │ ├── README.md │ ├── package.json │ ├── library.js │ ├── next.js │ └── react-internal.js ├── typescript-config │ ├── package.json │ ├── react-library.json │ ├── nextjs.json │ └── base.json ├── e2e-tests │ ├── CHANGELOG.md │ ├── .env.example │ ├── tests │ │ ├── fixtures.ts │ │ ├── helpers │ │ │ └── auth.ts │ │ └── cli-login.spec.ts │ ├── package.json │ └── playwright.config.ts └── react │ ├── tsconfig.json │ ├── tsconfig.lint.json │ ├── components │ ├── index.ts │ ├── Head.tsx │ ├── Page.tsx │ ├── Spacer.tsx │ ├── Document.tsx │ ├── Footer.tsx │ └── MarginBox.tsx │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── index.ts │ └── package.json ├── tsconfig.json ├── apps ├── examples │ ├── index.css │ ├── documents │ │ ├── static │ │ │ ├── fonts │ │ │ │ └── PPEiko-Medium.otf │ │ │ ├── axis.svg │ │ │ ├── logo.svg │ │ │ └── placeholder.svg │ │ └── templates │ │ │ └── Book.tsx │ ├── tsconfig.json │ ├── package.json │ ├── tailwind.config.js │ └── CHANGELOG.md └── docs │ ├── images │ ├── editor.png │ ├── dev-server.png │ └── checks-passed.png │ ├── snippets │ └── snippet-intro.mdx │ ├── api-reference │ ├── generate-html.mdx │ ├── generate-document.mdx │ └── authorization.mdx │ ├── README.md │ ├── components │ ├── page.mdx │ ├── head.mdx │ ├── document.mdx │ ├── spacer.mdx │ └── footer.mdx │ ├── usage │ ├── tailwind.mdx │ ├── custom-fonts.mdx │ ├── static-content.mdx │ ├── template-variables.mdx │ └── publishing-to-the-cloud.mdx │ ├── comparison.mdx │ ├── mint.json │ ├── quickstart.mdx │ └── introduction.mdx ├── pnpm-workspace.yaml ├── vitest.config.ts ├── .eslintrc.js ├── .changeset └── config.json ├── .vscode └── settings.json ├── turbo.json ├── .gitignore ├── package.json ├── LICENSE └── .github └── workflows ├── release.yml └── bump-canary.yml /.npmrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-detectable=false 2 | -------------------------------------------------------------------------------- /vitest.workspace.ts: -------------------------------------------------------------------------------- 1 | export default ['packages/*']; -------------------------------------------------------------------------------- /global.css: -------------------------------------------------------------------------------- 1 | .debug-outline { 2 | outline: 2px solid red; 3 | } -------------------------------------------------------------------------------- /packages/htmldocs/src/cli/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './preview'; -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/sidebar/index.ts: -------------------------------------------------------------------------------- 1 | export * from './sidebar'; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@htmldocs/typescript-config/base.json" 3 | } 4 | -------------------------------------------------------------------------------- /apps/examples/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /apps/docs/images/editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/apps/docs/images/editor.png -------------------------------------------------------------------------------- /packages/htmldocs/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/packages/htmldocs/bun.lockb -------------------------------------------------------------------------------- /packages/htmldocs/public/template/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /packages/render/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./renderAsync"; 2 | export * from "./util" 3 | export * from "./types" -------------------------------------------------------------------------------- /apps/docs/images/dev-server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/apps/docs/images/dev-server.png -------------------------------------------------------------------------------- /packages/eslint-config/README.md: -------------------------------------------------------------------------------- 1 | # `@turbo/eslint-config` 2 | 3 | Collection of internal eslint configurations. 4 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "apps/*" 3 | - "packages/*" 4 | - "packages/htmldocs/public/template" 5 | -------------------------------------------------------------------------------- /apps/docs/images/checks-passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/apps/docs/images/checks-passed.png -------------------------------------------------------------------------------- /packages/htmldocs/src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/packages/htmldocs/src/app/favicon.ico -------------------------------------------------------------------------------- /packages/htmldocs/src/utils/paths.ts: -------------------------------------------------------------------------------- 1 | export const NEXT_DIST_DIR = "dist" 2 | 3 | export const DOCUMENT_SCHEMAS_DIR = NEXT_DIST_DIR -------------------------------------------------------------------------------- /packages/htmldocs/src/app/lib/version.ts: -------------------------------------------------------------------------------- 1 | import packageJson from '../../../package.json'; 2 | 3 | export const VERSION = packageJson.version; -------------------------------------------------------------------------------- /packages/htmldocs/src/cli/utils/preview/index.ts: -------------------------------------------------------------------------------- 1 | export * from './start-dev-server'; 2 | export * from './hot-reloading/setup-hot-reloading'; 3 | -------------------------------------------------------------------------------- /apps/examples/documents/static/fonts/PPEiko-Medium.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/apps/examples/documents/static/fonts/PPEiko-Medium.otf -------------------------------------------------------------------------------- /packages/htmldocs/src/utils/types/hot-reload-event.ts: -------------------------------------------------------------------------------- 1 | export type HotReloadEvent = 2 | | 'add' 3 | | 'addDir' 4 | | 'change' 5 | | 'unlink' 6 | | 'unlinkDir'; -------------------------------------------------------------------------------- /packages/htmldocs/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | public/template/node_modules 3 | .turbo 4 | dist/preview/.next/cache 5 | dist/preview/.next/trace 6 | src/cli 7 | tsup.config.ts -------------------------------------------------------------------------------- /packages/htmldocs/public/template/documents/static/fonts/PPEiko-Medium.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htmldocs-js/htmldocs/HEAD/packages/htmldocs/public/template/documents/static/fonts/PPEiko-Medium.otf -------------------------------------------------------------------------------- /packages/typescript-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@htmldocs/typescript-config", 3 | "version": "0.0.1", 4 | "license": "MIT", 5 | "publishConfig": { 6 | "access": "public" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/htmldocs/src/utils/types/hot-reload-change.ts: -------------------------------------------------------------------------------- 1 | import type { HotReloadEvent } from './hot-reload-event'; 2 | 3 | export interface HotReloadChange { 4 | filename: string; 5 | event: HotReloadEvent; 6 | } -------------------------------------------------------------------------------- /packages/htmldocs/src/cli/utils/close-ora-on-sigint.ts: -------------------------------------------------------------------------------- 1 | import type { Ora } from 'ora'; 2 | 3 | export const closeOraOnSIGINT = (spinner: Ora) => { 4 | process.on('SIGINT', () => { 5 | spinner.stop(); 6 | }); 7 | }; -------------------------------------------------------------------------------- /packages/htmldocs/src/app/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from "clsx" 2 | import { twMerge } from "tailwind-merge" 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)) 6 | } 7 | -------------------------------------------------------------------------------- /packages/e2e-tests/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # e2e-tests 2 | 3 | ## 1.0.2 4 | 5 | ### Patch Changes 6 | 7 | - 00e7575: make e2e test private 8 | 9 | ## 1.0.1 10 | 11 | ### Patch Changes 12 | 13 | - c6753c4: Update cli auth 14 | -------------------------------------------------------------------------------- /packages/typescript-config/react-library.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "React Library", 4 | "extends": "./base.json", 5 | "compilerOptions": { 6 | "jsx": "react-jsx" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import { defineConfig } from 'vitest/config'; 4 | 5 | export default defineConfig({ 6 | test: { 7 | globals: true, 8 | environment: 'happy-dom', 9 | }, 10 | }); -------------------------------------------------------------------------------- /packages/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@htmldocs/typescript-config/react-library.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["components/**/*", "index.ts"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/react/tsconfig.lint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@htmldocs/typescript-config/react-library.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["components", "index.ts"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/react/components/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Document } from "./Document"; 2 | export { default as Page } from "./Page"; 3 | export { default as Head } from "./Head"; 4 | export { default as Spacer } from "./Spacer"; 5 | export { default as Footer } from "./Footer"; 6 | export { default as MarginBox } from "./MarginBox"; -------------------------------------------------------------------------------- /apps/docs/snippets/snippet-intro.mdx: -------------------------------------------------------------------------------- 1 | One of the core principles of software development is DRY (Don't Repeat 2 | Yourself). This is a principle that apply to documentation as 3 | well. If you find yourself repeating the same content in multiple places, you 4 | should consider creating a custom snippet to keep your content in sync. 5 | -------------------------------------------------------------------------------- /packages/react/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | extends: ["@htmldocs/eslint-config/react-internal.js"], 5 | parser: "@typescript-eslint/parser", 6 | parserOptions: { 7 | project: "./tsconfig.lint.json", 8 | tsconfigRootDir: __dirname, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/htmldocs/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import { fileURLToPath } from 'node:url'; 3 | 4 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); 5 | 6 | export default { 7 | plugins: { 8 | tailwindcss: { config: path.resolve(__dirname, 'tailwind.config.mjs') }, 9 | autoprefixer: {}, 10 | }, 11 | } -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // This configuration only applies to the package manager root. 2 | /** @type {import("eslint").Linter.Config} */ 3 | module.exports = { 4 | ignorePatterns: ["apps/**", "packages/**"], 5 | extends: ["@htmldocs/eslint-config/library.js"], 6 | parser: "@typescript-eslint/parser", 7 | parserOptions: { 8 | project: true, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/htmldocs/src/utils/types/error-object.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * An object that mimics the structure of the Error class, 3 | * we just can't use the Error class here because server actions can't 4 | * return classes 5 | */ 6 | export interface ErrorObject { 7 | name: string; 8 | stack: string | undefined; 9 | cause: unknown; 10 | message: string; 11 | } 12 | -------------------------------------------------------------------------------- /apps/docs/api-reference/generate-html.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Generate from HTML' 3 | openapi: 'POST /api/generate' 4 | --- 5 | 6 | This endpoint allows you to generate a PDF document directly from HTML content, without needing to publish a template first. 7 | 8 | For generating documents from published templates, see the [Generate Document](/api/generate-document) endpoint instead. 9 | -------------------------------------------------------------------------------- /apps/examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@htmldocs/typescript-config/react-library.json", 3 | "compilerOptions": { 4 | "lib": ["es2022", "dom"], 5 | "outDir": "dist", 6 | "paths": { 7 | "~/*": [ 8 | "./" 9 | ] 10 | } 11 | }, 12 | "include": ["**/*"], 13 | "exclude": ["node_modules", "dist"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/htmldocs/public/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "lib": ["es2022", "dom"], 5 | "outDir": "dist", 6 | "paths": { 7 | "~/*": [ 8 | "./" 9 | ] 10 | }, 11 | "esModuleInterop": true 12 | }, 13 | "include": ["**/*"], 14 | "exclude": ["node_modules", "dist"] 15 | } -------------------------------------------------------------------------------- /packages/typescript-config/nextjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Next.js", 4 | "extends": "./base.json", 5 | "compilerOptions": { 6 | "plugins": [{ "name": "next" }], 7 | "module": "ESNext", 8 | "moduleResolution": "Bundler", 9 | "allowJs": true, 10 | "jsx": "preserve", 11 | "noEmit": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [["htmldocs-starter", "htmldocs", "@htmldocs/react", "@htmldocs/render"]], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/theme-provider.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import { ThemeProvider as NextThemesProvider } from "next-themes" 5 | import { type ThemeProviderProps } from "next-themes/dist/types" 6 | 7 | export function ThemeProvider({ children, ...props }: ThemeProviderProps) { 8 | return {children} 9 | } 10 | -------------------------------------------------------------------------------- /packages/react/components/Head.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | export type HeadProps = Readonly>; 4 | 5 | const Head = React.forwardRef( 6 | ({ children, ...props }, ref) => ( 7 | 8 | {children} 9 | 10 | ), 11 | ); 12 | 13 | Head.displayName = "Head"; 14 | 15 | export default Head; -------------------------------------------------------------------------------- /apps/docs/api-reference/generate-document.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Generate Document' 3 | openapi: 'POST /api/documents/{documentId}' 4 | --- 5 | 6 | This endpoint is for generating a document based on a template you've published to a team. To publish a document, see the [publish command](a/cli#htmldocs-publish-file). 7 | 8 | You can find the ids of your published documents in the [dashboard](https://htmldocs.com/dashboard). 9 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/ui/collapsible.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" 4 | 5 | const Collapsible = CollapsiblePrimitive.Root 6 | 7 | const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger 8 | 9 | const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent 10 | 11 | export { Collapsible, CollapsibleTrigger, CollapsibleContent } 12 | -------------------------------------------------------------------------------- /packages/e2e-tests/.env.example: -------------------------------------------------------------------------------- 1 | # Base URL for the application 2 | TEST_BASE_URL=http://localhost:3000 3 | 4 | # Test user credentials (required) 5 | TEST_USER_EMAIL=test@example.com 6 | TEST_USER_PASSWORD=your-test-password 7 | 8 | # Optional test data 9 | TEST_TEAM_ID=your-test-team-id 10 | 11 | # Test timeouts (optional, defaults shown) 12 | TEST_AUTH_TIMEOUT_MS=300000 # 5 minutes 13 | TEST_POLLING_INTERVAL_MS=1000 # 1 second -------------------------------------------------------------------------------- /packages/htmldocs/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.mjs", 8 | "css": "src/app/globals.css", 9 | "baseColor": "zinc", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "~/components", 15 | "utils": "~/lib/utils" 16 | } 17 | } -------------------------------------------------------------------------------- /packages/react/components/Page.tsx: -------------------------------------------------------------------------------- 1 | interface Props extends React.ComponentProps<"div"> { } 2 | 3 | const Page: React.FC = ({ 4 | children, 5 | style, 6 | ...props 7 | }) => { 8 | return ( 9 | <> 10 |
14 | {children} 15 |
16 | 17 | ); 18 | }; 19 | 20 | export default Page; 21 | -------------------------------------------------------------------------------- /packages/htmldocs/next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | webpack: (config, { isServer }) => { 4 | if (isServer) { 5 | config.externals.push("esbuild"); 6 | } 7 | 8 | return config; 9 | }, 10 | }; 11 | 12 | const withBundleAnalyzer = (await import('@next/bundle-analyzer')).default({ 13 | enabled: process.env.ANALYZE === 'true', 14 | }); 15 | 16 | export default withBundleAnalyzer(nextConfig); 17 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.workingDirectories": [ 3 | { 4 | "mode": "auto" 5 | } 6 | ], 7 | "search.useIgnoreFiles": false, 8 | "search.exclude": { 9 | "**/node_modules": true, 10 | "**/bower_components": true, 11 | "**/*.code-search": true, 12 | ".git": true, 13 | ".next": true, 14 | "out": true, 15 | "build": true, 16 | "coverage": true, 17 | ".turbo": true, 18 | "*.tsbuildinfo": true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/render/build.ts: -------------------------------------------------------------------------------- 1 | import esbuild from 'esbuild'; 2 | import inlineImportPlugin from 'esbuild-plugin-inline-import'; 3 | 4 | esbuild.build({ 5 | entryPoints: ['src/index.ts'], 6 | bundle: true, 7 | outdir: 'dist', 8 | format: 'cjs', 9 | sourcemap: true, 10 | platform: 'node', 11 | external: ['react', 'react-dom'], 12 | plugins: [ 13 | inlineImportPlugin({ 14 | filter: /^(.*)\.css$/, 15 | }), 16 | ], 17 | }).catch(() => process.exit(1)); 18 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "globalDependencies": ["**/.env.*local"], 4 | "tasks": { 5 | "build": { 6 | "dependsOn": ["^build"], 7 | "outputs": [".next/**", "!.next/cache/**", "dist/**"] 8 | }, 9 | "lint": {}, 10 | "dev": { 11 | "cache": false, 12 | "persistent": true 13 | }, 14 | "test": { 15 | "dependsOn": ["^build"], 16 | "outputs": ["coverage/**"] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/preview/[...slug]/loading.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import { Shell } from "~/components/shell"; 4 | import path from "path"; 5 | import { Spinner } from "@phosphor-icons/react"; 6 | 7 | export default function Loading() { 8 | return ( 9 | 10 |
11 | 12 |
13 |
14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /packages/eslint-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@htmldocs/eslint-config", 3 | "version": "0.0.1", 4 | "files": [ 5 | "library.js", 6 | "next.js", 7 | "react-internal.js" 8 | ], 9 | "devDependencies": { 10 | "@vercel/style-guide": "^5.2.0", 11 | "eslint-config-turbo": "^1.12.4", 12 | "eslint-config-prettier": "^9.1.0", 13 | "eslint-plugin-only-warn": "^1.1.0", 14 | "@typescript-eslint/parser": "^7.1.0", 15 | "@typescript-eslint/eslint-plugin": "^7.1.0", 16 | "typescript": "^5.3.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/render/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@htmldocs/typescript-config/base.json", 3 | "ts-node": { 4 | "compilerOptions": { 5 | "module": "commonjs" 6 | } 7 | }, 8 | "compilerOptions": { 9 | "esModuleInterop": true, 10 | "emitDeclarationOnly": true, 11 | "rootDir": "src", 12 | "outDir": "dist", 13 | "module": "esnext", 14 | "moduleResolution": "bundler", 15 | "jsx": "react-jsx", 16 | }, 17 | "include": ["src/**/*", "index.ts"], 18 | "exclude": ["node_modules", "dist"] 19 | } 20 | -------------------------------------------------------------------------------- /packages/htmldocs/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | /cli 19 | 20 | # misc 21 | .DS_Store 22 | *.pem 23 | 24 | # debug 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | 29 | # local env files 30 | .env*.local 31 | 32 | # vercel 33 | .vercel 34 | 35 | # typescript 36 | *.tsbuildinfo 37 | next-env.d.ts 38 | -------------------------------------------------------------------------------- /packages/e2e-tests/tests/fixtures.ts: -------------------------------------------------------------------------------- 1 | import { test as base, type Page } from '@playwright/test'; 2 | import { login } from './helpers/auth'; 3 | 4 | // Declare the types of your fixtures 5 | type AuthFixtures = { 6 | authedPage: Page; 7 | }; 8 | 9 | // Extend the base test with authenticated page 10 | export const test = base.extend({ 11 | authedPage: async ({ page }, use: (page: Page) => Promise) => { 12 | // Login before running the test 13 | await login(page); 14 | 15 | // Use the authenticated page in the test 16 | await use(page); 17 | }, 18 | }); -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/icons/icon-arrow-down.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import type { IconElement, IconProps } from './icon-base'; 3 | import { IconBase } from './icon-base'; 4 | 5 | export const IconArrowDown = React.forwardRef>( 6 | ({ ...props }, forwardedRef) => ( 7 | 8 | 12 | 13 | ), 14 | ); 15 | 16 | IconArrowDown.displayName = 'IconArrowDown'; -------------------------------------------------------------------------------- /packages/render/src/css/index.scss: -------------------------------------------------------------------------------- 1 | @import "normalize.scss"; 2 | @import "pagedjs.scss"; 3 | // @import "paper.scss"; 4 | 5 | .loading-spinner { 6 | position: fixed; 7 | top: 50%; 8 | left: 50%; 9 | transform: translate(-50%, -50%); 10 | width: 50px; 11 | height: 50px; 12 | border: 3px solid #f3f3f3; 13 | border-top: 3px solid #3498db; 14 | border-radius: 50%; 15 | animation: spin 1s linear infinite; 16 | z-index: 9999; 17 | } 18 | 19 | @keyframes spin { 20 | 0% { transform: translate(-50%, -50%) rotate(0deg); } 21 | 100% { transform: translate(-50%, -50%) rotate(360deg); } 22 | } -------------------------------------------------------------------------------- /packages/react/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @htmldocs/react 2 | 3 | ## 0.2.30 4 | 5 | ## 0.2.29 6 | 7 | ## 0.2.28 8 | 9 | ## 0.2.27 10 | 11 | ## 0.2.26 12 | 13 | ## 0.2.25 14 | 15 | ## 0.2.24 16 | 17 | ## 0.2.23 18 | 19 | ## 0.2.22 20 | 21 | ## 0.2.21 22 | 23 | ## 0.2.20 24 | 25 | ## 0.2.19 26 | 27 | ## 0.2.18 28 | 29 | ### Patch Changes 30 | 31 | - 60f8e6b: improve logging, dev experience 32 | 33 | ## 0.2.17 34 | 35 | ### Patch Changes 36 | 37 | - 191eb52: restore packages 38 | 39 | ## 0.2.16 40 | 41 | ### Patch Changes 42 | 43 | - 8787d4b: add .npmignore 44 | 45 | ## 0.2.15 46 | 47 | ## 0.2.14 48 | 49 | ## 0.2.13 50 | -------------------------------------------------------------------------------- /packages/typescript-config/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Default", 4 | "compilerOptions": { 5 | "declaration": true, 6 | "declarationMap": true, 7 | "esModuleInterop": true, 8 | "incremental": false, 9 | "isolatedModules": true, 10 | "lib": ["es2022", "DOM", "DOM.Iterable"], 11 | "module": "NodeNext", 12 | "moduleDetection": "force", 13 | "moduleResolution": "NodeNext", 14 | "noUncheckedIndexedAccess": true, 15 | "resolveJsonModule": true, 16 | "skipLibCheck": true, 17 | "strict": true, 18 | "target": "ES2022" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/htmldocs/build-preview-server.mjs: -------------------------------------------------------------------------------- 1 | import { spawn } from 'node:child_process'; 2 | import fs from 'node:fs'; 3 | 4 | const nextBuildProcess = spawn('next', ['build'], { 5 | detached: true, 6 | stdio: "inherit", 7 | env: { ...process.env } 8 | }); 9 | 10 | process.on('SIGINT', () => { 11 | nextBuildProcess.kill('SIGINT'); 12 | }); 13 | 14 | nextBuildProcess.on('exit', (code) => { 15 | if (code !== 0) { 16 | process.exit(code); 17 | } 18 | 19 | if (fs.existsSync('dist/preview')) { 20 | fs.rmSync('dist/preview', { recursive: true }); 21 | } 22 | fs.mkdirSync('dist/preview', { recursive: true }); 23 | fs.renameSync('.next', 'dist/preview/.next'); 24 | }); -------------------------------------------------------------------------------- /packages/e2e-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "e2e-tests", 3 | "private": true, 4 | "version": "1.0.2", 5 | "description": "End-to-end tests for htmldocs", 6 | "scripts": { 7 | "test": "playwright test", 8 | "test:ui": "playwright test --ui", 9 | "test:debug": "playwright test --debug", 10 | "install:browsers": "playwright install chromium", 11 | "report": "playwright show-report" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "devDependencies": { 17 | "@playwright/test": "^1.50.1", 18 | "@types/node-fetch": "^2.6.12", 19 | "dotenv": "^16.4.7", 20 | "expect": "^29.7.0", 21 | "node-fetch": "^2.7.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/react/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./components"; 2 | 3 | export type JSONPrimitive = string | number | boolean | Date | null; 4 | export type JSONObject = { [key: string]: JSONValue }; 5 | export type JSONInterface = { [P in keyof T]: JSONValue }; 6 | export type JSONArray = JSONValue[]; 7 | export type JSONValue = JSONPrimitive | JSONObject | JSONInterface | JSONArray; 8 | 9 | // stub, subbed out during build process 10 | export function useValue>(name: string): T | undefined { 11 | return undefined; 12 | } 13 | 14 | export { MarginBox } from './components/MarginBox'; 15 | export type { MarginBoxPosition } from './components/MarginBox'; 16 | 17 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/icons/icon-base.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export type IconElement = React.ElementRef<'svg'>; 4 | export type RootProps = React.ComponentPropsWithoutRef<'svg'>; 5 | 6 | export interface IconProps extends RootProps { 7 | size?: number; 8 | } 9 | 10 | export const IconBase = React.forwardRef>( 11 | ({ size = 20, ...props }, forwardedRef) => ( 12 | 21 | ), 22 | ); 23 | 24 | IconBase.displayName = 'IconBase'; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # Dependencies 4 | node_modules 5 | .pnp 6 | .pnp.js 7 | 8 | # Local env files 9 | **/.env 10 | **/.env.local 11 | **/.env.development.local 12 | **/.env.test.local 13 | **/.env.production.local 14 | 15 | # Testing 16 | coverage 17 | 18 | # Turbo 19 | .turbo 20 | 21 | # Vercel 22 | .vercel 23 | 24 | # Build Outputs 25 | .next/ 26 | out/ 27 | build 28 | dist 29 | 30 | # Playwright 31 | **/playwright-report 32 | **/test-results 33 | 34 | # Debug 35 | npm-debug.log* 36 | yarn-debug.log* 37 | yarn-error.log* 38 | 39 | # Misc 40 | .DS_Store 41 | .ignore 42 | *.pemapps/app 43 | 44 | # Submodules 45 | apps/app 46 | -------------------------------------------------------------------------------- /packages/htmldocs/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "tsup"; 2 | import fs from 'fs'; 3 | import path from 'path'; 4 | 5 | const nodeModulesPath = path.join(__dirname, 'public', 'template', 'node_modules'); 6 | 7 | if (fs.existsSync(nodeModulesPath)) { 8 | fs.rmSync(nodeModulesPath, { recursive: true, force: true }); 9 | } 10 | 11 | export default defineConfig({ 12 | entry: ["./src/cli/index.ts"], 13 | format: ["esm"], 14 | dts: true, 15 | clean: true, 16 | outDir: "dist/cli", 17 | banner: { 18 | js: "#!/usr/bin/env node", 19 | }, 20 | publicDir: true, 21 | define: { 22 | "process.env.API_URL": JSON.stringify(process.env.API_URL || "https://htmldocs.com"), 23 | }, 24 | }); 25 | 26 | -------------------------------------------------------------------------------- /apps/docs/api-reference/authorization.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Authorization 3 | icon: lock 4 | --- 5 | 6 | ### Getting Started 7 | 8 | API requests to htmldocs require an API key which can be obtained from the API tokens section in the [Dashboard](https://htmldocs.com/dashboard). 9 | 10 | 11 | API keys are scoped to your team. Each API key provides access only to documents and resources owned by that team. 12 | 13 | 14 | ### Headers 15 | 16 | API keys should be included in the `Authorization` header of your requests using the Bearer token format: 17 | 18 | ``` 19 | Authorization: Bearer YOUR_API_KEY 20 | ``` 21 | 22 | ### Content Type 23 | 24 | All requests should set the `Content-Type` header to `application/json`. -------------------------------------------------------------------------------- /packages/render/src/types/index.ts: -------------------------------------------------------------------------------- 1 | export interface DocumentComponent { 2 | (props: Record | Record): React.ReactNode; 3 | PreviewProps?: Record; 4 | documentId?: string; 5 | } 6 | 7 | export interface RenderedDocumentMetadata { 8 | markup: string; 9 | reactMarkup: string; 10 | } 11 | 12 | export type DocumentRenderingResult = RenderedDocumentMetadata | { error: ErrorObject }; 13 | 14 | /** 15 | * An object that mimics the structure of the Error class, 16 | * we just can't use the Error class here because server actions can't 17 | * return classes 18 | */ 19 | export interface ErrorObject { 20 | name: string; 21 | stack: string | undefined; 22 | cause: unknown; 23 | message: string; 24 | } 25 | -------------------------------------------------------------------------------- /packages/render/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @htmldocs/render 2 | 3 | ## 0.2.30 4 | 5 | ## 0.2.29 6 | 7 | ## 0.2.28 8 | 9 | ## 0.2.27 10 | 11 | ## 0.2.26 12 | 13 | ## 0.2.25 14 | 15 | ## 0.2.24 16 | 17 | ## 0.2.23 18 | 19 | ### Patch Changes 20 | 21 | - 7043ac8: add zoom controls 22 | 23 | ## 0.2.22 24 | 25 | ## 0.2.21 26 | 27 | ## 0.2.20 28 | 29 | ### Patch Changes 30 | 31 | - 91e3544: open links in new tab 32 | 33 | ## 0.2.19 34 | 35 | ## 0.2.18 36 | 37 | ### Patch Changes 38 | 39 | - 60f8e6b: improve logging, dev experience 40 | 41 | ## 0.2.17 42 | 43 | ### Patch Changes 44 | 45 | - 191eb52: restore packages 46 | 47 | ## 0.2.16 48 | 49 | ### Patch Changes 50 | 51 | - 8787d4b: add .npmignore 52 | 53 | ## 0.2.15 54 | 55 | ## 0.2.14 56 | 57 | ## 0.2.13 58 | -------------------------------------------------------------------------------- /packages/eslint-config/library.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("node:path"); 2 | 3 | const project = resolve(process.cwd(), "tsconfig.json"); 4 | 5 | /** @type {import("eslint").Linter.Config} */ 6 | module.exports = { 7 | extends: ["eslint:recommended", "prettier", "eslint-config-turbo"], 8 | plugins: ["only-warn"], 9 | globals: { 10 | React: true, 11 | JSX: true, 12 | }, 13 | env: { 14 | node: true, 15 | }, 16 | settings: { 17 | "import/resolver": { 18 | typescript: { 19 | project, 20 | }, 21 | }, 22 | }, 23 | ignorePatterns: [ 24 | // Ignore dotfiles 25 | ".*.js", 26 | "node_modules/", 27 | "dist/", 28 | ], 29 | overrides: [ 30 | { 31 | files: ["*.js?(x)", "*.ts?(x)"], 32 | }, 33 | ], 34 | }; 35 | -------------------------------------------------------------------------------- /apps/examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@htmldocs/examples", 3 | "version": "0.0.43", 4 | "private": true, 5 | "scripts": { 6 | "lint": "eslint . --max-warnings 0", 7 | "dev": "htmldocs dev" 8 | }, 9 | "dependencies": { 10 | "@formatjs/intl": "^2.10.4", 11 | "@htmldocs/react": "workspace:*", 12 | "@htmldocs/render": "workspace:*", 13 | "@react-email/components": "0.0.18", 14 | "clsx": "^2.1.1", 15 | "htmldocs": "workspace:*", 16 | "markdown-it": "^14.1.0", 17 | "react": "^18.2.0", 18 | "react-dom": "^18.2.0", 19 | "react-icons": "^5.3.0" 20 | }, 21 | "devDependencies": { 22 | "@types/markdown-it": "^14.1.2", 23 | "@types/node": "^22.8.1", 24 | "@types/react": "^18.2.61", 25 | "@types/react-dom": "^18.2.19", 26 | "typescript": "^5.4.5" 27 | } 28 | } -------------------------------------------------------------------------------- /packages/htmldocs/src/app/lib/types.ts: -------------------------------------------------------------------------------- 1 | export const standardSizes = ["A3", "A4", "A5", "letter", "legal"] as const; 2 | export const orientations = ["portrait", "landscape"] as const; 3 | 4 | type StandardSize = typeof standardSizes[number]; 5 | type Orientation = typeof orientations[number]; 6 | type Unit = 'in' | 'cm' | 'mm' | 'px'; 7 | type CustomSize = `${number}${Unit} ${number}${Unit}`; 8 | export type DocumentSize = StandardSize | CustomSize; 9 | 10 | export interface PageConfig { 11 | size: DocumentSize; 12 | orientation: Orientation; 13 | } 14 | 15 | export const isStandardSize = (size: string): size is StandardSize => { 16 | return standardSizes.includes(size as StandardSize); 17 | }; 18 | 19 | export const parseCustomSize = (size: string) => { 20 | const [width, height] = size.split(' '); 21 | return { width, height }; 22 | }; -------------------------------------------------------------------------------- /packages/eslint-config/next.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("node:path"); 2 | 3 | const project = resolve(process.cwd(), "tsconfig.json"); 4 | 5 | /** @type {import("eslint").Linter.Config} */ 6 | module.exports = { 7 | extends: [ 8 | "eslint:recommended", 9 | "prettier", 10 | require.resolve("@vercel/style-guide/eslint/next"), 11 | "eslint-config-turbo", 12 | ], 13 | globals: { 14 | React: true, 15 | JSX: true, 16 | }, 17 | env: { 18 | node: true, 19 | browser: true, 20 | }, 21 | plugins: ["only-warn"], 22 | settings: { 23 | "import/resolver": { 24 | typescript: { 25 | project, 26 | }, 27 | }, 28 | }, 29 | ignorePatterns: [ 30 | // Ignore dotfiles 31 | ".*.js", 32 | "node_modules/", 33 | ], 34 | overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }], 35 | }; 36 | -------------------------------------------------------------------------------- /packages/htmldocs/src/cli/utils/preview/get-env-variables-for-preview-app.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | export const getEnvVariablesForPreviewApp = ( 4 | relativePathToDocumentsDirectory: string, 5 | cliPackageLocation: string, 6 | cwd: string, 7 | ) => { 8 | return { 9 | NEXT_PUBLIC_DOCUMENTS_DIR_RELATIVE_PATH: relativePathToDocumentsDirectory, 10 | NEXT_PUBLIC_CLI_PACKAGE_LOCATION: cliPackageLocation, 11 | NEXT_PUBLIC_OS_PATH_SEPARATOR: path.sep, 12 | NEXT_PUBLIC_USER_PROJECT_LOCATION: cwd, 13 | // new vars 14 | DOCUMENTS_DIR_RELATIVE_PATH: relativePathToDocumentsDirectory, 15 | DOCUMENTS_STATIC_PATH: path.resolve(relativePathToDocumentsDirectory, 'static'), 16 | DOCUMENTS_DIR_ABSOLUTE_PATH: path.resolve(cwd, relativePathToDocumentsDirectory), 17 | USER_PROJECT_LOCATION: cwd, 18 | } as const; 19 | }; -------------------------------------------------------------------------------- /packages/htmldocs/public/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "htmldocs-starter", 3 | "version": "0.2.30", 4 | "private": true, 5 | "scripts": { 6 | "lint": "eslint . --max-warnings 0", 7 | "dev": "npx htmldocs@latest dev" 8 | }, 9 | "dependencies": { 10 | "@formatjs/intl": "^2.10.4", 11 | "@htmldocs/react": "workspace:0.2.30", 12 | "@htmldocs/render": "workspace:0.2.30", 13 | "@react-email/components": "0.0.18", 14 | "clsx": "^2.1.1", 15 | "htmldocs": "workspace:0.2.30", 16 | "markdown-it": "^14.1.0", 17 | "react": "^18.2.0", 18 | "react-dom": "^18.2.0", 19 | "react-icons": "^5.3.0" 20 | }, 21 | "devDependencies": { 22 | "@types/markdown-it": "^14.1.2", 23 | "@types/node": "^22.8.1", 24 | "@types/react": "^18.2.61", 25 | "@types/react-dom": "^18.2.19", 26 | "typescript": "^5.4.5" 27 | } 28 | } -------------------------------------------------------------------------------- /packages/e2e-tests/playwright.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig, devices } from '@playwright/test'; 2 | import dotenv from 'dotenv'; 3 | import path from 'path'; 4 | 5 | // Load environment variables from .env file 6 | dotenv.config({ path: path.join(__dirname, '.env') }); 7 | 8 | export default defineConfig({ 9 | testDir: './tests', 10 | timeout: 60000, 11 | expect: { 12 | timeout: 10000, 13 | }, 14 | fullyParallel: true, 15 | forbidOnly: !!process.env.CI, 16 | retries: process.env.CI ? 2 : 0, 17 | workers: process.env.CI ? 1 : undefined, 18 | reporter: 'html', 19 | use: { 20 | baseURL: process.env.TEST_BASE_URL || 'http://localhost:3000', 21 | trace: 'on-first-retry', 22 | video: 'on-first-retry', 23 | }, 24 | projects: [ 25 | { 26 | name: 'chromium', 27 | use: { ...devices['Desktop Chrome'] }, 28 | }, 29 | ], 30 | }); -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as LabelPrimitive from "@radix-ui/react-label" 5 | import { cva, type VariantProps } from "class-variance-authority" 6 | 7 | import { cn } from "~/lib/utils" 8 | 9 | const labelVariants = cva( 10 | "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" 11 | ) 12 | 13 | const Label = React.forwardRef< 14 | React.ElementRef, 15 | React.ComponentPropsWithoutRef & 16 | VariantProps 17 | >(({ className, ...props }, ref) => ( 18 | 23 | )) 24 | Label.displayName = LabelPrimitive.Root.displayName 25 | 26 | export { Label } 27 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/ui/input.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "~/lib/utils" 4 | 5 | export interface InputProps 6 | extends React.InputHTMLAttributes {} 7 | 8 | const Input = React.forwardRef( 9 | ({ className, type, ...props }, ref) => { 10 | return ( 11 | 20 | ) 21 | } 22 | ) 23 | Input.displayName = "Input" 24 | 25 | export { Input } 26 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/actions/get-document-schema.ts: -------------------------------------------------------------------------------- 1 | "use server"; 2 | 3 | import path from 'node:path'; 4 | import fs from 'node:fs'; 5 | import { DOCUMENT_SCHEMAS_DIR } from '../../utils/paths'; 6 | import { JSONSchema7Definition } from 'json-schema'; 7 | import logger from '~/lib/logger'; 8 | 9 | export async function getDocumentSchema(documentPath: string): Promise { 10 | const baseName = path.basename(documentPath, path.extname(documentPath)); 11 | const schemaPath = path.join( 12 | DOCUMENT_SCHEMAS_DIR, 13 | baseName, 14 | `${baseName}.schema.json` 15 | ); 16 | 17 | try { 18 | if (fs.existsSync(schemaPath)) { 19 | const rawSchema = JSON.parse(await fs.promises.readFile(schemaPath, 'utf-8')); 20 | return rawSchema?.definitions?.ComponentProps || null; 21 | } 22 | } catch (error) { 23 | logger.warn('Failed to load schema:', error); 24 | } 25 | 26 | return null; 27 | } -------------------------------------------------------------------------------- /packages/eslint-config/react-internal.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("node:path"); 2 | 3 | const project = resolve(process.cwd(), "tsconfig.json"); 4 | 5 | /* 6 | * This is a custom ESLint configuration for use with 7 | * internal (bundled by their consumer) libraries 8 | * that utilize React. 9 | */ 10 | 11 | /** @type {import("eslint").Linter.Config} */ 12 | module.exports = { 13 | extends: ["eslint:recommended", "prettier", "eslint-config-turbo"], 14 | plugins: ["only-warn"], 15 | globals: { 16 | React: true, 17 | JSX: true, 18 | }, 19 | env: { 20 | browser: true, 21 | }, 22 | settings: { 23 | "import/resolver": { 24 | typescript: { 25 | project, 26 | }, 27 | }, 28 | }, 29 | ignorePatterns: [ 30 | // Ignore dotfiles 31 | ".*.js", 32 | "node_modules/", 33 | "dist/", 34 | ], 35 | overrides: [ 36 | // Force ESLint to detect .tsx files 37 | { files: ["*.js?(x)", "*.ts?(x)"] }, 38 | ], 39 | }; 40 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/icons/icon-file.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import type { IconElement, IconProps } from './icon-base'; 3 | import { IconBase } from './icon-base'; 4 | 5 | export const IconFile = React.forwardRef>( 6 | ({ ...props }, forwardedRef) => ( 7 | 8 | 15 | 16 | ), 17 | ); 18 | 19 | IconFile.displayName = 'IconFile'; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "htmldocs", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "build": "turbo run build --filter=./packages/* --filter=!htmldocs-starter", 7 | "dev": "turbo dev", 8 | "lint": "turbo lint", 9 | "format": "prettier --write \"**/*.{ts,tsx,md}\"", 10 | "version": "changeset version && pnpm install --no-frozen-lockfile", 11 | "publish": "pnpm run build && pnpm publish -r", 12 | "test": "turbo test" 13 | }, 14 | "devDependencies": { 15 | "@htmldocs/eslint-config": "workspace:*", 16 | "@htmldocs/typescript-config": "workspace:*", 17 | "prettier": "^3.2.5", 18 | "turbo": "latest", 19 | "vitest": "^1.3.1", 20 | "@vitest/coverage-v8": "^1.3.1", 21 | "happy-dom": "^13.3.8" 22 | }, 23 | "packageManager": "pnpm@8.9.0", 24 | "publishConfig": { 25 | "registry": "https://npm.pkg.github.com" 26 | }, 27 | "engines": { 28 | "node": ">=18" 29 | }, 30 | "dependencies": { 31 | "@changesets/cli": "^2.27.9" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/htmldocs/src/app/components/icons/icon-folder.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import type { IconElement, IconProps } from './icon-base'; 3 | import { IconBase } from './icon-base'; 4 | 5 | export const IconFolder = React.forwardRef>( 6 | ({ ...props }, forwardedRef) => ( 7 | 8 | 14 | 15 | ), 16 | ); 17 | 18 | IconFolder.displayName = 'IconFolder'; -------------------------------------------------------------------------------- /apps/examples/documents/templates/Book.tsx: -------------------------------------------------------------------------------- 1 | import { Document, Footer } from "@htmldocs/react" 2 | import MarkdownIt from 'markdown-it' 3 | import fs from 'node:fs' 4 | import path from "path" 5 | 6 | import "~/index.css" 7 | 8 | const content = fs.readFileSync( 9 | path.join(process.env.DOCUMENTS_STATIC_PATH ?? '', 'content.md'), 10 | 'utf-8' 11 | ) 12 | 13 | const md = new MarkdownIt({ html: true }) 14 | 15 | function Book() { 16 | const html = md.render(content) 17 | 18 | return ( 19 | 20 |
21 |
22 |
23 | 24 |