@rspress/plugin-medium-zoom 1.42.0 → 1.42.1-canary-20240226

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/dist/index.d.ts CHANGED
@@ -159,6 +159,14 @@ declare interface EditLink {
159
159
  text?: string;
160
160
  }
161
161
 
162
+ declare interface Feature {
163
+ icon: string;
164
+ title: string;
165
+ details: string;
166
+ span?: number;
167
+ link?: string;
168
+ }
169
+
162
170
  /**
163
171
  * The config of filter component
164
172
  */
@@ -172,6 +180,23 @@ declare interface Footer {
172
180
  message?: string;
173
181
  }
174
182
 
183
+ declare interface FrontMatterMeta {
184
+ title?: string;
185
+ description?: string;
186
+ overview?: boolean;
187
+ pageType?: PageType;
188
+ features?: Feature[];
189
+ hero?: Hero;
190
+ sidebar?: boolean;
191
+ outline?: boolean;
192
+ lineNumbers?: boolean;
193
+ overviewHeaders?: number[];
194
+ titleSuffix?: string;
195
+ head?: [string, Record<string, string>][];
196
+ context?: string;
197
+ [key: string]: unknown;
198
+ }
199
+
175
200
  declare interface Header {
176
201
  id: string;
177
202
  text: string;
@@ -179,6 +204,30 @@ declare interface Header {
179
204
  charIndex: number;
180
205
  }
181
206
 
207
+ declare interface Hero {
208
+ name: string;
209
+ text: string;
210
+ tagline: string;
211
+ image?: {
212
+ src: string | {
213
+ dark: string;
214
+ light: string;
215
+ };
216
+ alt: string;
217
+ /**
218
+ * `srcset` and `sizes` are attributes of `<img>` tag. Please refer to https://mdn.io/srcset for the usage.
219
+ * When the value is an array, rspress will join array members with commas.
220
+ **/
221
+ sizes?: string | string[];
222
+ srcset?: string | string[];
223
+ };
224
+ actions: {
225
+ text: string;
226
+ link: string;
227
+ theme: 'brand' | 'alt';
228
+ }[];
229
+ }
230
+
182
231
  declare interface Locale {
183
232
  lang: string;
184
233
  label: string;
@@ -310,20 +359,22 @@ declare interface Options {
310
359
  * "_foo" is the private field that won't be written to search-index.json file
311
360
  * and should not be used in the runtime (usePageData).
312
361
  */
313
- declare type PageIndexInfo = {
362
+ declare interface PageIndexInfo {
314
363
  id: number;
315
364
  title: string;
316
365
  routePath: string;
317
366
  toc: Header[];
318
367
  content: string;
319
368
  _html: string;
320
- frontmatter: Record<string, unknown>;
369
+ frontmatter: FrontMatterMeta;
321
370
  lang: string;
322
371
  version: string;
323
372
  domain: string;
324
373
  _filepath: string;
325
374
  _relativePath: string;
326
- };
375
+ }
376
+
377
+ declare type PageType = 'home' | 'doc' | 'custom' | '404' | 'blank';
327
378
 
328
379
  /**
329
380
  * The plugin is used to add medium-zoom to the doc site.
@@ -421,9 +472,7 @@ declare interface RspressPlugin {
421
472
  /**
422
473
  * Extend every page's data
423
474
  */
424
- extendPageData?: (pageData: PageIndexInfo & {
425
- [key: string]: unknown;
426
- }, isProd: boolean) => void | Promise<void>;
475
+ extendPageData?: (pageData: PageIndexInfo, isProd: boolean) => void | Promise<void>;
427
476
  /**
428
477
  * Add custom route
429
478
  */
@@ -646,15 +695,15 @@ declare interface UserConfig<ThemeConfig = DefaultThemeConfig> {
646
695
  /**
647
696
  * Whether to enable language parity checking
648
697
  */
649
- enabled: boolean;
698
+ enabled?: boolean;
650
699
  /**
651
700
  * Directories to include in the parity check
652
701
  */
653
- include: string[];
702
+ include?: string[];
654
703
  /**
655
704
  * Directories to exclude from the parity check
656
705
  */
657
- exclude: string[];
706
+ exclude?: string[];
658
707
  };
659
708
  }
660
709
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-medium-zoom",
3
- "version": "1.42.0",
3
+ "version": "1.42.1-canary-20240226",
4
4
  "description": "A plugin for rspress to zoom images in docs.",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -20,22 +20,21 @@
20
20
  "module": "./dist/node/index.js",
21
21
  "types": "./dist/index.d.ts",
22
22
  "files": [
23
- "dist",
24
- "src"
23
+ "dist"
25
24
  ],
26
25
  "dependencies": {
27
26
  "medium-zoom": "1.1.0"
28
27
  },
29
28
  "devDependencies": {
30
29
  "@microsoft/api-extractor": "^7.49.2",
31
- "@modern-js/tsconfig": "2.64.0",
32
- "@rslib/core": "0.4.1",
30
+ "@rslib/core": "0.5.2",
33
31
  "@types/node": "^18.11.17",
34
32
  "@types/react": "^18.3.18",
35
33
  "@types/react-dom": "^18.3.5",
36
34
  "react": "^18.3.1",
37
35
  "typescript": "^5.5.3",
38
- "@rspress/shared": "1.42.0"
36
+ "@rspress/shared": "1.42.1-canary-20240226",
37
+ "@rspress/config": "1.0.0"
39
38
  },
40
39
  "peerDependencies": {
41
40
  "@rspress/runtime": "^1.42.0"
@@ -48,7 +47,6 @@
48
47
  "provenance": true,
49
48
  "registry": "https://registry.npmjs.org/"
50
49
  },
51
- "jsnext:source": "./src/index.ts",
52
50
  "scripts": {
53
51
  "build": "rslib build",
54
52
  "dev": "rslib build -w",
@@ -1,5 +0,0 @@
1
- /* https://github.com/francoischalifour/medium-zoom#debugging */
2
- .medium-zoom-overlay,
3
- .medium-zoom-image--opened {
4
- z-index: 999;
5
- }
@@ -1,29 +0,0 @@
1
- import { useLocation } from '@rspress/runtime';
2
- import mediumZoom, { type Zoom, type ZoomOptions } from 'medium-zoom';
3
- import { useEffect } from 'react';
4
- import './MediumZoom.css';
5
-
6
- interface Props {
7
- selector?: string;
8
- options?: ZoomOptions;
9
- }
10
-
11
- export default function MediumZoom(props: Props) {
12
- const { pathname } = useLocation();
13
- const { selector = '.rspress-doc img', options = {} } = props;
14
-
15
- useEffect(() => {
16
- let zoom: Zoom | undefined;
17
- const timeout = setTimeout(() => {
18
- const images = document.querySelectorAll(selector);
19
- zoom = mediumZoom(images, { ...options, background: 'var(--rp-c-bg)' });
20
- }, 100);
21
- return () => {
22
- clearTimeout(timeout);
23
- zoom?.detach();
24
- zoom?.close();
25
- };
26
- }, [pathname]);
27
-
28
- return null;
29
- }
package/src/env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types='@rslib/core/types' />
package/src/index.ts DELETED
@@ -1,25 +0,0 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { type RspressPlugin, normalizePosixPath } from '@rspress/shared';
4
- import type { ZoomOptions } from 'medium-zoom';
5
-
6
- interface Options {
7
- selector?: string;
8
- options?: ZoomOptions;
9
- }
10
-
11
- /**
12
- * The plugin is used to add medium-zoom to the doc site.
13
- */
14
- export function pluginMediumZoom(options: Options = {}): RspressPlugin {
15
- const __dirname = normalizePosixPath(
16
- path.dirname(fileURLToPath(import.meta.url)),
17
- );
18
-
19
- return {
20
- name: '@rspress/plugin-medium-zoom',
21
- globalUIComponents: [
22
- [path.posix.join(__dirname, '../src/components/MediumZoom.tsx'), options],
23
- ],
24
- };
25
- }