lithent 1.8.0 → 1.9.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ➿ lithent
2
2
 
3
- > An extensible virtual DOM library for lightweight use in a variety of environments.
3
+ > An extensible JSX-based virtual DOM library for lightweight use in a variety of environments.
4
4
 
5
5
  - [Korean Guide Document](https://medium.com/@superlucky84/lithent-전체-기능-설명서-3cfab04c0722)
6
6
  - [Home Page](https://superlucky84.github.io/lithent) - (This page is written in lithent.)
@@ -18,9 +18,9 @@ used lightly in a variety of situations.
18
18
  - [How To Install](#how-to-install)
19
19
  - [Use NPM](#use-npm)
20
20
  - [Use CDN](#or-use-cdn)
21
- - [With HTM](#with-htm)
22
21
  - [With JSX](#with-jsx)
23
22
  - [With FTAGS](#with-ftags)
23
+ - [With HTM](#with-htm)
24
24
  - [Examples](#examples)
25
25
  - [With ESM](#with-esm)
26
26
  - [With UMD](#with-umd)
@@ -66,57 +66,50 @@ pnpm add lithent
66
66
 
67
67
  #### Or Use CDN
68
68
 
69
- * UMD : https://cdn.jsdelivr.net/npm/lithent@1.8.0/dist/lithent.umd.js
70
- * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.8.0/helper/dist/lithentHelper.umd.js
71
- * UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.8.0/tag/dist/lithentTag.umd.js
72
- * ESM : https://cdn.jsdelivr.net/npm/lithent@1.8.0/dist/lithent.mjs
73
- * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.8.0/helper/dist/lithentHelper.mjs
74
- * ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.8.0/tag/dist/lithentTag.mjs
69
+ * UMD : https://cdn.jsdelivr.net/npm/lithent@1.9.1/dist/lithent.umd.js
70
+ * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.9.1/helper/dist/lithentHelper.umd.js
71
+ * UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.9.1/ftags/dist/lithentFTags.umd.js
72
+ * UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.9.1/tag/dist/lithentTag.umd.js
73
+ * ESM : https://cdn.jsdelivr.net/npm/lithent@1.9.1/dist/lithent.mjs
74
+ * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.9.1/helper/dist/lithentHelper.mjs
75
+ * ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.9.1/ftags/dist/lithentFTag.mjs
76
+ * ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.9.1/tag/dist/lithentTag.mjs
75
77
 
76
78
 
77
79
  It's easier to use lithent with JSX or HTM.
78
80
 
79
- #### With HTM
80
-
81
- - [Htm Github](https://github.com/developit/htm)
82
-
83
- ```js
84
- import { lTag } from 'lithent/tag';
85
- const destroy = render(lTag`<${Component} />`, document.getElementById('root'), document.getElementById('#insert-before-this-element'));
86
- ```
87
-
88
81
  #### With JSX
89
82
 
90
- - [Setting Guide](https://superlucky84.github.io/lithent/#install)
83
+ * Lithent is built on top of JSX.
84
+ * [Setting Guide](https://superlucky84.github.io/lithent/#install)
91
85
 
92
86
 
93
87
  #### With FTAGS
94
88
 
95
- You can markup by calling a function.
96
- When creating components, use `fMount` instead of `mount`.
97
- When creating fragment, use `FFragment` instead of `Fragment`.
89
+ You don't need to use h functions or JSX, you can call functions to mark them up.
90
+ When creating a component, use `fMount` instead of `mount`.
91
+ When creating a fragment, use `fFragment` instead of `Fragment`.
98
92
 
99
93
  ```ts
100
94
  import { render, h } from 'lithent';
101
- import { fTags, FFragment, fMount } from 'lithent/ftags';
95
+ import { fTags, fFragment, fMount } from 'lithent/ftags';
102
96
 
103
97
  const { section, div, p, br, strong } = fTags;
104
98
 
105
- const FTagComponent = fMount<{ firstProp: number }>((_r, props, children) => {
99
+ const fTagComponent = fMount<{ firstProp: number }>((_r, props, children) => {
106
100
  return () =>
107
- FFragment(
108
- {},
101
+ fFragment(
109
102
  'first inner',
110
- div({ style: 'border: 1px solid red' }, 'second inner'),
103
+ div({ style: { border: '1px solid red' } }, 'second inner'),
111
104
  props.firstProp,
112
105
  ...children
113
106
  );
114
107
  });
115
108
 
116
109
  render(
117
- FTagComponent(
110
+ fTagComponent(
118
111
  { firstProp: 3 },
119
- div({ style: 'border: 1px solid green' }, `Fchildren1`),
112
+ div({ style: { border: '1px solid green' } }, `Fchildren1`),
120
113
  'Fchildren2',
121
114
  br()
122
115
  ),
@@ -124,6 +117,16 @@ render(
124
117
  );
125
118
  ```
126
119
 
120
+ #### With HTM
121
+
122
+ - [Htm Github](https://github.com/developit/htm)
123
+
124
+ ```js
125
+ import { lTag } from 'lithent/tag';
126
+ const destroy = render(lTag`<${Component} />`, document.getElementById('root'), document.getElementById('#insert-before-this-element'));
127
+ ```
128
+
129
+
127
130
  ## Examples
128
131
 
129
132
  - [More Examples](https://superlucky84.github.io/lithent/#examples)
@@ -158,10 +161,10 @@ const destroy = render(lTag`<${Component} />`, document.getElementById('root'),
158
161
  #### With UMD
159
162
 
160
163
  ```html
161
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.8.0/dist/lithent.umd.js"></script>
162
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.8.0/helper/dist/lithentHelper.umd.js"></script-->
163
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.8.0/tag/dist/lithentTag.umd.js"></script>
164
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.8.0/ftags/dist/lithentFTags.umd.js"></script-->
164
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.9.1/dist/lithent.umd.js"></script>
165
+ <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.9.1/helper/dist/lithentHelper.umd.js"></script-->
166
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.9.1/tag/dist/lithentTag.umd.js"></script>
167
+ <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.9.1/ftags/dist/lithentFTags.umd.js"></script-->
165
168
 
166
169
  <div id="root"></div>
167
170
 
@@ -14,6 +14,16 @@ export declare const FFragment: (props: Props, ...children: MiddleStateWDom[]) =
14
14
  children: WDom[];
15
15
  resolve: (compKey?: Props | undefined) => WDom;
16
16
  };
17
+ export declare const fFragment: (...children: MiddleStateWDom[]) => WDom | {
18
+ type: string;
19
+ children: WDom[];
20
+ } | {
21
+ tagName: string;
22
+ ctor: TagFunction;
23
+ props: Props;
24
+ children: WDom[];
25
+ resolve: (compKey?: Props | undefined) => WDom;
26
+ };
17
27
  export declare const fMount: <T>(component: Component<T>) => (props?: T | undefined, ...children: MiddleStateWDom[]) => WDom | {
18
28
  type: string;
19
29
  children: WDom[];
@@ -2,17 +2,18 @@ import { h as e, Fragment as c } from "lithent";
2
2
  const g = new Proxy(
3
3
  {},
4
4
  {
5
- get(n, t) {
6
- return (r, ...o) => e(t, r || {}, ...o);
5
+ get(t, n) {
6
+ return (r, ...o) => e(n, r || {}, ...o);
7
7
  }
8
8
  }
9
- ), u = (n, ...t) => e(c, n, ...t), a = (n) => {
10
- const t = (r, o) => n;
11
- return (r, ...o) => e(t, r || {}, o);
9
+ ), u = (t, ...n) => e(c, t, ...n), a = (...t) => e(c, {}, ...t), m = (t) => {
10
+ const n = (r, o) => t;
11
+ return (r, ...o) => e(n, r || {}, ...o);
12
12
  };
13
13
  export {
14
14
  u as FFragment,
15
- a as fMount,
15
+ a as fFragment,
16
+ m as fMount,
16
17
  g as fTags
17
18
  };
18
19
  //# sourceMappingURL=lithentFTags.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lithentFTags.mjs","sources":["../src/index.ts"],"sourcesContent":["import { h, Fragment } from 'lithent';\nimport type {\n Props,\n WDom,\n FragmentFunction,\n MiddleStateWDom,\n Component,\n TagFunction,\n} from 'lithent';\n\ntype FFunction = (props?: Props, ...childrens: MiddleStateWDom[]) => WDom;\ntype FTags = {\n [tagName: string]: FFunction;\n};\n\nexport const fTags: FTags = new Proxy(\n {},\n {\n get(_: {}, tagName: string) {\n return (props?: Props, ...childrens: MiddleStateWDom[]) =>\n h(tagName, props || {}, ...childrens);\n },\n }\n);\n\nexport const FFragment = (props: Props, ...children: MiddleStateWDom[]) => {\n return h(Fragment as FragmentFunction, props, ...children);\n};\n\nexport const fMount = <T>(component: Component<T>) => {\n const tagFunction = (_props: T, _children: WDom[]) => component;\n\n return (props?: T, ...children: MiddleStateWDom[]) =>\n h(tagFunction as TagFunction, props || {}, children);\n};\n"],"names":["fTags","_","tagName","props","childrens","h","FFragment","children","Fragment","fMount","component","tagFunction","_props","_children"],"mappings":";AAeO,MAAMA,IAAe,IAAI;AAAA,EAC9B,CAAC;AAAA,EACD;AAAA,IACE,IAAIC,GAAOC,GAAiB;AACnB,aAAA,CAACC,MAAkBC,MACxBC,EAAEH,GAASC,KAAS,CAAA,GAAI,GAAGC,CAAS;AAAA,IACxC;AAAA,EACF;AACF,GAEaE,IAAY,CAACH,MAAiBI,MAClCF,EAAEG,GAA8BL,GAAO,GAAGI,CAAQ,GAG9CE,IAAS,CAAIC,MAA4B;AAC9C,QAAAC,IAAc,CAACC,GAAWC,MAAsBH;AAE/C,SAAA,CAACP,MAAcI,MACpBF,EAAEM,GAA4BR,KAAS,IAAII,CAAQ;AACvD;"}
1
+ {"version":3,"file":"lithentFTags.mjs","sources":["../src/index.ts"],"sourcesContent":["import { h, Fragment } from 'lithent';\nimport type {\n Props,\n WDom,\n FragmentFunction,\n MiddleStateWDom,\n Component,\n TagFunction,\n} from 'lithent';\n\ntype FFunction = (props?: Props, ...childrens: MiddleStateWDom[]) => WDom;\ntype FTags = {\n [tagName: string]: FFunction;\n};\n\nexport const fTags: FTags = new Proxy(\n {},\n {\n get(_: {}, tagName: string) {\n return (props?: Props, ...childrens: MiddleStateWDom[]) =>\n h(tagName, props || {}, ...childrens);\n },\n }\n);\n\nexport const FFragment = (props: Props, ...children: MiddleStateWDom[]) => {\n return h(Fragment as FragmentFunction, props, ...children);\n};\n\nexport const fFragment = (...children: MiddleStateWDom[]) => {\n return h(Fragment as FragmentFunction, {}, ...children);\n};\n\nexport const fMount = <T>(component: Component<T>) => {\n const tagFunction = (_props: T, _children: WDom[]) => component;\n\n return (props?: T, ...children: MiddleStateWDom[]) =>\n h(tagFunction as TagFunction, props || {}, ...children);\n};\n"],"names":["fTags","_","tagName","props","childrens","h","FFragment","children","Fragment","fFragment","fMount","component","tagFunction","_props","_children"],"mappings":";AAeO,MAAMA,IAAe,IAAI;AAAA,EAC9B,CAAC;AAAA,EACD;AAAA,IACE,IAAIC,GAAOC,GAAiB;AACnB,aAAA,CAACC,MAAkBC,MACxBC,EAAEH,GAASC,KAAS,CAAA,GAAI,GAAGC,CAAS;AAAA,IACxC;AAAA,EACF;AACF,GAEaE,IAAY,CAACH,MAAiBI,MAClCF,EAAEG,GAA8BL,GAAO,GAAGI,CAAQ,GAG9CE,IAAY,IAAIF,MACpBF,EAAEG,GAA8B,IAAI,GAAGD,CAAQ,GAG3CG,IAAS,CAAIC,MAA4B;AAC9C,QAAAC,IAAc,CAACC,GAAWC,MAAsBH;AAE/C,SAAA,CAACR,MAAcI,MACpBF,EAAEO,GAA4BT,KAAS,CAAA,GAAI,GAAGI,CAAQ;AAC1D;"}
@@ -1,2 +1,2 @@
1
- (function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("lithent")):typeof define=="function"&&define.amd?define(["exports","lithent"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.lithentFTags={},e.lithent))})(this,function(e,n){"use strict";const r=new Proxy({},{get(o,t){return(i,...f)=>n.h(t,i||{},...f)}}),u=(o,...t)=>n.h(n.Fragment,o,...t),s=o=>{const t=(i,f)=>o;return(i,...f)=>n.h(t,i||{},f)};e.FFragment=u,e.fMount=s,e.fTags=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("lithent")):typeof define=="function"&&define.amd?define(["exports","lithent"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.lithentFTags={},e.lithent))})(this,function(e,n){"use strict";const u=new Proxy({},{get(t,r){return(o,...f)=>n.h(r,o||{},...f)}}),i=(t,...r)=>n.h(n.Fragment,t,...r),s=(...t)=>n.h(n.Fragment,{},...t),d=t=>{const r=(o,f)=>t;return(o,...f)=>n.h(r,o||{},...f)};e.FFragment=i,e.fFragment=s,e.fMount=d,e.fTags=u,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=lithentFTags.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lithentFTags.umd.js","sources":["../src/index.ts"],"sourcesContent":["import { h, Fragment } from 'lithent';\nimport type {\n Props,\n WDom,\n FragmentFunction,\n MiddleStateWDom,\n Component,\n TagFunction,\n} from 'lithent';\n\ntype FFunction = (props?: Props, ...childrens: MiddleStateWDom[]) => WDom;\ntype FTags = {\n [tagName: string]: FFunction;\n};\n\nexport const fTags: FTags = new Proxy(\n {},\n {\n get(_: {}, tagName: string) {\n return (props?: Props, ...childrens: MiddleStateWDom[]) =>\n h(tagName, props || {}, ...childrens);\n },\n }\n);\n\nexport const FFragment = (props: Props, ...children: MiddleStateWDom[]) => {\n return h(Fragment as FragmentFunction, props, ...children);\n};\n\nexport const fMount = <T>(component: Component<T>) => {\n const tagFunction = (_props: T, _children: WDom[]) => component;\n\n return (props?: T, ...children: MiddleStateWDom[]) =>\n h(tagFunction as TagFunction, props || {}, children);\n};\n"],"names":["fTags","_","tagName","props","childrens","h","FFragment","children","Fragment","fMount","component","tagFunction","_props","_children"],"mappings":"6QAea,MAAAA,EAAe,IAAI,MAC9B,CAAC,EACD,CACE,IAAIC,EAAOC,EAAiB,CACnB,MAAA,CAACC,KAAkBC,IACxBC,EAAA,EAAEH,EAASC,GAAS,CAAA,EAAI,GAAGC,CAAS,CACxC,CACF,CACF,EAEaE,EAAY,CAACH,KAAiBI,IAClCF,EAAE,EAAAG,EAAA,SAA8BL,EAAO,GAAGI,CAAQ,EAG9CE,EAAaC,GAA4B,CAC9C,MAAAC,EAAc,CAACC,EAAWC,IAAsBH,EAE/C,MAAA,CAACP,KAAcI,IACpBF,EAAAA,EAAEM,EAA4BR,GAAS,GAAII,CAAQ,CACvD"}
1
+ {"version":3,"file":"lithentFTags.umd.js","sources":["../src/index.ts"],"sourcesContent":["import { h, Fragment } from 'lithent';\nimport type {\n Props,\n WDom,\n FragmentFunction,\n MiddleStateWDom,\n Component,\n TagFunction,\n} from 'lithent';\n\ntype FFunction = (props?: Props, ...childrens: MiddleStateWDom[]) => WDom;\ntype FTags = {\n [tagName: string]: FFunction;\n};\n\nexport const fTags: FTags = new Proxy(\n {},\n {\n get(_: {}, tagName: string) {\n return (props?: Props, ...childrens: MiddleStateWDom[]) =>\n h(tagName, props || {}, ...childrens);\n },\n }\n);\n\nexport const FFragment = (props: Props, ...children: MiddleStateWDom[]) => {\n return h(Fragment as FragmentFunction, props, ...children);\n};\n\nexport const fFragment = (...children: MiddleStateWDom[]) => {\n return h(Fragment as FragmentFunction, {}, ...children);\n};\n\nexport const fMount = <T>(component: Component<T>) => {\n const tagFunction = (_props: T, _children: WDom[]) => component;\n\n return (props?: T, ...children: MiddleStateWDom[]) =>\n h(tagFunction as TagFunction, props || {}, ...children);\n};\n"],"names":["fTags","_","tagName","props","childrens","h","FFragment","children","Fragment","fFragment","fMount","component","tagFunction","_props","_children"],"mappings":"6QAea,MAAAA,EAAe,IAAI,MAC9B,CAAC,EACD,CACE,IAAIC,EAAOC,EAAiB,CACnB,MAAA,CAACC,KAAkBC,IACxBC,EAAA,EAAEH,EAASC,GAAS,CAAA,EAAI,GAAGC,CAAS,CACxC,CACF,CACF,EAEaE,EAAY,CAACH,KAAiBI,IAClCF,EAAE,EAAAG,EAAA,SAA8BL,EAAO,GAAGI,CAAQ,EAG9CE,EAAY,IAAIF,IACpBF,EAAE,EAAAG,EAAA,SAA8B,GAAI,GAAGD,CAAQ,EAG3CG,EAAaC,GAA4B,CAC9C,MAAAC,EAAc,CAACC,EAAWC,IAAsBH,EAE/C,MAAA,CAACR,KAAcI,IACpBF,EAAA,EAAEO,EAA4BT,GAAS,CAAA,EAAI,GAAGI,CAAQ,CAC1D"}
@@ -27,9 +27,13 @@ export const FFragment = (props: Props, ...children: MiddleStateWDom[]) => {
27
27
  return h(Fragment as FragmentFunction, props, ...children);
28
28
  };
29
29
 
30
+ export const fFragment = (...children: MiddleStateWDom[]) => {
31
+ return h(Fragment as FragmentFunction, {}, ...children);
32
+ };
33
+
30
34
  export const fMount = <T>(component: Component<T>) => {
31
35
  const tagFunction = (_props: T, _children: WDom[]) => component;
32
36
 
33
37
  return (props?: T, ...children: MiddleStateWDom[]) =>
34
- h(tagFunction as TagFunction, props || {}, children);
38
+ h(tagFunction as TagFunction, props || {}, ...children);
35
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lithent",
3
- "version": "1.8.0",
3
+ "version": "1.9.1",
4
4
  "description": "An extensible virtual DOM library for lightweight use in a variety of environments.",
5
5
  "packageManager": "pnpm@7.6.0",
6
6
  "main": "./dist/lithent.umd.js",
@@ -28,30 +28,29 @@ const fMount = <T,>(component: Component<T>) => {
28
28
  const tagFunction = (_props: T, _children: WDom[]) => component;
29
29
 
30
30
  return (props?: T, ...children: MiddleStateWDom[]) =>
31
- h(tagFunction as TagFunction, props || {}, children);
31
+ h(tagFunction as TagFunction, props || {}, ...children);
32
32
  };
33
33
 
34
- const FFragment = (props: Props, ...children: MiddleStateWDom[]) => {
35
- return h(Fragment as FragmentFunction, props, ...children);
34
+ const fFragment = (...children: MiddleStateWDom[]) => {
35
+ return h(Fragment as FragmentFunction, {}, ...children);
36
36
  };
37
37
 
38
38
  const { section, div, p, br, strong } = fTags;
39
39
 
40
- const FTagComponent = fMount<{ a: number }>((_r, props, children) => {
40
+ const fTagComponent = fMount<{ a: number }>((_r, props, children) => {
41
41
  return () =>
42
- FFragment(
43
- {},
42
+ fFragment(
44
43
  'first inner',
45
- div({ style: 'border: 1px solid red' }, 'second inner'),
44
+ div({ style: { border: '1px solid red' } }, 'second inner'),
46
45
  props.a,
47
46
  ...children
48
47
  );
49
48
  });
50
49
 
51
50
  render(
52
- FTagComponent(
51
+ fTagComponent(
53
52
  { a: 3 },
54
- div({ style: 'border: 1px solid green' }, `Fchildren1`),
53
+ div({ style: { border: '1px solid green' } }, `Fchildren1`),
55
54
  'Fchildren2',
56
55
  br(),
57
56
  section(