lilact 0.23.1 → 0.24.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 (45) hide show
  1. package/README.md +17 -1
  2. package/dist/lilact.development.js +485 -461
  3. package/dist/lilact.development.js.map +4 -4
  4. package/dist/lilact.development.min.js +24 -24
  5. package/dist/lilact.development.min.js.map +4 -4
  6. package/dist/lilact.production.min.js +25 -25
  7. package/docs/assets/hierarchy.js +1 -1
  8. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  9. package/docs/classes/accessories.Suspense.html +7 -7
  10. package/docs/classes/components.Component.html +11 -11
  11. package/docs/classes/components.HTMLComponent.html +11 -11
  12. package/docs/classes/components.RootComponent.html +11 -11
  13. package/docs/functions/components.cloneComponent.html +1 -1
  14. package/docs/functions/components.createComponent.html +1 -1
  15. package/docs/functions/components.createPortal.html +1 -1
  16. package/docs/functions/components.createRoot.html +1 -1
  17. package/docs/functions/components.memo.html +1 -1
  18. package/docs/functions/components.render.html +1 -1
  19. package/docs/functions/timers.timeoutPromise.html +4 -4
  20. package/docs/hierarchy.html +1 -1
  21. package/docs/index.html +18 -1
  22. package/docs/static/demos/cloneelement.jsx +6 -0
  23. package/docs/static/demos/lazy.jsx +1 -1
  24. package/docs/static/demos/legacy-context.jsx +0 -7
  25. package/docs/static/index.html +2 -2
  26. package/docs/static/lilact.development.js +485 -461
  27. package/docs/static/lilact.development.js.map +4 -4
  28. package/docs/static/lilact.development.min.js +24 -24
  29. package/docs/static/lilact.development.min.js.map +4 -4
  30. package/docs/static/lilact.production.min.js +25 -25
  31. package/docs/variables/components.cloneElement.html +1 -1
  32. package/examples/demos/cloneelement.jsx +6 -0
  33. package/examples/demos/lazy.jsx +1 -1
  34. package/examples/demos/legacy-context.jsx +0 -7
  35. package/examples/index.html +2 -2
  36. package/examples/lilact.development.js +485 -461
  37. package/examples/lilact.development.js.map +4 -4
  38. package/examples/lilact.development.min.js +24 -24
  39. package/examples/lilact.development.min.js.map +4 -4
  40. package/examples/lilact.production.min.js +25 -25
  41. package/package.json +1 -1
  42. package/src/components.jsx +11 -4
  43. package/src/lilact.jsx +1 -1
  44. package/src/proptypes.jsx +38 -0
  45. package/impexptest.js +0 -51
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lilact",
3
- "version": "0.23.1",
3
+ "version": "0.24.1",
4
4
  "description": "A Little React/JSX Runtime Implementation for Browser",
5
5
  "repository": "github:arashkazemi/lilact",
6
6
  "homepage": "https://arashkazemi.github.io/lilact/",
@@ -35,6 +35,8 @@ import { shallowEqual, toBool, isClass } from "./misc.jsx";
35
35
 
36
36
  import { PropTypes } from './proptypes.jsx';
37
37
 
38
+ const SVG_NS = "http://www.w3.org/2000/svg";
39
+
38
40
  /*
39
41
  ComponentCache is for internal use. It is the heart of the JSX runtime,
40
42
  it holds child components and detects which one is being rendered or updated.
@@ -210,7 +212,12 @@ if(DEBUG) {
210
212
 
211
213
  if( typeof(this.entity)==='string' ) {
212
214
  if(!(this.element instanceof Element)) {
213
- this.element = document.createElement(this.entity);
215
+ if(this.parent.entity==='svg' || this.entity==='svg') {
216
+ this.element = document.createElementNS(SVG_NS, this.entity);
217
+ }
218
+ else {
219
+ this.element = document.createElement(this.entity);
220
+ }
214
221
  if(next_props?.defaultValue) this.element.value = String(next_props.defaultValue).slice(0, next_props?.maxLength);
215
222
  if(next_props?.defaultChecked) this.element.checked = next_props.defaultChecked;
216
223
  }
@@ -1142,7 +1149,7 @@ export function createComponent(entity, props={}, ...children)
1142
1149
  props.key = generateComponentKey(entity, props);
1143
1150
  props.children = children;
1144
1151
 
1145
- return { entity, props };
1152
+ return { entity, props, [CORE]: null };
1146
1153
  }
1147
1154
 
1148
1155
  /**
@@ -1208,7 +1215,7 @@ export function createPortal(children, element)
1208
1215
 
1209
1216
  export function cloneComponent(component, propsPatch, ...children)
1210
1217
  {
1211
- return { entity: component.entity, props: {...component.props, ...propsPatch, children} };
1218
+ return { entity: component.entity, props: {...component.props, ...propsPatch, children}, [CORE]: null };
1212
1219
  }
1213
1220
 
1214
1221
  export const cloneElement = cloneComponent;
@@ -1247,7 +1254,7 @@ export function memo(component)
1247
1254
  component[MEMOIZED] = true;
1248
1255
  }
1249
1256
  else {
1250
- component = { component, [MEMOIZED]: true };
1257
+ component = { component, [MEMOIZED]: true, [CORE]: null };
1251
1258
  }
1252
1259
  return component;
1253
1260
  }
package/src/lilact.jsx CHANGED
@@ -92,7 +92,7 @@ export {transpileJSX, transpilerConfig} from "./jsx";
92
92
  export const Lilact =
93
93
  {
94
94
 
95
- VERSION: "beta.23",
95
+ VERSION: "RC.1",
96
96
 
97
97
  // Configuration
98
98
 
package/src/proptypes.jsx CHANGED
@@ -28,6 +28,9 @@
28
28
 
29
29
  */
30
30
 
31
+ import { isValidComponent } from "./misc.jsx";
32
+
33
+
31
34
  function isNullOrUndefined(v) {
32
35
  return v === null || v === undefined;
33
36
  }
@@ -45,6 +48,28 @@ function defaultGetDisplayName(x) {
45
48
  return x.displayName || x.name || "Unknown";
46
49
  }
47
50
 
51
+
52
+ // ---- node validator ----
53
+ function isNode(x) {
54
+ // ignored-by-render children should be accepted by node
55
+ if (x === null || x === undefined) return true;
56
+ if (x === false || x === true) return true;
57
+
58
+ // primitives render
59
+ if (typeof x === "string" || typeof x === "number") return true;
60
+
61
+ if (isValidComponent(x)) return true;
62
+
63
+ // arrays are accepted as children; renderer will flatten later
64
+ if (Array.isArray(x)) return x.every(isNode);
65
+
66
+ return false;
67
+ }
68
+
69
+ function isValidElementType(x) {
70
+ return typeof x === "function" || typeof x === "string";
71
+ }
72
+
48
73
  /**
49
74
  * Build a prop validator with a consistent contract:
50
75
  * validator(props, propName, componentName, location, propFullName)
@@ -117,6 +142,19 @@ function createPropTypes() {
117
142
  PropTypes.symbol = createPrimitiveValidator((v) => typeof v === "symbol");
118
143
  PropTypes.symbol.expectedType = "symbol";
119
144
 
145
+ PropTypes.component = createPrimitiveValidator((v) => isValidComponent(v));
146
+ PropTypes.component.expectedType = "component";
147
+
148
+ PropTypes.element = createPrimitiveValidator((v) => isValidComponent(v));
149
+ PropTypes.element.expectedType = "element";
150
+
151
+ PropTypes.node = createPrimitiveValidator((v) => isNode(v));
152
+ PropTypes.node.expectedType = "node";
153
+
154
+ PropTypes.elementType = createPrimitiveValidator((v) => isValidElementType(v));
155
+ PropTypes.elementType.expectedType = "elementType";
156
+
157
+
120
158
  // ----- combinators -----
121
159
 
122
160
  PropTypes.oneOf = function oneOf(values) {
package/impexptest.js DELETED
@@ -1,51 +0,0 @@
1
- // Imports
2
- import foo from "foo";
3
- import { a, b } from "foo";
4
- import {a as alpha, b as beta} from "foo";
5
- import * as utils from "foo";
6
- import foo, { a, b as c, d } from "foo";
7
- import "foo";
8
-
9
- // Re-exports from other modules
10
- export * from "foo";
11
- export { a, b } from "foo";
12
- export { default as Foo } from "foo";
13
-
14
- export * from "./some-module.js";
15
- export { exportedThing } from "./another-module.js";
16
- export { default as depDefault } from "./yet-another-module.js";
17
- export { default as depDefault, a, b, c as depC } from "./...";
18
-
19
- // Default export forms
20
- const defaultValue = { ok: true };
21
- export default defaultValue;
22
-
23
- export default function defaultFn() {
24
- return "defaultFn";
25
- }
26
-
27
- export default class DefaultClass {
28
- constructor() {}
29
- }
30
-
31
-
32
- export {localA as a, localB as b, localC as c};
33
-
34
-
35
- export { localFn as renamedFn };
36
-
37
- // Additional named exports (declared bindings)
38
- export const namedConst = 1;
39
- export let namedLet = 2;
40
- export var namedVar = 3;
41
-
42
- export function namedFn() {
43
- return "namedFn";
44
- }
45
-
46
-
47
- export class NamedClass {}
48
-
49
- // Re-exporting local bindings is OK (examples)
50
- export defaultValue;
51
- export { defaultValue };