Skip to content

Commit de747b7

Browse files
authored
Better structure monorepo and publish JS files for react-openapi and react-math (#2392)
1 parent 8e8b73f commit de747b7

File tree

342 files changed

+337
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+337
-142
lines changed

.changeset/five-maps-tickle.md

Lines changed: 5 additions & 0 deletions

.changeset/proud-shrimps-lie.md

Lines changed: 7 additions & 0 deletions

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
5959
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
6060
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
61-
directory: ./.vercel/output/static
61+
directory: ./packages/gitbook/.vercel/output/static
6262
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
6363
workingDirectory: ./
6464
- name: Outputs
@@ -108,7 +108,7 @@ jobs:
108108
env:
109109
PUPPETEER_SKIP_DOWNLOAD: 1
110110
- name: Run pagespeed tests
111-
run: bun ./tests/pagespeed-testing.ts $DEPLOYMENT_URL
111+
run: bun ./packages/gitbook/tests/pagespeed-testing.ts $DEPLOYMENT_URL
112112
env:
113113
DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment_url}}
114114
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }}

.gitignore

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ node_modules
55
/.pnp
66
.pnp.js
77

8-
# testing
9-
/coverage
10-
11-
# next.js
12-
/.next/
13-
/out/
14-
15-
# production
16-
/build
17-
188
# misc
199
.DS_Store
2010
*.pem
@@ -24,25 +14,9 @@ npm-debug.log*
2414
yarn-debug.log*
2515
yarn-error.log*
2616

27-
# local env files
28-
.env*.local
17+
# Turbo
18+
.turbo
2919

30-
# vercel
20+
# Vercel
3121
.vercel
3222

33-
# typescript
34-
*.tsbuildinfo
35-
next-env.d.ts
36-
37-
# visual tests
38-
screenshots/
39-
40-
# Sentry Config File
41-
.sentryclirc
42-
/test-results/
43-
/playwright-report/
44-
/blob-report/
45-
/playwright/.cache/
46-
47-
# Generated public files
48-
/public/~gitbook/static/

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.next
2+
.vercel
23

34
# Generated
45
packages/emoji-codepoints/index.ts
6+
packages/gitbook/public/~gitbook/static/

bun.lockb

11.5 KB
Binary file not shown.

package.json

Lines changed: 10 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,26 @@
22
"name": "gitbook",
33
"version": "0.1.0",
44
"private": true,
5+
"packageManager": "[email protected]",
56
"scripts": {
6-
"dev": "next dev",
7-
"build": "next build",
8-
"build:cloudflare": "next-on-pages",
9-
"start": "next start",
10-
"lint": "next lint",
7+
"dev": "turbo run dev",
8+
"build": "turbo run build",
9+
"build:cloudflare": "turbo run build:cloudflare",
10+
"lint": "turbo run lint",
11+
"typecheck": "turbo run typecheck",
1112
"format": "prettier ./ --ignore-unknown --write",
1213
"format:check": "prettier ./ --ignore-unknown --list-different",
13-
"typecheck": "tsc --noEmit",
14-
"unit": "bun test {src,packages}",
15-
"e2e": "playwright test",
14+
"unit": "turbo run unit",
15+
"e2e": "turbo run e2e",
1616
"changeset": "changeset",
17-
"release": "changeset publish",
18-
"postinstall": "rm -rf ./public/~gitbook/static/[email protected] && mkdir -p ./public/~gitbook/static/ && cp -R node_modules/mathjax/es5 ./public/~gitbook/static/[email protected]"
17+
"release": "turbo run build && changeset publish"
1918
},
2019
"workspaces": [
2120
"packages/*"
2221
],
23-
"dependencies": {
24-
"@geist-ui/icons": "^1.0.2",
25-
"@gitbook/api": "^0.56.0",
26-
"@radix-ui/react-checkbox": "^1.0.4",
27-
"@radix-ui/react-popover": "^1.0.7",
28-
"@sentry/nextjs": "^7.94.1",
29-
"@sindresorhus/fnv1a": "^3.1.0",
30-
"@tailwindcss/container-queries": "^0.1.1",
31-
"@tailwindcss/typography": "^0.5.10",
32-
"@upstash/redis": "^1.27.1",
33-
"ajv": "^8.12.0",
34-
"assert-never": "^1.2.1",
35-
"bun-types": "^1.0.7",
36-
"classnames": "^2.5.1",
37-
"content-security-policy-merger": "^1.0.0",
38-
"framer-motion": "^10.16.14",
39-
"js-cookie": "^3.0.5",
40-
"jsontoxml": "^1.0.1",
41-
"katex": "^0.16.9",
42-
"mathjax": "^3.2.2",
43-
"memoizee": "^0.4.15",
44-
"next": "^14.1.3",
45-
"next-themes": "^0.2.1",
46-
"nuqs": "^1.17.4",
47-
"object-hash": "^3.0.0",
48-
"openapi-types": "^12.1.3",
49-
"p-map": "^7.0.0",
50-
"parse-cache-control": "^1.0.1",
51-
"react": "^18",
52-
"react-dom": "^18",
53-
"react-hotkeys-hook": "^4.4.1",
54-
"recoil": "^0.7.7",
55-
"rehype-sanitize": "^6.0.0",
56-
"rehype-stringify": "^10.0.0",
57-
"remark-gfm": "^4.0.0",
58-
"remark-parse": "^11.0.0",
59-
"remark-rehype": "^11.1.0",
60-
"rison": "^0.1.1",
61-
"server-only": "^0.0.1",
62-
"shiki": "^1.2.0",
63-
"tailwind-merge": "^2.2.0",
64-
"tailwind-shades": "^1.1.2",
65-
"unified": "^11.0.4",
66-
"url-join": "^5.0.0"
67-
},
6822
"devDependencies": {
69-
"@argos-ci/playwright": "^2.0.0",
7023
"@changesets/cli": "^2.27.7",
71-
"@cloudflare/next-on-pages": "^1.11.3",
72-
"@cloudflare/workers-types": "^4.20231218.0",
73-
"@playwright/test": "^1.42.1",
74-
"@types/js-cookie": "^3.0.6",
75-
"@types/jsontoxml": "^1.0.5",
76-
"@types/jsonwebtoken": "^9.0.6",
77-
"@types/katex": "^0.16.5",
78-
"@types/node": "^20",
79-
"@types/object-hash": "^3.0.6",
80-
"@types/parse-cache-control": "^1.0.4",
81-
"@types/psi": "^4.1.6",
82-
"@types/react": "^18",
83-
"@types/react-dom": "^18",
84-
"@types/rison": "^0.0.9",
85-
"autoprefixer": "^10",
86-
"eslint": "^8",
87-
"eslint-config-next": "13.5.6",
88-
"eslint-plugin-import": "^2.29.0",
89-
"jsonwebtoken": "^9.0.2",
90-
"postcss": "^8",
9124
"prettier": "^3.0.3",
92-
"psi": "^4.1.0",
93-
"tailwindcss": "^3.4.0",
94-
"typescript": "^5"
25+
"turbo": "^2.0.9"
9526
}
9627
}
File renamed without changes.
File renamed without changes.

packages/gitbook/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# testing
4+
/coverage
5+
6+
# next.js
7+
/.next/
8+
/out/
9+
10+
# production
11+
/build
12+
13+
# local env files
14+
.env*.local
15+
16+
# vercel
17+
.vercel
18+
19+
# typescript
20+
*.tsbuildinfo
21+
next-env.d.ts
22+
23+
# visual tests
24+
screenshots/
25+
26+
# Sentry Config File
27+
.sentryclirc
28+
29+
/test-results/
30+
/playwright-report/
31+
/blob-report/
32+
/playwright/.cache/
33+
34+
# Generated public files
35+
/public/~gitbook/static/
File renamed without changes.
File renamed without changes.

packages/gitbook/package.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"name": "gitbook",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"build:cloudflare": "next-on-pages",
9+
"start": "next start",
10+
"lint": "next lint",
11+
"typecheck": "tsc --noEmit",
12+
"e2e": "playwright test",
13+
"unit": "bun test {src,packages}",
14+
"postinstall": "rm -rf ./public/~gitbook/static/[email protected] && mkdir -p ./public/~gitbook/static/ && cp -R ../../node_modules/mathjax/es5 ./public/~gitbook/static/[email protected]"
15+
},
16+
"dependencies": {
17+
"@geist-ui/icons": "^1.0.2",
18+
"@gitbook/api": "^0.56.0",
19+
"@gitbook/react-math": "workspace:*",
20+
"@gitbook/react-openapi": "workspace:*",
21+
"@gitbook/react-contentkit": "workspace:*",
22+
"@radix-ui/react-checkbox": "^1.0.4",
23+
"@radix-ui/react-popover": "^1.0.7",
24+
"@sentry/nextjs": "^7.94.1",
25+
"@sindresorhus/fnv1a": "^3.1.0",
26+
"@tailwindcss/container-queries": "^0.1.1",
27+
"@tailwindcss/typography": "^0.5.10",
28+
"@upstash/redis": "^1.27.1",
29+
"ajv": "^8.12.0",
30+
"assert-never": "^1.2.1",
31+
"bun-types": "^1.1.20",
32+
"classnames": "^2.5.1",
33+
"content-security-policy-merger": "^1.0.0",
34+
"framer-motion": "^10.16.14",
35+
"js-cookie": "^3.0.5",
36+
"jsontoxml": "^1.0.1",
37+
"katex": "^0.16.9",
38+
"mathjax": "^3.2.2",
39+
"memoizee": "^0.4.15",
40+
"next": "^14.1.3",
41+
"next-themes": "^0.2.1",
42+
"nuqs": "^1.17.4",
43+
"object-hash": "^3.0.0",
44+
"openapi-types": "^12.1.3",
45+
"p-map": "^7.0.0",
46+
"parse-cache-control": "^1.0.1",
47+
"react": "^18",
48+
"react-dom": "^18",
49+
"react-hotkeys-hook": "^4.4.1",
50+
"recoil": "^0.7.7",
51+
"rehype-sanitize": "^6.0.0",
52+
"rehype-stringify": "^10.0.0",
53+
"remark-gfm": "^4.0.0",
54+
"remark-parse": "^11.0.0",
55+
"remark-rehype": "^11.1.0",
56+
"rison": "^0.1.1",
57+
"server-only": "^0.0.1",
58+
"shiki": "^1.2.0",
59+
"tailwind-merge": "^2.2.0",
60+
"tailwind-shades": "^1.1.2",
61+
"unified": "^11.0.4",
62+
"url-join": "^5.0.0"
63+
},
64+
"devDependencies": {
65+
"@argos-ci/playwright": "^2.0.0",
66+
"@playwright/test": "^1.42.1",
67+
"@cloudflare/next-on-pages": "^1.11.3",
68+
"@cloudflare/workers-types": "^4.20231218.0",
69+
"@types/js-cookie": "^3.0.6",
70+
"@types/jsontoxml": "^1.0.5",
71+
"@types/jsonwebtoken": "^9.0.6",
72+
"@types/node": "^20",
73+
"@types/object-hash": "^3.0.6",
74+
"@types/parse-cache-control": "^1.0.4",
75+
"@types/psi": "^4.1.6",
76+
"@types/react": "^18.3.3",
77+
"@types/react-dom": "^18.3.0",
78+
"@types/rison": "^0.0.9",
79+
"autoprefixer": "^10",
80+
"eslint": "^8",
81+
"eslint-config-next": "^14.2.5",
82+
"eslint-plugin-import": "^2.29.1",
83+
"jsonwebtoken": "^9.0.2",
84+
"postcss": "^8",
85+
"psi": "^4.1.0",
86+
"tailwindcss": "^3.4.0",
87+
"typescript": "^5.5.3"
88+
}
89+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/components/DocumentView/Integration/IntegrationBlock.tsx renamed to packages/gitbook/src/components/DocumentView/Integration/IntegrationBlock.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ import {
1515
Lock,
1616
} from '@geist-ui/icons';
1717
import { ContentKitContext, DocumentBlockIntegration } from '@gitbook/api';
18+
import { ContentKit, ContentKitOutput, ContentKitServerContext } from '@gitbook/react-contentkit';
1819

1920
import { ignoreAPIError, renderIntegrationUi } from '@/lib/api';
2021
import { parseMarkdown } from '@/lib/markdown';
2122
import { tcls } from '@/lib/tailwind';
2223

23-
import { ContentKit, ContentKitOutput, ContentKitServerContext } from '@gitbook/react-contentkit';
24-
2524
import type { BlockProps } from '../Block';
2625
import './contentkit.css';
2726
import { PlainCodeBlock } from '../CodeBlock';

src/components/DocumentView/Math.tsx renamed to packages/gitbook/src/components/DocumentView/Math.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { DocumentBlockMath, DocumentInlineMath } from '@gitbook/api';
2+
import { MathFormula } from '@gitbook/react-math';
23

34
import { getStaticFileURL } from '@/lib/assets';
45
import { tcls } from '@/lib/tailwind';
56

6-
import { MathFormula } from '@gitbook/react-math';
7-
87
import { BlockProps } from './Block';
98
import { InlineProps } from './Inline';
109

src/components/DocumentView/OpenAPI/OpenAPI.tsx renamed to packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPI.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { ChevronDown, ChevronRight } from '@geist-ui/icons';
22
import { DocumentBlockSwagger } from '@gitbook/api';
3+
import { OpenAPIOperation } from '@gitbook/react-openapi';
34
import React from 'react';
45

56
import { LoadingPane } from '@/components/primitives';
67
import { fetchOpenAPIBlock } from '@/lib/openapi';
78
import { tcls } from '@/lib/tailwind';
89

9-
import { OpenAPIOperation } from '@gitbook/react-openapi';
10-
1110
import { BlockProps } from '../Block';
1211
import { PlainCodeBlock } from '../CodeBlock';
1312

src/components/Search/SearchResults.tsx renamed to packages/gitbook/src/components/Search/SearchResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const SearchResults = React.forwardRef(function SearchResults(
4949
const { children, query, spaceId, revisionId, parent, withAsk, onSwitchToAsk } = props;
5050

5151
const language = useLanguage();
52-
const debounceTimeout = React.useRef<NodeJS.Timeout | null>(null);
52+
const debounceTimeout = React.useRef<Timer | null>(null);
5353
const [results, setResults] = React.useState<ResultType[] | null>(null);
5454
const [cursor, setCursor] = React.useState<number | null>(null);
5555
const refs = React.useRef<(null | HTMLAnchorElement)[]>([]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/intl/translate.tsx renamed to packages/gitbook/src/intl/translate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function reactToString(el: React.ReactNode): string {
6969
return el.map(reactToString).join('');
7070
}
7171

72-
if ('props' in el) {
72+
if (typeof el === 'object' && 'props' in el) {
7373
return el.props.children.map(reactToString).join('');
7474
}
7575

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/lib/async.ts renamed to packages/gitbook/src/lib/async.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export async function race<I, R>(
7575
const result = await new Promise<R | null>((resolve, reject) => {
7676
let resolved = false;
7777
let pending = inputs.length;
78-
let timeoutId: NodeJS.Timeout | null = null;
78+
let timeoutId: Timer | null = null;
7979
let blockFallbackStarted = false;
8080
let blockFallbackRunning = false;
8181
let blockFallbackError: Error | null = null;
82-
let blockTimeoutId: NodeJS.Timeout | null = null;
82+
let blockTimeoutId: Timer | null = null;
8383
const abort = new AbortController();
8484

8585
const done = () => {
@@ -326,7 +326,7 @@ export function batch<Args extends any[], R>(
326326
const { delay, groupBy = () => 'default', skip = () => false } = options;
327327

328328
const groups = new Map<string, Array<[Args, (r: R) => void, (error: Error) => void]>>();
329-
let timeoutId: NodeJS.Timeout | null = null;
329+
let timeoutId: Timer | null = null;
330330

331331
return async (...args) => {
332332
if (await skip(...args)) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)