lilact 0.16.3 → 0.18.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 (70) hide show
  1. package/dist/lilact.development.js +227 -151
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +20 -20
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +20 -20
  6. package/docs/assets/hierarchy.js +1 -1
  7. package/docs/assets/navigation.js +1 -1
  8. package/docs/assets/search.js +1 -1
  9. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  10. package/docs/classes/accessories.Suspense.html +7 -7
  11. package/docs/classes/components.Component.html +11 -11
  12. package/docs/classes/components.HTMLComponent.html +11 -11
  13. package/docs/classes/components.RootComponent.html +11 -11
  14. package/docs/functions/components.createComponent.html +1 -1
  15. package/docs/functions/components.createRoot.html +1 -1
  16. package/docs/functions/components.memo.html +7 -0
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/hooks.startTransition.html +6 -0
  19. package/docs/functions/hooks.useActionState.html +1 -1
  20. package/docs/functions/hooks.useDebugValue.html +5 -0
  21. package/docs/functions/hooks.useDeferredValue.html +1 -1
  22. package/docs/functions/hooks.useEffect.html +5 -4
  23. package/docs/functions/hooks.useImperativeHandle.html +1 -1
  24. package/docs/functions/hooks.useInsertionEffect.html +6 -0
  25. package/docs/functions/hooks.useLayoutEffect.html +3 -2
  26. package/docs/functions/hooks.useMemo.html +3 -2
  27. package/docs/functions/hooks.useReducer.html +1 -1
  28. package/docs/functions/misc.Fragment.html +2 -2
  29. package/docs/functions/misc.deepEqual.html +1 -1
  30. package/docs/functions/misc.findDOMNode.html +1 -1
  31. package/docs/functions/misc.forwardRef.html +1 -1
  32. package/docs/functions/misc.getComponentByPointer.html +1 -1
  33. package/docs/functions/misc.isAsync.html +1 -1
  34. package/docs/functions/misc.isClass.html +1 -1
  35. package/docs/functions/misc.isEmpty.html +1 -1
  36. package/docs/functions/misc.isError.html +1 -1
  37. package/docs/functions/misc.isThenable.html +1 -1
  38. package/docs/functions/{misc.isValidElement.html → misc.isValidComponent.html} +1 -1
  39. package/docs/functions/misc.shallowEqual.html +3 -2
  40. package/docs/functions/misc.toBool.html +1 -1
  41. package/docs/functions/timers.timeoutPromise.html +10 -7
  42. package/docs/hierarchy.html +1 -1
  43. package/docs/modules/components.html +1 -1
  44. package/docs/modules/hooks.html +1 -1
  45. package/docs/modules/misc.html +1 -1
  46. package/docs/static/demos/actionstate.jsx +2 -2
  47. package/docs/static/demos/memo.jsx +26 -0
  48. package/docs/static/demos/priorities.jsx +68 -0
  49. package/docs/static/index.html +3 -1
  50. package/docs/static/lilact.development.js +227 -151
  51. package/docs/static/lilact.development.js.map +3 -3
  52. package/docs/static/lilact.development.min.js +20 -20
  53. package/docs/static/lilact.development.min.js.map +3 -3
  54. package/docs/static/lilact.production.min.js +20 -20
  55. package/docs/variables/misc.Children.html +2 -2
  56. package/docs/variables/misc.isValidElement.html +7 -0
  57. package/examples/demos/actionstate.jsx +2 -2
  58. package/examples/demos/memo.jsx +26 -0
  59. package/examples/demos/priorities.jsx +68 -0
  60. package/examples/index.html +3 -1
  61. package/examples/lilact.development.js +227 -151
  62. package/examples/lilact.development.js.map +3 -3
  63. package/examples/lilact.development.min.js +20 -20
  64. package/examples/lilact.development.min.js.map +3 -3
  65. package/examples/lilact.production.min.js +20 -20
  66. package/package.json +1 -1
  67. package/src/components.jsx +126 -40
  68. package/src/hooks.jsx +84 -11
  69. package/src/lilact.jsx +1 -1
  70. package/src/misc.jsx +13 -8
@@ -1977,14 +1977,21 @@ __export(components_exports, {
1977
1977
  createElement: () => createElement,
1978
1978
  createRoot: () => createRoot,
1979
1979
  current_component: () => current_component,
1980
+ effect_timeout: () => effect_timeout,
1980
1981
  events_set: () => events_set,
1982
+ insertion_effects: () => insertion_effects,
1981
1983
  layout_effects: () => layout_effects,
1982
1984
  length_css_attributes_set: () => length_css_attributes_set,
1985
+ memo: () => memo,
1986
+ passive_effects: () => passive_effects,
1987
+ processEffects: () => processEffects,
1983
1988
  render: () => render,
1984
1989
  roots: () => roots,
1985
1990
  special_attributes: () => special_attributes,
1986
1991
  update_cbs: () => update_cbs,
1987
- update_set: () => update_set
1992
+ update_interval_margin: () => update_interval_margin,
1993
+ update_set: () => update_set,
1994
+ update_timeout: () => update_timeout
1988
1995
  });
1989
1996
 
1990
1997
  // .tmp/src/symbols.jsx
@@ -2036,11 +2043,10 @@ __export(misc_exports, {
2036
2043
  isEmpty: () => isEmpty,
2037
2044
  isError: () => isError2,
2038
2045
  isThenable: () => isThenable,
2046
+ isValidComponent: () => isValidComponent,
2039
2047
  isValidElement: () => isValidElement,
2040
2048
  shallowEqual: () => shallowEqual,
2041
- toBool: () => toBool,
2042
- update_interval_margin: () => update_interval_margin,
2043
- update_timeout: () => update_timeout
2049
+ toBool: () => toBool
2044
2050
  });
2045
2051
  var typeOf = (input) => {
2046
2052
  const rawObject = Object.prototype.toString.call(input).toLowerCase();
@@ -2048,9 +2054,10 @@ var typeOf = (input) => {
2048
2054
  const type = typeOfRegex.exec(rawObject)[1];
2049
2055
  return type;
2050
2056
  };
2051
- var isValidElement = (value) => {
2057
+ var isValidComponent = (value) => {
2052
2058
  return value[CORE] !== void 0 || value[TEXT] !== void 0;
2053
2059
  };
2060
+ var isValidElement = isValidComponent;
2054
2061
  var findDOMNode = (component) => {
2055
2062
  var _a, _b;
2056
2063
  if (!((_b = (_a = component[CORE]) == null ? void 0 : _a.element) == null ? void 0 : _b.parentNode)) throw new Error("findDOMNode only works on mounted components.");
@@ -2130,7 +2137,7 @@ function isEmpty(value) {
2130
2137
  for (let i2 in value) return false;
2131
2138
  return true;
2132
2139
  }
2133
- var shallowEqual = (source, target) => {
2140
+ var shallowEqual = (source, target, ignore) => {
2134
2141
  if (typeOf(source) !== typeOf(target)) {
2135
2142
  return false;
2136
2143
  }
@@ -2138,9 +2145,9 @@ var shallowEqual = (source, target) => {
2138
2145
  if (source.length !== target.length) {
2139
2146
  return false;
2140
2147
  }
2141
- return source.every((el, index2) => el === target[index2]);
2148
+ return source.every((el, index2) => el === target[index2] || index2 === ignore);
2142
2149
  } else if (typeOf(source) === "object") {
2143
- return Object.keys(source).every((key) => source[key] === target[key]);
2150
+ return Object.keys(source).every((key) => source[key] === target[key] || key === ignore);
2144
2151
  } else if (typeOf(source) === "date") {
2145
2152
  return source.getTime() === target.getTime();
2146
2153
  }
@@ -2193,8 +2200,6 @@ function toBool(value) {
2193
2200
  }
2194
2201
  return Boolean(value);
2195
2202
  }
2196
- var update_timeout = void 0;
2197
- var update_interval_margin = 0;
2198
2203
  var id_num = Math.floor(Math.random() * 1e4);
2199
2204
  var eval_num = 0;
2200
2205
 
@@ -2239,7 +2244,11 @@ var ComponentCache = class {
2239
2244
  commit() {
2240
2245
  this.current_map.forEach((arr) => {
2241
2246
  arr.slice(arr[IDX]).forEach((ex) => {
2242
- if (ex.cleanup) ex.cleanup();
2247
+ if (ex.cleanup) {
2248
+ ex.cleanup();
2249
+ } else if (ex.element) {
2250
+ ex.element.parentElement.removeChild(ex.element);
2251
+ }
2243
2252
  });
2244
2253
  });
2245
2254
  this.current_map = this.new_map;
@@ -2277,116 +2286,116 @@ var ComponentCore = class {
2277
2286
  this.props = props || {};
2278
2287
  }
2279
2288
  /*
2280
- //let do_rerender = true;
2281
-
2282
- // if(this.outlet && this.entity[MEMOIZED]) {
2283
- // if(shallowEqual(this.props, next_props)) do_rerender=false;
2284
- // delete this.entity[MEMOIZED];
2285
- // }
2286
-
2287
- if(do_rerender) {
2288
- */
2289
+ */
2289
2290
  // TODO: should componentDidUpdate be called after arranging/appending the outlet or before?
2290
2291
  apply(next_props = this.props, next_state = this.next_state || this.state) {
2291
- var _a, _b, _c, _d;
2292
- if (true) {
2293
- if ((_a = this.entity) == null ? void 0 : _a.propTypes) {
2294
- PropTypes.checkPropTypes(this.entity.propTypes, this.props, "prop", this.entity.name);
2295
- } else if ((_b = this.component) == null ? void 0 : _b.propTypes) {
2296
- PropTypes.checkPropTypes(this.component.propTypes, this.props, "prop", this.component.name);
2292
+ var _a, _b, _c, _d, _e;
2293
+ let do_rerender = true;
2294
+ if (this.outlet && (this == null ? void 0 : this[MEMOIZED])) {
2295
+ if (shallowEqual(this.props, next_props, "children") && shallowEqual((_a = this.props) == null ? void 0 : _a.children, next_props == null ? void 0 : next_props.children)) {
2296
+ do_rerender = false;
2297
2297
  }
2298
2298
  }
2299
- if (typeof next_state === "function") next_state = next_state(this.state);
2300
- if (this.component.constructor.defaultProps) {
2301
- next_props = { ...this.component.constructor.defaultProps, ...next_props };
2302
- }
2303
- if (this.component.shouldComponentUpdate && !this.component.shouldComponentUpdate(next_state, next_props, this.context)) return;
2304
- if (typeof this.entity === "string") {
2305
- if (!(this.element instanceof Element)) {
2306
- this.element = document.createElement(this.entity);
2307
- if (next_props == null ? void 0 : next_props.defaultValue) this.element.value = String(next_props.defaultValue).slice(0, next_props == null ? void 0 : next_props.maxLength);
2308
- if (next_props == null ? void 0 : next_props.defaultChecked) this.element.checked = next_props.defaultChecked;
2299
+ if (do_rerender) {
2300
+ if (true) {
2301
+ if ((_b = this.entity) == null ? void 0 : _b.propTypes) {
2302
+ PropTypes.checkPropTypes(this.entity.propTypes, this.props, "prop", this.entity.name);
2303
+ } else if ((_c = this.component) == null ? void 0 : _c.propTypes) {
2304
+ PropTypes.checkPropTypes(this.component.propTypes, this.props, "prop", this.component.name);
2305
+ }
2309
2306
  }
2310
- this.element[COMPONENT] = this.component;
2311
- }
2312
- if (next_props.ref) {
2313
- if (typeof next_props.ref === "function") {
2314
- next_props.ref(this.element || this.component);
2315
- } else {
2316
- next_props.ref.current = this.element || this.component;
2307
+ if (typeof next_state === "function") next_state = next_state(this.state);
2308
+ if (this.component.constructor.defaultProps) {
2309
+ next_props = { ...this.component.constructor.defaultProps, ...next_props };
2317
2310
  }
2318
- }
2319
- if (next_props !== void 0 && this.component.componentWillReceiveProps) {
2320
- this.component.componentWillReceiveProps(next_props);
2321
- }
2322
- if (this.component.componentWillUpdate) {
2323
- this.component.componentWillUpdate(next_props, next_state);
2324
- }
2325
- const prev_state = this.state, prev_props = this.props;
2326
- if (this.element) {
2327
- this.updateElementProps(next_props);
2328
- }
2329
- this.props = next_props;
2330
- if (typeof this.next_state === "object") {
2331
- if (!this.state) this.state = { ...next_state };
2332
- else Object.assign(this.state, next_state);
2333
- } else if (this.next_state !== void 0) throw new Error("Component.setState only accepts objects or functions is new state.");
2334
- if (this.next_state) delete this.next_state;
2335
- if (this.hooks !== void 0) {
2336
- this.hook_index = 0;
2337
- lilact_default.current_component = [this, lilact_default.current_component];
2338
- try {
2339
- this.outlet = this.component.render(next_props, { current: this.element || this.component });
2340
- } catch (e) {
2341
- renderErrorHandler(this, e);
2311
+ if (this.component.shouldComponentUpdate && !this.component.shouldComponentUpdate(next_state, next_props, this.context)) return;
2312
+ if (typeof this.entity === "string") {
2313
+ if (!(this.element instanceof Element)) {
2314
+ this.element = document.createElement(this.entity);
2315
+ if (next_props == null ? void 0 : next_props.defaultValue) this.element.value = String(next_props.defaultValue).slice(0, next_props == null ? void 0 : next_props.maxLength);
2316
+ if (next_props == null ? void 0 : next_props.defaultChecked) this.element.checked = next_props.defaultChecked;
2317
+ }
2318
+ this.element[COMPONENT] = this.component;
2342
2319
  }
2343
- lilact_default.current_component = lilact_default.current_component[1];
2344
- } else {
2345
- try {
2346
- this.outlet = this.component.render({ current: this.element || this.component });
2347
- } catch (e) {
2348
- renderErrorHandler(this, e);
2320
+ if (next_props.ref) {
2321
+ if (typeof next_props.ref === "function") {
2322
+ next_props.ref(this.element || this.component);
2323
+ } else {
2324
+ next_props.ref.current = this.element || this.component;
2325
+ }
2349
2326
  }
2350
- }
2351
- if (((_d = (_c = this.outlet) == null ? void 0 : _c.constructor) == null ? void 0 : _d.name) !== "Array") {
2352
- this.outlet = [this.outlet];
2353
- }
2354
- this.outlet = [...this.outlet];
2355
- for (let i2 = 0; i2 < this.outlet.length; i2++) {
2356
- let item = this.outlet[i2];
2357
- if (item === void 0 || item === null || typeof item === "boolean") {
2358
- this.outlet.splice(i2, 1);
2359
- i2--;
2360
- } else if (typeof item === "function") {
2361
- const res2 = this.childFunctionHandler(item);
2362
- this.outlet.splice(i2, 1, res2);
2363
- i2--;
2364
- } else if (item.constructor.name === "Array") {
2365
- this.outlet.splice(i2, 1, ...item);
2366
- i2--;
2327
+ if (next_props !== void 0 && this.component.componentWillReceiveProps) {
2328
+ this.component.componentWillReceiveProps(next_props);
2329
+ }
2330
+ if (this.component.componentWillUpdate) {
2331
+ this.component.componentWillUpdate(next_props, next_state);
2332
+ }
2333
+ const prev_state = this.state, prev_props = this.props;
2334
+ if (this.element) {
2335
+ this.updateElementProps(next_props);
2336
+ }
2337
+ this.props = next_props;
2338
+ if (typeof this.next_state === "object") {
2339
+ if (!this.state) this.state = { ...next_state };
2340
+ else Object.assign(this.state, next_state);
2341
+ } else if (this.next_state !== void 0) throw new Error("Component.setState only accepts objects or functions is new state.");
2342
+ if (this.next_state) delete this.next_state;
2343
+ if (this.hooks !== void 0) {
2344
+ this.hook_index = 0;
2345
+ lilact_default.current_component = [this, lilact_default.current_component];
2346
+ try {
2347
+ this.outlet = this.component.render(next_props, { current: this.element || this.component });
2348
+ } catch (e) {
2349
+ renderErrorHandler(this, e);
2350
+ }
2351
+ lilact_default.current_component = lilact_default.current_component[1];
2367
2352
  } else {
2368
- const core = prepareCore(this, item);
2369
- this.outlet[i2] = core;
2370
- if (core[TEXT2] === void 0) {
2371
- core.container = this.element ? this : this.container;
2372
- core.apply(item.props);
2353
+ try {
2354
+ this.outlet = this.component.render({ current: this.element || this.component });
2355
+ } catch (e) {
2356
+ renderErrorHandler(this, e);
2357
+ }
2358
+ }
2359
+ if (((_e = (_d = this.outlet) == null ? void 0 : _d.constructor) == null ? void 0 : _e.name) !== "Array") {
2360
+ this.outlet = [this.outlet];
2361
+ }
2362
+ this.outlet = [...this.outlet];
2363
+ for (let i2 = 0; i2 < this.outlet.length; i2++) {
2364
+ let item = this.outlet[i2];
2365
+ if (item === void 0 || item === null || typeof item === "boolean") {
2366
+ this.outlet.splice(i2, 1);
2367
+ i2--;
2368
+ } else if (typeof item === "function") {
2369
+ const res2 = this.childFunctionHandler(item);
2370
+ this.outlet.splice(i2, 1, res2);
2371
+ i2--;
2372
+ } else if (item.constructor.name === "Array") {
2373
+ this.outlet.splice(i2, 1, ...item);
2374
+ i2--;
2373
2375
  } else {
2374
- if (!core.element) {
2375
- core.element = document.createTextNode(item[TEXT2]);
2376
- core[TEXT2] = item[TEXT2];
2377
- } else if (core[TEXT2] !== item[TEXT2]) {
2378
- core.element.textContent = item[TEXT2];
2379
- core[TEXT2] = item[TEXT2];
2376
+ const core = prepareCore(this, item);
2377
+ this.outlet[i2] = core;
2378
+ if (core[TEXT2] === void 0) {
2379
+ core.container = this.element ? this : this.container;
2380
+ core.apply(item.props);
2381
+ } else {
2382
+ if (!core.element) {
2383
+ core.element = document.createTextNode(item[TEXT2]);
2384
+ core[TEXT2] = item[TEXT2];
2385
+ } else if (core[TEXT2] !== item[TEXT2]) {
2386
+ core.element.textContent = item[TEXT2];
2387
+ core[TEXT2] = item[TEXT2];
2388
+ }
2380
2389
  }
2381
2390
  }
2382
2391
  }
2392
+ if (this.cache) this.cache.commit();
2393
+ if (this.element) this.arrangeOutlet();
2394
+ if (this.component.componentDidUpdate) {
2395
+ this.component.componentDidUpdate(prev_props, prev_state, this.last_snapshot);
2396
+ }
2397
+ if (this.last_snapshot) delete this.last_snapshot;
2383
2398
  }
2384
- if (this.cache) this.cache.commit();
2385
- if (this.element) this.arrangeOutlet();
2386
- if (this.component.componentDidUpdate) {
2387
- this.component.componentDidUpdate(prev_props, prev_state, this.last_snapshot);
2388
- }
2389
- if (this.last_snapshot) delete this.last_snapshot;
2390
2399
  }
2391
2400
  async cleanup() {
2392
2401
  var _a, _b, _c;
@@ -2614,18 +2623,23 @@ var renderErrorHandler = (c, e) => {
2614
2623
  } else throw e;
2615
2624
  };
2616
2625
  function constructFunc(core, parent) {
2617
- var _a, _b;
2618
2626
  let comp = core;
2619
2627
  if (core[TEXT2] !== void 0) {
2620
2628
  } else {
2621
- if (typeof core.entity === "string") {
2622
- comp = new HTMLComponent(core.entity, core.props);
2629
+ let entity = core.entity;
2630
+ let memoized = false;
2631
+ if (typeof entity === "object" && entity[MEMOIZED]) {
2632
+ memoized = true;
2633
+ entity = entity[MEMOIZED];
2634
+ }
2635
+ if (typeof entity === "string") {
2636
+ comp = new HTMLComponent(entity, core.props);
2623
2637
  } else {
2624
- if (isClass(core.entity)) {
2625
- if ((_a = core.entity) == null ? void 0 : _a.defaultProps) {
2626
- core.props = { ...core.entity.defaultProps, ...core.props };
2638
+ if (isClass(entity)) {
2639
+ if (entity == null ? void 0 : entity.defaultProps) {
2640
+ core.props = { ...entity.defaultProps, ...core.props };
2627
2641
  }
2628
- comp = new core.entity(core.props);
2642
+ comp = new entity(core.props);
2629
2643
  const desc = Object.getOwnPropertyDescriptor(comp, "state");
2630
2644
  if (desc) {
2631
2645
  if (typeof desc.get !== "function" && typeof desc.set !== "function") {
@@ -2644,22 +2658,23 @@ function constructFunc(core, parent) {
2644
2658
  });
2645
2659
  }
2646
2660
  }
2647
- } else if (typeof core.entity === "function") {
2648
- if ((_b = core.entity) == null ? void 0 : _b.defaultProps) {
2649
- core.props = { ...core.entity.defaultProps, ...core.props };
2661
+ } else if (typeof entity === "function") {
2662
+ if (entity == null ? void 0 : entity.defaultProps) {
2663
+ core.props = { ...entity.defaultProps, ...core.props };
2650
2664
  }
2651
2665
  comp = new Component(core.props);
2652
- comp.render = core.entity.bind(comp);
2666
+ comp.render = entity.bind(comp);
2653
2667
  comp[CORE].hooks = [];
2654
2668
  comp[CORE].hook_index = 0;
2655
2669
  } else {
2656
- throw new Error("Invalid entity for createComponent.");
2670
+ throw new Error("Error in constructing component.");
2657
2671
  }
2658
- comp[CORE].entity = core.entity;
2672
+ comp[CORE].entity = entity;
2659
2673
  if (core.container) {
2660
2674
  comp[CORE].container = core.container;
2661
2675
  }
2662
2676
  }
2677
+ if (memoized) comp[CORE][MEMOIZED] = true;
2663
2678
  }
2664
2679
  if (parent instanceof ComponentCore) comp[CORE].parent = parent;
2665
2680
  return comp;
@@ -2680,16 +2695,26 @@ function prepareCore(parent, core) {
2680
2695
  }
2681
2696
  }
2682
2697
  function doUpdates() {
2698
+ clearTimeout(lilact_default.effect_timeout);
2699
+ const _update_set = lilact_default.update_set;
2700
+ const _update_cbs = lilact_default.update_cbs;
2701
+ lilact_default.update_set = /* @__PURE__ */ new Set();
2702
+ lilact_default.update_cbs = /* @__PURE__ */ new Set();
2703
+ for (const u of _update_set) u.apply();
2704
+ for (const cb of _update_cbs) cb();
2705
+ processEffects();
2706
+ }
2707
+ function processEffects() {
2708
+ const _insertion_effects = lilact_default.insertion_effects;
2709
+ const _layout_effects = lilact_default.layout_effects;
2710
+ const _passive_effects = lilact_default.passive_effects;
2711
+ lilact_default.insertion_effects = /* @__PURE__ */ new Set();
2712
+ lilact_default.layout_effects = /* @__PURE__ */ new Set();
2713
+ lilact_default.passive_effects = /* @__PURE__ */ new Set();
2714
+ for (const ie of _insertion_effects) ie();
2715
+ for (const le of _layout_effects) le();
2683
2716
  requestAnimationFrame(() => {
2684
- let _layout_effects = lilact_default.layout_effects;
2685
- let _update_cbs = lilact_default.update_cbs;
2686
- let _update_set = lilact_default.update_set;
2687
- lilact_default.layout_effects = /* @__PURE__ */ new Set();
2688
- lilact_default.update_cbs = /* @__PURE__ */ new Set();
2689
- lilact_default.update_set = /* @__PURE__ */ new Set();
2690
- for (const le of _layout_effects) le();
2691
- for (const u of _update_set) u.apply();
2692
- for (const cb of _update_cbs) cb();
2717
+ for (const pe of _passive_effects) pe();
2693
2718
  });
2694
2719
  }
2695
2720
  var generateComponentKey = (entity, props) => {
@@ -2885,8 +2910,10 @@ var RootComponent = class extends HTMLComponent {
2885
2910
  }
2886
2911
  };
2887
2912
  function createComponent2(entity, props = {}, ...children) {
2888
- if (entity !== void 0 && typeof entity !== "string" && typeof entity !== "function") {
2889
- throw new Error("Invalid entity for createComponent.");
2913
+ if (typeof entity !== "string" && typeof entity !== "function") {
2914
+ if (typeof entity !== "object" || !entity[MEMOIZED]) {
2915
+ throw new Error("Invalid entity for createComponent.");
2916
+ }
2890
2917
  }
2891
2918
  for (let i2 = 0; i2 < children.length; i2++) {
2892
2919
  let ch2 = children[i2];
@@ -2935,12 +2962,20 @@ function render(component, element) {
2935
2962
  }
2936
2963
  return createRoot(element).render(component);
2937
2964
  }
2965
+ function memo(component) {
2966
+ return { [MEMOIZED]: component };
2967
+ }
2938
2968
  var createElement = createComponent2;
2939
2969
  var current_component = [];
2940
2970
  var update_set = /* @__PURE__ */ new Set();
2941
2971
  var update_cbs = /* @__PURE__ */ new Set();
2942
2972
  var roots = /* @__PURE__ */ new Set();
2943
2973
  var layout_effects = /* @__PURE__ */ new Set();
2974
+ var insertion_effects = /* @__PURE__ */ new Set();
2975
+ var passive_effects = /* @__PURE__ */ new Set();
2976
+ var update_timeout = void 0;
2977
+ var effect_timeout = void 0;
2978
+ var update_interval_margin = 0;
2944
2979
  var special_attributes = /* @__PURE__ */ new Set([
2945
2980
  "classname",
2946
2981
  "ref",
@@ -3097,14 +3132,17 @@ var boolean_html_attributes_set = /* @__PURE__ */ new Set([
3097
3132
  var hooks_exports = {};
3098
3133
  __export(hooks_exports, {
3099
3134
  createContext: () => createContext,
3135
+ startTransition: () => startTransition,
3100
3136
  useActionState: () => useActionState,
3101
3137
  useCallback: () => useCallback,
3102
3138
  useContext: () => useContext,
3139
+ useDebugValue: () => useDebugValue,
3103
3140
  useDeferredValue: () => useDeferredValue,
3104
3141
  useEffect: () => useEffect,
3105
3142
  useHook: () => useHook,
3106
3143
  useId: () => useId,
3107
3144
  useImperativeHandle: () => useImperativeHandle,
3145
+ useInsertionEffect: () => useInsertionEffect,
3108
3146
  useLayoutEffect: () => useLayoutEffect,
3109
3147
  useLocalStorage: () => useLocalStorage,
3110
3148
  useMemo: () => useMemo,
@@ -3183,10 +3221,10 @@ function useTransition() {
3183
3221
  if (isEmpty(hk)) {
3184
3222
  hk.count = 0;
3185
3223
  hk.func = (async function(core, hk2, fn) {
3186
- hk2.count++;
3187
- if (hk2.count === 1) {
3224
+ if (hk2.count === 0) {
3188
3225
  core.component.forceUpdate();
3189
3226
  }
3227
+ hk2.count++;
3190
3228
  await fn();
3191
3229
  hk2.count--;
3192
3230
  if (hk2.count === 0) {
@@ -3229,7 +3267,7 @@ function useRef(initialValue = null) {
3229
3267
  }
3230
3268
  function useLayoutEffect(effect, deps = void 0) {
3231
3269
  if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3232
- throw new Error("Layout effect dependencies must be an array or omitted.");
3270
+ throw new Error("Layout effect dependencies must be an array, object or omitted.");
3233
3271
  }
3234
3272
  const hk = useHook();
3235
3273
  if (!isEmpty(hk)) {
@@ -3242,11 +3280,12 @@ function useLayoutEffect(effect, deps = void 0) {
3242
3280
  lilact_default.layout_effects.add(() => {
3243
3281
  hk.cleanup = effect();
3244
3282
  });
3245
- lilact_default.current_component[0].component.forceUpdate();
3283
+ lilact_default.clearTimeout(lilact_default.effect_timeout);
3284
+ lilact_default.setTimeout(lilact_default.processEffects, 0);
3246
3285
  }
3247
3286
  function useEffect(effect, deps = void 0) {
3248
3287
  if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3249
- throw new Error("Effect dependencies must be an array or omitted.");
3288
+ throw new Error("Effect dependencies must be an array, object or omitted.");
3250
3289
  }
3251
3290
  const hk = useHook();
3252
3291
  if (!isEmpty(hk)) {
@@ -3256,9 +3295,29 @@ function useEffect(effect, deps = void 0) {
3256
3295
  hk.cleanup();
3257
3296
  }
3258
3297
  hk.deps = deps;
3259
- lilact_default.setTimeout(() => {
3298
+ lilact_default.passive_effects.add(() => {
3260
3299
  hk.cleanup = effect();
3261
- }, 0);
3300
+ });
3301
+ lilact_default.clearTimeout(lilact_default.effect_timeout);
3302
+ lilact_default.setTimeout(lilact_default.processEffects, 0);
3303
+ }
3304
+ function useInsertionEffect(effect, deps = void 0) {
3305
+ if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3306
+ throw new Error("Insertion effect dependencies must be an array, object, or omitted.");
3307
+ }
3308
+ const hk = useHook();
3309
+ if (!isEmpty(hk)) {
3310
+ if (deps !== void 0 && (hk == null ? void 0 : hk.deps) !== void 0 && shallowEqual(deps, hk.deps)) return;
3311
+ }
3312
+ if (hk == null ? void 0 : hk.cleanup) {
3313
+ hk.cleanup();
3314
+ }
3315
+ hk.deps = deps;
3316
+ lilact_default.insertion_effects.add(() => {
3317
+ hk.cleanup = effect();
3318
+ });
3319
+ lilact_default.clearTimeout(lilact_default.effect_timeout);
3320
+ lilact_default.setTimeout(lilact_default.processEffects, 0);
3262
3321
  }
3263
3322
  function useMemo(factory, deps = void 0) {
3264
3323
  if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
@@ -3346,6 +3405,14 @@ function useImperativeHandle(ref, factory, deps = void 0) {
3346
3405
  }
3347
3406
  Object.assign(ref.current, factory(), 0);
3348
3407
  }
3408
+ function useDebugValue(val, formatter = (x) => x) {
3409
+ if (true) {
3410
+ console.log(formatter(val));
3411
+ }
3412
+ }
3413
+ function startTransition(transition) {
3414
+ transition();
3415
+ }
3349
3416
 
3350
3417
  // .tmp/src/run.jsx
3351
3418
  var run_exports = {};
@@ -3494,7 +3561,7 @@ var timers_exports = {};
3494
3561
  __export(timers_exports, {
3495
3562
  animationFramePromise: () => animationFramePromise,
3496
3563
  clearInterval: () => clearInterval,
3497
- clearTimeout: () => clearTimeout,
3564
+ clearTimeout: () => clearTimeout2,
3498
3565
  grabTimers: () => grabTimers,
3499
3566
  pauseTimers: () => pauseTimers,
3500
3567
  releaseTimers: () => releaseTimers,
@@ -3603,7 +3670,7 @@ function setTimeout2(callback, delay, ...args) {
3603
3670
  function setInterval(callback, interval, ...args) {
3604
3671
  return add_timer({ [CALLBACK]: callback, [INTERVAL]: interval, [DUE]: Date.now() + interval, [REPEAT]: true, [ARGS]: args });
3605
3672
  }
3606
- function clearTimeout(id) {
3673
+ function clearTimeout2(id) {
3607
3674
  if (all_timers[id]) all_timers[id][CLEARED] = true;
3608
3675
  }
3609
3676
  function clearInterval(id) {
@@ -3686,14 +3753,14 @@ function Transition({
3686
3753
  } else this[CORE].mount_state = EXITED;
3687
3754
  }
3688
3755
  useEffect(() => {
3689
- return () => clearTimeout(this[CORE].timer);
3756
+ return () => clearTimeout2(this[CORE].timer);
3690
3757
  }, []);
3691
3758
  useEffect(() => {
3692
3759
  if (!this[CORE].is_appeared && appear && this[CORE].mount_state === ENTERING && inProp) {
3693
3760
  onEnter == null ? void 0 : onEnter();
3694
3761
  requestAnimationFrame(() => {
3695
3762
  onEntering == null ? void 0 : onEntering(!this[CORE].is_appeared);
3696
- clearTimeout(this[CORE].timer);
3763
+ clearTimeout2(this[CORE].timer);
3697
3764
  this[CORE].timer = setTimeout2(() => {
3698
3765
  this[CORE].mount_state = ENTERED;
3699
3766
  this.forceUpdate();
@@ -3711,7 +3778,7 @@ function Transition({
3711
3778
  this[CORE].mount_state = ENTERING;
3712
3779
  this.forceUpdate(() => {
3713
3780
  onEntering == null ? void 0 : onEntering(!this[CORE].is_appeared);
3714
- clearTimeout(this[CORE].timer);
3781
+ clearTimeout2(this[CORE].timer);
3715
3782
  this[CORE].timer = setTimeout2(() => {
3716
3783
  this[CORE].mount_state = ENTERED;
3717
3784
  this.forceUpdate();
@@ -3725,7 +3792,7 @@ function Transition({
3725
3792
  this[CORE].mount_state = EXITING;
3726
3793
  this.forceUpdate(() => {
3727
3794
  onExiting == null ? void 0 : onExiting();
3728
- clearTimeout(this[CORE].timer);
3795
+ clearTimeout2(this[CORE].timer);
3729
3796
  this[CORE].timer = setTimeout2(() => {
3730
3797
  this[CORE].mount_state = EXITED;
3731
3798
  this.forceUpdate();
@@ -4578,11 +4645,11 @@ var Suspense = class extends Component {
4578
4645
  /** @ignore */
4579
4646
  _clearTimers() {
4580
4647
  if (this._delayTimer) {
4581
- clearTimeout(this._delayTimer);
4648
+ clearTimeout2(this._delayTimer);
4582
4649
  this._delayTimer = null;
4583
4650
  }
4584
4651
  if (this._minShowTimer) {
4585
- clearTimeout(this._minShowTimer);
4652
+ clearTimeout2(this._minShowTimer);
4586
4653
  this._minShowTimer = null;
4587
4654
  }
4588
4655
  }
@@ -4593,7 +4660,7 @@ var Suspense = class extends Component {
4593
4660
  if (this._pending.size === 1) {
4594
4661
  const delay = Math.max(0, this.props.minDelay);
4595
4662
  if (this._delayTimer) {
4596
- clearTimeout(this._delayTimer);
4663
+ clearTimeout2(this._delayTimer);
4597
4664
  this._delayTimer = null;
4598
4665
  }
4599
4666
  this._delayTimer = setTimeout2(() => {
@@ -4608,7 +4675,7 @@ var Suspense = class extends Component {
4608
4675
  }
4609
4676
  if (this._pending.size === 0) {
4610
4677
  if (this._delayTimer) {
4611
- clearTimeout(this._delayTimer);
4678
+ clearTimeout2(this._delayTimer);
4612
4679
  this._delayTimer = null;
4613
4680
  this.setState({ showingFallback: false });
4614
4681
  return;
@@ -4619,7 +4686,7 @@ var Suspense = class extends Component {
4619
4686
  this.setState({ showingFallback: false });
4620
4687
  } else {
4621
4688
  if (this._minShowTimer) {
4622
- clearTimeout(this._minShowTimer);
4689
+ clearTimeout2(this._minShowTimer);
4623
4690
  this._minShowTimer = null;
4624
4691
  }
4625
4692
  this._minShowTimer = setTimeout2(() => {
@@ -5760,7 +5827,7 @@ function transpileJSX(jsx2, {
5760
5827
 
5761
5828
  // .tmp/src/lilact.jsx
5762
5829
  var Lilact2 = {
5763
- VERSION: "beta.16",
5830
+ VERSION: "beta.18",
5764
5831
  // Configuration
5765
5832
  defaultTransitionTimeout: 300,
5766
5833
  defaultIsEqual: Object.is,
@@ -5829,7 +5896,7 @@ export {
5829
5896
  boolean_html_attributes_set,
5830
5897
  capture_events_set,
5831
5898
  clearInterval,
5832
- clearTimeout,
5899
+ clearTimeout2 as clearTimeout,
5833
5900
  combineReducers2 as combineReducers,
5834
5901
  connect,
5835
5902
  createComponent2 as createComponent,
@@ -5840,6 +5907,7 @@ export {
5840
5907
  current_component,
5841
5908
  deepEqual,
5842
5909
  lilact_default as default,
5910
+ effect_timeout,
5843
5911
  emotion_css_esm_exports as emotion,
5844
5912
  error,
5845
5913
  eval_num,
@@ -5850,16 +5918,21 @@ export {
5850
5918
  globalErrorHandler,
5851
5919
  grabTimers,
5852
5920
  id_num,
5921
+ insertion_effects,
5853
5922
  isAsync,
5854
5923
  isClass,
5855
5924
  isEmpty,
5856
5925
  isError2 as isError,
5857
5926
  isThenable,
5927
+ isValidComponent,
5858
5928
  isValidElement,
5859
5929
  layout_effects,
5860
5930
  lazy,
5861
5931
  length_css_attributes_set,
5932
+ memo,
5933
+ passive_effects,
5862
5934
  pauseTimers,
5935
+ processEffects,
5863
5936
  redux_exports as redux,
5864
5937
  releaseSyntheticEvent,
5865
5938
  releaseTimers,
@@ -5876,6 +5949,7 @@ export {
5876
5949
  setTimeout2 as setTimeout,
5877
5950
  shallowEqual,
5878
5951
  special_attributes,
5952
+ startTransition,
5879
5953
  timeoutPromise,
5880
5954
  toBool,
5881
5955
  traceError,
@@ -5888,12 +5962,14 @@ export {
5888
5962
  useActionState,
5889
5963
  useCallback,
5890
5964
  useContext,
5965
+ useDebugValue,
5891
5966
  useDeferredValue,
5892
5967
  useDispatch,
5893
5968
  useEffect,
5894
5969
  useHook,
5895
5970
  useId,
5896
5971
  useImperativeHandle,
5972
+ useInsertionEffect,
5897
5973
  useLayoutEffect,
5898
5974
  useLocalStorage,
5899
5975
  useLocation,