@knotx/core 0.4.0 → 0.4.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.
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.cjs';
3
+ export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.DA6YV1kV.cjs';
4
4
  import '@knotx/data';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.mjs';
3
+ export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.DA6YV1kV.mjs';
4
4
  import '@knotx/data';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.js';
3
+ export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.DA6YV1kV.js';
4
4
  import '@knotx/data';
package/dist/index.cjs CHANGED
@@ -8,6 +8,43 @@ const core = require('@knotx/core');
8
8
  const utils = require('@knotx/utils');
9
9
  const data = require('@knotx/data');
10
10
 
11
+ var __defProp$5 = Object.defineProperty;
12
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __publicField$4 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
14
+ class DOMElement {
15
+ constructor(dom) {
16
+ this.dom = dom;
17
+ __publicField$4(this, "classList");
18
+ __publicField$4(this, "attribute");
19
+ this.classList = dom.classList;
20
+ this.attribute = {
21
+ get: (name) => dom.getAttribute(name),
22
+ set: (name, value) => dom.setAttribute(name, value),
23
+ remove: (name) => dom.removeAttribute(name)
24
+ };
25
+ }
26
+ getRect() {
27
+ return this.dom.getBoundingClientRect();
28
+ }
29
+ query(selector) {
30
+ const element = this.dom.querySelector(selector);
31
+ return element ? DOMElement.fromDOM(element) : null;
32
+ }
33
+ queryAll(selector) {
34
+ const elements = this.dom.querySelectorAll(selector);
35
+ return Array.from(elements).map((element) => DOMElement.fromDOM(element));
36
+ }
37
+ addEventListener(...args) {
38
+ this.dom.addEventListener(...args);
39
+ }
40
+ removeEventListener(...args) {
41
+ this.dom.removeEventListener(...args);
42
+ }
43
+ static fromDOM(dom) {
44
+ return new DOMElement(dom);
45
+ }
46
+ }
47
+
11
48
  var __defProp$4 = Object.defineProperty;
12
49
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
50
  var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
@@ -442,7 +479,7 @@ const _BasePlugin = class _BasePlugin {
442
479
  Reflect.set(this, utils.getSymbol("engine"), new rxjs.BehaviorSubject(null));
443
480
  }
444
481
  get pluginId() {
445
- return `${this.name}:${this._instanceId}`;
482
+ return `${this.name.toLowerCase()}-${this._instanceId}`;
446
483
  }
447
484
  onDestroy() {
448
485
  this.subscriptions.forEach((subscription) => {
@@ -544,6 +581,7 @@ function use(hook, context) {
544
581
 
545
582
  exports.Layer = definition.Layer;
546
583
  exports.BasePlugin = BasePlugin;
584
+ exports.DOMElement = DOMElement;
547
585
  exports.Engine = Engine;
548
586
  exports.InteractionManager = InteractionManager;
549
587
  exports.InteractionPriority = InteractionPriority;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,79 @@
1
- import { E as Engine } from './shared/core.CJuzxwMC.cjs';
2
- export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.cjs';
1
+ import { E as Engine } from './shared/core.DA6YV1kV.cjs';
2
+ export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.DA6YV1kV.cjs';
3
3
  import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  export * from '@knotx/data';
6
6
  export * from '@knotx/utils';
7
7
  import 'jsonschema';
8
8
 
9
+ interface ElementClassList {
10
+ toString: () => string;
11
+ /**
12
+ * Adds all arguments passed, except those already present.
13
+ *
14
+ * Throws a "SyntaxError" DOMException if one of the arguments is the empty string.
15
+ *
16
+ * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
17
+ *
18
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/add)
19
+ */
20
+ add: (...tokens: string[]) => void;
21
+ /**
22
+ * Returns true if token is present, and false otherwise.
23
+ *
24
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/contains)
25
+ */
26
+ contains: (token: string) => boolean;
27
+ /**
28
+ * Removes arguments passed, if they are present.
29
+ *
30
+ * Throws a "SyntaxError" DOMException if one of the arguments is the empty string.
31
+ *
32
+ * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
33
+ *
34
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/remove)
35
+ */
36
+ remove: (...tokens: string[]) => void;
37
+ }
38
+ interface ElementAttribute {
39
+ get: (name: string) => string | null;
40
+ set: (name: string, value: string) => void;
41
+ remove: (name: string) => void;
42
+ }
43
+ interface ElementRect {
44
+ height: number;
45
+ width: number;
46
+ x: number;
47
+ y: number;
48
+ }
49
+ interface EventListenerDefinition<E = any> {
50
+ (type: string, listener: ((evt: E) => void) | EventListenerObject<E>, options?: boolean | AddEventListenerOptions): void;
51
+ }
52
+ interface EventListenerObject<E> {
53
+ handleEvent: (evt: E) => void;
54
+ }
55
+ interface Element {
56
+ classList: ElementClassList;
57
+ attribute: ElementAttribute;
58
+ getRect: () => ElementRect;
59
+ addEventListener: EventListenerDefinition;
60
+ removeEventListener: EventListenerDefinition;
61
+ query: (selector: string) => Element | null;
62
+ queryAll: (selector: string) => Element[];
63
+ }
64
+ declare class DOMElement implements Element {
65
+ readonly dom: HTMLElement;
66
+ classList: ElementClassList;
67
+ attribute: ElementAttribute;
68
+ constructor(dom: HTMLElement);
69
+ getRect(): DOMRect;
70
+ query(selector: string): Element | null;
71
+ queryAll(selector: string): Element[];
72
+ addEventListener(...args: Parameters<EventListenerDefinition>): void;
73
+ removeEventListener(...args: Parameters<EventListenerDefinition>): void;
74
+ static fromDOM(dom: HTMLElement): DOMElement;
75
+ }
76
+
9
77
  declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
10
78
 
11
79
  /**
@@ -69,4 +137,4 @@ declare function use<T, TContext>(hook: () => {
69
137
  __contextValue__: TContext;
70
138
  }, context: TContext): T;
71
139
 
72
- export { Engine, Runtime, getLayerRenders, use };
140
+ export { DOMElement, type Element, type ElementAttribute, type ElementClassList, type ElementRect, Engine, type EventListenerDefinition, Runtime, getLayerRenders, use };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,79 @@
1
- import { E as Engine } from './shared/core.CJuzxwMC.mjs';
2
- export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.mjs';
1
+ import { E as Engine } from './shared/core.DA6YV1kV.mjs';
2
+ export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.DA6YV1kV.mjs';
3
3
  import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  export * from '@knotx/data';
6
6
  export * from '@knotx/utils';
7
7
  import 'jsonschema';
8
8
 
9
+ interface ElementClassList {
10
+ toString: () => string;
11
+ /**
12
+ * Adds all arguments passed, except those already present.
13
+ *
14
+ * Throws a "SyntaxError" DOMException if one of the arguments is the empty string.
15
+ *
16
+ * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
17
+ *
18
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/add)
19
+ */
20
+ add: (...tokens: string[]) => void;
21
+ /**
22
+ * Returns true if token is present, and false otherwise.
23
+ *
24
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/contains)
25
+ */
26
+ contains: (token: string) => boolean;
27
+ /**
28
+ * Removes arguments passed, if they are present.
29
+ *
30
+ * Throws a "SyntaxError" DOMException if one of the arguments is the empty string.
31
+ *
32
+ * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
33
+ *
34
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/remove)
35
+ */
36
+ remove: (...tokens: string[]) => void;
37
+ }
38
+ interface ElementAttribute {
39
+ get: (name: string) => string | null;
40
+ set: (name: string, value: string) => void;
41
+ remove: (name: string) => void;
42
+ }
43
+ interface ElementRect {
44
+ height: number;
45
+ width: number;
46
+ x: number;
47
+ y: number;
48
+ }
49
+ interface EventListenerDefinition<E = any> {
50
+ (type: string, listener: ((evt: E) => void) | EventListenerObject<E>, options?: boolean | AddEventListenerOptions): void;
51
+ }
52
+ interface EventListenerObject<E> {
53
+ handleEvent: (evt: E) => void;
54
+ }
55
+ interface Element {
56
+ classList: ElementClassList;
57
+ attribute: ElementAttribute;
58
+ getRect: () => ElementRect;
59
+ addEventListener: EventListenerDefinition;
60
+ removeEventListener: EventListenerDefinition;
61
+ query: (selector: string) => Element | null;
62
+ queryAll: (selector: string) => Element[];
63
+ }
64
+ declare class DOMElement implements Element {
65
+ readonly dom: HTMLElement;
66
+ classList: ElementClassList;
67
+ attribute: ElementAttribute;
68
+ constructor(dom: HTMLElement);
69
+ getRect(): DOMRect;
70
+ query(selector: string): Element | null;
71
+ queryAll(selector: string): Element[];
72
+ addEventListener(...args: Parameters<EventListenerDefinition>): void;
73
+ removeEventListener(...args: Parameters<EventListenerDefinition>): void;
74
+ static fromDOM(dom: HTMLElement): DOMElement;
75
+ }
76
+
9
77
  declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
10
78
 
11
79
  /**
@@ -69,4 +137,4 @@ declare function use<T, TContext>(hook: () => {
69
137
  __contextValue__: TContext;
70
138
  }, context: TContext): T;
71
139
 
72
- export { Engine, Runtime, getLayerRenders, use };
140
+ export { DOMElement, type Element, type ElementAttribute, type ElementClassList, type ElementRect, Engine, type EventListenerDefinition, Runtime, getLayerRenders, use };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,79 @@
1
- import { E as Engine } from './shared/core.CJuzxwMC.js';
2
- export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.js';
1
+ import { E as Engine } from './shared/core.DA6YV1kV.js';
2
+ export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.DA6YV1kV.js';
3
3
  import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  export * from '@knotx/data';
6
6
  export * from '@knotx/utils';
7
7
  import 'jsonschema';
8
8
 
9
+ interface ElementClassList {
10
+ toString: () => string;
11
+ /**
12
+ * Adds all arguments passed, except those already present.
13
+ *
14
+ * Throws a "SyntaxError" DOMException if one of the arguments is the empty string.
15
+ *
16
+ * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
17
+ *
18
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/add)
19
+ */
20
+ add: (...tokens: string[]) => void;
21
+ /**
22
+ * Returns true if token is present, and false otherwise.
23
+ *
24
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/contains)
25
+ */
26
+ contains: (token: string) => boolean;
27
+ /**
28
+ * Removes arguments passed, if they are present.
29
+ *
30
+ * Throws a "SyntaxError" DOMException if one of the arguments is the empty string.
31
+ *
32
+ * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
33
+ *
34
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/remove)
35
+ */
36
+ remove: (...tokens: string[]) => void;
37
+ }
38
+ interface ElementAttribute {
39
+ get: (name: string) => string | null;
40
+ set: (name: string, value: string) => void;
41
+ remove: (name: string) => void;
42
+ }
43
+ interface ElementRect {
44
+ height: number;
45
+ width: number;
46
+ x: number;
47
+ y: number;
48
+ }
49
+ interface EventListenerDefinition<E = any> {
50
+ (type: string, listener: ((evt: E) => void) | EventListenerObject<E>, options?: boolean | AddEventListenerOptions): void;
51
+ }
52
+ interface EventListenerObject<E> {
53
+ handleEvent: (evt: E) => void;
54
+ }
55
+ interface Element {
56
+ classList: ElementClassList;
57
+ attribute: ElementAttribute;
58
+ getRect: () => ElementRect;
59
+ addEventListener: EventListenerDefinition;
60
+ removeEventListener: EventListenerDefinition;
61
+ query: (selector: string) => Element | null;
62
+ queryAll: (selector: string) => Element[];
63
+ }
64
+ declare class DOMElement implements Element {
65
+ readonly dom: HTMLElement;
66
+ classList: ElementClassList;
67
+ attribute: ElementAttribute;
68
+ constructor(dom: HTMLElement);
69
+ getRect(): DOMRect;
70
+ query(selector: string): Element | null;
71
+ queryAll(selector: string): Element[];
72
+ addEventListener(...args: Parameters<EventListenerDefinition>): void;
73
+ removeEventListener(...args: Parameters<EventListenerDefinition>): void;
74
+ static fromDOM(dom: HTMLElement): DOMElement;
75
+ }
76
+
9
77
  declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
10
78
 
11
79
  /**
@@ -69,4 +137,4 @@ declare function use<T, TContext>(hook: () => {
69
137
  __contextValue__: TContext;
70
138
  }, context: TContext): T;
71
139
 
72
- export { Engine, Runtime, getLayerRenders, use };
140
+ export { DOMElement, type Element, type ElementAttribute, type ElementClassList, type ElementRect, Engine, type EventListenerDefinition, Runtime, getLayerRenders, use };
package/dist/index.js CHANGED
@@ -8,6 +8,43 @@ export * from '@knotx/utils';
8
8
  import { DataManager } from '@knotx/data';
9
9
  export * from '@knotx/data';
10
10
 
11
+ var __defProp$5 = Object.defineProperty;
12
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __publicField$4 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
14
+ class DOMElement {
15
+ constructor(dom) {
16
+ this.dom = dom;
17
+ __publicField$4(this, "classList");
18
+ __publicField$4(this, "attribute");
19
+ this.classList = dom.classList;
20
+ this.attribute = {
21
+ get: (name) => dom.getAttribute(name),
22
+ set: (name, value) => dom.setAttribute(name, value),
23
+ remove: (name) => dom.removeAttribute(name)
24
+ };
25
+ }
26
+ getRect() {
27
+ return this.dom.getBoundingClientRect();
28
+ }
29
+ query(selector) {
30
+ const element = this.dom.querySelector(selector);
31
+ return element ? DOMElement.fromDOM(element) : null;
32
+ }
33
+ queryAll(selector) {
34
+ const elements = this.dom.querySelectorAll(selector);
35
+ return Array.from(elements).map((element) => DOMElement.fromDOM(element));
36
+ }
37
+ addEventListener(...args) {
38
+ this.dom.addEventListener(...args);
39
+ }
40
+ removeEventListener(...args) {
41
+ this.dom.removeEventListener(...args);
42
+ }
43
+ static fromDOM(dom) {
44
+ return new DOMElement(dom);
45
+ }
46
+ }
47
+
11
48
  var __defProp$4 = Object.defineProperty;
12
49
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
50
  var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
@@ -442,7 +479,7 @@ const _BasePlugin = class _BasePlugin {
442
479
  Reflect.set(this, getSymbol("engine"), new BehaviorSubject(null));
443
480
  }
444
481
  get pluginId() {
445
- return `${this.name}:${this._instanceId}`;
482
+ return `${this.name.toLowerCase()}-${this._instanceId}`;
446
483
  }
447
484
  onDestroy() {
448
485
  this.subscriptions.forEach((subscription) => {
@@ -542,4 +579,4 @@ function use(hook, context) {
542
579
  return Runtime.getInstance().runInContext("render", hook, context);
543
580
  }
544
581
 
545
- export { BasePlugin, Engine, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
582
+ export { BasePlugin, DOMElement, Engine, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
@@ -164,7 +164,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
164
164
  }): void;
165
165
  resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
166
166
  registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
167
- registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: EdgeConfig): (() => void);
167
+ registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: Required<EdgeConfig>): (() => void);
168
168
  listPlugins(): IPluginInfo[];
169
169
  listPluginTools({ pluginName }: {
170
170
  pluginName: string;
@@ -209,7 +209,7 @@ interface Node<TData extends IRecord = IRecord> {
209
209
  interface NodeProps<TData extends IRecord = IRecord> {
210
210
  node: Node<TData>;
211
211
  }
212
- interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
212
+ interface Edge<TData extends IRecord = IRecord> extends EdgeConfig {
213
213
  id: string;
214
214
  source: string;
215
215
  target: string;
@@ -217,12 +217,12 @@ interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
217
217
  data?: TData;
218
218
  }
219
219
  interface EdgeConfig {
220
- sourcePosition: Position;
221
- targetPosition: Position;
222
- sourceYOffset: string | number;
223
- sourceXOffset: string | number;
224
- targetYOffset: string | number;
225
- targetXOffset: string | number;
220
+ sourcePosition?: Position;
221
+ targetPosition?: Position;
222
+ sourceYOffset?: string | number;
223
+ sourceXOffset?: string | number;
224
+ targetYOffset?: string | number;
225
+ targetXOffset?: string | number;
226
226
  }
227
227
  interface EdgeProps<TData extends IRecord = IRecord> {
228
228
  edge: Edge<TData>;
@@ -241,7 +241,7 @@ type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>)
241
241
  type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
242
242
  interface EdgeRender<TD extends IRecord = any, TR = any> {
243
243
  renderer: EdgeRenderType<TD, TR>;
244
- config: EdgeConfig;
244
+ config: Required<EdgeConfig>;
245
245
  }
246
246
  declare enum Layer {
247
247
  Canvas = 0,
@@ -164,7 +164,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
164
164
  }): void;
165
165
  resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
166
166
  registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
167
- registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: EdgeConfig): (() => void);
167
+ registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: Required<EdgeConfig>): (() => void);
168
168
  listPlugins(): IPluginInfo[];
169
169
  listPluginTools({ pluginName }: {
170
170
  pluginName: string;
@@ -209,7 +209,7 @@ interface Node<TData extends IRecord = IRecord> {
209
209
  interface NodeProps<TData extends IRecord = IRecord> {
210
210
  node: Node<TData>;
211
211
  }
212
- interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
212
+ interface Edge<TData extends IRecord = IRecord> extends EdgeConfig {
213
213
  id: string;
214
214
  source: string;
215
215
  target: string;
@@ -217,12 +217,12 @@ interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
217
217
  data?: TData;
218
218
  }
219
219
  interface EdgeConfig {
220
- sourcePosition: Position;
221
- targetPosition: Position;
222
- sourceYOffset: string | number;
223
- sourceXOffset: string | number;
224
- targetYOffset: string | number;
225
- targetXOffset: string | number;
220
+ sourcePosition?: Position;
221
+ targetPosition?: Position;
222
+ sourceYOffset?: string | number;
223
+ sourceXOffset?: string | number;
224
+ targetYOffset?: string | number;
225
+ targetXOffset?: string | number;
226
226
  }
227
227
  interface EdgeProps<TData extends IRecord = IRecord> {
228
228
  edge: Edge<TData>;
@@ -241,7 +241,7 @@ type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>)
241
241
  type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
242
242
  interface EdgeRender<TD extends IRecord = any, TR = any> {
243
243
  renderer: EdgeRenderType<TD, TR>;
244
- config: EdgeConfig;
244
+ config: Required<EdgeConfig>;
245
245
  }
246
246
  declare enum Layer {
247
247
  Canvas = 0,
@@ -164,7 +164,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
164
164
  }): void;
165
165
  resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
166
166
  registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
167
- registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: EdgeConfig): (() => void);
167
+ registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: Required<EdgeConfig>): (() => void);
168
168
  listPlugins(): IPluginInfo[];
169
169
  listPluginTools({ pluginName }: {
170
170
  pluginName: string;
@@ -209,7 +209,7 @@ interface Node<TData extends IRecord = IRecord> {
209
209
  interface NodeProps<TData extends IRecord = IRecord> {
210
210
  node: Node<TData>;
211
211
  }
212
- interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
212
+ interface Edge<TData extends IRecord = IRecord> extends EdgeConfig {
213
213
  id: string;
214
214
  source: string;
215
215
  target: string;
@@ -217,12 +217,12 @@ interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
217
217
  data?: TData;
218
218
  }
219
219
  interface EdgeConfig {
220
- sourcePosition: Position;
221
- targetPosition: Position;
222
- sourceYOffset: string | number;
223
- sourceXOffset: string | number;
224
- targetYOffset: string | number;
225
- targetXOffset: string | number;
220
+ sourcePosition?: Position;
221
+ targetPosition?: Position;
222
+ sourceYOffset?: string | number;
223
+ sourceXOffset?: string | number;
224
+ targetYOffset?: string | number;
225
+ targetXOffset?: string | number;
226
226
  }
227
227
  interface EdgeProps<TData extends IRecord = IRecord> {
228
228
  edge: Edge<TData>;
@@ -241,7 +241,7 @@ type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>)
241
241
  type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
242
242
  interface EdgeRender<TD extends IRecord = any, TR = any> {
243
243
  renderer: EdgeRenderType<TD, TR>;
244
- config: EdgeConfig;
244
+ config: Required<EdgeConfig>;
245
245
  }
246
246
  declare enum Layer {
247
247
  Canvas = 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Core for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -46,14 +46,14 @@
46
46
  "jsonschema": "^1.5.0",
47
47
  "lodash-es": "^4.17.21",
48
48
  "rxjs": "^7.8.1",
49
- "@knotx/data": "0.4.0",
50
- "@knotx/utils": "0.4.0"
49
+ "@knotx/data": "0.4.2",
50
+ "@knotx/utils": "0.4.2"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/lodash-es": "^4.17.12",
54
- "@knotx/build-config": "0.4.0",
55
- "@knotx/eslint-config": "0.4.0",
56
- "@knotx/typescript-config": "0.4.0"
54
+ "@knotx/build-config": "0.4.2",
55
+ "@knotx/eslint-config": "0.4.2",
56
+ "@knotx/typescript-config": "0.4.2"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "unbuild",