lilact 0.16.3 → 0.17.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 (66) hide show
  1. package/dist/lilact.development.js +101 -38
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +16 -16
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +18 -18
  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.render.html +1 -1
  17. package/docs/functions/hooks.startTransition.html +6 -0
  18. package/docs/functions/hooks.useActionState.html +1 -1
  19. package/docs/functions/hooks.useDebugValue.html +5 -0
  20. package/docs/functions/hooks.useDeferredValue.html +1 -1
  21. package/docs/functions/hooks.useEffect.html +4 -4
  22. package/docs/functions/hooks.useImperativeHandle.html +1 -1
  23. package/docs/functions/hooks.useInsertionEffect.html +5 -0
  24. package/docs/functions/hooks.useLayoutEffect.html +2 -2
  25. package/docs/functions/hooks.useMemo.html +3 -3
  26. package/docs/functions/hooks.useReducer.html +1 -1
  27. package/docs/functions/misc.Fragment.html +2 -2
  28. package/docs/functions/misc.deepEqual.html +1 -1
  29. package/docs/functions/misc.findDOMNode.html +1 -1
  30. package/docs/functions/misc.forwardRef.html +1 -1
  31. package/docs/functions/misc.getComponentByPointer.html +1 -1
  32. package/docs/functions/misc.isAsync.html +1 -1
  33. package/docs/functions/misc.isClass.html +1 -1
  34. package/docs/functions/misc.isEmpty.html +1 -1
  35. package/docs/functions/misc.isError.html +1 -1
  36. package/docs/functions/misc.isThenable.html +1 -1
  37. package/docs/functions/{misc.isValidElement.html → misc.isValidComponent.html} +1 -1
  38. package/docs/functions/misc.shallowEqual.html +1 -1
  39. package/docs/functions/misc.toBool.html +1 -1
  40. package/docs/functions/timers.timeoutPromise.html +9 -6
  41. package/docs/hierarchy.html +1 -1
  42. package/docs/modules/hooks.html +1 -1
  43. package/docs/modules/misc.html +1 -1
  44. package/docs/static/demos/actionstate.jsx +2 -2
  45. package/docs/static/demos/priorities.jsx +68 -0
  46. package/docs/static/index.html +1 -0
  47. package/docs/static/lilact.development.js +101 -38
  48. package/docs/static/lilact.development.js.map +3 -3
  49. package/docs/static/lilact.development.min.js +16 -16
  50. package/docs/static/lilact.development.min.js.map +3 -3
  51. package/docs/static/lilact.production.min.js +18 -18
  52. package/docs/variables/misc.Children.html +2 -2
  53. package/docs/variables/misc.isValidElement.html +7 -0
  54. package/examples/demos/actionstate.jsx +2 -2
  55. package/examples/demos/priorities.jsx +68 -0
  56. package/examples/index.html +1 -0
  57. package/examples/lilact.development.js +101 -38
  58. package/examples/lilact.development.js.map +3 -3
  59. package/examples/lilact.development.min.js +16 -16
  60. package/examples/lilact.development.min.js.map +3 -3
  61. package/examples/lilact.production.min.js +18 -18
  62. package/package.json +1 -1
  63. package/src/components.jsx +68 -13
  64. package/src/hooks.jsx +80 -11
  65. package/src/lilact.jsx +1 -1
  66. package/src/misc.jsx +9 -5
@@ -1977,14 +1977,20 @@ __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
+ passive_effects: () => passive_effects,
1986
+ processEffects: () => processEffects,
1983
1987
  render: () => render,
1984
1988
  roots: () => roots,
1985
1989
  special_attributes: () => special_attributes,
1986
1990
  update_cbs: () => update_cbs,
1987
- update_set: () => update_set
1991
+ update_interval_margin: () => update_interval_margin,
1992
+ update_set: () => update_set,
1993
+ update_timeout: () => update_timeout
1988
1994
  });
1989
1995
 
1990
1996
  // .tmp/src/symbols.jsx
@@ -2036,11 +2042,10 @@ __export(misc_exports, {
2036
2042
  isEmpty: () => isEmpty,
2037
2043
  isError: () => isError2,
2038
2044
  isThenable: () => isThenable,
2045
+ isValidComponent: () => isValidComponent,
2039
2046
  isValidElement: () => isValidElement,
2040
2047
  shallowEqual: () => shallowEqual,
2041
- toBool: () => toBool,
2042
- update_interval_margin: () => update_interval_margin,
2043
- update_timeout: () => update_timeout
2048
+ toBool: () => toBool
2044
2049
  });
2045
2050
  var typeOf = (input) => {
2046
2051
  const rawObject = Object.prototype.toString.call(input).toLowerCase();
@@ -2048,9 +2053,10 @@ var typeOf = (input) => {
2048
2053
  const type = typeOfRegex.exec(rawObject)[1];
2049
2054
  return type;
2050
2055
  };
2051
- var isValidElement = (value) => {
2056
+ var isValidComponent = (value) => {
2052
2057
  return value[CORE] !== void 0 || value[TEXT] !== void 0;
2053
2058
  };
2059
+ var isValidElement = isValidComponent;
2054
2060
  var findDOMNode = (component) => {
2055
2061
  var _a, _b;
2056
2062
  if (!((_b = (_a = component[CORE]) == null ? void 0 : _a.element) == null ? void 0 : _b.parentNode)) throw new Error("findDOMNode only works on mounted components.");
@@ -2193,8 +2199,6 @@ function toBool(value) {
2193
2199
  }
2194
2200
  return Boolean(value);
2195
2201
  }
2196
- var update_timeout = void 0;
2197
- var update_interval_margin = 0;
2198
2202
  var id_num = Math.floor(Math.random() * 1e4);
2199
2203
  var eval_num = 0;
2200
2204
 
@@ -2239,7 +2243,11 @@ var ComponentCache = class {
2239
2243
  commit() {
2240
2244
  this.current_map.forEach((arr) => {
2241
2245
  arr.slice(arr[IDX]).forEach((ex) => {
2242
- if (ex.cleanup) ex.cleanup();
2246
+ if (ex.cleanup) {
2247
+ ex.cleanup();
2248
+ } else if (ex.element) {
2249
+ ex.element.parentElement.removeChild(ex.element);
2250
+ }
2243
2251
  });
2244
2252
  });
2245
2253
  this.current_map = this.new_map;
@@ -2680,16 +2688,26 @@ function prepareCore(parent, core) {
2680
2688
  }
2681
2689
  }
2682
2690
  function doUpdates() {
2691
+ clearTimeout(lilact_default.effect_timeout);
2692
+ const _update_set = lilact_default.update_set;
2693
+ const _update_cbs = lilact_default.update_cbs;
2694
+ lilact_default.update_set = /* @__PURE__ */ new Set();
2695
+ lilact_default.update_cbs = /* @__PURE__ */ new Set();
2696
+ for (const u of _update_set) u.apply();
2697
+ for (const cb of _update_cbs) cb();
2698
+ processEffects();
2699
+ }
2700
+ function processEffects() {
2701
+ const _insertion_effects = lilact_default.insertion_effects;
2702
+ const _layout_effects = lilact_default.layout_effects;
2703
+ const _passive_effects = lilact_default.passive_effects;
2704
+ lilact_default.insertion_effects = /* @__PURE__ */ new Set();
2705
+ lilact_default.layout_effects = /* @__PURE__ */ new Set();
2706
+ lilact_default.passive_effects = /* @__PURE__ */ new Set();
2707
+ for (const ie of _insertion_effects) ie();
2708
+ for (const le of _layout_effects) le();
2683
2709
  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();
2710
+ for (const pe of _passive_effects) pe();
2693
2711
  });
2694
2712
  }
2695
2713
  var generateComponentKey = (entity, props) => {
@@ -2885,7 +2903,7 @@ var RootComponent = class extends HTMLComponent {
2885
2903
  }
2886
2904
  };
2887
2905
  function createComponent2(entity, props = {}, ...children) {
2888
- if (entity !== void 0 && typeof entity !== "string" && typeof entity !== "function") {
2906
+ if (typeof entity !== "string" && typeof entity !== "function") {
2889
2907
  throw new Error("Invalid entity for createComponent.");
2890
2908
  }
2891
2909
  for (let i2 = 0; i2 < children.length; i2++) {
@@ -2941,6 +2959,11 @@ var update_set = /* @__PURE__ */ new Set();
2941
2959
  var update_cbs = /* @__PURE__ */ new Set();
2942
2960
  var roots = /* @__PURE__ */ new Set();
2943
2961
  var layout_effects = /* @__PURE__ */ new Set();
2962
+ var insertion_effects = /* @__PURE__ */ new Set();
2963
+ var passive_effects = /* @__PURE__ */ new Set();
2964
+ var update_timeout = void 0;
2965
+ var effect_timeout = void 0;
2966
+ var update_interval_margin = 0;
2944
2967
  var special_attributes = /* @__PURE__ */ new Set([
2945
2968
  "classname",
2946
2969
  "ref",
@@ -3097,14 +3120,17 @@ var boolean_html_attributes_set = /* @__PURE__ */ new Set([
3097
3120
  var hooks_exports = {};
3098
3121
  __export(hooks_exports, {
3099
3122
  createContext: () => createContext,
3123
+ startTransition: () => startTransition,
3100
3124
  useActionState: () => useActionState,
3101
3125
  useCallback: () => useCallback,
3102
3126
  useContext: () => useContext,
3127
+ useDebugValue: () => useDebugValue,
3103
3128
  useDeferredValue: () => useDeferredValue,
3104
3129
  useEffect: () => useEffect,
3105
3130
  useHook: () => useHook,
3106
3131
  useId: () => useId,
3107
3132
  useImperativeHandle: () => useImperativeHandle,
3133
+ useInsertionEffect: () => useInsertionEffect,
3108
3134
  useLayoutEffect: () => useLayoutEffect,
3109
3135
  useLocalStorage: () => useLocalStorage,
3110
3136
  useMemo: () => useMemo,
@@ -3183,10 +3209,10 @@ function useTransition() {
3183
3209
  if (isEmpty(hk)) {
3184
3210
  hk.count = 0;
3185
3211
  hk.func = (async function(core, hk2, fn) {
3186
- hk2.count++;
3187
- if (hk2.count === 1) {
3212
+ if (hk2.count === 0) {
3188
3213
  core.component.forceUpdate();
3189
3214
  }
3215
+ hk2.count++;
3190
3216
  await fn();
3191
3217
  hk2.count--;
3192
3218
  if (hk2.count === 0) {
@@ -3229,7 +3255,7 @@ function useRef(initialValue = null) {
3229
3255
  }
3230
3256
  function useLayoutEffect(effect, deps = void 0) {
3231
3257
  if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3232
- throw new Error("Layout effect dependencies must be an array or omitted.");
3258
+ throw new Error("Layout effect dependencies must be an array, object or omitted.");
3233
3259
  }
3234
3260
  const hk = useHook();
3235
3261
  if (!isEmpty(hk)) {
@@ -3242,11 +3268,30 @@ function useLayoutEffect(effect, deps = void 0) {
3242
3268
  lilact_default.layout_effects.add(() => {
3243
3269
  hk.cleanup = effect();
3244
3270
  });
3245
- lilact_default.current_component[0].component.forceUpdate();
3271
+ lilact_default.clearTimeout(lilact_default.effect_timeout);
3272
+ lilact_default.setTimeout(lilact_default.processEffects, 0);
3246
3273
  }
3247
3274
  function useEffect(effect, deps = void 0) {
3248
3275
  if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3249
- throw new Error("Effect dependencies must be an array or omitted.");
3276
+ throw new Error("Effect dependencies must be an array, object or omitted.");
3277
+ }
3278
+ const hk = useHook();
3279
+ if (!isEmpty(hk)) {
3280
+ if (deps !== void 0 && (hk == null ? void 0 : hk.deps) !== void 0 && shallowEqual(deps, hk.deps)) return;
3281
+ }
3282
+ if (hk == null ? void 0 : hk.cleanup) {
3283
+ hk.cleanup();
3284
+ }
3285
+ hk.deps = deps;
3286
+ lilact_default.passive_effects.add(() => {
3287
+ hk.cleanup = effect();
3288
+ });
3289
+ lilact_default.clearTimeout(lilact_default.effect_timeout);
3290
+ lilact_default.setTimeout(lilact_default.processEffects, 0);
3291
+ }
3292
+ function useInsertionEffect(effect, deps = void 0) {
3293
+ if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3294
+ throw new Error("Insertion effect dependencies must be an array, object, or omitted.");
3250
3295
  }
3251
3296
  const hk = useHook();
3252
3297
  if (!isEmpty(hk)) {
@@ -3256,9 +3301,11 @@ function useEffect(effect, deps = void 0) {
3256
3301
  hk.cleanup();
3257
3302
  }
3258
3303
  hk.deps = deps;
3259
- lilact_default.setTimeout(() => {
3304
+ lilact_default.insertion_effects.add(() => {
3260
3305
  hk.cleanup = effect();
3261
- }, 0);
3306
+ });
3307
+ lilact_default.clearTimeout(lilact_default.effect_timeout);
3308
+ lilact_default.setTimeout(lilact_default.processEffects, 0);
3262
3309
  }
3263
3310
  function useMemo(factory, deps = void 0) {
3264
3311
  if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
@@ -3346,6 +3393,14 @@ function useImperativeHandle(ref, factory, deps = void 0) {
3346
3393
  }
3347
3394
  Object.assign(ref.current, factory(), 0);
3348
3395
  }
3396
+ function useDebugValue(val, formatter = (x) => x) {
3397
+ if (true) {
3398
+ console.log(formatter(val));
3399
+ }
3400
+ }
3401
+ function startTransition(transition) {
3402
+ transition();
3403
+ }
3349
3404
 
3350
3405
  // .tmp/src/run.jsx
3351
3406
  var run_exports = {};
@@ -3494,7 +3549,7 @@ var timers_exports = {};
3494
3549
  __export(timers_exports, {
3495
3550
  animationFramePromise: () => animationFramePromise,
3496
3551
  clearInterval: () => clearInterval,
3497
- clearTimeout: () => clearTimeout,
3552
+ clearTimeout: () => clearTimeout2,
3498
3553
  grabTimers: () => grabTimers,
3499
3554
  pauseTimers: () => pauseTimers,
3500
3555
  releaseTimers: () => releaseTimers,
@@ -3603,7 +3658,7 @@ function setTimeout2(callback, delay, ...args) {
3603
3658
  function setInterval(callback, interval, ...args) {
3604
3659
  return add_timer({ [CALLBACK]: callback, [INTERVAL]: interval, [DUE]: Date.now() + interval, [REPEAT]: true, [ARGS]: args });
3605
3660
  }
3606
- function clearTimeout(id) {
3661
+ function clearTimeout2(id) {
3607
3662
  if (all_timers[id]) all_timers[id][CLEARED] = true;
3608
3663
  }
3609
3664
  function clearInterval(id) {
@@ -3686,14 +3741,14 @@ function Transition({
3686
3741
  } else this[CORE].mount_state = EXITED;
3687
3742
  }
3688
3743
  useEffect(() => {
3689
- return () => clearTimeout(this[CORE].timer);
3744
+ return () => clearTimeout2(this[CORE].timer);
3690
3745
  }, []);
3691
3746
  useEffect(() => {
3692
3747
  if (!this[CORE].is_appeared && appear && this[CORE].mount_state === ENTERING && inProp) {
3693
3748
  onEnter == null ? void 0 : onEnter();
3694
3749
  requestAnimationFrame(() => {
3695
3750
  onEntering == null ? void 0 : onEntering(!this[CORE].is_appeared);
3696
- clearTimeout(this[CORE].timer);
3751
+ clearTimeout2(this[CORE].timer);
3697
3752
  this[CORE].timer = setTimeout2(() => {
3698
3753
  this[CORE].mount_state = ENTERED;
3699
3754
  this.forceUpdate();
@@ -3711,7 +3766,7 @@ function Transition({
3711
3766
  this[CORE].mount_state = ENTERING;
3712
3767
  this.forceUpdate(() => {
3713
3768
  onEntering == null ? void 0 : onEntering(!this[CORE].is_appeared);
3714
- clearTimeout(this[CORE].timer);
3769
+ clearTimeout2(this[CORE].timer);
3715
3770
  this[CORE].timer = setTimeout2(() => {
3716
3771
  this[CORE].mount_state = ENTERED;
3717
3772
  this.forceUpdate();
@@ -3725,7 +3780,7 @@ function Transition({
3725
3780
  this[CORE].mount_state = EXITING;
3726
3781
  this.forceUpdate(() => {
3727
3782
  onExiting == null ? void 0 : onExiting();
3728
- clearTimeout(this[CORE].timer);
3783
+ clearTimeout2(this[CORE].timer);
3729
3784
  this[CORE].timer = setTimeout2(() => {
3730
3785
  this[CORE].mount_state = EXITED;
3731
3786
  this.forceUpdate();
@@ -4578,11 +4633,11 @@ var Suspense = class extends Component {
4578
4633
  /** @ignore */
4579
4634
  _clearTimers() {
4580
4635
  if (this._delayTimer) {
4581
- clearTimeout(this._delayTimer);
4636
+ clearTimeout2(this._delayTimer);
4582
4637
  this._delayTimer = null;
4583
4638
  }
4584
4639
  if (this._minShowTimer) {
4585
- clearTimeout(this._minShowTimer);
4640
+ clearTimeout2(this._minShowTimer);
4586
4641
  this._minShowTimer = null;
4587
4642
  }
4588
4643
  }
@@ -4593,7 +4648,7 @@ var Suspense = class extends Component {
4593
4648
  if (this._pending.size === 1) {
4594
4649
  const delay = Math.max(0, this.props.minDelay);
4595
4650
  if (this._delayTimer) {
4596
- clearTimeout(this._delayTimer);
4651
+ clearTimeout2(this._delayTimer);
4597
4652
  this._delayTimer = null;
4598
4653
  }
4599
4654
  this._delayTimer = setTimeout2(() => {
@@ -4608,7 +4663,7 @@ var Suspense = class extends Component {
4608
4663
  }
4609
4664
  if (this._pending.size === 0) {
4610
4665
  if (this._delayTimer) {
4611
- clearTimeout(this._delayTimer);
4666
+ clearTimeout2(this._delayTimer);
4612
4667
  this._delayTimer = null;
4613
4668
  this.setState({ showingFallback: false });
4614
4669
  return;
@@ -4619,7 +4674,7 @@ var Suspense = class extends Component {
4619
4674
  this.setState({ showingFallback: false });
4620
4675
  } else {
4621
4676
  if (this._minShowTimer) {
4622
- clearTimeout(this._minShowTimer);
4677
+ clearTimeout2(this._minShowTimer);
4623
4678
  this._minShowTimer = null;
4624
4679
  }
4625
4680
  this._minShowTimer = setTimeout2(() => {
@@ -5760,7 +5815,7 @@ function transpileJSX(jsx2, {
5760
5815
 
5761
5816
  // .tmp/src/lilact.jsx
5762
5817
  var Lilact2 = {
5763
- VERSION: "beta.16",
5818
+ VERSION: "beta.17",
5764
5819
  // Configuration
5765
5820
  defaultTransitionTimeout: 300,
5766
5821
  defaultIsEqual: Object.is,
@@ -5829,7 +5884,7 @@ export {
5829
5884
  boolean_html_attributes_set,
5830
5885
  capture_events_set,
5831
5886
  clearInterval,
5832
- clearTimeout,
5887
+ clearTimeout2 as clearTimeout,
5833
5888
  combineReducers2 as combineReducers,
5834
5889
  connect,
5835
5890
  createComponent2 as createComponent,
@@ -5840,6 +5895,7 @@ export {
5840
5895
  current_component,
5841
5896
  deepEqual,
5842
5897
  lilact_default as default,
5898
+ effect_timeout,
5843
5899
  emotion_css_esm_exports as emotion,
5844
5900
  error,
5845
5901
  eval_num,
@@ -5850,16 +5906,20 @@ export {
5850
5906
  globalErrorHandler,
5851
5907
  grabTimers,
5852
5908
  id_num,
5909
+ insertion_effects,
5853
5910
  isAsync,
5854
5911
  isClass,
5855
5912
  isEmpty,
5856
5913
  isError2 as isError,
5857
5914
  isThenable,
5915
+ isValidComponent,
5858
5916
  isValidElement,
5859
5917
  layout_effects,
5860
5918
  lazy,
5861
5919
  length_css_attributes_set,
5920
+ passive_effects,
5862
5921
  pauseTimers,
5922
+ processEffects,
5863
5923
  redux_exports as redux,
5864
5924
  releaseSyntheticEvent,
5865
5925
  releaseTimers,
@@ -5876,6 +5936,7 @@ export {
5876
5936
  setTimeout2 as setTimeout,
5877
5937
  shallowEqual,
5878
5938
  special_attributes,
5939
+ startTransition,
5879
5940
  timeoutPromise,
5880
5941
  toBool,
5881
5942
  traceError,
@@ -5888,12 +5949,14 @@ export {
5888
5949
  useActionState,
5889
5950
  useCallback,
5890
5951
  useContext,
5952
+ useDebugValue,
5891
5953
  useDeferredValue,
5892
5954
  useDispatch,
5893
5955
  useEffect,
5894
5956
  useHook,
5895
5957
  useId,
5896
5958
  useImperativeHandle,
5959
+ useInsertionEffect,
5897
5960
  useLayoutEffect,
5898
5961
  useLocalStorage,
5899
5962
  useLocation,