vvvfs 0.2.1 → 0.2.2

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/index.html CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  <body>
12
12
  <script src="index.js"></script>
13
+ <fs-img src="test.png" alt="Test Image"></fs-img>
13
14
  </body>
14
15
 
15
16
  </html>
package/index.ts CHANGED
@@ -4,6 +4,9 @@ import { Mime } from "mime";
4
4
  import standardTypes from "mime/types/standard.js";
5
5
  import otherTypes from "mime/types/other.js";
6
6
 
7
+ // 自定义元素 <fs-img>(直接显示 vvvfs 中的图片文件)
8
+ export { FsImg } from "./Img";
9
+
7
10
  const mime = new Mime(standardTypes, otherTypes);
8
11
 
9
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vvvfs",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "一个使用IndexDB实现的虚拟文件系统",
5
5
  "keywords": [
6
6
  "Virtual",
package/types/index.d.ts CHANGED
@@ -608,6 +608,75 @@ export class VVVFS {
608
608
  static registerMIMEType(mimetype: string, extensions: string[]): Mime;
609
609
  }
610
610
 
611
+ /**
612
+ * <fs-img> 元素 load 事件详情
613
+ */
614
+ export interface FsImgLoadDetail {
615
+ /**
616
+ * 图片路径
617
+ */
618
+ path: string;
619
+ /**
620
+ * 图片文件对象
621
+ */
622
+ file: File | null;
623
+ }
624
+
625
+ /**
626
+ * <fs-img> 元素 error 事件详情
627
+ */
628
+ export interface FsImgErrorDetail {
629
+ /**
630
+ * 图片路径
631
+ */
632
+ path: string;
633
+ /**
634
+ * 错误信息
635
+ */
636
+ message: string;
637
+ }
638
+
639
+ /**
640
+ * 自定义图片元素 <fs-img>
641
+ * @description 直接读取并显示存储在 vvvfs 中的图片文件
642
+ * @attributes
643
+ * - src / path:图片在 vvvfs 中的路径(src 优先,其次 path)
644
+ * - dbname:数据库名,默认 "vvvfs";未指定且存在全局 vvvfs 实例时直接使用该实例
645
+ * - alt / width / height:透传到内部 <img> 元素
646
+ * - watch:存在时,文件发生变化自动刷新
647
+ * @events
648
+ * - load:图片加载完成(detail: { path, file })
649
+ * - error:图片加载失败(detail: { path, message })
650
+ * @example <fs-img src="/home/user/Pictures/logo.png" alt="Logo" width="120"></fs-img>
651
+ */
652
+ export class FsImg extends HTMLElement {
653
+ /**
654
+ * 监听的属性列表
655
+ */
656
+ static get observedAttributes(): string[];
657
+ /**
658
+ * 构造函数
659
+ */
660
+ constructor();
661
+ /**
662
+ * 图片路径(src 优先,其次 path)
663
+ */
664
+ src: string;
665
+ /**
666
+ * 数据库名
667
+ */
668
+ dbname: string;
669
+ /**
670
+ * 手动刷新(重新读取并显示图片)
671
+ */
672
+ refresh(): Promise<boolean>;
673
+ /**
674
+ * 调度一次 watch 触发的刷新(内部使用)
675
+ * @internal
676
+ */
677
+ scheduleWatchRefresh(): void;
678
+ }
679
+
611
680
  /**
612
681
  * 解析路径
613
682
  * @param path 路径