lilact 0.22.0 → 0.23.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 (57) hide show
  1. package/README.md +4 -4
  2. package/dist/lilact.development.js +32 -12
  3. package/dist/lilact.development.js.map +2 -2
  4. package/dist/lilact.development.min.js +26 -25
  5. package/dist/lilact.development.min.js.map +3 -3
  6. package/dist/lilact.production.min.js +26 -25
  7. package/docs/assets/hierarchy.js +1 -1
  8. package/docs/assets/navigation.js +1 -1
  9. package/docs/assets/search.js +1 -1
  10. package/docs/classes/components.Component.html +1 -1
  11. package/docs/classes/components.HTMLComponent.html +1 -1
  12. package/docs/classes/components.RootComponent.html +1 -1
  13. package/docs/functions/accessories.DragHandle.html +2 -2
  14. package/docs/functions/accessories.Spinner.html +2 -2
  15. package/docs/functions/components.cloneComponent.html +1 -0
  16. package/docs/functions/components.memo.html +1 -1
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/redux.Provider.html +2 -2
  19. package/docs/functions/redux.connect.html +2 -2
  20. package/docs/functions/router.HashRouter.html +2 -2
  21. package/docs/functions/router.Link.html +2 -2
  22. package/docs/functions/router.NavLink.html +2 -2
  23. package/docs/functions/router.Routes.html +2 -2
  24. package/docs/functions/run.lazy.html +3 -3
  25. package/docs/functions/run.require.html +4 -9
  26. package/docs/functions/run.runScripts.html +1 -1
  27. package/docs/functions/timers.timeoutPromise.html +144 -2
  28. package/docs/functions/transition.CSSTransition.html +4 -4
  29. package/docs/functions/transition.SwitchTransition.html +2 -2
  30. package/docs/functions/transition.Transition.html +3 -3
  31. package/docs/hierarchy.html +1 -1
  32. package/docs/index.html +4 -4
  33. package/docs/modules/components.html +1 -1
  34. package/docs/static/demos/cloneelement.jsx +66 -0
  35. package/docs/static/demos/reducer.jsx +2 -0
  36. package/docs/static/demos/router.jsx +1 -1
  37. package/docs/static/index.html +33 -32
  38. package/docs/static/lilact.development.js +32 -12
  39. package/docs/static/lilact.development.js.map +2 -2
  40. package/docs/static/lilact.development.min.js +26 -25
  41. package/docs/static/lilact.development.min.js.map +3 -3
  42. package/docs/static/lilact.production.min.js +26 -25
  43. package/docs/variables/components.cloneElement.html +1 -0
  44. package/examples/demos/cloneelement.jsx +66 -0
  45. package/examples/demos/reducer.jsx +2 -0
  46. package/examples/demos/router.jsx +1 -1
  47. package/examples/index.html +33 -32
  48. package/examples/lilact.development.js +32 -12
  49. package/examples/lilact.development.js.map +2 -2
  50. package/examples/lilact.development.min.js +26 -25
  51. package/examples/lilact.development.min.js.map +3 -3
  52. package/examples/lilact.production.min.js +26 -25
  53. package/package.json +1 -1
  54. package/src/components.jsx +7 -0
  55. package/src/expscan.js +7 -3
  56. package/src/lilact.jsx +5 -5
  57. package/src/run.jsx +13 -16
package/README.md CHANGED
@@ -53,7 +53,7 @@ There is a `transpile.js` helper in the `bin` directory to demonstrate how to us
53
53
 
54
54
  In addition to the API itself, it bundles the official `Redux` library (see the `redux.jsx` example). As a result, it has Redux support and provides all necessary functions and hooks for working with it.
55
55
 
56
- It also includes the amazing `@emotion/css` library to ease working with styles. You can access it via `Lilact.emotion`.
56
+ It also includes the amazing `@emotion/css` library to ease working with styles. You can access it via `Lilact.emotion` or by importing `@emotion/css`.
57
57
 
58
58
  For convenience, it already includes components such as:
59
59
 
@@ -106,7 +106,7 @@ import App from './App.jsx'; // imports the default export
106
106
  or
107
107
 
108
108
  ```js
109
- const { useState, useRef, render, require } = Lilact;
109
+ const { useState, useRef, render } = Lilact;
110
110
 
111
111
  const App = require('./App.jsx');
112
112
  ```
@@ -121,7 +121,7 @@ export default ...
121
121
  or
122
122
 
123
123
  ```js
124
- module.exports = ...
124
+ module.exports.default = ...
125
125
  ```
126
126
 
127
127
  Bundled projects can also be used statically on other backends. However, bundling is not required: JSX files can be served and transpiled live.
@@ -197,7 +197,7 @@ render(<App/>, document.body);
197
197
  </head>
198
198
  <body></body>
199
199
  <script type='text/jsx'>
200
- const { render } = Lilact;
200
+ import { render } from "lilact";
201
201
 
202
202
  function App() {
203
203
  return <div>Hello World</div>;
@@ -1973,6 +1973,8 @@ __export(components_exports, {
1973
1973
  RootComponent: () => RootComponent,
1974
1974
  boolean_html_attributes_set: () => boolean_html_attributes_set,
1975
1975
  capture_events_set: () => capture_events_set,
1976
+ cloneComponent: () => cloneComponent,
1977
+ cloneElement: () => cloneElement,
1976
1978
  createComponent: () => createComponent2,
1977
1979
  createElement: () => createElement,
1978
1980
  createPortal: () => createPortal,
@@ -3071,6 +3073,10 @@ function createRoot(element) {
3071
3073
  function createPortal(children, element) {
3072
3074
  return createComponent2(lilact_default.Portal, { "view": element }, children);
3073
3075
  }
3076
+ function cloneComponent(component, propsPatch, ...children) {
3077
+ return { entity: component.entity, props: { ...component.props, ...propsPatch, children } };
3078
+ }
3079
+ var cloneElement = cloneComponent;
3074
3080
  function render(component, element) {
3075
3081
  if (component[CORE] && (component[CORE].container || component[CORE].parent)) {
3076
3082
  throw new Error("Component is already in use");
@@ -3606,9 +3612,16 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, is_inline = t
3606
3612
  throw e;
3607
3613
  }
3608
3614
  }
3609
- function require2(path2, { forceUpdate, checkExport, requirer, isLazy }) {
3610
- var _a, _b;
3611
- if ((_a = lilact_default.importObjectPaths) == null ? void 0 : _a[path2]) return lilact_default.importObjectPaths[path2];
3615
+ function require2(path2) {
3616
+ var _a, _b, _c, _d, _e, _f;
3617
+ let forceUpdate, checkExport, requirer, isLazy;
3618
+ if (arguments.length === 2 && typeof (arguments[1] === "object")) {
3619
+ forceUpdate = (_a = arguments[1]) == null ? void 0 : _a.forceUpdate;
3620
+ checkExport = (_b = arguments[1]) == null ? void 0 : _b.checkExport;
3621
+ requirer = (_c = arguments[1]) == null ? void 0 : _c.requirer;
3622
+ isLazy = (_d = arguments[1]) == null ? void 0 : _d.isLazy;
3623
+ }
3624
+ if ((_e = lilact_default.importObjectPaths) == null ? void 0 : _e[path2]) return lilact_default.importObjectPaths[path2];
3612
3625
  if (required_scripts[path2] && !forceUpdate) return required_scripts[path2].exports;
3613
3626
  if (path2[0] === "#") {
3614
3627
  const el = document.getElementById(path2);
@@ -3619,7 +3632,7 @@ function require2(path2, { forceUpdate, checkExport, requirer, isLazy }) {
3619
3632
  if (requirer && requirer.path) {
3620
3633
  path2 = joinPaths(requirer.path, path2);
3621
3634
  }
3622
- if (((_b = lilact_default) == null ? void 0 : _b[LAZY]) || isLazy) {
3635
+ if (((_f = lilact_default) == null ? void 0 : _f[LAZY]) || isLazy) {
3623
3636
  lilact_default[LAZY] = false;
3624
3637
  return fetch(path2).then((res2) => {
3625
3638
  if (!res2.ok) throw new Error(`HTTP ${res2.status}`);
@@ -5316,19 +5329,20 @@ function processImportExports(node3, jsx2) {
5316
5329
  const src = jsx2.substring(node3.out[m.index + imp.length - 1].begin, node3.out[m.index + imp.length - 1].end);
5317
5330
  const imports = {};
5318
5331
  let star_imports = [];
5332
+ let import_alls = [];
5319
5333
  for (i2 = m.index + 1; i2 < m.index + imp.length - 1; i2++) {
5320
5334
  node3.out.splice(m.index, 1, {
5321
5335
  type: "import",
5322
5336
  begin: begins[m.index],
5323
- end: begins[m.index + imp.length]
5337
+ end: begins[m.index + imp.length],
5338
+ cjs: ""
5324
5339
  });
5325
5340
  skip_spaces();
5326
5341
  switch (s[i2]) {
5327
5342
  case ",":
5328
5343
  break;
5329
5344
  case "I": {
5330
- const prop = node3.out[i2];
5331
- imports[prop] = "default";
5345
+ import_alls.push(node3.out[i2]);
5332
5346
  continue;
5333
5347
  }
5334
5348
  case "J": {
@@ -5371,8 +5385,12 @@ function processImportExports(node3, jsx2) {
5371
5385
  node3.out[i2] = null;
5372
5386
  }
5373
5387
  let cjs = "";
5374
- for (const s2 of star_imports) {
5388
+ for (const s2 of import_alls) {
5375
5389
  cjs += `const ${s2} = require(${src},{requirer:module});
5390
+ `;
5391
+ }
5392
+ for (const s2 of star_imports) {
5393
+ cjs += `const ${s2} = require(${src},{requirer:module, checkExport: ['default']}).default;
5376
5394
  `;
5377
5395
  }
5378
5396
  if (Object.keys(imports).length) {
@@ -6387,7 +6405,7 @@ function transpileJSX(jsx2, {
6387
6405
 
6388
6406
  // .tmp/src/lilact.jsx
6389
6407
  var Lilact2 = {
6390
- VERSION: "beta.22",
6408
+ VERSION: "beta.23",
6391
6409
  // Configuration
6392
6410
  defaultTransitionTimeout: 300,
6393
6411
  defaultIsEqual: Object.is,
@@ -6409,9 +6427,10 @@ var Lilact2 = {
6409
6427
  // Dependencies
6410
6428
  PropTypes,
6411
6429
  redux: redux_exports,
6412
- emotion: emotion_css_esm_exports,
6413
- default: Lilact2
6430
+ emotion: emotion_css_esm_exports
6414
6431
  };
6432
+ Lilact2.default = Lilact2;
6433
+ var lilact_default = Lilact2;
6415
6434
  Lilact2.importObjectPaths = {
6416
6435
  "lilact": Lilact2,
6417
6436
  "@emotion/css": Lilact2.emotion,
@@ -6433,7 +6452,6 @@ if (true) {
6433
6452
  console.log(`Lilact (Version: ${Lilact2.VERSION}) - Debug Mode`);
6434
6453
  console.log(`Copyright(C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>`);
6435
6454
  }
6436
- var lilact_default = Lilact2;
6437
6455
  export {
6438
6456
  CSSTransition,
6439
6457
  Children,
@@ -6465,6 +6483,8 @@ export {
6465
6483
  capture_events_set,
6466
6484
  clearInterval,
6467
6485
  clearTimeout2 as clearTimeout,
6486
+ cloneComponent,
6487
+ cloneElement,
6468
6488
  combineReducers2 as combineReducers,
6469
6489
  connect,
6470
6490
  createComponent2 as createComponent,