@htmlplus/element 0.3.3 → 0.4.0

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 (106) hide show
  1. package/client/decorators/attributes.js +3 -3
  2. package/client/decorators/element.js +8 -4
  3. package/client/decorators/event.js +2 -3
  4. package/client/decorators/listen.js +2 -1
  5. package/client/decorators/method.js +4 -5
  6. package/client/decorators/property.d.ts +0 -4
  7. package/client/decorators/property.js +37 -43
  8. package/client/decorators/state.js +17 -26
  9. package/client/decorators/watch.d.ts +7 -1
  10. package/client/decorators/watch.js +26 -9
  11. package/client/helpers/index.d.ts +3 -3
  12. package/client/helpers/index.js +3 -3
  13. package/client/helpers/{is-rtl.d.ts → isRTL.d.ts} +0 -0
  14. package/client/helpers/{is-rtl.js → isRTL.js} +0 -0
  15. package/client/helpers/{query-all.d.ts → queryAll.d.ts} +0 -0
  16. package/client/helpers/{query-all.js → queryAll.js} +0 -0
  17. package/client/helpers/slots.js +1 -1
  18. package/client/helpers/styles.js +2 -1
  19. package/client/helpers/{to-unit.d.ts → toUnit.d.ts} +0 -0
  20. package/client/helpers/{to-unit.js → toUnit.js} +0 -0
  21. package/client/utils/{append-to-method.d.ts → appendToMethod.d.ts} +0 -0
  22. package/client/utils/{append-to-method.js → appendToMethod.js} +0 -0
  23. package/client/utils/{define-property.d.ts → defineProperty.d.ts} +0 -0
  24. package/client/utils/{define-property.js → defineProperty.js} +0 -0
  25. package/client/utils/event.d.ts +5 -2
  26. package/client/utils/event.js +7 -4
  27. package/client/utils/{get-members.d.ts → getMembers.d.ts} +0 -0
  28. package/client/utils/{get-members.js → getMembers.js} +0 -0
  29. package/client/utils/{get-styles.d.ts → getStyles.d.ts} +0 -0
  30. package/client/utils/{get-styles.js → getStyles.js} +0 -0
  31. package/client/utils/index.d.ts +11 -14
  32. package/client/utils/index.js +11 -14
  33. package/client/utils/{is-event.d.ts → isEvent.d.ts} +0 -0
  34. package/client/utils/{is-event.js → isEvent.js} +0 -0
  35. package/client/utils/{is-server.d.ts → isServer.d.ts} +0 -0
  36. package/client/utils/{is-server.js → isServer.js} +0 -0
  37. package/client/utils/{parse-value.d.ts → parseValue.d.ts} +0 -0
  38. package/client/utils/{parse-value.js → parseValue.js} +2 -2
  39. package/client/utils/request.d.ts +3 -1
  40. package/client/utils/request.js +15 -5
  41. package/client/utils/sync.js +3 -3
  42. package/client/utils/{to-boolean.d.ts → toBoolean.d.ts} +0 -0
  43. package/client/utils/{to-boolean.js → toBoolean.js} +0 -0
  44. package/client/utils/{to-event.d.ts → toEvent.d.ts} +0 -0
  45. package/client/utils/{to-event.js → toEvent.js} +0 -0
  46. package/client/utils/{type-of.d.ts → typeOf.d.ts} +0 -0
  47. package/client/utils/{type-of.js → typeOf.js} +0 -0
  48. package/client/utils/{update-attribute.d.ts → updateAttribute.d.ts} +0 -0
  49. package/client/utils/{update-attribute.js → updateAttribute.js} +0 -0
  50. package/client/vendor/uhtml.d.ts +22 -0
  51. package/client/vendor/uhtml.js +700 -0
  52. package/compiler/compiler.js +39 -22
  53. package/compiler/plugins/customElement.d.ts +4 -1
  54. package/compiler/plugins/customElement.js +96 -77
  55. package/compiler/plugins/customElementReact/customElementReact.d.ts +1 -1
  56. package/compiler/plugins/customElementReact/customElementReact.js +12 -8
  57. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +4 -4
  58. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +1 -1
  59. package/compiler/plugins/{docs.d.ts → document.d.ts} +3 -4
  60. package/compiler/plugins/document.js +254 -0
  61. package/compiler/plugins/external.d.ts +9 -0
  62. package/compiler/plugins/external.js +25 -0
  63. package/compiler/plugins/extract.js +3 -11
  64. package/compiler/plugins/index.d.ts +2 -0
  65. package/compiler/plugins/index.js +2 -0
  66. package/compiler/plugins/style.js +1 -1
  67. package/compiler/utils/{get-initializer.d.ts → getInitializer.d.ts} +0 -0
  68. package/compiler/utils/{get-initializer.js → getInitializer.js} +0 -0
  69. package/compiler/utils/{get-type.d.ts → getType.d.ts} +0 -0
  70. package/compiler/utils/{get-type.js → getType.js} +0 -0
  71. package/compiler/utils/getTypeReference.d.ts +2 -0
  72. package/compiler/utils/getTypeReference.js +33 -0
  73. package/compiler/utils/{has-decorator.d.ts → hasDecorator.d.ts} +0 -0
  74. package/compiler/utils/{has-decorator.js → hasDecorator.js} +0 -0
  75. package/compiler/utils/index.d.ts +8 -7
  76. package/compiler/utils/index.js +8 -7
  77. package/compiler/utils/{is-directory-empty.d.ts → isDirectoryEmpty.d.ts} +0 -0
  78. package/compiler/utils/{is-directory-empty.js → isDirectoryEmpty.js} +0 -0
  79. package/compiler/utils/{print-type.d.ts → printType.d.ts} +0 -0
  80. package/compiler/utils/{print-type.js → printType.js} +0 -0
  81. package/compiler/utils/{render-template.d.ts → renderTemplate.d.ts} +0 -0
  82. package/compiler/utils/{render-template.js → renderTemplate.js} +0 -0
  83. package/compiler/utils/tags.d.ts +13 -0
  84. package/compiler/utils/tags.js +53 -0
  85. package/constants/index.d.ts +0 -1
  86. package/constants/index.js +0 -1
  87. package/package.json +14 -17
  88. package/types/context.d.ts +6 -0
  89. package/types/index.d.ts +1 -1
  90. package/types/index.js +1 -1
  91. package/types/plugin.d.ts +4 -3
  92. package/types/{plus-element.d.ts → plusElement.d.ts} +0 -0
  93. package/types/{plus-element.js → plusElement.js} +0 -0
  94. package/client/utils/is-ready.d.ts +0 -2
  95. package/client/utils/is-ready.js +0 -4
  96. package/client/utils/on-ready.d.ts +0 -2
  97. package/client/utils/on-ready.js +0 -6
  98. package/client/utils/render.d.ts +0 -2
  99. package/client/utils/render.js +0 -19
  100. package/compiler/plugins/componentDependencyResolver.d.ts +0 -5
  101. package/compiler/plugins/componentDependencyResolver.js +0 -40
  102. package/compiler/plugins/docs.js +0 -320
  103. package/compiler/utils/get-tags.d.ts +0 -6
  104. package/compiler/utils/get-tags.js +0 -34
  105. package/runtime/index.d.ts +0 -1
  106. package/runtime/index.js +0 -4
@@ -2,12 +2,12 @@ import * as CONSTANTS from '../../constants/index.js';
2
2
  import { appendToMethod, host, sync } from '../utils/index.js';
3
3
  export function Attributes() {
4
4
  return function (target, propertyKey) {
5
- let update;
5
+ const updates = new Map();
6
6
  appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
7
- update = sync(host(this));
7
+ updates.set(this, sync(host(this)));
8
8
  });
9
9
  appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function () {
10
- update(this[propertyKey]);
10
+ updates.get(this)(this[propertyKey]);
11
11
  });
12
12
  };
13
13
  }
@@ -1,6 +1,7 @@
1
1
  import { camelCase, paramCase } from 'change-case';
2
2
  import * as CONSTANTS from '../../constants/index.js';
3
3
  import { call, getMembers, isServer, parseValue, request } from '../utils/index.js';
4
+ import * as uhtml from '../vendor/uhtml.js';
4
5
  export function Element(tag) {
5
6
  return function (constructor) {
6
7
  if (isServer())
@@ -8,12 +9,13 @@ export function Element(tag) {
8
9
  const members = getMembers(constructor);
9
10
  class Plus extends HTMLElement {
10
11
  constructor() {
11
- var _a;
12
12
  super();
13
+ this.attachShadow({ mode: 'open' });
14
+ // TODO
13
15
  this.plus = new constructor();
14
16
  this.plus[CONSTANTS.API_HOST] = () => this;
15
- (_a = this.plus[CONSTANTS.API_SETUP]) === null || _a === void 0 ? void 0 : _a.forEach((setup) => setup.call(this.plus));
16
- this.attachShadow({ mode: 'open' });
17
+ this.plus['uhtml'] = uhtml;
18
+ this.plus[CONSTANTS.API_READY] = true;
17
19
  }
18
20
  static get observedAttributes() {
19
21
  return Object.keys(members)
@@ -23,6 +25,7 @@ export function Element(tag) {
23
25
  adoptedCallback() {
24
26
  call(this.plus, CONSTANTS.LIFECYCLE_ADOPTED);
25
27
  }
28
+ // TODO
26
29
  attributeChangedCallback(name, prev, next) {
27
30
  const key = camelCase(name);
28
31
  const [type] = members[key];
@@ -30,7 +33,6 @@ export function Element(tag) {
30
33
  this.plus[key] = parsed;
31
34
  }
32
35
  connectedCallback() {
33
- this.plus[CONSTANTS.API_READY] = true;
34
36
  call(this.plus, CONSTANTS.LIFECYCLE_CONNECTED);
35
37
  request(this.plus)
36
38
  .then(() => {
@@ -44,6 +46,8 @@ export function Element(tag) {
44
46
  call(this.plus, CONSTANTS.LIFECYCLE_DISCONNECTED);
45
47
  }
46
48
  }
49
+ if (customElements.get(tag))
50
+ return;
47
51
  customElements.define(tag, Plus);
48
52
  };
49
53
  }
@@ -1,5 +1,4 @@
1
- import { defineProperty, host } from '../utils/index.js';
2
- // TODO: add global hook
1
+ import { defineProperty, dispatch, host } from '../utils/index.js';
3
2
  export function Event(options = {}) {
4
3
  return function (target, propertyKey) {
5
4
  defineProperty(target, propertyKey, {
@@ -9,7 +8,7 @@ export function Event(options = {}) {
9
8
  (_a = options.bubbles) !== null && _a !== void 0 ? _a : (options.bubbles = false);
10
9
  const name = options.name || String(propertyKey);
11
10
  const event = new CustomEvent(name, Object.assign(Object.assign({}, options), { detail }));
12
- host(this).dispatchEvent(event);
11
+ dispatch(host(this), event);
13
12
  return event;
14
13
  };
15
14
  }
@@ -6,7 +6,6 @@ const defaults = {
6
6
  };
7
7
  export function Listen(name, options = defaults) {
8
8
  return function (target, propertyKey, descriptor) {
9
- // TODO: types
10
9
  const element = (instance) => {
11
10
  switch (options.target) {
12
11
  case 'body':
@@ -17,6 +16,8 @@ export function Listen(name, options = defaults) {
17
16
  return window;
18
17
  case 'host':
19
18
  return host(instance);
19
+ default:
20
+ return host(instance);
20
21
  }
21
22
  };
22
23
  appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
@@ -1,11 +1,10 @@
1
- import { defineProperty, host, onReady } from '../utils/index.js';
1
+ import * as CONSTANTS from '../../constants/index.js';
2
+ import { appendToMethod, defineProperty, host } from '../utils/index.js';
2
3
  export function Method() {
3
4
  return function (target, propertyKey) {
4
- onReady(target, function () {
5
+ appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
5
6
  defineProperty(host(this), propertyKey, {
6
- get: () => {
7
- return this[propertyKey].bind(this);
8
- }
7
+ get: () => this[propertyKey].bind(this)
9
8
  });
10
9
  });
11
10
  };
@@ -1,9 +1,5 @@
1
1
  import { PlusElement } from '../../types/index.js';
2
2
  export interface PropertyOptions {
3
- /**
4
- * TODO
5
- */
6
- attribute?: boolean | string;
7
3
  /**
8
4
  * Whether property value is reflected back to the associated attribute. default is `false`.
9
5
  */
@@ -1,51 +1,45 @@
1
- import { defineProperty, getMembers, host, isReady, parseValue, request, updateAttribute, onReady } from '../utils/index.js';
1
+ import { paramCase } from 'change-case';
2
+ import * as CONSTANTS from '../../constants/index.js';
3
+ import { defineProperty, getMembers, host, parseValue, request, updateAttribute, appendToMethod } from '../utils/index.js';
2
4
  export function Property(options) {
3
5
  return function (target, propertyKey) {
6
+ const name = String(propertyKey);
7
+ const attribute = paramCase(name);
8
+ const type = getMembers(target)[name].at(0);
4
9
  const values = new Map();
5
- defineProperty(target, propertyKey, {
6
- get() {
7
- return values.get(this);
8
- },
9
- set(input) {
10
- const value = values.get(this);
11
- if (value === input)
10
+ function get() {
11
+ return values.get(this);
12
+ }
13
+ function set(input) {
14
+ const value = values.get(this);
15
+ if (input === value)
16
+ return;
17
+ values.set(this, input);
18
+ const isReady = !!this[CONSTANTS.API_READY];
19
+ request(this, { [name]: [input, value, !this[CONSTANTS.API_READY]] }).then(() => {
20
+ const element = host(this);
21
+ const has = element.hasAttribute(attribute);
22
+ if (!isReady && has)
12
23
  return;
13
- values.set(this, input);
14
- // TODO
15
- const ready = isReady(this);
16
- request(this, { [propertyKey]: [input, value] })
17
- .then((renderd) => {
18
- const name = String(propertyKey);
19
- const element = host(this);
20
- const hasAttribute = element.hasAttribute(name);
21
- // TODO
22
- if ((options === null || options === void 0 ? void 0 : options.reflect) && !hasAttribute && !renderd && !ready)
23
- updateAttribute(element, name, input);
24
- if (!renderd)
25
- return;
26
- if (!(options === null || options === void 0 ? void 0 : options.reflect))
27
- return;
28
- const raw = element.getAttribute(name);
29
- const [type] = getMembers(target)[propertyKey];
30
- const parsed = parseValue(raw, type);
31
- if (parsed === input)
32
- return;
33
- updateAttribute(element, name, input);
34
- })
35
- .catch((error) => {
36
- throw error;
37
- });
38
- }
39
- });
40
- onReady(target, function () {
41
- defineProperty(host(this), propertyKey, {
42
- get: () => {
43
- return this[propertyKey];
44
- },
45
- set: (value) => {
46
- this[propertyKey] = value;
47
- }
24
+ if (!(options === null || options === void 0 ? void 0 : options.reflect))
25
+ return;
26
+ const raw = element.getAttribute(attribute);
27
+ const parsed = parseValue(raw, type);
28
+ if (input === parsed)
29
+ return;
30
+ updateAttribute(element, attribute, input);
48
31
  });
32
+ }
33
+ defineProperty(target, propertyKey, { get, set });
34
+ appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
35
+ const element = host(this);
36
+ const get = () => {
37
+ return this[propertyKey];
38
+ };
39
+ const set = (input) => {
40
+ this[propertyKey] = input;
41
+ };
42
+ defineProperty(element, propertyKey, { get, set });
49
43
  });
50
44
  };
51
45
  }
@@ -1,32 +1,23 @@
1
- import { defineProperty, host, onReady, request } from '../utils/index.js';
1
+ import * as CONSTANTS from '../../constants/index.js';
2
+ import { defineProperty, request } from '../utils/index.js';
2
3
  export function State() {
3
4
  return function (target, propertyKey) {
5
+ const name = String(propertyKey);
4
6
  const values = new Map();
5
- defineProperty(target, propertyKey, {
6
- get() {
7
- return values.get(this);
8
- },
9
- set(input) {
10
- const value = values.get(this);
11
- if (value === input)
12
- return;
13
- values.set(this, input);
14
- request(this, { [propertyKey]: [input, value] })
15
- .then(() => { })
16
- .catch((error) => {
17
- throw error;
18
- });
19
- }
20
- });
21
- onReady(target, function () {
22
- defineProperty(host(this), propertyKey, {
23
- get: () => {
24
- return this[propertyKey];
25
- },
26
- set: (value) => {
27
- this[propertyKey] = value;
28
- }
7
+ function get() {
8
+ return values.get(this);
9
+ }
10
+ function set(input) {
11
+ const value = values.get(this);
12
+ if (input === value)
13
+ return;
14
+ values.set(this, input);
15
+ request(this, { [name]: [input, value, !this[CONSTANTS.API_READY]] })
16
+ .then(() => undefined)
17
+ .catch((error) => {
18
+ throw error;
29
19
  });
30
- });
20
+ }
21
+ defineProperty(target, propertyKey, { get, set });
31
22
  };
32
23
  }
@@ -1,2 +1,8 @@
1
1
  import { PlusElement } from '../../types/index.js';
2
- export declare function Watch(...keys: Array<string>): (target: PlusElement, propertyKey: PropertyKey) => void;
2
+ /**
3
+ * Monitors properties and states to catch changes.
4
+ * The decorated method will be invoked after any
5
+ * changes with the key, newValue, and oldValue as parameters.
6
+ * If the arguments aren't defined, all of the properties and states are considered.
7
+ */
8
+ export declare function Watch(keys?: Array<string>, immediate?: boolean): (target: PlusElement, propertyKey: PropertyKey) => void;
@@ -1,16 +1,33 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  import { appendToMethod } from '../utils/index.js';
3
- // TODO: support * key
4
- export function Watch(...keys) {
3
+ /**
4
+ * Monitors properties and states to catch changes.
5
+ * The decorated method will be invoked after any
6
+ * changes with the key, newValue, and oldValue as parameters.
7
+ * If the arguments aren't defined, all of the properties and states are considered.
8
+ */
9
+ export function Watch(keys, immediate) {
5
10
  return function (target, propertyKey) {
6
- if (!keys.length)
7
- return;
8
- appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function (args) {
9
- const [states] = args;
11
+ // Registers a lifecycle to detect changes.
12
+ appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function ([states]) {
13
+ // Gets all keys
14
+ const keys = Object.keys(states);
15
+ // Loops the keys
10
16
  for (const key of keys) {
11
- if (states === null || states === void 0 ? void 0 : states[key]) {
12
- this[propertyKey](...states[key], key);
13
- }
17
+ // Finds current key in keys
18
+ const has = keys === null || keys === void 0 ? void 0 : keys.some((x) => x == key);
19
+ // Checks the existence of key
20
+ if (!has && !!(keys === null || keys === void 0 ? void 0 : keys.length))
21
+ continue;
22
+ // Gets the current state
23
+ const state = states === null || states === void 0 ? void 0 : states[key];
24
+ // Destructs the state
25
+ const [next, prev, isInitial] = state;
26
+ // TODO
27
+ if (!immediate && isInitial)
28
+ continue;
29
+ // Invokes the method with parameters.
30
+ this[propertyKey](next, prev, key);
14
31
  }
15
32
  });
16
33
  };
@@ -1,9 +1,9 @@
1
1
  export * from './classes.js';
2
2
  export * from './direction.js';
3
- export * from './is-rtl.js';
3
+ export * from './isRTL.js';
4
4
  export * from './query.js';
5
- export * from './query-all.js';
5
+ export * from './queryAll.js';
6
6
  export * from './slots.js';
7
7
  export * from './styles.js';
8
- export * from './to-unit.js';
8
+ export * from './toUnit.js';
9
9
  export { host, isServer, on, off } from '../utils/index.js';
@@ -1,9 +1,9 @@
1
1
  export * from './classes.js';
2
2
  export * from './direction.js';
3
- export * from './is-rtl.js';
3
+ export * from './isRTL.js';
4
4
  export * from './query.js';
5
- export * from './query-all.js';
5
+ export * from './queryAll.js';
6
6
  export * from './slots.js';
7
7
  export * from './styles.js';
8
- export * from './to-unit.js';
8
+ export * from './toUnit.js';
9
9
  export { host, isServer, on, off } from '../utils/index.js';
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import { defineProperty } from '../utils/index.js';
2
- import { queryAll } from './query-all.js';
2
+ import { queryAll } from './queryAll.js';
3
3
  export const slots = (target) => {
4
4
  var _a;
5
5
  const result = {};
@@ -6,7 +6,8 @@ export const styles = (input) => {
6
6
  return input.join('; ');
7
7
  case 'object':
8
8
  return Object.keys(input)
9
- .map((key) => `${paramCase(key)}: ${input[key]}`)
9
+ .filter((key) => input[key] !== undefined && input[key] !== null)
10
+ .map((key) => `${key.startsWith('--') ? '--' : ''}${paramCase(key)}: ${input[key]}`)
10
11
  .join('; ');
11
12
  case 'string':
12
13
  return input;
File without changes
File without changes
@@ -1,2 +1,5 @@
1
- export declare const on: (target: Window | Document | Element, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined) => void;
2
- export declare const off: (target: Window | Document | Element, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined) => void;
1
+ declare type Target = Window | Document | Element;
2
+ export declare const dispatch: (target: Target, event: Event) => boolean;
3
+ export declare const on: (target: Target, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined) => void;
4
+ export declare const off: (target: Target, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined) => void;
5
+ export {};
@@ -1,6 +1,9 @@
1
- export const on = (target, event, handler, options) => {
2
- target.addEventListener(event, handler, options);
1
+ export const dispatch = (target, event) => {
2
+ return target.dispatchEvent(event);
3
3
  };
4
- export const off = (target, event, handler, options) => {
5
- target.removeEventListener(event, handler, options);
4
+ export const on = (target, type, handler, options) => {
5
+ target.addEventListener(type, handler, options);
6
+ };
7
+ export const off = (target, type, handler, options) => {
8
+ target.removeEventListener(type, handler, options);
6
9
  };
File without changes
File without changes
File without changes
@@ -1,20 +1,17 @@
1
- export * from './append-to-method.js';
1
+ export * from './appendToMethod.js';
2
2
  export * from './call.js';
3
- export * from './define-property.js';
3
+ export * from './defineProperty.js';
4
4
  export * from './event.js';
5
- export * from './get-members.js';
6
- export * from './get-styles.js';
5
+ export * from './getMembers.js';
6
+ export * from './getStyles.js';
7
7
  export * from './host.js';
8
- export * from './is-event.js';
9
- export * from './is-ready.js';
10
- export * from './is-server.js';
11
- export * from './on-ready.js';
12
- export * from './parse-value.js';
13
- export * from './render.js';
8
+ export * from './isEvent.js';
9
+ export * from './isServer.js';
10
+ export * from './parseValue.js';
14
11
  export * from './request.js';
15
12
  export * from './sync.js';
16
13
  export * from './task.js';
17
- export * from './to-boolean.js';
18
- export * from './to-event.js';
19
- export * from './type-of.js';
20
- export * from './update-attribute.js';
14
+ export * from './toBoolean.js';
15
+ export * from './toEvent.js';
16
+ export * from './typeOf.js';
17
+ export * from './updateAttribute.js';
@@ -1,20 +1,17 @@
1
- export * from './append-to-method.js';
1
+ export * from './appendToMethod.js';
2
2
  export * from './call.js';
3
- export * from './define-property.js';
3
+ export * from './defineProperty.js';
4
4
  export * from './event.js';
5
- export * from './get-members.js';
6
- export * from './get-styles.js';
5
+ export * from './getMembers.js';
6
+ export * from './getStyles.js';
7
7
  export * from './host.js';
8
- export * from './is-event.js';
9
- export * from './is-ready.js';
10
- export * from './is-server.js';
11
- export * from './on-ready.js';
12
- export * from './parse-value.js';
13
- export * from './render.js';
8
+ export * from './isEvent.js';
9
+ export * from './isServer.js';
10
+ export * from './parseValue.js';
14
11
  export * from './request.js';
15
12
  export * from './sync.js';
16
13
  export * from './task.js';
17
- export * from './to-boolean.js';
18
- export * from './to-event.js';
19
- export * from './type-of.js';
20
- export * from './update-attribute.js';
14
+ export * from './toBoolean.js';
15
+ export * from './toEvent.js';
16
+ export * from './typeOf.js';
17
+ export * from './updateAttribute.js';
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
- import { toBoolean } from './to-boolean.js';
2
+ import { toBoolean } from './toBoolean.js';
3
3
  // TODO: input type & validate date
4
4
  export const parseValue = (value, type) => {
5
5
  switch (type) {
@@ -8,7 +8,7 @@ export const parseValue = (value, type) => {
8
8
  case CONSTANTS.TYPE_DATE:
9
9
  return new Date(value);
10
10
  case CONSTANTS.TYPE_NUMBER:
11
- return parseFloat(value);
11
+ return isNaN(value) ? value : parseFloat(value);
12
12
  default:
13
13
  return value;
14
14
  }
@@ -1,2 +1,4 @@
1
1
  import { PlusElement } from '../../types/index.js';
2
- export declare const request: (target: PlusElement, state?: any) => Promise<boolean>;
2
+ export declare const request: (target: PlusElement, state?: {
3
+ [key: string]: [any, any, (boolean | undefined)?];
4
+ } | undefined) => Promise<boolean>;
@@ -1,12 +1,11 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  import { call } from '../utils/call';
3
- import { isReady } from '../utils/is-ready';
4
- import { render } from '../utils/render';
5
3
  import { task } from '../utils/task';
4
+ import { html, render } from '../vendor/uhtml.js';
5
+ import { getStyles } from './getStyles.js';
6
+ import { host } from './host.js';
6
7
  const targets = new Map();
7
8
  export const request = (target, state) => {
8
- if (!isReady(target))
9
- return Promise.resolve(false);
10
9
  let run = targets.get(target);
11
10
  if (run)
12
11
  return run(state);
@@ -19,7 +18,18 @@ export const request = (target, state) => {
19
18
  },
20
19
  run: (states) => {
21
20
  call(target, CONSTANTS.LIFECYCLE_UPDATE, states);
22
- render(target);
21
+ const element = host(target);
22
+ render(element.shadowRoot, () => {
23
+ const markup = call(target, CONSTANTS.METHOD_RENDER);
24
+ const styles = getStyles(target);
25
+ if (!styles && !markup)
26
+ return html ``;
27
+ if (!styles)
28
+ return markup;
29
+ if (!markup)
30
+ return html `<style>${styles}</style>`;
31
+ return html `<style>${styles}</style>${markup}`;
32
+ });
23
33
  call(target, CONSTANTS.LIFECYCLE_UPDATED, states);
24
34
  }
25
35
  });
@@ -1,7 +1,7 @@
1
1
  import { on, off } from './event.js';
2
- import { isEvent } from './is-event.js';
3
- import { toEvent } from './to-event.js';
4
- import { updateAttribute } from './update-attribute.js';
2
+ import { isEvent } from './isEvent.js';
3
+ import { toEvent } from './toEvent.js';
4
+ import { updateAttribute } from './updateAttribute.js';
5
5
  export const sync = (node) => {
6
6
  let prev = {};
7
7
  return (next = {}) => {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Holds all details wrappers needed to render the content further on.
3
+ * @constructor
4
+ * @param {string} type The hole type, either `html` or `svg`.
5
+ * @param {string[]} template The template literals used to the define the content.
6
+ * @param {Array} values Zero, one, or more interpolated values to render.
7
+ */
8
+ export class Hole {
9
+ constructor(type: any, template: any, values: any);
10
+ type: any;
11
+ template: any;
12
+ values: any;
13
+ }
14
+ export const html: ((template: any, ...values: any[]) => Hole) & {
15
+ for(ref: any, id: any): any;
16
+ node: (template: any, ...values: any[]) => any;
17
+ };
18
+ export function render(where: any, what: any): any;
19
+ export const svg: ((template: any, ...values: any[]) => Hole) & {
20
+ for(ref: any, id: any): any;
21
+ node: (template: any, ...values: any[]) => any;
22
+ };