vvvfs 0.2.1 → 0.2.3

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
@@ -4,6 +4,14 @@
4
4
 
5
5
  GitHub仓库: https://github.com/IFTC-XLKJ/vvvfs
6
6
 
7
+ ## 赞助
8
+
9
+ 如果这个项目对你有帮助,欢迎通过爱发电支持我们:
10
+
11
+ [![爱发电](https://img.shields.io/badge/爱发电-支持我们-ff69b4.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBmaWxsPSIjZmY2OWI0IiBkPSJNOCAxNS41cy03LTQuNS03LTkgQTEuNSAxLjUgMCAwIDAgOCAwYTEuNSAxLjUgMCAwIDAgNyA2LjVjMCA0LjUtNyA5LTcgOXoiLz48L3N2Zz4=)](https://afdian.com/a/IFTCCEO)
12
+
13
+ **爱发电主页:** https://afdian.com/a/IFTCCEO
14
+
7
15
  ## 快速开始
8
16
 
9
17
  1. 安装依赖
@@ -94,8 +102,57 @@ const vvvfs = new VVVFS("vvvfs", {
94
102
  // 用法与 vvvfs 相当
95
103
  ```
96
104
 
105
+ ### 使用 `<fs-img>` / `<fs-audio>` / `<fs-video>` 自定义元素
106
+
107
+ 库加载后会自动注册这三个元素,可直接显示 / 播放 vvvfs 中的媒体文件:
108
+
109
+ ```html
110
+ <fs-img src="/home/user/Pictures/logo.png" alt="Logo" width="120"></fs-img>
111
+ <fs-audio src="/home/user/Music/demo.mp3"></fs-audio>
112
+ <fs-video src="/home/user/Videos/demo.mp4" width="320"></fs-video>
113
+ ```
114
+
115
+ ```javascript
116
+ // 也可通过 JS 动态创建
117
+ const img = document.createElement("fs-img");
118
+ img.src = "/home/user/Pictures/logo.png";
119
+ document.body.appendChild(img);
120
+ ```
121
+
122
+ 三者共有的属性:
123
+
124
+ - `src` / `path`:文件在 vvvfs 中的路径(`src` 优先)
125
+ - `dbname`:数据库名,默认 `vvvfs`;未指定且存在全局 `vvvfs` 实例时直接使用该实例
126
+ - `watch`:`true` 时启用文件监听,`false` 时停止监听;启用后文件内容发生变化会自动刷新(缺省或空值视为 `true`,兼容 `<fs-img watch>` 的写法)
127
+
128
+ 各自的属性:
129
+
130
+ - `<fs-img>`:`alt` / `width` / `height` 透传到内部 `<img>` 元素
131
+ - `<fs-audio>`:`autoplay` / `loop` / `muted` / `preload` 透传到内部 `<audio>` 元素;`controls` 默认开启,移除该属性即可关闭
132
+ - `<fs-video>`:`autoplay` / `loop` / `muted` / `preload` / `width` / `height` 透传到内部 `<video>` 元素;`controls` 默认开启,移除该属性即可关闭
133
+
134
+ 事件:`load`(加载完成)、`error`(加载失败),`detail` 中包含 `path` 与 `file`(或 `message`)。元素上还会写入 `data-state` 属性(`loading` / `loaded` / `error`),便于 CSS 定制。
135
+
136
+ 此外提供 `data` 属性(JS 属性),返回当前媒体文件的 Blob 对象(未加载或加载失败时为 `null`),可用于上传、二次处理等场景。
137
+
138
+ 内部使用 Shadow DOM 渲染:媒体元素分别暴露为 `part="img"` / `part="audio"` / `part="video"`,可用 `fs-img::part(img) { ... }` 等定制样式;默认插槽内容会在加载失败或未设置路径时显示(如 `<fs-audio src="/a.mp3">加载失败</fs-audio>`)。
139
+
97
140
  ## 更新日志
98
141
 
142
+ ### 0.2.3
143
+
144
+ - 新增 `<fs-audio>` 自定义元素,可直接播放 vvvfs 中的音频文件
145
+ - 新增 `<fs-video>` 自定义元素,可直接播放 vvvfs 中的视频文件
146
+ - `<fs-img>` / `<fs-audio>` / `<fs-video>` 新增 `data` 属性,返回当前媒体文件的 Blob 对象(未加载时为 `null`)
147
+ - `<fs-img>` / `<fs-audio>` / `<fs-video>` 的 `watch` 属性支持 `true` / `false`,为 `false` 时停止文件监听
148
+
149
+ ### 0.2.2
150
+
151
+ - 新增 `<fs-img>` 自定义元素,可直接显示 vvvfs 中的图片文件
152
+ - `<fs-img>` 新增 `src` / `path` / `dbname` / `alt` / `width` / `height` / `watch` 属性
153
+ - `<fs-img>` 新增 `load` / `error` 事件与 `data-state` 状态属性
154
+ - `<fs-img>` 使用 Shadow DOM 渲染,支持 `::part(img)` 样式定制与默认插槽回退内容
155
+
99
156
  ### 0.2.1
100
157
 
101
158
  - 新增 `setHide` 方法,用于设置文件或文件夹的隐藏属性
@@ -199,6 +256,14 @@ A lightweight and simple Linux virtual file system in the browser, based on Inde
199
256
 
200
257
  GitHub repository: https://github.com/IFTC-XLKJ/vvvfs
201
258
 
259
+ ## Sponsor
260
+
261
+ If this project is helpful to you, please consider supporting us on Afdian:
262
+
263
+ [![Afdian](https://img.shields.io/badge/Afdian-Support%20us-ff69b4.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBmaWxsPSIjZmY2OWI0IiBkPSJNOCAxNS41cy03LTQuNS03LTkgQTEuNSAxLjUgMCAwIDAgOCAwYTEuNSAxLjUgMCAwIDAgNyA2LjVjMCA0LjUtNyA5LTcgOXoiLz48L3N2Zz4=)](https://afdian.com/a/IFTCCEO)
264
+
265
+ **Afdian homepage:** https://afdian.com/a/IFTCCEO
266
+
202
267
  ## Quick Start
203
268
 
204
269
  1. Install the dependency
@@ -288,8 +353,57 @@ Using the `VVVFS.File` class:
288
353
  // The usage is equivalent to vvvfs
289
354
  ```
290
355
 
356
+ ### Using the `<fs-img>` / `<fs-audio>` / `<fs-video>` Custom Elements
357
+
358
+ Once the library is loaded, these three elements are registered automatically and can display / play media files stored in vvvfs directly:
359
+
360
+ ```html
361
+ <fs-img src="/home/user/Pictures/logo.png" alt="Logo" width="120"></fs-img>
362
+ <fs-audio src="/home/user/Music/demo.mp3"></fs-audio>
363
+ <fs-video src="/home/user/Videos/demo.mp4" width="320"></fs-video>
364
+ ```
365
+
366
+ ```javascript
367
+ // They can also be created dynamically
368
+ const img = document.createElement("fs-img");
369
+ img.src = "/home/user/Pictures/logo.png";
370
+ document.body.appendChild(img);
371
+ ```
372
+
373
+ Attributes shared by all three:
374
+
375
+ - `src` / `path`: path of the file inside vvvfs (`src` takes precedence)
376
+ - `dbname`: database name, defaults to `vvvfs`; when omitted and a global `vvvfs` instance exists, that instance is used directly
377
+ - `watch`: `true` enables file watching and `false` disables it; when enabled, the media is refreshed automatically after the file content changes (a missing or empty value is treated as `true`, for compatibility with `<fs-img watch>`)
378
+
379
+ Element-specific attributes:
380
+
381
+ - `<fs-img>`: `alt` / `width` / `height` are passed through to the inner `<img>` element
382
+ - `<fs-audio>`: `autoplay` / `loop` / `muted` / `preload` are passed through to the inner `<audio>` element; `controls` is enabled by default and can be turned off by removing the attribute
383
+ - `<fs-video>`: `autoplay` / `loop` / `muted` / `preload` / `width` / `height` are passed through to the inner `<video>` element; `controls` is enabled by default and can be turned off by removing the attribute
384
+
385
+ Events: `load` (media loaded) and `error` (loading failed); `detail` contains `path` plus `file` (or `message`). A `data-state` attribute (`loading` / `loaded` / `error`) is also written to the element for CSS customization.
386
+
387
+ A `data` property (JS property) is also available, returning the Blob object of the current media file (`null` before loading or after a failure), which is useful for uploading or further processing.
388
+
389
+ Rendering happens inside a Shadow DOM: the media element is exposed as `part="img"` / `part="audio"` / `part="video"`, so it can be styled with `fs-img::part(img) { ... }` and friends; the default slot content is shown when loading fails or no path is set (e.g. `<fs-audio src="/a.mp3">failed</fs-audio>`).
390
+
291
391
  ## Changelog
292
392
 
393
+ ### 0.2.3
394
+
395
+ - Added the `<fs-audio>` custom element to play audio files stored in vvvfs directly
396
+ - Added the `<fs-video>` custom element to play video files stored in vvvfs directly
397
+ - Added the `data` property to `<fs-img>` / `<fs-audio>` / `<fs-video>`, returning the Blob object of the current media file (`null` before loading)
398
+ - The `watch` attribute of `<fs-img>` / `<fs-audio>` / `<fs-video>` now accepts `true` / `false`; `false` stops the file watching
399
+
400
+ ### 0.2.2
401
+
402
+ - Added the `<fs-img>` custom element to display image files stored in vvvfs directly
403
+ - Added the `src` / `path` / `dbname` / `alt` / `width` / `height` / `watch` attributes to `<fs-img>`
404
+ - Added the `load` / `error` events and the `data-state` attribute to `<fs-img>`
405
+ - `<fs-img>` renders inside a Shadow DOM, supporting `::part(img)` styling and a default slot fallback
406
+
293
407
  ### 0.2.1
294
408
 
295
409
  - Added the `setHide` method to set the hidden attribute of a file or directory