@htmlplus/element 2.9.3 → 2.9.5

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 (70) hide show
  1. package/README.md +0 -1
  2. package/client/decorators/bind.js +1 -1
  3. package/client/decorators/context.js +4 -6
  4. package/client/decorators/element.d.ts +1 -1
  5. package/client/decorators/element.js +44 -47
  6. package/client/decorators/event.d.ts +1 -1
  7. package/client/decorators/event.js +4 -5
  8. package/client/decorators/listen.d.ts +1 -1
  9. package/client/decorators/listen.js +1 -1
  10. package/client/decorators/method.d.ts +1 -1
  11. package/client/decorators/property.d.ts +1 -1
  12. package/client/decorators/property.js +7 -8
  13. package/client/decorators/state.d.ts +1 -1
  14. package/client/decorators/watch.d.ts +1 -1
  15. package/client/utils/appendToMethod.js +1 -1
  16. package/client/utils/attributes.d.ts +1 -1
  17. package/client/utils/attributes.js +1 -1
  18. package/client/utils/call.js +1 -2
  19. package/client/utils/config.js +1 -1
  20. package/client/utils/direction.d.ts +1 -1
  21. package/client/utils/event.d.ts +1 -1
  22. package/client/utils/getFramework.d.ts +1 -1
  23. package/client/utils/getStyles.d.ts +1 -1
  24. package/client/utils/getStyles.js +1 -2
  25. package/client/utils/getTag.d.ts +1 -1
  26. package/client/utils/getTag.js +1 -2
  27. package/client/utils/host.d.ts +1 -1
  28. package/client/utils/host.js +1 -1
  29. package/client/utils/isEvent.js +1 -1
  30. package/client/utils/isRTL.d.ts +1 -1
  31. package/client/utils/query.d.ts +1 -1
  32. package/client/utils/query.js +1 -2
  33. package/client/utils/queryAll.d.ts +1 -1
  34. package/client/utils/queryAll.js +1 -2
  35. package/client/utils/request.d.ts +1 -1
  36. package/client/utils/request.js +2 -3
  37. package/client/utils/shadowRoot.d.ts +1 -1
  38. package/client/utils/shadowRoot.js +1 -2
  39. package/client/utils/slots.d.ts +1 -1
  40. package/client/utils/slots.js +1 -2
  41. package/client/utils/toDecorator.d.ts +1 -1
  42. package/client/utils/toEvent.js +1 -1
  43. package/client/utils/toProperty.js +2 -2
  44. package/client/utils/updateAttribute.d.ts +1 -1
  45. package/package.json +19 -19
  46. package/transformer/plugins/assets.d.ts +1 -1
  47. package/transformer/plugins/copy.d.ts +1 -1
  48. package/transformer/plugins/customElement.d.ts +1 -1
  49. package/transformer/plugins/customElement.js +12 -13
  50. package/transformer/plugins/document.d.ts +1 -1
  51. package/transformer/plugins/document.js +18 -26
  52. package/transformer/plugins/extract.d.ts +1 -1
  53. package/transformer/plugins/extract.js +3 -4
  54. package/transformer/plugins/parse.d.ts +1 -1
  55. package/transformer/plugins/read.d.ts +2 -3
  56. package/transformer/plugins/readme.d.ts +1 -1
  57. package/transformer/plugins/style.d.ts +1 -1
  58. package/transformer/plugins/validate.d.ts +1 -1
  59. package/transformer/plugins/validate.js +1 -2
  60. package/transformer/plugins/visualStudioCode.d.ts +1 -1
  61. package/transformer/plugins/visualStudioCode.js +3 -4
  62. package/transformer/plugins/webTypes.d.ts +1 -1
  63. package/transformer/plugins/webTypes.js +15 -19
  64. package/transformer/transformer.d.ts +1 -1
  65. package/transformer/utils/addDependency.js +2 -3
  66. package/transformer/utils/extractAttribute.js +1 -1
  67. package/transformer/utils/extractFromComment.js +11 -8
  68. package/transformer/utils/getInitializer.js +1 -2
  69. package/transformer/utils/getType.js +3 -3
  70. package/transformer/utils/hasDecorator.js +1 -1
package/README.md CHANGED
@@ -26,7 +26,6 @@ A powerful tool for building a scalable, reusable, fast, and lightweight `UI Com
26
26
  - **Style File Recognition**: Identifies and links the relevant style file to the element.
27
27
  - **Tag Name Recognition**: Generates tag name from the class name.
28
28
  - **Clean Syntax**: Uses a minimal amount of code to achieve the same functionality, making the code easier to read, understand, and maintain.
29
- - **Attribute Over Class**: Uses HTML attributes instead of HTML class names to keep the size of the start tag short, making it more readable and preventing the DOM from getting dirty.
30
29
 
31
30
  ## Quick Start
32
31
 
@@ -8,7 +8,7 @@ export function Bind() {
8
8
  return {
9
9
  configurable: true,
10
10
  get() {
11
- const value = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value.bind(this);
11
+ const value = descriptor?.value.bind(this);
12
12
  defineProperty(this, key, {
13
13
  value,
14
14
  configurable: true,
@@ -6,7 +6,7 @@ export function Provider(namespace) {
6
6
  const [MAIN, SUB] = namespace.split('.');
7
7
  const prefix = `htmlplus:${MAIN}`;
8
8
  const cleanups = (instance) => {
9
- return (instance[symbol] || (instance[symbol] = new Map()));
9
+ return (instance[symbol] ||= new Map());
10
10
  };
11
11
  const update = (instance) => {
12
12
  const options = {};
@@ -31,11 +31,10 @@ export function Provider(namespace) {
31
31
  cleanups(this).set(prefix, cleanup);
32
32
  });
33
33
  appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATE, function (states) {
34
- var _a;
35
34
  update(this);
36
35
  if (cleanups(this).size && !states.has(SUB))
37
36
  return;
38
- (_a = cleanups(this).get(`${prefix}:${states.get(SUB)}`)) === null || _a === void 0 ? void 0 : _a();
37
+ cleanups(this).get(`${prefix}:${states.get(SUB)}`)?.();
39
38
  const type = `${prefix}:${this[SUB]}`;
40
39
  const cleanup = () => {
41
40
  off(window, `${type}:presence`, onPresence);
@@ -59,7 +58,7 @@ export function Consumer(namespace) {
59
58
  const [MAIN, SUB] = namespace.split('.');
60
59
  const prefix = `htmlplus:${MAIN}`;
61
60
  const cleanups = (instance) => {
62
- return (instance[symbol] || (instance[symbol] = new Map()));
61
+ return (instance[symbol] ||= new Map());
63
62
  };
64
63
  const update = (instance, state) => {
65
64
  instance[key] = state;
@@ -94,10 +93,9 @@ export function Consumer(namespace) {
94
93
  !connected && setTimeout(() => dispatch(this, `${prefix}:presence`, options));
95
94
  });
96
95
  appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATE, function (states) {
97
- var _a;
98
96
  if (cleanups(this).size && !states.has(SUB))
99
97
  return;
100
- (_a = cleanups(this).get(`${prefix}:${states.get(SUB)}`)) === null || _a === void 0 ? void 0 : _a();
98
+ cleanups(this).get(`${prefix}:${states.get(SUB)}`)?.();
101
99
  const type = `${prefix}:${this[SUB]}`;
102
100
  const cleanup = () => {
103
101
  off(window, `${type}:disconnect`, onDisconnect);
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * The class marked with this decorator is considered a
4
4
  * [Custom Element](https://mdn.io/using-custom-elements),
@@ -17,52 +17,49 @@ export function Element() {
17
17
  };
18
18
  }
19
19
  const proxy = (constructor) => {
20
- var _a;
21
- return _a = class Plus extends HTMLElement {
22
- constructor() {
23
- super();
24
- this.attachShadow({
25
- mode: 'open',
26
- delegatesFocus: constructor['delegatesFocus'],
27
- slotAssignment: constructor['slotAssignment']
28
- });
29
- const instance = (this[CONSTANTS.API_INSTANCE] = new constructor());
30
- instance[CONSTANTS.API_HOST] = () => this;
31
- call(instance, CONSTANTS.LIFECYCLE_CONSTRUCTED);
32
- }
33
- adoptedCallback() {
34
- call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_ADOPTED);
35
- }
36
- attributeChangedCallback(key, prev, next) {
37
- var _a;
38
- // Ensures the integrity of readonly properties to prevent potential errors.
39
- try {
40
- const attribute = (_a = constructor[CONSTANTS.MAPPER]) === null || _a === void 0 ? void 0 : _a[key];
41
- const property = attribute || camelCase(key);
42
- this[property] = next;
43
- }
44
- catch (_b) { }
45
- }
46
- connectedCallback() {
47
- const instance = this[CONSTANTS.API_INSTANCE];
48
- // TODO: experimental for global config
49
- Object.assign(instance, getConfig('element', getTag(instance), 'property'));
50
- instance[CONSTANTS.API_CONNECTED] = true;
51
- const connect = () => {
52
- request(instance, undefined, undefined, () => {
53
- call(instance, CONSTANTS.LIFECYCLE_LOADED);
54
- });
55
- };
56
- const callback = call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
57
- if (!(callback === null || callback === void 0 ? void 0 : callback.then))
58
- return connect();
59
- callback.then(() => connect());
20
+ return class Plus extends HTMLElement {
21
+ static formAssociated = constructor['formAssociated'];
22
+ static observedAttributes = constructor['observedAttributes'];
23
+ constructor() {
24
+ super();
25
+ this.attachShadow({
26
+ mode: 'open',
27
+ delegatesFocus: constructor['delegatesFocus'],
28
+ slotAssignment: constructor['slotAssignment']
29
+ });
30
+ const instance = (this[CONSTANTS.API_INSTANCE] = new constructor());
31
+ instance[CONSTANTS.API_HOST] = () => this;
32
+ call(instance, CONSTANTS.LIFECYCLE_CONSTRUCTED);
33
+ }
34
+ adoptedCallback() {
35
+ call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_ADOPTED);
36
+ }
37
+ attributeChangedCallback(key, prev, next) {
38
+ // Ensures the integrity of readonly properties to prevent potential errors.
39
+ try {
40
+ const attribute = constructor[CONSTANTS.MAPPER]?.[key];
41
+ const property = attribute || camelCase(key);
42
+ this[property] = next;
60
43
  }
61
- disconnectedCallback() {
62
- call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_DISCONNECTED);
63
- }
64
- },
65
- _a.formAssociated = constructor['formAssociated'],
66
- _a.observedAttributes = constructor['observedAttributes'],
67
- _a;
44
+ catch { }
45
+ }
46
+ connectedCallback() {
47
+ const instance = this[CONSTANTS.API_INSTANCE];
48
+ // TODO: experimental for global config
49
+ Object.assign(instance, getConfig('element', getTag(instance), 'property'));
50
+ instance[CONSTANTS.API_CONNECTED] = true;
51
+ const connect = () => {
52
+ request(instance, undefined, undefined, () => {
53
+ call(instance, CONSTANTS.LIFECYCLE_LOADED);
54
+ });
55
+ };
56
+ const callback = call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
57
+ if (!callback?.then)
58
+ return connect();
59
+ callback.then(() => connect());
60
+ }
61
+ disconnectedCallback() {
62
+ call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_DISCONNECTED);
63
+ }
64
+ };
68
65
  };
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * A function type that generates a `CustomEvent`.
4
4
  */
@@ -11,10 +11,9 @@ export function Event(options = {}) {
11
11
  defineProperty(target, key, {
12
12
  get() {
13
13
  return (detail) => {
14
- var _a, _b;
15
14
  const element = host(this);
16
15
  const framework = getFramework(this);
17
- (_a = options.bubbles) !== null && _a !== void 0 ? _a : (options.bubbles = false);
16
+ options.bubbles ??= false;
18
17
  let type = String(key);
19
18
  switch (framework) {
20
19
  // TODO: Experimental
@@ -28,7 +27,7 @@ export function Event(options = {}) {
28
27
  })
29
28
  });
30
29
  }
31
- catch (_c) { }
30
+ catch { }
32
31
  break;
33
32
  case 'qwik':
34
33
  case 'solid':
@@ -43,9 +42,9 @@ export function Event(options = {}) {
43
42
  break;
44
43
  }
45
44
  let event;
46
- event || (event = (_b = getConfig('event', 'resolver')) === null || _b === void 0 ? void 0 : _b({ detail, element, framework, options, type }));
45
+ event ||= getConfig('event', 'resolver')?.({ detail, element, framework, options, type });
47
46
  event && element.dispatchEvent(event);
48
- event || (event = dispatch(this, type, Object.assign(Object.assign({}, options), { detail })));
47
+ event ||= dispatch(this, type, { ...options, detail });
49
48
  return event;
50
49
  };
51
50
  }
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * An object that configures
4
4
  * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
@@ -13,7 +13,7 @@ import { Bind } from './bind.js';
13
13
  export function Listen(type, options) {
14
14
  return function (target, key, descriptor) {
15
15
  const element = (instance) => {
16
- switch (options === null || options === void 0 ? void 0 : options.target) {
16
+ switch (options?.target) {
17
17
  case 'body':
18
18
  return window.document.body;
19
19
  case 'document':
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Provides a way to encapsulate functionality within an element
4
4
  * and invoke it as needed, both internally and externally.
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * The configuration for property decorator.
4
4
  */
@@ -7,19 +7,18 @@ import { appendToMethod, defineProperty, host, request, toProperty, updateAttrib
7
7
  */
8
8
  export function Property(options) {
9
9
  return function (target, key, descriptor) {
10
- var _a, _b, _c;
11
10
  // Creates a unique symbol for the lock flag.
12
11
  const locked = Symbol();
13
12
  // Converts property name to string.
14
13
  const name = String(key);
15
14
  // Calculates attribute.
16
- const attribute = (options === null || options === void 0 ? void 0 : options.attribute) || kebabCase(name);
15
+ const attribute = options?.attribute || kebabCase(name);
17
16
  // Registers an attribute that is intricately linked to the property.
18
- ((_a = target.constructor)['observedAttributes'] || (_a['observedAttributes'] = [])).push(attribute);
17
+ (target.constructor['observedAttributes'] ||= []).push(attribute);
19
18
  // TODO
20
19
  if (attribute) {
21
20
  // TODO
22
- (_b = target.constructor)[_c = CONSTANTS.MAPPER] || (_b[_c] = {});
21
+ target.constructor[CONSTANTS.MAPPER] ||= {};
23
22
  // TODO
24
23
  target.constructor[CONSTANTS.MAPPER][attribute] = name;
25
24
  }
@@ -27,12 +26,12 @@ export function Property(options) {
27
26
  // When the property is a getter function.
28
27
  if (descriptor) {
29
28
  // Checks the reflection.
30
- if (options === null || options === void 0 ? void 0 : options.reflect) {
29
+ if (options?.reflect) {
31
30
  // Stores the original getter function.
32
31
  const getter = descriptor.get;
33
32
  // Defines a new getter function.
34
33
  descriptor.get = function () {
35
- const value = getter === null || getter === void 0 ? void 0 : getter.apply(this);
34
+ const value = getter?.apply(this);
36
35
  this[locked] = true;
37
36
  updateAttribute(this, attribute, value);
38
37
  this[locked] = false;
@@ -62,7 +61,7 @@ export function Property(options) {
62
61
  request(this, name, previous, (skipped) => {
63
62
  if (skipped)
64
63
  return;
65
- if (!(options === null || options === void 0 ? void 0 : options.reflect))
64
+ if (!options?.reflect)
66
65
  return;
67
66
  this[locked] = true;
68
67
  updateAttribute(this, attribute, next);
@@ -85,7 +84,7 @@ export function Property(options) {
85
84
  if (this[locked]) {
86
85
  return;
87
86
  }
88
- this[key] = toProperty(input, options === null || options === void 0 ? void 0 : options.type);
87
+ this[key] = toProperty(input, options?.type);
89
88
  };
90
89
  // TODO: Check the configuration.
91
90
  // Attaches the getter and setter functions to the current property of the host element.
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Applying this decorator to any `class property` will trigger the
4
4
  * element to re-render upon the desired property changes.
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Monitors `@Property` and `@State` to detect changes.
4
4
  * The decorated method will be called after any changes,
@@ -4,7 +4,7 @@ export const appendToMethod = (target, key, handler) => {
4
4
  // Creates new function
5
5
  function next(...parameters) {
6
6
  // Calls the previous
7
- const result = previous === null || previous === void 0 ? void 0 : previous.bind(this)(...parameters);
7
+ const result = previous?.bind(this)(...parameters);
8
8
  // Calls the appended
9
9
  handler.bind(this)(...parameters);
10
10
  // Returns the result
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare const attributes: (target: HTMLElement | HTMLPlusElement, attributes: any[]) => void;
@@ -29,5 +29,5 @@ export const attributes = (target, attributes) => {
29
29
  else
30
30
  updateAttribute(element, key, next[key]);
31
31
  }
32
- element[symbol] = Object.assign({}, next);
32
+ element[symbol] = { ...next };
33
33
  };
@@ -1,4 +1,3 @@
1
1
  export const call = (target, key, ...parameters) => {
2
- var _a;
3
- return (_a = target[key]) === null || _a === void 0 ? void 0 : _a.call(target, ...parameters);
2
+ return target[key]?.call(target, ...parameters);
4
3
  };
@@ -23,6 +23,6 @@ export const getConfig = (...keys) => {
23
23
  export const setConfig = (config, options) => {
24
24
  if (isServer())
25
25
  return;
26
- const previous = (options === null || options === void 0 ? void 0 : options.override) ? {} : window[`$htmlplus$`];
26
+ const previous = options?.override ? {} : window[`$htmlplus$`];
27
27
  window[`$htmlplus$`] = merge({}, DEFAULTS, previous, config);
28
28
  };
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Indicates whether the [Direction](https://mdn.io/css-direction)
4
4
  * of the element is `Right-To-Left` or `Left-To-Right`.
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * TODO
4
4
  */
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare const getFramework: (target: HTMLElement | HTMLPlusElement) => string | undefined;
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare const getStyles: (target: HTMLPlusElement) => string | undefined;
@@ -1,5 +1,4 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  export const getStyles = (target) => {
3
- var _a;
4
- return (_a = target.constructor[CONSTANTS.STATIC_STYLE]) !== null && _a !== void 0 ? _a : target[CONSTANTS.STATIC_STYLE];
3
+ return target.constructor[CONSTANTS.STATIC_STYLE] ?? target[CONSTANTS.STATIC_STYLE];
5
4
  };
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare const getTag: (target: HTMLPlusElement) => string | undefined;
@@ -1,5 +1,4 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  export const getTag = (target) => {
3
- var _a;
4
- return (_a = target.constructor[CONSTANTS.STATIC_TAG]) !== null && _a !== void 0 ? _a : target[CONSTANTS.STATIC_TAG];
3
+ return target.constructor[CONSTANTS.STATIC_TAG] ?? target[CONSTANTS.STATIC_TAG];
5
4
  };
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Indicates the host of the element.
4
4
  */
@@ -6,7 +6,7 @@ export const host = (target) => {
6
6
  try {
7
7
  return target[CONSTANTS.API_HOST]();
8
8
  }
9
- catch (_a) {
9
+ catch {
10
10
  return target;
11
11
  }
12
12
  };
@@ -1,3 +1,3 @@
1
1
  export const isEvent = (input) => {
2
- return !!(input === null || input === void 0 ? void 0 : input.match(/on[A-Z]\w+/g));
2
+ return !!input?.match(/on[A-Z]\w+/g);
3
3
  };
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Indicates whether the direction of the element is `Right-To-Left` or not.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Selects the first element in the shadow dom that matches a specified CSS selector.
4
4
  */
@@ -3,6 +3,5 @@ import { shadowRoot } from './shadowRoot.js';
3
3
  * Selects the first element in the shadow dom that matches a specified CSS selector.
4
4
  */
5
5
  export function query(target, selectors) {
6
- var _a;
7
- return (_a = shadowRoot(target)) === null || _a === void 0 ? void 0 : _a.querySelector(selectors);
6
+ return shadowRoot(target)?.querySelector(selectors);
8
7
  }
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Selects all elements in the shadow dom that match a specified CSS selector.
4
4
  */
@@ -3,6 +3,5 @@ import { shadowRoot } from './shadowRoot.js';
3
3
  * Selects all elements in the shadow dom that match a specified CSS selector.
4
4
  */
5
5
  export function queryAll(target, selectors) {
6
- var _a;
7
- return (_a = shadowRoot(target)) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selectors);
6
+ return shadowRoot(target)?.querySelectorAll(selectors);
8
7
  }
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  /**
3
3
  * Updates the DOM with a scheduled task.
4
4
  * @param target The element instance.
@@ -12,9 +12,8 @@ import { html, render } from './uhtml.js';
12
12
  * @param callback Invoked when the rendering phase is completed.
13
13
  */
14
14
  export const request = (target, name, previous, callback) => {
15
- var _a, _b;
16
15
  // Creates/Gets a stacks.
17
- const stacks = (target[_a = CONSTANTS.API_STACKS] || (target[_a] = new Map()));
16
+ const stacks = (target[CONSTANTS.API_STACKS] ||= new Map());
18
17
  // Creates/Updates a stack.
19
18
  const stack = stacks.get(name) || { callbacks: [], previous };
20
19
  // Adds the callback to the stack, if exists.
@@ -60,7 +59,7 @@ export const request = (target, name, previous, callback) => {
60
59
  target[CONSTANTS.API_RENDER_COMPLETED] = true;
61
60
  };
62
61
  // Creates/Gets a micro task function.
63
- target[_b = CONSTANTS.API_REQUEST] || (target[_b] = task({ handler }));
62
+ target[CONSTANTS.API_REQUEST] ||= task({ handler });
64
63
  // Calls the micro task.
65
64
  call(target, CONSTANTS.API_REQUEST);
66
65
  };
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare const shadowRoot: (target: HTMLElement | HTMLPlusElement) => ShadowRoot | null;
@@ -1,5 +1,4 @@
1
1
  import { host } from './host.js';
2
2
  export const shadowRoot = (target) => {
3
- var _a;
4
- return (_a = host(target)) === null || _a === void 0 ? void 0 : _a.shadowRoot;
3
+ return host(target)?.shadowRoot;
5
4
  };
@@ -1,4 +1,4 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  type Slots = {
3
3
  [key: string]: boolean;
4
4
  };
@@ -3,14 +3,13 @@ import { host } from './host.js';
3
3
  * Returns the slots name.
4
4
  */
5
5
  export const slots = (target) => {
6
- var _a;
7
6
  const element = host(target);
8
7
  const slots = {};
9
8
  const children = Array.from(element.childNodes);
10
9
  for (const child of children) {
11
10
  if (child.nodeName == '#comment')
12
11
  continue;
13
- const name = child['slot'] || (((_a = child.nodeValue) === null || _a === void 0 ? void 0 : _a.trim()) && 'default') || ('slot' in child && 'default');
12
+ const name = child['slot'] || (child.nodeValue?.trim() && 'default') || ('slot' in child && 'default');
14
13
  if (!name)
15
14
  continue;
16
15
  slots[name] = true;
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare function toDecorator(util: Function, ...parameters: any[]): (target: HTMLPlusElement, key: PropertyKey) => void;
@@ -1,3 +1,3 @@
1
1
  export const toEvent = (input) => {
2
- return input === null || input === void 0 ? void 0 : input.slice(2).toLowerCase();
2
+ return input?.slice(2).toLowerCase();
3
3
  };
@@ -35,7 +35,7 @@ export const toProperty = (input, type) => {
35
35
  return value;
36
36
  }
37
37
  }
38
- catch (_a) { }
38
+ catch { }
39
39
  }
40
40
  if (CONSTANTS.TYPE_OBJECT & type || type === Object) {
41
41
  try {
@@ -44,7 +44,7 @@ export const toProperty = (input, type) => {
44
44
  return value;
45
45
  }
46
46
  }
47
- catch (_b) { }
47
+ catch { }
48
48
  }
49
49
  if (CONSTANTS.TYPE_UNDEFINED & type || type === undefined) {
50
50
  if (string === 'undefined') {
@@ -1,2 +1,2 @@
1
- import { HTMLPlusElement } from '../../types';
1
+ import { HTMLPlusElement } from '../../types/index.js';
2
2
  export declare const updateAttribute: (target: HTMLElement | HTMLPlusElement, key: string, value: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "2.9.3",
3
+ "version": "2.9.5",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
@@ -32,31 +32,31 @@
32
32
  },
33
33
  "homepage": "https://github.com/htmlplus/element#readme",
34
34
  "dependencies": {
35
- "@babel/generator": "^7.23.6",
36
- "@babel/parser": "^7.23.9",
37
- "@babel/template": "^7.23.9",
38
- "@babel/traverse": "^7.23.9",
39
- "@babel/types": "^7.23.9",
40
- "@types/node": "^20.11.20",
41
- "change-case": "^5.4.3",
35
+ "@babel/generator": "^7.24.7",
36
+ "@babel/parser": "^7.24.7",
37
+ "@babel/template": "^7.24.7",
38
+ "@babel/traverse": "^7.24.7",
39
+ "@babel/types": "^7.24.7",
40
+ "@types/node": "^20.14.9",
41
+ "change-case": "^5.4.4",
42
42
  "fs-extra": "^11.2.0",
43
- "glob": "^10.3.10",
43
+ "glob": "^10.4.2",
44
44
  "ora": "^8.0.1",
45
45
  "typescript": "^4.9.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@semantic-release/changelog": "^6.0.3",
49
- "@semantic-release/commit-analyzer": "^11.1.0",
49
+ "@semantic-release/commit-analyzer": "^13.0.0",
50
50
  "@semantic-release/git": "^10.0.1",
51
- "@semantic-release/github": "^9.2.6",
52
- "@semantic-release/npm": "^11.0.2",
53
- "@semantic-release/release-notes-generator": "^12.1.0",
51
+ "@semantic-release/github": "^10.0.7",
52
+ "@semantic-release/npm": "^12.0.1",
53
+ "@semantic-release/release-notes-generator": "^14.0.1",
54
54
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
55
- "cpy": "^11.0.0",
56
- "prettier": "^3.2.5",
57
- "rimraf": "^5.0.5",
58
- "semantic-release": "^23.0.2",
59
- "tsx": "^4.7.1",
60
- "vite": "^5.1.4"
55
+ "cpy": "^11.0.1",
56
+ "prettier": "^3.3.2",
57
+ "rimraf": "^5.0.7",
58
+ "semantic-release": "^24.0.0",
59
+ "tsx": "^4.16.2",
60
+ "vite": "^5.3.3"
61
61
  }
62
62
  }
@@ -1,4 +1,4 @@
1
- import { TransformerPlugin, TransformerPluginContext } from '../transformer.types';
1
+ import { TransformerPlugin, TransformerPluginContext } from '../transformer.types.js';
2
2
  export declare const ASSETS_OPTIONS: Partial<AssetsOptions>;
3
3
  export interface AssetsOptions {
4
4
  destination?: (context: TransformerPluginContext) => string;