lilact 0.30.1 → 0.31.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 (33) hide show
  1. package/dist/lilact.development.js +68 -43
  2. package/dist/lilact.development.js.map +2 -2
  3. package/dist/lilact.development.min.js +23 -23
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +23 -23
  6. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  7. package/docs/classes/accessories.Suspense.html +7 -7
  8. package/docs/classes/components.Component.html +11 -11
  9. package/docs/classes/components.HTMLComponent.html +11 -11
  10. package/docs/classes/components.RootComponent.html +11 -11
  11. package/docs/functions/components.cloneComponent.html +1 -1
  12. package/docs/functions/components.createComponent.html +1 -1
  13. package/docs/functions/components.createPortal.html +1 -1
  14. package/docs/functions/components.createRoot.html +1 -1
  15. package/docs/functions/components.hotReloadRoot.html +1 -1
  16. package/docs/functions/components.memo.html +1 -1
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/components.replaceAllComponentInstances.html +1 -1
  19. package/docs/functions/components.replaceComponentEntity.html +1 -1
  20. package/docs/static/lilact.development.js +68 -43
  21. package/docs/static/lilact.development.js.map +2 -2
  22. package/docs/static/lilact.development.min.js +23 -23
  23. package/docs/static/lilact.development.min.js.map +3 -3
  24. package/docs/static/lilact.production.min.js +23 -23
  25. package/docs/variables/components.cloneElement.html +1 -1
  26. package/examples/lilact.development.js +68 -43
  27. package/examples/lilact.development.js.map +2 -2
  28. package/examples/lilact.development.min.js +23 -23
  29. package/examples/lilact.development.min.js.map +3 -3
  30. package/examples/lilact.production.min.js +23 -23
  31. package/package.json +1 -1
  32. package/src/components.jsx +104 -69
  33. package/src/lilact.jsx +1 -1
@@ -2371,6 +2371,16 @@ var SVG_NS = "http://www.w3.org/2000/svg";
2371
2371
  function getComponentEntity(entity) {
2372
2372
  return entity?.[MEMOIZED] ? entity.component : entity;
2373
2373
  }
2374
+ var hotEntityAliases = /* @__PURE__ */ new Map();
2375
+ function resolveHotEntity(entity) {
2376
+ entity = getComponentEntity(entity);
2377
+ const visited = /* @__PURE__ */ new Set();
2378
+ while (typeof entity === "function" && hotEntityAliases.has(entity) && !visited.has(entity)) {
2379
+ visited.add(entity);
2380
+ entity = hotEntityAliases.get(entity);
2381
+ }
2382
+ return entity;
2383
+ }
2374
2384
  var componentInstances = /* @__PURE__ */ new Map();
2375
2385
  function registerComponentCore(core) {
2376
2386
  const entity = getComponentEntity(core.entity);
@@ -2416,7 +2426,7 @@ function replaceComponentEntity(componentCore, nextEntity) {
2416
2426
  return false;
2417
2427
  }
2418
2428
  const oldEntity = getComponentEntity(componentCore.entity);
2419
- const newEntity = getComponentEntity(nextEntity);
2429
+ const newEntity = resolveHotEntity(nextEntity);
2420
2430
  if (oldEntity === newEntity) {
2421
2431
  return true;
2422
2432
  }
@@ -2442,6 +2452,11 @@ function replaceAllComponentInstances(oldEntity, newEntity) {
2442
2452
  if (typeof oldEntity !== "function" || typeof newEntity !== "function") {
2443
2453
  return 0;
2444
2454
  }
2455
+ newEntity = resolveHotEntity(newEntity);
2456
+ if (oldEntity === newEntity) {
2457
+ return 0;
2458
+ }
2459
+ hotEntityAliases.set(oldEntity, newEntity);
2445
2460
  const instances = componentInstances.get(oldEntity);
2446
2461
  if (!instances) {
2447
2462
  return 0;
@@ -2471,7 +2486,7 @@ var ComponentCache = class {
2471
2486
  componentCore = bucket[bucket[IDX]];
2472
2487
  bucket[IDX]++;
2473
2488
  const oldEntity = getComponentEntity(componentCore.entity);
2474
- const newEntity = getComponentEntity(nextEntity);
2489
+ const newEntity = resolveHotEntity(nextEntity);
2475
2490
  const incompatible = typeof oldEntity !== typeof newEntity || typeof oldEntity === "function" && isClass(oldEntity) !== isClass(newEntity);
2476
2491
  if (incompatible) {
2477
2492
  componentCore = construct_func();
@@ -2898,8 +2913,7 @@ var renderErrorHandler = (c, e) => {
2898
2913
  };
2899
2914
  function constructFunc(core, parent) {
2900
2915
  let comp = core;
2901
- if (core[TEXT2] !== void 0) {
2902
- } else {
2916
+ if (core[TEXT2] === void 0) {
2903
2917
  let entity = core.entity;
2904
2918
  let memoized = false;
2905
2919
  if (typeof entity === "object") {
@@ -2910,52 +2924,63 @@ function constructFunc(core, parent) {
2910
2924
  throw new Error("Invalid component.");
2911
2925
  }
2912
2926
  }
2927
+ entity = resolveHotEntity(entity);
2913
2928
  if (typeof entity === "string") {
2914
2929
  comp = new HTMLComponent(entity, core.props);
2915
- } else {
2916
- if (isClass(entity)) {
2917
- if (entity?.defaultProps) {
2918
- core.props = { ...entity.defaultProps, ...core.props };
2919
- }
2920
- comp = new entity(core.props);
2921
- const desc = Object.getOwnPropertyDescriptor(comp, "state");
2922
- if (desc) {
2923
- if (typeof desc.get !== "function" && typeof desc.set !== "function") {
2924
- comp[CORE].state = comp.state;
2925
- Object.defineProperty(comp, "state", {
2926
- get() {
2927
- return this[CORE].state;
2928
- },
2929
- set(v) {
2930
- if (this[CORE].state === void 0) {
2931
- this[CORE].state = v;
2932
- } else {
2933
- throw new Error("Assigning component state this way is not allowed.");
2934
- }
2930
+ } else if (isClass(entity)) {
2931
+ if (entity?.defaultProps) {
2932
+ core.props = {
2933
+ ...entity.defaultProps,
2934
+ ...core.props
2935
+ };
2936
+ }
2937
+ comp = new entity(core.props);
2938
+ const desc = Object.getOwnPropertyDescriptor(comp, "state");
2939
+ if (desc) {
2940
+ if (typeof desc.get !== "function" && typeof desc.set !== "function") {
2941
+ comp[CORE].state = comp.state;
2942
+ Object.defineProperty(comp, "state", {
2943
+ get() {
2944
+ return this[CORE].state;
2945
+ },
2946
+ set(value) {
2947
+ if (this[CORE].state === void 0) {
2948
+ this[CORE].state = value;
2949
+ } else {
2950
+ throw new Error(
2951
+ "Assigning component state this way is not allowed."
2952
+ );
2935
2953
  }
2936
- });
2937
- }
2938
- }
2939
- } else if (typeof entity === "function") {
2940
- if (entity?.defaultProps) {
2941
- core.props = { ...entity.defaultProps, ...core.props };
2954
+ }
2955
+ });
2942
2956
  }
2943
- comp = new Component(core.props);
2944
- comp.render = entity.bind(comp);
2945
- comp[CORE].hooks = [];
2946
- comp[CORE].hook_index = 0;
2947
- } else {
2948
- throw new Error("Error in constructing component.");
2949
2957
  }
2950
- comp[CORE].entity = entity;
2951
- registerComponentCore(comp[CORE]);
2952
- if (core.container) {
2953
- comp[CORE].container = core.container;
2958
+ } else if (typeof entity === "function") {
2959
+ if (entity?.defaultProps) {
2960
+ core.props = {
2961
+ ...entity.defaultProps,
2962
+ ...core.props
2963
+ };
2954
2964
  }
2965
+ comp = new Component(core.props);
2966
+ comp.render = entity.bind(comp);
2967
+ comp[CORE].hooks = [];
2968
+ comp[CORE].hook_index = 0;
2969
+ } else {
2970
+ throw new Error("Error in constructing component.");
2971
+ }
2972
+ comp[CORE].entity = entity;
2973
+ registerComponentCore(comp[CORE]);
2974
+ if (core.container) {
2975
+ comp[CORE].container = core.container;
2955
2976
  }
2956
- if (memoized) comp[CORE][MEMOIZED] = true;
2977
+ if (memoized) {
2978
+ comp[CORE][MEMOIZED] = true;
2979
+ }
2980
+ }
2981
+ if (parent instanceof ComponentCore) {
2982
+ comp[CORE].parent = parent;
2957
2983
  }
2958
- if (parent instanceof ComponentCore) comp[CORE].parent = parent;
2959
2984
  return comp;
2960
2985
  }
2961
2986
  function prepareCore(parent, core) {
@@ -7098,7 +7123,7 @@ function transpileJSX(jsx2, {
7098
7123
 
7099
7124
  // .tmp/src/lilact.jsx
7100
7125
  var Lilact2 = {
7101
- VERSION: "RC.6",
7126
+ VERSION: "RC.7",
7102
7127
  // Configuration
7103
7128
  defaultTransitionTimeout: 300,
7104
7129
  defaultIsEqual: Object.is,