lilact 0.28.4 → 0.29.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 (45) hide show
  1. package/dist/lilact.development.js +227 -179
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +29 -29
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +29 -29
  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 +3 -6
  26. package/docs/static/lilact.development.js +227 -179
  27. package/docs/static/lilact.development.js.map +3 -3
  28. package/docs/static/lilact.development.min.js +29 -29
  29. package/docs/static/lilact.development.min.js.map +3 -3
  30. package/docs/static/lilact.production.min.js +29 -29
  31. package/docs/variables/components.cloneElement.html +1 -1
  32. package/docs/variables/errors.blocksInfo.html +1 -0
  33. package/examples/index.html +3 -4
  34. package/examples/lilact.development.js +227 -179
  35. package/examples/lilact.development.js.map +3 -3
  36. package/examples/lilact.development.min.js +29 -29
  37. package/examples/lilact.development.min.js.map +3 -3
  38. package/examples/lilact.production.min.js +29 -29
  39. package/package.json +1 -1
  40. package/src/components.jsx +118 -122
  41. package/src/errors.jsx +4 -4
  42. package/src/expscan.js +40 -15
  43. package/src/jsx.js +67 -38
  44. package/src/run.jsx +51 -39
  45. package/docs/variables/errors.blocks_info.html +0 -1
@@ -2452,125 +2452,122 @@ 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
- 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);
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--;
2557
2545
  } 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];
2546
+ const core = prepareCore(this, item);
2547
+ this.outlet[i2] = core;
2548
+ if (core[TEXT2] === void 0) {
2549
+ core.container = this.element ? this : this.container;
2550
+ core.apply(item.props);
2551
+ } else {
2552
+ if (!core.element) {
2553
+ core.element = document.createTextNode(item[TEXT2]);
2554
+ core[TEXT2] = item[TEXT2];
2555
+ } else if (core[TEXT2] !== item[TEXT2]) {
2556
+ core.element.textContent = item[TEXT2];
2557
+ core[TEXT2] = item[TEXT2];
2558
+ }
2564
2559
  }
2565
2560
  }
2566
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;
2567
2568
  }
2568
- if (this.cache) this.cache.commit();
2569
- if (this.element) this.arrangeOutlet();
2570
- if (this.component.componentDidUpdate) {
2571
- this.component.componentDidUpdate(prev_props, prev_state, this.last_snapshot);
2572
- }
2573
- if (this.last_snapshot) delete this.last_snapshot;
2569
+ } catch (e) {
2570
+ renderErrorHandler(this, e);
2574
2571
  }
2575
2572
  }
2576
2573
  async cleanup() {
@@ -2767,7 +2764,7 @@ var ComponentCore = class {
2767
2764
  core.container = this.element ? this : this.container;
2768
2765
  core.container.appendElement(core);
2769
2766
  } else {
2770
- if (core.arrangeOutlet) core.arrangeOutlet();
2767
+ if (core.arrangeOutlet && core.outlet) core.arrangeOutlet();
2771
2768
  if (!core?.mounted) {
2772
2769
  core.mounted = true;
2773
2770
  if (core?.component?.componentDidMount) {
@@ -3675,17 +3672,14 @@ function report(value, path2) {
3675
3672
  }
3676
3673
  var required_scripts = {};
3677
3674
  function createModule(path2, {
3678
- code: code2 = "",
3679
- isInline: isInline2 = false,
3680
- isModule: isModule2 = true
3675
+ code: code2 = ""
3681
3676
  } = {}) {
3682
3677
  const module2 = {
3683
3678
  path: path2,
3684
3679
  code: String(code2),
3685
3680
  mappings: [],
3681
+ meta: {},
3686
3682
  exports: {},
3687
- isInline: isInline2,
3688
- isModule: isModule2,
3689
3683
  // True only after the module has been successfully evaluated.
3690
3684
  loaded: false,
3691
3685
  // The promise for the request currently loading this resource.
@@ -3696,37 +3690,57 @@ function createModule(path2, {
3696
3690
  required_scripts[path2] = module2;
3697
3691
  return module2;
3698
3692
  }
3699
- function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3700
- isInline = true,
3701
- isModule = true
3702
- } = {}) {
3693
+ function makeImportsObject(mod) {
3694
+ mod.importsObject ?? (mod.importsObject = {});
3695
+ 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
+ }
3701
+ for (const i2 in imps.named_imports) {
3702
+ 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];
3706
+ }
3707
+ for (const i2 of imps.import_defaults) {
3708
+ if (!exps.hasOwnProperty("default")) throw new Error(`Imported module does not export a default.`);
3709
+ mod.importsObject[i2] = exps.default;
3710
+ }
3711
+ for (const i2 of imps.import_stars) {
3712
+ mod.importsObject[i2] = { ...exps };
3713
+ }
3714
+ }
3715
+ }
3716
+ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {} = {}) {
3703
3717
  let module = required_scripts[path];
3704
3718
  if (!module) {
3705
3719
  module = createModule(path, {
3706
- code: jsx,
3707
- isInline,
3708
- isModule
3720
+ code: jsx
3709
3721
  });
3710
3722
  } else {
3711
3723
  module.path = path;
3712
3724
  module.code = String(jsx);
3713
3725
  module.mappings = [];
3714
3726
  module.exports = {};
3715
- module.isInline = isInline;
3716
- module.isModule = isModule;
3717
3727
  module.loaded = false;
3718
3728
  module.error = void 0;
3729
+ module.importsObject = void 0;
3730
+ module.meta = {};
3719
3731
  }
3720
3732
  let processed;
3721
3733
  try {
3722
3734
  processed = lilact_default.transpileJSX(String(jsx), {
3723
3735
  path,
3724
3736
  mappings: module.mappings,
3737
+ meta: module.meta,
3725
3738
  factory: "createComponent",
3726
3739
  appendSourcemap: true,
3727
3740
  injectTraceLabels: true,
3728
- produceCJS: true,
3729
- blocks_info: lilact_default.blocks_info
3741
+ produceCJS: false,
3742
+ referentiateImports: true,
3743
+ blocksInfo: lilact_default.blocksInfo
3730
3744
  });
3731
3745
  } catch (value) {
3732
3746
  const error2 = asError(value);
@@ -3741,10 +3755,11 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, {
3741
3755
  lilact_default.scanBlockLabels(processed, path);
3742
3756
  }
3743
3757
  try {
3744
- new Function(processed);
3745
3758
  globalThis.Lilact = lilact_default;
3746
3759
  globalThis.createComponent = lilact_default.createComponent;
3747
3760
  globalThis.Fragment = lilact_default.Fragment;
3761
+ if (!module.importsObject) makeImportsObject(module);
3762
+ lilact_default.scriptImportsObject = module.importsObject;
3748
3763
  const result = eval(processed);
3749
3764
  module.loaded = true;
3750
3765
  return isEmpty(module.exports) ? result : module.exports;
@@ -3792,10 +3807,7 @@ function loadAsyncResource(path2, module2) {
3792
3807
  module2.loaded = true;
3793
3808
  return void 0;
3794
3809
  }
3795
- return run(module2.code, path2, {
3796
- isInline: false,
3797
- isModule: true
3798
- });
3810
+ return run(module2.code, path2, {});
3799
3811
  }).then((result2) => result2?.default ?? result2).catch((error2) => {
3800
3812
  module2.error = report(error2, path2);
3801
3813
  throw module2.error;
@@ -3815,15 +3827,12 @@ function require2(path2) {
3815
3827
  if (lilact_default.importObjectPaths?.[path2]) {
3816
3828
  return lilact_default.importObjectPaths[path2];
3817
3829
  }
3818
- if (options.requirer?.path) {
3830
+ if (options?.requirer?.path) {
3819
3831
  path2 = joinPaths(options.requirer.path, path2);
3820
3832
  }
3821
3833
  const loadAsync = Boolean(lilact_default[LAZY]) || Boolean(options.isLazy);
3822
- const module2 = getOrCreateModule(path2, {
3823
- isInline: false,
3824
- isModule: true
3825
- });
3826
- if (module2.loaded && !options.forceUpdate) {
3834
+ const module2 = getOrCreateModule(path2, {});
3835
+ if (module2.loaded && !options.forceReload) {
3827
3836
  return module2.exports;
3828
3837
  }
3829
3838
  if (path2.startsWith("#")) {
@@ -3834,7 +3843,7 @@ function require2(path2) {
3834
3843
  path2
3835
3844
  );
3836
3845
  }
3837
- return run(element.textContent || "", path2);
3846
+ return run(element.textContent || "", path2, { forceReload: options.forceReload });
3838
3847
  }
3839
3848
  if (loadAsync) {
3840
3849
  lilact_default[LAZY] = false;
@@ -3851,10 +3860,7 @@ function require2(path2) {
3851
3860
  module2.loaded = true;
3852
3861
  return void 0;
3853
3862
  }
3854
- return run(String(resolved), path2, {
3855
- isInline: false,
3856
- isModule: true
3857
- });
3863
+ return run(String(resolved), path2, { forceReload: options.forceReload });
3858
3864
  }
3859
3865
  const request = new XMLHttpRequest();
3860
3866
  try {
@@ -3870,10 +3876,7 @@ function require2(path2) {
3870
3876
  module2.loaded = true;
3871
3877
  return void 0;
3872
3878
  }
3873
- return run(request.responseText, path2, {
3874
- isInline: false,
3875
- isModule: true
3876
- });
3879
+ return run(request.responseText, path2, { forceReload: options.forceReload });
3877
3880
  }
3878
3881
  throw report(
3879
3882
  new Error(
@@ -4656,7 +4659,8 @@ function animationFramePromise() {
4656
4659
  // .tmp/src/errors.jsx
4657
4660
  var errors_exports = {};
4658
4661
  __export(errors_exports, {
4659
- blocks_info: () => blocks_info,
4662
+ asError: () => asError2,
4663
+ blocksInfo: () => blocksInfo,
4660
4664
  error: () => error,
4661
4665
  globalErrorHandler: () => globalErrorHandler,
4662
4666
  scanBlockLabels: () => scanBlockLabels,
@@ -4720,7 +4724,7 @@ function traceBlock(error2) {
4720
4724
  }
4721
4725
  function blockInfo(error2) {
4722
4726
  const trace = traceBlock(error2);
4723
- return trace == null ? null : lilact_default.blocks_info?.labels?.[trace];
4727
+ return trace == null ? null : lilact_default.blocksInfo?.labels?.[trace];
4724
4728
  }
4725
4729
  function mapLocation(mappings, line2, column2) {
4726
4730
  if (!Array.isArray(mappings) || !mappings.length || !Number.isFinite(line2) || !Number.isFinite(column2)) {
@@ -4879,7 +4883,7 @@ function scanBlockLabels(code2, path2) {
4879
4883
  for (const match2 of String(code2).matchAll(
4880
4884
  /LILACTBLOCK(\d+):(\d+),(\d+):([^*]+)\*\//gm
4881
4885
  )) {
4882
- lilact_default.blocks_info.labels[match2[1]] = {
4886
+ lilact_default.blocksInfo.labels[match2[1]] = {
4883
4887
  path: path2,
4884
4888
  line: Number(match2[2]),
4885
4889
  column: Number(match2[3]),
@@ -4887,7 +4891,7 @@ function scanBlockLabels(code2, path2) {
4887
4891
  };
4888
4892
  }
4889
4893
  }
4890
- var blocks_info = {
4894
+ var blocksInfo = {
4891
4895
  counter: 0,
4892
4896
  labels: {}
4893
4897
  };
@@ -5764,7 +5768,7 @@ function generateSequence(arr, labeler2 = labeler2.bind(null, null)) {
5764
5768
  }
5765
5769
  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;
5766
5770
  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;
5767
- function processImportExports(node3, jsx2) {
5771
+ function processImportExports(node3, jsx2, meta) {
5768
5772
  const s = generateSequence(
5769
5773
  node3.out,
5770
5774
  labeler.bind(
@@ -5809,6 +5813,8 @@ function processImportExports(node3, jsx2) {
5809
5813
  }
5810
5814
  }
5811
5815
  begins.push(node3.end);
5816
+ meta.imports ?? (meta.imports = {});
5817
+ const imported_names = /* @__PURE__ */ new Set();
5812
5818
  for (const m of s.matchAll(import_export_regexp)) {
5813
5819
  if (m[0].startsWith("r")) {
5814
5820
  const req = m[0];
@@ -5822,9 +5828,9 @@ function processImportExports(node3, jsx2) {
5822
5828
  skip_spaces(-1);
5823
5829
  if (s[i2] === ".") continue;
5824
5830
  const src = jsx2.substring(node3.out[m.index + imp.length - 1].begin, node3.out[m.index + imp.length - 1].end);
5825
- const imports = {};
5826
- let star_imports = [];
5827
- let import_alls = [];
5831
+ const named_imports = {};
5832
+ let import_stars = [];
5833
+ let import_defaults = [];
5828
5834
  for (i2 = m.index + 1; i2 < m.index + imp.length - 1; i2++) {
5829
5835
  node3.out.splice(m.index, 1, {
5830
5836
  type: "import",
@@ -5837,7 +5843,7 @@ function processImportExports(node3, jsx2) {
5837
5843
  case ",":
5838
5844
  break;
5839
5845
  case "I": {
5840
- import_alls.push(node3.out[i2]);
5846
+ import_defaults.push(node3.out[i2]);
5841
5847
  continue;
5842
5848
  }
5843
5849
  case "J": {
@@ -5859,10 +5865,10 @@ function processImportExports(node3, jsx2) {
5859
5865
  if (sj[j] === "a") {
5860
5866
  j++;
5861
5867
  while (sj[j] === " " || sj[j] === "\n" || sj[j] === "C") j++;
5862
- imports[ps[j]] = prop;
5868
+ named_imports[ps[j]] = prop;
5863
5869
  j++;
5864
5870
  } else {
5865
- imports[prop] = prop;
5871
+ named_imports[prop] = prop;
5866
5872
  }
5867
5873
  }
5868
5874
  continue;
@@ -5872,7 +5878,7 @@ function processImportExports(node3, jsx2) {
5872
5878
  skip_spaces();
5873
5879
  i2++;
5874
5880
  skip_spaces();
5875
- star_imports.push(node3.out[i2]);
5881
+ import_stars.push(node3.out[i2]);
5876
5882
  continue;
5877
5883
  }
5878
5884
  case "S":
@@ -5880,28 +5886,31 @@ function processImportExports(node3, jsx2) {
5880
5886
  node3.out[i2] = null;
5881
5887
  }
5882
5888
  let cjs = "";
5883
- for (const s2 of star_imports) {
5889
+ for (const s2 of import_stars) {
5884
5890
  cjs += `const ${s2} = require(${src},{requirer:module});
5885
5891
  `;
5892
+ imported_names.add(s2);
5886
5893
  }
5887
- for (const s2 of import_alls) {
5894
+ for (const s2 of import_defaults) {
5888
5895
  cjs += `const ${s2} = require(${src},{requirer:module, checkExport: ['default']}).default;
5889
5896
  `;
5897
+ imported_names.add(s2);
5890
5898
  }
5891
- if (Object.keys(imports).length) {
5899
+ if (Object.keys(named_imports).length) {
5892
5900
  let o = "{";
5893
5901
  let ls = "[";
5894
- for (const p in imports) {
5902
+ for (const p in named_imports) {
5903
+ imported_names.add(p);
5895
5904
  if (o.length > 1) {
5896
5905
  o += ",";
5897
5906
  ls += ",";
5898
5907
  }
5899
- if (p === imports[p]) {
5908
+ if (p === named_imports[p]) {
5900
5909
  o += p;
5901
5910
  ls += `'${p}'`;
5902
5911
  } else {
5903
- o += p + ":" + imports[p];
5904
- ls += `'${imports[p]}'`;
5912
+ o += p + ":" + named_imports[p];
5913
+ ls += `'${named_imports[p]}'`;
5905
5914
  }
5906
5915
  }
5907
5916
  o += "}";
@@ -5909,11 +5918,20 @@ function processImportExports(node3, jsx2) {
5909
5918
  cjs += `const ${o} = require(${src}, {checkExport: ${ls},requirer:module})`;
5910
5919
  } else if (cjs.length === 0) {
5911
5920
  cjs += `require(${src},{requirer:module})`;
5921
+ named_imports[""] = src;
5912
5922
  }
5913
5923
  node3.out[m.index].cjs = cjs;
5914
5924
  continue;
5915
5925
  }
5916
5926
  }
5927
+ const ss = src.slice(1, src.length - 1);
5928
+ if (meta.imports[ss]) {
5929
+ meta.imports[ss] = {
5930
+ import_stars: [...meta.imports[ss].import_stars, ...import_stars],
5931
+ import_defaults: [...meta.imports[ss].import_defaults, ...import_defaults],
5932
+ named_imports: { ...meta.imports[ss].named_imports, ...named_imports }
5933
+ };
5934
+ } else meta.imports[ss] = { import_stars, import_defaults, named_imports };
5917
5935
  } else {
5918
5936
  const exp = m[0];
5919
5937
  node3.out.splice(m.index, 1, {
@@ -6027,13 +6045,17 @@ function processImportExports(node3, jsx2) {
6027
6045
  }
6028
6046
  }
6029
6047
  }
6048
+ if (meta.imported_names) {
6049
+ meta.imported_names = /* @__PURE__ */ new Set([...meta.imported_names, ...imported_names]);
6050
+ } else {
6051
+ meta.imported_names = imported_names;
6052
+ }
6030
6053
  }
6031
6054
 
6032
6055
  // .tmp/src/jsx.js
6033
6056
  var transpilerConfig = {
6034
6057
  setBlockLabels: true,
6035
6058
  enableLabelStack: false,
6036
- injectLabels: true,
6037
6059
  // todo: alt+shift+7 on apple abc extended layout is better i think,
6038
6060
  // but my current editor doesn't support syntax highlighting with it.
6039
6061
  preprocessorDelimiter: "\u0294"
@@ -6591,7 +6613,7 @@ function parseJS(code2, index2 = 0, is_block = false, container2) {
6591
6613
  if (container2) container2.children.push(b2);
6592
6614
  return b2;
6593
6615
  }
6594
- function labelFunctions(node3, eols, blocks_info2) {
6616
+ function labelFunctions(node3, eols, blocksInfo2) {
6595
6617
  node3.already_labeled = true;
6596
6618
  function getNext(i3, step = 1) {
6597
6619
  while ((i3 += step) < node3.children.length && i3 >= 0) {
@@ -6620,11 +6642,11 @@ function labelFunctions(node3, eols, blocks_info2) {
6620
6642
  if (nxt === null) continue;
6621
6643
  if (transpilerConfig.injectTraceLabels && typeof nxt === "object" && nxt.type === "js") {
6622
6644
  const begin = getRowCol(eols, chi);
6623
- nxt.children.splice(1, 0, `/*LILACTBLOCK${++blocks_info2.counter}:${begin}:${label}*/try{`);
6645
+ nxt.children.splice(1, 0, `/*LILACTBLOCK${++blocksInfo2.counter}:${begin}:${label}*/try{`);
6624
6646
  if (transpilerConfig.enableLabelStack) {
6625
- 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}`);
6647
+ 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}`);
6626
6648
  } else {
6627
- 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}`);
6649
+ 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}`);
6628
6650
  }
6629
6651
  chi += 2;
6630
6652
  }
@@ -6638,19 +6660,19 @@ function labelFunctions(node3, eols, blocks_info2) {
6638
6660
  nxt.children.splice(
6639
6661
  1,
6640
6662
  0,
6641
- `/*LILACTBLOCK${++blocks_info2.counter}:${begin}:<ARROW>*/try {`
6663
+ `/*LILACTBLOCK${++blocksInfo2.counter}:${begin}:<ARROW>*/try {`
6642
6664
  );
6643
6665
  if (transpilerConfig.enableLabelStack) {
6644
6666
  nxt.children.splice(
6645
6667
  nxt.children.length - 1,
6646
6668
  0,
6647
- `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info2.counter},e.lilact_trace];throw e}`
6669
+ `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocksInfo2.counter},e.lilact_trace];throw e}`
6648
6670
  );
6649
6671
  } else {
6650
6672
  nxt.children.splice(
6651
6673
  nxt.children.length - 1,
6652
6674
  0,
6653
- `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocks_info2.counter};throw e}`
6675
+ `} catch(e){if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocksInfo2.counter};throw e}`
6654
6676
  );
6655
6677
  }
6656
6678
  }
@@ -6744,13 +6766,19 @@ function transpileJSX(jsx2, {
6744
6766
  injectTraceLabels = false,
6745
6767
  discardComments = false,
6746
6768
  produceCJS = false,
6769
+ referentiateImports = false,
6770
+ importsObject = "Lilact.scriptImportsObject",
6771
+ // first letter must be capital so components work as expected
6772
+ importsObjectVar = "LilactImports",
6773
+ // first letter must be capital so components work as expected
6747
6774
  logErrors = false,
6748
6775
  // lilact internal
6749
- blocks_info: blocks_info2 = {
6776
+ mappings = [],
6777
+ meta,
6778
+ blocksInfo: blocksInfo2 = {
6750
6779
  labels: {},
6751
6780
  counter: 0
6752
- },
6753
- mappings = []
6781
+ }
6754
6782
  } = {}) {
6755
6783
  transpilerConfig.preprocessorDelimiter ?? (transpilerConfig.preprocessorDelimiter = "\u0294");
6756
6784
  transpilerConfig.injectTraceLabels ?? (transpilerConfig.injectTraceLabels = injectTraceLabels);
@@ -6812,18 +6840,31 @@ function transpileJSX(jsx2, {
6812
6840
  }
6813
6841
  node3.children = node3.children.filter((x) => x !== "");
6814
6842
  if (transpilerConfig.setBlockLabels && !node3.already_labeled) {
6815
- labelFunctions(node3, eols, blocks_info2);
6843
+ labelFunctions(node3, eols, blocksInfo2);
6816
6844
  }
6817
6845
  }
6818
6846
  };
6819
6847
  prepare(json);
6820
6848
  preprocessPragmas(json);
6849
+ const flattened_nodes = [];
6821
6850
  const codify = (outlen, node3, is_attr = false, is_xml = false) => {
6822
- if (typeof node3 !== "object") return node3;
6851
+ flattened_nodes.push(node3);
6852
+ if (typeof node3 !== "object") {
6853
+ if (referentiateImports && typeof node3 === "string") {
6854
+ if (meta?.imported_names.has(node3)) {
6855
+ let j = flattened_nodes.length - 2;
6856
+ while (typeof flattened_nodes[j] === "string" && flattened_nodes[j].trim() === "" || typeof flattened_nodes[j] === "object" && flattened_nodes[j].type === "comment") j--;
6857
+ if (typeof flattened_nodes[j] !== "string" || flattened_nodes[j] !== ".") {
6858
+ return importsObjectVar + "." + node3;
6859
+ }
6860
+ }
6861
+ }
6862
+ return node3;
6863
+ }
6823
6864
  if (node3 === null) return "";
6824
6865
  node3.out_index = outlen;
6825
6866
  if (node3.type === "string") return jsx2.substring(node3.begin, node3.end);
6826
- if (node3.type === "import") return node3.cjs;
6867
+ if (node3.type === "import") return referentiateImports ? "" : node3.cjs;
6827
6868
  if (node3.type === "export") return node3.cjs;
6828
6869
  if (node3.type === "regex") return jsx2.substring(node3.begin, node3.end);
6829
6870
  if (node3.type === "comment") return discardComments || is_attr ? "" : jsx2.substring(node3.begin, node3.end);
@@ -6831,7 +6872,7 @@ function transpileJSX(jsx2, {
6831
6872
  if (node3.type === "parenthesis") {
6832
6873
  let out2 = "(";
6833
6874
  if (node3.out) {
6834
- if (produceCJS) processImportExports(node3, jsx2);
6875
+ if (produceCJS || referentiateImports) processImportExports(node3, jsx2, meta);
6835
6876
  for (const ch2 of node3.out) {
6836
6877
  out2 += codify(outlen + out2.length - 1, ch2);
6837
6878
  }
@@ -6841,7 +6882,7 @@ function transpileJSX(jsx2, {
6841
6882
  if (node3.type === "js") {
6842
6883
  let out2 = "";
6843
6884
  if (node3.out) {
6844
- if (produceCJS) processImportExports(node3, jsx2);
6885
+ if (produceCJS || referentiateImports) processImportExports(node3, jsx2, meta);
6845
6886
  for (const ch2 of node3.out) {
6846
6887
  if (is_xml && ch2.type === "comment") continue;
6847
6888
  out2 += codify(outlen + out2.length - (is_attr ? 1 : 0), ch2);
@@ -6856,6 +6897,9 @@ function transpileJSX(jsx2, {
6856
6897
  return out2;
6857
6898
  }
6858
6899
  if (node3.type === "xml") {
6900
+ if (referentiateImports && meta?.imported_names?.has(node3.tag) && node3.tag[0] === node3.tag[0].toUpperCase()) {
6901
+ node3.tag = importsObjectVar + "." + node3.tag;
6902
+ }
6859
6903
  if (node3.tag.length === 0) {
6860
6904
  node3.tag = fragment;
6861
6905
  } else if (node3.tag[0] !== node3.tag[0].toUpperCase()) {
@@ -6891,14 +6935,17 @@ function transpileJSX(jsx2, {
6891
6935
  };
6892
6936
  let out = "";
6893
6937
  if (injectTraceLabels) {
6894
- out = `/*LILACTBLOCK${++blocks_info2.counter}:0,0:<EXEC>*/try{`;
6938
+ out = `/*LILACTBLOCK${++blocksInfo2.counter}:0,0:<EXEC>*/try{`;
6939
+ }
6940
+ if (referentiateImports) {
6941
+ out += `const ${importsObjectVar} = ${importsObject};`;
6895
6942
  }
6896
6943
  out += codify(out.length, json);
6897
6944
  if (injectTraceLabels) {
6898
6945
  if (transpilerConfig.enableLabelStack) {
6899
- out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info2.counter},e.lilact_trace];throw e}`;
6946
+ out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocksInfo2.counter},e.lilact_trace];throw e}`;
6900
6947
  } else {
6901
- out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocks_info2.counter};throw e}`;
6948
+ out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=${blocksInfo2.counter};throw e}`;
6902
6949
  }
6903
6950
  }
6904
6951
  const inline_sm = generateSourceMap(json, path2, eols, scanEOLs(out), mappings);
@@ -7008,7 +7055,8 @@ export {
7008
7055
  TransitionGroup,
7009
7056
  addWrappedEventListener,
7010
7057
  animationFramePromise,
7011
- blocks_info,
7058
+ asError2 as asError,
7059
+ blocksInfo,
7012
7060
  boolean_html_attributes_set,
7013
7061
  capture_events_set,
7014
7062
  clearInterval,