ddan-js 3.7.0 → 3.8.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/bin/ddan-browser.js +1 -0
- package/bin/{ddan-js.browser.js → ddan-browser.mjs} +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/ddan-js.mjs +1 -1
- package/bin/modules/html/elementObserver.d.ts +43 -0
- package/bin/modules/{html.d.ts → html/index.d.ts} +10 -0
- package/bin/modules/html/watch.d.ts +28 -0
- package/bin/tiny/mini.d.ts +9 -0
- package/bin/tiny/web.d.ts +9 -0
- package/package.json +6 -3
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
deep?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class ElementObserver {
|
|
13
|
+
private callbacks;
|
|
14
|
+
private selector;
|
|
15
|
+
private observer;
|
|
16
|
+
private elementsSeen;
|
|
17
|
+
private clickHandlers;
|
|
18
|
+
private isObserving;
|
|
19
|
+
private deep;
|
|
20
|
+
private root;
|
|
21
|
+
constructor(callbacks?: ElementObserverCallbacks);
|
|
22
|
+
/** 初始化 MutationObserver */
|
|
23
|
+
private initObserver;
|
|
24
|
+
private collectAdded;
|
|
25
|
+
private collectRemoved;
|
|
26
|
+
/** 触发回调 */
|
|
27
|
+
private triggerCallback;
|
|
28
|
+
/** 点击事件绑定 */
|
|
29
|
+
private bindClick;
|
|
30
|
+
/** 点击事件解绑 */
|
|
31
|
+
private unbindClick;
|
|
32
|
+
/** 开始观察 */
|
|
33
|
+
observe(selector: string, options?: ObserveOptions): void;
|
|
34
|
+
/** 动态修改 selector */
|
|
35
|
+
updateObserver(selector?: string, deep?: boolean): void;
|
|
36
|
+
/** 停止观察 */
|
|
37
|
+
disconnect(): void;
|
|
38
|
+
/** 更新回调函数 */
|
|
39
|
+
updateCallbacks(callbacks: ElementObserverCallbacks): void;
|
|
40
|
+
/** 销毁实例 */
|
|
41
|
+
destroy(): void;
|
|
42
|
+
}
|
|
43
|
+
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;
|
package/bin/tiny/mini.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "3.8.1",
|
|
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-
|
|
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":
|
|
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",
|