@domql/event 2.5.184 → 2.5.185
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/dist/esm/can.js +8 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/legacy.js +61 -0
- package/dist/esm/on.js +58 -0
- package/dist/esm/store.js +7 -0
- package/package.json +9 -9
package/dist/esm/can.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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/dist/esm/on.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isFunction } from "@domql/utils";
|
|
2
|
+
const getOnOrPropsEvent = (param, element) => {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const onEvent = (_a = element.on) == null ? void 0 : _a[param];
|
|
5
|
+
const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
|
|
6
|
+
return onEvent || onPropEvent;
|
|
7
|
+
};
|
|
8
|
+
const applyEvent = (param, element, state, context, options) => {
|
|
9
|
+
return param.call(element, element, state || element.state, context || element.context, options);
|
|
10
|
+
};
|
|
11
|
+
const triggerEventOn = async (param, element, options) => {
|
|
12
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
13
|
+
if (appliedFunction) {
|
|
14
|
+
const { state, context } = element;
|
|
15
|
+
return await applyEvent(appliedFunction, element, state, context, options);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
|
|
19
|
+
return param.call(element, updatedObj, element, state || element.state, context || element.context, options);
|
|
20
|
+
};
|
|
21
|
+
const triggerEventOnUpdate = (param, updatedObj, element, options) => {
|
|
22
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
23
|
+
if (appliedFunction) {
|
|
24
|
+
const { state, context } = element;
|
|
25
|
+
return applyEventUpdate(appliedFunction, updatedObj, element, state, context, options);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const applyAnimationFrame = (element, options) => {
|
|
29
|
+
const { props, on, __ref: ref } = element;
|
|
30
|
+
const { frameListeners } = ref.root.data;
|
|
31
|
+
if (frameListeners && ((on == null ? void 0 : on.frame) || (props == null ? void 0 : props.onFrame))) {
|
|
32
|
+
const { registerFrameListener } = element.context.utils;
|
|
33
|
+
if (registerFrameListener)
|
|
34
|
+
registerFrameListener(element);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const applyEventsOnNode = (element, options) => {
|
|
38
|
+
const { node, on } = element;
|
|
39
|
+
for (const param in on) {
|
|
40
|
+
if (param === "init" || param === "beforeClassAssign" || param === "render" || param === "renderRouter" || param === "attachNode" || param === "stateInit" || param === "stateCreated" || param === "beforeStateUpdate" || param === "stateUpdate" || param === "beforeUpdate" || param === "done" || param === "create" || param === "complete" || param === "frame" || param === "update")
|
|
41
|
+
continue;
|
|
42
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
43
|
+
if (isFunction(appliedFunction)) {
|
|
44
|
+
node.addEventListener(param, (event) => {
|
|
45
|
+
const { state, context } = element;
|
|
46
|
+
appliedFunction.call(element, event, element, state, context, options);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
applyAnimationFrame,
|
|
53
|
+
applyEvent,
|
|
54
|
+
applyEventUpdate,
|
|
55
|
+
applyEventsOnNode,
|
|
56
|
+
triggerEventOn,
|
|
57
|
+
triggerEventOnUpdate
|
|
58
|
+
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.185",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"module": "
|
|
6
|
+
"module": "index.js",
|
|
7
|
+
"main": "index.js",
|
|
7
8
|
"unpkg": "dist/iife/index.js",
|
|
8
9
|
"jsdelivr": "dist/iife/index.js",
|
|
9
|
-
"main": "dist/esm/index.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"default": "./dist/esm/index.js",
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"source": "index.js",
|
|
@@ -23,12 +24,11 @@
|
|
|
23
24
|
"build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
24
25
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
25
26
|
"build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
|
|
26
|
-
"
|
|
27
|
-
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
27
|
+
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@domql/report": "^2.5.162",
|
|
31
|
-
"@domql/utils": "^2.5.
|
|
31
|
+
"@domql/utils": "^2.5.185"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "ccab034f188b6a1f55f741c0b29a9d3b0c9bee6f"
|
|
34
34
|
}
|