@htmlplus/element 0.1.9 → 0.2.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.
@@ -1,6 +1,8 @@
1
1
  import { html, render as renderer } from 'uhtml';
2
2
  import * as CONSTANTS from '../../configs/constants.js';
3
- import { call, getStyles, host } from '../utils/index.js';
3
+ import { call } from './call.js';
4
+ import { getStyles } from './get-styles.js';
5
+ import { host } from './host.js';
4
6
  export const render = (target) => {
5
7
  const element = host(target);
6
8
  renderer(element.shadowRoot, () => {
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  export const task = (options) => {
11
2
  let states, isPending, updatePromise;
12
3
  const run = (state) => {
@@ -18,10 +9,10 @@ export const task = (options) => {
18
9
  updatePromise = enqueue();
19
10
  return updatePromise;
20
11
  };
21
- const enqueue = () => __awaiter(void 0, void 0, void 0, function* () {
12
+ const enqueue = async () => {
22
13
  isPending = true;
23
14
  try {
24
- yield updatePromise;
15
+ await updatePromise;
25
16
  }
26
17
  catch (error) {
27
18
  Promise.reject(error);
@@ -41,6 +32,6 @@ export const task = (options) => {
41
32
  isPending = false;
42
33
  throw error;
43
34
  }
44
- });
35
+ };
45
36
  return run;
46
37
  };
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import logUpdate from 'log-update';
11
2
  const log = (namespace, message) => {
12
3
  logUpdate(`${new Date().toLocaleTimeString()} [@htmlplus/element]${namespace ? `[${namespace}]` : ''} ${message}`);
@@ -15,16 +6,16 @@ export default (...plugins) => {
15
6
  let global = {
16
7
  contexts: {}
17
8
  };
18
- const start = () => __awaiter(void 0, void 0, void 0, function* () {
9
+ const start = async () => {
19
10
  log(undefined, 'Starting.');
20
11
  for (const plugin of plugins) {
21
12
  if (!plugin.start)
22
13
  continue;
23
- global = (yield plugin.start(global)) || global;
14
+ global = (await plugin.start(global)) || global;
24
15
  log(plugin.name, 'Started successfully.');
25
16
  }
26
- });
27
- const next = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
17
+ };
18
+ const next = async (filePath) => {
28
19
  const key = filePath.split(/[\/|\\]/g).pop();
29
20
  let context = {
30
21
  filePath
@@ -32,22 +23,22 @@ export default (...plugins) => {
32
23
  for (const plugin of plugins) {
33
24
  if (!plugin.next)
34
25
  continue;
35
- context = (yield plugin.next(context, global)) || context;
26
+ context = (await plugin.next(context, global)) || context;
36
27
  log(`${key}:${plugin.name}`, 'Executed successfully.');
37
28
  }
38
29
  log(key, 'Executed successfully.');
39
30
  global.contexts[filePath] = context;
40
31
  return context;
41
- });
42
- const finish = () => __awaiter(void 0, void 0, void 0, function* () {
32
+ };
33
+ const finish = async () => {
43
34
  for (const plugin of plugins) {
44
35
  if (!plugin.finish)
45
36
  continue;
46
- global = (yield plugin.finish(global)) || global;
37
+ global = (await plugin.finish(global)) || global;
47
38
  log(plugin.name, 'Finished successfully.');
48
39
  }
49
40
  log(undefined, 'Finished.');
50
- });
41
+ };
51
42
  return {
52
43
  start,
53
44
  next,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
6
6
  "description": "Compiler of HTMLPlus",