14 |
Social platform
' 17 | ); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/icons/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["es2023"], 4 | "module": "ESNext", 5 | "target": "es2022", 6 | "strict": true, 7 | "noUncheckedIndexedAccess": true, 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "moduleResolution": "bundler", 11 | "allowJs": true, 12 | "noEmit": false, 13 | "declaration": true, 14 | "outDir": "dist", 15 | "resolveJsonModule": true, 16 | "isolatedModules": true, 17 | "jsx": "react-jsx", 18 | "incremental": true, 19 | "types": [ 20 | "bun-types" // add Bun global 21 | ] 22 | }, 23 | "include": ["src/**/*.ts", "src/**/*.tsx"], 24 | "exclude": ["node_modules"] 25 | } 26 | -------------------------------------------------------------------------------- /packages/gitbook/src/components/hooks/useNow.ts: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import React from 'react'; 4 | 5 | /** 6 | * Hook that returns the current time and updates it at the specified interval. 7 | * @param refreshInterval - The interval in milliseconds to refresh the time (default: 30 minutes) 8 | * @returns The current timestamp in milliseconds 9 | */ 10 | export function useNow(refreshInterval: number = 30 * 60 * 1000): number { 11 | const [now, setNow] = React.useState
26 | {props.code}
27 |
28 | );
29 | }
30 |
--------------------------------------------------------------------------------
/packages/gitbook/src/components/hooks/useCurrentPageMetadata.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 | import type { PageMetaLinks } from '../SitePage';
3 |
4 | import * as zustand from 'zustand';
5 |
6 | /**
7 | * A store for the current page metadata.
8 | *
9 | * We use a global store because the metadata is generated and set by the Page component
10 | * but needs to be accessed by other components (ex - Layout) that are not its descendants.
11 | */
12 | export const currentPageMetadataStore = zustand.create<{
13 | metaLinks: PageMetaLinks | null;
14 | }>(() => ({
15 | metaLinks: null,
16 | }));
17 |
18 | /**
19 | * Return the metadata for the current page.
20 | */
21 | export function useCurrentPageMetadata() {
22 | const metaLinks = zustand.useStore(currentPageMetadataStore, (state) => state.metaLinks);
23 | return {
24 | metaLinks,
25 | };
26 | }
27 |
--------------------------------------------------------------------------------
/packages/gitbook/src/components/Adaptive/utils.ts:
--------------------------------------------------------------------------------
1 | import type { Variables } from '@gitbook/api';
2 | import type { AdaptiveVisitorClaims } from './types';
3 |
4 | /**
5 | * Return an evaluation context to evaluate expressions.
6 | */
7 | export function createExpressionEvaluationContext(args: {
8 | visitorClaims: AdaptiveVisitorClaims | null;
9 | variables: {
10 | space?: Variables;
11 | page?: Variables;
12 | };
13 | }) {
14 | const { visitorClaims, variables } = args;
15 | return {
16 | ...(visitorClaims ? visitorClaims : {}),
17 | space: {
18 | vars: variables.space ?? {},
19 | },
20 | ...(variables.page
21 | ? {
22 | page: {
23 | vars: variables.page ?? {},
24 | },
25 | }
26 | : {}),
27 | };
28 | }
29 |
--------------------------------------------------------------------------------
/packages/gitbook/src/lib/adaptive.ts:
--------------------------------------------------------------------------------
1 | import type { SiteURLData } from '@/lib/context';
2 | import type { SiteAPIToken } from '@gitbook/api';
3 | import { jwtDecode } from 'jwt-decode';
4 |
5 | /**
6 | * Claims about the visitor, stored in the VA and auth token.
7 | */
8 | export type VisitorAuthClaims = Record