lilact 0.31.0 → 0.31.2
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 +23 -21
- package/dist/lilact.development.js.map +2 -2
- package/dist/lilact.development.min.js +22 -22
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +22 -22
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- 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.memo.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/misc.deepEqual.html +1 -1
- package/docs/functions/{misc.getComponentByPointer.html → misc.getComponentUnderPointer.html} +1 -1
- package/docs/functions/misc.isAsync.html +1 -1
- package/docs/functions/misc.isClass.html +1 -1
- package/docs/functions/misc.isEmpty.html +1 -1
- package/docs/functions/misc.isError.html +1 -1
- package/docs/functions/misc.isThenable.html +1 -1
- package/docs/functions/misc.shallowEqual.html +1 -1
- package/docs/functions/misc.toBool.html +1 -1
- package/docs/functions/run.lazy.html +1 -1
- package/docs/functions/run.runScripts.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/modules/components.html +1 -1
- package/docs/modules/misc.html +1 -1
- package/docs/static/lilact.development.js +23 -21
- package/docs/static/lilact.development.js.map +2 -2
- package/docs/static/lilact.development.min.js +22 -22
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +22 -22
- package/docs/variables/components.cloneElement.html +1 -1
- package/examples/lilact.development.js +23 -21
- package/examples/lilact.development.js.map +2 -2
- package/examples/lilact.development.min.js +22 -22
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +22 -22
- package/package.json +1 -1
- package/src/components.jsx +21 -33
- package/src/jsx.js +6 -2
- package/src/misc.jsx +24 -17
- package/src/run.jsx +1 -0
- package/src/symbols.jsx +5 -1
- package/docs/functions/components.hotReloadRoot.html +0 -1
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
import Lilact from './lilact.jsx';
|
|
32
32
|
|
|
33
|
-
import { CORE, COMPONENT, TEXT, IS_ZOMBIE, IDX, CHILD_CLASS_ADDENDUM, MEMOIZED } from "./symbols.jsx"
|
|
33
|
+
import { CORE, COMPONENT, TEXT, IS_ZOMBIE, IDX, CHILD_CLASS_ADDENDUM, MEMOIZED, LOCATION } from "./symbols.jsx"
|
|
34
34
|
import { shallowEqual, toBool, isClass, isThenable } from "./misc.jsx";
|
|
35
35
|
|
|
36
36
|
import { PropTypes } from './proptypes.jsx';
|
|
@@ -847,6 +847,9 @@ function constructFunc(core, parent) {
|
|
|
847
847
|
let entity = core.entity;
|
|
848
848
|
let memoized = false;
|
|
849
849
|
|
|
850
|
+
const loc = core.props[LOCATION];
|
|
851
|
+
if(loc) delete core.props[LOCATION];
|
|
852
|
+
|
|
850
853
|
if (typeof entity === "object") {
|
|
851
854
|
if (entity[MEMOIZED]) {
|
|
852
855
|
memoized = entity[MEMOIZED];
|
|
@@ -860,7 +863,8 @@ function constructFunc(core, parent) {
|
|
|
860
863
|
|
|
861
864
|
if (typeof entity === "string") {
|
|
862
865
|
comp = new HTMLComponent(entity, core.props);
|
|
863
|
-
}
|
|
866
|
+
}
|
|
867
|
+
else if (isClass(entity)) {
|
|
864
868
|
if (entity?.defaultProps) {
|
|
865
869
|
core.props = {
|
|
866
870
|
...entity.defaultProps,
|
|
@@ -895,7 +899,8 @@ function constructFunc(core, parent) {
|
|
|
895
899
|
});
|
|
896
900
|
}
|
|
897
901
|
}
|
|
898
|
-
}
|
|
902
|
+
}
|
|
903
|
+
else if (typeof entity === "function") {
|
|
899
904
|
if (entity?.defaultProps) {
|
|
900
905
|
core.props = {
|
|
901
906
|
...entity.defaultProps,
|
|
@@ -907,10 +912,13 @@ function constructFunc(core, parent) {
|
|
|
907
912
|
comp.render = entity.bind(comp);
|
|
908
913
|
comp[CORE].hooks = [];
|
|
909
914
|
comp[CORE].hook_index = 0;
|
|
910
|
-
}
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
911
917
|
throw new Error("Error in constructing component.");
|
|
912
918
|
}
|
|
913
919
|
|
|
920
|
+
if(loc) comp[CORE].location = loc;
|
|
921
|
+
|
|
914
922
|
comp[CORE].entity = entity;
|
|
915
923
|
registerComponentCore(comp[CORE]);
|
|
916
924
|
|
|
@@ -938,13 +946,12 @@ function prepareCore(parent, core) {
|
|
|
938
946
|
const isText = core[TEXT] !== undefined;
|
|
939
947
|
|
|
940
948
|
const key = isText
|
|
941
|
-
|
|
942
|
-
|
|
949
|
+
? ':text:'
|
|
950
|
+
: core.props?.key;
|
|
943
951
|
|
|
944
|
-
const entity =
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
: core.entity;
|
|
952
|
+
const entity = isText || core instanceof ComponentCore
|
|
953
|
+
? undefined
|
|
954
|
+
: core.entity;
|
|
948
955
|
|
|
949
956
|
return parent.cache.pick(
|
|
950
957
|
key,
|
|
@@ -955,10 +962,12 @@ function prepareCore(parent, core) {
|
|
|
955
962
|
),
|
|
956
963
|
entity
|
|
957
964
|
);
|
|
958
|
-
}
|
|
965
|
+
}
|
|
966
|
+
catch (e) {
|
|
959
967
|
if (core?.component?.componentDidCatch) {
|
|
960
968
|
core.component.componentDidCatch(e);
|
|
961
|
-
}
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
962
971
|
throw e;
|
|
963
972
|
}
|
|
964
973
|
}
|
|
@@ -1418,7 +1427,6 @@ export function createRoot(element)
|
|
|
1418
1427
|
},
|
|
1419
1428
|
|
|
1420
1429
|
getCore() {
|
|
1421
|
-
console.log(root, root[CORE]);
|
|
1422
1430
|
return root[CORE];
|
|
1423
1431
|
}
|
|
1424
1432
|
}
|
|
@@ -1426,26 +1434,6 @@ export function createRoot(element)
|
|
|
1426
1434
|
|
|
1427
1435
|
|
|
1428
1436
|
|
|
1429
|
-
export function hotReloadRoot(rootCore, nextEntity, props) {
|
|
1430
|
-
if (!rootCore || !rootCore.component) {
|
|
1431
|
-
throw new Error("Invalid root component.");
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
const replaced = replaceComponentEntity(rootCore, nextEntity);
|
|
1435
|
-
|
|
1436
|
-
if (!replaced) {
|
|
1437
|
-
throw new Error(
|
|
1438
|
-
"Cannot hot-reload the root from a class component to a function component, or vice versa."
|
|
1439
|
-
);
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
rootCore.apply(props === undefined ? rootCore.props : {...rootCore.props, ...props});
|
|
1443
|
-
|
|
1444
|
-
return rootCore;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
1437
|
/**
|
|
1450
1438
|
* Creates a portal — a way to render children into a DOM node
|
|
1451
1439
|
* that exists outside the current component hierarchy.
|
package/src/jsx.js
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
import * as vlq from './vlq.js'
|
|
51
51
|
import {processImportExports} from './expscan.js'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const LOCATION = Symbol.for('LILACT:LOCATION'); // it is also defined in symbols.jsx.
|
|
54
54
|
|
|
55
55
|
/** @ignore */
|
|
56
56
|
export const transpilerConfig = {
|
|
@@ -982,6 +982,7 @@ export function transpileJSX( jsx, {
|
|
|
982
982
|
discardComments = false,
|
|
983
983
|
produceCJS = false,
|
|
984
984
|
logErrors = false,
|
|
985
|
+
addLocationProp = false,
|
|
985
986
|
|
|
986
987
|
// lilact internal
|
|
987
988
|
mappings = [],
|
|
@@ -1175,7 +1176,10 @@ export function transpileJSX( jsx, {
|
|
|
1175
1176
|
}
|
|
1176
1177
|
|
|
1177
1178
|
const loc = getRowCol(eols,node.begin);
|
|
1178
|
-
|
|
1179
|
+
if(addLocationProp)
|
|
1180
|
+
out = ` ${factory}( ${node.tag}, { [Lilact.LOCATION]:["${path}", ${loc}], ${out} )`;
|
|
1181
|
+
else
|
|
1182
|
+
out = ` ${factory}( ${node.tag}, { ${out} )`;
|
|
1179
1183
|
|
|
1180
1184
|
return out;
|
|
1181
1185
|
}
|
package/src/misc.jsx
CHANGED
|
@@ -311,33 +311,40 @@ export const forwardRef = (render)=>
|
|
|
311
311
|
*
|
|
312
312
|
* @returns A promise that is resolved when the user clicks on screen and its value will be the component if any.
|
|
313
313
|
*/
|
|
314
|
-
export function
|
|
314
|
+
export function getComponentUnderPointer()
|
|
315
315
|
{
|
|
316
|
-
|
|
316
|
+
let resolve_func;
|
|
317
317
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
const pr = new Promise( (res, rej)=> {
|
|
319
|
+
resolve_func = res;
|
|
320
|
+
});
|
|
321
321
|
|
|
322
|
-
|
|
322
|
+
const overlay = document.createElement('div');
|
|
323
|
+
overlay.style.cssText =
|
|
324
|
+
'position:fixed;inset:0;z-index:2147483647;cursor:crosshair;background:transparent;';
|
|
325
|
+
document.body.appendChild(overlay);
|
|
323
326
|
|
|
324
|
-
|
|
325
|
-
window.removeEventListener('click', click_handler, true);
|
|
327
|
+
function click_handler(event) {
|
|
326
328
|
|
|
327
|
-
|
|
329
|
+
event.stopImmediatePropagation();
|
|
330
|
+
window.removeEventListener('click', click_handler, true);
|
|
328
331
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
+
overlay.style.display = 'none';
|
|
333
|
+
let t = document.elementFromPoint(event.clientX, event.clientY);
|
|
334
|
+
overlay.remove();
|
|
332
335
|
|
|
333
|
-
|
|
336
|
+
while( !t[COMPONENT] && t.parentNode ) {
|
|
337
|
+
t = t.parentNode;
|
|
338
|
+
}
|
|
334
339
|
|
|
335
|
-
|
|
336
|
-
|
|
340
|
+
resolve_func( t[COMPONENT] );
|
|
341
|
+
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
337
344
|
|
|
338
|
-
|
|
345
|
+
window.addEventListener('click', click_handler, true);
|
|
339
346
|
|
|
340
|
-
|
|
347
|
+
return pr;
|
|
341
348
|
}
|
|
342
349
|
|
|
343
350
|
|
package/src/run.jsx
CHANGED
package/src/symbols.jsx
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
export const [
|
|
33
|
+
LOCATION,
|
|
34
|
+
|
|
33
35
|
CORE,
|
|
34
36
|
COMPONENT,
|
|
35
37
|
TEXT,
|
|
@@ -44,9 +46,11 @@ export const [
|
|
|
44
46
|
CLEARED,
|
|
45
47
|
INTERVAL,
|
|
46
48
|
CALLBACK,
|
|
47
|
-
ARGS
|
|
49
|
+
ARGS
|
|
48
50
|
] =
|
|
49
51
|
[
|
|
52
|
+
Symbol.for('LILACT:LOCATION'),
|
|
53
|
+
|
|
50
54
|
Symbol.for('LILACT:CORE'),
|
|
51
55
|
Symbol.for('LILACT:COMPONENT'),
|
|
52
56
|
Symbol.for('LILACT:TEXT'),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>hotReloadRoot | Lilact</title><meta name="description" content="Documentation for Lilact"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Lilact</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/components.html">components</a></li><li><a href="" aria-current="page">hotReloadRoot</a></li></ul><h1>Function hotReloadRoot</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="hotreloadroot"><span class="tsd-kind-call-signature">hotReloadRoot</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">rootCore</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-kind-parameter">nextEntity</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-kind-parameter">props</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><a href="#hotreloadroot" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">rootCore</span>: <span class="tsd-signature-type">any</span></span></li><li><span><span class="tsd-kind-parameter">nextEntity</span>: <span class="tsd-signature-type">any</span></span></li><li><span><span class="tsd-kind-parameter">props</span>: <span class="tsd-signature-type">any</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in components.jsx:1429</li></ul></aside></div></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Lilact</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|