@knotx/core 0.4.1 → 0.4.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.
- package/dist/index.cjs +39 -1
- package/dist/index.d.cts +69 -1
- package/dist/index.d.mts +69 -1
- package/dist/index.d.ts +69 -1
- package/dist/index.js +39 -2
- package/package.json +6 -6
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}
|
|
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
|
@@ -6,6 +6,74 @@ 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
|
@@ -6,6 +6,74 @@ 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
|
@@ -6,6 +6,74 @@ 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}
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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.
|
|
50
|
-
"@knotx/utils": "0.4.
|
|
49
|
+
"@knotx/data": "0.4.3",
|
|
50
|
+
"@knotx/utils": "0.4.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/lodash-es": "^4.17.12",
|
|
54
|
-
"@knotx/build-config": "0.4.
|
|
55
|
-
"@knotx/eslint-config": "0.4.
|
|
56
|
-
"@knotx/typescript-config": "0.4.
|
|
54
|
+
"@knotx/build-config": "0.4.3",
|
|
55
|
+
"@knotx/eslint-config": "0.4.3",
|
|
56
|
+
"@knotx/typescript-config": "0.4.3"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "unbuild",
|