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.
- package/dist/lilact.development.js +68 -43
- package/dist/lilact.development.js.map +2 -2
- package/dist/lilact.development.min.js +23 -23
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +23 -23
- package/docs/classes/accessories.ErrorBoundary.html +8 -8
- package/docs/classes/accessories.Suspense.html +7 -7
- package/docs/classes/components.Component.html +11 -11
- package/docs/classes/components.HTMLComponent.html +11 -11
- package/docs/classes/components.RootComponent.html +11 -11
- package/docs/functions/components.cloneComponent.html +1 -1
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createPortal.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.hotReloadRoot.html +1 -1
- package/docs/functions/components.memo.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/components.replaceAllComponentInstances.html +1 -1
- package/docs/functions/components.replaceComponentEntity.html +1 -1
- package/docs/static/lilact.development.js +68 -43
- package/docs/static/lilact.development.js.map +2 -2
- package/docs/static/lilact.development.min.js +23 -23
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +23 -23
- package/docs/variables/components.cloneElement.html +1 -1
- package/examples/lilact.development.js +68 -43
- package/examples/lilact.development.js.map +2 -2
- package/examples/lilact.development.min.js +23 -23
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +23 -23
- package/package.json +1 -1
- package/src/components.jsx +104 -69
- 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 =
|
|
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 =
|
|
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]
|
|
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 (
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
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
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
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)
|
|
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.
|
|
7126
|
+
VERSION: "RC.7",
|
|
7102
7127
|
// Configuration
|
|
7103
7128
|
defaultTransitionTimeout: 300,
|
|
7104
7129
|
defaultIsEqual: Object.is,
|