lilact 0.28.5 → 0.29.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.
Files changed (46) hide show
  1. package/dist/lilact.development.js +225 -177
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +33 -33
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +33 -33
  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.asError.html +1 -0
  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/modules/errors.html +1 -1
  25. package/docs/static/index.html +4 -5
  26. package/docs/static/lilact.development.js +225 -177
  27. package/docs/static/lilact.development.js.map +3 -3
  28. package/docs/static/lilact.development.min.js +33 -33
  29. package/docs/static/lilact.development.min.js.map +3 -3
  30. package/docs/static/lilact.production.min.js +33 -33
  31. package/docs/variables/components.cloneElement.html +1 -1
  32. package/docs/variables/errors.blocksInfo.html +1 -0
  33. package/examples/index.html +4 -5
  34. package/examples/lilact.development.js +225 -177
  35. package/examples/lilact.development.js.map +3 -3
  36. package/examples/lilact.development.min.js +33 -33
  37. package/examples/lilact.development.min.js.map +3 -3
  38. package/examples/lilact.production.min.js +33 -33
  39. package/package.json +1 -1
  40. package/src/components.jsx +122 -121
  41. package/src/errors.jsx +4 -4
  42. package/src/expscan.js +40 -15
  43. package/src/jsx.js +67 -38
  44. package/src/lilact.jsx +1 -1
  45. package/src/run.jsx +55 -40
  46. package/docs/variables/errors.blocks_info.html +0 -1
@@ -2452,104 +2452,97 @@ var ComponentCore = class {
2452
2452
  */
2453
2453
  // TODO: should componentDidUpdate be called after arranging/appending the outlet or before?
2454
2454
  apply(next_props = this.props, next_state = this.next_state || this.state) {
2455
- let do_rerender = true;
2456
- if (this.outlet && this?.[MEMOIZED]) {
2457
- if (shallowEqual(this.props, next_props, "children") && shallowEqual(this.props?.children, next_props?.children)) {
2458
- do_rerender = false;
2459
- }
2460
- }
2461
- if (do_rerender) {
2462
- if (true) {
2463
- if (this.entity?.propTypes) {
2464
- PropTypes.checkPropTypes(this.entity.propTypes, this.props, "prop", this.entity.name);
2465
- } else if (this.component?.propTypes) {
2466
- PropTypes.checkPropTypes(this.component.propTypes, this.props, "prop", this.component.name);
2455
+ try {
2456
+ let do_rerender = true;
2457
+ if (this.outlet && this?.[MEMOIZED]) {
2458
+ if (shallowEqual(this.props, next_props, "children") && shallowEqual(this.props?.children, next_props?.children)) {
2459
+ do_rerender = false;
2467
2460
  }
2468
2461
  }
2469
- if (typeof next_state === "function") next_state = next_state(this.state);
2470
- if (this.component.constructor.defaultProps) {
2471
- next_props = { ...this.component.constructor.defaultProps, ...next_props };
2472
- }
2473
- if (this?.parent?.component?.context || this?.parent?.component?.getChildContext) {
2474
- this.context = { ...this.parent.component.context, ...this.parent.component.getChildContext?.() };
2475
- if (this.component.constructor.contextTypes) {
2476
- PropTypes.checkPropTypes(this.component.constructor.contextTypes, this.context, "context", this.entity.name);
2462
+ if (do_rerender) {
2463
+ if (true) {
2464
+ if (this.entity?.propTypes) {
2465
+ PropTypes.checkPropTypes(this.entity.propTypes, this.props, "prop", this.entity.name);
2466
+ } else if (this.component?.propTypes) {
2467
+ PropTypes.checkPropTypes(this.component.propTypes, this.props, "prop", this.component.name);
2468
+ }
2477
2469
  }
2478
- }
2479
- if (this.component.shouldComponentUpdate && !this.component.shouldComponentUpdate(next_state, next_props, this.context)) return;
2480
- if (typeof this.entity === "string") {
2481
- if (!(this.element instanceof Element)) {
2482
- if (this.is_svg || this.container.is_svg) {
2483
- this.is_svg = true;
2484
- this.element = document.createElementNS(SVG_NS, this.entity);
2470
+ if (typeof next_state === "function") next_state = next_state(this.state);
2471
+ if (this.component.constructor.defaultProps) {
2472
+ next_props = { ...this.component.constructor.defaultProps, ...next_props };
2473
+ }
2474
+ if (this?.parent?.component?.context || this?.parent?.component?.getChildContext) {
2475
+ this.context = { ...this.parent.component.context, ...this.parent.component.getChildContext?.() };
2476
+ if (this.component.constructor.contextTypes) {
2477
+ PropTypes.checkPropTypes(this.component.constructor.contextTypes, this.context, "context", this.entity.name);
2478
+ }
2479
+ }
2480
+ if (this.component.shouldComponentUpdate && !this.component.shouldComponentUpdate(next_state, next_props, this.context)) return;
2481
+ if (typeof this.entity === "string") {
2482
+ if (!(this.element instanceof Element)) {
2483
+ if (this.is_svg || this.container.is_svg) {
2484
+ this.is_svg = true;
2485
+ this.element = document.createElementNS(SVG_NS, this.entity);
2486
+ } else {
2487
+ this.element = document.createElement(this.entity);
2488
+ }
2489
+ if (next_props?.defaultValue) this.element.value = String(next_props.defaultValue).slice(0, next_props?.maxLength);
2490
+ if (next_props?.defaultChecked) this.element.checked = next_props.defaultChecked;
2491
+ }
2492
+ this.element[COMPONENT] = this.component;
2493
+ }
2494
+ if (next_props.ref) {
2495
+ if (typeof next_props.ref === "function") {
2496
+ next_props.ref(this.element || this.component);
2485
2497
  } else {
2486
- this.element = document.createElement(this.entity);
2498
+ next_props.ref.current = this.element || this.component;
2487
2499
  }
2488
- if (next_props?.defaultValue) this.element.value = String(next_props.defaultValue).slice(0, next_props?.maxLength);
2489
- if (next_props?.defaultChecked) this.element.checked = next_props.defaultChecked;
2490
2500
  }
2491
- this.element[COMPONENT] = this.component;
2492
- }
2493
- if (next_props.ref) {
2494
- if (typeof next_props.ref === "function") {
2495
- next_props.ref(this.element || this.component);
2496
- } else {
2497
- next_props.ref.current = this.element || this.component;
2501
+ if (next_props !== void 0 && this.component.componentWillReceiveProps) {
2502
+ this.component.componentWillReceiveProps(next_props);
2498
2503
  }
2499
- }
2500
- if (next_props !== void 0 && this.component.componentWillReceiveProps) {
2501
- this.component.componentWillReceiveProps(next_props);
2502
- }
2503
- if (this.component.componentWillUpdate) {
2504
- this.component.componentWillUpdate(next_props, next_state);
2505
- }
2506
- const prev_state = this.state, prev_props = this.props;
2507
- if (this.element) {
2508
- this.updateElementProps(next_props);
2509
- }
2510
- this.props = next_props;
2511
- if (typeof this.next_state === "object") {
2512
- if (!this.state) this.state = { ...next_state };
2513
- else Object.assign(this.state, next_state);
2514
- } else if (this.next_state !== void 0) throw new Error("Component.setState only accepts objects or functions is new state.");
2515
- if (this.next_state) delete this.next_state;
2516
- if (this.hooks !== void 0) {
2517
- this.hook_index = 0;
2518
- lilact_default.current_component = [this, lilact_default.current_component];
2519
- try {
2520
- this.outlet = this.component.render(next_props, { current: this.element || this.component });
2521
- } catch (e) {
2522
- renderErrorHandler(this, e);
2504
+ if (this.component.componentWillUpdate) {
2505
+ this.component.componentWillUpdate(next_props, next_state);
2523
2506
  }
2524
- lilact_default.current_component = lilact_default.current_component[1];
2525
- } else {
2526
- try {
2507
+ const prev_state = this.state, prev_props = this.props;
2508
+ if (this.element) {
2509
+ this.updateElementProps(next_props);
2510
+ }
2511
+ this.props = next_props;
2512
+ if (typeof this.next_state === "object") {
2513
+ if (!this.state) this.state = { ...next_state };
2514
+ else Object.assign(this.state, next_state);
2515
+ } else if (this.next_state !== void 0) throw new Error("Component.setState only accepts objects or functions is new state.");
2516
+ if (this.next_state) delete this.next_state;
2517
+ if (this.hooks !== void 0) {
2518
+ this.hook_index = 0;
2519
+ lilact_default.current_component = [this, lilact_default.current_component];
2520
+ this.outlet = this.component.render(next_props, { current: this.element || this.component });
2521
+ lilact_default.current_component = lilact_default.current_component[1];
2522
+ } else {
2527
2523
  this.outlet = this.component.render({ current: this.element || this.component });
2528
- } catch (e) {
2529
- renderErrorHandler(this, e);
2530
2524
  }
2531
- }
2532
- if (this?.portal) {
2533
- this.element = this.portal;
2534
- }
2535
- if (this.outlet?.constructor?.name !== "Array") {
2536
- this.outlet = [this.outlet];
2537
- }
2538
- this.outlet = [...this.outlet];
2539
- for (let i2 = 0; i2 < this.outlet.length; i2++) {
2540
- let item = this.outlet[i2];
2541
- if (item === void 0 || item === null || typeof item === "boolean") {
2542
- this.outlet.splice(i2, 1);
2543
- i2--;
2544
- } else if (typeof item === "function") {
2545
- const res = this.childFunctionHandler(item);
2546
- this.outlet.splice(i2, 1, res);
2547
- i2--;
2548
- } else if (item.constructor.name === "Array") {
2549
- this.outlet.splice(i2, 1, ...item);
2550
- i2--;
2525
+ if (this?.portal) {
2526
+ this.element = this.portal;
2527
+ }
2528
+ if (this.outlet?.constructor?.name !== "Array") {
2529
+ this.outlet = [this.outlet];
2551
2530
  } else {
2552
- try {
2531
+ this.outlet = [...this.outlet];
2532
+ }
2533
+ for (let i2 = 0; i2 < this.outlet.length; i2++) {
2534
+ let item = this.outlet[i2];
2535
+ if (item === void 0 || item === null || typeof item === "boolean") {
2536
+ this.outlet.splice(i2, 1);
2537
+ i2--;
2538
+ } else if (typeof item === "function") {
2539
+ const res = this.childFunctionHandler(item);
2540
+ this.outlet.splice(i2, 1, res);
2541
+ i2--;
2542
+ } else if (item.constructor.name === "Array") {
2543
+ this.outlet.splice(i2, 1, ...item);
2544
+ i2--;
2545
+ } else {
2553
2546
  const core = prepareCore(this, item);
2554
2547
  this.outlet[i2] = core;
2555
2548
  if (core[TEXT2] === void 0) {
@@ -2564,17 +2557,17 @@ var ComponentCore = class {
2564
2557
  core[TEXT2] = item[TEXT2];
2565
2558
  }
2566
2559
  }
2567
- } catch (e) {
2568
- renderErrorHandler(this, e);
2569
2560
  }
2570
2561
  }
2562
+ if (this.cache) this.cache.commit();
2563
+ if (this.element) this.arrangeOutlet();
2564
+ if (this.component.componentDidUpdate) {
2565
+ this.component.componentDidUpdate(prev_props, prev_state, this.last_snapshot);
2566
+ }
2567
+ if (this.last_snapshot) delete this.last_snapshot;
2571
2568
  }
2572
- if (this.cache) this.cache.commit();
2573
- if (this.element) this.arrangeOutlet();
2574
- if (this.component.componentDidUpdate) {
2575
- this.component.componentDidUpdate(prev_props, prev_state, this.last_snapshot);
2576
- }
2577
- if (this.last_snapshot) delete this.last_snapshot;
2569
+ } catch (e) {
2570
+ renderErrorHandler(this, e);
2578
2571
  }
2579
2572
  }
2580
2573
  async cleanup() {
@@ -2771,7 +2764,7 @@ var ComponentCore = class {
2771
2764
  core.container = this.element ? this : this.container;
2772
2765
  core.container.appendElement(core);
2773
2766
  } else {
2774
- if (core.arrangeOutlet) core.arrangeOutlet();
2767
+ if (core.arrangeOutlet && core.outlet) core.arrangeOutlet();
2775
2768
  if (!core?.mounted) {
2776
2769
  core.mounted = true;
2777
2770
  if (core?.component?.componentDidMount) {
@@ -2788,6 +2781,11 @@ var ComponentCore = class {
2788
2781
  }
2789
2782
  };
2790
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
+ );
2791
2789
  const stack = [c];
2792
2790
  while (c && !c.component?.componentDidCatch) {
2793
2791
  c = c.parent;
@@ -2795,14 +2793,14 @@ var renderErrorHandler = (c, e) => {
2795
2793
  }
2796
2794
  if (c?.component?.componentDidCatch) {
2797
2795
  if (c.entity?.getDerivedStateFromError) {
2798
- c.component.setState(c.entity.getDerivedStateFromError.call(c, e));
2796
+ c.component.setState(c.entity.getDerivedStateFromError.call(c, error2));
2799
2797
  }
2800
2798
  }
2801
2799
  let stack_log = Array.prototype.map.call(stack, (x) => `in ${typeof x.component.displayName === "function" ? x.component.displayName() : x.component.displayName}`).join("\n");
2802
- e.componentStack = stack;
2803
- e.componentStackLog = stack_log;
2800
+ error2.componentStack = stack;
2801
+ error2.componentStackLog = stack_log;
2804
2802
  if (c?.component?.componentDidCatch) {
2805
- c.component.componentDidCatch(e, { componentStack: stack, componentStackLog: stack_log });
2803
+ c.component.componentDidCatch(error2, { componentStack: stack, componentStackLog: stack_log });
2806
2804
  } else throw e;
2807
2805
  };
2808
2806
  function constructFunc(core, parent) {
@@ -3679,17 +3677,14 @@ function report(value, path2) {
3679
3677
  }
3680
3678
  var required_scripts = {};
3681
3679
  function createModule(path2, {
3682
- code: code2 = "",
3683
- isInline: isInline2 = false,
3684
- isModule: isModule2 = true
3680
+ code: code2 = ""
3685
3681
  } = {}) {
3686
3682
  const module2 = {
3687
3683
  path: path2,
3688
3684
  code: String(code2),
3689
3685
  mappings: [],
3686
+ meta: {},
3690
3687
  exports: {},
3691
- isInline: isInline2,
3692
- isModule: isModule2,
3693
3688
  // True only after the module has been successfully evaluated.
3694
3689
  loaded: false,
3695
3690
  // The promise for the request currently loading this resource.
@@ -3700,38 +3695,57 @@ function createModule(path2, {
3700
3695
  required_scripts[path2] = module2;
3701
3696
  return module2;
3702
3697
  }
3703
- function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3704
- isInline = true,
3705
- isModule = true,
3706
- hotReload = true
3707
- } = {}) {
3698
+ function makeImportsObject(mod) {
3699
+ mod.importsObject ?? (mod.importsObject = {});
3700
+ for (const path2 in mod.meta.imports) {
3701
+ let exps = required_scripts[path2];
3702
+ let imps = mod.meta.imports[path2];
3703
+ if (!exps) {
3704
+ exps = lilact_default.require(path2, { requirer: mod });
3705
+ }
3706
+ for (const i2 in imps.named_imports) {
3707
+ if (i2 === "") continue;
3708
+ const j = imps.named_imports[i2];
3709
+ if (!exps.hasOwnProperty(j)) throw new Error(`Imported module does not export any "${i2}".`);
3710
+ mod.importsObject[i2] = exps[j];
3711
+ }
3712
+ for (const i2 of imps.import_defaults) {
3713
+ if (!exps.hasOwnProperty("default")) throw new Error(`Imported module does not export a default.`);
3714
+ mod.importsObject[i2] = exps.default;
3715
+ }
3716
+ for (const i2 of imps.import_stars) {
3717
+ mod.importsObject[i2] = { ...exps };
3718
+ }
3719
+ }
3720
+ }
3721
+ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {} = {}) {
3708
3722
  let module = required_scripts[path];
3709
3723
  if (!module) {
3710
3724
  module = createModule(path, {
3711
- code: jsx,
3712
- isInline,
3713
- isModule
3725
+ code: jsx
3714
3726
  });
3715
3727
  } else {
3716
3728
  module.path = path;
3717
3729
  module.code = String(jsx);
3718
3730
  module.mappings = [];
3719
3731
  module.exports = {};
3720
- module.isInline = isInline;
3721
- module.isModule = isModule;
3722
3732
  module.loaded = false;
3723
3733
  module.error = void 0;
3734
+ module.importsObject = void 0;
3735
+ module.meta = {};
3724
3736
  }
3725
3737
  let processed;
3726
3738
  try {
3727
3739
  processed = lilact_default.transpileJSX(String(jsx), {
3728
3740
  path,
3729
3741
  mappings: module.mappings,
3742
+ meta: module.meta,
3730
3743
  factory: "createComponent",
3731
3744
  appendSourcemap: true,
3732
3745
  injectTraceLabels: true,
3733
- produceCJS: true,
3734
- blocks_info: lilact_default.blocks_info
3746
+ produceCJS: false,
3747
+ referentiateImports: true,
3748
+ blocksInfo: lilact_default.blocksInfo
3735
3749
  });
3736
3750
  } catch (value) {
3737
3751
  const error2 = asError(value);
@@ -3746,10 +3760,11 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3746
3760
  lilact_default.scanBlockLabels(processed, path);
3747
3761
  }
3748
3762
  try {
3749
- new Function(processed);
3750
3763
  globalThis.Lilact = lilact_default;
3751
3764
  globalThis.createComponent = lilact_default.createComponent;
3752
3765
  globalThis.Fragment = lilact_default.Fragment;
3766
+ makeImportsObject(module);
3767
+ lilact_default.scriptImportsObject = module.importsObject;
3753
3768
  const result = eval(processed);
3754
3769
  module.loaded = true;
3755
3770
  return isEmpty(module.exports) ? result : module.exports;
@@ -3797,10 +3812,7 @@ function loadAsyncResource(path2, module2) {
3797
3812
  module2.loaded = true;
3798
3813
  return void 0;
3799
3814
  }
3800
- return run(module2.code, path2, {
3801
- isInline: false,
3802
- isModule: true
3803
- });
3815
+ return run(module2.code, path2, {});
3804
3816
  }).then((result2) => result2?.default ?? result2).catch((error2) => {
3805
3817
  module2.error = report(error2, path2);
3806
3818
  throw module2.error;
@@ -3820,15 +3832,12 @@ function require2(path2) {
3820
3832
  if (lilact_default.importObjectPaths?.[path2]) {
3821
3833
  return lilact_default.importObjectPaths[path2];
3822
3834
  }
3823
- if (options.requirer?.path) {
3835
+ if (options?.requirer?.path) {
3824
3836
  path2 = joinPaths(options.requirer.path, path2);
3825
3837
  }
3826
3838
  const loadAsync = Boolean(lilact_default[LAZY]) || Boolean(options.isLazy);
3827
- const module2 = getOrCreateModule(path2, {
3828
- isInline: false,
3829
- isModule: true
3830
- });
3831
- if (module2.loaded && !options.forceUpdate) {
3839
+ const module2 = getOrCreateModule(path2, {});
3840
+ if (module2.loaded && !options.forceReload) {
3832
3841
  return module2.exports;
3833
3842
  }
3834
3843
  if (path2.startsWith("#")) {
@@ -3839,7 +3848,7 @@ function require2(path2) {
3839
3848
  path2
3840
3849
  );
3841
3850
  }
3842
- return run(element.textContent || "", path2);
3851
+ return run(element.textContent || "", path2, { forceReload: options.forceReload });
3843
3852
  }
3844
3853
  if (loadAsync) {
3845
3854
  lilact_default[LAZY] = false;
@@ -3856,10 +3865,7 @@ function require2(path2) {
3856
3865
  module2.loaded = true;
3857
3866
  return void 0;
3858
3867
  }
3859
- return run(String(resolved), path2, {
3860
- isInline: false,
3861
- isModule: true
3862
- });
3868
+ return run(String(resolved), path2, { forceReload: options.forceReload });
3863
3869
  }
3864
3870
  const request = new XMLHttpRequest();
3865
3871
  try {
@@ -3875,10 +3881,7 @@ function require2(path2) {
3875
3881
  module2.loaded = true;
3876
3882
  return void 0;
3877
3883
  }
3878
- return run(request.responseText, path2, {
3879
- isInline: false,
3880
- isModule: true
3881
- });
3884
+ return run(request.responseText, path2, { forceReload: true });
3882
3885
  }
3883
3886
  throw report(
3884
3887
  new Error(
@@ -4661,7 +4664,8 @@ function animationFramePromise() {
4661
4664
  // .tmp/src/errors.jsx
4662
4665
  var errors_exports = {};
4663
4666
  __export(errors_exports, {
4664
- blocks_info: () => blocks_info,
4667
+ asError: () => asError2,
4668
+ blocksInfo: () => blocksInfo,
4665
4669
  error: () => error,
4666
4670
  globalErrorHandler: () => globalErrorHandler,
4667
4671
  scanBlockLabels: () => scanBlockLabels,
@@ -4725,7 +4729,7 @@ function traceBlock(error2) {
4725
4729
  }
4726
4730
  function blockInfo(error2) {
4727
4731
  const trace = traceBlock(error2);
4728
- return trace == null ? null : lilact_default.blocks_info?.labels?.[trace];
4732
+ return trace == null ? null : lilact_default.blocksInfo?.labels?.[trace];
4729
4733
  }
4730
4734
  function mapLocation(mappings, line2, column2) {
4731
4735
  if (!Array.isArray(mappings) || !mappings.length || !Number.isFinite(line2) || !Number.isFinite(column2)) {
@@ -4884,7 +4888,7 @@ function scanBlockLabels(code2, path2) {
4884
4888
  for (const match2 of String(code2).matchAll(
4885
4889
  /LILACTBLOCK(\d+):(\d+),(\d+):([^*]+)\*\//gm
4886
4890
  )) {
4887
- lilact_default.blocks_info.labels[match2[1]] = {
4891
+ lilact_default.blocksInfo.labels[match2[1]] = {
4888
4892
  path: path2,
4889
4893
  line: Number(match2[2]),
4890
4894
  column: Number(match2[3]),
@@ -4892,7 +4896,7 @@ function scanBlockLabels(code2, path2) {
4892
4896
  };
4893
4897
  }
4894
4898
  }
4895
- var blocks_info = {
4899
+ var blocksInfo = {
4896
4900
  counter: 0,
4897
4901
  labels: {}
4898
4902
  };
@@ -5769,7 +5773,7 @@ function generateSequence(arr, labeler2 = labeler2.bind(null, null)) {
5769
5773
  }
5770
5774
  var import_export_regexp = /(?:i[C \n]*(?:(?:I|J|(?:\*[C \n]*a[C \n]*I))[C \n]*,[C \n]*)*(?:(?:(?:I(?:[C \n]*a[C \n]*I)?)|J|(?:\*[C \n]*a[C \n]*I))[C \n]*f[C \n]*)?S)|(?:e[C \n]*(?:(?:[*J][C \n]*f[C \n]*S)|(?:d[C \n]*[IFJ])|J|(?:[VF][c \n]*I)|I))|(?:r[c \n]*P)/mg;
5771
5775
  var props_regexp = /O[C \n]*(?:[Id](?:[C \n]*a[C \n]*I)?[C \n]*,[C \n]*)*(?:I(?:[C \n]*a[C \n]*I)?)[C \n]*O/mg;
5772
- function processImportExports(node3, jsx2) {
5776
+ function processImportExports(node3, jsx2, meta) {
5773
5777
  const s = generateSequence(
5774
5778
  node3.out,
5775
5779
  labeler.bind(
@@ -5814,6 +5818,8 @@ function processImportExports(node3, jsx2) {
5814
5818
  }
5815
5819
  }
5816
5820
  begins.push(node3.end);
5821
+ meta.imports ?? (meta.imports = {});
5822
+ const imported_names = /* @__PURE__ */ new Set();
5817
5823
  for (const m of s.matchAll(import_export_regexp)) {
5818
5824
  if (m[0].startsWith("r")) {
5819
5825
  const req = m[0];
@@ -5827,9 +5833,9 @@ function processImportExports(node3, jsx2) {
5827
5833
  skip_spaces(-1);
5828
5834
  if (s[i2] === ".") continue;
5829
5835
  const src = jsx2.substring(node3.out[m.index + imp.length - 1].begin, node3.out[m.index + imp.length - 1].end);
5830
- const imports = {};
5831
- let star_imports = [];
5832
- let import_alls = [];
5836
+ const named_imports = {};
5837
+ let import_stars = [];
5838
+ let import_defaults = [];
5833
5839
  for (i2 = m.index + 1; i2 < m.index + imp.length - 1; i2++) {
5834
5840
  node3.out.splice(m.index, 1, {
5835
5841
  type: "import",
@@ -5842,7 +5848,7 @@ function processImportExports(node3, jsx2) {
5842
5848
  case ",":
5843
5849
  break;
5844
5850
  case "I": {
5845
- import_alls.push(node3.out[i2]);
5851
+ import_defaults.push(node3.out[i2]);
5846
5852
  continue;
5847
5853
  }
5848
5854
  case "J": {
@@ -5864,10 +5870,10 @@ function processImportExports(node3, jsx2) {
5864
5870
  if (sj[j] === "a") {
5865
5871
  j++;
5866
5872
  while (sj[j] === " " || sj[j] === "\n" || sj[j] === "C") j++;
5867
- imports[ps[j]] = prop;
5873
+ named_imports[ps[j]] = prop;
5868
5874
  j++;
5869
5875
  } else {
5870
- imports[prop] = prop;
5876
+ named_imports[prop] = prop;
5871
5877
  }
5872
5878
  }
5873
5879
  continue;
@@ -5877,7 +5883,7 @@ function processImportExports(node3, jsx2) {
5877
5883
  skip_spaces();
5878
5884
  i2++;
5879
5885
  skip_spaces();
5880
- star_imports.push(node3.out[i2]);
5886
+ import_stars.push(node3.out[i2]);
5881
5887
  continue;
5882
5888
  }
5883
5889
  case "S":
@@ -5885,28 +5891,31 @@ function processImportExports(node3, jsx2) {
5885
5891
  node3.out[i2] = null;
5886
5892
  }
5887
5893
  let cjs = "";
5888
- for (const s2 of star_imports) {
5894
+ for (const s2 of import_stars) {
5889
5895
  cjs += `const ${s2} = require(${src},{requirer:module});
5890
5896
  `;
5897
+ imported_names.add(s2);
5891
5898
  }
5892
- for (const s2 of import_alls) {
5899
+ for (const s2 of import_defaults) {
5893
5900
  cjs += `const ${s2} = require(${src},{requirer:module, checkExport: ['default']}).default;
5894
5901
  `;
5902
+ imported_names.add(s2);
5895
5903
  }
5896
- if (Object.keys(imports).length) {
5904
+ if (Object.keys(named_imports).length) {
5897
5905
  let o = "{";
5898
5906
  let ls = "[";
5899
- for (const p in imports) {
5907
+ for (const p in named_imports) {
5908
+ imported_names.add(p);
5900
5909
  if (o.length > 1) {
5901
5910
  o += ",";
5902
5911
  ls += ",";
5903
5912
  }
5904
- if (p === imports[p]) {
5913
+ if (p === named_imports[p]) {
5905
5914
  o += p;
5906
5915
  ls += `'${p}'`;
5907
5916
  } else {
5908
- o += p + ":" + imports[p];
5909
- ls += `'${imports[p]}'`;
5917
+ o += p + ":" + named_imports[p];
5918
+ ls += `'${named_imports[p]}'`;
5910
5919
  }
5911
5920
  }
5912
5921
  o += "}";
@@ -5914,11 +5923,20 @@ function processImportExports(node3, jsx2) {
5914
5923
  cjs += `const ${o} = require(${src}, {checkExport: ${ls},requirer:module})`;
5915
5924
  } else if (cjs.length === 0) {
5916
5925
  cjs += `require(${src},{requirer:module})`;
5926
+ named_imports[""] = src;
5917
5927
  }
5918
5928
  node3.out[m.index].cjs = cjs;
5919
5929
  continue;
5920
5930
  }
5921
5931
  }
5932
+ const ss = src.slice(1, src.length - 1);
5933
+ if (meta.imports[ss]) {
5934
+ meta.imports[ss] = {
5935
+ import_stars: [...meta.imports[ss].import_stars, ...import_stars],
5936
+ import_defaults: [...meta.imports[ss].import_defaults, ...import_defaults],
5937
+ named_imports: { ...meta.imports[ss].named_imports, ...named_imports }
5938
+ };
5939
+ } else meta.imports[ss] = { import_stars, import_defaults, named_imports };
5922
5940
  } else {
5923
5941
  const exp = m[0];
5924
5942
  node3.out.splice(m.index, 1, {
@@ -6032,13 +6050,17 @@ function processImportExports(node3, jsx2) {
6032
6050
  }
6033
6051
  }
6034
6052
  }
6053
+ if (meta.imported_names) {
6054
+ meta.imported_names = /* @__PURE__ */ new Set([...meta.imported_names, ...imported_names]);
6055
+ } else {
6056
+ meta.imported_names = imported_names;
6057
+ }
6035
6058
  }
6036
6059
 
6037
6060
  // .tmp/src/jsx.js
6038
6061
  var transpilerConfig = {
6039
6062
  setBlockLabels: true,
6040
6063
  enableLabelStack: false,
6041
- injectLabels: true,
6042
6064
  // todo: alt+shift+7 on apple abc extended layout is better i think,
6043
6065
  // but my current editor doesn't support syntax highlighting with it.
6044
6066
  preprocessorDelimiter: "\u0294"
@@ -6596,7 +6618,7 @@ function parseJS(code2, index2 = 0, is_block = false, container2) {
6596
6618
  if (container2) container2.children.push(b2);
6597
6619
  return b2;
6598
6620
  }
6599
- function labelFunctions(node3, eols, blocks_info2) {
6621
+ function labelFunctions(node3, eols, blocksInfo2) {
6600
6622
  node3.already_labeled = true;
6601
6623
  function getNext(i3, step = 1) {
6602
6624
  while ((i3 += step) < node3.children.length && i3 >= 0) {
@@ -6625,11 +6647,11 @@ function labelFunctions(node3, eols, blocks_info2) {
6625
6647
  if (nxt === null) continue;
6626
6648
  if (transpilerConfig.injectTraceLabels && typeof nxt === "object" && nxt.type === "js") {
6627
6649
  const begin = getRowCol(eols, chi);
6628
- nxt.children.splice(1, 0, `/*LILACTBLOCK${++blocks_info2.counter}:${begin}:${label}*/try{`);
6650
+ nxt.children.splice(1, 0, `/*LILACTBLOCK${++blocksInfo2.counter}:${begin}:${label}*/try{`);
6629
6651
  if (transpilerConfig.enableLabelStack) {
6630
- nxt.children.splice(nxt.children.length - 1, 0, `} catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info2.counter},e.lilact_trace];throw e}`);
6652
+ nxt.children.splice(nxt.children.length - 1, 0, `} catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocksInfo2.counter},e.lilact_trace];throw e}`);
6631
6653
  } else {
6632
- nxt.children.splice(nxt.children.length - 1, 0, `} catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocks_info2.counter};throw e}`);
6654
+ nxt.children.splice(nxt.children.length - 1, 0, `} catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocksInfo2.counter};throw e}`);
6633
6655
  }
6634
6656
  chi += 2;
6635
6657
  }
@@ -6643,19 +6665,19 @@ function labelFunctions(node3, eols, blocks_info2) {
6643
6665
  nxt.children.splice(
6644
6666
  1,
6645
6667
  0,
6646
- `/*LILACTBLOCK${++blocks_info2.counter}:${begin}:<ARROW>*/try {`
6668
+ `/*LILACTBLOCK${++blocksInfo2.counter}:${begin}:<ARROW>*/try {`
6647
6669
  );
6648
6670
  if (transpilerConfig.enableLabelStack) {
6649
6671
  nxt.children.splice(
6650
6672
  nxt.children.length - 1,
6651
6673
  0,
6652
- `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info2.counter},e.lilact_trace];throw e}`
6674
+ `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocksInfo2.counter},e.lilact_trace];throw e}`
6653
6675
  );
6654
6676
  } else {
6655
6677
  nxt.children.splice(
6656
6678
  nxt.children.length - 1,
6657
6679
  0,
6658
- `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocks_info2.counter};throw e}`
6680
+ `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocksInfo2.counter};throw e}`
6659
6681
  );
6660
6682
  }
6661
6683
  }
@@ -6749,13 +6771,19 @@ function transpileJSX(jsx2, {
6749
6771
  injectTraceLabels = false,
6750
6772
  discardComments = false,
6751
6773
  produceCJS = false,
6774
+ referentiateImports = false,
6775
+ importsObject = "Lilact.scriptImportsObject",
6776
+ // first letter must be capital so components work as expected
6777
+ importsObjectVar = "LilactImports",
6778
+ // first letter must be capital so components work as expected
6752
6779
  logErrors = false,
6753
6780
  // lilact internal
6754
- blocks_info: blocks_info2 = {
6781
+ mappings = [],
6782
+ meta,
6783
+ blocksInfo: blocksInfo2 = {
6755
6784
  labels: {},
6756
6785
  counter: 0
6757
- },
6758
- mappings = []
6786
+ }
6759
6787
  } = {}) {
6760
6788
  transpilerConfig.preprocessorDelimiter ?? (transpilerConfig.preprocessorDelimiter = "\u0294");
6761
6789
  transpilerConfig.injectTraceLabels ?? (transpilerConfig.injectTraceLabels = injectTraceLabels);
@@ -6817,18 +6845,31 @@ function transpileJSX(jsx2, {
6817
6845
  }
6818
6846
  node3.children = node3.children.filter((x) => x !== "");
6819
6847
  if (transpilerConfig.setBlockLabels && !node3.already_labeled) {
6820
- labelFunctions(node3, eols, blocks_info2);
6848
+ labelFunctions(node3, eols, blocksInfo2);
6821
6849
  }
6822
6850
  }
6823
6851
  };
6824
6852
  prepare(json);
6825
6853
  preprocessPragmas(json);
6854
+ const flattened_nodes = [];
6826
6855
  const codify = (outlen, node3, is_attr = false, is_xml = false) => {
6827
- if (typeof node3 !== "object") return node3;
6856
+ flattened_nodes.push(node3);
6857
+ if (typeof node3 !== "object") {
6858
+ if (referentiateImports && typeof node3 === "string") {
6859
+ if (meta?.imported_names.has(node3)) {
6860
+ let j = flattened_nodes.length - 2;
6861
+ while (typeof flattened_nodes[j] === "string" && flattened_nodes[j].trim() === "" || typeof flattened_nodes[j] === "object" && flattened_nodes[j].type === "comment") j--;
6862
+ if (typeof flattened_nodes[j] !== "string" || flattened_nodes[j] !== ".") {
6863
+ return importsObjectVar + "." + node3;
6864
+ }
6865
+ }
6866
+ }
6867
+ return node3;
6868
+ }
6828
6869
  if (node3 === null) return "";
6829
6870
  node3.out_index = outlen;
6830
6871
  if (node3.type === "string") return jsx2.substring(node3.begin, node3.end);
6831
- if (node3.type === "import") return node3.cjs;
6872
+ if (node3.type === "import") return referentiateImports ? "" : node3.cjs;
6832
6873
  if (node3.type === "export") return node3.cjs;
6833
6874
  if (node3.type === "regex") return jsx2.substring(node3.begin, node3.end);
6834
6875
  if (node3.type === "comment") return discardComments || is_attr ? "" : jsx2.substring(node3.begin, node3.end);
@@ -6836,7 +6877,7 @@ function transpileJSX(jsx2, {
6836
6877
  if (node3.type === "parenthesis") {
6837
6878
  let out2 = "(";
6838
6879
  if (node3.out) {
6839
- if (produceCJS) processImportExports(node3, jsx2);
6880
+ if (produceCJS || referentiateImports) processImportExports(node3, jsx2, meta);
6840
6881
  for (const ch2 of node3.out) {
6841
6882
  out2 += codify(outlen + out2.length - 1, ch2);
6842
6883
  }
@@ -6846,7 +6887,7 @@ function transpileJSX(jsx2, {
6846
6887
  if (node3.type === "js") {
6847
6888
  let out2 = "";
6848
6889
  if (node3.out) {
6849
- if (produceCJS) processImportExports(node3, jsx2);
6890
+ if (produceCJS || referentiateImports) processImportExports(node3, jsx2, meta);
6850
6891
  for (const ch2 of node3.out) {
6851
6892
  if (is_xml && ch2.type === "comment") continue;
6852
6893
  out2 += codify(outlen + out2.length - (is_attr ? 1 : 0), ch2);
@@ -6861,6 +6902,9 @@ function transpileJSX(jsx2, {
6861
6902
  return out2;
6862
6903
  }
6863
6904
  if (node3.type === "xml") {
6905
+ if (referentiateImports && meta?.imported_names?.has(node3.tag) && node3.tag[0] === node3.tag[0].toUpperCase()) {
6906
+ node3.tag = importsObjectVar + "." + node3.tag;
6907
+ }
6864
6908
  if (node3.tag.length === 0) {
6865
6909
  node3.tag = fragment;
6866
6910
  } else if (node3.tag[0] !== node3.tag[0].toUpperCase()) {
@@ -6896,14 +6940,17 @@ function transpileJSX(jsx2, {
6896
6940
  };
6897
6941
  let out = "";
6898
6942
  if (injectTraceLabels) {
6899
- out = `/*LILACTBLOCK${++blocks_info2.counter}:0,0:<EXEC>*/try{`;
6943
+ out = `/*LILACTBLOCK${++blocksInfo2.counter}:0,0:<EXEC>*/try{`;
6944
+ }
6945
+ if (referentiateImports) {
6946
+ out += `const ${importsObjectVar} = ${importsObject};`;
6900
6947
  }
6901
6948
  out += codify(out.length, json);
6902
6949
  if (injectTraceLabels) {
6903
6950
  if (transpilerConfig.enableLabelStack) {
6904
- out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info2.counter},e.lilact_trace];throw e}`;
6951
+ out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocksInfo2.counter},e.lilact_trace];throw e}`;
6905
6952
  } else {
6906
- out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocks_info2.counter};throw e}`;
6953
+ out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocksInfo2.counter};throw e}`;
6907
6954
  }
6908
6955
  }
6909
6956
  const inline_sm = generateSourceMap(json, path2, eols, scanEOLs(out), mappings);
@@ -6915,7 +6962,7 @@ function transpileJSX(jsx2, {
6915
6962
 
6916
6963
  // .tmp/src/lilact.jsx
6917
6964
  var Lilact2 = {
6918
- VERSION: "RC.4",
6965
+ VERSION: "RC.5",
6919
6966
  // Configuration
6920
6967
  defaultTransitionTimeout: 300,
6921
6968
  defaultIsEqual: Object.is,
@@ -7013,7 +7060,8 @@ export {
7013
7060
  TransitionGroup,
7014
7061
  addWrappedEventListener,
7015
7062
  animationFramePromise,
7016
- blocks_info,
7063
+ asError2 as asError,
7064
+ blocksInfo,
7017
7065
  boolean_html_attributes_set,
7018
7066
  capture_events_set,
7019
7067
  clearInterval,