@domql/event 2.3.89 → 2.3.100
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/can.js +6 -7
- package/dist/cjs/can.js +29 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/legacy.js +65 -0
- package/dist/cjs/on.js +52 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/store.js +27 -0
- package/index.js +2 -14
- package/legacy.js +49 -0
- package/on.js +29 -54
- package/package.json +21 -5
- package/is.js +0 -15
package/can.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { report } from '@domql/report'
|
|
4
|
+
import { isValidHtmlTag } from '@domql/utils'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// }
|
|
6
|
+
export const canRender = (element) => {
|
|
7
|
+
const tag = element.tag || 'div'
|
|
8
|
+
return isValidHtmlTag(tag) || report('HTMLInvalidTag')
|
|
9
|
+
}
|
package/dist/cjs/can.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 can_exports = {};
|
|
20
|
+
__export(can_exports, {
|
|
21
|
+
canRender: () => canRender
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(can_exports);
|
|
24
|
+
var import_report = require("@domql/report");
|
|
25
|
+
var import_utils = require("@domql/utils");
|
|
26
|
+
const canRender = (element) => {
|
|
27
|
+
const tag = element.tag || "div";
|
|
28
|
+
return (0, import_utils.isValidHtmlTag)(tag) || (0, import_report.report)("HTMLInvalidTag");
|
|
29
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var event_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(event_exports);
|
|
18
|
+
__reExport(event_exports, require("./on"), module.exports);
|
|
19
|
+
__reExport(event_exports, require("./can"), module.exports);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var legacy_exports = {};
|
|
19
|
+
__export(legacy_exports, {
|
|
20
|
+
createState: () => createState,
|
|
21
|
+
init: () => init,
|
|
22
|
+
propsUpdated: () => propsUpdated,
|
|
23
|
+
render: () => render,
|
|
24
|
+
update: () => update,
|
|
25
|
+
updateState: () => updateState,
|
|
26
|
+
updateStateInit: () => updateStateInit
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(legacy_exports);
|
|
29
|
+
var import_utils = require("@domql/utils");
|
|
30
|
+
const init = (param, element, state) => {
|
|
31
|
+
param(element, state);
|
|
32
|
+
};
|
|
33
|
+
const render = (param, element, state) => {
|
|
34
|
+
param(element, state);
|
|
35
|
+
};
|
|
36
|
+
const createState = (state, element) => {
|
|
37
|
+
const { on, ...el } = element;
|
|
38
|
+
if (on && (0, import_utils.isFunction)(on.createState)) {
|
|
39
|
+
on.createState(state, el);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const updateStateInit = (changes, element) => {
|
|
43
|
+
const { state, on, ...el } = element;
|
|
44
|
+
if (on && (0, import_utils.isFunction)(on.updateStateInit)) {
|
|
45
|
+
on.updateStateInit(changes, state, el);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const updateState = (changes, element) => {
|
|
49
|
+
const { state, on } = element;
|
|
50
|
+
if (on && (0, import_utils.isFunction)(on.updateState)) {
|
|
51
|
+
on.updateState(changes, state, element);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const propsUpdated = (element) => {
|
|
55
|
+
const { props, state, on } = element;
|
|
56
|
+
if (on && (0, import_utils.isFunction)(on.propsUpdated)) {
|
|
57
|
+
on.propsUpdated(props, state, element);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const update = (params, element, state) => {
|
|
61
|
+
if (element.on && (0, import_utils.isFunction)(element.on.update)) {
|
|
62
|
+
element.on.update(element, state);
|
|
63
|
+
}
|
|
64
|
+
return params;
|
|
65
|
+
};
|
package/dist/cjs/on.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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 on_exports = {};
|
|
20
|
+
__export(on_exports, {
|
|
21
|
+
applyEvent: () => applyEvent,
|
|
22
|
+
applyEventsOnNode: () => applyEventsOnNode,
|
|
23
|
+
triggerEventOn: () => triggerEventOn
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(on_exports);
|
|
26
|
+
var import_utils = require("@domql/utils");
|
|
27
|
+
const applyEvent = (param, element, state, context, updatedObj) => {
|
|
28
|
+
if (updatedObj)
|
|
29
|
+
return param(updatedObj, element, state || element.state, context || element.context);
|
|
30
|
+
return param(element, state || element.state, context || element.context);
|
|
31
|
+
};
|
|
32
|
+
const triggerEventOn = (param, element, updatedObj) => {
|
|
33
|
+
if (element.on && (0, import_utils.isFunction)(element.on[param])) {
|
|
34
|
+
if (updatedObj) {
|
|
35
|
+
const { state, context } = element;
|
|
36
|
+
return applyEvent(element.on[param], element, state, context, updatedObj);
|
|
37
|
+
}
|
|
38
|
+
return applyEvent(element.on[param], element);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const applyEventsOnNode = (element) => {
|
|
42
|
+
const { node, on } = element;
|
|
43
|
+
for (const param in on) {
|
|
44
|
+
if (param === "init" || param === "beforeClassAssign" || param === "render" || param === "renderRouter" || param === "attachNode" || param === "stateInit" || param === "stateCreated" || param === "initStateUpdated" || param === "stateUpdated" || param === "initUpdate" || param === "update")
|
|
45
|
+
continue;
|
|
46
|
+
const appliedFunction = element.on[param];
|
|
47
|
+
if ((0, import_utils.isFunction)(appliedFunction)) {
|
|
48
|
+
const { state, context } = element;
|
|
49
|
+
node.addEventListener(param, (event) => appliedFunction(event, element, state, context));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 store_exports = {};
|
|
20
|
+
__export(store_exports, {
|
|
21
|
+
default: () => store_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(store_exports);
|
|
24
|
+
var store_default = {
|
|
25
|
+
click: [],
|
|
26
|
+
render: []
|
|
27
|
+
};
|
package/index.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import * as is from './is'
|
|
6
|
-
|
|
7
|
-
const applyEvent = on.applyEvent
|
|
8
|
-
const triggerEventOn = on.triggerEventOn
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
on,
|
|
12
|
-
applyEvent,
|
|
13
|
-
triggerEventOn,
|
|
14
|
-
can,
|
|
15
|
-
is
|
|
16
|
-
}
|
|
3
|
+
export * from './on'
|
|
4
|
+
export * from './can'
|
package/legacy.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isFunction } from '@domql/utils'
|
|
2
|
+
|
|
3
|
+
// LEGACY
|
|
4
|
+
export const init = (param, element, state) => {
|
|
5
|
+
param(element, state)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const render = (param, element, state) => {
|
|
9
|
+
param(element, state)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// export const attachNode = (param, element, state) => {
|
|
13
|
+
// param(element, state)
|
|
14
|
+
// }
|
|
15
|
+
|
|
16
|
+
export const createState = (state, element) => {
|
|
17
|
+
const { on, ...el } = element
|
|
18
|
+
if (on && isFunction(on.createState)) {
|
|
19
|
+
on.createState(state, el)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const updateStateInit = (changes, element) => {
|
|
24
|
+
const { state, on, ...el } = element
|
|
25
|
+
if (on && isFunction(on.updateStateInit)) {
|
|
26
|
+
on.updateStateInit(changes, state, el)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const updateState = (changes, element) => {
|
|
31
|
+
const { state, on } = element
|
|
32
|
+
if (on && isFunction(on.updateState)) {
|
|
33
|
+
on.updateState(changes, state, element)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const propsUpdated = (element) => {
|
|
38
|
+
const { props, state, on } = element
|
|
39
|
+
if (on && isFunction(on.propsUpdated)) {
|
|
40
|
+
on.propsUpdated(props, state, element)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const update = (params, element, state) => {
|
|
45
|
+
if (element.on && isFunction(element.on.update)) {
|
|
46
|
+
element.on.update(element, state)
|
|
47
|
+
}
|
|
48
|
+
return params
|
|
49
|
+
}
|
package/on.js
CHANGED
|
@@ -2,67 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
import { isFunction } from '@domql/utils'
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
param(element, state)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const render = (param, element, state) => {
|
|
10
|
-
param(element, state)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const applyEvent = (param, element, state, context) => {
|
|
5
|
+
export const applyEvent = (param, element, state, context, updatedObj) => {
|
|
6
|
+
if (updatedObj) return param(updatedObj, element, state || element.state, context || element.context)
|
|
14
7
|
return param(element, state || element.state, context || element.context)
|
|
15
8
|
}
|
|
16
9
|
|
|
17
|
-
export const triggerEventOn = (param, element) => {
|
|
10
|
+
export const triggerEventOn = (param, element, updatedObj) => {
|
|
18
11
|
if (element.on && isFunction(element.on[param])) {
|
|
12
|
+
if (updatedObj) {
|
|
13
|
+
const { state, context } = element
|
|
14
|
+
return applyEvent(element.on[param], element, state, context, updatedObj)
|
|
15
|
+
}
|
|
19
16
|
return applyEvent(element.on[param], element)
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export const
|
|
24
|
-
const {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
on.updateStateInit(changes, state, el)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const updateState = (changes, element) => {
|
|
50
|
-
const { state, on } = element
|
|
51
|
-
if (on && isFunction(on.updateState)) {
|
|
52
|
-
on.updateState(changes, state, element)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const propsUpdated = (element) => {
|
|
57
|
-
const { props, state, on } = element
|
|
58
|
-
if (on && isFunction(on.propsUpdated)) {
|
|
59
|
-
on.propsUpdated(props, state, element)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const update = (params, element, state) => {
|
|
64
|
-
if (element.on && isFunction(element.on.update)) {
|
|
65
|
-
element.on.update(element, state)
|
|
20
|
+
export const applyEventsOnNode = element => {
|
|
21
|
+
const { node, on } = element
|
|
22
|
+
for (const param in on) {
|
|
23
|
+
if (
|
|
24
|
+
param === 'init' ||
|
|
25
|
+
param === 'beforeClassAssign' ||
|
|
26
|
+
param === 'render' ||
|
|
27
|
+
param === 'renderRouter' ||
|
|
28
|
+
param === 'attachNode' ||
|
|
29
|
+
param === 'stateInit' ||
|
|
30
|
+
param === 'stateCreated' ||
|
|
31
|
+
param === 'initStateUpdated' ||
|
|
32
|
+
param === 'stateUpdated' ||
|
|
33
|
+
param === 'initUpdate' ||
|
|
34
|
+
param === 'update'
|
|
35
|
+
) continue
|
|
36
|
+
|
|
37
|
+
const appliedFunction = element.on[param]
|
|
38
|
+
if (isFunction(appliedFunction)) {
|
|
39
|
+
const { state, context } = element
|
|
40
|
+
node.addEventListener(param, event => appliedFunction(event, element, state, context))
|
|
41
|
+
}
|
|
66
42
|
}
|
|
67
|
-
return params
|
|
68
43
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"main": "index.js",
|
|
3
|
+
"version": "2.3.100",
|
|
5
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"unpkg": "dist/iife/index.js",
|
|
8
|
+
"jsdelivr": "dist/iife/index.js",
|
|
9
|
+
"main": "dist/esm/index.js",
|
|
10
|
+
"exports": "./dist/cjs/index.js",
|
|
11
|
+
"source": "index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"*.js",
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
6
16
|
"scripts": {
|
|
7
|
-
"
|
|
17
|
+
"copy:package:cjs": "cp ../../.build/package-cjs.json dist/cjs/package.json",
|
|
18
|
+
"build:esm": "npx esbuild *.js --target=es2020 --format=esm --outdir=dist/esm",
|
|
19
|
+
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
20
|
+
"build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
|
|
21
|
+
"build": "yarn build:cjs",
|
|
22
|
+
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
8
23
|
},
|
|
9
24
|
"dependencies": {
|
|
10
25
|
"@domql/globals": "latest",
|
|
26
|
+
"@domql/registry": "latest",
|
|
27
|
+
"@domql/report": "latest",
|
|
11
28
|
"@domql/utils": "latest"
|
|
12
29
|
},
|
|
13
|
-
"gitHead": "
|
|
14
|
-
"source": "index.js"
|
|
30
|
+
"gitHead": "4d65ad04e488122bfc73ec81dc16c45b842ffa9b"
|
|
15
31
|
}
|
package/is.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { window } from '@domql/globals'
|
|
4
|
-
|
|
5
|
-
export const node = (node) => {
|
|
6
|
-
const { Node } = window
|
|
7
|
-
return (
|
|
8
|
-
typeof Node === 'function'
|
|
9
|
-
? node instanceof Node
|
|
10
|
-
: node &&
|
|
11
|
-
typeof node === 'object' &&
|
|
12
|
-
typeof node.nodeType === 'number' &&
|
|
13
|
-
typeof node.tag === 'string'
|
|
14
|
-
)
|
|
15
|
-
}
|