mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ec64dad58 | |||
| 326d674254 | |||
| a6a78ce5ac | |||
| 56cb2f4c9a |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
"@babel/preset-env",
|
||||||
|
"@babel/preset-react"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"public"
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
/// <reference types="next" />
|
||||||
|
/// <reference types="next/image-types/global" />
|
||||||
|
|
||||||
|
// NOTE: This file should not be edited
|
||||||
|
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||||
+43
-36
@@ -1,38 +1,45 @@
|
|||||||
{
|
{
|
||||||
"name": "gitbook",
|
"name": "gitbook",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"devDependencies": {
|
"type": "module",
|
||||||
"@changesets/cli": "^2.27.7",
|
"devDependencies": {
|
||||||
"prettier": "^3.0.3",
|
"@changesets/cli": "^2.27.7",
|
||||||
"turbo": "^2.1.2"
|
"prettier": "^3.0.3",
|
||||||
},
|
"turbo": "^2.1.2"
|
||||||
"packageManager": "bun@1.1.18",
|
},
|
||||||
"patchedDependencies": {
|
"packageManager": "bun@1.1.18",
|
||||||
"@vercel/next@4.3.15": "patches/@vercel%2Fnext@4.3.15.patch",
|
"patchedDependencies": {
|
||||||
"@cloudflare/next-on-pages@1.13.5": "patches/@cloudflare%2Fnext-on-pages@1.13.5.patch"
|
"@vercel/next@4.3.15": "patches/@vercel%2Fnext@4.3.15.patch",
|
||||||
},
|
"@cloudflare/next-on-pages@1.13.5": "patches/@cloudflare%2Fnext-on-pages@1.13.5.patch"
|
||||||
"overrides": {
|
},
|
||||||
"@codemirror/state": "6.4.1"
|
"overrides": {
|
||||||
},
|
"@codemirror/state": "6.4.1"
|
||||||
"private": true,
|
},
|
||||||
"scripts": {
|
"private": true,
|
||||||
"dev": "turbo run dev",
|
"scripts": {
|
||||||
"build": "turbo run build",
|
"dev": "turbo run dev",
|
||||||
"build:cloudflare": "turbo run build:cloudflare",
|
"build": "turbo run build",
|
||||||
"lint": "turbo run lint",
|
"build:cloudflare": "turbo run build:cloudflare",
|
||||||
"lint:fix": "turbo run lint -- --fix",
|
"lint": "turbo run lint",
|
||||||
"typecheck": "turbo run typecheck",
|
"lint:fix": "turbo run lint -- --fix",
|
||||||
"format": "prettier ./ --ignore-unknown --write",
|
"typecheck": "turbo run typecheck",
|
||||||
"format:check": "prettier ./ --ignore-unknown --list-different",
|
"format": "prettier ./ --ignore-unknown --write",
|
||||||
"unit": "turbo run unit",
|
"format:check": "prettier ./ --ignore-unknown --list-different",
|
||||||
"e2e": "turbo run e2e",
|
"unit": "turbo run unit",
|
||||||
"changeset": "changeset",
|
"e2e": "turbo run e2e",
|
||||||
"release": "turbo run release && changeset publish",
|
"changeset": "changeset",
|
||||||
"release:preview": "turbo run release:preview",
|
"release": "turbo run release && changeset publish",
|
||||||
"download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local",
|
"release:preview": "turbo run release:preview",
|
||||||
"clean": "turbo run clean"
|
"download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local",
|
||||||
},
|
"clean": "turbo run clean"
|
||||||
"workspaces": [
|
},
|
||||||
"packages/*"
|
"workspaces": [
|
||||||
]
|
"packages/*"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/cli": "^7.26.4",
|
||||||
|
"@babel/preset-env": "^7.26.0",
|
||||||
|
"@babel/preset-react": "^7.26.3",
|
||||||
|
"tsconfig-paths": "^4.2.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -11,23 +11,24 @@ import { Metadata } from 'next';
|
|||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { DocumentView } from '@/components/DocumentView';
|
import { DocumentView } from '../../../../components/DocumentView';
|
||||||
import { TrademarkLink } from '@/components/TableOfContents/Trademark';
|
import { TrademarkLink } from '../../../../components/TableOfContents/Trademark';
|
||||||
import { PolymorphicComponentProp } from '@/components/utils/types';
|
import { PolymorphicComponentProp } from '../../../../components/utils/types';
|
||||||
import { getSpaceLanguage } from '@/intl/server';
|
import { getSpaceLanguage } from '../../../../intl/server';
|
||||||
import { tString } from '@/intl/translate';
|
import { tString } from '../../../../intl/translate';
|
||||||
import {
|
import {
|
||||||
getDocument,
|
getDocument,
|
||||||
getSpace,
|
getSpace,
|
||||||
getSpaceCustomization,
|
getSpaceCustomization,
|
||||||
getSpaceContentData,
|
getSpaceContentData,
|
||||||
getSiteData,
|
getSiteData,
|
||||||
} from '@/lib/api';
|
} from '../../../../lib/api';
|
||||||
import { pagePDFContainerId, PageHrefContext, absoluteHref } from '@/lib/links';
|
import { pagePDFContainerId, PageHrefContext, absoluteHref } from '../../../../lib/links';
|
||||||
import { resolvePageId } from '@/lib/pages';
|
import { resolvePageId } from '../../../../lib/pages';
|
||||||
import { ContentRefContext, resolveContentRef } from '@/lib/references';
|
import { ContentRefContext, resolveContentRef } from '../../../../lib/references';
|
||||||
import { tcls } from '@/lib/tailwind';
|
import { tcls } from '../../../../lib/tailwind';
|
||||||
import { PDFSearchParams, getPDFSearchParams } from '@/lib/urls';
|
import { SiteContentPointer, SpaceContentPointer } from '../../../../lib/api';
|
||||||
|
import { PDFSearchParams, getPDFSearchParams } from '../../../../lib/urls';
|
||||||
|
|
||||||
import './pdf.css';
|
import './pdf.css';
|
||||||
import { PageControlButtons } from './PageControlButtons';
|
import { PageControlButtons } from './PageControlButtons';
|
||||||
@@ -55,7 +56,9 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
* Render a space as a standalone HTML page that can be printed as a PDF.
|
* Render a space as a standalone HTML page that can be printed as a PDF.
|
||||||
*/
|
*/
|
||||||
export default async function PDFHTMLOutput(props: { searchParams: { [key: string]: string } }) {
|
export default async function PDFHTMLOutput(props: { searchParams: { [key: string]: string } }) {
|
||||||
const pointer = getSiteOrSpacePointerForPDF();
|
const pointer = {"siteId": "site_dIY9z", "spaceId": "-MdwVZ6HOZriajCf5nXH", "siteSpaceId": "sitesp_mX2p5", "organizationId": "-M4tdxG8qotLgGZnLpFR"} as SiteContentPointer | SpaceContentPointer;
|
||||||
|
|
||||||
|
console.log('vib pointer', JSON.stringify(pointer));
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(props.searchParams);
|
const searchParams = new URLSearchParams(props.searchParams);
|
||||||
const pdfParams = getPDFSearchParams(new URLSearchParams(searchParams));
|
const pdfParams = getPDFSearchParams(new URLSearchParams(searchParams));
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
const { renderToPipeableStream } = require('react-dom/server');
|
||||||
|
const PDFHTMLOutput = require('./page');
|
||||||
|
//import { renderToPipeableStream, renderToStaticNodeStream } from 'react-dom/server';
|
||||||
|
//import PDFHTMLOutput from './page';
|
||||||
|
//import fs from 'fs';
|
||||||
|
//import React from 'react';
|
||||||
|
const fs = require('fs');
|
||||||
|
const React = require('react');
|
||||||
|
|
||||||
|
|
||||||
|
// Create a writable stream to save the HTML to a file
|
||||||
|
const writeStream = fs.createWriteStream('output.html');
|
||||||
|
|
||||||
|
// Start the server-side rendering with renderToPipeableStream
|
||||||
|
const { pipe } = renderToPipeableStream(React.createElement(PDFHTMLOutput, {searchParams : {'a': 'b'}}) as any);
|
||||||
|
|
||||||
|
// Pipe the render stream to the writable file stream
|
||||||
|
pipe(writeStream);
|
||||||
|
|
||||||
|
// Optionally, you can handle errors and closure
|
||||||
|
writeStream.on('finish', () => {
|
||||||
|
console.log('HTML has been written to output.html');
|
||||||
|
});
|
||||||
|
|
||||||
|
writeStream.on('error', (err: any) => {
|
||||||
|
console.error('Error writinsg to file:', err);
|
||||||
|
});
|
||||||
@@ -283,9 +283,9 @@ function CodeHighlightToken(props: {
|
|||||||
return <>{token.content}</>;
|
return <>{token.content}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!token.token.color) {
|
// if (!token.token.color) {
|
||||||
return <>{token.token.content}</>;
|
// return <>{token.token.content}</>;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return <span style={{ color: token.token.color }}>{token.token.content}</span>;
|
// return <span style={{ color: token.token.color }}>{token.token.content}</span>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,105 +1,110 @@
|
|||||||
import { DocumentBlockCode, DocumentBlockCodeLine, DocumentInlineAnnotation } from '@gitbook/api';
|
import { DocumentBlockCode, DocumentBlockCodeLine, DocumentInlineAnnotation } from '@gitbook/api';
|
||||||
import {
|
// // @ts-ignore - onigWasm is a Wasm module
|
||||||
createdBundledHighlighter,
|
// import {
|
||||||
ThemedToken,
|
// createdBundledHighlighter,
|
||||||
createCssVariablesTheme,
|
// ThemedToken,
|
||||||
HighlighterGeneric,
|
// createCssVariablesTheme,
|
||||||
} from 'shiki/core';
|
// HighlighterGeneric,
|
||||||
import { loadWasm, createOnigurumaEngine } from 'shiki/engine/oniguruma';
|
// } from 'shiki/core';
|
||||||
import { bundledLanguages } from 'shiki/langs';
|
// // @ts-ignore - onigWasm is a Wasm module
|
||||||
// @ts-ignore - onigWasm is a Wasm module
|
// import { loadWasm, createOnigurumaEngine } from 'shiki/engine/oniguruma';
|
||||||
import onigWasm from 'shiki/onig.wasm?module';
|
// // @ts-ignore - onigWasm is a Wasm module
|
||||||
|
// import { bundledLanguages } from 'shiki/langs';
|
||||||
|
// // @ts-ignore - onigWasm is a Wasm module
|
||||||
|
// import onigWasm from 'shiki/onig.wasm?module';
|
||||||
|
|
||||||
import { asyncMutexFunction, singleton } from '@/lib/async';
|
// import { asyncMutexFunction, singleton } from '@/lib/async';
|
||||||
import { getNodeText } from '@/lib/document';
|
import { getNodeText } from '@/lib/document';
|
||||||
import { trace } from '@/lib/tracing';
|
// import { trace } from '@/lib/tracing';
|
||||||
|
|
||||||
export type HighlightLine = {
|
export type HighlightLine = {
|
||||||
highlighted: boolean;
|
highlighted: boolean;
|
||||||
tokens: HighlightToken[];
|
tokens: HighlightToken[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HighlightToken =
|
export type HighlightToken =
|
||||||
| { type: 'plain'; content: string }
|
| { type: 'plain'; content: string }
|
||||||
| { type: 'shiki'; token: ThemedToken }
|
| { type: 'inline'; inline: DocumentInlineAnnotation; children: HighlightToken[] };
|
||||||
| { type: 'inline'; inline: DocumentInlineAnnotation; children: HighlightToken[] };
|
|
||||||
|
|
||||||
type InlineIndexed = { inline: any; start: number; end: number };
|
// | { type: 'shiki'; token: ThemedToken }
|
||||||
|
|
||||||
type PositionedToken = ThemedToken & { start: number; end: number };
|
// type InlineIndexed = { inline: any; start: number; end: number };
|
||||||
|
|
||||||
/**
|
// type PositionedToken = ThemedToken & { start: number; end: number };
|
||||||
* Highlight a code block while preserving inline elements.
|
|
||||||
*/
|
// /**
|
||||||
|
// * Highlight a code block while preserving inline elements.
|
||||||
|
// */
|
||||||
export async function highlight(block: DocumentBlockCode): Promise<HighlightLine[]> {
|
export async function highlight(block: DocumentBlockCode): Promise<HighlightLine[]> {
|
||||||
const langName = block.data.syntax ? getLanguageForSyntax(block.data.syntax) : null;
|
return plainHighlighting(block);
|
||||||
if (!langName) {
|
// const langName = block.data.syntax ? getLanguageForSyntax(block.data.syntax) : null;
|
||||||
// Language not found, fallback to plain highlighting
|
// if (!langName) {
|
||||||
return plainHighlighting(block);
|
// // Language not found, fallback to plain highlighting
|
||||||
}
|
// return plainHighlighting(block);
|
||||||
|
// }
|
||||||
|
|
||||||
const inlines: InlineIndexed[] = [];
|
// const inlines: InlineIndexed[] = [];
|
||||||
const code = getPlainCodeBlock(block, inlines);
|
// const code = getPlainCodeBlock(block, inlines);
|
||||||
|
|
||||||
inlines.sort((a, b) => {
|
// inlines.sort((a, b) => {
|
||||||
return a.start - b.start;
|
// return a.start - b.start;
|
||||||
});
|
// });
|
||||||
|
|
||||||
const highlighter = await loadHighlighter();
|
// const highlighter = await loadHighlighter();
|
||||||
await loadHighlighterLanguage(highlighter, langName);
|
// await loadHighlighterLanguage(highlighter, langName);
|
||||||
|
|
||||||
const lines = highlighter.codeToTokensBase(code, {
|
// const lines = highlighter.codeToTokensBase(code, {
|
||||||
lang: langName,
|
// lang: langName,
|
||||||
tokenizeMaxLineLength: 400,
|
// tokenizeMaxLineLength: 400,
|
||||||
});
|
// });
|
||||||
|
|
||||||
let currentIndex = 0;
|
// let currentIndex = 0;
|
||||||
return lines.map((tokens, index) => {
|
// return lines.map((tokens, index) => {
|
||||||
const lineBlock = block.nodes[index];
|
// const lineBlock = block.nodes[index];
|
||||||
const result: HighlightToken[] = [];
|
// const result: HighlightToken[] = [];
|
||||||
|
|
||||||
const eatToken = (): PositionedToken | null => {
|
// const eatToken = (): PositionedToken | null => {
|
||||||
const token = tokens.shift();
|
// const token = tokens.shift();
|
||||||
if (token) {
|
// if (token) {
|
||||||
currentIndex += token.content.length;
|
// currentIndex += token.content.length;
|
||||||
}
|
// }
|
||||||
return token
|
// return token
|
||||||
? { ...token, start: currentIndex - token.content.length, end: currentIndex }
|
// ? { ...token, start: currentIndex - token.content.length, end: currentIndex }
|
||||||
: null;
|
// : null;
|
||||||
};
|
// };
|
||||||
|
|
||||||
while (tokens.length > 0) {
|
// while (tokens.length > 0) {
|
||||||
result.push(...matchTokenAndInlines(eatToken, inlines));
|
// result.push(...matchTokenAndInlines(eatToken, inlines));
|
||||||
}
|
// }
|
||||||
|
|
||||||
currentIndex += 1; // for the \n
|
// currentIndex += 1; // for the \n
|
||||||
|
|
||||||
return {
|
// return {
|
||||||
highlighted: !!lineBlock.data.highlighted,
|
// highlighted: !!lineBlock.data.highlighted,
|
||||||
tokens: result,
|
// tokens: result,
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Validate a language name.
|
// * Validate a language name.
|
||||||
*/
|
// */
|
||||||
function getLanguageForSyntax(syntax: string): keyof typeof bundledLanguages | null {
|
// function getLanguageForSyntax(syntax: string): keyof typeof bundledLanguages | null {
|
||||||
// @ts-ignore
|
// // @ts-ignore
|
||||||
const lang = bundledLanguages[syntax];
|
// const lang = bundledLanguages[syntax];
|
||||||
if (!lang) {
|
// if (!lang) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @ts-ignore
|
// // @ts-ignore
|
||||||
return syntax;
|
// return syntax;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Parse a code block without highlighting it.
|
// * Parse a code block without highlighting it.
|
||||||
*/
|
// */
|
||||||
export function plainHighlighting(block: DocumentBlockCode): HighlightLine[] {
|
export function plainHighlighting(block: DocumentBlockCode): HighlightLine[] {
|
||||||
return block.nodes.map((lineBlock) => {
|
return block.nodes.map((lineBlock: any) => {
|
||||||
const tokens: HighlightToken[] = [];
|
const tokens: HighlightToken[] = [];
|
||||||
|
|
||||||
for (const node of lineBlock.nodes) {
|
for (const node of lineBlock.nodes) {
|
||||||
@@ -108,17 +113,6 @@ export function plainHighlighting(block: DocumentBlockCode): HighlightLine[] {
|
|||||||
type: 'plain',
|
type: 'plain',
|
||||||
content: getNodeText(node),
|
content: getNodeText(node),
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
tokens.push({
|
|
||||||
type: 'inline',
|
|
||||||
inline: node,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
type: 'plain',
|
|
||||||
content: getNodeText(node),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,214 +123,214 @@ export function plainHighlighting(block: DocumentBlockCode): HighlightLine[] {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function matchTokenAndInlines(
|
// function matchTokenAndInlines(
|
||||||
eat: () => PositionedToken | null,
|
// eat: () => PositionedToken | null,
|
||||||
allInlines: InlineIndexed[],
|
// allInlines: InlineIndexed[],
|
||||||
): HighlightToken[] {
|
// ): HighlightToken[] {
|
||||||
const initialToken = eat();
|
// const initialToken = eat();
|
||||||
if (!initialToken) {
|
// if (!initialToken) {
|
||||||
return [];
|
// return [];
|
||||||
}
|
// }
|
||||||
|
|
||||||
const inlines = allInlines.filter(
|
// const inlines = allInlines.filter(
|
||||||
(inline) => inline.start >= initialToken.start && inline.start < initialToken.end,
|
// (inline) => inline.start >= initialToken.start && inline.start < initialToken.end,
|
||||||
);
|
// );
|
||||||
let token = initialToken;
|
// let token = initialToken;
|
||||||
const result: HighlightToken[] = [];
|
// const result: HighlightToken[] = [];
|
||||||
|
|
||||||
const matchAgainstInline = () => {
|
// const matchAgainstInline = () => {
|
||||||
const inline = inlines.shift();
|
// const inline = inlines.shift();
|
||||||
if (!inline) {
|
// if (!inline) {
|
||||||
result.push({
|
// result.push({
|
||||||
type: 'shiki',
|
// type: 'shiki',
|
||||||
token,
|
// token,
|
||||||
});
|
// });
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const [before, afterBefore] = splitPositionedTokenAt(token, inline.start);
|
// const [before, afterBefore] = splitPositionedTokenAt(token, inline.start);
|
||||||
if (before) {
|
// if (before) {
|
||||||
result.push({
|
// result.push({
|
||||||
type: 'shiki',
|
// type: 'shiki',
|
||||||
token: before,
|
// token: before,
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
if (!afterBefore) {
|
// if (!afterBefore) {
|
||||||
throw new Error(`expect afterBefore to not be empty`);
|
// throw new Error(`expect afterBefore to not be empty`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
token = afterBefore;
|
// token = afterBefore;
|
||||||
const children: HighlightToken[] = [];
|
// const children: HighlightToken[] = [];
|
||||||
|
|
||||||
// If shiki token finished before the end of the annotation or the annotation contains multiple tokens
|
// // If shiki token finished before the end of the annotation or the annotation contains multiple tokens
|
||||||
while (token.end < inline.end) {
|
// while (token.end < inline.end) {
|
||||||
children.push({
|
// children.push({
|
||||||
type: 'shiki',
|
// type: 'shiki',
|
||||||
token: token,
|
// token: token,
|
||||||
});
|
// });
|
||||||
|
|
||||||
const next = eat();
|
// const next = eat();
|
||||||
if (!next) {
|
// if (!next) {
|
||||||
throw new Error(`expect token to not be empty`);
|
// throw new Error(`expect token to not be empty`);
|
||||||
}
|
// }
|
||||||
token = next;
|
// token = next;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const [inside, after] = splitPositionedTokenAt(token, inline.end);
|
// const [inside, after] = splitPositionedTokenAt(token, inline.end);
|
||||||
if (!inside) {
|
// if (!inside) {
|
||||||
throw new Error(`expect inside to not be empty`);
|
// throw new Error(`expect inside to not be empty`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
children.push({
|
// children.push({
|
||||||
type: 'shiki',
|
// type: 'shiki',
|
||||||
token: inside,
|
// token: inside,
|
||||||
});
|
// });
|
||||||
|
|
||||||
result.push({
|
// result.push({
|
||||||
type: 'inline',
|
// type: 'inline',
|
||||||
inline: inline.inline,
|
// inline: inline.inline,
|
||||||
children,
|
// children,
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (after) {
|
// if (after) {
|
||||||
token = after;
|
// token = after;
|
||||||
matchAgainstInline();
|
// matchAgainstInline();
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
matchAgainstInline();
|
// matchAgainstInline();
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function getPlainCodeBlock(code: DocumentBlockCode, inlines: InlineIndexed[]): string {
|
// function getPlainCodeBlock(code: DocumentBlockCode, inlines: InlineIndexed[]): string {
|
||||||
let content = '';
|
// let content = '';
|
||||||
|
|
||||||
code.nodes.forEach((node, index) => {
|
// code.nodes.forEach((node, index) => {
|
||||||
const lineContent = getPlainCodeBlockLine(node, inlines, content.length);
|
// const lineContent = getPlainCodeBlockLine(node, inlines, content.length);
|
||||||
content += lineContent;
|
// content += lineContent;
|
||||||
|
|
||||||
if (index < code.nodes.length - 1) {
|
// if (index < code.nodes.length - 1) {
|
||||||
content += '\n';
|
// content += '\n';
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
return content;
|
// return content;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function getPlainCodeBlockLine(
|
// function getPlainCodeBlockLine(
|
||||||
parent: DocumentBlockCodeLine | DocumentInlineAnnotation,
|
// parent: DocumentBlockCodeLine | DocumentInlineAnnotation,
|
||||||
inlines: InlineIndexed[],
|
// inlines: InlineIndexed[],
|
||||||
index: number,
|
// index: number,
|
||||||
): string {
|
// ): string {
|
||||||
let content = '';
|
// let content = '';
|
||||||
|
|
||||||
for (const node of parent.nodes) {
|
// for (const node of parent.nodes) {
|
||||||
if (node.object === 'text') {
|
// if (node.object === 'text') {
|
||||||
content += cleanupLine(node.leaves.map((leaf) => leaf.text).join(''));
|
// content += cleanupLine(node.leaves.map((leaf) => leaf.text).join(''));
|
||||||
} else {
|
// } else {
|
||||||
const start = index + content.length;
|
// const start = index + content.length;
|
||||||
content += getPlainCodeBlockLine(node, inlines, index + content.length);
|
// content += getPlainCodeBlockLine(node, inlines, index + content.length);
|
||||||
const end = index + content.length;
|
// const end = index + content.length;
|
||||||
|
|
||||||
inlines.push({
|
// inlines.push({
|
||||||
inline: node,
|
// inline: node,
|
||||||
start,
|
// start,
|
||||||
end,
|
// end,
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return content;
|
// return content;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function slicePositionedToken(
|
// function slicePositionedToken(
|
||||||
token: PositionedToken,
|
// token: PositionedToken,
|
||||||
relativeStart: number,
|
// relativeStart: number,
|
||||||
relativeLength: number,
|
// relativeLength: number,
|
||||||
): PositionedToken {
|
// ): PositionedToken {
|
||||||
return {
|
// return {
|
||||||
...token,
|
// ...token,
|
||||||
start: token.start + relativeStart,
|
// start: token.start + relativeStart,
|
||||||
end: token.start + relativeStart + relativeLength,
|
// end: token.start + relativeStart + relativeLength,
|
||||||
content: token.content.slice(relativeStart, relativeStart + relativeLength),
|
// content: token.content.slice(relativeStart, relativeStart + relativeLength),
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
function splitPositionedTokenAt(
|
// function splitPositionedTokenAt(
|
||||||
token: PositionedToken,
|
// token: PositionedToken,
|
||||||
absoluteIndex: number,
|
// absoluteIndex: number,
|
||||||
): [PositionedToken | null, PositionedToken | null] {
|
// ): [PositionedToken | null, PositionedToken | null] {
|
||||||
if (absoluteIndex < token.start || absoluteIndex > token.end) {
|
// if (absoluteIndex < token.start || absoluteIndex > token.end) {
|
||||||
throw new Error(`index (${absoluteIndex}) out of bound (${token.start}:${token.end})`);
|
// throw new Error(`index (${absoluteIndex}) out of bound (${token.start}:${token.end})`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const before = slicePositionedToken(token, 0, absoluteIndex - token.start);
|
// const before = slicePositionedToken(token, 0, absoluteIndex - token.start);
|
||||||
const after = slicePositionedToken(
|
// const after = slicePositionedToken(
|
||||||
token,
|
// token,
|
||||||
absoluteIndex - token.start,
|
// absoluteIndex - token.start,
|
||||||
token.end - absoluteIndex,
|
// token.end - absoluteIndex,
|
||||||
);
|
// );
|
||||||
|
|
||||||
return [
|
// return [
|
||||||
isEmptyPositionedToken(before) ? null : before,
|
// isEmptyPositionedToken(before) ? null : before,
|
||||||
isEmptyPositionedToken(after) ? null : after,
|
// isEmptyPositionedToken(after) ? null : after,
|
||||||
];
|
// ];
|
||||||
}
|
// }
|
||||||
|
|
||||||
function isEmptyPositionedToken(token: PositionedToken): boolean {
|
// function isEmptyPositionedToken(token: PositionedToken): boolean {
|
||||||
return token.start === token.end;
|
// return token.start === token.end;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Currently it's possible for some lines to contain \r characters, we need to remove them
|
// * Currently it's possible for some lines to contain \r characters, we need to remove them
|
||||||
* as they are considered as new lines by shikijs.
|
// * as they are considered as new lines by shikijs.
|
||||||
*/
|
// */
|
||||||
function cleanupLine(line: string): string {
|
// function cleanupLine(line: string): string {
|
||||||
return line.replace(/\r/g, '');
|
// return line.replace(/\r/g, '');
|
||||||
}
|
// }
|
||||||
|
|
||||||
const createHighlighter = createdBundledHighlighter<any, any>({
|
// const createHighlighter = createdBundledHighlighter<any, any>({
|
||||||
langs: bundledLanguages,
|
// langs: bundledLanguages,
|
||||||
themes: {},
|
// themes: {},
|
||||||
engine: () => createOnigurumaEngine(import('shiki/wasm')),
|
// engine: () => createOnigurumaEngine(import('shiki/wasm')),
|
||||||
});
|
// });
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Load the highlighter, only once, and reuse it.
|
// * Load the highlighter, only once, and reuse it.
|
||||||
* It makes sure to handle concurrent calls.
|
// * It makes sure to handle concurrent calls.
|
||||||
*/
|
// */
|
||||||
const loadHighlighter = singleton(async () => {
|
// const loadHighlighter = singleton(async () => {
|
||||||
return await trace('highlighting.loadHighlighter', async () => {
|
// return await trace('highlighting.loadHighlighter', async () => {
|
||||||
if (typeof onigWasm !== 'string') {
|
// if (typeof onigWasm !== 'string') {
|
||||||
// When running bun test, the import is a string, we ignore it and let the module
|
// // When running bun test, the import is a string, we ignore it and let the module
|
||||||
// loads it on its own.
|
// // loads it on its own.
|
||||||
//
|
// //
|
||||||
// Otherwise for Vercel/Cloudflare, we need to load it ourselves.
|
// // Otherwise for Vercel/Cloudflare, we need to load it ourselves.
|
||||||
await loadWasm((obj) => WebAssembly.instantiate(onigWasm, obj));
|
// await loadWasm((obj) => WebAssembly.instantiate(onigWasm, obj));
|
||||||
}
|
// }
|
||||||
|
|
||||||
const highlighter = await createHighlighter({
|
// const highlighter = await createHighlighter({
|
||||||
themes: [createCssVariablesTheme()],
|
// themes: [createCssVariablesTheme()],
|
||||||
langs: [],
|
// langs: [],
|
||||||
});
|
// });
|
||||||
return highlighter;
|
// return highlighter;
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
|
||||||
const loadLanguagesMutex = asyncMutexFunction();
|
// const loadLanguagesMutex = asyncMutexFunction();
|
||||||
async function loadHighlighterLanguage(
|
// async function loadHighlighterLanguage(
|
||||||
highlighter: HighlighterGeneric<any, any>,
|
// highlighter: HighlighterGeneric<any, any>,
|
||||||
lang: keyof typeof bundledLanguages,
|
// lang: keyof typeof bundledLanguages,
|
||||||
) {
|
// ) {
|
||||||
await loadLanguagesMutex.runBlocking(async () => {
|
// await loadLanguagesMutex.runBlocking(async () => {
|
||||||
if (highlighter.getLoadedLanguages().includes(lang)) {
|
// if (highlighter.getLoadedLanguages().includes(lang)) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
await trace(
|
// await trace(
|
||||||
`highlighting.loadLanguage(${lang})`,
|
// `highlighting.loadLanguage(${lang})`,
|
||||||
async () => await highlighter.loadLanguage(lang),
|
// async () => await highlighter.loadLanguage(lang),
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ import { useTrackEvent } from './InsightsProvider';
|
|||||||
*/
|
*/
|
||||||
export function TrackPageViewEvent(props: { pageId: string | null; revisionId: string }) {
|
export function TrackPageViewEvent(props: { pageId: string | null; revisionId: string }) {
|
||||||
const { pageId, revisionId } = props;
|
const { pageId, revisionId } = props;
|
||||||
const trackEvent = useTrackEvent();
|
//const trackEvent = useTrackEvent();
|
||||||
|
|
||||||
React.useEffect(() => {
|
// React.useEffect(() => {
|
||||||
trackEvent(
|
// trackEvent(
|
||||||
{
|
// {
|
||||||
type: 'page_view',
|
// type: 'page_view',
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
pageId,
|
// pageId,
|
||||||
revisionId,
|
// revisionId,
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}, [pageId, revisionId, trackEvent]);
|
// }, [pageId, revisionId, trackEvent]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export function PageFeedbackForm(props: {
|
|||||||
}) {
|
}) {
|
||||||
const { orientation = 'vertical', pageId, className } = props;
|
const { orientation = 'vertical', pageId, className } = props;
|
||||||
const languages = useLanguage();
|
const languages = useLanguage();
|
||||||
const trackEvent = useTrackEvent();
|
// const trackEvent = useTrackEvent();
|
||||||
const [submitted, setSubmitted] = React.useState(false);
|
const [submitted, setSubmitted] = React.useState(false);
|
||||||
|
|
||||||
const onSubmit = async (rating: PageFeedbackRating) => {
|
const onSubmit = async (rating: PageFeedbackRating) => {
|
||||||
@@ -28,12 +28,12 @@ export function PageFeedbackForm(props: {
|
|||||||
const visitorId = await getVisitorId();
|
const visitorId = await getVisitorId();
|
||||||
await postPageFeedback({ pageId, visitorId, rating });
|
await postPageFeedback({ pageId, visitorId, rating });
|
||||||
|
|
||||||
trackEvent({
|
// trackEvent({
|
||||||
type: 'page_post_feedback',
|
// type: 'page_post_feedback',
|
||||||
feedback: {
|
// feedback: {
|
||||||
rating,
|
// rating,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export function SearchAskAnswer(props: { pointer: SiteContentPointer; query: str
|
|||||||
const { pointer, query } = props;
|
const { pointer, query } = props;
|
||||||
|
|
||||||
const language = useLanguage();
|
const language = useLanguage();
|
||||||
const trackEvent = useTrackEvent();
|
// const trackEvent = useTrackEvent();
|
||||||
const [, setSearchState] = useSearch();
|
const [, setSearchState] = useSearch();
|
||||||
const [state, setState] = useRecoilState(searchAskState);
|
const [state, setState] = useRecoilState(searchAskState);
|
||||||
const { organizationId, siteId, siteSpaceId } = pointer;
|
const { organizationId, siteId, siteSpaceId } = pointer;
|
||||||
@@ -56,10 +56,10 @@ export function SearchAskAnswer(props: { pointer: SiteContentPointer; query: str
|
|||||||
setState({ type: 'loading' });
|
setState({ type: 'loading' });
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
trackEvent({
|
// trackEvent({
|
||||||
type: 'ask_question',
|
// type: 'ask_question',
|
||||||
query,
|
// query,
|
||||||
});
|
// });
|
||||||
|
|
||||||
const response = streamAskQuestion(organizationId, siteId, siteSpaceId ?? null, query);
|
const response = streamAskQuestion(organizationId, siteId, siteSpaceId ?? null, query);
|
||||||
const stream = iterateStreamResponse(response);
|
const stream = iterateStreamResponse(response);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function SearchButton(props: { children?: React.ReactNode; style?: ClassV
|
|||||||
|
|
||||||
const language = useLanguage();
|
const language = useLanguage();
|
||||||
const [, setSearchState] = useSearch();
|
const [, setSearchState] = useSearch();
|
||||||
const trackEvent = useTrackEvent();
|
// const trackEvent = useTrackEvent();
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
setSearchState({
|
setSearchState({
|
||||||
@@ -27,9 +27,9 @@ export function SearchButton(props: { children?: React.ReactNode; style?: ClassV
|
|||||||
query: '',
|
query: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
trackEvent({
|
// trackEvent({
|
||||||
type: 'search_open',
|
// type: 'search_open',
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
|||||||
const { children, query, pointer, spaceId, revisionId, global, withAsk, onSwitchToAsk } = props;
|
const { children, query, pointer, spaceId, revisionId, global, withAsk, onSwitchToAsk } = props;
|
||||||
|
|
||||||
const language = useLanguage();
|
const language = useLanguage();
|
||||||
const trackEvent = useTrackEvent();
|
// const trackEvent = useTrackEvent();
|
||||||
const debounceTimeout = React.useRef<Timer | null>(null);
|
const debounceTimeout = React.useRef<Timer | null>(null);
|
||||||
const [results, setResults] = React.useState<ResultType[] | null>(null);
|
const [results, setResults] = React.useState<ResultType[] | null>(null);
|
||||||
const [cursor, setCursor] = React.useState<number | null>(null);
|
const [cursor, setCursor] = React.useState<number | null>(null);
|
||||||
@@ -99,10 +99,10 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
|||||||
|
|
||||||
setResults(withAsk ? withQuestionResult(fetchedResults, query) : fetchedResults);
|
setResults(withAsk ? withQuestionResult(fetchedResults, query) : fetchedResults);
|
||||||
|
|
||||||
trackEvent({
|
// trackEvent({
|
||||||
type: 'search_type_query',
|
// type: 'search_type_query',
|
||||||
query,
|
// query,
|
||||||
});
|
// });
|
||||||
}, 350);
|
}, 350);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { CustomizationThemedURL } from '@gitbook/api';
|
import { CustomizationThemedURL } from '@gitbook/api';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import { Image } from '@/components/utils';
|
import { Image } from '@/components/utils';
|
||||||
import { absoluteHref } from '@/lib/links';
|
import { absoluteHref } from '@/lib/links';
|
||||||
@@ -47,6 +48,7 @@ export function SpaceIcon(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{...imageProps}
|
{...imageProps}
|
||||||
|
sizes={[]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Icon } from '@gitbook/icons';
|
import { Icon } from '@gitbook/icons';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import { ClassValue, tcls } from '@/lib/tailwind';
|
import { ClassValue, tcls } from '@/lib/tailwind';
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const Link = React.forwardRef(function Link(
|
|||||||
ref: React.Ref<HTMLAnchorElement>,
|
ref: React.Ref<HTMLAnchorElement>,
|
||||||
) {
|
) {
|
||||||
const { href, prefetch, children, insights, ...domProps } = props;
|
const { href, prefetch, children, insights, ...domProps } = props;
|
||||||
const trackEvent = useTrackEvent();
|
// const trackEvent = useTrackEvent();
|
||||||
|
|
||||||
// Use a real anchor tag for external links,s and a Next.js Link for internal links.
|
// Use a real anchor tag for external links,s and a Next.js Link for internal links.
|
||||||
// If we use a NextLink for external links, Nextjs won't rerender the top-level layouts.
|
// If we use a NextLink for external links, Nextjs won't rerender the top-level layouts.
|
||||||
@@ -40,9 +40,9 @@ export const Link = React.forwardRef(function Link(
|
|||||||
|
|
||||||
const onClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
const onClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||||
if (insights) {
|
if (insights) {
|
||||||
trackEvent({ type: 'link_click', link: insights }, undefined, {
|
// trackEvent({ type: 'link_click', link: insights }, undefined, {
|
||||||
immediate: isExternal,
|
// immediate: isExternal,
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
domProps.onClick?.(event);
|
domProps.onClick?.(event);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable @next/next/no-img-element */
|
/* eslint-disable @next/next/no-img-element */
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import { checkIsHttpURL, getImageSize, getResizedImageURLFactory } from '@/lib/images';
|
import { checkIsHttpURL, getImageSize, getResizedImageURLFactory } from '@/lib/images';
|
||||||
import { ClassValue, tcls } from '@/lib/tailwind';
|
import { ClassValue, tcls } from '@/lib/tailwind';
|
||||||
@@ -228,7 +229,6 @@ function ImagePictureSized(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const imgProps: ImgDOMPropsWithSrc = {
|
const imgProps: ImgDOMPropsWithSrc = {
|
||||||
alt,
|
|
||||||
style,
|
style,
|
||||||
loading,
|
loading,
|
||||||
fetchPriority,
|
fetchPriority,
|
||||||
@@ -236,7 +236,7 @@ function ImagePictureSized(
|
|||||||
...attrs,
|
...attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
return zoom ? <ZoomImage {...imgProps} /> : <img {...imgProps} alt={imgProps.alt ?? ''} />;
|
return zoom ? <ZoomImage {...imgProps} /> : <img {...imgProps} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
html:has(.zoomModal) {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zoomImg {
|
|
||||||
cursor: zoom-in;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zoomImageActive {
|
|
||||||
view-transition-name: zoom-image;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zoomModal {
|
|
||||||
}
|
|
||||||
|
|
||||||
.zoomModal img {
|
|
||||||
view-transition-name: zoom-image;
|
|
||||||
cursor: zoom-out;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'server-only';
|
// import 'server-only';
|
||||||
import { AsyncLocalStorage } from 'node:async_hooks';
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ export function cache<Args extends any[], Result>(
|
|||||||
cacheDef: CacheDefinition<Args, Result>,
|
cacheDef: CacheDefinition<Args, Result>,
|
||||||
): CacheFunction<Args, Result> {
|
): CacheFunction<Args, Result> {
|
||||||
// We stop everything after 10s to avoid pending requests
|
// We stop everything after 10s to avoid pending requests
|
||||||
const timeout = cacheDef.timeout ?? 1000 * 10;
|
const timeout = 1000 * 1000000;
|
||||||
const defaultTtl = cacheDef.defaultTtl ?? 60 * 60 * 24;
|
const defaultTtl = cacheDef.defaultTtl ?? 60 * 60 * 24;
|
||||||
|
|
||||||
const revalidate = singletonMap(
|
const revalidate = singletonMap(
|
||||||
|
|||||||
+17
-16
@@ -78,24 +78,25 @@ export const cloudflareDOCache: CacheBackend = {
|
|||||||
const globalStubs = new WeakMap<object, Map<string, CacheObjectStub>>();
|
const globalStubs = new WeakMap<object, Map<string, CacheObjectStub>>();
|
||||||
|
|
||||||
async function getStub(tag: string): Promise<CacheObjectStub | null> {
|
async function getStub(tag: string): Promise<CacheObjectStub | null> {
|
||||||
if (process.env.NODE_ENV === 'test') {
|
return null;
|
||||||
return null;
|
// if (process.env.NODE_ENV === 'test') {
|
||||||
}
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
// We lazy-load the next-on-pages package to avoid errors when running tests because of 'server-only'.
|
// // We lazy-load the next-on-pages package to avoid errors when running tests because of 'server-only'.
|
||||||
const { getOptionalRequestContext } = await import('@cloudflare/next-on-pages');
|
// const { getOptionalRequestContext } = await import('@cloudflare/next-on-pages');
|
||||||
const cloudflare = getOptionalRequestContext();
|
// const cloudflare = getOptionalRequestContext();
|
||||||
if (!cloudflare || !cloudflare.env.CACHE) {
|
// if (!cloudflare || !cloudflare.env.CACHE) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const requestStubs = globalStubs.get(cloudflare.cf) ?? new Map();
|
// const requestStubs = globalStubs.get(cloudflare.cf) ?? new Map();
|
||||||
globalStubs.set(cloudflare.cf, requestStubs);
|
// globalStubs.set(cloudflare.cf, requestStubs);
|
||||||
|
|
||||||
const locationId: CacheLocationId = cloudflare.cf.continent ?? 'NA';
|
// const locationId: CacheLocationId = cloudflare.cf.continent ?? 'NA';
|
||||||
const stub =
|
// const stub =
|
||||||
requestStubs.get(tag) ?? new CacheObjectStub(cloudflare.env.CACHE, locationId, tag);
|
// requestStubs.get(tag) ?? new CacheObjectStub(cloudflare.env.CACHE, locationId, tag);
|
||||||
requestStubs.set(tag, stub);
|
// requestStubs.set(tag, stub);
|
||||||
|
|
||||||
return stub;
|
// return stub;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'server-only';
|
//import 'server-only';
|
||||||
|
|
||||||
import fnv1a from '@sindresorhus/fnv1a';
|
// import fnv1a from '@sindresorhus/fnv1a';
|
||||||
|
|
||||||
import { noCacheFetchOptions } from '@/lib/cache/http';
|
import { noCacheFetchOptions } from '@/lib/cache/http';
|
||||||
|
|
||||||
@@ -250,5 +250,6 @@ function generateSignature(input: string) {
|
|||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(':');
|
.join(':');
|
||||||
return fnv1a(all, { utf8Buffer: fnv1aUtf8Buffer }).toString(16);
|
return 'aaaa';
|
||||||
|
//return fnv1a(all, { utf8Buffer: fnv1aUtf8Buffer }).toString(16);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'server-only';
|
// import 'server-only';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
RevisionPage,
|
RevisionPage,
|
||||||
|
|||||||
@@ -1,30 +1,54 @@
|
|||||||
{
|
{
|
||||||
|
"ts-node": {
|
||||||
|
// these options are overrides used only by ts-node
|
||||||
|
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"module": "commonjs"
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
}
|
||||||
"allowJs": true,
|
},
|
||||||
"skipLibCheck": true,
|
"compilerOptions": {
|
||||||
"strict": true,
|
"target": "esnext",
|
||||||
"noEmit": true,
|
"lib": [
|
||||||
"esModuleInterop": true,
|
"dom",
|
||||||
"module": "esnext",
|
"dom.iterable",
|
||||||
"moduleResolution": "bundler",
|
"esnext"
|
||||||
"resolveJsonModule": true,
|
],
|
||||||
"isolatedModules": true,
|
"allowJs": true,
|
||||||
"jsx": "preserve",
|
"skipLibCheck": true,
|
||||||
"incremental": true,
|
"strict": true,
|
||||||
"plugins": [
|
"noEmit": true,
|
||||||
{
|
"esModuleInterop": true,
|
||||||
"name": "next"
|
"module": "esnext",
|
||||||
}
|
"moduleResolution": "bundler",
|
||||||
],
|
"resolveJsonModule": true,
|
||||||
"paths": {
|
"isolatedModules": true,
|
||||||
"@/*": ["./src/*"]
|
"jsx": "react",
|
||||||
},
|
"incremental": true,
|
||||||
"types": [
|
"plugins": [
|
||||||
"bun-types" // add Bun global
|
{
|
||||||
]
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "cf-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"types": [
|
||||||
"exclude": ["node_modules", "packages/react-openapi", "packages/react-math"]
|
"bun-types" // add Bun global
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"cf-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
"src/app/(space)/~gitbook/pdf/script.tss"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"packages/react-openapi",
|
||||||
|
"packages/react-math"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitbook/icons",
|
"name": "@gitbook/icons",
|
||||||
"type": "module",
|
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user