@rhtml/decorators 0.0.113 → 0.0.116
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/host-binding.js +4 -3
- package/dist/host-binding.js.map +1 -1
- package/dist/host-listener.js +5 -4
- package/dist/host-listener.js.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -11
- package/src/host-binding.ts +46 -47
- package/src/host-listener.ts +40 -42
- package/.eslintrc.js +0 -26
- package/.prettierrc +0 -4
- package/jest.config.js +0 -16
package/dist/host-binding.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HostBinding = void 0;
|
|
7
7
|
// type Styles = keyof CSSStyleDeclaration;
|
|
8
8
|
// type Binding<T = Type> = T extends Style ? `${T}.${Styles}` : `${Class}.${string}`;
|
|
9
|
-
|
|
9
|
+
const HostBinding = (binding /* Binding<T> */) => (target, memberName) => {
|
|
10
10
|
const [type, key] = binding.split('.');
|
|
11
11
|
const OnInit = target['OnInit'] ||
|
|
12
12
|
function () {
|
|
@@ -43,7 +43,7 @@ exports.HostBinding = (binding /* Binding<T> */) => (target, memberName) => {
|
|
|
43
43
|
apply(value)(element);
|
|
44
44
|
currentValue = value;
|
|
45
45
|
},
|
|
46
|
-
configurable: true
|
|
46
|
+
configurable: true,
|
|
47
47
|
});
|
|
48
48
|
if (currentValue) {
|
|
49
49
|
apply(currentValue)(element);
|
|
@@ -51,7 +51,8 @@ exports.HostBinding = (binding /* Binding<T> */) => (target, memberName) => {
|
|
|
51
51
|
return OnInit.apply(this, args);
|
|
52
52
|
},
|
|
53
53
|
configurable: true,
|
|
54
|
-
writable: true
|
|
54
|
+
writable: true,
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
+
exports.HostBinding = HostBinding;
|
|
57
58
|
//# sourceMappingURL=host-binding.js.map
|
package/dist/host-binding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-binding.js","sourceRoot":"","sources":["../src/host-binding.ts"],"names":[],"mappings":";AAAA,wBAAwB;AACxB,wBAAwB;AACxB,6BAA6B;;;AAE7B,2CAA2C;AAE3C,sFAAsF;
|
|
1
|
+
{"version":3,"file":"host-binding.js","sourceRoot":"","sources":["../src/host-binding.ts"],"names":[],"mappings":";AAAA,wBAAwB;AACxB,wBAAwB;AACxB,6BAA6B;;;AAE7B,2CAA2C;AAE3C,sFAAsF;AAE/E,MAAM,WAAW,GACtB,CAAI,OAAe,CAAC,gBAAgB,EAAE,EAAE,CACxC,CAAC,MAAM,EAAE,UAAkB,EAAE,EAAE;IAC7B,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,MAAM,MAAM,GACV,MAAM,CAAC,QAAQ,CAAC;QAChB;YACE,MAAM;QACR,CAAC,CAAC;IACJ,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,OAAoB,EAAE,EAAE;QACxD,IAAI,IAAI,KAAK,OAAO,EAAE;YACpB,IAAI,CAAC,KAAK,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;aAC3B;iBAAM;gBACL,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aAC5B;SACF;QACD,IAAI,IAAI,KAAK,OAAO,EAAE;YACpB,IAAI,CAAC,KAAK,EAAE;gBACV,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC/B;iBAAM;gBACL,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aAC5B;SACF;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;QACtC,KAAK,EAAE,UAAU,GAAG,IAAe;;YACjC,IAAI,YAAY,GAAW,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5C,MAAM,OAAO,GAAgB,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAI,CAAC;YAElD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;gBACxC,GAAG,EAAE;oBACH,OAAO,YAAY,CAAC;gBACtB,CAAC;gBACD,GAAG,EAAE,UAAU,KAAK;oBAClB,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;oBACtB,YAAY,GAAG,KAAK,CAAC;gBACvB,CAAC;gBACD,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;YACH,IAAI,YAAY,EAAE;gBAChB,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC;aAC9B;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC,CAAC;AAlDS,QAAA,WAAW,eAkDpB"}
|
package/dist/host-listener.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HostListener = void 0;
|
|
4
|
-
|
|
4
|
+
const HostListener = (event) => (target, key, propertyDescriptor) => {
|
|
5
5
|
const wrapper = function (...args) {
|
|
6
6
|
return propertyDescriptor.value.apply(this, args);
|
|
7
7
|
};
|
|
@@ -21,7 +21,7 @@ exports.HostListener = (event) => (target, key, propertyDescriptor) => {
|
|
|
21
21
|
return OnInit.apply(this, args);
|
|
22
22
|
},
|
|
23
23
|
configurable: true,
|
|
24
|
-
writable: true
|
|
24
|
+
writable: true,
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(target, 'OnDestroy', {
|
|
27
27
|
value: function (...args) {
|
|
@@ -31,10 +31,11 @@ exports.HostListener = (event) => (target, key, propertyDescriptor) => {
|
|
|
31
31
|
return OnDestroy.apply(this, args);
|
|
32
32
|
},
|
|
33
33
|
configurable: true,
|
|
34
|
-
writable: true
|
|
34
|
+
writable: true,
|
|
35
35
|
});
|
|
36
36
|
return {
|
|
37
|
-
get: () => wrapper
|
|
37
|
+
get: () => wrapper,
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
exports.HostListener = HostListener;
|
|
40
41
|
//# sourceMappingURL=host-listener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-listener.js","sourceRoot":"","sources":["../src/host-listener.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"host-listener.js","sourceRoot":"","sources":["../src/host-listener.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GACvB,CAAC,KAA6B,EAAE,EAAE,CAClC,CAAC,MAAe,EAAE,GAAW,EAAE,kBAAsC,EAAE,EAAE;IACvE,MAAM,OAAO,GAAG,UAAU,GAAG,IAAe;QAC1C,OAAO,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC;IACF,MAAM,MAAM,GACV,MAAM,CAAC,QAAQ,CAAC;QAChB;YACE,MAAM;QACR,CAAC,CAAC;IACJ,MAAM,SAAS,GACb,MAAM,CAAC,WAAW,CAAC;QACnB;YACE,MAAM;QACR,CAAC,CAAC;IAEJ,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;QACtC,KAAK,EAAE,UAAU,GAAG,IAAe;;YACjC,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAI,CAAC;YACrC,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE,CACrD,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAC1B,CAAC;YACF,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IAEH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;QACzC,KAAK,EAAE,UAAU,GAAG,IAAe;;YACjC,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAI,CAAC;YACrC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE,CACxD,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAC1B,CAAC;YACF,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;KACnB,CAAC;AACJ,CAAC,CAAC;AA3CS,QAAA,YAAY,gBA2CrB"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./host-listener"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhtml/decorators",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.116",
|
|
4
4
|
"description": "Reactive HyperText Markup Language",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "npx parcel ./examples/index.html --out-dir build/examples",
|
|
@@ -16,16 +16,7 @@
|
|
|
16
16
|
"url": "git@github.com:rhtml/rhtml.git"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"eslint": "^6.7.2",
|
|
21
|
-
"eslint-config-prettier": "^6.7.0",
|
|
22
|
-
"eslint-plugin-prettier": "^3.1.1",
|
|
23
|
-
"eslint-plugin-simple-import-sort": "^5.0.0",
|
|
24
|
-
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
|
25
|
-
"@typescript-eslint/parser": "^2.10.0",
|
|
26
|
-
"prettier": "^1.19.1",
|
|
27
|
-
"ts-jest": "25.2.1"
|
|
28
|
-
},
|
|
19
|
+
"devDependencies": {},
|
|
29
20
|
"author": "Kristiyan Tachev",
|
|
30
21
|
"license": "MIT",
|
|
31
22
|
"browserslist": [
|
package/src/host-binding.ts
CHANGED
|
@@ -6,55 +6,54 @@
|
|
|
6
6
|
|
|
7
7
|
// type Binding<T = Type> = T extends Style ? `${T}.${Styles}` : `${Class}.${string}`;
|
|
8
8
|
|
|
9
|
-
export const HostBinding =
|
|
10
|
-
|
|
11
|
-
memberName: string
|
|
12
|
-
|
|
13
|
-
const [type, key] = binding.split('.');
|
|
9
|
+
export const HostBinding =
|
|
10
|
+
<T>(binding: string /* Binding<T> */) =>
|
|
11
|
+
(target, memberName: string) => {
|
|
12
|
+
const [type, key] = binding.split('.');
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const OnInit =
|
|
15
|
+
target['OnInit'] ||
|
|
16
|
+
function () {
|
|
17
|
+
/* */
|
|
18
|
+
};
|
|
19
|
+
const apply = (value: string) => (element: HTMLElement) => {
|
|
20
|
+
if (type === 'style') {
|
|
21
|
+
if (!value) {
|
|
22
|
+
element.style[key] = null;
|
|
23
|
+
} else {
|
|
24
|
+
element.style[key] = value;
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if (type === 'class') {
|
|
28
|
+
if (!value) {
|
|
29
|
+
element.classList.remove(key);
|
|
30
|
+
} else {
|
|
31
|
+
element.classList.add(key);
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
34
|
+
};
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
Object.defineProperty(target, 'OnInit', {
|
|
37
|
+
value: function (...args: unknown[]) {
|
|
38
|
+
let currentValue: string = this[memberName];
|
|
39
|
+
const element: HTMLElement = this.element ?? this;
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
41
|
+
Object.defineProperty(target, memberName, {
|
|
42
|
+
get: function () {
|
|
43
|
+
return currentValue;
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
apply(value)(element);
|
|
47
|
+
currentValue = value;
|
|
48
|
+
},
|
|
49
|
+
configurable: true,
|
|
50
|
+
});
|
|
51
|
+
if (currentValue) {
|
|
52
|
+
apply(currentValue)(element);
|
|
53
|
+
}
|
|
54
|
+
return OnInit.apply(this, args);
|
|
55
|
+
},
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
});
|
|
59
|
+
};
|
package/src/host-listener.ts
CHANGED
|
@@ -1,46 +1,44 @@
|
|
|
1
|
-
export const HostListener =
|
|
2
|
-
|
|
3
|
-
key: string,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const wrapper = function(...args: unknown[]) {
|
|
7
|
-
return propertyDescriptor.value.apply(this, args);
|
|
8
|
-
};
|
|
9
|
-
const OnInit =
|
|
10
|
-
target['OnInit'] ||
|
|
11
|
-
function() {
|
|
12
|
-
/* */
|
|
13
|
-
};
|
|
14
|
-
const OnDestroy =
|
|
15
|
-
target['OnDestroy'] ||
|
|
16
|
-
function() {
|
|
17
|
-
/* */
|
|
1
|
+
export const HostListener =
|
|
2
|
+
(event: keyof DocumentEventMap) =>
|
|
3
|
+
(target: unknown, key: string, propertyDescriptor: PropertyDescriptor) => {
|
|
4
|
+
const wrapper = function (...args: unknown[]) {
|
|
5
|
+
return propertyDescriptor.value.apply(this, args);
|
|
18
6
|
};
|
|
7
|
+
const OnInit =
|
|
8
|
+
target['OnInit'] ||
|
|
9
|
+
function () {
|
|
10
|
+
/* */
|
|
11
|
+
};
|
|
12
|
+
const OnDestroy =
|
|
13
|
+
target['OnDestroy'] ||
|
|
14
|
+
function () {
|
|
15
|
+
/* */
|
|
16
|
+
};
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
Object.defineProperty(target, 'OnInit', {
|
|
19
|
+
value: function (...args: unknown[]) {
|
|
20
|
+
const element = this.element ?? this;
|
|
21
|
+
element.addEventListener(event, (...args: unknown[]) =>
|
|
22
|
+
wrapper.apply(this, args)
|
|
23
|
+
);
|
|
24
|
+
return OnInit.apply(this, args);
|
|
25
|
+
},
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
});
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
Object.defineProperty(target, 'OnDestroy', {
|
|
31
|
+
value: function (...args: unknown[]) {
|
|
32
|
+
const element = this.element ?? this;
|
|
33
|
+
element.removeEventListener(event, (...args: unknown[]) =>
|
|
34
|
+
wrapper.apply(this, args)
|
|
35
|
+
);
|
|
36
|
+
return OnDestroy.apply(this, args);
|
|
37
|
+
},
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
get: () => wrapper,
|
|
43
|
+
};
|
|
45
44
|
};
|
|
46
|
-
};
|
package/.eslintrc.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// Specifies the ESLint parser
|
|
3
|
-
parser: "@typescript-eslint/parser",
|
|
4
|
-
extends: [
|
|
5
|
-
// Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
|
6
|
-
"plugin:@typescript-eslint/recommended",
|
|
7
|
-
// Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
|
8
|
-
"prettier/@typescript-eslint",
|
|
9
|
-
// Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
|
10
|
-
"plugin:prettier/recommended"
|
|
11
|
-
],
|
|
12
|
-
parserOptions: {
|
|
13
|
-
// Allows for the parsing of modern ECMAScript features
|
|
14
|
-
ecmaVersion: 2018,
|
|
15
|
-
// Allows for the use of imports
|
|
16
|
-
sourceType: "module"
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
"@typescript-eslint/explicit-function-return-type": 0,
|
|
20
|
-
"simple-import-sort/sort": "error",
|
|
21
|
-
"sort-imports": "off",
|
|
22
|
-
"import/order": "off",
|
|
23
|
-
"@typescript-eslint/camelcase": 0
|
|
24
|
-
},
|
|
25
|
-
plugins: ["simple-import-sort"]
|
|
26
|
-
};
|
package/.prettierrc
DELETED
package/jest.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
testEnvironment: 'node',
|
|
3
|
-
testPathIgnorePatterns: ['/node_modules/'],
|
|
4
|
-
coverageReporters: ['lcov', 'html'],
|
|
5
|
-
rootDir: './',
|
|
6
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'],
|
|
7
|
-
globals: {
|
|
8
|
-
__DEV__: true
|
|
9
|
-
},
|
|
10
|
-
transform: {
|
|
11
|
-
'\\.(ts|tsx)$': 'ts-jest'
|
|
12
|
-
},
|
|
13
|
-
testRegex: '/src/.*\\.spec.(ts|tsx|js)$',
|
|
14
|
-
verbose: true,
|
|
15
|
-
collectCoverage: true
|
|
16
|
-
};
|