ddan-js 3.7.0 → 3.8.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.
@@ -0,0 +1,41 @@
1
+ type ElementObserverCallbacks = {
2
+ onAppear?: (el: Element) => void;
3
+ onDisappear?: (el: Element) => void;
4
+ onClick?: (el: Element, ev: MouseEvent) => void;
5
+ };
6
+ type ObserveOptions = {
7
+ root?: Element;
8
+ childList?: boolean;
9
+ subtree?: boolean;
10
+ };
11
+ export declare class ElementObserver {
12
+ private callbacks;
13
+ private selector;
14
+ private observer;
15
+ private elementsSeen;
16
+ private clickHandlers;
17
+ private isObserving;
18
+ private root;
19
+ constructor(callbacks?: ElementObserverCallbacks);
20
+ /** 初始化 MutationObserver */
21
+ private initObserver;
22
+ private collectAdded;
23
+ private collectRemoved;
24
+ /** 触发回调 */
25
+ private triggerCallback;
26
+ /** 点击事件绑定 */
27
+ private bindClick;
28
+ /** 点击事件解绑 */
29
+ private unbindClick;
30
+ /** 开始观察 */
31
+ observe(selector: string, options?: ObserveOptions): void;
32
+ /** 动态修改 selector */
33
+ updateObserver(selector?: string): boolean;
34
+ /** 停止观察 */
35
+ disconnect(): void;
36
+ /** 更新回调函数 */
37
+ updateCallbacks(callbacks: ElementObserverCallbacks): void;
38
+ /** 销毁实例 */
39
+ destroy(): void;
40
+ }
41
+ export {};
@@ -1,3 +1,4 @@
1
+ import { ElementObserver } from "./elementObserver";
1
2
  declare const _default: {
2
3
  dataURLtoFile: (dataurl: any, filename: any) => File;
3
4
  dataURLtoBlob: (dataurl: any) => Blob;
@@ -33,5 +34,14 @@ declare const _default: {
33
34
  width: number;
34
35
  height: number;
35
36
  }>;
37
+ ElementObserver: typeof ElementObserver;
38
+ watchTextChange: (element: HTMLElement, callback: (newText: string, oldText: string) => void) => (() => void) | undefined;
39
+ watchAttrChange: typeof import("./watch").watchAttrChange;
40
+ watchElementChange: (element: Element | null, options?: {
41
+ onText?: ((newText: string, oldText: string) => void) | undefined;
42
+ onAttr?: ((name: string, newValue: string | null, oldValue: string | null) => void) | undefined;
43
+ attrFilter?: string[] | null | undefined;
44
+ } | undefined) => (() => void) | undefined;
45
+ waitForElement: (selector: string, timeout?: number) => Promise<Element | null>;
36
46
  };
37
47
  export default _default;
@@ -0,0 +1,28 @@
1
+ /**
2
+ *
3
+ * @param element
4
+ * @param callback
5
+ * @returns
6
+ */
7
+ declare function watchTextChange(element: HTMLElement, callback: (newText: string, oldText: string) => void): (() => void) | undefined;
8
+ /**
9
+ *
10
+ * @param element
11
+ * @param callback
12
+ * @param attrs
13
+ * @returns
14
+ */
15
+ export declare function watchAttrChange(element: HTMLElement | null | undefined, callback: (attrName: string, newValue: string | null, oldValue: string | null) => void, attrs?: string[]): (() => void) | undefined;
16
+ declare function watchElementChange(element: Element | null, options?: {
17
+ onText?: (newText: string, oldText: string) => void;
18
+ onAttr?: (name: string, newValue: string | null, oldValue: string | null) => void;
19
+ attrFilter?: string[] | null;
20
+ }): (() => void) | undefined;
21
+ declare function waitForElement(selector: string, timeout?: number): Promise<Element | null>;
22
+ declare const _default: {
23
+ watchTextChange: typeof watchTextChange;
24
+ watchAttrChange: typeof watchAttrChange;
25
+ watchElementChange: typeof watchElementChange;
26
+ waitForElement: typeof waitForElement;
27
+ };
28
+ export default _default;
@@ -118,6 +118,15 @@ declare const dMini: {
118
118
  width: number;
119
119
  height: number;
120
120
  }>;
121
+ ElementObserver: typeof import("../modules/html/elementObserver").ElementObserver;
122
+ watchTextChange: (element: HTMLElement, callback: (newText: string, oldText: string) => void) => (() => void) | undefined;
123
+ watchAttrChange: typeof import("../modules/html/watch").watchAttrChange;
124
+ watchElementChange: (element: Element | null, options?: {
125
+ onText?: ((newText: string, oldText: string) => void) | undefined;
126
+ onAttr?: ((name: string, newValue: string | null, oldValue: string | null) => void) | undefined;
127
+ attrFilter?: string[] | null | undefined;
128
+ } | undefined) => (() => void) | undefined;
129
+ waitForElement: (selector: string, timeout?: number) => Promise<Element | null>;
121
130
  };
122
131
  };
123
132
  export default dMini;
package/bin/tiny/web.d.ts CHANGED
@@ -150,6 +150,15 @@ declare const dWeb: {
150
150
  width: number;
151
151
  height: number;
152
152
  }>;
153
+ ElementObserver: typeof import("../modules/html/elementObserver").ElementObserver;
154
+ watchTextChange: (element: HTMLElement, callback: (newText: string, oldText: string) => void) => (() => void) | undefined;
155
+ watchAttrChange: typeof import("../modules/html/watch").watchAttrChange;
156
+ watchElementChange: (element: Element | null, options?: {
157
+ onText?: ((newText: string, oldText: string) => void) | undefined;
158
+ onAttr?: ((name: string, newValue: string | null, oldValue: string | null) => void) | undefined;
159
+ attrFilter?: string[] | null | undefined;
160
+ } | undefined) => (() => void) | undefined;
161
+ waitForElement: (selector: string, timeout?: number) => Promise<Element | null>;
153
162
  };
154
163
  rsa: {
155
164
  generateKeys: () => Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",
@@ -19,14 +19,17 @@
19
19
  ],
20
20
  "main": "bin/ddan-js.js",
21
21
  "module": "bin/ddan-js.mjs",
22
- "browser": "bin/ddan-js.browser.js",
22
+ "browser": "bin/ddan-browser.js",
23
23
  "types": "bin/index.d.ts",
24
24
  "exports": {
25
25
  ".": {
26
26
  "types": "./bin/index.d.ts",
27
27
  "import": "./bin/ddan-js.mjs",
28
28
  "require": "./bin/ddan-js.js",
29
- "browser": "./bin/ddan-js.browser.js"
29
+ "browser": {
30
+ "import": "./bin/ddan-browser.mjs",
31
+ "require": "./bin/ddan-browser.js"
32
+ }
30
33
  },
31
34
  "./upload": {
32
35
  "types": "./bin/upload.d.ts",