@htmlplus/element 0.3.2 → 0.4.1

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 (110) hide show
  1. package/README.md +2 -2
  2. package/client/decorators/attributes.js +3 -3
  3. package/client/decorators/element.js +11 -4
  4. package/client/decorators/event.js +2 -3
  5. package/client/decorators/listen.js +2 -1
  6. package/client/decorators/method.js +4 -5
  7. package/client/decorators/property.d.ts +0 -4
  8. package/client/decorators/property.js +38 -43
  9. package/client/decorators/state.js +17 -26
  10. package/client/decorators/watch.d.ts +7 -1
  11. package/client/decorators/watch.js +24 -10
  12. package/client/helpers/classes.d.ts +1 -1
  13. package/client/helpers/index.d.ts +3 -3
  14. package/client/helpers/index.js +3 -3
  15. package/client/helpers/{is-rtl.d.ts → isRTL.d.ts} +0 -0
  16. package/client/helpers/{is-rtl.js → isRTL.js} +0 -0
  17. package/client/helpers/{query-all.d.ts → queryAll.d.ts} +0 -0
  18. package/client/helpers/{query-all.js → queryAll.js} +0 -0
  19. package/client/helpers/slots.js +1 -1
  20. package/client/helpers/styles.js +2 -1
  21. package/client/helpers/{to-unit.d.ts → toUnit.d.ts} +0 -0
  22. package/client/helpers/{to-unit.js → toUnit.js} +0 -0
  23. package/client/utils/{append-to-method.d.ts → appendToMethod.d.ts} +0 -0
  24. package/client/utils/{append-to-method.js → appendToMethod.js} +0 -0
  25. package/client/utils/{define-property.d.ts → defineProperty.d.ts} +0 -0
  26. package/client/utils/{define-property.js → defineProperty.js} +0 -0
  27. package/client/utils/event.d.ts +5 -2
  28. package/client/utils/event.js +7 -4
  29. package/client/utils/{get-members.d.ts → getMembers.d.ts} +0 -0
  30. package/client/utils/{get-members.js → getMembers.js} +0 -0
  31. package/client/utils/{get-styles.d.ts → getStyles.d.ts} +0 -0
  32. package/client/utils/{get-styles.js → getStyles.js} +0 -0
  33. package/client/utils/index.d.ts +11 -14
  34. package/client/utils/index.js +11 -14
  35. package/client/utils/{is-event.d.ts → isEvent.d.ts} +0 -0
  36. package/client/utils/{is-event.js → isEvent.js} +0 -0
  37. package/client/utils/{is-server.d.ts → isServer.d.ts} +0 -0
  38. package/client/utils/{is-server.js → isServer.js} +0 -0
  39. package/client/utils/{parse-value.d.ts → parseValue.d.ts} +0 -0
  40. package/client/utils/{parse-value.js → parseValue.js} +2 -2
  41. package/client/utils/request.d.ts +3 -1
  42. package/client/utils/request.js +15 -5
  43. package/client/utils/sync.js +3 -3
  44. package/client/utils/{to-boolean.d.ts → toBoolean.d.ts} +0 -0
  45. package/client/utils/{to-boolean.js → toBoolean.js} +0 -0
  46. package/client/utils/{to-event.d.ts → toEvent.d.ts} +0 -0
  47. package/client/utils/{to-event.js → toEvent.js} +0 -0
  48. package/client/utils/{type-of.d.ts → typeOf.d.ts} +0 -0
  49. package/client/utils/{type-of.js → typeOf.js} +0 -0
  50. package/client/utils/{update-attribute.d.ts → updateAttribute.d.ts} +0 -0
  51. package/client/utils/{update-attribute.js → updateAttribute.js} +0 -0
  52. package/client/vendor/uhtml.d.ts +22 -0
  53. package/client/vendor/uhtml.js +700 -0
  54. package/compiler/compiler.js +42 -22
  55. package/compiler/plugins/customElement.d.ts +4 -1
  56. package/compiler/plugins/customElement.js +96 -77
  57. package/compiler/plugins/customElementReact/customElementReact.d.ts +1 -1
  58. package/compiler/plugins/customElementReact/customElementReact.js +12 -8
  59. package/compiler/plugins/customElementReact/templates/package.json.hbs +2 -2
  60. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +4 -4
  61. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +1 -1
  62. package/compiler/plugins/{docs.d.ts → document.d.ts} +3 -4
  63. package/compiler/plugins/document.js +254 -0
  64. package/compiler/plugins/external.d.ts +9 -0
  65. package/compiler/plugins/external.js +25 -0
  66. package/compiler/plugins/extract.d.ts +1 -1
  67. package/compiler/plugins/extract.js +3 -11
  68. package/compiler/plugins/index.d.ts +2 -0
  69. package/compiler/plugins/index.js +2 -0
  70. package/compiler/plugins/style.js +1 -1
  71. package/compiler/utils/{get-initializer.d.ts → getInitializer.d.ts} +0 -0
  72. package/compiler/utils/{get-initializer.js → getInitializer.js} +0 -0
  73. package/compiler/utils/{get-type.d.ts → getType.d.ts} +0 -0
  74. package/compiler/utils/{get-type.js → getType.js} +0 -0
  75. package/compiler/utils/getTypeReference.d.ts +2 -0
  76. package/compiler/utils/getTypeReference.js +33 -0
  77. package/compiler/utils/{has-decorator.d.ts → hasDecorator.d.ts} +0 -0
  78. package/compiler/utils/{has-decorator.js → hasDecorator.js} +0 -0
  79. package/compiler/utils/index.d.ts +8 -7
  80. package/compiler/utils/index.js +8 -7
  81. package/compiler/utils/{is-directory-empty.d.ts → isDirectoryEmpty.d.ts} +0 -0
  82. package/compiler/utils/{is-directory-empty.js → isDirectoryEmpty.js} +0 -0
  83. package/compiler/utils/{print-type.d.ts → printType.d.ts} +0 -0
  84. package/compiler/utils/{print-type.js → printType.js} +0 -0
  85. package/compiler/utils/{render-template.d.ts → renderTemplate.d.ts} +0 -0
  86. package/compiler/utils/{render-template.js → renderTemplate.js} +0 -0
  87. package/compiler/utils/tags.d.ts +13 -0
  88. package/compiler/utils/tags.js +53 -0
  89. package/constants/index.d.ts +1 -2
  90. package/constants/index.js +2 -2
  91. package/package.json +22 -27
  92. package/types/context.d.ts +6 -0
  93. package/types/index.d.ts +1 -1
  94. package/types/index.js +1 -1
  95. package/types/plugin.d.ts +4 -3
  96. package/types/{plus-element.d.ts → plusElement.d.ts} +0 -0
  97. package/types/{plus-element.js → plusElement.js} +0 -0
  98. package/client/utils/is-ready.d.ts +0 -2
  99. package/client/utils/is-ready.js +0 -4
  100. package/client/utils/on-ready.d.ts +0 -2
  101. package/client/utils/on-ready.js +0 -6
  102. package/client/utils/render.d.ts +0 -2
  103. package/client/utils/render.js +0 -19
  104. package/compiler/plugins/componentDependencyResolver.d.ts +0 -5
  105. package/compiler/plugins/componentDependencyResolver.js +0 -40
  106. package/compiler/plugins/docs.js +0 -320
  107. package/compiler/utils/get-tags.d.ts +0 -6
  108. package/compiler/utils/get-tags.js +0 -34
  109. package/runtime/index.d.ts +0 -1
  110. package/runtime/index.js +0 -4
package/README.md CHANGED
@@ -941,8 +941,8 @@ const { start, next, finish } = compiler(...plugins);
941
941
  TODO
942
942
 
943
943
  ```js
944
- import compiler from '@htmlplus/element/compiler';
945
- import { customElement, extract, parse, read, style, validate } from '@htmlplus/element/compiler';
944
+ import compiler from '@htmlplus/element/compiler/index.js';
945
+ import { customElement, extract, parse, read, style, validate } from '@htmlplus/element/compiler/index.js';
946
946
 
947
947
  const { start, next, finish } = compiler(
948
948
  read(),
@@ -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_STATUS] = 'initialize';
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,10 +33,11 @@ export function Element(tag) {
30
33
  this.plus[key] = parsed;
31
34
  }
32
35
  connectedCallback() {
33
- this.plus[CONSTANTS.API_READY] = true;
36
+ this.plus[CONSTANTS.API_STATUS] = 'connected';
34
37
  call(this.plus, CONSTANTS.LIFECYCLE_CONNECTED);
35
38
  request(this.plus)
36
39
  .then(() => {
40
+ this.plus[CONSTANTS.API_STATUS] = 'loaded';
37
41
  call(this.plus, CONSTANTS.LIFECYCLE_LOADED);
38
42
  })
39
43
  .catch((error) => {
@@ -41,9 +45,12 @@ export function Element(tag) {
41
45
  });
42
46
  }
43
47
  disconnectedCallback() {
48
+ this.plus[CONSTANTS.API_STATUS] = 'disconnected';
44
49
  call(this.plus, CONSTANTS.LIFECYCLE_DISCONNECTED);
45
50
  }
46
51
  }
52
+ if (customElements.get(tag))
53
+ return;
47
54
  customElements.define(tag, Plus);
48
55
  };
49
56
  }
@@ -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,46 @@
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_STATUS] == 'initialize';
19
+ request(this, { [name]: [input, value] }).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
+ // TODO: configurable
43
+ defineProperty(element, propertyKey, { get, set, configurable: true });
49
44
  });
50
45
  };
51
46
  }
@@ -1,32 +1,23 @@
1
- import { defineProperty, host, onReady, request } from '../utils/index.js';
1
+ import { defineProperty, request } from '../utils/index.js';
2
2
  export function State() {
3
3
  return function (target, propertyKey) {
4
+ const name = String(propertyKey);
4
5
  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
- }
6
+ function get() {
7
+ return values.get(this);
8
+ }
9
+ function set(input) {
10
+ const value = values.get(this);
11
+ if (input === value)
12
+ return;
13
+ values.set(this, input);
14
+ request(this, { [name]: [input, value] })
15
+ .then(() => undefined)
16
+ .catch((error) => {
17
+ throw error;
29
18
  });
30
- });
19
+ }
20
+ // TODO: configurable
21
+ defineProperty(target, propertyKey, { get, set, configurable: true });
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,30 @@
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;
10
- for (const key of keys) {
11
- if (states === null || states === void 0 ? void 0 : states[key]) {
12
- this[propertyKey](...states[key], key);
13
- }
11
+ // Registers a lifecycle to detect changes.
12
+ appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function ([states]) {
13
+ // Loops the keys
14
+ for (const key of Object.keys(states)) {
15
+ // TODO
16
+ if ((keys === null || keys === void 0 ? void 0 : keys.length) && !keys.includes(key))
17
+ continue;
18
+ // Checks the existence of key
19
+ if ((keys === null || keys === void 0 ? void 0 : keys.length) && !(key in states))
20
+ continue;
21
+ // Gets the current state
22
+ const [next, prev] = states[key];
23
+ // TODO
24
+ if (!immediate && this[CONSTANTS.API_STATUS] != 'loaded')
25
+ continue;
26
+ // Invokes the method with parameters.
27
+ this[propertyKey](next, prev, key);
14
28
  }
15
29
  });
16
30
  };
@@ -1 +1 @@
1
- export declare const classes: (input: any, smart?: boolean | undefined) => string;
1
+ export declare const classes: (input: any, smart?: boolean) => string;
@@ -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) => void;
4
+ export declare const off: (target: Target, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => 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];
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