lilact 0.26.15 → 0.27.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 (61) hide show
  1. package/dist/lilact.development.js +459 -324
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +63 -54
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +63 -54
  6. package/docs/assets/navigation.js +1 -1
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  9. package/docs/classes/accessories.Suspense.html +7 -7
  10. package/docs/classes/components.Component.html +11 -11
  11. package/docs/classes/components.HTMLComponent.html +11 -11
  12. package/docs/classes/components.RootComponent.html +11 -11
  13. package/docs/functions/components.cloneComponent.html +1 -1
  14. package/docs/functions/components.createComponent.html +1 -1
  15. package/docs/functions/components.createPortal.html +1 -1
  16. package/docs/functions/components.createRoot.html +1 -1
  17. package/docs/functions/components.memo.html +1 -1
  18. package/docs/functions/components.render.html +1 -1
  19. package/docs/functions/errors.globalErrorHandler.html +1 -8
  20. package/docs/functions/errors.scanBlockLabels.html +1 -0
  21. package/docs/functions/errors.traceError.html +1 -7
  22. package/docs/functions/hooks.startTransition.html +1 -1
  23. package/docs/functions/hooks.useActionState.html +1 -1
  24. package/docs/functions/hooks.useDebugValue.html +1 -1
  25. package/docs/functions/hooks.useDeferredValue.html +1 -1
  26. package/docs/functions/hooks.useEffect.html +1 -1
  27. package/docs/functions/hooks.useImperativeHandle.html +1 -1
  28. package/docs/functions/hooks.useInsertionEffect.html +1 -1
  29. package/docs/functions/hooks.useMemo.html +1 -1
  30. package/docs/functions/hooks.useReducer.html +1 -1
  31. package/docs/functions/run.lazy.html +1 -13
  32. package/docs/functions/run.require.html +1 -9
  33. package/docs/functions/run.run.html +1 -5
  34. package/docs/functions/run.runScripts.html +1 -7
  35. package/docs/functions/timers.timeoutPromise.html +3 -3
  36. package/docs/modules/errors.html +1 -1
  37. package/docs/modules/run.html +1 -1
  38. package/docs/static/index.html +1 -1
  39. package/docs/static/lilact.development.js +459 -324
  40. package/docs/static/lilact.development.js.map +3 -3
  41. package/docs/static/lilact.development.min.js +63 -54
  42. package/docs/static/lilact.development.min.js.map +3 -3
  43. package/docs/static/lilact.production.min.js +63 -54
  44. package/docs/variables/components.cloneElement.html +1 -1
  45. package/docs/variables/errors.blocks_info.html +1 -0
  46. package/docs/variables/errors.error.html +1 -0
  47. package/docs/variables/run.required_scripts.html +1 -0
  48. package/examples/index.html +1 -1
  49. package/examples/lilact.development.js +459 -324
  50. package/examples/lilact.development.js.map +3 -3
  51. package/examples/lilact.development.min.js +63 -54
  52. package/examples/lilact.development.min.js.map +3 -3
  53. package/examples/lilact.production.min.js +63 -54
  54. package/package.json +1 -1
  55. package/src/components.jsx +10 -4
  56. package/src/errors.jsx +344 -245
  57. package/src/expscan.js +1 -1
  58. package/src/hooks.jsx +8 -5
  59. package/src/jsx.js +16 -16
  60. package/src/lilact.jsx +2 -2
  61. package/src/run.jsx +313 -267
@@ -1417,9 +1417,9 @@ function handleInterpolation(mergedProps, registered, interpolation) {
1417
1417
  case "function": {
1418
1418
  if (mergedProps !== void 0) {
1419
1419
  var previousCursor = cursor;
1420
- var result = interpolation(mergedProps);
1420
+ var result2 = interpolation(mergedProps);
1421
1421
  cursor = previousCursor;
1422
- return handleInterpolation(mergedProps, registered, result);
1422
+ return handleInterpolation(mergedProps, registered, result2);
1423
1423
  }
1424
1424
  break;
1425
1425
  }
@@ -1927,8 +1927,8 @@ var forwardRef = (render2) => {
1927
1927
  };
1928
1928
  function getComponentByPointer() {
1929
1929
  let resolve_func;
1930
- const pr = new Promise((res2, rej) => {
1931
- resolve_func = res2;
1930
+ const pr = new Promise((res, rej) => {
1931
+ resolve_func = res;
1932
1932
  });
1933
1933
  function click_handler(event2) {
1934
1934
  event2.stopImmediatePropagation();
@@ -2528,8 +2528,8 @@ var ComponentCore = class {
2528
2528
  this.outlet.splice(i2, 1);
2529
2529
  i2--;
2530
2530
  } else if (typeof item === "function") {
2531
- const res2 = this.childFunctionHandler(item);
2532
- this.outlet.splice(i2, 1, res2);
2531
+ const res = this.childFunctionHandler(item);
2532
+ this.outlet.splice(i2, 1, res);
2533
2533
  i2--;
2534
2534
  } else if (item.constructor.name === "Array") {
2535
2535
  this.outlet.splice(i2, 1, ...item);
@@ -2579,24 +2579,25 @@ var ComponentCore = class {
2579
2579
  if (this.outlet !== void 0) {
2580
2580
  for (let c of this.outlet) {
2581
2581
  if (c.cleanup) {
2582
- c.cleanup();
2582
+ promises.push(c.cleanup());
2583
2583
  }
2584
2584
  }
2585
2585
  }
2586
2586
  if (((_c = this.props) == null ? void 0 : _c.children) !== void 0) {
2587
2587
  for (let c of this.props.children) {
2588
2588
  if (c.cleanup) {
2589
- c.cleanup();
2589
+ promises.push(c.cleanup());
2590
2590
  }
2591
2591
  }
2592
2592
  }
2593
2593
  if (this.hooks !== void 0) {
2594
2594
  for (let h of this.hooks) {
2595
2595
  if (h.cleanup) {
2596
- h.cleanup();
2596
+ promises.push(h.cleanup());
2597
2597
  }
2598
2598
  }
2599
2599
  }
2600
+ await Promise.all(promises);
2600
2601
  } catch (e) {
2601
2602
  throw e;
2602
2603
  }
@@ -2627,7 +2628,7 @@ var ComponentCore = class {
2627
2628
  if (events_set.has(al)) {
2628
2629
  this.event_detachers[al]();
2629
2630
  } else {
2630
- this.element.setAttribute(a, void 0);
2631
+ this.element.removeAttribute(a);
2631
2632
  }
2632
2633
  }
2633
2634
  }
@@ -2670,6 +2671,7 @@ var ComponentCore = class {
2670
2671
  }
2671
2672
  } else if (boolean_html_attributes_set.has(a)) {
2672
2673
  this.element[a] = toBool(patch[a]);
2674
+ if (!this.element[a]) this.element.removeAttribute(a);
2673
2675
  } else if (a === "autoFocus") {
2674
2676
  this.element["autofocus"] = toBool(patch[a]);
2675
2677
  } else if (a === "htmlFor") {
@@ -3443,7 +3445,7 @@ function useRef(initialValue = null) {
3443
3445
  return hk;
3444
3446
  }
3445
3447
  async function useLayoutEffect(effect, deps = void 0) {
3446
- if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3448
+ if (deps !== void 0 && (typeof deps !== "object" && deps.constructor.name !== "Array")) {
3447
3449
  throw new Error("Layout effect dependencies must be an array, object or omitted.");
3448
3450
  }
3449
3451
  const hk = useHook();
@@ -3452,6 +3454,7 @@ async function useLayoutEffect(effect, deps = void 0) {
3452
3454
  }
3453
3455
  if (hk == null ? void 0 : hk.cleanup) {
3454
3456
  await hk.cleanup();
3457
+ hk.cleanup = void 0;
3455
3458
  }
3456
3459
  hk.deps = deps;
3457
3460
  lilact_default.layout_effects.add(async () => {
@@ -3461,7 +3464,7 @@ async function useLayoutEffect(effect, deps = void 0) {
3461
3464
  lilact_default.setTimeout(lilact_default.processEffects, 0);
3462
3465
  }
3463
3466
  async function useEffect(effect, deps = void 0) {
3464
- if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3467
+ if (deps !== void 0 && (typeof deps !== "object" && deps.constructor.name !== "Array")) {
3465
3468
  throw new Error("Effect dependencies must be an array, object or omitted.");
3466
3469
  }
3467
3470
  const hk = useHook();
@@ -3470,6 +3473,7 @@ async function useEffect(effect, deps = void 0) {
3470
3473
  }
3471
3474
  if (hk == null ? void 0 : hk.cleanup) {
3472
3475
  await hk.cleanup();
3476
+ hk.cleanup = void 0;
3473
3477
  }
3474
3478
  hk.deps = deps;
3475
3479
  lilact_default.passive_effects.add(async () => {
@@ -3479,7 +3483,7 @@ async function useEffect(effect, deps = void 0) {
3479
3483
  lilact_default.setTimeout(lilact_default.processEffects, 0);
3480
3484
  }
3481
3485
  async function useInsertionEffect(effect, deps = void 0) {
3482
- if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3486
+ if (deps !== void 0 && (typeof deps !== "object" && deps.constructor.name !== "Array")) {
3483
3487
  throw new Error("Insertion effect dependencies must be an array, object, or omitted.");
3484
3488
  }
3485
3489
  const hk = useHook();
@@ -3488,6 +3492,7 @@ async function useInsertionEffect(effect, deps = void 0) {
3488
3492
  }
3489
3493
  if (hk == null ? void 0 : hk.cleanup) {
3490
3494
  await hk.cleanup();
3495
+ hk.cleanup = void 0;
3491
3496
  }
3492
3497
  hk.deps = deps;
3493
3498
  lilact_default.insertion_effects.add(async () => {
@@ -3497,7 +3502,7 @@ async function useInsertionEffect(effect, deps = void 0) {
3497
3502
  lilact_default.setTimeout(lilact_default.processEffects, 0);
3498
3503
  }
3499
3504
  function useMemo(factory, deps = void 0) {
3500
- if (deps !== void 0 && (typeof deps !== "object" || deps.constructor.name !== "Array")) {
3505
+ if (deps !== void 0 && (typeof deps !== "object" && deps.constructor.name !== "Array")) {
3501
3506
  throw new Error("Memo dependencies must be an array or omitted.");
3502
3507
  }
3503
3508
  const hk = useHook();
@@ -3601,181 +3606,242 @@ __export(run_exports, {
3601
3606
  runScripts: () => runScripts
3602
3607
  });
3603
3608
  function joinPaths(basePath, relativePath) {
3604
- const isAbs = relativePath.startsWith("/");
3605
- const stack = [];
3606
- const parts = (isAbs ? "" : basePath).split("/").filter(Boolean);
3607
- for (const p of parts) stack.push(p);
3608
- if (!basePath.endsWith("/")) stack.pop();
3609
- const relParts = relativePath.split("/");
3610
- for (const p of relParts) {
3611
- if (p === "" || p === ".") continue;
3612
- if (p === "..") {
3613
- if (stack.length > 0) stack.pop();
3614
- } else {
3615
- stack.push(p);
3609
+ const absolute = relativePath.startsWith("/");
3610
+ const parts = (absolute ? "" : basePath).split("/").filter(Boolean);
3611
+ if (!absolute && !basePath.endsWith("/")) parts.pop();
3612
+ for (const part of relativePath.split("/")) {
3613
+ if (!part || part === ".") continue;
3614
+ if (part === "..") parts.pop();
3615
+ else parts.push(part);
3616
+ }
3617
+ return `${absolute ? "/" : ""}${parts.join("/")}`;
3618
+ }
3619
+ function asError(value, fallback = "Unknown error") {
3620
+ if (value instanceof Error) return value;
3621
+ if ((value == null ? void 0 : value.error) instanceof Error) return value.error;
3622
+ const error2 = new Error(
3623
+ (value == null ? void 0 : value.message) == null ? fallback : String(value.message)
3624
+ );
3625
+ if (value && typeof value === "object") {
3626
+ if (value.name) error2.name = value.name;
3627
+ if (value.stack) error2.stack = value.stack;
3628
+ for (const key of Object.keys(value)) {
3629
+ if (!(key in error2)) error2[key] = value[key];
3616
3630
  }
3617
3631
  }
3618
- return (isAbs ? "/" : "") + stack.join("/");
3632
+ return error2;
3633
+ }
3634
+ function markSource(value, path2) {
3635
+ const error2 = asError(value);
3636
+ if (!error2.lilact_source) {
3637
+ error2.lilact_source = { path: path2 };
3638
+ }
3639
+ return error2;
3640
+ }
3641
+ function report(value, path2) {
3642
+ const error2 = markSource(value, path2);
3643
+ if (error2.isTraced) return error2;
3644
+ if (typeof lilact_default.traceError === "function") {
3645
+ return lilact_default.traceError(error2, path2);
3646
+ }
3647
+ lilact_default.error = error2;
3648
+ return error2;
3619
3649
  }
3620
3650
  var required_scripts = {};
3621
- function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, { isInline, isModule } = { isInline: true, isModule: true }) {
3622
- const mappings = [];
3651
+ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3652
+ isInline = true,
3653
+ isModule = true
3654
+ } = {}) {
3655
+ var _a, _b;
3623
3656
  const module = {
3624
- mappings,
3625
- isInline,
3626
3657
  path,
3627
- code: jsx,
3628
- exports: {}
3658
+ code: String(jsx),
3659
+ mappings: [],
3660
+ exports: {},
3661
+ isInline,
3662
+ isModule
3629
3663
  };
3630
- let processed;
3631
3664
  required_scripts[path] = module;
3665
+ let processed;
3632
3666
  try {
3633
- processed = lilact_default.transpileJSX(
3634
- jsx,
3635
- {
3636
- path,
3637
- mappings,
3638
- factory: "createComponent",
3639
- appendSourcemap: false,
3640
- injectTraceLabels: true,
3641
- produceCJS: true,
3642
- blocks_info: lilact_default.blocks_info
3643
- }
3644
- );
3645
- } catch (e) {
3646
- lilact_default.error = e;
3647
- throw e;
3667
+ processed = lilact_default.transpileJSX(String(jsx), {
3668
+ path,
3669
+ mappings: module.mappings,
3670
+ factory: "createComponent",
3671
+ appendSourcemap: false,
3672
+ injectTraceLabels: true,
3673
+ produceCJS: true,
3674
+ blocks_info: lilact_default.blocks_info
3675
+ });
3676
+ } catch (value) {
3677
+ const error2 = asError(value);
3678
+ (_a = error2.fileName) != null ? _a : error2.fileName = path;
3679
+ error2.sourcePhase = "transpile";
3680
+ module.error = error2;
3681
+ lilact_default.error = error2;
3682
+ throw error2;
3648
3683
  }
3649
- if (true) {
3650
- required_scripts[path].processed = processed;
3684
+ if (typeof lilact_default.scanBlockLabels === "function") {
3685
+ lilact_default.scanBlockLabels(processed, path);
3651
3686
  }
3652
- processed += "\n//# sourceURL=eval:/" + path;
3653
- lilact_default.scanBlockLabels(processed, path);
3687
+ processed += `
3688
+ //# sourceURL=eval:/${path}`;
3654
3689
  try {
3655
3690
  globalThis.Lilact = lilact_default;
3656
3691
  globalThis.createComponent = lilact_default.createComponent;
3657
3692
  globalThis.Fragment = lilact_default.Fragment;
3658
- const res = eval(processed);
3659
- if (!isEmpty(module.exports)) return module.exports;
3660
- return res;
3661
- } catch (e) {
3662
- e = lilact_default.traceError(e, path);
3663
- throw e;
3693
+ const result = eval(processed);
3694
+ return isEmpty(module.exports) ? result : module.exports;
3695
+ } catch (value) {
3696
+ const error2 = report(value, path);
3697
+ (_b = error2.sourcePhase) != null ? _b : error2.sourcePhase = "runtime";
3698
+ module.error = error2;
3699
+ throw error2;
3664
3700
  }
3665
3701
  }
3666
3702
  function require2(path2) {
3667
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3668
- let forceUpdate, checkExport, requirer, isLazy;
3669
- if (arguments.length === 2 && typeof (arguments[1] === "object")) {
3670
- forceUpdate = (_a = arguments[1]) == null ? void 0 : _a.forceUpdate;
3671
- checkExport = (_b = arguments[1]) == null ? void 0 : _b.checkExport;
3672
- requirer = (_c = arguments[1]) == null ? void 0 : _c.requirer;
3673
- isLazy = (_d = arguments[1]) == null ? void 0 : _d.isLazy;
3674
- }
3675
- if ((_e = lilact_default.importObjectPaths) == null ? void 0 : _e[path2]) return lilact_default.importObjectPaths[path2];
3676
- if (required_scripts[path2] && !forceUpdate) return required_scripts[path2].exports;
3677
- if (path2[0] === "#") {
3678
- const el = document.getElementById(path2);
3679
- if (el) {
3680
- return run(el.innerText, path2);
3681
- }
3682
- throw new Error(`Required element not found (${path2})`);
3683
- } else {
3684
- if (requirer && requirer.path) {
3685
- path2 = joinPaths(requirer.path, path2);
3686
- }
3687
- if (((_f = lilact_default) == null ? void 0 : _f[LAZY]) || isLazy) {
3688
- lilact_default[LAZY] = false;
3689
- let p = (_h = (_g = lilact_default).resolver) == null ? void 0 : _h.call(_g, path2);
3690
- if (p) {
3691
- p = Promise.resolve(p);
3703
+ var _a, _b, _c, _d, _e, _f;
3704
+ let options = {};
3705
+ if (arguments.length === 2 && arguments[1] && typeof arguments[1] === "object") {
3706
+ options = arguments[1];
3707
+ }
3708
+ if ((_a = lilact_default.importObjectPaths) == null ? void 0 : _a[path2]) {
3709
+ return lilact_default.importObjectPaths[path2];
3710
+ }
3711
+ const loadAsync = Boolean(lilact_default[LAZY]) || Boolean(options.isLazy);
3712
+ if ((_b = options.requirer) == null ? void 0 : _b.path) {
3713
+ path2 = joinPaths(options.requirer.path, path2);
3714
+ }
3715
+ if (required_scripts[path2] && !options.forceUpdate && !loadAsync) {
3716
+ return required_scripts[path2].exports;
3717
+ }
3718
+ if (path2.startsWith("#")) {
3719
+ const element = document.getElementById(path2.slice(1));
3720
+ if (!element) {
3721
+ throw report(
3722
+ new Error(`Required element not found (${path2})`),
3723
+ path2
3724
+ );
3725
+ }
3726
+ return run(element.textContent || "", path2);
3727
+ }
3728
+ if (loadAsync) {
3729
+ lilact_default[LAZY] = false;
3730
+ let request2 = (_d = (_c = lilact_default).resolver) == null ? void 0 : _d.call(_c, path2);
3731
+ if (request2 == null) {
3732
+ if (required_scripts[path2] && !options.forceUpdate) {
3733
+ request2 = Promise.resolve(required_scripts[path2].code);
3692
3734
  } else {
3693
- p = fetch(path2).then((res2) => {
3694
- if (!res2.ok) throw new Error(`HTTP ${res2.status}`);
3695
- return res2.text();
3735
+ request2 = fetch(path2).then((response) => {
3736
+ if (!response.ok) {
3737
+ throw report(
3738
+ new Error(
3739
+ `Unable to load ${path2}: HTTP ${response.status}`
3740
+ ),
3741
+ path2
3742
+ );
3743
+ }
3744
+ return response.text();
3696
3745
  });
3697
3746
  }
3698
- return p.then((res2) => {
3699
- var _a2;
3700
- if (path2.endsWith(".css")) {
3701
- injectGlobal(res2);
3702
- return;
3703
- }
3704
- res2 = run(res2, path2, { isInline: false });
3705
- return (_a2 = res2 == null ? void 0 : res2.default) != null ? _a2 : res2;
3706
- }).catch((err) => {
3707
- throw err;
3708
- });
3709
3747
  } else {
3710
- const p = (_j = (_i = lilact_default).resolver) == null ? void 0 : _j.call(_i, path2);
3711
- if (p) {
3712
- if (path2.endsWith(".css")) {
3713
- injectGlobal(p);
3714
- return;
3715
- }
3716
- return run(p, path2, { isInline: false });
3717
- } else {
3718
- const request = new XMLHttpRequest();
3719
- request.open("GET", path2, false);
3720
- request.send(null);
3721
- if (request.status === 200) {
3722
- if (path2.endsWith(".css")) {
3723
- injectGlobal(res);
3724
- return;
3725
- }
3726
- return run(request.responseText, path2, { isInline: false });
3727
- }
3748
+ request2 = Promise.resolve(request2);
3749
+ }
3750
+ return request2.then((source) => {
3751
+ if (path2.endsWith(".css")) {
3752
+ injectGlobal(String(source));
3753
+ return;
3754
+ }
3755
+ return run(String(source), path2, {
3756
+ isInline: false,
3757
+ isModule: true
3758
+ });
3759
+ }).then(
3760
+ (result2) => {
3761
+ var _a2;
3762
+ return (_a2 = result2 == null ? void 0 : result2.default) != null ? _a2 : result2;
3728
3763
  }
3764
+ ).catch((error2) => {
3765
+ throw report(error2, path2);
3766
+ });
3767
+ }
3768
+ const resolved = (_f = (_e = lilact_default).resolver) == null ? void 0 : _f.call(_e, path2);
3769
+ if (resolved != null) {
3770
+ if (path2.endsWith(".css")) {
3771
+ injectGlobal(String(resolved));
3772
+ return;
3729
3773
  }
3774
+ return run(String(resolved), path2, {
3775
+ isInline: false,
3776
+ isModule: true
3777
+ });
3730
3778
  }
3731
- throw new Error(`Required resource not found (${path2})`);
3779
+ const request = new XMLHttpRequest();
3780
+ try {
3781
+ request.open("GET", path2, false);
3782
+ request.send(null);
3783
+ } catch (value) {
3784
+ throw report(value, path2);
3785
+ }
3786
+ if (request.status >= 200 && request.status < 300) {
3787
+ if (path2.endsWith(".css")) {
3788
+ injectGlobal(request.responseText);
3789
+ return;
3790
+ }
3791
+ return run(request.responseText, path2, {
3792
+ isInline: false,
3793
+ isModule: true
3794
+ });
3795
+ }
3796
+ throw report(
3797
+ new Error(`Unable to load ${path2}: HTTP ${request.status || 0}`),
3798
+ path2
3799
+ );
3732
3800
  }
3733
3801
  function lazy(factory) {
3734
3802
  let status = "pending";
3735
- let result;
3803
+ let result2;
3736
3804
  lilact_default[LAZY] = true;
3737
- result = factory();
3738
- if (lilact_default.isThenable(result)) {
3739
- result.then(
3740
- (mod) => {
3805
+ try {
3806
+ result2 = factory();
3807
+ } catch (error2) {
3808
+ status = "error";
3809
+ result2 = error2;
3810
+ }
3811
+ if (lilact_default.isThenable(result2)) {
3812
+ result2.then(
3813
+ (value) => {
3741
3814
  status = "success";
3742
- result = mod;
3743
- return result;
3815
+ result2 = value;
3744
3816
  },
3745
- (err) => {
3817
+ (error2) => {
3746
3818
  status = "error";
3747
- result = err;
3748
- throw err;
3819
+ result2 = error2;
3749
3820
  }
3750
3821
  );
3751
- } else {
3822
+ } else if (status !== "error") {
3752
3823
  status = "success";
3753
3824
  }
3754
3825
  function LazyComponent(props) {
3755
- if (status === "pending") throw result;
3756
- if (status === "error") throw result;
3757
- const Component2 = result;
3826
+ if (status === "pending") throw result2;
3827
+ if (status === "error") throw result2;
3828
+ const Component2 = result2;
3758
3829
  return createComponent(Component2, { ...props });
3759
3830
  }
3760
3831
  return LazyComponent;
3761
3832
  }
3762
- function scanScriptTagsWithType() {
3763
- const scripts = Array.from(
3833
+ function scriptTags() {
3834
+ return Array.from(
3764
3835
  document.querySelectorAll('script[type="text/jsx"]')
3765
- );
3766
- return scripts.map((el) => {
3767
- var _a, _b;
3768
- return {
3769
- src: (_a = el.getAttribute("src")) != null ? _a : null,
3770
- content: (_b = el.textContent) != null ? _b : ""
3771
- };
3772
- });
3836
+ ).map((element) => ({
3837
+ src: element.getAttribute("src"),
3838
+ content: element.textContent || ""
3839
+ }));
3773
3840
  }
3774
3841
  function runScripts() {
3775
- const scripts = scanScriptTagsWithType();
3776
- for (const s of scripts) {
3777
- if (s.src) require2(s.src);
3778
- if (s.content) run(s.content);
3842
+ for (const script of scriptTags()) {
3843
+ if (script.src) require2(script.src);
3844
+ if (script.content) run(script.content);
3779
3845
  }
3780
3846
  }
3781
3847
 
@@ -3922,8 +3988,8 @@ function releaseTimers() {
3922
3988
  }
3923
3989
  function timeoutPromise(duration = 0, timerSource = Lilact) {
3924
3990
  let id, resolve, reject;
3925
- const promise = new Promise((res2, rej) => {
3926
- resolve = res2;
3991
+ const promise = new Promise((res, rej) => {
3992
+ resolve = res;
3927
3993
  reject = rej;
3928
3994
  id = timerSource.setTimeout(() => {
3929
3995
  resolve();
@@ -4331,8 +4397,8 @@ function wrapListener(fn, opts = {}) {
4331
4397
  const currentTarget = this || nativeEvent.currentTarget || null;
4332
4398
  const sEvent = createSyntheticEvent(nativeEvent, currentTarget);
4333
4399
  try {
4334
- const result = fn(sEvent);
4335
- if (stopPropagationOnTrueReturn && result === true) {
4400
+ const result2 = fn(sEvent);
4401
+ if (stopPropagationOnTrueReturn && result2 === true) {
4336
4402
  sEvent.stopPropagation();
4337
4403
  }
4338
4404
  } finally {
@@ -4450,163 +4516,232 @@ __export(errors_exports, {
4450
4516
  scanBlockLabels: () => scanBlockLabels,
4451
4517
  traceError: () => traceError
4452
4518
  });
4453
- function getErrorLocation(err) {
4454
- if (err.lineno !== void 0 || err.line !== void 0 || err.lineNumber !== void 0) {
4455
- const l = err.lineNumber || err.lineno || err.line;
4456
- const c = err.columnNumber || err.colno || err.column;
4457
- return { line: l, col: c };
4458
- }
4459
- let match2 = /:(\d+):(\d+)[\n].*/m.exec(err.stack);
4460
- if (match2 === null) {
4461
- match2 = /:(\d+):(\d+)\)\s+at .*/m.exec(err.stack);
4519
+ function number(value) {
4520
+ const result2 = Number(value);
4521
+ return Number.isFinite(result2) ? result2 : null;
4522
+ }
4523
+ function asError2(value) {
4524
+ if (value instanceof Error) return value;
4525
+ if ((value == null ? void 0 : value.error) instanceof Error) return value.error;
4526
+ const error2 = new Error(
4527
+ (value == null ? void 0 : value.message) == null ? String(value) : String(value.message)
4528
+ );
4529
+ if (value && typeof value === "object") {
4530
+ if (value.name) error2.name = value.name;
4531
+ if (value.stack) error2.stack = value.stack;
4532
+ for (const key of Object.keys(value)) {
4533
+ if (!(key in error2)) error2[key] = value[key];
4534
+ }
4462
4535
  }
4463
- if (match2) {
4464
- return { line: parseInt(match2[1]), col: parseInt(match2[2]) };
4536
+ return error2;
4537
+ }
4538
+ function isParserError(error2) {
4539
+ return (error2 == null ? void 0 : error2.name) === "JSXParserError";
4540
+ }
4541
+ function stackLocation(stack) {
4542
+ if (typeof stack !== "string") return null;
4543
+ for (const line2 of stack.split(/\r?\n/)) {
4544
+ const match2 = line2.match(/(eval:\/.*):(\d+):(\d+)/);
4545
+ if (!match2) continue;
4546
+ return {
4547
+ path: match2[1].replace(/^eval:\/+/, ""),
4548
+ line: Number(match2[2]) - 1,
4549
+ column: Number(match2[3]) - 1
4550
+ };
4465
4551
  }
4466
4552
  return null;
4467
4553
  }
4468
- function parseEvalLocationFromStack(stack, urlPrefix = "eval:/") {
4469
- const raw = typeof stack === "string" ? stack : String(stack || "");
4470
- const lines = raw.split(/\r?\n/);
4471
- const re = new RegExp(`\\(?((?:${escapeRegExp(urlPrefix)})[^\\s):]+):(\\d+):(?:(\\d+))?\\)?$`);
4472
- for (const l of lines) {
4473
- const line2 = l.trim();
4474
- if (!line2.includes(urlPrefix)) continue;
4475
- const m = line2.match(re);
4476
- if (!m) continue;
4477
- const url = m[1];
4478
- const parsedLine = Number(m[2]);
4479
- const parsedCol = m[3] == null ? null : Number(m[3]);
4480
- if (Number.isFinite(parsedLine) && (parsedCol === null || Number.isFinite(parsedCol))) {
4481
- return { url, line: parsedLine, col: parsedCol, matched: line2 };
4482
- }
4483
- }
4484
- return { url: null, line: null, col: null, matched: null, stackPreview: lines.slice(0, 6).join("\n") };
4485
- }
4486
- function escapeRegExp(s) {
4487
- return String(s).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4488
- }
4489
- function mapLocation(mps, r, c) {
4490
- let map = null;
4491
- for (const i2 in mps) {
4492
- if (mps[i2][0] < r) continue;
4493
- if (mps[i2][0] > r || mps[i2][0] === r && mps[i2][1] >= c) {
4494
- map = mps[i2 - 1];
4554
+ function browserLocation(error2) {
4555
+ var _a, _b, _c, _d;
4556
+ const line2 = number(
4557
+ (_b = (_a = error2 == null ? void 0 : error2.lineNumber) != null ? _a : error2 == null ? void 0 : error2.lineno) != null ? _b : error2 == null ? void 0 : error2.line
4558
+ );
4559
+ const column2 = number(
4560
+ (_d = (_c = error2 == null ? void 0 : error2.columnNumber) != null ? _c : error2 == null ? void 0 : error2.colno) != null ? _d : error2 == null ? void 0 : error2.column
4561
+ );
4562
+ return {
4563
+ line: line2 == null ? null : Math.max(0, line2 - 1),
4564
+ column: column2 == null ? null : Math.max(0, column2 - 1)
4565
+ };
4566
+ }
4567
+ function traceBlock(error2) {
4568
+ const trace = error2 == null ? void 0 : error2.lilact_trace;
4569
+ return Array.isArray(trace) ? trace[0] : trace;
4570
+ }
4571
+ function blockInfo(error2) {
4572
+ var _a, _b;
4573
+ const trace = traceBlock(error2);
4574
+ return trace == null ? null : (_b = (_a = lilact_default.blocks_info) == null ? void 0 : _a.labels) == null ? void 0 : _b[trace];
4575
+ }
4576
+ function mapLocation(mappings, line2, column2) {
4577
+ if (!Array.isArray(mappings) || !mappings.length || !Number.isFinite(line2) || !Number.isFinite(column2)) {
4578
+ return { line: line2, column: column2 };
4579
+ }
4580
+ const valid = mappings.filter(
4581
+ (mapping) => Array.isArray(mapping) && mapping.length >= 4 && mapping.slice(0, 4).every((value) => Number.isFinite(Number(value)))
4582
+ ).sort(
4583
+ (a, b2) => Number(a[0]) - Number(b2[0]) || Number(a[1]) - Number(b2[1])
4584
+ );
4585
+ if (!valid.length) return { line: line2, column: column2 };
4586
+ let selected = valid[0];
4587
+ for (const mapping of valid) {
4588
+ const generatedLine2 = Number(mapping[0]);
4589
+ const generatedColumn2 = Number(mapping[1]);
4590
+ if (generatedLine2 < line2 || generatedLine2 === line2 && generatedColumn2 <= column2) {
4591
+ selected = mapping;
4592
+ } else {
4495
4593
  break;
4496
4594
  }
4497
4595
  }
4498
- if (!map) map = mps[mps.length - 1];
4499
- return { line: r - map[0] + map[2], col: r - map[0] === 0 ? map[3] : 0 };
4500
- }
4501
- function scanBlockLabels(code2, path2) {
4502
- const ls = Array.from(code2.matchAll(/LILACTBLOCK(\d+):(\d+),(\d+):([^*]+)\*\//mg));
4503
- ls.forEach(
4504
- (x) => {
4505
- lilact_default.blocks_info.labels[x[1]] = {
4506
- path: path2,
4507
- desc: x[4]
4508
- };
4509
- }
4510
- );
4596
+ const generatedLine = Number(selected[0]);
4597
+ const generatedColumn = Number(selected[1]);
4598
+ const sourceLine = Number(selected[2]);
4599
+ const sourceColumn = Number(selected[3]);
4600
+ return {
4601
+ line: sourceLine + (line2 === generatedLine ? 0 : line2 - generatedLine),
4602
+ column: line2 === generatedLine ? Math.max(0, sourceColumn + column2 - generatedColumn) : sourceColumn
4603
+ };
4511
4604
  }
4512
- function traceError(error2, run_path) {
4513
- var _a;
4514
- if (error2 == null ? void 0 : error2.is_traced) {
4515
- return error2;
4516
- }
4517
- const loc = parseEvalLocationFromStack(error2.stack);
4518
- const obj = {
4519
- fileName: ((_a = loc.url) == null ? void 0 : _a.slice(6)) || run_path || error2.fileName,
4520
- lineNumber: loc.line,
4521
- columnNumber: loc.col,
4522
- message: error2.message,
4523
- name: error2.name,
4524
- stack: error2.stack,
4605
+ function traceError(value, runPath) {
4606
+ var _a, _b, _c, _d, _e, _f;
4607
+ if (value == null ? void 0 : value.isTraced) return value;
4608
+ const error2 = asError2(value);
4609
+ const source = error2.lilact_source;
4610
+ const stack = isParserError(error2) ? null : stackLocation(error2.stack);
4611
+ const browser = isParserError(error2) ? {
4612
+ line: number(error2.lineNumber),
4613
+ column: number(error2.columnNumber)
4614
+ } : browserLocation(error2);
4615
+ const fileName = (source == null ? void 0 : source.path) || (stack == null ? void 0 : stack.path) || error2.fileName || runPath || null;
4616
+ let line2 = (_b = (_a = stack == null ? void 0 : stack.line) != null ? _a : browser.line) != null ? _b : null;
4617
+ let column2 = (_d = (_c = stack == null ? void 0 : stack.column) != null ? _c : browser.column) != null ? _d : null;
4618
+ const result2 = {
4619
+ fileName,
4620
+ lineNumber: line2,
4621
+ columnNumber: column2,
4622
+ message: error2.message == null ? String(error2) : String(error2.message),
4623
+ name: error2.name || "Error",
4624
+ stack: error2.stack || null,
4625
+ lilact_source: source || null,
4525
4626
  _error: error2,
4526
- is_traced: true
4627
+ isTraced: true
4527
4628
  };
4528
- if (error2.name !== "JSXParseError") {
4529
- let mps;
4530
- if (loc.url) {
4531
- const rm = required_scripts[obj.fileName];
4532
- mps = rm.mappings;
4533
- const mloc = mapLocation(mps, obj.lineNumber - 1, obj.columnNumber - 1);
4534
- obj.lineNumber = mloc.line;
4535
- obj.columnNumber = mloc.col;
4536
- } else {
4537
- let loc2 = getErrorLocation(error2);
4538
- if (error2.lilact_trace !== void 0) {
4539
- let mps2;
4540
- let blk;
4541
- if (typeof error2.lilact_trace === "object") {
4542
- blk = lilact_default.blocks_info.labels[error2.lilact_trace[0]];
4543
- } else {
4544
- blk = lilact_default.blocks_info.labels[error2.lilact_trace];
4545
- }
4546
- if (blk) {
4547
- obj.fileName = blk.path;
4548
- obj.label = blk.label;
4549
- mps2 = required_scripts[blk.path].mappings;
4550
- loc2 = mapLocation(mps2, loc2.line - 1, loc2.col - 1);
4551
- }
4552
- }
4553
- obj.lineNumber = loc2.line;
4554
- obj.columnNumber = loc2.col;
4629
+ const module2 = fileName && required_scripts[fileName];
4630
+ if (module2) {
4631
+ const mapped = mapLocation(
4632
+ module2.mappings,
4633
+ result2.lineNumber,
4634
+ result2.columnNumber
4635
+ );
4636
+ result2.lineNumber = mapped.line;
4637
+ result2.columnNumber = mapped.column;
4638
+ }
4639
+ const block = blockInfo(error2);
4640
+ if (block && (result2.lineNumber == null || result2.columnNumber == null || !result2.fileName)) {
4641
+ result2.fileName || (result2.fileName = block.path || runPath || null);
4642
+ (_e = result2.lineNumber) != null ? _e : result2.lineNumber = block.line;
4643
+ (_f = result2.columnNumber) != null ? _f : result2.columnNumber = block.col;
4644
+ result2.label = block.desc;
4645
+ }
4646
+ lilact_default.error = result2;
4647
+ return result2;
4648
+ }
4649
+ function escapeHtml(value) {
4650
+ return String(value != null ? value : "").replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
4651
+ }
4652
+ function sourceExcerpt(module2, line2) {
4653
+ var _a, _b, _c, _d;
4654
+ if (!module2 || !Number.isFinite(line2)) return null;
4655
+ const lines = String((_a = module2.code) != null ? _a : "").split(/\r?\n/);
4656
+ return {
4657
+ before: (_b = lines[line2 - 1]) != null ? _b : "",
4658
+ current: (_c = lines[line2]) != null ? _c : "",
4659
+ after: (_d = lines[line2 + 1]) != null ? _d : ""
4660
+ };
4661
+ }
4662
+ function globalErrorHandler(eventOrError) {
4663
+ var _a, _b;
4664
+ const value = (eventOrError == null ? void 0 : eventOrError.error) instanceof Error ? eventOrError.error : (eventOrError == null ? void 0 : eventOrError.reason) !== void 0 ? eventOrError.reason : eventOrError;
4665
+ const error2 = traceError(
4666
+ value,
4667
+ (eventOrError == null ? void 0 : eventOrError.fileName) || null
4668
+ );
4669
+ const excerpt = sourceExcerpt(
4670
+ required_scripts[error2.fileName],
4671
+ error2.lineNumber
4672
+ );
4673
+ const className = css(`
4674
+ background: linear-gradient(135deg, #fff2f2d4, #ffffffd4);
4675
+ backdrop-filter: blur(10px);
4676
+ border: 1px solid rgba(255,255,255,.25);
4677
+ border-radius: 5px;
4678
+ box-shadow: 0 10px 30px rgba(0,0,0,.35);
4679
+ overflow: hidden;
4680
+ min-width: 400px;
4681
+ width: 66%;
4682
+
4683
+ red {
4684
+ color: #d00;
4555
4685
  }
4686
+
4687
+ code {
4688
+ border: 1px solid #0003;
4689
+ overflow: auto;
4690
+ padding: 10px;
4691
+ display: block;
4692
+ }
4693
+ `);
4694
+ const dialog = document.createElement("dialog");
4695
+ dialog.className = className;
4696
+ const location = error2.fileName ? `At ${escapeHtml(error2.fileName)}` : "";
4697
+ const line2 = Number.isFinite(error2.lineNumber) ? `: Line ${error2.lineNumber + 1}` : "";
4698
+ const componentStack = ((_a = error2._error) == null ? void 0 : _a.componentStackLog) || ((_b = error2._error) == null ? void 0 : _b.componentStack) || "";
4699
+ dialog.innerHTML = `
4700
+ <h3><red>Error!</red></h3>
4701
+ <b>${location}${line2}</b><br><br>
4702
+ <b>${escapeHtml(error2.name)}</b>:
4703
+ <span>${escapeHtml(error2.message)}</span>
4704
+ <br><br>
4705
+
4706
+ ${excerpt ? "<code><pre></pre><red><pre></pre></red><pre></pre></code>" : ""}
4707
+
4708
+ ${componentStack ? `
4709
+ <br>
4710
+ Component Stack:
4711
+ <br>
4712
+ <code><pre>${escapeHtml(componentStack)}</pre></code>
4713
+ ` : ""}
4714
+ `;
4715
+ if (excerpt) {
4716
+ const pre = dialog.querySelectorAll("pre");
4717
+ pre[0].innerText = excerpt.before;
4718
+ pre[1].innerText = excerpt.current;
4719
+ pre[2].innerText = excerpt.after;
4720
+ }
4721
+ document.body.appendChild(dialog);
4722
+ if (typeof dialog.showModal === "function") {
4723
+ dialog.showModal();
4556
4724
  } else {
4557
- const loc2 = getErrorLocation(error2);
4558
- if (error2.fileName) obj.fileName = error2.fileName;
4559
- else if (run_path) obj.fileName = run_path;
4560
- obj.lineNumber = loc2.line;
4561
- obj.columnNumber = loc2.col;
4562
- }
4563
- lilact_default.error = obj;
4564
- return obj;
4565
- }
4566
- function globalErrorHandler(error2) {
4567
- if (error2.error) error2 = error2.error;
4568
- error2 = traceError(error2);
4569
- const cls = css(`
4570
- background: linear-gradient(135deg, #fff2f2d4, #ffffffd4);
4571
- backdrop-filter: blur(10px);
4572
- border: 1px solid rgba(255,255,255,.25);
4573
- border-radius: 5px;
4574
- box-shadow: 0 10px 30px rgba(0,0,0,.35);
4575
- overflow:hidden;
4576
- min-width: 400px;
4577
- width: 66%;
4578
- red {
4579
- color:#d00;
4580
- }
4581
- code {
4582
- border: 1px solid #0003;
4583
- overflow: auto;
4584
- padding: 10px;
4585
- display: block;
4586
- }
4587
- `);
4588
- const el = document.createElement("dialog");
4589
- el.className = cls;
4590
- el.innerHTML = `<h3 style=""><red>Error!</red></h3>
4591
- <b>${error2.fileName ? "At " + error2.fileName : ""}
4592
- ${Number.isFinite(error2.lineNumber) ? ": Line " + (error2.lineNumber + 1) : ""}</b><br><br>
4593
- <b>${error2.name}</b>:&nbsp;<span>${error2.message}</span><br><br>
4594
- ${required_scripts[error2.fileName] ? "<code><pre></pre><pre><red></red></pre><pre></pre></code>" : ""}
4595
- ${error2._error.componentStackLog ? "<br>Component Stack:<br><code><pre>" + error2._error.componentStackLog + "</pre></code>" : ""}
4596
- `;
4597
- document.body.appendChild(el);
4598
- const pres = el.querySelectorAll("pre");
4599
- if (required_scripts[error2.fileName]) {
4600
- const lines = required_scripts[error2.fileName].code.split("\n");
4601
- if (lines == null ? void 0 : lines[error2.lineNumber - 1])
4602
- pres[0].innerText = lines[error2.lineNumber - 1];
4603
- if (lines == null ? void 0 : lines[error2.lineNumber]) el.querySelector("pre red").innerText = lines[error2.lineNumber];
4604
- if (lines == null ? void 0 : lines[error2.lineNumber + 1])
4605
- pres[2].innerText = lines[error2.lineNumber + 1];
4606
- }
4607
- el.showModal();
4608
- }
4609
- var blocks_info = { counter: 0, labels: {} };
4725
+ dialog.setAttribute("open", "");
4726
+ }
4727
+ return error2;
4728
+ }
4729
+ function scanBlockLabels(code2, path2) {
4730
+ for (const match2 of String(code2).matchAll(
4731
+ /LILACTBLOCK(\d+):(\d+),(\d+):([^*]+)\*\//gm
4732
+ )) {
4733
+ lilact_default.blocks_info.labels[match2[1]] = {
4734
+ path: path2,
4735
+ line: Number(match2[2]),
4736
+ col: Number(match2[3]),
4737
+ desc: match2[4]
4738
+ };
4739
+ }
4740
+ }
4741
+ var blocks_info = {
4742
+ counter: 0,
4743
+ labels: {}
4744
+ };
4610
4745
  var error = null;
4611
4746
 
4612
4747
  // .tmp/src/router.jsx
@@ -4623,13 +4758,13 @@ __export(router_exports, {
4623
4758
  var RouterContext = createContext(null);
4624
4759
  var RouteContext = createContext({ params: {} });
4625
4760
  var createURL = (to) => typeof to === "string" ? to : (to.pathname || "") + (to.search || "") + (to.hash || "");
4626
- var escapeRegExp2 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4761
+ var escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4627
4762
  function HashRouter({ children, basename = "" }) {
4628
4763
  const readLocation = () => {
4629
4764
  var _a;
4630
4765
  const raw = window.location.hash || "#/";
4631
4766
  const full = raw.slice(1);
4632
- const baseRe = new RegExp("^" + escapeRegExp2(basename));
4767
+ const baseRe = new RegExp("^" + escapeRegExp(basename));
4633
4768
  const withoutBase = full.replace(baseRe, "") || "/";
4634
4769
  const [pathAndSearch, hashPart] = withoutBase.split("#");
4635
4770
  const [path2, search = ""] = pathAndSearch.split("?");
@@ -5306,14 +5441,14 @@ function encode(...value) {
5306
5441
  if (typeof value === "number") {
5307
5442
  return encode_integer(value);
5308
5443
  }
5309
- let result = "";
5444
+ let result2 = "";
5310
5445
  for (let i2 = 0; i2 < value.length; i2 += 1) {
5311
- result += encode_integer(value[i2]);
5446
+ result2 += encode_integer(value[i2]);
5312
5447
  }
5313
- return result;
5448
+ return result2;
5314
5449
  }
5315
5450
  function encode_integer(num) {
5316
- let result = "";
5451
+ let result2 = "";
5317
5452
  if (num < 0) {
5318
5453
  num = -num << 1 | 1;
5319
5454
  } else {
@@ -5325,9 +5460,9 @@ function encode_integer(num) {
5325
5460
  if (num > 0) {
5326
5461
  clamped |= 32;
5327
5462
  }
5328
- result += integer_to_char[clamped];
5463
+ result2 += integer_to_char[clamped];
5329
5464
  } while (num > 0);
5330
- return result;
5465
+ return result2;
5331
5466
  }
5332
5467
 
5333
5468
  // .tmp/src/expscan.js
@@ -5477,7 +5612,7 @@ function labeler(custom_words, x) {
5477
5612
  if (x.type === "comment") return "C";
5478
5613
  if (x.type === "regexp") return "R";
5479
5614
  if (x.type === "js") return "J";
5480
- if (x.type === "paranthesis") return "P";
5615
+ if (x.type === "parenthesis") return "P";
5481
5616
  if (x.type === "string") return "S";
5482
5617
  if (x.type === "xml") return "X";
5483
5618
  }
@@ -5776,7 +5911,7 @@ function lookAhead(f, code2, index2, ...args) {
5776
5911
  function parseRegex(code, index, container) {
5777
5912
  let i = index;
5778
5913
  let dels = `;=,([{}!^~&|:?*%-+/<>${transpilerConfig.preprocessorDelimiter}`;
5779
- while (--i > 0) {
5914
+ while (--i >= 0) {
5780
5915
  if (" \r".indexOf(code[i]) !== -1) continue;
5781
5916
  if (code[i] === "\n") {
5782
5917
  dels += ")]";
@@ -6122,8 +6257,8 @@ function parseXML(code2, index2, container2, look_behind = false) {
6122
6257
  index2++;
6123
6258
  skip_spaces();
6124
6259
  while (code2[index2] === "/") {
6125
- const res3 = lookAhead(parseComment, code2, index2);
6126
- if (res3[0] > index2) index2 = res3[0];
6260
+ const res2 = lookAhead(parseComment, code2, index2);
6261
+ if (res2[0] > index2) index2 = res2[0];
6127
6262
  else index2++;
6128
6263
  skip_spaces();
6129
6264
  }
@@ -6172,8 +6307,8 @@ function parseXML(code2, index2, container2, look_behind = false) {
6172
6307
  if (container2) container2.children.push(b2);
6173
6308
  return b2;
6174
6309
  }
6175
- const res2 = lookAhead(parseComment, code2, index2);
6176
- if (res2[0] > index2) index2 = res2[0];
6310
+ const res = lookAhead(parseComment, code2, index2);
6311
+ if (res[0] > index2) index2 = res[0];
6177
6312
  else index2++;
6178
6313
  break;
6179
6314
  case ">":
@@ -6198,10 +6333,10 @@ function parseXML(code2, index2, container2, look_behind = false) {
6198
6333
  }
6199
6334
  }
6200
6335
  }
6201
- function parseParanthesis(code2, index2, container2) {
6336
+ function parseParenthesis(code2, index2, container2) {
6202
6337
  const b2 = {
6203
6338
  // block
6204
- type: "paranthesis",
6339
+ type: "parenthesis",
6205
6340
  begin: index2,
6206
6341
  cbegin: ++index2,
6207
6342
  children: [],
@@ -6225,7 +6360,7 @@ function parseParanthesis(code2, index2, container2) {
6225
6360
  [index2] = lookAhead(parseJS, code2, index2, true, b2);
6226
6361
  break;
6227
6362
  case "(":
6228
- [index2] = lookAhead(parseParanthesis, code2, index2, b2);
6363
+ [index2] = lookAhead(parseParenthesis, code2, index2, b2);
6229
6364
  break;
6230
6365
  case "}":
6231
6366
  raiseError(`Unmatched curly bracket`, b2.begin);
@@ -6247,7 +6382,7 @@ function parseParanthesis(code2, index2, container2) {
6247
6382
  break;
6248
6383
  }
6249
6384
  }
6250
- raiseError(`Unterminated paranthesis block`, b2.begin);
6385
+ raiseError(`Unterminated parenthesis block`, b2.begin);
6251
6386
  }
6252
6387
  function parseJS(code2, index2 = 0, is_block = false, container2) {
6253
6388
  const b2 = {
@@ -6277,10 +6412,10 @@ function parseJS(code2, index2 = 0, is_block = false, container2) {
6277
6412
  break;
6278
6413
  }
6279
6414
  case "(":
6280
- [index2] = lookAhead(parseParanthesis, code2, index2, b2);
6415
+ [index2] = lookAhead(parseParenthesis, code2, index2, b2);
6281
6416
  break;
6282
6417
  case ")":
6283
- raiseError(`Unmatched paranthesis`, b2.begin);
6418
+ raiseError(`Unmatched parenthesis`, b2.begin);
6284
6419
  break;
6285
6420
  case "}":
6286
6421
  if (is_block) {
@@ -6332,7 +6467,7 @@ function labelFunctions(node3, eols, blocks_info2) {
6332
6467
  }
6333
6468
  let i2, nxt, prev2;
6334
6469
  for (let chi = 0; chi < node3.children.length; chi++) {
6335
- if (typeof node3.children[chi] === "object" && node3.children[chi].type === "paranthesis") {
6470
+ if (typeof node3.children[chi] === "object" && node3.children[chi].type === "parenthesis") {
6336
6471
  [i2, prev2] = getNext(chi, -1);
6337
6472
  if (prev2 === null) continue;
6338
6473
  if (typeof prev2 !== "string" || ["switch", "catch", "try", "class"].find((x) => prev2.trim().endsWith(x)) !== void 0) continue;
@@ -6354,7 +6489,7 @@ function labelFunctions(node3, eols, blocks_info2) {
6354
6489
  }
6355
6490
  } else if (node3.children[chi] === "=>") {
6356
6491
  [i2, prev2] = getNext(chi, -1);
6357
- if (typeof prev2 === "object" && prev2.type === "paranthesis") {
6492
+ if (typeof prev2 === "object" && prev2.type === "parenthesis") {
6358
6493
  const begin = getRowCol(eols, prev2.begin);
6359
6494
  [i2, nxt] = getNext(chi);
6360
6495
  if (typeof nxt === "object" && nxt.type === "js") {
@@ -6408,7 +6543,7 @@ function getRowCol(eols, i2) {
6408
6543
  }
6409
6544
  return [eols.last - 1, i2 - eols[eols.last - 1]];
6410
6545
  }
6411
- function generateSourceMap(json, path2, jsx_eols, out_eols, mappings2 = []) {
6546
+ function generateSourceMap(json, path2, jsx_eols, out_eols, mappings = []) {
6412
6547
  let mpps = [];
6413
6548
  const sourcemap = {
6414
6549
  "version": 3,
@@ -6438,7 +6573,7 @@ function generateSourceMap(json, path2, jsx_eols, out_eols, mappings2 = []) {
6438
6573
  return a[0] - b2[0];
6439
6574
  }
6440
6575
  );
6441
- mappings2.push(...mpps);
6576
+ mappings.push(...mpps);
6442
6577
  let mstr = "";
6443
6578
  let r = 0, oc = 0;
6444
6579
  let lr = 0, lc = 0;
@@ -6472,7 +6607,7 @@ function transpileJSX(jsx2, {
6472
6607
  labels: {},
6473
6608
  counter: 0
6474
6609
  },
6475
- mappings: mappings2 = []
6610
+ mappings = []
6476
6611
  } = {}) {
6477
6612
  var _a, _b;
6478
6613
  (_a = transpilerConfig.preprocessorDelimiter) != null ? _a : transpilerConfig.preprocessorDelimiter = "\u0294";
@@ -6483,7 +6618,7 @@ function transpileJSX(jsx2, {
6483
6618
  const er = new Error(msg);
6484
6619
  if (logErrors) console.error(`JSXParserError: ${msg} [file ${path2} at line ${rc[0]}]`);
6485
6620
  [er.lineNumber, er.columnNumber] = rc;
6486
- er.name = "JSXParseError";
6621
+ er.name = "JSXParserError";
6487
6622
  er.fileName = path2;
6488
6623
  er.lilact_trace = "parse";
6489
6624
  throw er;
@@ -6551,7 +6686,7 @@ function transpileJSX(jsx2, {
6551
6686
  if (node3.type === "regex") return jsx2.substring(node3.begin, node3.end);
6552
6687
  if (node3.type === "comment") return discardComments || is_attr ? "" : jsx2.substring(node3.begin, node3.end);
6553
6688
  if (node3.type === "directive") return node3.value;
6554
- if (node3.type === "paranthesis") {
6689
+ if (node3.type === "parenthesis") {
6555
6690
  let out2 = "(";
6556
6691
  if (node3.out) {
6557
6692
  if (produceCJS) processImportExports(node3, jsx2);
@@ -6624,7 +6759,7 @@ function transpileJSX(jsx2, {
6624
6759
  out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocks_info2.counter};throw e}`;
6625
6760
  }
6626
6761
  }
6627
- const inline_sm = generateSourceMap(json, path2, eols, scanEOLs(out), mappings2);
6762
+ const inline_sm = generateSourceMap(json, path2, eols, scanEOLs(out), mappings);
6628
6763
  if (appendSourcemap) {
6629
6764
  out += inline_sm;
6630
6765
  }
@@ -6633,7 +6768,7 @@ function transpileJSX(jsx2, {
6633
6768
 
6634
6769
  // .tmp/src/lilact.jsx
6635
6770
  var Lilact2 = {
6636
- VERSION: "RC.3",
6771
+ VERSION: "RC.4",
6637
6772
  // Configuration
6638
6773
  defaultTransitionTimeout: 300,
6639
6774
  defaultIsEqual: Object.is,
@@ -6674,7 +6809,7 @@ document.addEventListener("DOMContentLoaded", () => {
6674
6809
  });
6675
6810
  if (true) {
6676
6811
  window.addEventListener("unhandledrejection", (e) => {
6677
- Lilact2.globalErrorHandler(e.reason);
6812
+ Lilact2.globalErrorHandler(e);
6678
6813
  });
6679
6814
  window.addEventListener("error", (e) => {
6680
6815
  Lilact2.globalErrorHandler(e);