lilact 0.29.0 → 0.29.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.
Files changed (37) hide show
  1. package/dist/lilact.development.js +110 -82
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +17 -17
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +17 -17
  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/run.lazy.html +1 -1
  18. package/docs/functions/run.require.html +1 -1
  19. package/docs/functions/run.run.html +1 -1
  20. package/docs/functions/run.runScripts.html +1 -1
  21. package/docs/static/index.html +1 -1
  22. package/docs/static/lilact.development.js +110 -82
  23. package/docs/static/lilact.development.js.map +3 -3
  24. package/docs/static/lilact.development.min.js +17 -17
  25. package/docs/static/lilact.development.min.js.map +3 -3
  26. package/docs/static/lilact.production.min.js +17 -17
  27. package/docs/variables/components.cloneElement.html +1 -1
  28. package/examples/index.html +1 -1
  29. package/examples/lilact.development.js +110 -82
  30. package/examples/lilact.development.js.map +3 -3
  31. package/examples/lilact.development.min.js +17 -17
  32. package/examples/lilact.development.min.js.map +3 -3
  33. package/examples/lilact.production.min.js +17 -17
  34. package/package.json +1 -1
  35. package/src/components.jsx +19 -7
  36. package/src/lilact.jsx +1 -1
  37. package/src/run.jsx +146 -119
@@ -2781,6 +2781,11 @@ var ComponentCore = class {
2781
2781
  }
2782
2782
  };
2783
2783
  var renderErrorHandler = (c, e) => {
2784
+ const value = e?.error instanceof Error ? e.error : e?.reason !== void 0 ? e.reason : e;
2785
+ const error2 = lilact_default.isThenable(e) ? e : lilact_default.traceError(
2786
+ value,
2787
+ e?.fileName || null
2788
+ );
2784
2789
  const stack = [c];
2785
2790
  while (c && !c.component?.componentDidCatch) {
2786
2791
  c = c.parent;
@@ -2788,14 +2793,14 @@ var renderErrorHandler = (c, e) => {
2788
2793
  }
2789
2794
  if (c?.component?.componentDidCatch) {
2790
2795
  if (c.entity?.getDerivedStateFromError) {
2791
- c.component.setState(c.entity.getDerivedStateFromError.call(c, e));
2796
+ c.component.setState(c.entity.getDerivedStateFromError.call(c, error2));
2792
2797
  }
2793
2798
  }
2794
2799
  let stack_log = Array.prototype.map.call(stack, (x) => `in ${typeof x.component.displayName === "function" ? x.component.displayName() : x.component.displayName}`).join("\n");
2795
- e.componentStack = stack;
2796
- e.componentStackLog = stack_log;
2800
+ error2.componentStack = stack;
2801
+ error2.componentStackLog = stack_log;
2797
2802
  if (c?.component?.componentDidCatch) {
2798
- c.component.componentDidCatch(e, { componentStack: stack, componentStackLog: stack_log });
2803
+ c.component.componentDidCatch(error2, { componentStack: stack, componentStackLog: stack_log });
2799
2804
  } else throw e;
2800
2805
  };
2801
2806
  function constructFunc(core, parent) {
@@ -3206,6 +3211,7 @@ var events_set = /* @__PURE__ */ new Set([
3206
3211
  "onsearch",
3207
3212
  "onselect",
3208
3213
  "onsubmit",
3214
+ "oncancel",
3209
3215
  "onkeydown",
3210
3216
  "onkeypress",
3211
3217
  "onkeyup",
@@ -3690,22 +3696,110 @@ function createModule(path2, {
3690
3696
  required_scripts[path2] = module2;
3691
3697
  return module2;
3692
3698
  }
3699
+ function loadModule(path2, options = {}) {
3700
+ if (lilact_default.importObjectPaths?.[path2]) {
3701
+ return lilact_default.importObjectPaths[path2];
3702
+ }
3703
+ if (options.requirer?.path) {
3704
+ path2 = joinPaths(options.requirer.path, path2);
3705
+ }
3706
+ const loadAsync = Boolean(lilact_default[LAZY]) || Boolean(options.isLazy);
3707
+ const module2 = getOrCreateModule(path2, {});
3708
+ if (module2.loaded && !options.forceReload) {
3709
+ return module2.exports;
3710
+ }
3711
+ if (path2.startsWith("#")) {
3712
+ const element = document.getElementById(path2.slice(1));
3713
+ if (!element) {
3714
+ throw report(
3715
+ new Error(`Required element not found (${path2})`),
3716
+ path2
3717
+ );
3718
+ }
3719
+ return run(
3720
+ element.textContent || "",
3721
+ path2,
3722
+ { forceReload: options.forceReload }
3723
+ );
3724
+ }
3725
+ if (loadAsync) {
3726
+ lilact_default[LAZY] = false;
3727
+ if (module2.request) {
3728
+ return module2.request;
3729
+ }
3730
+ return loadAsyncResource(path2, module2);
3731
+ }
3732
+ const resolved = lilact_default.resolver?.(path2);
3733
+ if (resolved != null) {
3734
+ if (path2.endsWith(".css")) {
3735
+ injectGlobal(String(resolved));
3736
+ module2.code = String(resolved);
3737
+ module2.loaded = true;
3738
+ return void 0;
3739
+ }
3740
+ return run(
3741
+ String(resolved),
3742
+ path2,
3743
+ { forceReload: options.forceReload }
3744
+ );
3745
+ }
3746
+ const request = new XMLHttpRequest();
3747
+ try {
3748
+ request.open("GET", path2, false);
3749
+ request.send(null);
3750
+ } catch (value) {
3751
+ throw report(value, path2);
3752
+ }
3753
+ if (request.status >= 200 && request.status < 300) {
3754
+ if (path2.endsWith(".css")) {
3755
+ module2.code = request.responseText;
3756
+ injectGlobal(module2.code);
3757
+ module2.loaded = true;
3758
+ return void 0;
3759
+ }
3760
+ return run(
3761
+ request.responseText,
3762
+ path2,
3763
+ { forceReload: true }
3764
+ );
3765
+ }
3766
+ throw report(
3767
+ new Error(
3768
+ `Unable to load ${path2}: HTTP ${request.status || 0}`
3769
+ ),
3770
+ path2
3771
+ );
3772
+ }
3773
+ function require2(path2) {
3774
+ let options = {};
3775
+ if (arguments.length === 2 && arguments[1] && typeof arguments[1] === "object") {
3776
+ options = arguments[1];
3777
+ }
3778
+ return loadModule(path2, options);
3779
+ }
3693
3780
  function makeImportsObject(mod) {
3694
- mod.importsObject ?? (mod.importsObject = {});
3781
+ mod.importsObject = {};
3695
3782
  for (const path2 in mod.meta.imports) {
3696
- let exps = required_scripts[path2];
3697
- let imps = mod.meta.imports[path2];
3698
- if (!exps) {
3699
- exps = lilact_default.require(path2, { requirer: mod });
3700
- }
3783
+ const imps = mod.meta.imports[path2];
3784
+ const exps = loadModule(path2, {
3785
+ requirer: mod
3786
+ });
3701
3787
  for (const i2 in imps.named_imports) {
3702
3788
  if (i2 === "") continue;
3703
- const j = imps.named_imports[i2];
3704
- if (!exps.hasOwnProperty(j)) throw new Error(`Imported module does not export any "${i2}".`);
3705
- mod.importsObject[i2] = exps[j];
3789
+ const exportedName = imps.named_imports[i2];
3790
+ if (!Object.prototype.hasOwnProperty.call(exps, exportedName)) {
3791
+ throw new Error(
3792
+ `Imported module does not export any "${i2}".`
3793
+ );
3794
+ }
3795
+ mod.importsObject[i2] = exps[exportedName];
3706
3796
  }
3707
3797
  for (const i2 of imps.import_defaults) {
3708
- if (!exps.hasOwnProperty("default")) throw new Error(`Imported module does not export a default.`);
3798
+ if (!Object.prototype.hasOwnProperty.call(exps, "default")) {
3799
+ throw new Error(
3800
+ `Imported module does not export a default.`
3801
+ );
3802
+ }
3709
3803
  mod.importsObject[i2] = exps.default;
3710
3804
  }
3711
3805
  for (const i2 of imps.import_stars) {
@@ -3758,7 +3852,7 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {} = {}) {
3758
3852
  globalThis.Lilact = lilact_default;
3759
3853
  globalThis.createComponent = lilact_default.createComponent;
3760
3854
  globalThis.Fragment = lilact_default.Fragment;
3761
- if (!module.importsObject) makeImportsObject(module);
3855
+ makeImportsObject(module);
3762
3856
  lilact_default.scriptImportsObject = module.importsObject;
3763
3857
  const result = eval(processed);
3764
3858
  module.loaded = true;
@@ -3819,72 +3913,6 @@ function loadAsyncResource(path2, module2) {
3819
3913
  module2.request = request;
3820
3914
  return request;
3821
3915
  }
3822
- function require2(path2) {
3823
- let options = {};
3824
- if (arguments.length === 2 && arguments[1] && typeof arguments[1] === "object") {
3825
- options = arguments[1];
3826
- }
3827
- if (lilact_default.importObjectPaths?.[path2]) {
3828
- return lilact_default.importObjectPaths[path2];
3829
- }
3830
- if (options?.requirer?.path) {
3831
- path2 = joinPaths(options.requirer.path, path2);
3832
- }
3833
- const loadAsync = Boolean(lilact_default[LAZY]) || Boolean(options.isLazy);
3834
- const module2 = getOrCreateModule(path2, {});
3835
- if (module2.loaded && !options.forceReload) {
3836
- return module2.exports;
3837
- }
3838
- if (path2.startsWith("#")) {
3839
- const element = document.getElementById(path2.slice(1));
3840
- if (!element) {
3841
- throw report(
3842
- new Error(`Required element not found (${path2})`),
3843
- path2
3844
- );
3845
- }
3846
- return run(element.textContent || "", path2, { forceReload: options.forceReload });
3847
- }
3848
- if (loadAsync) {
3849
- lilact_default[LAZY] = false;
3850
- if (module2.request) {
3851
- return module2.request;
3852
- }
3853
- return loadAsyncResource(path2, module2);
3854
- }
3855
- const resolved = lilact_default.resolver?.(path2);
3856
- if (resolved != null) {
3857
- if (path2.endsWith(".css")) {
3858
- injectGlobal(String(resolved));
3859
- module2.code = String(resolved);
3860
- module2.loaded = true;
3861
- return void 0;
3862
- }
3863
- return run(String(resolved), path2, { forceReload: options.forceReload });
3864
- }
3865
- const request = new XMLHttpRequest();
3866
- try {
3867
- request.open("GET", path2, false);
3868
- request.send(null);
3869
- } catch (value) {
3870
- throw report(value, path2);
3871
- }
3872
- if (request.status >= 200 && request.status < 300) {
3873
- if (path2.endsWith(".css")) {
3874
- module2.code = request.responseText;
3875
- injectGlobal(module2.code);
3876
- module2.loaded = true;
3877
- return void 0;
3878
- }
3879
- return run(request.responseText, path2, { forceReload: options.forceReload });
3880
- }
3881
- throw report(
3882
- new Error(
3883
- `Unable to load ${path2}: HTTP ${request.status || 0}`
3884
- ),
3885
- path2
3886
- );
3887
- }
3888
3916
  function lazy(factory) {
3889
3917
  let status = "pending";
3890
3918
  let result2;
@@ -6957,7 +6985,7 @@ function transpileJSX(jsx2, {
6957
6985
 
6958
6986
  // .tmp/src/lilact.jsx
6959
6987
  var Lilact2 = {
6960
- VERSION: "RC.4",
6988
+ VERSION: "RC.5",
6961
6989
  // Configuration
6962
6990
  defaultTransitionTimeout: 300,
6963
6991
  defaultIsEqual: Object.is,