zreader 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +237 -4
- package/dist/agent/index.d.ts +90 -0
- package/dist/agent/index.js +293 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/react/index.d.ts +65 -0
- package/dist/agent/react/index.js +286 -0
- package/dist/agent/react/index.js.map +1 -0
- package/dist/next/index.cjs +3 -0
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +3 -0
- package/dist/next/index.js.map +1 -1
- package/dist/next/server/index.d.ts +26 -3
- package/dist/next/server/index.js +10 -3
- package/dist/next/server/index.js.map +1 -1
- package/dist/react/index.d.ts +22 -6
- package/dist/react/index.js +8 -3
- package/dist/react/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -0
- package/package.json +14 -2
package/dist/next/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/defaults.ts","../../src/core/types.ts","../../src/config/index.ts","../../src/config/load.ts","../../src/next/index.ts"],"names":["join","resolve"],"mappings":";;;;;;;AAEO,IAAM,sBAAA,GAA8C;AAAA,EACzD,aAAA,EAAe,IAAA;AAAA,EACf,eAAA,EAAiB,CAAC,QAAA,EAAU,OAAA,EAAS,QAAQ,MAAM,CAAA;AAAA,EACnD,qBAAA,EAAuB,QAAA;AAAA,EACvB,UAAA,EAAY,EAAE,OAAA,EAAS,IAAA,EAAM,QAAQ,CAAC,SAAA,EAAW,MAAA,EAAQ,QAAQ,CAAA,EAAE;AAAA,EACnE,MAAA,EAAQ,CAAC,QAAA,EAAU,OAAA,EAAS,SAAS,MAAM,CAAA;AAAA,EAC3C,YAAA,EAAc,QAAA;AAAA,EACd,eAAA,EAAiB;AAAA,IACf,QAAA,EAAU,IAAA;AAAA,IACV,OAAA,EAAS,SAAA;AAAA,IACT,OAAA,EAAS,QAAA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BD,IAAAA,CAAK,IAAA,EAAM,OAAA,EAAS,SAAS,SAAS,CAAA;AACxE,IAAA,MAAM,IAAA,GAAO,OAAO,UAAA,KAAe,UAAA,GAAa,MAAM,UAAA,CAAW,KAAA,EAAO,GAAG,CAAA,GAAI,UAAA;AAC/E,IAAA,MAAM,QAAQ,MAAM,WAAA,CAAY,EAAE,GAAG,OAAA,EAAS,MAAM,CAAA;AACpD,IAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,MAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,kBAAA,EAAqB,KAAA,CAAM,UAAA,IAAc,YAAY,CAAA,CAAE,CAAA;AAAA,IACrE;AACA,IAAA,OAAO,iBAAA,CAAkB,IAAA,EAAM,KAAA,EAAO,IAAI,CAAA;AAAA,EAC5C,CAAA;AACF","file":"index.js","sourcesContent":["import type { ReaderClientOptions } from \"./types\";\n\nexport const DEFAULT_CLIENT_OPTIONS: ReaderClientOptions = {\n storagePrefix: \"zr\",\n highlightColors: [\"yellow\", \"green\", \"blue\", \"pink\"],\n defaultHighlightColor: \"yellow\",\n scratchpad: { enabled: true, scopes: [\"chapter\", \"book\", \"global\"] },\n themes: [\"system\", \"light\", \"sepia\", \"dark\"],\n defaultTheme: \"system\",\n defaultSettings: {\n textSize: \"lg\",\n leading: \"relaxed\",\n measure: \"normal\",\n fontFamily: \"serif\",\n highlightMode: false,\n },\n progress: { completeAt: 0.9, saveIntervalMs: 1000 },\n backupReminder: true,\n basePath: \"/books\",\n};\n","/** Shared, framework-agnostic data model for zreader. */\n\nexport type ISODate = string;\n\n/** W3C Web Annotation-style anchor. Offsets are measured over the chapter root's text. */\nexport interface Anchor {\n /** `data-block-id` of the block containing the start of the selection. */\n blockId: string;\n /** Offsets relative to the start block's text (fast path). */\n blockStart: number;\n /** TextPositionSelector over the whole chapter text. */\n start: number;\n end: number;\n /** TextQuoteSelector. */\n exact: string;\n prefix: string;\n suffix: string;\n /** Content hash of the chapter when the anchor was created. */\n contentHash?: string;\n}\n\nexport interface Highlight {\n id: string;\n bookId: string;\n chapterId: string;\n anchor: Anchor;\n color: string;\n note?: string;\n createdAt: ISODate;\n updatedAt: ISODate;\n}\n\nexport interface Bookmark {\n id: string;\n bookId: string;\n chapterId: string;\n /** Absent for whole-chapter bookmarks. */\n blockId?: string;\n label?: string;\n excerpt?: string;\n createdAt: ISODate;\n updatedAt: ISODate;\n}\n\nexport interface ChapterProgress {\n chapterId: string;\n blockId?: string;\n /** 0..1 */\n percent: number;\n completed: boolean;\n updatedAt: ISODate;\n}\n\nexport interface BookProgress {\n bookId: string;\n chapters: Record<string, ChapterProgress>;\n last?: { chapterId: string; blockId?: string; updatedAt: ISODate };\n}\n\nexport type PadScope =\n | { kind: \"global\" }\n | { kind: \"book\"; bookId: string }\n | { kind: \"chapter\"; bookId: string; chapterId: string };\n\nexport type PadScopeKind = PadScope[\"kind\"];\n\nexport interface Pad {\n /** Markdown is the interchange/source format. */\n markdown: string;\n /** Lossless editor JSON cache. Cleared whenever `markdown` is changed outside the editor. */\n json?: unknown;\n updatedAt: ISODate;\n}\n\nexport type ThemeName = \"system\" | \"light\" | \"sepia\" | \"dark\";\nexport type Measure = \"narrow\" | \"normal\" | \"wide\";\nexport type FontFamily = \"serif\" | \"sans\" | \"mono\";\nexport type TextSize = \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\";\nexport type Leading = \"tight\" | \"normal\" | \"relaxed\";\n\nexport const THEMES = [\"system\", \"light\", \"sepia\", \"dark\"] as const satisfies readonly ThemeName[];\nexport const TEXT_SIZES = [\"sm\", \"base\", \"lg\", \"xl\", \"2xl\"] as const satisfies readonly TextSize[];\nexport const LEADINGS = [\"tight\", \"normal\", \"relaxed\"] as const satisfies readonly Leading[];\nexport const MEASURES = [\"narrow\", \"normal\", \"wide\"] as const satisfies readonly Measure[];\nexport const FONT_FAMILIES = [\"serif\", \"sans\", \"mono\"] as const satisfies readonly FontFamily[];\n/** The palette the UI ships styles for (`::highlight(zr-<color>)`). */\nexport const HIGHLIGHT_COLORS = [\"yellow\", \"green\", \"blue\", \"pink\", \"purple\", \"orange\"] as const;\nexport type HighlightColor = (typeof HIGHLIGHT_COLORS)[number];\n\nexport interface ReaderSettings {\n textSize: TextSize;\n leading: Leading;\n measure: Measure;\n fontFamily: FontFamily;\n /** Tap a sentence to highlight it with the default colour. */\n highlightMode: boolean;\n updatedAt: ISODate;\n}\n\n/** Serializable client options (the `reader` half of reader.config.ts). */\nexport interface ReaderClientOptions {\n storagePrefix: string;\n highlightColors: HighlightColor[];\n defaultHighlightColor: HighlightColor;\n scratchpad: { enabled: boolean; scopes: PadScopeKind[] };\n /** Themes offered in the UI. Applied as a class on <html> via next-themes. */\n themes: ThemeName[];\n defaultTheme: ThemeName;\n defaultSettings: Omit<ReaderSettings, \"updatedAt\">;\n progress: { completeAt: number; saveIntervalMs: number };\n /** Show a \"your notes only live in this browser\" reminder. */\n backupReminder: boolean;\n /** Base path used to build links back into the reader (e.g. quote-to-pad). */\n basePath: string;\n}\n\nexport interface TocEntry {\n id: string;\n depth: number;\n text: string;\n}\n\nexport interface ChapterMeta {\n id: string;\n title: string;\n order: number;\n description?: string;\n /** Section the chapter belongs to, e.g. \"Part I · For the Builders\". Groups the contents list. */\n part?: string;\n /** Eyebrow shown above the title, e.g. \"Chapter 5\" or \"Appendix A\". */\n label?: string;\n /** Short marker for lists, e.g. \"5\" or \"A\". */\n number?: string;\n}\n\nexport interface BookMeta {\n id: string;\n title: string;\n subtitle?: string;\n authors: string[];\n description?: string;\n cover?: string;\n chapters: ChapterMeta[];\n}\n","import { z } from \"zod/v4\";\nimport { DEFAULT_CLIENT_OPTIONS } from \"../core/defaults\";\nimport {\n FONT_FAMILIES,\n HIGHLIGHT_COLORS,\n LEADINGS,\n MEASURES,\n TEXT_SIZES,\n THEMES,\n type ReaderClientOptions,\n} from \"../core/types\";\n\nexport { z };\n\n// ---------------------------------------------------------------- types\n\nexport interface GlobLoader {\n kind: \"glob\";\n /** Directory containing one folder per book. Relative to the project root. */\n base: string;\n /** Chapter files, relative to `base`. */\n pattern: string | string[];\n ignore?: string[];\n}\n\n/** Astro-style glob loader: `content/books/<book>/{book.json, 01-intro.md, ...}` */\nexport function glob(opts: { base: string; pattern?: string | string[]; ignore?: string[] }): GlobLoader {\n return { kind: \"glob\", base: opts.base, pattern: opts.pattern ?? \"**/*.{md,mdx,html}\", ignore: opts.ignore };\n}\n\n// unified's PluggableList, kept loose to avoid a type dependency in this entry.\nexport type PluginList = unknown[];\n\nexport interface SanitizeOptions {\n /** Hostnames allowed for <iframe src>. Iframes are stripped unless listed here. */\n allowIframes?: string[];\n /** Extra tags to allow on top of DOMPurify's safe HTML profile. */\n allowTags?: string[];\n /** Extra attributes to allow. */\n allowAttributes?: string[];\n}\n\nexport interface ContentConfig {\n loader: GlobLoader;\n schemas: { book: z.ZodType; chapter: z.ZodType };\n /** Applied to `.md` and `.mdx`. */\n remarkPlugins: PluginList;\n rehypePlugins: PluginList;\n sanitize: SanitizeOptions;\n /** Include chapters with `draft: true`. Defaults to `true` in development. */\n includeDrafts: boolean;\n /** Where compiled chapters are cached. */\n cacheDir: string;\n}\n\ntype DeepPartial<T> = T extends unknown[] ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;\n\nexport interface ReaderUserConfig {\n content?: DeepPartial<Omit<ContentConfig, \"schemas\" | \"loader\">> & {\n loader?: GlobLoader;\n schemas?: Partial<ContentConfig[\"schemas\"]>;\n };\n reader?: DeepPartial<ReaderClientOptions>;\n}\n\nexport interface ResolvedReaderConfig {\n root: string;\n content: ContentConfig;\n reader: ReaderClientOptions;\n}\n\n// ------------------------------------------------------------- defaults\n\nexport const defaultBookSchema = z.looseObject({\n title: z.string(),\n subtitle: z.string().optional(),\n authors: z.array(z.string()).default([]),\n description: z.string().optional(),\n cover: z.string().optional(),\n /** Optional explicit chapter order (chapter slugs). */\n chapters: z.array(z.string()).optional(),\n});\n\nexport const defaultChapterSchema = z.looseObject({\n title: z.string(),\n order: z.number().optional(),\n description: z.string().optional(),\n part: z.string().optional(),\n label: z.string().optional(),\n number: z.union([z.string(), z.number()]).transform(String).optional(),\n draft: z.boolean().default(false),\n});\n\nfunction isDev() {\n return typeof process !== \"undefined\" && process.env?.NODE_ENV === \"development\";\n}\n\nexport function defaultContentConfig(): ContentConfig {\n return {\n loader: glob({ base: \"./content/books\" }),\n schemas: { book: defaultBookSchema, chapter: defaultChapterSchema },\n remarkPlugins: [],\n rehypePlugins: [],\n sanitize: {},\n includeDrafts: isDev(),\n cacheDir:\n (typeof process !== \"undefined\" && process.env?.ZREADER_CACHE_DIR) || \"node_modules/.cache/zreader\",\n };\n}\n\n// ------------------------------------------------------------ define/merge\n\n/** Identity helper that gives `reader.config.ts` full type-checking. */\nexport function defineConfig(config: ReaderUserConfig): ReaderUserConfig {\n return config;\n}\n\nfunction isPlainObject(x: unknown): x is Record<string, unknown> {\n if (typeof x !== \"object\" || x === null || Array.isArray(x)) return false;\n const proto = Object.getPrototypeOf(x);\n return proto === Object.prototype || proto === null;\n}\n\n/**\n * Deep merge: plain objects merge key-by-key, arrays and class instances\n * (e.g. zod schemas) replace, `undefined` never overrides.\n */\nexport function mergeConfig<T>(base: T, ...overrides: unknown[]): T {\n let out: unknown = base;\n for (const o of overrides) out = mergeTwo(out, o);\n return out as T;\n}\n\nfunction mergeTwo(a: unknown, b: unknown): unknown {\n if (b === undefined) return a;\n if (isPlainObject(a) && isPlainObject(b)) {\n const out: Record<string, unknown> = { ...a };\n for (const [k, v] of Object.entries(b)) out[k] = mergeTwo(a[k], v);\n return out;\n }\n return b;\n}\n\n// --------------------------------------------------------------- validate\n\nconst themeName = z.enum(THEMES);\nconst highlightColor = z.enum(HIGHLIGHT_COLORS);\nconst clientSchema = z\n .object({\n storagePrefix: z.string().regex(/^[a-z0-9_-]+$/i, \"use letters, digits, '-' or '_'\"),\n highlightColors: z.array(highlightColor).min(1, \"must be non-empty\"),\n defaultHighlightColor: highlightColor,\n scratchpad: z.object({\n enabled: z.boolean(),\n scopes: z.array(z.enum([\"global\", \"book\", \"chapter\"])).min(1, \"must be non-empty\"),\n }),\n themes: z.array(themeName).min(1),\n defaultTheme: themeName,\n defaultSettings: z.object({\n textSize: z.enum(TEXT_SIZES),\n leading: z.enum(LEADINGS),\n measure: z.enum(MEASURES),\n fontFamily: z.enum(FONT_FAMILIES),\n highlightMode: z.boolean(),\n }),\n progress: z.object({ completeAt: z.number().gt(0).max(1), saveIntervalMs: z.number().min(100) }),\n backupReminder: z.boolean(),\n basePath: z.string().startsWith(\"/\"),\n })\n .refine((c) => c.highlightColors.includes(c.defaultHighlightColor), {\n message: \"defaultHighlightColor must be one of highlightColors\",\n path: [\"defaultHighlightColor\"],\n })\n .refine((c) => c.themes.includes(c.defaultTheme), {\n message: \"defaultTheme must be one of themes\",\n path: [\"defaultTheme\"],\n });\n\nfunction isSchemaLike(v: unknown): boolean {\n return typeof v === \"object\" && v !== null && typeof (v as { safeParse?: unknown }).safeParse === \"function\";\n}\n\nconst contentSchema = z.object({\n loader: z.object({\n kind: z.literal(\"glob\"),\n base: z.string().min(1),\n pattern: z.union([z.string(), z.array(z.string()).min(1)]),\n ignore: z.array(z.string()).optional(),\n }),\n schemas: z.object({\n book: z.custom<z.ZodType>(isSchemaLike, \"must be a zod (or safeParse-compatible) schema\"),\n chapter: z.custom<z.ZodType>(isSchemaLike, \"must be a zod (or safeParse-compatible) schema\"),\n }),\n remarkPlugins: z.array(z.any()),\n rehypePlugins: z.array(z.any()),\n sanitize: z.object({\n allowIframes: z.array(z.string()).optional(),\n allowTags: z.array(z.string()).optional(),\n allowAttributes: z.array(z.string()).optional(),\n }),\n includeDrafts: z.boolean(),\n cacheDir: z.string(),\n});\n\nexport class ReaderConfigError extends Error {\n constructor(\n message: string,\n public readonly issues: { path: string; message: string }[] = [],\n ) {\n super(message);\n this.name = \"ReaderConfigError\";\n }\n}\n\nfunction formatIssues(source: string, section: string, error: z.ZodError) {\n const issues = error.issues.map((i) => ({ path: [section, ...i.path.map(String)].join(\".\"), message: i.message }));\n return new ReaderConfigError(\n `Invalid reader config${source ? ` (${source})` : \"\"}:\\n` + issues.map((i) => ` - ${i.path}: ${i.message}`).join(\"\\n\"),\n issues,\n );\n}\n\n/**\n * Resolve the final config: package defaults ← reader.config.ts ← inline overrides.\n * Throws `ReaderConfigError` with readable messages.\n */\nexport function resolveConfig(\n user?: ReaderUserConfig | null,\n inline?: ReaderUserConfig | null,\n opts: { root?: string; source?: string } = {},\n): ResolvedReaderConfig {\n const root = opts.root ?? (typeof process !== \"undefined\" && process.cwd ? process.cwd() : \"/\");\n const reader = mergeConfig<ReaderClientOptions>(\n structuredClone(DEFAULT_CLIENT_OPTIONS),\n user?.reader,\n inline?.reader,\n );\n const content = mergeConfig<ContentConfig>(defaultContentConfig(), user?.content, inline?.content);\n\n const r = clientSchema.safeParse(reader);\n if (!r.success) throw formatIssues(opts.source ?? \"\", \"reader\", r.error);\n const c = contentSchema.safeParse(content);\n if (!c.success) throw formatIssues(opts.source ?? \"\", \"content\", c.error);\n\n return { root, content, reader };\n}\n\n/** Only the serializable, client-safe half. */\nexport function clientOptions(config: ResolvedReaderConfig): ReaderClientOptions {\n return config.reader;\n}\n\nexport const CONFIG_FILE_NAMES = [\"reader.config.ts\", \"reader.config.mts\", \"reader.config.mjs\", \"reader.config.js\"];\n","/** Node-only helpers for locating and loading reader.config.* (via jiti). */\nimport { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { CONFIG_FILE_NAMES, type ReaderUserConfig } from \"./index\";\n\n/** Search `from` and its parents (up to the filesystem root or a `.git` dir) for reader.config.*. */\nexport function findConfigFile(from: string = process.cwd()): string | null {\n let dir = resolve(from);\n for (;;) {\n for (const name of CONFIG_FILE_NAMES) {\n const p = join(dir, name);\n if (existsSync(p)) return p;\n }\n if (existsSync(join(dir, \"package.json\")) || existsSync(join(dir, \".git\"))) return null;\n const parent = dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nexport async function loadConfigFile(file: string): Promise<ReaderUserConfig> {\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(file, { interopDefault: true, moduleCache: false });\n const mod = (await jiti.import(file)) as { default?: ReaderUserConfig } | ReaderUserConfig;\n const cfg = (mod && typeof mod === \"object\" && \"default\" in mod ? mod.default : mod) as ReaderUserConfig | undefined;\n return cfg ?? {};\n}\n","/**\n * Next.js integration.\n *\n * // next.config.ts\n * import { withReader } from \"zreader/next\";\n * export default withReader({ reactStrictMode: true });\n */\nimport { join, relative, resolve, sep } from \"node:path\";\nimport type { NextConfig } from \"next\";\nimport { resolveConfig, type ResolvedReaderConfig, type ReaderUserConfig } from \"../config/index\";\nimport { findConfigFile, loadConfigFile } from \"../config/load\";\n\nexport const USER_CONFIG_SPECIFIER = \"zreader/user-config\";\nexport const EMPTY_CONFIG_SPECIFIER = \"zreader/empty-config\";\n\n/** Packages that must stay external on the server (dynamic requires / native-ish). */\nexport const SERVER_EXTERNALS = [\"jsdom\", \"isomorphic-dompurify\"];\n\nexport interface WithReaderOptions {\n /** Path to the config file. Defaults to discovering reader.config.{ts,mts,mjs,js}. */\n configPath?: string;\n /** Project root. Defaults to process.cwd() (the directory containing next.config). */\n root?: string;\n /** Inline overrides merged on top of reader.config.ts. */\n config?: ReaderUserConfig;\n /** Log the resolved config file path at startup. */\n verbose?: boolean;\n}\n\ntype NextConfigFn = (phase: string, ctx: { defaultConfig: NextConfig }) => NextConfig | Promise<NextConfig>;\nexport type NextConfigInput = NextConfig | NextConfigFn;\n\ntype WebpackFn = NonNullable<NextConfig[\"webpack\"]>;\n\nfunction toPosix(p: string) {\n return p.split(sep).join(\"/\");\n}\n\n/** Alias target relative to the project root, as Turbopack expects (`./reader.config.ts`). */\nfunction relativeImport(root: string, file: string) {\n const rel = toPosix(relative(root, file));\n return rel.startsWith(\".\") ? rel : `./${rel}`;\n}\n\nexport interface ReaderNextSetup {\n configFile: string | null;\n resolved: ResolvedReaderConfig;\n}\n\n/** Pure transform (exported for testing): apply reader wiring to a resolved Next config. */\nexport function applyReaderConfig(base: NextConfig, setup: ReaderNextSetup, root: string): NextConfig {\n const { configFile, resolved } = setup;\n const turboTarget = configFile ? relativeImport(root, configFile) : EMPTY_CONFIG_SPECIFIER;\n const webpackTarget = configFile ?? EMPTY_CONFIG_SPECIFIER;\n\n const prevWebpack = base.webpack as WebpackFn | undefined;\n const webpack: WebpackFn = (config, ctx) => {\n const cfg = (prevWebpack ? prevWebpack(config, ctx) : config) as { resolve?: { alias?: Record<string, unknown> } };\n cfg.resolve ??= {};\n const alias = (cfg.resolve.alias ??= {}) as Record<string, unknown>;\n alias[`${USER_CONFIG_SPECIFIER}$`] = webpackTarget;\n return cfg;\n };\n\n const contentGlob = toPosix(join(resolved.content.loader.base, \"**/*\"));\n const tracing = { ...(base.outputFileTracingIncludes ?? {}) };\n const allRoutes = \"/**\";\n tracing[allRoutes] = Array.from(new Set([...(tracing[allRoutes] ?? []), contentGlob]));\n\n const externals = Array.from(new Set([...(base.serverExternalPackages ?? []), ...SERVER_EXTERNALS]));\n\n return {\n ...base,\n serverExternalPackages: externals,\n outputFileTracingIncludes: tracing,\n turbopack: {\n ...base.turbopack,\n resolveAlias: {\n ...base.turbopack?.resolveAlias,\n [USER_CONFIG_SPECIFIER]: turboTarget,\n },\n },\n webpack,\n };\n}\n\nexport async function setupReader(options: WithReaderOptions = {}): Promise<ReaderNextSetup> {\n const root = resolve(options.root ?? process.cwd());\n const configFile = options.configPath ? resolve(root, options.configPath) : findConfigFile(root);\n const user = configFile ? await loadConfigFile(configFile) : {};\n // Validate eagerly so `next dev` / `next build` fail fast with a readable error.\n const resolved = resolveConfig(user, options.config, {\n root,\n source: configFile ? relative(root, configFile) : \"defaults\",\n });\n return { configFile, resolved };\n}\n\n/**\n * Wire zreader into Next.js:\n * - validates reader.config.* at startup;\n * - aliases `zreader/user-config` to it (Turbopack + webpack), so\n * `zreader/virtual-config` is the resolved config everywhere on the server;\n * - keeps jsdom/DOMPurify external on the server;\n * - traces the content directory into the server output (Vercel);\n * - points the compiled-chapter cache at `.next/cache/zreader`.\n */\nexport function withReader(nextConfig: NextConfigInput = {}, options: WithReaderOptions = {}): NextConfigFn {\n return async (phase, ctx) => {\n const root = resolve(options.root ?? process.cwd());\n process.env.ZREADER_CACHE_DIR ??= join(root, \".next\", \"cache\", \"zreader\");\n const base = typeof nextConfig === \"function\" ? await nextConfig(phase, ctx) : nextConfig;\n const setup = await setupReader({ ...options, root });\n if (options.verbose) {\n console.log(`[zreader] config: ${setup.configFile ?? \"(defaults)\"}`);\n }\n return applyReaderConfig(base, setup, root);\n };\n}\n\nexport { resolveConfig, findConfigFile, loadConfigFile };\nexport type { ResolvedReaderConfig, ReaderUserConfig };\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/defaults.ts","../../src/core/types.ts","../../src/config/index.ts","../../src/config/load.ts","../../src/next/index.ts"],"names":["join","resolve"],"mappings":";;;;;;;AAEO,IAAM,sBAAA,GAA8C;AAAA,EACzD,aAAA,EAAe,IAAA;AAAA,EACf,eAAA,EAAiB,CAAC,QAAA,EAAU,OAAA,EAAS,QAAQ,MAAM,CAAA;AAAA,EACnD,qBAAA,EAAuB,QAAA;AAAA,EACvB,UAAA,EAAY,EAAE,OAAA,EAAS,IAAA,EAAM,QAAQ,CAAC,SAAA,EAAW,MAAA,EAAQ,QAAQ,CAAA,EAAE;AAAA,EACnE,MAAA,EAAQ,CAAC,QAAA,EAAU,OAAA,EAAS,SAAS,MAAM,CAAA;AAAA,EAC3C,YAAA,EAAc,QAAA;AAAA,EACd,eAAA,EAAiB;AAAA,IACf,QAAA,EAAU,IAAA;AAAA,IACV,OAAA,EAAS,SAAA;AAAA,IACT,OAAA,EAAS,QAAA;AAAA,IACT,UAAA,EAAY,OAAA;AAAA,IACZ,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,QAAA,EAAU,EAAE,UAAA,EAAY,GAAA,EAAK,gBAAgB,GAAA,EAAK;AAAA,EAClD,cAAA,EAAgB,IAAA;A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IAAQ,OAAA,CAAQ,KAAK,CAAA;AAClD,IAAA,OAAA,CAAQ,IAAI,iBAAA,KAAsBD,IAAAA,CAAK,IAAA,EAAM,OAAA,EAAS,SAAS,SAAS,CAAA;AACxE,IAAA,MAAM,IAAA,GAAO,OAAO,UAAA,KAAe,UAAA,GAAa,MAAM,UAAA,CAAW,KAAA,EAAO,GAAG,CAAA,GAAI,UAAA;AAC/E,IAAA,MAAM,QAAQ,MAAM,WAAA,CAAY,EAAE,GAAG,OAAA,EAAS,MAAM,CAAA;AACpD,IAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,MAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,kBAAA,EAAqB,KAAA,CAAM,UAAA,IAAc,YAAY,CAAA,CAAE,CAAA;AAAA,IACrE;AACA,IAAA,OAAO,iBAAA,CAAkB,IAAA,EAAM,KAAA,EAAO,IAAI,CAAA;AAAA,EAC5C,CAAA;AACF","file":"index.js","sourcesContent":["import type { ReaderClientOptions } from \"./types\";\n\nexport const DEFAULT_CLIENT_OPTIONS: ReaderClientOptions = {\n storagePrefix: \"zr\",\n highlightColors: [\"yellow\", \"green\", \"blue\", \"pink\"],\n defaultHighlightColor: \"yellow\",\n scratchpad: { enabled: true, scopes: [\"chapter\", \"book\", \"global\"] },\n themes: [\"system\", \"light\", \"sepia\", \"dark\"],\n defaultTheme: \"system\",\n defaultSettings: {\n textSize: \"lg\",\n leading: \"relaxed\",\n measure: \"normal\",\n fontFamily: \"serif\",\n highlightMode: false,\n },\n progress: { completeAt: 0.9, saveIntervalMs: 1000 },\n backupReminder: true,\n basePath: \"/books\",\n};\n","/** Shared, framework-agnostic data model for zreader. */\n\nexport type ISODate = string;\n\n/** W3C Web Annotation-style anchor. Offsets are measured over the chapter root's text. */\nexport interface Anchor {\n /** `data-block-id` of the block containing the start of the selection. */\n blockId: string;\n /** Offsets relative to the start block's text (fast path). */\n blockStart: number;\n /** TextPositionSelector over the whole chapter text. */\n start: number;\n end: number;\n /** TextQuoteSelector. */\n exact: string;\n prefix: string;\n suffix: string;\n /** Content hash of the chapter when the anchor was created. */\n contentHash?: string;\n}\n\nexport interface Highlight {\n id: string;\n bookId: string;\n chapterId: string;\n anchor: Anchor;\n color: string;\n note?: string;\n createdAt: ISODate;\n updatedAt: ISODate;\n}\n\nexport interface Bookmark {\n id: string;\n bookId: string;\n chapterId: string;\n /** Absent for whole-chapter bookmarks. */\n blockId?: string;\n label?: string;\n excerpt?: string;\n createdAt: ISODate;\n updatedAt: ISODate;\n}\n\nexport interface ChapterProgress {\n chapterId: string;\n blockId?: string;\n /** 0..1 */\n percent: number;\n completed: boolean;\n updatedAt: ISODate;\n}\n\nexport interface BookProgress {\n bookId: string;\n chapters: Record<string, ChapterProgress>;\n last?: { chapterId: string; blockId?: string; updatedAt: ISODate };\n}\n\nexport type PadScope =\n | { kind: \"global\" }\n | { kind: \"book\"; bookId: string }\n | { kind: \"chapter\"; bookId: string; chapterId: string };\n\nexport type PadScopeKind = PadScope[\"kind\"];\n\nexport interface Pad {\n /** Markdown is the interchange/source format. */\n markdown: string;\n /** Lossless editor JSON cache. Cleared whenever `markdown` is changed outside the editor. */\n json?: unknown;\n updatedAt: ISODate;\n}\n\nexport type ThemeName = \"system\" | \"light\" | \"sepia\" | \"dark\";\nexport type Measure = \"narrow\" | \"normal\" | \"wide\";\nexport type FontFamily = \"serif\" | \"sans\" | \"mono\";\nexport type TextSize = \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\";\nexport type Leading = \"tight\" | \"normal\" | \"relaxed\";\n\nexport const THEMES = [\"system\", \"light\", \"sepia\", \"dark\"] as const satisfies readonly ThemeName[];\nexport const TEXT_SIZES = [\"sm\", \"base\", \"lg\", \"xl\", \"2xl\"] as const satisfies readonly TextSize[];\nexport const LEADINGS = [\"tight\", \"normal\", \"relaxed\"] as const satisfies readonly Leading[];\nexport const MEASURES = [\"narrow\", \"normal\", \"wide\"] as const satisfies readonly Measure[];\nexport const FONT_FAMILIES = [\"serif\", \"sans\", \"mono\"] as const satisfies readonly FontFamily[];\n/** The palette the UI ships styles for (`::highlight(zr-<color>)`). */\nexport const HIGHLIGHT_COLORS = [\"yellow\", \"green\", \"blue\", \"pink\", \"purple\", \"orange\"] as const;\nexport type HighlightColor = (typeof HIGHLIGHT_COLORS)[number];\n\nexport interface ReaderSettings {\n textSize: TextSize;\n leading: Leading;\n measure: Measure;\n fontFamily: FontFamily;\n /** Tap a sentence to highlight it with the default colour. */\n highlightMode: boolean;\n updatedAt: ISODate;\n}\n\n/** Serializable client options (the `reader` half of reader.config.ts). */\nexport interface ReaderClientOptions {\n storagePrefix: string;\n highlightColors: HighlightColor[];\n defaultHighlightColor: HighlightColor;\n scratchpad: { enabled: boolean; scopes: PadScopeKind[] };\n /** Themes offered in the UI. Applied as a class on <html> via next-themes. */\n themes: ThemeName[];\n defaultTheme: ThemeName;\n defaultSettings: Omit<ReaderSettings, \"updatedAt\">;\n progress: { completeAt: number; saveIntervalMs: number };\n /** Show a \"your notes only live in this browser\" reminder. */\n backupReminder: boolean;\n /** Base path used to build links back into the reader (e.g. quote-to-pad). */\n basePath: string;\n}\n\nexport interface TocEntry {\n id: string;\n depth: number;\n text: string;\n}\n\nexport interface ChapterMeta {\n id: string;\n title: string;\n order: number;\n description?: string;\n /** Section the chapter belongs to, e.g. \"Part I · For the Builders\". Groups the contents list. */\n part?: string;\n /** Eyebrow shown above the title, e.g. \"Chapter 5\" or \"Appendix A\". */\n label?: string;\n /** Short marker for lists, e.g. \"5\" or \"A\". */\n number?: string;\n}\n\nexport interface BookMeta {\n id: string;\n title: string;\n subtitle?: string;\n authors: string[];\n description?: string;\n cover?: string;\n chapters: ChapterMeta[];\n}\n","import { z } from \"zod/v4\";\nimport { DEFAULT_CLIENT_OPTIONS } from \"../core/defaults\";\nimport {\n FONT_FAMILIES,\n HIGHLIGHT_COLORS,\n LEADINGS,\n MEASURES,\n TEXT_SIZES,\n THEMES,\n type ReaderClientOptions,\n} from \"../core/types\";\n\nexport { z };\n\n// ---------------------------------------------------------------- types\n\nexport interface GlobLoader {\n kind: \"glob\";\n /** Directory containing one folder per book. Relative to the project root. */\n base: string;\n /** Chapter files, relative to `base`. */\n pattern: string | string[];\n ignore?: string[];\n}\n\n/** Astro-style glob loader: `content/books/<book>/{book.json, 01-intro.md, ...}` */\nexport function glob(opts: { base: string; pattern?: string | string[]; ignore?: string[] }): GlobLoader {\n return { kind: \"glob\", base: opts.base, pattern: opts.pattern ?? \"**/*.{md,mdx,html}\", ignore: opts.ignore };\n}\n\n// unified's PluggableList, kept loose to avoid a type dependency in this entry.\nexport type PluginList = unknown[];\n\nexport interface SanitizeOptions {\n /** Hostnames allowed for <iframe src>. Iframes are stripped unless listed here. */\n allowIframes?: string[];\n /** Extra tags to allow on top of DOMPurify's safe HTML profile. */\n allowTags?: string[];\n /** Extra attributes to allow. */\n allowAttributes?: string[];\n}\n\nexport interface ContentConfig {\n loader: GlobLoader;\n schemas: { book: z.ZodType; chapter: z.ZodType };\n /** Applied to `.md` and `.mdx`. */\n remarkPlugins: PluginList;\n rehypePlugins: PluginList;\n sanitize: SanitizeOptions;\n /** Include chapters with `draft: true`. Defaults to `true` in development. */\n includeDrafts: boolean;\n /** Where compiled chapters are cached. */\n cacheDir: string;\n}\n\ntype DeepPartial<T> = T extends unknown[] ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;\n\nexport interface ReaderUserConfig {\n content?: DeepPartial<Omit<ContentConfig, \"schemas\" | \"loader\">> & {\n loader?: GlobLoader;\n schemas?: Partial<ContentConfig[\"schemas\"]>;\n };\n reader?: DeepPartial<ReaderClientOptions>;\n}\n\nexport interface ResolvedReaderConfig {\n root: string;\n content: ContentConfig;\n reader: ReaderClientOptions;\n}\n\n// ------------------------------------------------------------- defaults\n\nexport const defaultBookSchema = z.looseObject({\n title: z.string(),\n subtitle: z.string().optional(),\n authors: z.array(z.string()).default([]),\n description: z.string().optional(),\n cover: z.string().optional(),\n /** Optional explicit chapter order (chapter slugs). */\n chapters: z.array(z.string()).optional(),\n});\n\nexport const defaultChapterSchema = z.looseObject({\n title: z.string(),\n order: z.number().optional(),\n description: z.string().optional(),\n part: z.string().optional(),\n label: z.string().optional(),\n number: z.union([z.string(), z.number()]).transform(String).optional(),\n draft: z.boolean().default(false),\n});\n\nfunction isDev() {\n return typeof process !== \"undefined\" && process.env?.NODE_ENV === \"development\";\n}\n\nexport function defaultContentConfig(): ContentConfig {\n return {\n loader: glob({ base: \"./content/books\" }),\n schemas: { book: defaultBookSchema, chapter: defaultChapterSchema },\n remarkPlugins: [],\n rehypePlugins: [],\n sanitize: {},\n includeDrafts: isDev(),\n cacheDir:\n (typeof process !== \"undefined\" && process.env?.ZREADER_CACHE_DIR) || \"node_modules/.cache/zreader\",\n };\n}\n\n// ------------------------------------------------------------ define/merge\n\n/** Identity helper that gives `reader.config.ts` full type-checking. */\nexport function defineConfig(config: ReaderUserConfig): ReaderUserConfig {\n return config;\n}\n\nfunction isPlainObject(x: unknown): x is Record<string, unknown> {\n if (typeof x !== \"object\" || x === null || Array.isArray(x)) return false;\n const proto = Object.getPrototypeOf(x);\n return proto === Object.prototype || proto === null;\n}\n\n/**\n * Deep merge: plain objects merge key-by-key, arrays and class instances\n * (e.g. zod schemas) replace, `undefined` never overrides.\n */\nexport function mergeConfig<T>(base: T, ...overrides: unknown[]): T {\n let out: unknown = base;\n for (const o of overrides) out = mergeTwo(out, o);\n return out as T;\n}\n\nfunction mergeTwo(a: unknown, b: unknown): unknown {\n if (b === undefined) return a;\n if (isPlainObject(a) && isPlainObject(b)) {\n const out: Record<string, unknown> = { ...a };\n for (const [k, v] of Object.entries(b)) out[k] = mergeTwo(a[k], v);\n return out;\n }\n return b;\n}\n\n// --------------------------------------------------------------- validate\n\nconst themeName = z.enum(THEMES);\nconst highlightColor = z.enum(HIGHLIGHT_COLORS);\nconst clientSchema = z\n .object({\n storagePrefix: z.string().regex(/^[a-z0-9_-]+$/i, \"use letters, digits, '-' or '_'\"),\n highlightColors: z.array(highlightColor).min(1, \"must be non-empty\"),\n defaultHighlightColor: highlightColor,\n scratchpad: z.object({\n enabled: z.boolean(),\n scopes: z.array(z.enum([\"global\", \"book\", \"chapter\"])).min(1, \"must be non-empty\"),\n }),\n themes: z.array(themeName).min(1),\n defaultTheme: themeName,\n defaultSettings: z.object({\n textSize: z.enum(TEXT_SIZES),\n leading: z.enum(LEADINGS),\n measure: z.enum(MEASURES),\n fontFamily: z.enum(FONT_FAMILIES),\n highlightMode: z.boolean(),\n }),\n progress: z.object({ completeAt: z.number().gt(0).max(1), saveIntervalMs: z.number().min(100) }),\n backupReminder: z.boolean(),\n basePath: z.string().startsWith(\"/\"),\n })\n .refine((c) => c.highlightColors.includes(c.defaultHighlightColor), {\n message: \"defaultHighlightColor must be one of highlightColors\",\n path: [\"defaultHighlightColor\"],\n })\n .refine((c) => c.themes.includes(c.defaultTheme), {\n message: \"defaultTheme must be one of themes\",\n path: [\"defaultTheme\"],\n });\n\nfunction isSchemaLike(v: unknown): boolean {\n return typeof v === \"object\" && v !== null && typeof (v as { safeParse?: unknown }).safeParse === \"function\";\n}\n\nconst contentSchema = z.object({\n loader: z.object({\n kind: z.literal(\"glob\"),\n base: z.string().min(1),\n pattern: z.union([z.string(), z.array(z.string()).min(1)]),\n ignore: z.array(z.string()).optional(),\n }),\n schemas: z.object({\n book: z.custom<z.ZodType>(isSchemaLike, \"must be a zod (or safeParse-compatible) schema\"),\n chapter: z.custom<z.ZodType>(isSchemaLike, \"must be a zod (or safeParse-compatible) schema\"),\n }),\n remarkPlugins: z.array(z.any()),\n rehypePlugins: z.array(z.any()),\n sanitize: z.object({\n allowIframes: z.array(z.string()).optional(),\n allowTags: z.array(z.string()).optional(),\n allowAttributes: z.array(z.string()).optional(),\n }),\n includeDrafts: z.boolean(),\n cacheDir: z.string(),\n});\n\nexport class ReaderConfigError extends Error {\n constructor(\n message: string,\n public readonly issues: { path: string; message: string }[] = [],\n ) {\n super(message);\n this.name = \"ReaderConfigError\";\n }\n}\n\nfunction formatIssues(source: string, section: string, error: z.ZodError) {\n const issues = error.issues.map((i) => ({ path: [section, ...i.path.map(String)].join(\".\"), message: i.message }));\n return new ReaderConfigError(\n `Invalid reader config${source ? ` (${source})` : \"\"}:\\n` + issues.map((i) => ` - ${i.path}: ${i.message}`).join(\"\\n\"),\n issues,\n );\n}\n\n/**\n * Resolve the final config: package defaults ← reader.config.ts ← inline overrides.\n * Throws `ReaderConfigError` with readable messages.\n */\nexport function resolveConfig(\n user?: ReaderUserConfig | null,\n inline?: ReaderUserConfig | null,\n opts: { root?: string; source?: string } = {},\n): ResolvedReaderConfig {\n const root = opts.root ?? (typeof process !== \"undefined\" && process.cwd ? process.cwd() : \"/\");\n const reader = mergeConfig<ReaderClientOptions>(\n structuredClone(DEFAULT_CLIENT_OPTIONS),\n user?.reader,\n inline?.reader,\n );\n const content = mergeConfig<ContentConfig>(defaultContentConfig(), user?.content, inline?.content);\n\n const r = clientSchema.safeParse(reader);\n if (!r.success) throw formatIssues(opts.source ?? \"\", \"reader\", r.error);\n const c = contentSchema.safeParse(content);\n if (!c.success) throw formatIssues(opts.source ?? \"\", \"content\", c.error);\n\n return { root, content, reader };\n}\n\n/** Only the serializable, client-safe half. */\nexport function clientOptions(config: ResolvedReaderConfig): ReaderClientOptions {\n return config.reader;\n}\n\nexport const CONFIG_FILE_NAMES = [\"reader.config.ts\", \"reader.config.mts\", \"reader.config.mjs\", \"reader.config.js\"];\n","/** Node-only helpers for locating and loading reader.config.* (via jiti). */\nimport { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { CONFIG_FILE_NAMES, type ReaderUserConfig } from \"./index\";\n\n/** Search `from` and its parents (up to the filesystem root or a `.git` dir) for reader.config.*. */\nexport function findConfigFile(from: string = process.cwd()): string | null {\n let dir = resolve(from);\n for (;;) {\n for (const name of CONFIG_FILE_NAMES) {\n const p = join(dir, name);\n if (existsSync(p)) return p;\n }\n if (existsSync(join(dir, \"package.json\")) || existsSync(join(dir, \".git\"))) return null;\n const parent = dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nexport async function loadConfigFile(file: string): Promise<ReaderUserConfig> {\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(file, { interopDefault: true, moduleCache: false });\n const mod = (await jiti.import(file)) as { default?: ReaderUserConfig } | ReaderUserConfig;\n const cfg = (mod && typeof mod === \"object\" && \"default\" in mod ? mod.default : mod) as ReaderUserConfig | undefined;\n return cfg ?? {};\n}\n","/**\n * Next.js integration.\n *\n * // next.config.ts\n * import { withReader } from \"zreader/next\";\n * export default withReader({ reactStrictMode: true });\n */\nimport { join, relative, resolve, sep } from \"node:path\";\nimport type { NextConfig } from \"next\";\nimport { resolveConfig, type ResolvedReaderConfig, type ReaderUserConfig } from \"../config/index\";\nimport { findConfigFile, loadConfigFile } from \"../config/load\";\n\nexport const USER_CONFIG_SPECIFIER = \"zreader/user-config\";\nexport const EMPTY_CONFIG_SPECIFIER = \"zreader/empty-config\";\n\n/** Packages that must stay external on the server (dynamic requires / native-ish). */\nexport const SERVER_EXTERNALS = [\"jsdom\", \"isomorphic-dompurify\"];\n\nexport interface WithReaderOptions {\n /** Path to the config file. Defaults to discovering reader.config.{ts,mts,mjs,js}. */\n configPath?: string;\n /** Project root. Defaults to process.cwd() (the directory containing next.config). */\n root?: string;\n /** Inline overrides merged on top of reader.config.ts. */\n config?: ReaderUserConfig;\n /** Log the resolved config file path at startup. */\n verbose?: boolean;\n}\n\ntype NextConfigFn = (phase: string, ctx: { defaultConfig: NextConfig }) => NextConfig | Promise<NextConfig>;\nexport type NextConfigInput = NextConfig | NextConfigFn;\n\ntype WebpackFn = NonNullable<NextConfig[\"webpack\"]>;\n\nfunction toPosix(p: string) {\n return p.split(sep).join(\"/\");\n}\n\n/** Alias target relative to the project root, as Turbopack expects (`./reader.config.ts`). */\nfunction relativeImport(root: string, file: string) {\n const rel = toPosix(relative(root, file));\n return rel.startsWith(\".\") ? rel : `./${rel}`;\n}\n\nexport interface ReaderNextSetup {\n configFile: string | null;\n resolved: ResolvedReaderConfig;\n}\n\n/** Pure transform (exported for testing): apply reader wiring to a resolved Next config. */\nexport function applyReaderConfig(base: NextConfig, setup: ReaderNextSetup, root: string): NextConfig {\n const { configFile, resolved } = setup;\n const turboTarget = configFile ? relativeImport(root, configFile) : EMPTY_CONFIG_SPECIFIER;\n const webpackTarget = configFile ?? EMPTY_CONFIG_SPECIFIER;\n\n const prevWebpack = base.webpack as WebpackFn | undefined;\n const webpack: WebpackFn = (config, ctx) => {\n const cfg = (prevWebpack ? prevWebpack(config, ctx) : config) as { resolve?: { alias?: Record<string, unknown> } };\n cfg.resolve ??= {};\n const alias = (cfg.resolve.alias ??= {}) as Record<string, unknown>;\n alias[`${USER_CONFIG_SPECIFIER}$`] = webpackTarget;\n return cfg;\n };\n\n const contentGlob = toPosix(join(resolved.content.loader.base, \"**/*\"));\n const tracing = { ...(base.outputFileTracingIncludes ?? {}) };\n const allRoutes = \"/**\";\n tracing[allRoutes] = Array.from(new Set([...(tracing[allRoutes] ?? []), contentGlob]));\n // The proxy/middleware entry is named \"proxy\" or \"middleware\" (no leading\n // slash, so \"/**\" misses it); zreader/agent reads chapters from the proxy.\n for (const entry of [\"middleware\", \"proxy\"]) {\n tracing[entry] = Array.from(new Set([...(tracing[entry] ?? []), contentGlob]));\n }\n\n const externals = Array.from(new Set([...(base.serverExternalPackages ?? []), ...SERVER_EXTERNALS]));\n\n return {\n ...base,\n serverExternalPackages: externals,\n outputFileTracingIncludes: tracing,\n turbopack: {\n ...base.turbopack,\n resolveAlias: {\n ...base.turbopack?.resolveAlias,\n [USER_CONFIG_SPECIFIER]: turboTarget,\n },\n },\n webpack,\n };\n}\n\nexport async function setupReader(options: WithReaderOptions = {}): Promise<ReaderNextSetup> {\n const root = resolve(options.root ?? process.cwd());\n const configFile = options.configPath ? resolve(root, options.configPath) : findConfigFile(root);\n const user = configFile ? await loadConfigFile(configFile) : {};\n // Validate eagerly so `next dev` / `next build` fail fast with a readable error.\n const resolved = resolveConfig(user, options.config, {\n root,\n source: configFile ? relative(root, configFile) : \"defaults\",\n });\n return { configFile, resolved };\n}\n\n/**\n * Wire zreader into Next.js:\n * - validates reader.config.* at startup;\n * - aliases `zreader/user-config` to it (Turbopack + webpack), so\n * `zreader/virtual-config` is the resolved config everywhere on the server;\n * - keeps jsdom/DOMPurify external on the server;\n * - traces the content directory into the server output (Vercel);\n * - points the compiled-chapter cache at `.next/cache/zreader`.\n */\nexport function withReader(nextConfig: NextConfigInput = {}, options: WithReaderOptions = {}): NextConfigFn {\n return async (phase, ctx) => {\n const root = resolve(options.root ?? process.cwd());\n process.env.ZREADER_CACHE_DIR ??= join(root, \".next\", \"cache\", \"zreader\");\n const base = typeof nextConfig === \"function\" ? await nextConfig(phase, ctx) : nextConfig;\n const setup = await setupReader({ ...options, root });\n if (options.verbose) {\n console.log(`[zreader] config: ${setup.configFile ?? \"(defaults)\"}`);\n }\n return applyReaderConfig(base, setup, root);\n };\n}\n\nexport { resolveConfig, findConfigFile, loadConfigFile };\nexport type { ResolvedReaderConfig, ReaderUserConfig };\n"]}
|
|
@@ -5,6 +5,7 @@ import { ReactNode } from 'react';
|
|
|
5
5
|
export { default as readerConfig } from 'zreader/virtual-config';
|
|
6
6
|
import { MdxComponents } from 'zreader/content';
|
|
7
7
|
import { ReaderProps, ReaderProviderProps, Callout } from 'zreader/react';
|
|
8
|
+
import { BuiltInProvider } from 'zreader/agent/react';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Default MDX components (built here, in a server module, so RSC pages get real
|
|
@@ -13,7 +14,18 @@ import { ReaderProps, ReaderProviderProps, Callout } from 'zreader/react';
|
|
|
13
14
|
declare const mdxComponents: {
|
|
14
15
|
Callout: typeof Callout;
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
/** Serializable options for `<ReaderRoot agent>` (see `<CopyReference>`). */
|
|
18
|
+
interface ReaderRootAgentOptions {
|
|
19
|
+
/** Copied text; `{url}` is the chapter's `.md` URL. */
|
|
20
|
+
prompt?: string;
|
|
21
|
+
/** Prompt sent to the assistants in the menu. */
|
|
22
|
+
askPrompt?: string;
|
|
23
|
+
/** Built-in assistants, in order. `[]` hides them. */
|
|
24
|
+
providers?: BuiltInProvider[];
|
|
25
|
+
/** Button text. */
|
|
26
|
+
label?: string;
|
|
27
|
+
}
|
|
28
|
+
interface ReaderRootProps extends Omit<ReaderProviderProps, "options" | "store" | "adapter" | "onStorageError" | "Link" | "books" | "headerSlot" | "readerActions"> {
|
|
17
29
|
/** Defaults to every book from the content layer (`getBookMetas()`). */
|
|
18
30
|
books?: BookMeta[];
|
|
19
31
|
/**
|
|
@@ -21,13 +33,24 @@ interface ReaderRootProps extends Omit<ReaderProviderProps, "options" | "store"
|
|
|
21
33
|
* Server-rendered, so it must be a node, not a function.
|
|
22
34
|
*/
|
|
23
35
|
headerSlot?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Default buttons for the right of the reader's top bar. A chapter's
|
|
38
|
+
* `actions` replaces them. With `agent`, they render after the agent button.
|
|
39
|
+
*/
|
|
40
|
+
readerActions?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Agent features for every chapter: a `<link rel="alternate" type="text/markdown">`
|
|
43
|
+
* tag and a "Copy reference" button pointing at the chapter's `.md` twin.
|
|
44
|
+
* Serve those with `createAgentHandler()` from `zreader/agent` in proxy.ts.
|
|
45
|
+
*/
|
|
46
|
+
agent?: boolean | ReaderRootAgentOptions;
|
|
24
47
|
children: ReactNode;
|
|
25
48
|
}
|
|
26
49
|
/**
|
|
27
50
|
* The reader's provider for Next.js: client options from reader.config.ts, the
|
|
28
51
|
* book catalogue from the content layer, and next/link for every link.
|
|
29
52
|
*/
|
|
30
|
-
declare function ReaderRoot({ books, children, ...props }: ReaderRootProps): Promise<react.JSX.Element>;
|
|
53
|
+
declare function ReaderRoot({ books, agent, readerActions, children, ...props }: ReaderRootProps): Promise<react.JSX.Element>;
|
|
31
54
|
interface ReaderChapterProps extends Omit<ReaderProps, "book" | "chapter" | "html" | "children" | "toc" | "contentHash" | "Link" | "hrefFor" | "header"> {
|
|
32
55
|
/** Book id (a `[book]` route param). */
|
|
33
56
|
book: string;
|
|
@@ -55,4 +78,4 @@ declare function getChapterParams(): Promise<Array<{
|
|
|
55
78
|
declare function getClientOptions(): zreader.ReaderClientOptions;
|
|
56
79
|
|
|
57
80
|
export { ReaderChapter, ReaderRoot, getBookParams, getChapterParams, getClientOptions, mdxComponents };
|
|
58
|
-
export type { ReaderChapterProps, ReaderRootProps };
|
|
81
|
+
export type { ReaderChapterProps, ReaderRootAgentOptions, ReaderRootProps };
|
|
@@ -4,13 +4,20 @@ export { default as readerConfig } from 'zreader/virtual-config';
|
|
|
4
4
|
import { getBookMetas, getChapter, renderChapter, getStaticParams } from 'zreader/content';
|
|
5
5
|
import { Callout, Reader } from 'zreader/react';
|
|
6
6
|
import { NextReaderProvider } from 'zreader/next/client';
|
|
7
|
-
import {
|
|
7
|
+
import { MarkdownAlternate, CopyReference } from 'zreader/agent/react';
|
|
8
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
|
9
10
|
// src/next/server/index.tsx
|
|
10
11
|
var mdxComponents = { Callout };
|
|
11
|
-
async function ReaderRoot({ books, children, ...props }) {
|
|
12
|
+
async function ReaderRoot({ books, agent, readerActions, children, ...props }) {
|
|
12
13
|
const catalogue = books ?? await getBookMetas();
|
|
13
|
-
|
|
14
|
+
const agentOptions = agent === true ? {} : agent || null;
|
|
15
|
+
const actions = agentOptions ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16
|
+
/* @__PURE__ */ jsx(MarkdownAlternate, {}),
|
|
17
|
+
/* @__PURE__ */ jsx(CopyReference, { markdown: true, ...agentOptions }),
|
|
18
|
+
readerActions
|
|
19
|
+
] }) : readerActions;
|
|
20
|
+
return /* @__PURE__ */ jsx(NextReaderProvider, { options: config.reader, books: catalogue, readerActions: actions, ...props, children });
|
|
14
21
|
}
|
|
15
22
|
async function ReaderChapter({ book, chapter, components, ...props }) {
|
|
16
23
|
const hit = await getChapter(book, chapter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/server/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/server/index.tsx"],"names":[],"mappings":";;;;;;;;;;AAyBO,IAAM,aAAA,GAAgB,EAAE,OAAA;AAyC/B,eAAsB,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAO,eAAe,QAAA,EAAU,GAAG,OAAM,EAAoB;AACrG,EAAA,MAAM,SAAA,GAAY,KAAA,IAAU,MAAM,YAAA,EAAa;AAC/C,EAAA,MAAM,YAAA,GAAe,KAAA,KAAU,IAAA,GAAO,KAAK,KAAA,IAAS,IAAA;AACpD,EAAA,MAAM,OAAA,GAAU,+BACd,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,CAAA;AAAA,oBACnB,GAAA,CAAC,aAAA,EAAA,EAAc,QAAA,EAAQ,IAAA,EAAE,GAAG,YAAA,EAAc,CAAA;AAAA,IACzC;AAAA,GAAA,EACH,CAAA,GAEA,aAAA;AAEF,EAAA,uBACE,GAAA,CAAC,kBAAA,EAAA,EAAmB,OAAA,EAAS,MAAA,CAAO,MAAA,EAAQ,KAAA,EAAO,SAAA,EAAW,aAAA,EAAe,OAAA,EAAU,GAAG,KAAA,EACvF,QAAA,EACH,CAAA;AAEJ;AAiBA,eAAsB,cAAc,EAAE,IAAA,EAAM,SAAS,UAAA,EAAY,GAAG,OAAM,EAAuB;AAC/F,EAAA,MAAM,GAAA,GAAM,MAAM,UAAA,CAAW,IAAA,EAAM,OAAO,CAAA;AAC1C,EAAA,IAAI,CAAC,KAAK,QAAA,EAAS;AACnB,EAAA,MAAM,QAAA,GAAW,MAAM,aAAA,CAAc,GAAA,CAAI,OAAO,CAAA;AAChD,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,IAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAK,QAAA,CAAS,GAAA;AAAA,MACd,aAAa,QAAA,CAAS,WAAA;AAAA,MACtB,IAAA,EAAM,QAAA,CAAS,IAAA,KAAS,MAAA,GAAS,SAAS,IAAA,GAAO,MAAA;AAAA,MAEhD,QAAA,EAAA,QAAA,CAAS,IAAA,KAAS,KAAA,mBAAQ,GAAA,CAAC,SAAS,OAAA,EAAT,EAAiB,UAAA,EAAY,EAAE,GAAG,aAAA,EAAe,GAAG,UAAA,IAA+B,CAAA,GAAK;AAAA;AAAA,GACtH;AAEJ;AAGA,eAAsB,aAAA,GAAkD;AACtE,EAAA,OAAA,CAAQ,MAAM,YAAA,EAAa,EAAG,GAAA,CAAI,CAAC,OAAO,EAAE,IAAA,EAAM,CAAA,CAAE,EAAA,EAAG,CAAE,CAAA;AAC3D;AAGA,eAAsB,gBAAA,GAAsE;AAC1F,EAAA,OAAO,eAAA,EAAgB;AACzB;AAEO,SAAS,gBAAA,GAAmB;AACjC,EAAA,OAAO,MAAA,CAAO,MAAA;AAChB","file":"index.js","sourcesContent":["/**\n * `zreader/next/server` — React Server Components for the optional\n * Next.js adapter. Other React apps wire <ReaderProvider> themselves.\n *\n * // app/books/layout.tsx — provider with the whole catalogue + next/link\n * export default function Layout({ children }) { return <ReaderRoot>{children}</ReaderRoot>; }\n *\n * // app/books/page.tsx → <BookShelf />\n * // app/books/[book]/page.tsx → <BookContents book={params.book} />\n * // app/books/[book]/[chapter]/page.tsx\n * export default async function Page({ params }) { return <ReaderChapter {...await params} />; }\n */\nimport type { ReactNode } from \"react\";\nimport { notFound } from \"next/navigation\";\nimport config from \"zreader/virtual-config\";\nimport { getBookMetas, getChapter, getStaticParams, renderChapter, type MdxComponents } from \"zreader/content\";\nimport { Callout, Reader, type ReaderProps, type ReaderProviderProps } from \"zreader/react\";\nimport { NextReaderProvider } from \"zreader/next/client\";\nimport { CopyReference, MarkdownAlternate, type BuiltInProvider } from \"zreader/agent/react\";\nimport type { BookMeta } from \"zreader\";\n\n/**\n * Default MDX components (built here, in a server module, so RSC pages get real\n * component references): `<Content components={mdxComponents} />`.\n */\nexport const mdxComponents = { Callout };\n\n/** Serializable options for `<ReaderRoot agent>` (see `<CopyReference>`). */\nexport interface ReaderRootAgentOptions {\n /** Copied text; `{url}` is the chapter's `.md` URL. */\n prompt?: string;\n /** Prompt sent to the assistants in the menu. */\n askPrompt?: string;\n /** Built-in assistants, in order. `[]` hides them. */\n providers?: BuiltInProvider[];\n /** Button text. */\n label?: string;\n}\n\nexport interface ReaderRootProps\n extends Omit<ReaderProviderProps, \"options\" | \"store\" | \"adapter\" | \"onStorageError\" | \"Link\" | \"books\" | \"headerSlot\" | \"readerActions\"> {\n /** Defaults to every book from the content layer (`getBookMetas()`). */\n books?: BookMeta[];\n /**\n * Default content for the middle of the reader's top bar (text or any element).\n * Server-rendered, so it must be a node, not a function.\n */\n headerSlot?: ReactNode;\n /**\n * Default buttons for the right of the reader's top bar. A chapter's\n * `actions` replaces them. With `agent`, they render after the agent button.\n */\n readerActions?: ReactNode;\n /**\n * Agent features for every chapter: a `<link rel=\"alternate\" type=\"text/markdown\">`\n * tag and a \"Copy reference\" button pointing at the chapter's `.md` twin.\n * Serve those with `createAgentHandler()` from `zreader/agent` in proxy.ts.\n */\n agent?: boolean | ReaderRootAgentOptions;\n children: ReactNode;\n}\n\n/**\n * The reader's provider for Next.js: client options from reader.config.ts, the\n * book catalogue from the content layer, and next/link for every link.\n */\nexport async function ReaderRoot({ books, agent, readerActions, children, ...props }: ReaderRootProps) {\n const catalogue = books ?? (await getBookMetas());\n const agentOptions = agent === true ? {} : agent || null;\n const actions = agentOptions ? (\n <>\n <MarkdownAlternate />\n <CopyReference markdown {...agentOptions} />\n {readerActions}\n </>\n ) : (\n readerActions\n );\n return (\n <NextReaderProvider options={config.reader} books={catalogue} readerActions={actions} {...props}>\n {children}\n </NextReaderProvider>\n );\n}\n\nexport interface ReaderChapterProps extends Omit<ReaderProps, \"book\" | \"chapter\" | \"html\" | \"children\" | \"toc\" | \"contentHash\" | \"Link\" | \"hrefFor\" | \"header\"> {\n /** Book id (a `[book]` route param). */\n book: string;\n /** Chapter id (a `[chapter]` route param). */\n chapter: string;\n /** Extra MDX components, merged over `mdxComponents`. */\n components?: MdxComponents;\n /** Top-bar content for this chapter only (overrides the provider's). */\n header?: ReactNode;\n}\n\n/**\n * Loads, compiles and renders one chapter (Markdown, HTML or MDX) inside <Reader>.\n * Calls `notFound()` for unknown ids. Must be rendered under <ReaderRoot>.\n */\nexport async function ReaderChapter({ book, chapter, components, ...props }: ReaderChapterProps) {\n const hit = await getChapter(book, chapter);\n if (!hit) notFound();\n const rendered = await renderChapter(hit.chapter);\n return (\n <Reader\n {...props}\n book={book}\n chapter={chapter}\n toc={rendered.toc}\n contentHash={rendered.contentHash}\n html={rendered.kind === \"html\" ? rendered.html : undefined}\n >\n {rendered.kind === \"mdx\" ? <rendered.Content components={{ ...mdxComponents, ...components } as MdxComponents} /> : null}\n </Reader>\n );\n}\n\n/** `export const generateStaticParams = getBookParams` in `app/books/[book]/page.tsx`. */\nexport async function getBookParams(): Promise<Array<{ book: string }>> {\n return (await getBookMetas()).map((b) => ({ book: b.id }));\n}\n\n/** `export const generateStaticParams = getChapterParams` in `app/books/[book]/[chapter]/page.tsx`. */\nexport async function getChapterParams(): Promise<Array<{ book: string; chapter: string }>> {\n return getStaticParams();\n}\n\nexport function getClientOptions() {\n return config.reader;\n}\n\nexport { config as readerConfig };\n"]}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ interface Library {
|
|
|
36
36
|
Link: LinkComponent;
|
|
37
37
|
href: HrefFor;
|
|
38
38
|
headerSlot?: HeaderSlot;
|
|
39
|
+
readerActions?: ReactNode;
|
|
39
40
|
}
|
|
40
41
|
interface ReaderContextValue {
|
|
41
42
|
store: ReaderStore;
|
|
@@ -72,9 +73,15 @@ interface ReaderProviderProps {
|
|
|
72
73
|
* or any component. Omit to show the book and chapter titles.
|
|
73
74
|
*/
|
|
74
75
|
headerSlot?: HeaderSlot;
|
|
76
|
+
/**
|
|
77
|
+
* Default buttons for the right of the reader's top bar (before the bookmark
|
|
78
|
+
* toggle), e.g. `<CopyReference markdown />`. A <Reader>'s `actions` replaces
|
|
79
|
+
* them; `actions={null}` hides them for that chapter.
|
|
80
|
+
*/
|
|
81
|
+
readerActions?: ReactNode;
|
|
75
82
|
children: ReactNode;
|
|
76
83
|
}
|
|
77
|
-
declare function ReaderProvider({ options, overrides, adapter, store: external, onStorageError, manageTheme, toaster, books, Link, hrefFor, headerSlot, children, }: ReaderProviderProps): react.JSX.Element;
|
|
84
|
+
declare function ReaderProvider({ options, overrides, adapter, store: external, onStorageError, manageTheme, toaster, books, Link, hrefFor, headerSlot, readerActions, children, }: ReaderProviderProps): react.JSX.Element;
|
|
78
85
|
declare function useReader(): ReaderContextValue;
|
|
79
86
|
/** The provider's catalogue, link component and URL builder. */
|
|
80
87
|
declare function useLibrary(): Library;
|
|
@@ -121,20 +128,29 @@ interface ReaderProps {
|
|
|
121
128
|
* `<><Logo /><ReaderTitle /></>`.
|
|
122
129
|
*/
|
|
123
130
|
header?: HeaderSlot;
|
|
131
|
+
/**
|
|
132
|
+
* Buttons for the right side of the top bar, before the bookmark toggle,
|
|
133
|
+
* e.g. `<CopyReference />` from `zreader/agent/react`. Defaults to the
|
|
134
|
+
* provider's `readerActions`; `null` hides them.
|
|
135
|
+
*/
|
|
136
|
+
actions?: ReactNode;
|
|
124
137
|
/** Where the back button goes. Defaults to the book page. */
|
|
125
138
|
backHref?: string;
|
|
126
139
|
className?: string;
|
|
127
140
|
}
|
|
128
|
-
|
|
129
|
-
declare function useReaderChapter(): {
|
|
141
|
+
interface ReaderChapterValue {
|
|
130
142
|
book: BookMeta;
|
|
131
143
|
chapter: ChapterMeta;
|
|
132
|
-
|
|
144
|
+
/** Page URL within this book (the reader's `hrefFor`): `href()` is the book, `href(chapterId)` a chapter. */
|
|
145
|
+
href: (chapterId?: string, hash?: string) => string;
|
|
146
|
+
}
|
|
147
|
+
/** The book and chapter of the surrounding <Reader> (for custom header content and actions). */
|
|
148
|
+
declare function useReaderChapter(): ReaderChapterValue;
|
|
133
149
|
/** The default header content: book title over chapter title. */
|
|
134
150
|
declare function ReaderTitle({ className }: {
|
|
135
151
|
className?: string;
|
|
136
152
|
}): react.JSX.Element;
|
|
137
|
-
declare function Reader({ book: bookArg, chapter: chapterArg, prev: prevArg, next: nextArg, toc: tocProp, contentHash, html, children, Link: LinkProp, hrefFor, header, backHref, className, }: ReaderProps): react.JSX.Element;
|
|
153
|
+
declare function Reader({ book: bookArg, chapter: chapterArg, prev: prevArg, next: nextArg, toc: tocProp, contentHash, html, children, Link: LinkProp, hrefFor, header, actions, backHref, className, }: ReaderProps): react.JSX.Element;
|
|
138
154
|
|
|
139
155
|
interface BookNavProps {
|
|
140
156
|
/** A book id from the provider's catalogue, or the book's metadata. */
|
|
@@ -373,4 +389,4 @@ declare function quoteBorderClass(color: string): string;
|
|
|
373
389
|
declare const PROSE_CLASS = "prose max-w-none text-foreground prose-headings:text-foreground prose-headings:scroll-mt-20 prose-p:text-foreground prose-li:text-foreground prose-strong:text-foreground prose-a:text-primary prose-a:underline-offset-4 prose-blockquote:border-l-border prose-blockquote:text-muted-foreground prose-code:text-foreground prose-pre:bg-muted prose-pre:text-foreground prose-hr:border-border prose-th:text-foreground prose-td:text-foreground prose-figcaption:text-muted-foreground prose-img:rounded-lg prose-table:block prose-table:max-w-full prose-table:overflow-x-auto prose-th:align-bottom prose-td:align-top";
|
|
374
390
|
|
|
375
391
|
export { BookContents, BookHome, BookShelf, Callout, ChapterList, ContentsSheet, ContinueReading, DefaultLink, FONT_CLASS, HighlightPanel, LEADING_CLASS, MEASURE_CLASS, PROSE_CLASS, QUOTE_BORDER_CLASS, Reader, ReaderProvider, ReaderTitle, ResponsivePanel, SWATCH_CLASS, ScratchpadPanel, SelectionToolbar, SettingsPanel, TEXT_SIZE_CLASS, chapterMarker, copyText, defaultHref, downloadFile, groupByPart, mergeOptions, quoteBorderClass, scopeFor, scopeKey, swatchClass, useBook, useBookmarks, useChapterEngine, useHighlights, useHydrated, useIsDesktop, useLibrary, useMediaQuery, usePad, useProgress, useReader, useReaderChapter, useReaderStore, useSettings, useValueStore };
|
|
376
|
-
export type { BookContentsProps, BookHomeProps, BookNavProps, BookShelfProps, CalloutProps, ChapterEngine, ChapterEngineOptions, ContentsSheetProps, ContentsTab, HeaderSlot, HighlightPanelProps, HrefFor, Library, LinkComponent, PartGroup, ReaderProps, ReaderProviderProps, ResponsivePanelProps, ScratchpadPanelProps, SelectionState, SelectionToolbarProps, SettingsPanelProps };
|
|
392
|
+
export type { BookContentsProps, BookHomeProps, BookNavProps, BookShelfProps, CalloutProps, ChapterEngine, ChapterEngineOptions, ContentsSheetProps, ContentsTab, HeaderSlot, HighlightPanelProps, HrefFor, Library, LinkComponent, PartGroup, ReaderChapterValue, ReaderProps, ReaderProviderProps, ResponsivePanelProps, ScratchpadPanelProps, SelectionState, SelectionToolbarProps, SettingsPanelProps };
|
package/dist/react/index.js
CHANGED
|
@@ -124,6 +124,7 @@ function ReaderProvider({
|
|
|
124
124
|
Link,
|
|
125
125
|
hrefFor,
|
|
126
126
|
headerSlot,
|
|
127
|
+
readerActions,
|
|
127
128
|
children
|
|
128
129
|
}) {
|
|
129
130
|
const key = JSON.stringify([options ?? null, overrides ?? null]);
|
|
@@ -144,9 +145,10 @@ function ReaderProvider({
|
|
|
144
145
|
getBook: (id) => byId.get(id),
|
|
145
146
|
Link: Link ?? DefaultLink,
|
|
146
147
|
href: hrefFor ?? ((b, c, h) => defaultHref(resolved.basePath, b, c, h)),
|
|
147
|
-
headerSlot
|
|
148
|
+
headerSlot,
|
|
149
|
+
readerActions
|
|
148
150
|
};
|
|
149
|
-
}, [books, Link, hrefFor, headerSlot, resolved.basePath]);
|
|
151
|
+
}, [books, Link, hrefFor, headerSlot, readerActions, resolved.basePath]);
|
|
150
152
|
const value = useMemo(() => ({ store, options: resolved, library }), [store, resolved, library]);
|
|
151
153
|
const tree = /* @__PURE__ */ jsx(ReaderContext.Provider, { value, children: /* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 400, children: [
|
|
152
154
|
children,
|
|
@@ -2252,6 +2254,7 @@ function Reader({
|
|
|
2252
2254
|
Link: LinkProp,
|
|
2253
2255
|
hrefFor,
|
|
2254
2256
|
header,
|
|
2257
|
+
actions,
|
|
2255
2258
|
backHref,
|
|
2256
2259
|
className
|
|
2257
2260
|
}) {
|
|
@@ -2267,13 +2270,14 @@ function Reader({
|
|
|
2267
2270
|
const next = nextArg !== void 0 ? nextArg : chapterIndex >= 0 ? book.chapters[chapterIndex + 1] ?? null : null;
|
|
2268
2271
|
const Link = LinkProp ?? library.Link;
|
|
2269
2272
|
const slot = header !== void 0 ? header : library.headerSlot;
|
|
2270
|
-
const
|
|
2273
|
+
const topActions = actions !== void 0 ? actions : library.readerActions;
|
|
2271
2274
|
const [settings, updateSettings] = useSettings();
|
|
2272
2275
|
const isDesktop = useIsDesktop();
|
|
2273
2276
|
const bookmarks = useBookmarks(book.id);
|
|
2274
2277
|
const progress = useProgress(book.id);
|
|
2275
2278
|
const build = hrefFor ?? library.href;
|
|
2276
2279
|
const href = useCallback((chapterId, hash) => build(book.id, chapterId, hash), [build, book.id]);
|
|
2280
|
+
const chapterCtx = useMemo(() => ({ book, chapter, href }), [book, chapter, href]);
|
|
2277
2281
|
const [rootEl, setRootEl] = useState(null);
|
|
2278
2282
|
const [scrollEl, setScrollEl] = useState(null);
|
|
2279
2283
|
const [contentsOpen, setContentsOpen] = useState(false);
|
|
@@ -2394,6 +2398,7 @@ function Reader({
|
|
|
2394
2398
|
] }),
|
|
2395
2399
|
/* @__PURE__ */ jsx(IconAction, { label: "Contents, highlights and bookmarks", onClick: () => setContentsOpen(true), children: /* @__PURE__ */ jsx(ListIcon, {}) }),
|
|
2396
2400
|
/* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 items-center gap-2 px-1", children: /* @__PURE__ */ jsx(HeaderContent, { slot, book, chapter }) }),
|
|
2401
|
+
topActions,
|
|
2397
2402
|
/* @__PURE__ */ jsx(IconToggle, { label: chapterBookmarks.length ? "Remove bookmark" : "Bookmark this place", pressed: chapterBookmarks.length > 0, onPressedChange: toggleBookmark, className: "data-[state=on]:[&_svg]:fill-current", children: /* @__PURE__ */ jsx(BookmarkIcon, {}) }),
|
|
2398
2403
|
/* @__PURE__ */ jsx(IconToggle, { label: "Highlight mode: tap a sentence", pressed: settings.highlightMode, onPressedChange: (highlightMode) => updateSettings({ highlightMode }), children: /* @__PURE__ */ jsx(HighlighterIcon, {}) }),
|
|
2399
2404
|
/* @__PURE__ */ jsx(IconAction, { label: "Reading settings", onClick: () => setSettingsOpen(true), children: /* @__PURE__ */ jsx(TypeIcon, {}) }),
|