vitepress-plugin-filelist 0.5.0 → 0.5.1

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/README.md CHANGED
@@ -203,7 +203,7 @@ import { fileListLocales, formatLabel, resolveLabels } from 'vitepress-plugin-fi
203
203
  | 入口 | 内容 |
204
204
  | --- | --- |
205
205
  | `vitepress-plugin-filelist` | `fileList` 插件(默认导出) |
206
- | `vitepress-plugin-filelist/client` | `FileList`、`VPFileList`、`enhanceAppWithFileList`、类型 |
206
+ | `vitepress-plugin-filelist/client` | `FileList`、`VPFileList`、`enhanceAppWithFileList`、文案工具(`fileListLocales`、`formatLabel`、`resolveLabels`)、格式与文件类型工具(`formatSize`、`formatDate`、`fileKind`、`previewKind` 等)、类型 |
207
207
  | `vitepress-plugin-filelist/style.css` | 组件样式 |
208
208
 
209
209
  ## 兼容性
@@ -237,11 +237,25 @@ Deno 可以安装 npm 依赖,但目前用 Deno 构建 VitePress 会在 rolldow
237
237
  ```bash
238
238
  pnpm install
239
239
  pnpm run build # 生成 dist/node、dist/client/ssr、dist/client/browser、style.css
240
- pnpm run typecheck
241
- pnpm test # Vitest:utils、locale helpers、FileList 组件
240
+ pnpm run typecheck # vue-tsc,包含 .vue 模板与测试
241
+ pnpm test # Vitest:工具函数、密码、下载、FileList 组件
242
242
  pnpm run pack:check
243
243
  ```
244
244
 
245
+ 源码结构(`src/client`):
246
+
247
+ | 文件 | 职责 |
248
+ | --- | --- |
249
+ | `FileList.vue` | 组件:把下列模块接到界面 |
250
+ | `api.ts` | OpenList 接口、文件地址缓存、错误判断 |
251
+ | `demo.ts` | 演示数据(与 `api.ts` 同一接口) |
252
+ | `tree.ts` | 树节点、排序、目录统计 |
253
+ | `usePasswords.ts` / `passwords.ts` | 目录密码的选择顺序 / 标签页内记住 |
254
+ | `download.ts` | 单文件下载、批量 ZIP |
255
+ | `PreviewDialog.vue` | 预览弹窗 |
256
+ | `Icon.vue` / `icons.ts` | 图标 |
257
+ | `utils.ts` | 路径、格式化、文件类型表 |
258
+
245
259
  仓库统一使用 pnpm(`pnpm-lock.yaml`),CI 与发布流程执行 `pnpm install --frozen-lockfile`。
246
260
 
247
261
  `demo/` 下的演示站通过 `file:..` 安装本地包:
@@ -18,6 +18,8 @@ interface FileListLabels {
18
18
  loading: string;
19
19
  loadFailed: string;
20
20
  guestHint: string;
21
+ /** Shown (and appended to toasts) for browser network errors, usually CORS. */
22
+ /** Shown (and appended to toasts) for browser network errors, usually CORS. */
21
23
  corsHint: string;
22
24
  retry: string;
23
25
  empty: string;
@@ -75,7 +77,7 @@ interface FileListLabels {
75
77
  /** Refresh failed; the old rows stay. `{message}` */
76
78
  refreshFailed: string;
77
79
  cancel: string;
78
- /** Placeholder / accessible name of a folder's password input. `{name}` */
80
+ /** Accessible name of a folder's password input. `{name}` */
79
81
  passwordFor: string;
80
82
  /** OpenList cannot tell a wrong password from missing permission. */
81
83
  passwordWrong: string;
@@ -88,7 +90,7 @@ interface FileListLabels {
88
90
  forgetPassword: string;
89
91
  /** Lock button on a folder that needs a password. `{name}` */
90
92
  unlockFolder: string;
91
- /** Appended to failure toasts for browser network errors (usually CORS). */
93
+ /** @deprecated Network failures now append `corsHint`. */
92
94
  networkHint: string;
93
95
  }
94
96
  interface FileListSource {
@@ -225,13 +227,13 @@ declare global {
225
227
  export declare const fileListLocales: Record<FileListLocale, FileListLabels>;
226
228
  export declare function formatLabel(template: string, values?: Record<string, string | number>): string;
227
229
  export declare function resolveLabels(locale?: FileListLocale, overrides?: Partial<FileListLabels>): FileListLabels;
228
- export interface SortableNode {
230
+ interface SortableNode {
229
231
  name: string;
230
232
  size: number;
231
233
  is_dir: boolean;
232
234
  modified: string;
233
235
  }
234
- export type SortKey = 'name' | 'size' | 'modified';
236
+ type SortKey = 'name' | 'size' | 'modified';
235
237
  export declare function joinPath(parent: string, name: string): string;
236
238
  export declare function encodePath(path: string): string;
237
239
  /**
@@ -246,24 +248,26 @@ export declare function zipEntryName(segments: string[]): string;
246
248
  * The suffix goes before the extension of the last segment. Adds the result to `used`.
247
249
  */
248
250
  export declare function uniqueEntryName(name: string, used: Set<string>): string;
251
+ /** Human-readable size. `0` reads `0 B`; missing, negative or invalid sizes read `-`. */
249
252
  export declare function formatSize(size: number): string;
250
253
  export declare function formatDate(iso: string): string;
254
+ /** Upper-case extension for the type badge, e.g. `PDF`. */
251
255
  export declare function extOf(name: string): string;
252
- export type FileKind = 'doc' | 'sheet' | 'slide' | 'pdf' | 'image' | 'media' | 'archive' | 'code' | 'other';
256
+ type FileKind = 'doc' | 'sheet' | 'slide' | 'pdf' | 'image' | 'media' | 'archive' | 'code' | 'other';
257
+ type PreviewKind = 'image' | 'video' | 'audio' | 'text' | 'pdf' | 'none';
253
258
  /** Rough file family, used to colour the type badge. */
254
259
  export declare function fileKind(name: string): FileKind;
255
- /** Sum of the `size` of the given entries, ignoring missing or invalid sizes. */
256
- export declare function totalSize(items: Array<{
257
- size?: number;
258
- }>): number;
259
- export declare function compareNodes(a: SortableNode, b: SortableNode, key: SortKey, ascending?: boolean): number;
260
- export type PreviewKind = 'image' | 'video' | 'audio' | 'text' | 'pdf' | 'none';
261
260
  /**
262
261
  * How a file is shown in the preview dialog. Office documents and anything
263
262
  * else the browser cannot render are `none` (info + download).
264
263
  */
265
264
  export declare function previewKind(name: string): PreviewKind;
266
- export interface IframePreview {
265
+ /** Sum of the `size` of the given entries, ignoring missing or invalid sizes. */
266
+ export declare function totalSize(items: Array<{
267
+ size?: number;
268
+ }>): number;
269
+ export declare function compareNodes(a: SortableNode, b: SortableNode, key: SortKey, ascending?: boolean): number;
270
+ interface IframePreview {
267
271
  label: string;
268
272
  scheme: string;
269
273
  }
@@ -300,4 +304,4 @@ export declare function fillPreviewUrl(scheme: string, args: {
300
304
  * ```
301
305
  */
302
306
  export declare function enhanceAppWithFileList({ app }: EnhanceAppContext): void;
303
- export { _default as FileList, _default as VPFileList, type FileListLabels, type FileListLocale, type FileListProps, type FileListSource, type OpenListEntry };
307
+ export { type FileKind, _default as FileList, _default as VPFileList, type FileListLabels, type FileListLocale, type FileListProps, type FileListSource, type IframePreview, type OpenListEntry, type PreviewKind, type SortKey, type SortableNode };