@domql/state 3.6.8 → 3.7.3

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.
Files changed (2) hide show
  1. package/dist/iife/index.js +27 -0
  2. package/package.json +3 -3
@@ -428,8 +428,30 @@ var DomqlState = (() => {
428
428
  });
429
429
 
430
430
  // ../utils/dist/esm/function.js
431
+ var resolveHandler, runPluginHook;
431
432
  var init_function = __esm({
432
433
  "../utils/dist/esm/function.js"() {
434
+ resolveHandler = (handler, element) => {
435
+ if (typeof handler === "function") return handler;
436
+ const plugins = element?.context?.plugins;
437
+ if (!plugins) return handler;
438
+ for (const plugin of plugins) {
439
+ if (plugin.resolveHandler) {
440
+ const resolved = plugin.resolveHandler(handler, element);
441
+ if (typeof resolved === "function") return resolved;
442
+ }
443
+ }
444
+ return handler;
445
+ };
446
+ runPluginHook = (hookName, element, ...args) => {
447
+ const plugins = element?.context?.plugins;
448
+ if (!plugins) return;
449
+ for (const plugin of plugins) {
450
+ if (typeof plugin[hookName] === "function") {
451
+ plugin[hookName](element, ...args);
452
+ }
453
+ }
454
+ };
433
455
  }
434
456
  });
435
457
 
@@ -635,6 +657,7 @@ var DomqlState = (() => {
635
657
  var init_triggerEvent = __esm({
636
658
  "../utils/dist/esm/triggerEvent.js"() {
637
659
  init_types();
660
+ init_function();
638
661
  getOnOrPropsEvent = (param, element) => {
639
662
  const onEvent = element.on?.[param];
640
663
  if (onEvent) return onEvent;
@@ -644,6 +667,7 @@ var DomqlState = (() => {
644
667
  return props[propKey];
645
668
  };
646
669
  applyEvent = (param, element, state, context, options) => {
670
+ param = resolveHandler(param, element);
647
671
  if (!isFunction(param)) return;
648
672
  try {
649
673
  const result = param.call(
@@ -670,6 +694,7 @@ var DomqlState = (() => {
670
694
  if (!element) {
671
695
  throw new Error("Element is required");
672
696
  }
697
+ runPluginHook(param, element, options);
673
698
  const appliedFunction = getOnOrPropsEvent(param, element);
674
699
  if (appliedFunction) {
675
700
  const { state, context } = element;
@@ -677,6 +702,7 @@ var DomqlState = (() => {
677
702
  }
678
703
  };
679
704
  applyEventUpdate = (param, updatedObj, element, state, context, options) => {
705
+ param = resolveHandler(param, element);
680
706
  if (!isFunction(param)) return;
681
707
  try {
682
708
  const result = param.call(
@@ -701,6 +727,7 @@ var DomqlState = (() => {
701
727
  }
702
728
  };
703
729
  triggerEventOnUpdate = (param, updatedObj, element, options) => {
730
+ runPluginHook(param, element, updatedObj, options);
704
731
  const appliedFunction = getOnOrPropsEvent(param, element);
705
732
  if (appliedFunction) {
706
733
  const { state, context } = element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/state",
3
- "version": "3.6.8",
3
+ "version": "3.7.3",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -35,8 +35,8 @@
35
35
  "prepublish": "npm run build && npm run copy:package:cjs"
36
36
  },
37
37
  "dependencies": {
38
- "@domql/report": "^3.6.8",
39
- "@domql/utils": "^3.6.8"
38
+ "@domql/report": "^3.7.3",
39
+ "@domql/utils": "^3.7.3"
40
40
  },
41
41
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
42
42
  "browser": "./dist/esm/index.js",