@domql/event 3.0.7 → 3.1.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/animationFrame.js +16 -7
- package/dist/cjs/animationFrame.js +10 -9
- package/dist/cjs/globals.js +30 -0
- package/dist/cjs/keys.js +178 -0
- package/dist/cjs/node.js +35 -0
- package/dist/cjs/on.js +6 -5
- package/dist/cjs/types.js +82 -0
- package/dist/esm/animationFrame.js +10 -9
- package/dist/esm/globals.js +10 -0
- package/dist/esm/keys.js +158 -0
- package/dist/esm/node.js +15 -0
- package/dist/esm/on.js +2 -1
- package/dist/esm/types.js +62 -0
- package/globals.js +8 -0
- package/keys.js +157 -0
- package/node.js +37 -0
- package/on.js +2 -1
- package/package.json +5 -5
- package/types.js +72 -0
package/animationFrame.js
CHANGED
|
@@ -27,10 +27,12 @@ export const applyAnimationFrame = element => {
|
|
|
27
27
|
if (!element) {
|
|
28
28
|
throw new Error('Element is invalid')
|
|
29
29
|
}
|
|
30
|
-
const {
|
|
30
|
+
const { on, props, __ref: ref } = element
|
|
31
31
|
if (!ref.root || !ref.root.data) return
|
|
32
32
|
const { frameListeners } = ref.root.data
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
// Register if any of the frame handlers exists
|
|
35
|
+
if (frameListeners && (on?.frame || element.onFrame || props?.onFrame)) {
|
|
34
36
|
registerFrameListener(element)
|
|
35
37
|
}
|
|
36
38
|
}
|
|
@@ -45,11 +47,18 @@ export const initAnimationFrame = () => {
|
|
|
45
47
|
frameListeners.delete(element) // Remove if node has no parent
|
|
46
48
|
} else {
|
|
47
49
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
element.state,
|
|
51
|
-
|
|
52
|
-
)
|
|
50
|
+
// First try to use on.frame if available
|
|
51
|
+
if (element.on?.frame) {
|
|
52
|
+
element.on.frame(element, element.state, element.context)
|
|
53
|
+
}
|
|
54
|
+
// Then try element.onFrame (direct property)
|
|
55
|
+
else if (element.onFrame) {
|
|
56
|
+
element.onFrame(element, element.state, element.context)
|
|
57
|
+
}
|
|
58
|
+
// Lastly check props.onFrame
|
|
59
|
+
else if (element.props?.onFrame) {
|
|
60
|
+
element.props.onFrame(element, element.state, element.context)
|
|
61
|
+
}
|
|
53
62
|
} catch (e) {
|
|
54
63
|
console.warn(e)
|
|
55
64
|
}
|
|
@@ -43,28 +43,29 @@ const applyAnimationFrame = (element) => {
|
|
|
43
43
|
if (!element) {
|
|
44
44
|
throw new Error("Element is invalid");
|
|
45
45
|
}
|
|
46
|
-
const {
|
|
46
|
+
const { on, props, __ref: ref } = element;
|
|
47
47
|
if (!ref.root || !ref.root.data) return;
|
|
48
48
|
const { frameListeners } = ref.root.data;
|
|
49
|
-
if (frameListeners && ((on == null ? void 0 : on.frame) || (props == null ? void 0 : props.onFrame))) {
|
|
49
|
+
if (frameListeners && ((on == null ? void 0 : on.frame) || element.onFrame || (props == null ? void 0 : props.onFrame))) {
|
|
50
50
|
registerFrameListener(element);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
const initAnimationFrame = () => {
|
|
54
54
|
const frameListeners = /* @__PURE__ */ new Set();
|
|
55
55
|
function requestFrame() {
|
|
56
|
-
var _a;
|
|
56
|
+
var _a, _b;
|
|
57
57
|
for (const element of frameListeners) {
|
|
58
58
|
if (!element.parent.node.contains(element.node)) {
|
|
59
59
|
frameListeners.delete(element);
|
|
60
60
|
} else {
|
|
61
61
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
element.state,
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
if ((_a = element.on) == null ? void 0 : _a.frame) {
|
|
63
|
+
element.on.frame(element, element.state, element.context);
|
|
64
|
+
} else if (element.onFrame) {
|
|
65
|
+
element.onFrame(element, element.state, element.context);
|
|
66
|
+
} else if ((_b = element.props) == null ? void 0 : _b.onFrame) {
|
|
67
|
+
element.props.onFrame(element, element.state, element.context);
|
|
68
|
+
}
|
|
68
69
|
} catch (e) {
|
|
69
70
|
console.warn(e);
|
|
70
71
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var globals_exports = {};
|
|
20
|
+
__export(globals_exports, {
|
|
21
|
+
document: () => document,
|
|
22
|
+
global: () => global,
|
|
23
|
+
self: () => self,
|
|
24
|
+
window: () => window
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(globals_exports);
|
|
27
|
+
const global = globalThis;
|
|
28
|
+
const self = globalThis;
|
|
29
|
+
const window = globalThis;
|
|
30
|
+
const document = window.document;
|
package/dist/cjs/keys.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var keys_exports = {};
|
|
20
|
+
__export(keys_exports, {
|
|
21
|
+
DOMQL_EVENTS: () => DOMQL_EVENTS,
|
|
22
|
+
DOMQ_PROPERTIES: () => DOMQ_PROPERTIES,
|
|
23
|
+
METHODS: () => METHODS,
|
|
24
|
+
METHODS_EXL: () => METHODS_EXL,
|
|
25
|
+
PARSED_DOMQ_PROPERTIES: () => PARSED_DOMQ_PROPERTIES,
|
|
26
|
+
PROPS_METHODS: () => PROPS_METHODS,
|
|
27
|
+
STATE_METHODS: () => STATE_METHODS,
|
|
28
|
+
STATE_PROPERTIES: () => STATE_PROPERTIES
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(keys_exports);
|
|
31
|
+
const DOMQ_PROPERTIES = [
|
|
32
|
+
"attr",
|
|
33
|
+
"style",
|
|
34
|
+
"text",
|
|
35
|
+
"html",
|
|
36
|
+
"content",
|
|
37
|
+
"data",
|
|
38
|
+
"classlist",
|
|
39
|
+
"state",
|
|
40
|
+
"scope",
|
|
41
|
+
"deps",
|
|
42
|
+
"extends",
|
|
43
|
+
"$router",
|
|
44
|
+
"routes",
|
|
45
|
+
"children",
|
|
46
|
+
"childExtends",
|
|
47
|
+
"childExtendsRecursive",
|
|
48
|
+
"props",
|
|
49
|
+
"if",
|
|
50
|
+
"define",
|
|
51
|
+
"__name",
|
|
52
|
+
"__ref",
|
|
53
|
+
"__hash",
|
|
54
|
+
"__text",
|
|
55
|
+
"key",
|
|
56
|
+
"tag",
|
|
57
|
+
"query",
|
|
58
|
+
"parent",
|
|
59
|
+
"node",
|
|
60
|
+
"variables",
|
|
61
|
+
"on",
|
|
62
|
+
"component",
|
|
63
|
+
"context"
|
|
64
|
+
];
|
|
65
|
+
const PARSED_DOMQ_PROPERTIES = [
|
|
66
|
+
"attr",
|
|
67
|
+
"style",
|
|
68
|
+
"text",
|
|
69
|
+
"html",
|
|
70
|
+
"content",
|
|
71
|
+
"data",
|
|
72
|
+
"class",
|
|
73
|
+
"state",
|
|
74
|
+
"scope",
|
|
75
|
+
"children",
|
|
76
|
+
"props",
|
|
77
|
+
"if",
|
|
78
|
+
"key",
|
|
79
|
+
"tag",
|
|
80
|
+
"query",
|
|
81
|
+
"on",
|
|
82
|
+
"context"
|
|
83
|
+
];
|
|
84
|
+
const STATE_PROPERTIES = [
|
|
85
|
+
"ref",
|
|
86
|
+
"parent",
|
|
87
|
+
"__element",
|
|
88
|
+
"__depends",
|
|
89
|
+
"__ref",
|
|
90
|
+
"__children",
|
|
91
|
+
"root"
|
|
92
|
+
];
|
|
93
|
+
const STATE_METHODS = [
|
|
94
|
+
"update",
|
|
95
|
+
"parse",
|
|
96
|
+
"clean",
|
|
97
|
+
"create",
|
|
98
|
+
"destroy",
|
|
99
|
+
"add",
|
|
100
|
+
"toggle",
|
|
101
|
+
"remove",
|
|
102
|
+
"apply",
|
|
103
|
+
"set",
|
|
104
|
+
"reset",
|
|
105
|
+
"replace",
|
|
106
|
+
"quietReplace",
|
|
107
|
+
"quietUpdate",
|
|
108
|
+
"applyReplace",
|
|
109
|
+
"applyFunction",
|
|
110
|
+
"keys",
|
|
111
|
+
"values",
|
|
112
|
+
"ref",
|
|
113
|
+
"rootUpdate",
|
|
114
|
+
"parentUpdate",
|
|
115
|
+
"parent",
|
|
116
|
+
"__element",
|
|
117
|
+
"__depends",
|
|
118
|
+
"__ref",
|
|
119
|
+
"__children",
|
|
120
|
+
"root",
|
|
121
|
+
"setByPath",
|
|
122
|
+
"setPathCollection",
|
|
123
|
+
"removeByPath",
|
|
124
|
+
"removePathCollection",
|
|
125
|
+
"getByPath"
|
|
126
|
+
];
|
|
127
|
+
const PROPS_METHODS = ["update", "__element"];
|
|
128
|
+
const METHODS = [
|
|
129
|
+
"set",
|
|
130
|
+
"reset",
|
|
131
|
+
"update",
|
|
132
|
+
"remove",
|
|
133
|
+
"updateContent",
|
|
134
|
+
"removeContent",
|
|
135
|
+
"lookup",
|
|
136
|
+
"lookdown",
|
|
137
|
+
"lookdownAll",
|
|
138
|
+
"getRef",
|
|
139
|
+
"getPath",
|
|
140
|
+
"setNodeStyles",
|
|
141
|
+
"spotByPath",
|
|
142
|
+
"keys",
|
|
143
|
+
"parse",
|
|
144
|
+
"setProps",
|
|
145
|
+
"parseDeep",
|
|
146
|
+
"variables",
|
|
147
|
+
"if",
|
|
148
|
+
"log",
|
|
149
|
+
"verbose",
|
|
150
|
+
"warn",
|
|
151
|
+
"error",
|
|
152
|
+
"call",
|
|
153
|
+
"nextElement",
|
|
154
|
+
"previousElement"
|
|
155
|
+
];
|
|
156
|
+
const METHODS_EXL = [
|
|
157
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
158
|
+
...METHODS,
|
|
159
|
+
...STATE_METHODS,
|
|
160
|
+
...PROPS_METHODS
|
|
161
|
+
];
|
|
162
|
+
const DOMQL_EVENTS = [
|
|
163
|
+
"init",
|
|
164
|
+
"beforeClassAssign",
|
|
165
|
+
"render",
|
|
166
|
+
"renderRouter",
|
|
167
|
+
"attachNode",
|
|
168
|
+
"stateInit",
|
|
169
|
+
"stateCreated",
|
|
170
|
+
"beforeStateUpdate",
|
|
171
|
+
"stateUpdate",
|
|
172
|
+
"beforeUpdate",
|
|
173
|
+
"done",
|
|
174
|
+
"create",
|
|
175
|
+
"complete",
|
|
176
|
+
"frame",
|
|
177
|
+
"update"
|
|
178
|
+
];
|
package/dist/cjs/node.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var node_exports = {};
|
|
20
|
+
__export(node_exports, {
|
|
21
|
+
isDOMNode: () => isDOMNode,
|
|
22
|
+
isHtmlElement: () => isHtmlElement,
|
|
23
|
+
isNode: () => isNode
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(node_exports);
|
|
26
|
+
var import_globals = require("./globals.js");
|
|
27
|
+
const isNode = (obj) => {
|
|
28
|
+
return (typeof Node === "object" ? obj instanceof import_globals.window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
|
|
29
|
+
};
|
|
30
|
+
const isHtmlElement = (obj) => {
|
|
31
|
+
return (typeof HTMLElement === "object" ? obj instanceof import_globals.window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
|
|
32
|
+
};
|
|
33
|
+
const isDOMNode = (obj) => {
|
|
34
|
+
return typeof import_globals.window !== "undefined" && (obj instanceof import_globals.window.Node || obj instanceof import_globals.window.Window || obj === import_globals.window || obj === document);
|
|
35
|
+
};
|
package/dist/cjs/on.js
CHANGED
|
@@ -25,7 +25,8 @@ __export(on_exports, {
|
|
|
25
25
|
triggerEventOnUpdate: () => triggerEventOnUpdate
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(on_exports);
|
|
28
|
-
var
|
|
28
|
+
var import_keys = require("./keys.js");
|
|
29
|
+
var import_types = require("./types.js");
|
|
29
30
|
const getOnOrPropsEvent = (param, element) => {
|
|
30
31
|
var _a, _b;
|
|
31
32
|
const onEvent = (_a = element.on) == null ? void 0 : _a[param];
|
|
@@ -33,7 +34,7 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
33
34
|
return onEvent || onPropEvent;
|
|
34
35
|
};
|
|
35
36
|
const applyEvent = async (param, element, state, context, options) => {
|
|
36
|
-
if (!(0,
|
|
37
|
+
if (!(0, import_types.isFunction)(param)) return;
|
|
37
38
|
return await param.call(
|
|
38
39
|
element,
|
|
39
40
|
element,
|
|
@@ -53,7 +54,7 @@ const triggerEventOn = async (param, element, options) => {
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
const applyEventUpdate = async (param, updatedObj, element, state, context, options) => {
|
|
56
|
-
if (!(0,
|
|
57
|
+
if (!(0, import_types.isFunction)(param)) return;
|
|
57
58
|
return await param.call(
|
|
58
59
|
element,
|
|
59
60
|
updatedObj,
|
|
@@ -80,9 +81,9 @@ const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
|
|
|
80
81
|
const applyEventsOnNode = (element, options) => {
|
|
81
82
|
const { node, on } = element;
|
|
82
83
|
for (const param in on) {
|
|
83
|
-
if (
|
|
84
|
+
if (import_keys.DOMQL_EVENTS.includes(param)) continue;
|
|
84
85
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
85
|
-
if ((0,
|
|
86
|
+
if ((0, import_types.isFunction)(appliedFunction)) {
|
|
86
87
|
node.addEventListener(param, async (event) => {
|
|
87
88
|
const { state, context } = element;
|
|
88
89
|
await appliedFunction.call(
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
TYPES: () => TYPES,
|
|
22
|
+
is: () => is,
|
|
23
|
+
isArray: () => isArray,
|
|
24
|
+
isBoolean: () => isBoolean,
|
|
25
|
+
isDate: () => isDate,
|
|
26
|
+
isDefined: () => isDefined,
|
|
27
|
+
isFunction: () => isFunction,
|
|
28
|
+
isNot: () => isNot,
|
|
29
|
+
isNull: () => isNull,
|
|
30
|
+
isNumber: () => isNumber,
|
|
31
|
+
isObject: () => isObject,
|
|
32
|
+
isObjectLike: () => isObjectLike,
|
|
33
|
+
isString: () => isString,
|
|
34
|
+
isUndefined: () => isUndefined
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(types_exports);
|
|
37
|
+
var import_node = require("./node.js");
|
|
38
|
+
const isObject = (arg) => {
|
|
39
|
+
if (arg === null) return false;
|
|
40
|
+
return typeof arg === "object" && arg.constructor === Object;
|
|
41
|
+
};
|
|
42
|
+
const isString = (arg) => typeof arg === "string";
|
|
43
|
+
const isNumber = (arg) => typeof arg === "number";
|
|
44
|
+
const isFunction = (arg) => typeof arg === "function";
|
|
45
|
+
const isBoolean = (arg) => arg === true || arg === false;
|
|
46
|
+
const isNull = (arg) => arg === null;
|
|
47
|
+
const isArray = (arg) => Array.isArray(arg);
|
|
48
|
+
const isDate = (d) => d instanceof Date;
|
|
49
|
+
const isObjectLike = (arg) => {
|
|
50
|
+
if (arg === null) return false;
|
|
51
|
+
return typeof arg === "object";
|
|
52
|
+
};
|
|
53
|
+
const isDefined = (arg) => {
|
|
54
|
+
return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isDate(arg) || isNull(arg);
|
|
55
|
+
};
|
|
56
|
+
const isUndefined = (arg) => {
|
|
57
|
+
return arg === void 0;
|
|
58
|
+
};
|
|
59
|
+
const TYPES = {
|
|
60
|
+
boolean: isBoolean,
|
|
61
|
+
array: isArray,
|
|
62
|
+
object: isObject,
|
|
63
|
+
string: isString,
|
|
64
|
+
date: isDate,
|
|
65
|
+
number: isNumber,
|
|
66
|
+
null: isNull,
|
|
67
|
+
function: isFunction,
|
|
68
|
+
objectLike: isObjectLike,
|
|
69
|
+
node: import_node.isNode,
|
|
70
|
+
htmlElement: import_node.isHtmlElement,
|
|
71
|
+
defined: isDefined
|
|
72
|
+
};
|
|
73
|
+
const is = (arg) => {
|
|
74
|
+
return (...args) => {
|
|
75
|
+
return args.map((val) => TYPES[val](arg)).filter((v) => v).length > 0;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const isNot = (arg) => {
|
|
79
|
+
return (...args) => {
|
|
80
|
+
return args.map((val) => TYPES[val](arg)).filter((v) => v).length === 0;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -18,28 +18,29 @@ const applyAnimationFrame = (element) => {
|
|
|
18
18
|
if (!element) {
|
|
19
19
|
throw new Error("Element is invalid");
|
|
20
20
|
}
|
|
21
|
-
const {
|
|
21
|
+
const { on, props, __ref: ref } = element;
|
|
22
22
|
if (!ref.root || !ref.root.data) return;
|
|
23
23
|
const { frameListeners } = ref.root.data;
|
|
24
|
-
if (frameListeners && ((on == null ? void 0 : on.frame) || (props == null ? void 0 : props.onFrame))) {
|
|
24
|
+
if (frameListeners && ((on == null ? void 0 : on.frame) || element.onFrame || (props == null ? void 0 : props.onFrame))) {
|
|
25
25
|
registerFrameListener(element);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
const initAnimationFrame = () => {
|
|
29
29
|
const frameListeners = /* @__PURE__ */ new Set();
|
|
30
30
|
function requestFrame() {
|
|
31
|
-
var _a;
|
|
31
|
+
var _a, _b;
|
|
32
32
|
for (const element of frameListeners) {
|
|
33
33
|
if (!element.parent.node.contains(element.node)) {
|
|
34
34
|
frameListeners.delete(element);
|
|
35
35
|
} else {
|
|
36
36
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
element.state,
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
if ((_a = element.on) == null ? void 0 : _a.frame) {
|
|
38
|
+
element.on.frame(element, element.state, element.context);
|
|
39
|
+
} else if (element.onFrame) {
|
|
40
|
+
element.onFrame(element, element.state, element.context);
|
|
41
|
+
} else if ((_b = element.props) == null ? void 0 : _b.onFrame) {
|
|
42
|
+
element.props.onFrame(element, element.state, element.context);
|
|
43
|
+
}
|
|
43
44
|
} catch (e) {
|
|
44
45
|
console.warn(e);
|
|
45
46
|
}
|
package/dist/esm/keys.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const DOMQ_PROPERTIES = [
|
|
2
|
+
"attr",
|
|
3
|
+
"style",
|
|
4
|
+
"text",
|
|
5
|
+
"html",
|
|
6
|
+
"content",
|
|
7
|
+
"data",
|
|
8
|
+
"classlist",
|
|
9
|
+
"state",
|
|
10
|
+
"scope",
|
|
11
|
+
"deps",
|
|
12
|
+
"extends",
|
|
13
|
+
"$router",
|
|
14
|
+
"routes",
|
|
15
|
+
"children",
|
|
16
|
+
"childExtends",
|
|
17
|
+
"childExtendsRecursive",
|
|
18
|
+
"props",
|
|
19
|
+
"if",
|
|
20
|
+
"define",
|
|
21
|
+
"__name",
|
|
22
|
+
"__ref",
|
|
23
|
+
"__hash",
|
|
24
|
+
"__text",
|
|
25
|
+
"key",
|
|
26
|
+
"tag",
|
|
27
|
+
"query",
|
|
28
|
+
"parent",
|
|
29
|
+
"node",
|
|
30
|
+
"variables",
|
|
31
|
+
"on",
|
|
32
|
+
"component",
|
|
33
|
+
"context"
|
|
34
|
+
];
|
|
35
|
+
const PARSED_DOMQ_PROPERTIES = [
|
|
36
|
+
"attr",
|
|
37
|
+
"style",
|
|
38
|
+
"text",
|
|
39
|
+
"html",
|
|
40
|
+
"content",
|
|
41
|
+
"data",
|
|
42
|
+
"class",
|
|
43
|
+
"state",
|
|
44
|
+
"scope",
|
|
45
|
+
"children",
|
|
46
|
+
"props",
|
|
47
|
+
"if",
|
|
48
|
+
"key",
|
|
49
|
+
"tag",
|
|
50
|
+
"query",
|
|
51
|
+
"on",
|
|
52
|
+
"context"
|
|
53
|
+
];
|
|
54
|
+
const STATE_PROPERTIES = [
|
|
55
|
+
"ref",
|
|
56
|
+
"parent",
|
|
57
|
+
"__element",
|
|
58
|
+
"__depends",
|
|
59
|
+
"__ref",
|
|
60
|
+
"__children",
|
|
61
|
+
"root"
|
|
62
|
+
];
|
|
63
|
+
const STATE_METHODS = [
|
|
64
|
+
"update",
|
|
65
|
+
"parse",
|
|
66
|
+
"clean",
|
|
67
|
+
"create",
|
|
68
|
+
"destroy",
|
|
69
|
+
"add",
|
|
70
|
+
"toggle",
|
|
71
|
+
"remove",
|
|
72
|
+
"apply",
|
|
73
|
+
"set",
|
|
74
|
+
"reset",
|
|
75
|
+
"replace",
|
|
76
|
+
"quietReplace",
|
|
77
|
+
"quietUpdate",
|
|
78
|
+
"applyReplace",
|
|
79
|
+
"applyFunction",
|
|
80
|
+
"keys",
|
|
81
|
+
"values",
|
|
82
|
+
"ref",
|
|
83
|
+
"rootUpdate",
|
|
84
|
+
"parentUpdate",
|
|
85
|
+
"parent",
|
|
86
|
+
"__element",
|
|
87
|
+
"__depends",
|
|
88
|
+
"__ref",
|
|
89
|
+
"__children",
|
|
90
|
+
"root",
|
|
91
|
+
"setByPath",
|
|
92
|
+
"setPathCollection",
|
|
93
|
+
"removeByPath",
|
|
94
|
+
"removePathCollection",
|
|
95
|
+
"getByPath"
|
|
96
|
+
];
|
|
97
|
+
const PROPS_METHODS = ["update", "__element"];
|
|
98
|
+
const METHODS = [
|
|
99
|
+
"set",
|
|
100
|
+
"reset",
|
|
101
|
+
"update",
|
|
102
|
+
"remove",
|
|
103
|
+
"updateContent",
|
|
104
|
+
"removeContent",
|
|
105
|
+
"lookup",
|
|
106
|
+
"lookdown",
|
|
107
|
+
"lookdownAll",
|
|
108
|
+
"getRef",
|
|
109
|
+
"getPath",
|
|
110
|
+
"setNodeStyles",
|
|
111
|
+
"spotByPath",
|
|
112
|
+
"keys",
|
|
113
|
+
"parse",
|
|
114
|
+
"setProps",
|
|
115
|
+
"parseDeep",
|
|
116
|
+
"variables",
|
|
117
|
+
"if",
|
|
118
|
+
"log",
|
|
119
|
+
"verbose",
|
|
120
|
+
"warn",
|
|
121
|
+
"error",
|
|
122
|
+
"call",
|
|
123
|
+
"nextElement",
|
|
124
|
+
"previousElement"
|
|
125
|
+
];
|
|
126
|
+
const METHODS_EXL = [
|
|
127
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
128
|
+
...METHODS,
|
|
129
|
+
...STATE_METHODS,
|
|
130
|
+
...PROPS_METHODS
|
|
131
|
+
];
|
|
132
|
+
const DOMQL_EVENTS = [
|
|
133
|
+
"init",
|
|
134
|
+
"beforeClassAssign",
|
|
135
|
+
"render",
|
|
136
|
+
"renderRouter",
|
|
137
|
+
"attachNode",
|
|
138
|
+
"stateInit",
|
|
139
|
+
"stateCreated",
|
|
140
|
+
"beforeStateUpdate",
|
|
141
|
+
"stateUpdate",
|
|
142
|
+
"beforeUpdate",
|
|
143
|
+
"done",
|
|
144
|
+
"create",
|
|
145
|
+
"complete",
|
|
146
|
+
"frame",
|
|
147
|
+
"update"
|
|
148
|
+
];
|
|
149
|
+
export {
|
|
150
|
+
DOMQL_EVENTS,
|
|
151
|
+
DOMQ_PROPERTIES,
|
|
152
|
+
METHODS,
|
|
153
|
+
METHODS_EXL,
|
|
154
|
+
PARSED_DOMQ_PROPERTIES,
|
|
155
|
+
PROPS_METHODS,
|
|
156
|
+
STATE_METHODS,
|
|
157
|
+
STATE_PROPERTIES
|
|
158
|
+
};
|
package/dist/esm/node.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { window } from "./globals.js";
|
|
2
|
+
const isNode = (obj) => {
|
|
3
|
+
return (typeof Node === "object" ? obj instanceof window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
|
|
4
|
+
};
|
|
5
|
+
const isHtmlElement = (obj) => {
|
|
6
|
+
return (typeof HTMLElement === "object" ? obj instanceof window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
|
|
7
|
+
};
|
|
8
|
+
const isDOMNode = (obj) => {
|
|
9
|
+
return typeof window !== "undefined" && (obj instanceof window.Node || obj instanceof window.Window || obj === window || obj === document);
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
isDOMNode,
|
|
13
|
+
isHtmlElement,
|
|
14
|
+
isNode
|
|
15
|
+
};
|
package/dist/esm/on.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DOMQL_EVENTS
|
|
1
|
+
import { DOMQL_EVENTS } from "./keys.js";
|
|
2
|
+
import { isFunction } from "./types.js";
|
|
2
3
|
const getOnOrPropsEvent = (param, element) => {
|
|
3
4
|
var _a, _b;
|
|
4
5
|
const onEvent = (_a = element.on) == null ? void 0 : _a[param];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isHtmlElement, isNode } from "./node.js";
|
|
2
|
+
const isObject = (arg) => {
|
|
3
|
+
if (arg === null) return false;
|
|
4
|
+
return typeof arg === "object" && arg.constructor === Object;
|
|
5
|
+
};
|
|
6
|
+
const isString = (arg) => typeof arg === "string";
|
|
7
|
+
const isNumber = (arg) => typeof arg === "number";
|
|
8
|
+
const isFunction = (arg) => typeof arg === "function";
|
|
9
|
+
const isBoolean = (arg) => arg === true || arg === false;
|
|
10
|
+
const isNull = (arg) => arg === null;
|
|
11
|
+
const isArray = (arg) => Array.isArray(arg);
|
|
12
|
+
const isDate = (d) => d instanceof Date;
|
|
13
|
+
const isObjectLike = (arg) => {
|
|
14
|
+
if (arg === null) return false;
|
|
15
|
+
return typeof arg === "object";
|
|
16
|
+
};
|
|
17
|
+
const isDefined = (arg) => {
|
|
18
|
+
return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isDate(arg) || isNull(arg);
|
|
19
|
+
};
|
|
20
|
+
const isUndefined = (arg) => {
|
|
21
|
+
return arg === void 0;
|
|
22
|
+
};
|
|
23
|
+
const TYPES = {
|
|
24
|
+
boolean: isBoolean,
|
|
25
|
+
array: isArray,
|
|
26
|
+
object: isObject,
|
|
27
|
+
string: isString,
|
|
28
|
+
date: isDate,
|
|
29
|
+
number: isNumber,
|
|
30
|
+
null: isNull,
|
|
31
|
+
function: isFunction,
|
|
32
|
+
objectLike: isObjectLike,
|
|
33
|
+
node: isNode,
|
|
34
|
+
htmlElement: isHtmlElement,
|
|
35
|
+
defined: isDefined
|
|
36
|
+
};
|
|
37
|
+
const is = (arg) => {
|
|
38
|
+
return (...args) => {
|
|
39
|
+
return args.map((val) => TYPES[val](arg)).filter((v) => v).length > 0;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const isNot = (arg) => {
|
|
43
|
+
return (...args) => {
|
|
44
|
+
return args.map((val) => TYPES[val](arg)).filter((v) => v).length === 0;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
TYPES,
|
|
49
|
+
is,
|
|
50
|
+
isArray,
|
|
51
|
+
isBoolean,
|
|
52
|
+
isDate,
|
|
53
|
+
isDefined,
|
|
54
|
+
isFunction,
|
|
55
|
+
isNot,
|
|
56
|
+
isNull,
|
|
57
|
+
isNumber,
|
|
58
|
+
isObject,
|
|
59
|
+
isObjectLike,
|
|
60
|
+
isString,
|
|
61
|
+
isUndefined
|
|
62
|
+
};
|
package/globals.js
ADDED
package/keys.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const DOMQ_PROPERTIES = [
|
|
4
|
+
'attr',
|
|
5
|
+
'style',
|
|
6
|
+
'text',
|
|
7
|
+
'html',
|
|
8
|
+
'content',
|
|
9
|
+
'data',
|
|
10
|
+
'classlist',
|
|
11
|
+
'state',
|
|
12
|
+
'scope',
|
|
13
|
+
'deps',
|
|
14
|
+
'extends',
|
|
15
|
+
'$router',
|
|
16
|
+
'routes',
|
|
17
|
+
'children',
|
|
18
|
+
'childExtends',
|
|
19
|
+
'childExtendsRecursive',
|
|
20
|
+
'props',
|
|
21
|
+
'if',
|
|
22
|
+
'define',
|
|
23
|
+
'__name',
|
|
24
|
+
'__ref',
|
|
25
|
+
'__hash',
|
|
26
|
+
'__text',
|
|
27
|
+
'key',
|
|
28
|
+
'tag',
|
|
29
|
+
'query',
|
|
30
|
+
'parent',
|
|
31
|
+
'node',
|
|
32
|
+
'variables',
|
|
33
|
+
'on',
|
|
34
|
+
'component',
|
|
35
|
+
'context'
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export const PARSED_DOMQ_PROPERTIES = [
|
|
39
|
+
'attr',
|
|
40
|
+
'style',
|
|
41
|
+
'text',
|
|
42
|
+
'html',
|
|
43
|
+
'content',
|
|
44
|
+
'data',
|
|
45
|
+
'class',
|
|
46
|
+
'state',
|
|
47
|
+
'scope',
|
|
48
|
+
'children',
|
|
49
|
+
'props',
|
|
50
|
+
'if',
|
|
51
|
+
'key',
|
|
52
|
+
'tag',
|
|
53
|
+
'query',
|
|
54
|
+
'on',
|
|
55
|
+
'context'
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
export const STATE_PROPERTIES = [
|
|
59
|
+
'ref',
|
|
60
|
+
'parent',
|
|
61
|
+
'__element',
|
|
62
|
+
'__depends',
|
|
63
|
+
'__ref',
|
|
64
|
+
'__children',
|
|
65
|
+
'root'
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
export const STATE_METHODS = [
|
|
69
|
+
'update',
|
|
70
|
+
'parse',
|
|
71
|
+
'clean',
|
|
72
|
+
'create',
|
|
73
|
+
'destroy',
|
|
74
|
+
'add',
|
|
75
|
+
'toggle',
|
|
76
|
+
'remove',
|
|
77
|
+
'apply',
|
|
78
|
+
'set',
|
|
79
|
+
'reset',
|
|
80
|
+
'replace',
|
|
81
|
+
'quietReplace',
|
|
82
|
+
'quietUpdate',
|
|
83
|
+
'applyReplace',
|
|
84
|
+
'applyFunction',
|
|
85
|
+
'keys',
|
|
86
|
+
'values',
|
|
87
|
+
'ref',
|
|
88
|
+
'rootUpdate',
|
|
89
|
+
'parentUpdate',
|
|
90
|
+
'parent',
|
|
91
|
+
'__element',
|
|
92
|
+
'__depends',
|
|
93
|
+
'__ref',
|
|
94
|
+
'__children',
|
|
95
|
+
'root',
|
|
96
|
+
'setByPath',
|
|
97
|
+
'setPathCollection',
|
|
98
|
+
'removeByPath',
|
|
99
|
+
'removePathCollection',
|
|
100
|
+
'getByPath'
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
export const PROPS_METHODS = ['update', '__element']
|
|
104
|
+
|
|
105
|
+
export const METHODS = [
|
|
106
|
+
'set',
|
|
107
|
+
'reset',
|
|
108
|
+
'update',
|
|
109
|
+
'remove',
|
|
110
|
+
'updateContent',
|
|
111
|
+
'removeContent',
|
|
112
|
+
'lookup',
|
|
113
|
+
'lookdown',
|
|
114
|
+
'lookdownAll',
|
|
115
|
+
'getRef',
|
|
116
|
+
'getPath',
|
|
117
|
+
'setNodeStyles',
|
|
118
|
+
'spotByPath',
|
|
119
|
+
'keys',
|
|
120
|
+
'parse',
|
|
121
|
+
'setProps',
|
|
122
|
+
'parseDeep',
|
|
123
|
+
'variables',
|
|
124
|
+
'if',
|
|
125
|
+
'log',
|
|
126
|
+
'verbose',
|
|
127
|
+
'warn',
|
|
128
|
+
'error',
|
|
129
|
+
'call',
|
|
130
|
+
'nextElement',
|
|
131
|
+
'previousElement'
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
export const METHODS_EXL = [
|
|
135
|
+
...['node', 'context', 'extends', '__element', '__ref'],
|
|
136
|
+
...METHODS,
|
|
137
|
+
...STATE_METHODS,
|
|
138
|
+
...PROPS_METHODS
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
export const DOMQL_EVENTS = [
|
|
142
|
+
'init',
|
|
143
|
+
'beforeClassAssign',
|
|
144
|
+
'render',
|
|
145
|
+
'renderRouter',
|
|
146
|
+
'attachNode',
|
|
147
|
+
'stateInit',
|
|
148
|
+
'stateCreated',
|
|
149
|
+
'beforeStateUpdate',
|
|
150
|
+
'stateUpdate',
|
|
151
|
+
'beforeUpdate',
|
|
152
|
+
'done',
|
|
153
|
+
'create',
|
|
154
|
+
'complete',
|
|
155
|
+
'frame',
|
|
156
|
+
'update'
|
|
157
|
+
]
|
package/node.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { window } from './globals.js'
|
|
4
|
+
|
|
5
|
+
export const isNode = obj => {
|
|
6
|
+
return (
|
|
7
|
+
(typeof Node === 'object'
|
|
8
|
+
? obj instanceof window.Node
|
|
9
|
+
: obj &&
|
|
10
|
+
typeof obj === 'object' &&
|
|
11
|
+
typeof obj.nodeType === 'number' &&
|
|
12
|
+
typeof obj.nodeName === 'string') || false
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Returns true if it is a DOM element
|
|
17
|
+
export const isHtmlElement = obj => {
|
|
18
|
+
return (
|
|
19
|
+
(typeof HTMLElement === 'object'
|
|
20
|
+
? obj instanceof window.HTMLElement // DOM2
|
|
21
|
+
: obj &&
|
|
22
|
+
typeof obj === 'object' &&
|
|
23
|
+
obj !== null &&
|
|
24
|
+
obj.nodeType === 1 &&
|
|
25
|
+
typeof obj.nodeName === 'string') || false
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const isDOMNode = obj => {
|
|
30
|
+
return (
|
|
31
|
+
typeof window !== 'undefined' &&
|
|
32
|
+
(obj instanceof window.Node ||
|
|
33
|
+
obj instanceof window.Window ||
|
|
34
|
+
obj === window ||
|
|
35
|
+
obj === document)
|
|
36
|
+
)
|
|
37
|
+
}
|
package/on.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
25
25
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
26
26
|
"build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
|
|
27
|
-
"build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
27
|
+
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
28
28
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@domql/report": "^3.
|
|
32
|
-
"@domql/utils": "^3.
|
|
31
|
+
"@domql/report": "^3.1.2",
|
|
32
|
+
"@domql/utils": "^3.1.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "429b36616aa04c8587a26ce3c129815115e35897"
|
|
35
35
|
}
|
package/types.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { isHtmlElement, isNode } from './node.js'
|
|
4
|
+
|
|
5
|
+
export const isObject = arg => {
|
|
6
|
+
if (arg === null) return false
|
|
7
|
+
return (typeof arg === 'object') && (arg.constructor === Object)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const isString = arg => typeof arg === 'string'
|
|
11
|
+
|
|
12
|
+
export const isNumber = arg => typeof arg === 'number'
|
|
13
|
+
|
|
14
|
+
export const isFunction = arg => typeof arg === 'function'
|
|
15
|
+
|
|
16
|
+
export const isBoolean = arg => arg === true || arg === false
|
|
17
|
+
|
|
18
|
+
export const isNull = arg => arg === null
|
|
19
|
+
|
|
20
|
+
export const isArray = arg => Array.isArray(arg)
|
|
21
|
+
|
|
22
|
+
export const isDate = d => d instanceof Date
|
|
23
|
+
|
|
24
|
+
export const isObjectLike = arg => {
|
|
25
|
+
if (arg === null) return false
|
|
26
|
+
// if (isArray(arg)) return false
|
|
27
|
+
return (typeof arg === 'object')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const isDefined = arg => {
|
|
31
|
+
return isObject(arg) ||
|
|
32
|
+
isObjectLike(arg) ||
|
|
33
|
+
isString(arg) ||
|
|
34
|
+
isNumber(arg) ||
|
|
35
|
+
isFunction(arg) ||
|
|
36
|
+
isArray(arg) ||
|
|
37
|
+
isObjectLike(arg) ||
|
|
38
|
+
isBoolean(arg) ||
|
|
39
|
+
isDate(arg) ||
|
|
40
|
+
isNull(arg)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const isUndefined = arg => {
|
|
44
|
+
return arg === undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const TYPES = {
|
|
48
|
+
boolean: isBoolean,
|
|
49
|
+
array: isArray,
|
|
50
|
+
object: isObject,
|
|
51
|
+
string: isString,
|
|
52
|
+
date: isDate,
|
|
53
|
+
number: isNumber,
|
|
54
|
+
null: isNull,
|
|
55
|
+
function: isFunction,
|
|
56
|
+
objectLike: isObjectLike,
|
|
57
|
+
node: isNode,
|
|
58
|
+
htmlElement: isHtmlElement,
|
|
59
|
+
defined: isDefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const is = (arg) => {
|
|
63
|
+
return (...args) => {
|
|
64
|
+
return args.map(val => TYPES[val](arg)).filter(v => v).length > 0
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const isNot = (arg) => {
|
|
69
|
+
return (...args) => {
|
|
70
|
+
return args.map(val => TYPES[val](arg)).filter(v => v).length === 0
|
|
71
|
+
}
|
|
72
|
+
}
|