lilact 0.14.2 → 0.15.1
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 +547 -393
- package/dist/lilact.development.js.map +1 -1
- package/dist/lilact.development.min.js +1 -1
- package/dist/lilact.development.min.js.LICENSE.txt +6 -0
- package/dist/lilact.development.min.js.map +1 -1
- package/dist/lilact.production.min.js +1 -1
- package/dist/lilact.production.min.js.map +1 -1
- package/docs/classes/accessories.ErrorBoundary.html +11 -11
- package/docs/classes/accessories.Suspense.html +10 -10
- 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/accessories.DragHandle.html +1 -1
- package/docs/functions/accessories.Spinner.html +1 -1
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/errors.globalErrorHandler.html +1 -1
- package/docs/functions/errors.traceError.html +1 -1
- package/docs/functions/hooks.createContext.html +1 -1
- package/docs/functions/hooks.useActionState.html +1 -1
- package/docs/functions/hooks.useCallback.html +1 -1
- package/docs/functions/hooks.useContext.html +1 -1
- package/docs/functions/hooks.useDeferredValue.html +1 -1
- package/docs/functions/hooks.useEffect.html +1 -1
- package/docs/functions/hooks.useHook.html +1 -1
- package/docs/functions/hooks.useId.html +1 -1
- package/docs/functions/hooks.useImperativeHandle.html +1 -1
- package/docs/functions/hooks.useLayoutEffect.html +1 -1
- package/docs/functions/hooks.useLocalStorage.html +1 -1
- package/docs/functions/hooks.useMemo.html +1 -1
- package/docs/functions/hooks.useReducer.html +1 -1
- package/docs/functions/hooks.useRef.html +1 -1
- package/docs/functions/hooks.useState.html +1 -1
- package/docs/functions/hooks.useTransition.html +1 -1
- package/docs/functions/redux.Provider.html +1 -1
- package/docs/functions/redux.combineReducers.html +1 -1
- package/docs/functions/redux.connect.html +1 -1
- package/docs/functions/redux.useDispatch.html +1 -1
- package/docs/functions/redux.useSelector.html +1 -1
- package/docs/functions/redux.useStore.html +1 -1
- package/docs/functions/router.HashRouter.html +1 -1
- package/docs/functions/router.Link.html +1 -1
- package/docs/functions/router.NavLink.html +1 -1
- package/docs/functions/router.Route.html +1 -1
- package/docs/functions/router.Routes.html +1 -1
- package/docs/functions/router.useLocation.html +1 -1
- package/docs/functions/router.useNavigate.html +1 -1
- package/docs/functions/run.lazy.html +1 -1
- package/docs/functions/run.require.html +3 -3
- package/docs/functions/run.run.html +1 -1
- package/docs/functions/run.runScripts.html +3 -3
- package/docs/functions/timers.timeoutPromise.html +133 -2
- package/docs/functions/transition.CSSTransition.html +1 -1
- package/docs/functions/transition.SwitchTransition.html +1 -1
- package/docs/functions/transition.Transition.html +1 -1
- package/docs/functions/transition.TransitionGroup.html +1 -1
- package/docs/static/lilact.development.js +547 -393
- package/docs/static/lilact.development.min.js +1 -1
- package/docs/static/lilact.production.min.js +1 -1
- package/docs/variables/accessories.SplitPane.html +1 -1
- package/package.json +1 -1
- package/root/lilact.development.js +547 -393
- package/root/lilact.development.min.js +1 -1
- package/root/lilact.production.min.js +1 -1
- package/src/accessories.jsx +14 -17
- package/src/components.jsx +87 -27
- package/src/errors.jsx +11 -9
- package/src/hooks.jsx +32 -30
- package/src/lilact.jsx +8 -8
- package/src/loader.cjs +1 -1
- package/src/misc.jsx +1 -60
- package/src/redux.jsx +13 -11
- package/src/router.jsx +88 -49
- package/src/run.jsx +19 -16
- package/src/symbols.jsx +65 -0
- package/src/timers.jsx +6 -6
- package/src/transition.jsx +6 -4
- package/webpack.config.js +7 -3
package/src/accessories.jsx
CHANGED
|
@@ -29,14 +29,11 @@
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useImperativeHandle } from "./hooks.jsx";
|
|
33
|
-
import { Children, forwardRef } from "./misc.jsx";
|
|
32
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useImperativeHandle, useCallback } from "./hooks.jsx";
|
|
33
|
+
import { Children, forwardRef, isThenable } from "./misc.jsx";
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
import {isThenable} from "./misc.jsx"
|
|
37
35
|
import {setTimeout, clearTimeout} from "./timers.jsx"
|
|
38
36
|
import {Component} from "./components.jsx"
|
|
39
|
-
import {useCallback} from './hooks.jsx'
|
|
40
37
|
import {emotion} from "./lilact.jsx"
|
|
41
38
|
const {css,cx} = emotion;
|
|
42
39
|
|
|
@@ -167,7 +164,7 @@ export class Suspense extends Component
|
|
|
167
164
|
|
|
168
165
|
/** @ignore */
|
|
169
166
|
static getDerivedStateFromError(error) {
|
|
170
|
-
if (
|
|
167
|
+
if (isThenable(error)) {
|
|
171
168
|
// signal to call componentDidCatch where we handle the thenable
|
|
172
169
|
return null;
|
|
173
170
|
}
|
|
@@ -177,7 +174,7 @@ export class Suspense extends Component
|
|
|
177
174
|
|
|
178
175
|
/** @ignore */
|
|
179
176
|
componentDidCatch(error) {
|
|
180
|
-
if (!
|
|
177
|
+
if (!isThenable(error)) return;
|
|
181
178
|
|
|
182
179
|
const promise = error;
|
|
183
180
|
|
|
@@ -191,10 +188,10 @@ export class Suspense extends Component
|
|
|
191
188
|
const delay = Math.max(0, this.props.minDelay);
|
|
192
189
|
// Ensure no leftover timers
|
|
193
190
|
if (this._delayTimer) {
|
|
194
|
-
|
|
191
|
+
clearTimeout(this._delayTimer);
|
|
195
192
|
this._delayTimer = null;
|
|
196
193
|
}
|
|
197
|
-
this._delayTimer =
|
|
194
|
+
this._delayTimer = setTimeout(() => {
|
|
198
195
|
this._delayTimer = null;
|
|
199
196
|
this._fallbackShownAt = Date.now();
|
|
200
197
|
this.setState({ showingFallback: true });
|
|
@@ -211,11 +208,11 @@ export class Suspense extends Component
|
|
|
211
208
|
/** @ignore */
|
|
212
209
|
_clearTimers() {
|
|
213
210
|
if (this._delayTimer) {
|
|
214
|
-
|
|
211
|
+
clearTimeout(this._delayTimer);
|
|
215
212
|
this._delayTimer = null;
|
|
216
213
|
}
|
|
217
214
|
if (this._minShowTimer) {
|
|
218
|
-
|
|
215
|
+
clearTimeout(this._minShowTimer);
|
|
219
216
|
this._minShowTimer = null;
|
|
220
217
|
}
|
|
221
218
|
}
|
|
@@ -228,10 +225,10 @@ export class Suspense extends Component
|
|
|
228
225
|
if (this._pending.size === 1) {
|
|
229
226
|
const delay = Math.max(0, this.props.minDelay);
|
|
230
227
|
if (this._delayTimer) {
|
|
231
|
-
|
|
228
|
+
clearTimeout(this._delayTimer);
|
|
232
229
|
this._delayTimer = null;
|
|
233
230
|
}
|
|
234
|
-
this._delayTimer =
|
|
231
|
+
this._delayTimer = setTimeout(() => {
|
|
235
232
|
this._delayTimer = null;
|
|
236
233
|
this._fallbackShownAt = Date.now();
|
|
237
234
|
this.setState({ showingFallback: true });
|
|
@@ -247,7 +244,7 @@ export class Suspense extends Component
|
|
|
247
244
|
if (this._pending.size === 0) {
|
|
248
245
|
// cancel delay if fallback hasn't shown yet
|
|
249
246
|
if (this._delayTimer) {
|
|
250
|
-
|
|
247
|
+
clearTimeout(this._delayTimer);
|
|
251
248
|
this._delayTimer = null;
|
|
252
249
|
// fallback never shown; just ensure state is not showing
|
|
253
250
|
this.setState({ showingFallback: false });
|
|
@@ -262,10 +259,10 @@ export class Suspense extends Component
|
|
|
262
259
|
this.setState({ showingFallback: false });
|
|
263
260
|
} else {
|
|
264
261
|
if (this._minShowTimer) {
|
|
265
|
-
|
|
262
|
+
clearTimeout(this._minShowTimer);
|
|
266
263
|
this._minShowTimer = null;
|
|
267
264
|
}
|
|
268
|
-
this._minShowTimer =
|
|
265
|
+
this._minShowTimer = setTimeout(() => {
|
|
269
266
|
this._minShowTimer = null;
|
|
270
267
|
this.setState({ showingFallback: false });
|
|
271
268
|
}, remaining);
|
|
@@ -279,7 +276,7 @@ export class Suspense extends Component
|
|
|
279
276
|
|
|
280
277
|
/** @ignore */
|
|
281
278
|
componentDidCatch(error, info) {
|
|
282
|
-
if (!
|
|
279
|
+
if (!isThenable(error)) return;
|
|
283
280
|
this._attachPromise(error);
|
|
284
281
|
}
|
|
285
282
|
|
package/src/components.jsx
CHANGED
|
@@ -28,9 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
import Lilact from './lilact.jsx';
|
|
32
32
|
|
|
33
|
-
import {
|
|
33
|
+
import { CORE, COMPONENT, TEXT, IS_ZOMBIE, IDX, CHILD_CLASS_ADDENDUM, MEMOIZED } from "./symbols.jsx"
|
|
34
|
+
import { shallowEqual, toBool, isClass } from "./misc.jsx";
|
|
35
|
+
|
|
36
|
+
import PropTypes from 'prop-types';
|
|
34
37
|
|
|
35
38
|
/*
|
|
36
39
|
ComponentCache is for internal use. It is the heart of the JSX runtime,
|
|
@@ -163,16 +166,16 @@ class ComponentCore
|
|
|
163
166
|
// }
|
|
164
167
|
|
|
165
168
|
/*if(do_rerender)*/ {
|
|
166
|
-
|
|
169
|
+
if(DEBUG) {
|
|
167
170
|
|
|
168
171
|
if(this.entity?.propTypes) {
|
|
169
|
-
|
|
172
|
+
PropTypes.checkPropTypes(this.entity.propTypes, this.props, 'prop', this.entity.name);
|
|
170
173
|
}
|
|
171
174
|
else if(this.component?.propTypes) {
|
|
172
|
-
|
|
175
|
+
PropTypes.checkPropTypes(this.component.propTypes, this.props, 'prop', this.component.name);
|
|
173
176
|
}
|
|
174
177
|
|
|
175
|
-
|
|
178
|
+
}
|
|
176
179
|
if(typeof(next_state)==='function') next_state = next_state(this.state);
|
|
177
180
|
|
|
178
181
|
if(this.component.constructor.defaultProps) {
|
|
@@ -405,7 +408,7 @@ class ComponentCore
|
|
|
405
408
|
|
|
406
409
|
if( !patch.hasOwnProperty(a) ) {
|
|
407
410
|
|
|
408
|
-
if(
|
|
411
|
+
if( events_set.has(al) ) {
|
|
409
412
|
this.event_detachers[al]();
|
|
410
413
|
}
|
|
411
414
|
else {
|
|
@@ -417,17 +420,17 @@ class ComponentCore
|
|
|
417
420
|
for(let a in patch) {
|
|
418
421
|
const al = a.toLowerCase();
|
|
419
422
|
|
|
420
|
-
if(
|
|
423
|
+
if( special_attributes.has(al) ) continue;
|
|
421
424
|
|
|
422
425
|
if( patch===this.props || !Lilact.defaultIsEqual(patch[a], this.props[a]) || force ) {
|
|
423
426
|
|
|
424
|
-
if(
|
|
427
|
+
if( events_set.has(al) ) {
|
|
425
428
|
this.event_detachers ??= {};
|
|
426
429
|
this.event_detachers[al]?.();
|
|
427
430
|
this.event_detachers[al] = Lilact.addWrappedEventListener(this.element, al.substring(2), patch[a]);
|
|
428
431
|
}
|
|
429
|
-
else if(
|
|
430
|
-
const alc =
|
|
432
|
+
else if( capture_events_set.hasOwnProperty(al) ) {
|
|
433
|
+
const alc = capture_events_set[al];
|
|
431
434
|
this.event_detachers ??= {};
|
|
432
435
|
this.event_detachers[al]?.();
|
|
433
436
|
this.event_detachers[al] =
|
|
@@ -439,7 +442,7 @@ class ComponentCore
|
|
|
439
442
|
}
|
|
440
443
|
else {
|
|
441
444
|
for(const x in patch[a]) {
|
|
442
|
-
if(
|
|
445
|
+
if( length_css_attributes_set.has(x) ) {
|
|
443
446
|
if(isFinite(patch[a][x])) {
|
|
444
447
|
patch[a][x]+='px';
|
|
445
448
|
}
|
|
@@ -448,11 +451,11 @@ class ComponentCore
|
|
|
448
451
|
Object.assign(this.element.style, patch[a]);
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
|
-
else if(
|
|
452
|
-
this.element[a] =
|
|
454
|
+
else if(boolean_html_attributes_set.has(a)) { // not lower cased(al), as it is set as a js property
|
|
455
|
+
this.element[a] = toBool(patch[a]);
|
|
453
456
|
}
|
|
454
457
|
else if(a==='autoFocus') { // not lower cased(al), as it is set as a js property
|
|
455
|
-
this.element['autofocus'] =
|
|
458
|
+
this.element['autofocus'] = toBool(patch[a]);
|
|
456
459
|
}
|
|
457
460
|
else if(a==='htmlFor') { // not lower cased(al), as it is set as a js property
|
|
458
461
|
this.element.setAttribute('for', patch[a]);
|
|
@@ -473,9 +476,9 @@ class ComponentCore
|
|
|
473
476
|
this.element.onsubmit = undefined;
|
|
474
477
|
}
|
|
475
478
|
|
|
476
|
-
|
|
479
|
+
if(DEBUG) {
|
|
477
480
|
//this.element.setAttribute('key', this.props.key);
|
|
478
|
-
|
|
481
|
+
}
|
|
479
482
|
|
|
480
483
|
this.updateElementClass(patch);
|
|
481
484
|
}
|
|
@@ -628,7 +631,7 @@ function constructFunc(core, parent) // returns {text} or component, and not com
|
|
|
628
631
|
}
|
|
629
632
|
else {
|
|
630
633
|
|
|
631
|
-
if(
|
|
634
|
+
if( isClass(core.entity) ) {
|
|
632
635
|
if(core.entity?.defaultProps) {
|
|
633
636
|
core.props = { ...core.entity.defaultProps, ...core.props };
|
|
634
637
|
}
|
|
@@ -710,19 +713,18 @@ function prepareCore(parent, core)
|
|
|
710
713
|
function doUpdates()
|
|
711
714
|
{
|
|
712
715
|
requestAnimationFrame(()=>{
|
|
713
|
-
let
|
|
714
|
-
let
|
|
715
|
-
let
|
|
716
|
+
let _layout_effects = Lilact.layout_effects;
|
|
717
|
+
let _update_cbs = Lilact.update_cbs;
|
|
718
|
+
let _update_set = Lilact.update_set;
|
|
716
719
|
|
|
717
720
|
Lilact.layout_effects = new Set;
|
|
718
721
|
Lilact.update_cbs = new Set;
|
|
719
722
|
Lilact.update_set = new Set;
|
|
720
723
|
|
|
721
|
-
for(const le of
|
|
722
|
-
|
|
723
|
-
for(const u of update_set) u.apply();
|
|
724
|
-
for(const cb of update_cbs) cb();
|
|
724
|
+
for(const le of _layout_effects) le();
|
|
725
725
|
|
|
726
|
+
for(const u of _update_set) u.apply();
|
|
727
|
+
for(const cb of _update_cbs) cb();
|
|
726
728
|
});
|
|
727
729
|
}
|
|
728
730
|
|
|
@@ -882,7 +884,7 @@ export class Component
|
|
|
882
884
|
{
|
|
883
885
|
if(this[CORE].entity?.displayName) return this[CORE].entity?.displayName;
|
|
884
886
|
if(typeof(this[CORE].entity)==='string') return this[CORE].entity;
|
|
885
|
-
if(
|
|
887
|
+
if( isClass(this[CORE].entity) ) this[CORE].entity.constructor.name;
|
|
886
888
|
if( typeof(this[CORE].entity)==='function' ) return this[CORE].entity.name;
|
|
887
889
|
return "Component";
|
|
888
890
|
}
|
|
@@ -1136,4 +1138,62 @@ export function render(component, element)
|
|
|
1136
1138
|
}
|
|
1137
1139
|
|
|
1138
1140
|
/** @ignore */
|
|
1139
|
-
export const createElement = createComponent;
|
|
1141
|
+
export const createElement = createComponent;
|
|
1142
|
+
|
|
1143
|
+
/** @ignore */
|
|
1144
|
+
export let current_component = [];
|
|
1145
|
+
/** @ignore */
|
|
1146
|
+
|
|
1147
|
+
export let update_set = new Set;
|
|
1148
|
+
/** @ignore */
|
|
1149
|
+
export let update_cbs = new Set;
|
|
1150
|
+
/** @ignore */
|
|
1151
|
+
export let roots = new Set;
|
|
1152
|
+
/** @ignore */
|
|
1153
|
+
export let layout_effects = new Set;
|
|
1154
|
+
|
|
1155
|
+
/** @ignore */
|
|
1156
|
+
export const special_attributes = new Set([
|
|
1157
|
+
"classname", "ref", "action", "lilact_jsx_loc", "children", "key",
|
|
1158
|
+
"defaultvalue", "defaultchecked"
|
|
1159
|
+
]);
|
|
1160
|
+
|
|
1161
|
+
/** @ignore */
|
|
1162
|
+
export const events_set = new Set([
|
|
1163
|
+
"onafterprint","onbeforeprint","onbeforeunload","onerror","onhashchange","onload","onmessage",
|
|
1164
|
+
"onoffline","ononline","onpagehide","onpageshow","onpopstate","onresize","onstorage","onunload",
|
|
1165
|
+
"onblur","onchange","oncontextmenu","onfocus","oninput","oninvalid","onreset","onsearch","onselect",
|
|
1166
|
+
"onsubmit",
|
|
1167
|
+
"onkeydown","onkeypress","onkeyup",
|
|
1168
|
+
"onclick","ondblclick","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel",
|
|
1169
|
+
"onwheel",
|
|
1170
|
+
"ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","onscroll",
|
|
1171
|
+
"oncopy","oncut","onpaste",
|
|
1172
|
+
"onabort","oncanplay","oncanplaythrough","oncuechange","ondurationchange","onemptied","onended","onerror",
|
|
1173
|
+
"onloadeddata","onloadedmetadata","onloadstart","onpause","onplay","onplaying","onprogress","onratechange",
|
|
1174
|
+
"onseeked","onseeking","onstalled","onsuspend","ontimeupdate","onvolumechange","onwaiting",
|
|
1175
|
+
"ontoggle",
|
|
1176
|
+
"onpointerdown", "onpointerup", "onpointermove", "onpointercancel", "onpointerover", "onpointerout",
|
|
1177
|
+
"onpointerenter", "onpointerleave"
|
|
1178
|
+
]);
|
|
1179
|
+
|
|
1180
|
+
/** @ignore */
|
|
1181
|
+
export const capture_events_set = {};
|
|
1182
|
+
for (const x of events_set) {
|
|
1183
|
+
capture_events_set[x+"capture"] = x;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/** @ignore */
|
|
1187
|
+
export const length_css_attributes_set = new Set([
|
|
1188
|
+
"width","height","minWidth","minHeight","maxWidth","maxHeight","top","right","bottom","left","margin",
|
|
1189
|
+
"marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom",
|
|
1190
|
+
"paddingLeft","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth",
|
|
1191
|
+
"outlineWidth","fontSize","lineHeight","letterSpacing","wordSpacing","textIndent","borderRadius",
|
|
1192
|
+
"borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius",
|
|
1193
|
+
"columnGap","rowGap","gap"
|
|
1194
|
+
]);
|
|
1195
|
+
|
|
1196
|
+
/** @ignore */
|
|
1197
|
+
export const boolean_html_attributes_set = new
|
|
1198
|
+
Set(["disabled", "readOnly", "required", "checked", "multiple",
|
|
1199
|
+
"hidden","open","loop","muted","controls","playsInline","allowFullScreen"]);
|
package/src/errors.jsx
CHANGED
|
@@ -27,8 +27,11 @@
|
|
|
27
27
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
28
|
|
|
29
29
|
*/
|
|
30
|
+
import Lilact from './lilact.jsx';
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
import { required_scripts } from './run.jsx'
|
|
33
|
+
import { pauseTimers } from './timers.jsx'
|
|
34
|
+
import { css } from "@emotion/css";
|
|
32
35
|
|
|
33
36
|
// Lilact API
|
|
34
37
|
|
|
@@ -160,7 +163,7 @@ export function traceError(error)
|
|
|
160
163
|
let mps;
|
|
161
164
|
|
|
162
165
|
if(loc.url) {
|
|
163
|
-
const rm =
|
|
166
|
+
const rm = required_scripts[obj.fileName];
|
|
164
167
|
mps = rm.mappings;
|
|
165
168
|
|
|
166
169
|
const mloc = mapLocation(mps, obj.lineNumber-1, obj.columnNumber-1);
|
|
@@ -186,7 +189,7 @@ export function traceError(error)
|
|
|
186
189
|
obj.fileName = blk.path;
|
|
187
190
|
obj.label = blk.label;
|
|
188
191
|
|
|
189
|
-
mps =
|
|
192
|
+
mps = required_scripts[blk.path].mappings;
|
|
190
193
|
|
|
191
194
|
loc = mapLocation(mps, loc.line-1, loc.col-1);
|
|
192
195
|
|
|
@@ -227,12 +230,11 @@ export function traceError(error)
|
|
|
227
230
|
*/
|
|
228
231
|
export function globalErrorHandler(error)
|
|
229
232
|
{
|
|
230
|
-
Lilact.pauseTimers();
|
|
231
233
|
if(error.error) error = error.error;
|
|
232
234
|
|
|
233
|
-
error =
|
|
235
|
+
error = traceError(error);
|
|
234
236
|
|
|
235
|
-
const cls =
|
|
237
|
+
const cls = css(`
|
|
236
238
|
background: linear-gradient(135deg, #fff2f2d4, #ffffffd4);
|
|
237
239
|
backdrop-filter: blur(10px);
|
|
238
240
|
border: 1px solid rgba(255,255,255,.25);
|
|
@@ -261,7 +263,7 @@ export function globalErrorHandler(error)
|
|
|
261
263
|
<b>${error.fileName?'At '+error.fileName:''}
|
|
262
264
|
${Number.isFinite(error.lineNumber)?": Line "+(error.lineNumber+1):""}</b><br><br>
|
|
263
265
|
<b>${error.name}</b>: <span>${error.message}</span><br><br>
|
|
264
|
-
${
|
|
266
|
+
${required_scripts[error.fileName]?'<code><pre></pre><pre><red></red></pre><pre></pre></code>':''}
|
|
265
267
|
${error._error.componentStackLog?'<br>Component Stack:<br><code><pre>'+error._error.componentStackLog+'</pre></code>':''}
|
|
266
268
|
`;
|
|
267
269
|
|
|
@@ -270,8 +272,8 @@ export function globalErrorHandler(error)
|
|
|
270
272
|
|
|
271
273
|
const pres = el.querySelectorAll('pre');
|
|
272
274
|
|
|
273
|
-
if(
|
|
274
|
-
const lines =
|
|
275
|
+
if(required_scripts[error.fileName]) {
|
|
276
|
+
const lines = required_scripts[error.fileName].code.split("\n");
|
|
275
277
|
|
|
276
278
|
if(lines?.[error.lineNumber-1])
|
|
277
279
|
pres[0].innerText = lines[error.lineNumber-1];
|
package/src/hooks.jsx
CHANGED
|
@@ -28,7 +28,10 @@
|
|
|
28
28
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
import Lilact from './lilact.jsx';
|
|
32
|
+
import { isEmpty, shallowEqual } from "./misc.jsx"
|
|
33
|
+
|
|
34
|
+
import { CORE, COMPONENT } from "./symbols.jsx"
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
/**
|
|
@@ -57,9 +60,9 @@ export function useHook()
|
|
|
57
60
|
*/
|
|
58
61
|
export function useState(initialValue)
|
|
59
62
|
{
|
|
60
|
-
const hk =
|
|
63
|
+
const hk = useHook();
|
|
61
64
|
|
|
62
|
-
if(
|
|
65
|
+
if( isEmpty(hk) ) {
|
|
63
66
|
if(typeof(initialValue)==='function') hk.value = initialValue();
|
|
64
67
|
else hk.value = initialValue;
|
|
65
68
|
|
|
@@ -88,10 +91,10 @@ export function useCallback(callback, deps=undefined)
|
|
|
88
91
|
throw new Error("Callback dependencies must be an array or omitted.");
|
|
89
92
|
}
|
|
90
93
|
|
|
91
|
-
const hk =
|
|
94
|
+
const hk = useHook();
|
|
92
95
|
|
|
93
|
-
if( !
|
|
94
|
-
if(deps!==undefined && hk?.deps!==undefined &&
|
|
96
|
+
if( !isEmpty(hk) ) {
|
|
97
|
+
if(deps!==undefined && hk?.deps!==undefined && shallowEqual(deps, hk.deps)) {
|
|
95
98
|
return hk.callback;
|
|
96
99
|
}
|
|
97
100
|
}
|
|
@@ -154,9 +157,9 @@ export function useContext(context)
|
|
|
154
157
|
*/
|
|
155
158
|
export function useId(prefix="N")
|
|
156
159
|
{
|
|
157
|
-
const hk =
|
|
160
|
+
const hk = useHook();
|
|
158
161
|
|
|
159
|
-
if(
|
|
162
|
+
if( isEmpty(hk) ) {
|
|
160
163
|
hk.id = prefix+Lilact.id_num++;
|
|
161
164
|
}
|
|
162
165
|
|
|
@@ -170,9 +173,9 @@ export function useId(prefix="N")
|
|
|
170
173
|
*/
|
|
171
174
|
export function useTransition()
|
|
172
175
|
{
|
|
173
|
-
const hk =
|
|
176
|
+
const hk = useHook();
|
|
174
177
|
|
|
175
|
-
if(
|
|
178
|
+
if( isEmpty(hk) ) {
|
|
176
179
|
hk.count=0;
|
|
177
180
|
|
|
178
181
|
hk.func =
|
|
@@ -210,7 +213,7 @@ export function useTransition()
|
|
|
210
213
|
export function useLocalStorage(key, initialValue)
|
|
211
214
|
{
|
|
212
215
|
|
|
213
|
-
const hk =
|
|
216
|
+
const hk = useHook();
|
|
214
217
|
let val;
|
|
215
218
|
|
|
216
219
|
try {
|
|
@@ -225,7 +228,7 @@ export function useLocalStorage(key, initialValue)
|
|
|
225
228
|
localStorage[key] = JSON.stringify(val);
|
|
226
229
|
}
|
|
227
230
|
|
|
228
|
-
if(
|
|
231
|
+
if( isEmpty(hk) ) {
|
|
229
232
|
hk.value = val;
|
|
230
233
|
hk.set_func = function(core, hk, val) {
|
|
231
234
|
|
|
@@ -253,9 +256,9 @@ export function useLocalStorage(key, initialValue)
|
|
|
253
256
|
*/
|
|
254
257
|
export function useRef(initialValue = null)
|
|
255
258
|
{
|
|
256
|
-
const hk =
|
|
259
|
+
const hk = useHook();
|
|
257
260
|
|
|
258
|
-
if(
|
|
261
|
+
if( isEmpty(hk) ) {
|
|
259
262
|
hk.current = initialValue;
|
|
260
263
|
}
|
|
261
264
|
|
|
@@ -275,10 +278,10 @@ export function useLayoutEffect(effect, deps=undefined)
|
|
|
275
278
|
throw new Error("Layout effect dependencies must be an array or omitted.");
|
|
276
279
|
}
|
|
277
280
|
|
|
278
|
-
const hk =
|
|
281
|
+
const hk = useHook();
|
|
279
282
|
|
|
280
|
-
if( !
|
|
281
|
-
if(deps!==undefined && hk?.deps!==undefined &&
|
|
283
|
+
if( !isEmpty(hk) ) {
|
|
284
|
+
if(deps!==undefined && hk?.deps!==undefined && shallowEqual(deps, hk.deps)) return;
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
if(hk?.cleanup) {
|
|
@@ -303,10 +306,10 @@ export function useEffect(effect, deps=undefined)
|
|
|
303
306
|
throw new Error("Effect dependencies must be an array or omitted.");
|
|
304
307
|
}
|
|
305
308
|
|
|
306
|
-
const hk =
|
|
309
|
+
const hk = useHook();
|
|
307
310
|
|
|
308
|
-
if( !
|
|
309
|
-
if(deps!==undefined && hk?.deps!==undefined &&
|
|
311
|
+
if( !isEmpty(hk) ) {
|
|
312
|
+
if(deps!==undefined && hk?.deps!==undefined && shallowEqual(deps, hk.deps)) return;
|
|
310
313
|
}
|
|
311
314
|
|
|
312
315
|
if(hk?.cleanup) {
|
|
@@ -331,10 +334,10 @@ export function useMemo(factory,deps=undefined)
|
|
|
331
334
|
throw new Error("Memo dependencies must be an array or omitted.");
|
|
332
335
|
}
|
|
333
336
|
|
|
334
|
-
const hk =
|
|
337
|
+
const hk = useHook();
|
|
335
338
|
|
|
336
|
-
if( !
|
|
337
|
-
if(deps!==undefined && hk?.deps!==undefined &&
|
|
339
|
+
if( !isEmpty(hk) ) {
|
|
340
|
+
if(deps!==undefined && hk?.deps!==undefined && shallowEqual(deps, hk.deps)) {
|
|
338
341
|
return hk.value;
|
|
339
342
|
}
|
|
340
343
|
}
|
|
@@ -354,10 +357,10 @@ export function useMemo(factory,deps=undefined)
|
|
|
354
357
|
*/
|
|
355
358
|
export function useActionState(action, initialState)
|
|
356
359
|
{
|
|
357
|
-
const hk =
|
|
358
|
-
const [is_pending, tran_start_func] =
|
|
360
|
+
const hk = useHook();
|
|
361
|
+
const [is_pending, tran_start_func] = useTransition();
|
|
359
362
|
|
|
360
|
-
if(
|
|
363
|
+
if( isEmpty(hk) ) {
|
|
361
364
|
|
|
362
365
|
hk.state = initialState;
|
|
363
366
|
|
|
@@ -389,9 +392,9 @@ export function useActionState(action, initialState)
|
|
|
389
392
|
*/
|
|
390
393
|
export function useReducer(reducer, initialArg, init)
|
|
391
394
|
{
|
|
392
|
-
const hk =
|
|
395
|
+
const hk = useHook();
|
|
393
396
|
|
|
394
|
-
if(
|
|
397
|
+
if( isEmpty(hk) ) {
|
|
395
398
|
hk.reducer = reducer;
|
|
396
399
|
hk.state = init?init(initialArg):initialArg;
|
|
397
400
|
hk.dispatch = function(core, hk, action) {
|
|
@@ -400,7 +403,6 @@ export function useReducer(reducer, initialArg, init)
|
|
|
400
403
|
hk.state = newst;
|
|
401
404
|
core.component.forceUpdate();
|
|
402
405
|
}
|
|
403
|
-
|
|
404
406
|
}.bind(undefined, Lilact.current_component[0], hk);
|
|
405
407
|
}
|
|
406
408
|
|
|
@@ -474,7 +476,7 @@ export function useDeferredValue(value, initialValue)
|
|
|
474
476
|
*/
|
|
475
477
|
export function useImperativeHandle(ref, factory, deps=undefined)
|
|
476
478
|
{
|
|
477
|
-
if(deps!==undefined && ref?.deps!==undefined &&
|
|
479
|
+
if(deps!==undefined && ref?.deps!==undefined && shallowEqual(deps, ref.deps)) return;
|
|
478
480
|
|
|
479
481
|
ref.deps = deps;
|
|
480
482
|
|
package/src/lilact.jsx
CHANGED
|
@@ -92,7 +92,7 @@ export {transpileJSX, transpilerConfig} from "./jsx";
|
|
|
92
92
|
export const Lilact =
|
|
93
93
|
{
|
|
94
94
|
|
|
95
|
-
VERSION: "beta.
|
|
95
|
+
VERSION: "beta.15",
|
|
96
96
|
|
|
97
97
|
// Configuration
|
|
98
98
|
|
|
@@ -132,16 +132,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
132
132
|
Lilact.runScripts();
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
window.addEventListener('error', (e) => {
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
|
|
135
|
+
if(DEBUG) {
|
|
136
|
+
window.addEventListener('error', (e) => {
|
|
137
|
+
Lilact.globalErrorHandler(e);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
if(DEBUG) {
|
|
142
142
|
console.log(`Lilact (Version: ${Lilact.VERSION}) - Debug Mode`);
|
|
143
143
|
console.log(`Copyright(C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>`);
|
|
144
|
-
|
|
144
|
+
}
|
|
145
145
|
|
|
146
146
|
export default Lilact;
|
|
147
147
|
|
package/src/loader.cjs
CHANGED
package/src/misc.jsx
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
import Lilact from './lilact.jsx';
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
import { CORE, COMPONENT, MEMOIZED } from "./symbols.jsx"
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
const typeOf = (input) => {
|
|
@@ -338,9 +338,6 @@ export function toBool(value) {
|
|
|
338
338
|
|
|
339
339
|
// Internals
|
|
340
340
|
|
|
341
|
-
/** @ignore */
|
|
342
|
-
export const required_scripts = {};
|
|
343
|
-
|
|
344
341
|
/** @ignore */
|
|
345
342
|
export let update_timeout = undefined;
|
|
346
343
|
/** @ignore */
|
|
@@ -352,59 +349,3 @@ export let eval_num = 0;//Math.floor(Math.random()*10000);
|
|
|
352
349
|
|
|
353
350
|
|
|
354
351
|
// todo =improve these stacks
|
|
355
|
-
/** @ignore */
|
|
356
|
-
export let current_component = [];
|
|
357
|
-
/** @ignore */
|
|
358
|
-
export let update_set = new Set;
|
|
359
|
-
/** @ignore */
|
|
360
|
-
export let update_cbs = new Set;
|
|
361
|
-
/** @ignore */
|
|
362
|
-
export let roots = new Set;
|
|
363
|
-
/** @ignore */
|
|
364
|
-
export let layout_effects = new Set;
|
|
365
|
-
|
|
366
|
-
/** @ignore */
|
|
367
|
-
export const special_attributes = new Set([
|
|
368
|
-
"classname", "ref", "action", "lilact_jsx_loc", "children", "key",
|
|
369
|
-
"defaultvalue", "defaultchecked"
|
|
370
|
-
]);
|
|
371
|
-
|
|
372
|
-
/** @ignore */
|
|
373
|
-
export const events_set = new Set([
|
|
374
|
-
"onafterprint","onbeforeprint","onbeforeunload","onerror","onhashchange","onload","onmessage",
|
|
375
|
-
"onoffline","ononline","onpagehide","onpageshow","onpopstate","onresize","onstorage","onunload",
|
|
376
|
-
"onblur","onchange","oncontextmenu","onfocus","oninput","oninvalid","onreset","onsearch","onselect",
|
|
377
|
-
"onsubmit",
|
|
378
|
-
"onkeydown","onkeypress","onkeyup",
|
|
379
|
-
"onclick","ondblclick","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel",
|
|
380
|
-
"onwheel",
|
|
381
|
-
"ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","onscroll",
|
|
382
|
-
"oncopy","oncut","onpaste",
|
|
383
|
-
"onabort","oncanplay","oncanplaythrough","oncuechange","ondurationchange","onemptied","onended","onerror",
|
|
384
|
-
"onloadeddata","onloadedmetadata","onloadstart","onpause","onplay","onplaying","onprogress","onratechange",
|
|
385
|
-
"onseeked","onseeking","onstalled","onsuspend","ontimeupdate","onvolumechange","onwaiting",
|
|
386
|
-
"ontoggle",
|
|
387
|
-
"onpointerdown", "onpointerup", "onpointermove", "onpointercancel", "onpointerover", "onpointerout",
|
|
388
|
-
"onpointerenter", "onpointerleave"
|
|
389
|
-
]);
|
|
390
|
-
|
|
391
|
-
/** @ignore */
|
|
392
|
-
export const capture_events_set = {};
|
|
393
|
-
for (const x of events_set) {
|
|
394
|
-
capture_events_set[x+"capture"] = x;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/** @ignore */
|
|
398
|
-
export const length_css_attributes_set = new Set([
|
|
399
|
-
"width","height","minWidth","minHeight","maxWidth","maxHeight","top","right","bottom","left","margin",
|
|
400
|
-
"marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom",
|
|
401
|
-
"paddingLeft","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth",
|
|
402
|
-
"outlineWidth","fontSize","lineHeight","letterSpacing","wordSpacing","textIndent","borderRadius",
|
|
403
|
-
"borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius",
|
|
404
|
-
"columnGap","rowGap","gap"
|
|
405
|
-
]);
|
|
406
|
-
|
|
407
|
-
/** @ignore */
|
|
408
|
-
export const boolean_html_attributes_set = new
|
|
409
|
-
Set(["disabled", "readOnly", "required", "checked", "multiple",
|
|
410
|
-
"hidden","open","loop","muted","controls","playsInline","allowFullScreen"]);
|