lilact 0.28.1 → 0.28.5

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 (45) hide show
  1. package/dist/lilact.development.js +36 -22
  2. package/dist/lilact.development.js.map +2 -2
  3. package/dist/lilact.development.min.js +31 -31
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +31 -31
  6. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  7. package/docs/classes/accessories.Suspense.html +7 -7
  8. package/docs/classes/components.Component.html +11 -11
  9. package/docs/classes/components.HTMLComponent.html +11 -11
  10. package/docs/classes/components.RootComponent.html +11 -11
  11. package/docs/functions/components.cloneComponent.html +1 -1
  12. package/docs/functions/components.createComponent.html +1 -1
  13. package/docs/functions/components.createPortal.html +1 -1
  14. package/docs/functions/components.createRoot.html +1 -1
  15. package/docs/functions/components.memo.html +1 -1
  16. package/docs/functions/components.render.html +1 -1
  17. package/docs/functions/errors.globalErrorHandler.html +1 -1
  18. package/docs/functions/errors.scanBlockLabels.html +1 -1
  19. package/docs/functions/errors.traceError.html +1 -1
  20. package/docs/functions/run.lazy.html +1 -1
  21. package/docs/functions/run.require.html +1 -1
  22. package/docs/functions/run.run.html +1 -1
  23. package/docs/functions/run.runScripts.html +1 -1
  24. package/docs/static/demos/error-nested-5.jsx +2 -3
  25. package/docs/static/index.html +1 -2
  26. package/docs/static/lilact.development.js +36 -22
  27. package/docs/static/lilact.development.js.map +2 -2
  28. package/docs/static/lilact.development.min.js +31 -31
  29. package/docs/static/lilact.development.min.js.map +3 -3
  30. package/docs/static/lilact.production.min.js +31 -31
  31. package/docs/variables/components.cloneElement.html +1 -1
  32. package/docs/variables/errors.blocks_info.html +1 -1
  33. package/docs/variables/errors.error.html +1 -1
  34. package/examples/demos/error-nested-5.jsx +2 -3
  35. package/examples/index.html +1 -2
  36. package/examples/lilact.development.js +36 -22
  37. package/examples/lilact.development.js.map +2 -2
  38. package/examples/lilact.development.min.js +31 -31
  39. package/examples/lilact.development.min.js.map +3 -3
  40. package/examples/lilact.production.min.js +31 -31
  41. package/package.json +1 -1
  42. package/src/components.jsx +21 -14
  43. package/src/errors.jsx +45 -24
  44. package/src/jsx.js +3 -1
  45. package/src/run.jsx +10 -17
@@ -2549,19 +2549,23 @@ var ComponentCore = class {
2549
2549
  this.outlet.splice(i2, 1, ...item);
2550
2550
  i2--;
2551
2551
  } else {
2552
- const core = prepareCore(this, item);
2553
- this.outlet[i2] = core;
2554
- if (core[TEXT2] === void 0) {
2555
- core.container = this.element ? this : this.container;
2556
- core.apply(item.props);
2557
- } else {
2558
- if (!core.element) {
2559
- core.element = document.createTextNode(item[TEXT2]);
2560
- core[TEXT2] = item[TEXT2];
2561
- } else if (core[TEXT2] !== item[TEXT2]) {
2562
- core.element.textContent = item[TEXT2];
2563
- core[TEXT2] = item[TEXT2];
2552
+ try {
2553
+ const core = prepareCore(this, item);
2554
+ this.outlet[i2] = core;
2555
+ if (core[TEXT2] === void 0) {
2556
+ core.container = this.element ? this : this.container;
2557
+ core.apply(item.props);
2558
+ } else {
2559
+ if (!core.element) {
2560
+ core.element = document.createTextNode(item[TEXT2]);
2561
+ core[TEXT2] = item[TEXT2];
2562
+ } else if (core[TEXT2] !== item[TEXT2]) {
2563
+ core.element.textContent = item[TEXT2];
2564
+ core[TEXT2] = item[TEXT2];
2565
+ }
2564
2566
  }
2567
+ } catch (e) {
2568
+ renderErrorHandler(this, e);
2565
2569
  }
2566
2570
  }
2567
2571
  }
@@ -3698,7 +3702,8 @@ function createModule(path2, {
3698
3702
  }
3699
3703
  function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3700
3704
  isInline = true,
3701
- isModule = true
3705
+ isModule = true,
3706
+ hotReload = true
3702
3707
  } = {}) {
3703
3708
  let module = required_scripts[path];
3704
3709
  if (!module) {
@@ -3723,7 +3728,7 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3723
3728
  path,
3724
3729
  mappings: module.mappings,
3725
3730
  factory: "createComponent",
3726
- appendSourcemap: false,
3731
+ appendSourcemap: true,
3727
3732
  injectTraceLabels: true,
3728
3733
  produceCJS: true,
3729
3734
  blocks_info: lilact_default.blocks_info
@@ -3731,6 +3736,7 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3731
3736
  } catch (value) {
3732
3737
  const error2 = asError(value);
3733
3738
  error2.fileName ?? (error2.fileName = path);
3739
+ error2.lilact_source ?? (error2.lilact_source = { path });
3734
3740
  error2.sourcePhase = "transpile";
3735
3741
  module.error = error2;
3736
3742
  lilact_default.error = error2;
@@ -3739,9 +3745,8 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3739
3745
  if (typeof lilact_default.scanBlockLabels === "function") {
3740
3746
  lilact_default.scanBlockLabels(processed, path);
3741
3747
  }
3742
- processed += `
3743
- //# sourceURL=eval:/${path}`;
3744
3748
  try {
3749
+ new Function(processed);
3745
3750
  globalThis.Lilact = lilact_default;
3746
3751
  globalThis.createComponent = lilact_default.createComponent;
3747
3752
  globalThis.Fragment = lilact_default.Fragment;
@@ -4662,6 +4667,10 @@ __export(errors_exports, {
4662
4667
  scanBlockLabels: () => scanBlockLabels,
4663
4668
  traceError: () => traceError
4664
4669
  });
4670
+ function isSafari() {
4671
+ const userAgent = navigator.userAgent;
4672
+ return /Safari/.test(userAgent) && !/Chrome|Chromium|CriOS|FxiOS|EdgiOS|OPiOS/.test(userAgent);
4673
+ }
4665
4674
  function number(value) {
4666
4675
  const result2 = Number(value);
4667
4676
  return Number.isFinite(result2) ? result2 : null;
@@ -4704,8 +4713,9 @@ function browserLocation(error2) {
4704
4713
  const column2 = number(
4705
4714
  error2?.columnNumber ?? error2?.colno ?? error2?.column
4706
4715
  );
4716
+ const lineOffset = isSafari() ? 0 : 1;
4707
4717
  return {
4708
- line: line2 == null ? null : Math.max(0, line2 - 1),
4718
+ line: line2 == null ? null : Math.max(0, line2 - lineOffset),
4709
4719
  column: column2 == null ? null : Math.max(0, column2 - 1)
4710
4720
  };
4711
4721
  }
@@ -4756,8 +4766,9 @@ function traceError(value, runPath) {
4756
4766
  column: number(error2.columnNumber)
4757
4767
  } : browserLocation(error2);
4758
4768
  const fileName = source?.path || stack?.path || error2.fileName || runPath || null;
4759
- let line2 = stack?.line ?? browser.line ?? null;
4760
- let column2 = stack?.column ?? browser.column ?? null;
4769
+ const sameSource = !source?.path || !stack?.path || source.path === stack.path;
4770
+ let line2 = sameSource ? stack?.line ?? browser.line ?? null : browser.line ?? null;
4771
+ let column2 = sameSource ? stack?.column ?? browser.column ?? null : browser.column ?? null;
4761
4772
  const result2 = {
4762
4773
  fileName,
4763
4774
  lineNumber: line2,
@@ -4783,7 +4794,7 @@ function traceError(value, runPath) {
4783
4794
  if (block && (result2.lineNumber == null || result2.columnNumber == null || !result2.fileName)) {
4784
4795
  result2.fileName || (result2.fileName = block.path || runPath || null);
4785
4796
  result2.lineNumber ?? (result2.lineNumber = block.line);
4786
- result2.columnNumber ?? (result2.columnNumber = block.col);
4797
+ result2.columnNumber ?? (result2.columnNumber = block.column);
4787
4798
  result2.label = block.desc;
4788
4799
  }
4789
4800
  lilact_default.error = result2;
@@ -4876,7 +4887,7 @@ function scanBlockLabels(code2, path2) {
4876
4887
  lilact_default.blocks_info.labels[match2[1]] = {
4877
4888
  path: path2,
4878
4889
  line: Number(match2[2]),
4879
- col: Number(match2[3]),
4890
+ column: Number(match2[3]),
4880
4891
  desc: match2[4]
4881
4892
  };
4882
4893
  }
@@ -6725,7 +6736,10 @@ function generateSourceMap(json, path2, jsx_eols, out_eols, mappings = []) {
6725
6736
  lc = m[3];
6726
6737
  }
6727
6738
  sourcemap.mappings = mstr.substring(1).replace(/;,/g, ";");
6728
- return "\n\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + btoa(JSON.stringify(sourcemap));
6739
+ let out = "\n\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + btoa(JSON.stringify(sourcemap));
6740
+ out += `
6741
+ //# sourceURL=eval:/${path2}`;
6742
+ return out;
6729
6743
  }
6730
6744
  function transpileJSX(jsx2, {
6731
6745
  factory = "createComponent",