@domql/event 2.5.200 → 3.0.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/animationFrame.js +25 -4
- package/dist/cjs/animationFrame.js +22 -3
- package/dist/cjs/on.js +39 -7
- package/dist/esm/animationFrame.js +22 -3
- package/dist/esm/on.js +40 -8
- package/on.js +55 -26
- package/package.json +4 -4
- package/dist/cjs/legacy.js +0 -65
- package/dist/esm/legacy.js +0 -61
- package/legacy.js +0 -49
package/animationFrame.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
export const registerFrameListener =
|
|
3
|
+
export const registerFrameListener = el => {
|
|
4
|
+
if (!el || !el.__ref) {
|
|
5
|
+
throw new Error('Element reference is invalid')
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
const { __ref: ref } = el
|
|
9
|
+
|
|
10
|
+
if (!ref.root) {
|
|
11
|
+
throw new Error('Root reference is invalid')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!ref.root.data) {
|
|
15
|
+
throw new Error('Data are undefined')
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
const { frameListeners } = ref.root.data
|
|
6
19
|
|
|
7
20
|
// Check if frameListeners exists and the element is not already in the Set
|
|
@@ -10,15 +23,19 @@ export const registerFrameListener = (el) => {
|
|
|
10
23
|
}
|
|
11
24
|
}
|
|
12
25
|
|
|
13
|
-
export const applyAnimationFrame =
|
|
26
|
+
export const applyAnimationFrame = element => {
|
|
27
|
+
if (!element) {
|
|
28
|
+
throw new Error('Element is invalid')
|
|
29
|
+
}
|
|
14
30
|
const { props, on, __ref: ref } = element
|
|
31
|
+
if (!ref.root || !ref.root.data) return
|
|
15
32
|
const { frameListeners } = ref.root.data
|
|
16
33
|
if (frameListeners && (on?.frame || props?.onFrame)) {
|
|
17
34
|
registerFrameListener(element)
|
|
18
35
|
}
|
|
19
36
|
}
|
|
20
37
|
|
|
21
|
-
export const initAnimationFrame = (
|
|
38
|
+
export const initAnimationFrame = () => {
|
|
22
39
|
const frameListeners = new Set()
|
|
23
40
|
|
|
24
41
|
function requestFrame () {
|
|
@@ -28,7 +45,11 @@ export const initAnimationFrame = (ctx) => {
|
|
|
28
45
|
frameListeners.delete(element) // Remove if node has no parent
|
|
29
46
|
} else {
|
|
30
47
|
try {
|
|
31
|
-
(element.on
|
|
48
|
+
;(element.on?.frame || element.props.onFrame)(
|
|
49
|
+
element,
|
|
50
|
+
element.state,
|
|
51
|
+
element.context
|
|
52
|
+
)
|
|
32
53
|
} catch (e) {
|
|
33
54
|
console.warn(e)
|
|
34
55
|
}
|
|
@@ -24,28 +24,47 @@ __export(animationFrame_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(animationFrame_exports);
|
|
26
26
|
const registerFrameListener = (el) => {
|
|
27
|
+
if (!el || !el.__ref) {
|
|
28
|
+
throw new Error("Element reference is invalid");
|
|
29
|
+
}
|
|
27
30
|
const { __ref: ref } = el;
|
|
31
|
+
if (!ref.root) {
|
|
32
|
+
throw new Error("Root reference is invalid");
|
|
33
|
+
}
|
|
34
|
+
if (!ref.root.data) {
|
|
35
|
+
throw new Error("Data are undefined");
|
|
36
|
+
}
|
|
28
37
|
const { frameListeners } = ref.root.data;
|
|
29
38
|
if (frameListeners && !frameListeners.has(el)) {
|
|
30
39
|
frameListeners.add(el);
|
|
31
40
|
}
|
|
32
41
|
};
|
|
33
|
-
const applyAnimationFrame = (element
|
|
42
|
+
const applyAnimationFrame = (element) => {
|
|
43
|
+
if (!element) {
|
|
44
|
+
throw new Error("Element is invalid");
|
|
45
|
+
}
|
|
34
46
|
const { props, on, __ref: ref } = element;
|
|
47
|
+
if (!ref.root || !ref.root.data) return;
|
|
35
48
|
const { frameListeners } = ref.root.data;
|
|
36
49
|
if (frameListeners && ((on == null ? void 0 : on.frame) || (props == null ? void 0 : props.onFrame))) {
|
|
37
50
|
registerFrameListener(element);
|
|
38
51
|
}
|
|
39
52
|
};
|
|
40
|
-
const initAnimationFrame = (
|
|
53
|
+
const initAnimationFrame = () => {
|
|
41
54
|
const frameListeners = /* @__PURE__ */ new Set();
|
|
42
55
|
function requestFrame() {
|
|
56
|
+
var _a;
|
|
43
57
|
for (const element of frameListeners) {
|
|
44
58
|
if (!element.parent.node.contains(element.node)) {
|
|
45
59
|
frameListeners.delete(element);
|
|
46
60
|
} else {
|
|
47
61
|
try {
|
|
48
|
-
|
|
62
|
+
;
|
|
63
|
+
(((_a = element.on) == null ? void 0 : _a.frame) || element.props.onFrame)(
|
|
64
|
+
element,
|
|
65
|
+
element.state,
|
|
66
|
+
element.context
|
|
67
|
+
);
|
|
49
68
|
} catch (e) {
|
|
50
69
|
console.warn(e);
|
|
51
70
|
}
|
package/dist/cjs/on.js
CHANGED
|
@@ -32,35 +32,67 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
32
32
|
const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
|
|
33
33
|
return onEvent || onPropEvent;
|
|
34
34
|
};
|
|
35
|
-
const applyEvent = (param, element, state, context, options) => {
|
|
36
|
-
|
|
35
|
+
const applyEvent = async (param, element, state, context, options) => {
|
|
36
|
+
if (!(0, import_utils.isFunction)(param)) return;
|
|
37
|
+
return await param.call(
|
|
38
|
+
element,
|
|
39
|
+
element,
|
|
40
|
+
state || element.state,
|
|
41
|
+
context || element.context,
|
|
42
|
+
options
|
|
43
|
+
);
|
|
37
44
|
};
|
|
38
45
|
const triggerEventOn = async (param, element, options) => {
|
|
46
|
+
if (!element) {
|
|
47
|
+
throw new Error("Element is required");
|
|
48
|
+
}
|
|
39
49
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
40
50
|
if (appliedFunction) {
|
|
41
51
|
const { state, context } = element;
|
|
42
52
|
return await applyEvent(appliedFunction, element, state, context, options);
|
|
43
53
|
}
|
|
44
54
|
};
|
|
45
|
-
const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
|
|
46
|
-
|
|
55
|
+
const applyEventUpdate = async (param, updatedObj, element, state, context, options) => {
|
|
56
|
+
if (!(0, import_utils.isFunction)(param)) return;
|
|
57
|
+
return await param.call(
|
|
58
|
+
element,
|
|
59
|
+
updatedObj,
|
|
60
|
+
element,
|
|
61
|
+
state || element.state,
|
|
62
|
+
context || element.context,
|
|
63
|
+
options
|
|
64
|
+
);
|
|
47
65
|
};
|
|
48
66
|
const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
|
|
49
67
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
50
68
|
if (appliedFunction) {
|
|
51
69
|
const { state, context } = element;
|
|
52
|
-
return await applyEventUpdate(
|
|
70
|
+
return await applyEventUpdate(
|
|
71
|
+
appliedFunction,
|
|
72
|
+
updatedObj,
|
|
73
|
+
element,
|
|
74
|
+
state,
|
|
75
|
+
context,
|
|
76
|
+
options
|
|
77
|
+
);
|
|
53
78
|
}
|
|
54
79
|
};
|
|
55
80
|
const applyEventsOnNode = (element, options) => {
|
|
56
81
|
const { node, on } = element;
|
|
57
82
|
for (const param in on) {
|
|
58
|
-
if (param
|
|
83
|
+
if (import_utils.DOMQL_EVENTS.includes(param)) continue;
|
|
59
84
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
60
85
|
if ((0, import_utils.isFunction)(appliedFunction)) {
|
|
61
86
|
node.addEventListener(param, async (event) => {
|
|
62
87
|
const { state, context } = element;
|
|
63
|
-
await appliedFunction.call(
|
|
88
|
+
await appliedFunction.call(
|
|
89
|
+
element,
|
|
90
|
+
event,
|
|
91
|
+
element,
|
|
92
|
+
state,
|
|
93
|
+
context,
|
|
94
|
+
options
|
|
95
|
+
);
|
|
64
96
|
});
|
|
65
97
|
}
|
|
66
98
|
}
|
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
const registerFrameListener = (el) => {
|
|
2
|
+
if (!el || !el.__ref) {
|
|
3
|
+
throw new Error("Element reference is invalid");
|
|
4
|
+
}
|
|
2
5
|
const { __ref: ref } = el;
|
|
6
|
+
if (!ref.root) {
|
|
7
|
+
throw new Error("Root reference is invalid");
|
|
8
|
+
}
|
|
9
|
+
if (!ref.root.data) {
|
|
10
|
+
throw new Error("Data are undefined");
|
|
11
|
+
}
|
|
3
12
|
const { frameListeners } = ref.root.data;
|
|
4
13
|
if (frameListeners && !frameListeners.has(el)) {
|
|
5
14
|
frameListeners.add(el);
|
|
6
15
|
}
|
|
7
16
|
};
|
|
8
|
-
const applyAnimationFrame = (element
|
|
17
|
+
const applyAnimationFrame = (element) => {
|
|
18
|
+
if (!element) {
|
|
19
|
+
throw new Error("Element is invalid");
|
|
20
|
+
}
|
|
9
21
|
const { props, on, __ref: ref } = element;
|
|
22
|
+
if (!ref.root || !ref.root.data) return;
|
|
10
23
|
const { frameListeners } = ref.root.data;
|
|
11
24
|
if (frameListeners && ((on == null ? void 0 : on.frame) || (props == null ? void 0 : props.onFrame))) {
|
|
12
25
|
registerFrameListener(element);
|
|
13
26
|
}
|
|
14
27
|
};
|
|
15
|
-
const initAnimationFrame = (
|
|
28
|
+
const initAnimationFrame = () => {
|
|
16
29
|
const frameListeners = /* @__PURE__ */ new Set();
|
|
17
30
|
function requestFrame() {
|
|
31
|
+
var _a;
|
|
18
32
|
for (const element of frameListeners) {
|
|
19
33
|
if (!element.parent.node.contains(element.node)) {
|
|
20
34
|
frameListeners.delete(element);
|
|
21
35
|
} else {
|
|
22
36
|
try {
|
|
23
|
-
|
|
37
|
+
;
|
|
38
|
+
(((_a = element.on) == null ? void 0 : _a.frame) || element.props.onFrame)(
|
|
39
|
+
element,
|
|
40
|
+
element.state,
|
|
41
|
+
element.context
|
|
42
|
+
);
|
|
24
43
|
} catch (e) {
|
|
25
44
|
console.warn(e);
|
|
26
45
|
}
|
package/dist/esm/on.js
CHANGED
|
@@ -1,39 +1,71 @@
|
|
|
1
|
-
import { isFunction } from "@domql/utils";
|
|
1
|
+
import { DOMQL_EVENTS, isFunction } from "@domql/utils";
|
|
2
2
|
const getOnOrPropsEvent = (param, element) => {
|
|
3
3
|
var _a, _b;
|
|
4
4
|
const onEvent = (_a = element.on) == null ? void 0 : _a[param];
|
|
5
5
|
const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
|
|
6
6
|
return onEvent || onPropEvent;
|
|
7
7
|
};
|
|
8
|
-
const applyEvent = (param, element, state, context, options) => {
|
|
9
|
-
|
|
8
|
+
const applyEvent = async (param, element, state, context, options) => {
|
|
9
|
+
if (!isFunction(param)) return;
|
|
10
|
+
return await param.call(
|
|
11
|
+
element,
|
|
12
|
+
element,
|
|
13
|
+
state || element.state,
|
|
14
|
+
context || element.context,
|
|
15
|
+
options
|
|
16
|
+
);
|
|
10
17
|
};
|
|
11
18
|
const triggerEventOn = async (param, element, options) => {
|
|
19
|
+
if (!element) {
|
|
20
|
+
throw new Error("Element is required");
|
|
21
|
+
}
|
|
12
22
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
13
23
|
if (appliedFunction) {
|
|
14
24
|
const { state, context } = element;
|
|
15
25
|
return await applyEvent(appliedFunction, element, state, context, options);
|
|
16
26
|
}
|
|
17
27
|
};
|
|
18
|
-
const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
|
|
19
|
-
|
|
28
|
+
const applyEventUpdate = async (param, updatedObj, element, state, context, options) => {
|
|
29
|
+
if (!isFunction(param)) return;
|
|
30
|
+
return await param.call(
|
|
31
|
+
element,
|
|
32
|
+
updatedObj,
|
|
33
|
+
element,
|
|
34
|
+
state || element.state,
|
|
35
|
+
context || element.context,
|
|
36
|
+
options
|
|
37
|
+
);
|
|
20
38
|
};
|
|
21
39
|
const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
|
|
22
40
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
23
41
|
if (appliedFunction) {
|
|
24
42
|
const { state, context } = element;
|
|
25
|
-
return await applyEventUpdate(
|
|
43
|
+
return await applyEventUpdate(
|
|
44
|
+
appliedFunction,
|
|
45
|
+
updatedObj,
|
|
46
|
+
element,
|
|
47
|
+
state,
|
|
48
|
+
context,
|
|
49
|
+
options
|
|
50
|
+
);
|
|
26
51
|
}
|
|
27
52
|
};
|
|
28
53
|
const applyEventsOnNode = (element, options) => {
|
|
29
54
|
const { node, on } = element;
|
|
30
55
|
for (const param in on) {
|
|
31
|
-
if (param
|
|
56
|
+
if (DOMQL_EVENTS.includes(param)) continue;
|
|
32
57
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
33
58
|
if (isFunction(appliedFunction)) {
|
|
34
59
|
node.addEventListener(param, async (event) => {
|
|
35
60
|
const { state, context } = element;
|
|
36
|
-
await appliedFunction.call(
|
|
61
|
+
await appliedFunction.call(
|
|
62
|
+
element,
|
|
63
|
+
event,
|
|
64
|
+
element,
|
|
65
|
+
state,
|
|
66
|
+
context,
|
|
67
|
+
options
|
|
68
|
+
);
|
|
37
69
|
});
|
|
38
70
|
}
|
|
39
71
|
}
|
package/on.js
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isFunction } from '@domql/utils'
|
|
3
|
+
import { DOMQL_EVENTS, isFunction } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
const getOnOrPropsEvent = (param, element) => {
|
|
6
6
|
const onEvent = element.on?.[param]
|
|
7
|
-
const onPropEvent =
|
|
7
|
+
const onPropEvent =
|
|
8
|
+
element.props?.['on' + param.slice(0, 1).toUpperCase() + param.slice(1)]
|
|
8
9
|
return onEvent || onPropEvent
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export const applyEvent = (param, element, state, context, options) => {
|
|
12
|
-
|
|
12
|
+
export const applyEvent = async (param, element, state, context, options) => {
|
|
13
|
+
if (!isFunction(param)) return
|
|
14
|
+
return await param.call(
|
|
15
|
+
element,
|
|
16
|
+
element,
|
|
17
|
+
state || element.state,
|
|
18
|
+
context || element.context,
|
|
19
|
+
options
|
|
20
|
+
)
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
export const triggerEventOn = async (param, element, options) => {
|
|
24
|
+
if (!element) {
|
|
25
|
+
throw new Error('Element is required')
|
|
26
|
+
}
|
|
16
27
|
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
17
28
|
if (appliedFunction) {
|
|
18
29
|
const { state, context } = element
|
|
@@ -20,44 +31,62 @@ export const triggerEventOn = async (param, element, options) => {
|
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
|
|
23
|
-
export const applyEventUpdate = (
|
|
24
|
-
|
|
34
|
+
export const applyEventUpdate = async (
|
|
35
|
+
param,
|
|
36
|
+
updatedObj,
|
|
37
|
+
element,
|
|
38
|
+
state,
|
|
39
|
+
context,
|
|
40
|
+
options
|
|
41
|
+
) => {
|
|
42
|
+
if (!isFunction(param)) return
|
|
43
|
+
return await param.call(
|
|
44
|
+
element,
|
|
45
|
+
updatedObj,
|
|
46
|
+
element,
|
|
47
|
+
state || element.state,
|
|
48
|
+
context || element.context,
|
|
49
|
+
options
|
|
50
|
+
)
|
|
25
51
|
}
|
|
26
52
|
|
|
27
|
-
export const triggerEventOnUpdate = async (
|
|
53
|
+
export const triggerEventOnUpdate = async (
|
|
54
|
+
param,
|
|
55
|
+
updatedObj,
|
|
56
|
+
element,
|
|
57
|
+
options
|
|
58
|
+
) => {
|
|
28
59
|
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
29
60
|
if (appliedFunction) {
|
|
30
61
|
const { state, context } = element
|
|
31
|
-
return await applyEventUpdate(
|
|
62
|
+
return await applyEventUpdate(
|
|
63
|
+
appliedFunction,
|
|
64
|
+
updatedObj,
|
|
65
|
+
element,
|
|
66
|
+
state,
|
|
67
|
+
context,
|
|
68
|
+
options
|
|
69
|
+
)
|
|
32
70
|
}
|
|
33
71
|
}
|
|
34
72
|
|
|
35
73
|
export const applyEventsOnNode = (element, options) => {
|
|
36
74
|
const { node, on } = element
|
|
37
75
|
for (const param in on) {
|
|
38
|
-
if (
|
|
39
|
-
param === 'init' ||
|
|
40
|
-
param === 'beforeClassAssign' ||
|
|
41
|
-
param === 'render' ||
|
|
42
|
-
param === 'renderRouter' ||
|
|
43
|
-
param === 'attachNode' ||
|
|
44
|
-
param === 'stateInit' ||
|
|
45
|
-
param === 'stateCreated' ||
|
|
46
|
-
param === 'beforeStateUpdate' ||
|
|
47
|
-
param === 'stateUpdate' ||
|
|
48
|
-
param === 'beforeUpdate' ||
|
|
49
|
-
param === 'done' ||
|
|
50
|
-
param === 'create' ||
|
|
51
|
-
param === 'complete' ||
|
|
52
|
-
param === 'frame' ||
|
|
53
|
-
param === 'update'
|
|
54
|
-
) continue
|
|
76
|
+
if (DOMQL_EVENTS.includes(param)) continue
|
|
55
77
|
|
|
56
78
|
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
57
79
|
if (isFunction(appliedFunction)) {
|
|
58
80
|
node.addEventListener(param, async event => {
|
|
59
81
|
const { state, context } = element
|
|
60
|
-
await appliedFunction.call(
|
|
82
|
+
await appliedFunction.call(
|
|
83
|
+
element,
|
|
84
|
+
event,
|
|
85
|
+
element,
|
|
86
|
+
state,
|
|
87
|
+
context,
|
|
88
|
+
options
|
|
89
|
+
)
|
|
61
90
|
})
|
|
62
91
|
}
|
|
63
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@domql/report": "^
|
|
32
|
-
"@domql/utils": "^
|
|
31
|
+
"@domql/report": "^3.0.0",
|
|
32
|
+
"@domql/utils": "^3.0.1"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "bdadc70a00c5ddde21ca889746bf28db0c3d7c2f"
|
|
35
35
|
}
|
package/dist/cjs/legacy.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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/esm/legacy.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var __objRest = (source, exclude) => {
|
|
5
|
-
var target = {};
|
|
6
|
-
for (var prop in source)
|
|
7
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
-
target[prop] = source[prop];
|
|
9
|
-
if (source != null && __getOwnPropSymbols)
|
|
10
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
-
target[prop] = source[prop];
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
import { isFunction } from "@domql/utils";
|
|
17
|
-
const init = (param, element, state) => {
|
|
18
|
-
param(element, state);
|
|
19
|
-
};
|
|
20
|
-
const render = (param, element, state) => {
|
|
21
|
-
param(element, state);
|
|
22
|
-
};
|
|
23
|
-
const createState = (state, element) => {
|
|
24
|
-
const _a = element, { on } = _a, el = __objRest(_a, ["on"]);
|
|
25
|
-
if (on && isFunction(on.createState)) {
|
|
26
|
-
on.createState(state, el);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const updateStateInit = (changes, element) => {
|
|
30
|
-
const _a = element, { state, on } = _a, el = __objRest(_a, ["state", "on"]);
|
|
31
|
-
if (on && isFunction(on.updateStateInit)) {
|
|
32
|
-
on.updateStateInit(changes, state, el);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const updateState = (changes, element) => {
|
|
36
|
-
const { state, on } = element;
|
|
37
|
-
if (on && isFunction(on.updateState)) {
|
|
38
|
-
on.updateState(changes, state, element);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const propsUpdated = (element) => {
|
|
42
|
-
const { props, state, on } = element;
|
|
43
|
-
if (on && isFunction(on.propsUpdated)) {
|
|
44
|
-
on.propsUpdated(props, state, element);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const update = (params, element, state) => {
|
|
48
|
-
if (element.on && isFunction(element.on.update)) {
|
|
49
|
-
element.on.update(element, state);
|
|
50
|
-
}
|
|
51
|
-
return params;
|
|
52
|
-
};
|
|
53
|
-
export {
|
|
54
|
-
createState,
|
|
55
|
-
init,
|
|
56
|
-
propsUpdated,
|
|
57
|
-
render,
|
|
58
|
-
update,
|
|
59
|
-
updateState,
|
|
60
|
-
updateStateInit
|
|
61
|
-
};
|
package/legacy.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
}
|