lilact 0.21.1 → 0.23.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 (120) hide show
  1. package/README.md +17 -4
  2. package/dist/lilact.development.js +498 -38
  3. package/dist/lilact.development.js.map +4 -4
  4. package/dist/lilact.development.min.js +34 -23
  5. package/dist/lilact.development.min.js.map +4 -4
  6. package/dist/lilact.production.min.js +33 -22
  7. package/docs/assets/hierarchy.js +1 -1
  8. package/docs/assets/highlight.css +20 -20
  9. package/docs/assets/navigation.js +1 -1
  10. package/docs/assets/search.js +1 -1
  11. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  12. package/docs/classes/accessories.Suspense.html +7 -7
  13. package/docs/classes/components.Component.html +11 -11
  14. package/docs/classes/components.HTMLComponent.html +12 -12
  15. package/docs/classes/components.RootComponent.html +12 -12
  16. package/docs/functions/components.cloneComponent.html +1 -0
  17. package/docs/functions/components.createComponent.html +1 -1
  18. package/docs/functions/components.createPortal.html +1 -1
  19. package/docs/functions/components.createRoot.html +1 -1
  20. package/docs/functions/components.memo.html +1 -1
  21. package/docs/functions/components.render.html +1 -1
  22. package/docs/functions/run.lazy.html +7 -1
  23. package/docs/functions/run.require.html +5 -9
  24. package/docs/functions/run.run.html +1 -1
  25. package/docs/functions/run.runScripts.html +1 -1
  26. package/docs/functions/timers.animationFramePromise.html +1 -1
  27. package/docs/functions/timers.clearInterval.html +1 -1
  28. package/docs/functions/timers.clearTimeout.html +1 -1
  29. package/docs/functions/timers.grabTimers.html +1 -1
  30. package/docs/functions/timers.pauseTimers.html +1 -1
  31. package/docs/functions/timers.releaseTimers.html +1 -1
  32. package/docs/functions/timers.resetTimers.html +1 -1
  33. package/docs/functions/timers.resumeTimers.html +1 -1
  34. package/docs/functions/timers.setInterval.html +1 -1
  35. package/docs/functions/timers.setTimeout.html +1 -1
  36. package/docs/functions/timers.timeoutPromise.html +6 -6
  37. package/docs/hierarchy.html +1 -1
  38. package/docs/index.html +17 -10
  39. package/docs/modules/components.html +1 -1
  40. package/docs/static/demos/actionstate.jsx +2 -2
  41. package/docs/static/demos/capture.jsx +2 -2
  42. package/docs/static/demos/cloneelement.jsx +66 -0
  43. package/docs/static/demos/context.jsx +3 -3
  44. package/docs/static/demos/css-transition.jsx +3 -3
  45. package/docs/static/demos/error-boundary.jsx +2 -2
  46. package/docs/static/demos/error-callback.jsx +1 -1
  47. package/docs/static/demos/error-component-stack.jsx +2 -2
  48. package/docs/static/demos/error-init.jsx +1 -1
  49. package/docs/static/demos/error-parser.jsx +1 -1
  50. package/docs/static/demos/form-elements.jsx +1 -1
  51. package/docs/static/demos/forwardref.jsx +2 -2
  52. package/docs/static/demos/lazy.jsx +3 -3
  53. package/docs/static/demos/legacy-context.jsx +2 -2
  54. package/docs/static/demos/memo.jsx +2 -2
  55. package/docs/static/demos/modal.jsx +2 -2
  56. package/docs/static/demos/pane.jsx +2 -2
  57. package/docs/static/demos/portal.jsx +4 -2
  58. package/docs/static/demos/priorities.jsx +2 -2
  59. package/docs/static/demos/proptypes.jsx +2 -2
  60. package/docs/static/demos/reducer.jsx +4 -2
  61. package/docs/static/demos/redux.jsx +3 -3
  62. package/docs/static/demos/router.jsx +3 -3
  63. package/docs/static/demos/stopwatch.jsx +2 -2
  64. package/docs/static/demos/suspense.jsx +2 -2
  65. package/docs/static/demos/switch-transition.jsx +2 -2
  66. package/docs/static/demos/transition.jsx +2 -2
  67. package/docs/static/demos/usedefered.jsx +2 -2
  68. package/docs/static/demos/usetransition.jsx +3 -3
  69. package/docs/static/index.html +34 -33
  70. package/docs/static/lilact.development.js +498 -38
  71. package/docs/static/lilact.development.js.map +4 -4
  72. package/docs/static/lilact.development.min.js +34 -23
  73. package/docs/static/lilact.development.min.js.map +4 -4
  74. package/docs/static/lilact.production.min.js +33 -22
  75. package/docs/variables/accessories.SplitPane.html +1 -1
  76. package/docs/variables/components.cloneElement.html +1 -0
  77. package/examples/demos/actionstate.jsx +2 -2
  78. package/examples/demos/capture.jsx +2 -2
  79. package/examples/demos/cloneelement.jsx +66 -0
  80. package/examples/demos/context.jsx +3 -3
  81. package/examples/demos/css-transition.jsx +3 -3
  82. package/examples/demos/error-boundary.jsx +2 -2
  83. package/examples/demos/error-callback.jsx +1 -1
  84. package/examples/demos/error-component-stack.jsx +2 -2
  85. package/examples/demos/error-init.jsx +1 -1
  86. package/examples/demos/error-parser.jsx +1 -1
  87. package/examples/demos/form-elements.jsx +1 -1
  88. package/examples/demos/forwardref.jsx +2 -2
  89. package/examples/demos/lazy.jsx +3 -3
  90. package/examples/demos/legacy-context.jsx +2 -2
  91. package/examples/demos/memo.jsx +2 -2
  92. package/examples/demos/modal.jsx +2 -2
  93. package/examples/demos/pane.jsx +2 -2
  94. package/examples/demos/portal.jsx +4 -2
  95. package/examples/demos/priorities.jsx +2 -2
  96. package/examples/demos/proptypes.jsx +2 -2
  97. package/examples/demos/reducer.jsx +4 -2
  98. package/examples/demos/redux.jsx +3 -3
  99. package/examples/demos/router.jsx +3 -3
  100. package/examples/demos/stopwatch.jsx +2 -2
  101. package/examples/demos/suspense.jsx +2 -2
  102. package/examples/demos/switch-transition.jsx +2 -2
  103. package/examples/demos/transition.jsx +2 -2
  104. package/examples/demos/usedefered.jsx +2 -2
  105. package/examples/demos/usetransition.jsx +3 -3
  106. package/examples/index.html +34 -33
  107. package/examples/lilact.development.js +498 -38
  108. package/examples/lilact.development.js.map +4 -4
  109. package/examples/lilact.development.min.js +34 -23
  110. package/examples/lilact.development.min.js.map +4 -4
  111. package/examples/lilact.production.min.js +33 -22
  112. package/impexptest.js +51 -0
  113. package/package.json +4 -4
  114. package/src/components.jsx +7 -5
  115. package/src/expscan.js +408 -0
  116. package/src/jsx.js +26 -28
  117. package/src/lilact.jsx +12 -3
  118. package/src/run.jsx +92 -45
  119. package/src/timers.jsx +0 -5
  120. package/src/jsx.addons.js +0 -70
@@ -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");
@@ -3543,18 +3549,35 @@ __export(run_exports, {
3543
3549
  run: () => run,
3544
3550
  runScripts: () => runScripts
3545
3551
  });
3552
+ function joinPaths(basePath, relativePath) {
3553
+ const isAbs = relativePath.startsWith("/");
3554
+ const stack = [];
3555
+ const parts = (isAbs ? "" : basePath).split("/").filter(Boolean);
3556
+ for (const p of parts) stack.push(p);
3557
+ if (!basePath.endsWith("/")) stack.pop();
3558
+ const relParts = relativePath.split("/");
3559
+ for (const p of relParts) {
3560
+ if (p === "" || p === ".") continue;
3561
+ if (p === "..") {
3562
+ if (stack.length > 0) stack.pop();
3563
+ } else {
3564
+ stack.push(p);
3565
+ }
3566
+ }
3567
+ return (isAbs ? "/" : "") + stack.join("/");
3568
+ }
3546
3569
  var required_scripts = {};
3547
3570
  function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, is_inline = true) {
3548
3571
  const mappings = [];
3549
- const module = { exports: {} };
3550
- let processed;
3551
- required_scripts[path] = {
3572
+ const module = {
3552
3573
  mappings,
3553
- module,
3554
3574
  is_inline,
3555
3575
  path,
3556
- code: jsx
3576
+ code: jsx,
3577
+ exports: {}
3557
3578
  };
3579
+ let processed;
3580
+ required_scripts[path] = module;
3558
3581
  try {
3559
3582
  processed = lilact_default.transpileJSX(
3560
3583
  jsx,
@@ -3564,7 +3587,8 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, is_inline = t
3564
3587
  factory: "createComponent",
3565
3588
  appendSourcemap: false,
3566
3589
  blocks_info: lilact_default.blocks_info,
3567
- injectTraceLabels: true
3590
+ injectTraceLabels: true,
3591
+ produceCJS: true
3568
3592
  }
3569
3593
  );
3570
3594
  } catch (e) {
@@ -3588,32 +3612,38 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, is_inline = t
3588
3612
  throw e;
3589
3613
  }
3590
3614
  }
3591
- function require2(path2, forceUpdate) {
3592
- var _a;
3593
- if (required_scripts[path2] && !forceUpdate) return required_scripts[path2].module.exports;
3615
+ function require2(path2, { forceUpdate, checkExport, requirer, isLazy }) {
3616
+ var _a, _b;
3617
+ if ((_a = lilact_default.importObjectPaths) == null ? void 0 : _a[path2]) return lilact_default.importObjectPaths[path2];
3618
+ if (required_scripts[path2] && !forceUpdate) return required_scripts[path2].exports;
3594
3619
  if (path2[0] === "#") {
3595
3620
  const el = document.getElementById(path2);
3596
3621
  if (el) {
3597
3622
  return run(el.innerText, path2);
3598
3623
  }
3599
- } else if ((_a = lilact_default) == null ? void 0 : _a[LAZY]) {
3600
- lilact_default[LAZY] = false;
3601
- return fetch(path2).then((res2) => {
3602
- if (!res2.ok) throw new Error(`HTTP ${res2.status}`);
3603
- return res2.text();
3604
- }).then((res2) => {
3605
- var _a2;
3606
- res2 = run(res2, path2, false);
3607
- return (_a2 = res2 == null ? void 0 : res2.default) != null ? _a2 : res2;
3608
- }).catch((err) => {
3609
- throw err;
3610
- });
3611
3624
  } else {
3612
- const request = new XMLHttpRequest();
3613
- request.open("GET", path2, false);
3614
- request.send(null);
3615
- if (request.status === 200) {
3616
- return run(request.responseText, path2, false);
3625
+ if (requirer && requirer.path) {
3626
+ path2 = joinPaths(requirer.path, path2);
3627
+ }
3628
+ if (((_b = lilact_default) == null ? void 0 : _b[LAZY]) || isLazy) {
3629
+ lilact_default[LAZY] = false;
3630
+ return fetch(path2).then((res2) => {
3631
+ if (!res2.ok) throw new Error(`HTTP ${res2.status}`);
3632
+ return res2.text();
3633
+ }).then((res2) => {
3634
+ var _a2;
3635
+ res2 = run(res2, path2, false);
3636
+ return (_a2 = res2 == null ? void 0 : res2.default) != null ? _a2 : res2;
3637
+ }).catch((err) => {
3638
+ throw err;
3639
+ });
3640
+ } else {
3641
+ const request = new XMLHttpRequest();
3642
+ request.open("GET", path2, false);
3643
+ request.send(null);
3644
+ if (request.status === 200) {
3645
+ return run(request.responseText, path2, false);
3646
+ }
3617
3647
  }
3618
3648
  }
3619
3649
  throw new Error(`Required resource not found (${path2})`);
@@ -5074,9 +5104,425 @@ function encode_integer(num) {
5074
5104
  return result;
5075
5105
  }
5076
5106
 
5107
+ // .tmp/src/expscan.js
5108
+ var keywords = /* @__PURE__ */ new Set([
5109
+ "break",
5110
+ "case",
5111
+ "catch",
5112
+ "class",
5113
+ "const",
5114
+ "continue",
5115
+ "debugger",
5116
+ "default",
5117
+ "do",
5118
+ "else",
5119
+ "export",
5120
+ "extends",
5121
+ "finally",
5122
+ "for",
5123
+ "function",
5124
+ "if",
5125
+ "import",
5126
+ "in",
5127
+ "instanceof",
5128
+ "super",
5129
+ "switch",
5130
+ "this",
5131
+ "throw",
5132
+ "try",
5133
+ "var",
5134
+ "while",
5135
+ "with",
5136
+ "yield",
5137
+ "return",
5138
+ "true",
5139
+ "false",
5140
+ "null",
5141
+ "undefined",
5142
+ "enum",
5143
+ "implements",
5144
+ "interface",
5145
+ "let",
5146
+ "package",
5147
+ "private",
5148
+ "protected",
5149
+ "public",
5150
+ "static",
5151
+ "yield",
5152
+ "as",
5153
+ "from",
5154
+ "of",
5155
+ "async",
5156
+ "get",
5157
+ "set",
5158
+ "static",
5159
+ "super",
5160
+ "delete",
5161
+ "void",
5162
+ "typeof",
5163
+ "new",
5164
+ "await"
5165
+ ]);
5166
+ var operators = /* @__PURE__ */ new Set([
5167
+ "(",
5168
+ ")",
5169
+ "{",
5170
+ "}",
5171
+ "[",
5172
+ "]",
5173
+ "...",
5174
+ ".",
5175
+ "=>",
5176
+ ",",
5177
+ ";",
5178
+ ":",
5179
+ "?",
5180
+ "++",
5181
+ "--",
5182
+ "+",
5183
+ "-",
5184
+ "*",
5185
+ "/",
5186
+ "%",
5187
+ "**",
5188
+ ">>",
5189
+ "<<",
5190
+ ">>>",
5191
+ "<<<",
5192
+ "&",
5193
+ "|",
5194
+ "^",
5195
+ "~",
5196
+ "==",
5197
+ "!=",
5198
+ "===",
5199
+ "!==",
5200
+ ">",
5201
+ "<",
5202
+ ">=",
5203
+ "<=",
5204
+ "&&",
5205
+ "||",
5206
+ "??",
5207
+ "?.",
5208
+ "=",
5209
+ "+=",
5210
+ "-=",
5211
+ "*=",
5212
+ "/=",
5213
+ "%=",
5214
+ "**=",
5215
+ "<<=",
5216
+ ">>=",
5217
+ ">>>=",
5218
+ "&=",
5219
+ "|=",
5220
+ "^=",
5221
+ "??=",
5222
+ "&&=",
5223
+ "||=",
5224
+ "!"
5225
+ ]);
5226
+ function isNumber(s) {
5227
+ if (!/^(?:[+-]?(?:(?:\d(?:\d|_)*)(?:\.(?:\d(?:\d|_)*))?|\.(?:\d(?:\d|_)*))(?:[eE][+-]?(?:\d(?:\d|_)*))?|[+-]?Infinity|[+-]?NaN|[+-]?(?:(?:0[xX](?:[0-9a-fA-F](?:[0-9a-fA-F]|_)*))|(?:0[oO](?:[0-7](?:[0-7]|_)*))|(?:0[bB](?:[01](?:[01]|_)*))|(?:\d(?:\d|_)*))n)$/u.test(s)) return false;
5228
+ return !keywords.has(s);
5229
+ }
5230
+ function isUnicodeEscapeSequence(s) {
5231
+ if (!/(?:\\u\{[0-9a-fA-F]+\}|\\u[0-9a-fA-F]{4})/g.test(s)) return false;
5232
+ return !keywords.has(s);
5233
+ }
5234
+ function isValidIdentifierName(s) {
5235
+ if (!/^(?:[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}]*)$/u.test(s)) return false;
5236
+ return !keywords.has(s);
5237
+ }
5238
+ function labeler(custom_words, x) {
5239
+ if (typeof x === "string") {
5240
+ if (custom_words && custom_words.hasOwnProperty(x)) return custom_words[x];
5241
+ if (x.trim() === "") {
5242
+ if (x.indexOf("\n") !== -1) return "\n";
5243
+ return " ";
5244
+ }
5245
+ if (keywords.has(x)) return "K";
5246
+ if (operators.has(x)) return "O";
5247
+ if (isValidIdentifierName(x)) return "I";
5248
+ if (isUnicodeEscapeSequence(x)) return "U";
5249
+ if (isNumber(x)) return "N";
5250
+ } else if (typeof x === "object") {
5251
+ if (x.type === "comment") return "C";
5252
+ if (x.type === "regexp") return "R";
5253
+ if (x.type === "js") return "J";
5254
+ if (x.type === "paranthesis") return "P";
5255
+ if (x.type === "string") return "S";
5256
+ if (x.type === "xml") return "X";
5257
+ }
5258
+ return "?";
5259
+ }
5260
+ function generateSequence(arr, labeler2 = labeler2.bind(null, null)) {
5261
+ return arr.map(labeler2).join("");
5262
+ }
5263
+ 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;
5264
+ 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;
5265
+ function processImportExports(node3, jsx2) {
5266
+ const s = generateSequence(
5267
+ node3.out,
5268
+ labeler.bind(
5269
+ null,
5270
+ {
5271
+ "import": "i",
5272
+ "export": "e",
5273
+ "as": "a",
5274
+ "from": "f",
5275
+ ",": ",",
5276
+ ".": ".",
5277
+ "*": "*",
5278
+ ";": ";",
5279
+ "var": "V",
5280
+ "let": "V",
5281
+ "const": "V",
5282
+ "function": "F",
5283
+ "class": "F",
5284
+ "=": "=",
5285
+ "default": "d",
5286
+ "require": "r"
5287
+ }
5288
+ )
5289
+ );
5290
+ let i2;
5291
+ const skip_spaces = (dir = 1) => {
5292
+ while (s[i2] === " " || s[i2] === "\n" || s[i2] === "C") {
5293
+ if (dir === 1) node3.out[i2] = null;
5294
+ i2 += dir;
5295
+ }
5296
+ };
5297
+ let begin = node3.begin;
5298
+ const begins = [];
5299
+ for (i2 = 0; i2 < node3.out.length; i2++) {
5300
+ if (i2 == 0) begins.push(node3.begin);
5301
+ else {
5302
+ if (typeof node3.out[i2 - 1] === "string") {
5303
+ begins.push(begins[i2 - 1] + node3.out[i2 - 1].length);
5304
+ } else {
5305
+ begins.push(node3.out[i2 - 1].end);
5306
+ }
5307
+ }
5308
+ }
5309
+ begins.push(node3.end);
5310
+ for (const m of s.matchAll(import_export_regexp)) {
5311
+ if (m[0].startsWith("r")) {
5312
+ const req = m[0];
5313
+ const args = node3.out[m.index + req.length - 1].out;
5314
+ if (args.length === 1) {
5315
+ args.push(", {requirer:module}");
5316
+ }
5317
+ } else if (m[0].startsWith("i")) {
5318
+ const imp = m[0];
5319
+ i2 = m.index - 1;
5320
+ skip_spaces(-1);
5321
+ if (s[i2] === ".") continue;
5322
+ const src = jsx2.substring(node3.out[m.index + imp.length - 1].begin, node3.out[m.index + imp.length - 1].end);
5323
+ const imports = {};
5324
+ let star_imports = [];
5325
+ let import_alls = [];
5326
+ for (i2 = m.index + 1; i2 < m.index + imp.length - 1; i2++) {
5327
+ node3.out.splice(m.index, 1, {
5328
+ type: "import",
5329
+ begin: begins[m.index],
5330
+ end: begins[m.index + imp.length],
5331
+ cjs: ""
5332
+ });
5333
+ skip_spaces();
5334
+ switch (s[i2]) {
5335
+ case ",":
5336
+ break;
5337
+ case "I": {
5338
+ import_alls.push(node3.out[i2]);
5339
+ continue;
5340
+ }
5341
+ case "J": {
5342
+ let sj = generateSequence(
5343
+ node3.out[i2].out,
5344
+ labeler.bind(
5345
+ null,
5346
+ { "as": "a", ",": "," }
5347
+ )
5348
+ );
5349
+ props_regexp.lastIndex = -1;
5350
+ if (!props_regexp.test(sj)) throw "incorrect import properties definition.";
5351
+ const ps = node3.out[i2].out;
5352
+ for (let j = 1; j < sj.length - 1; j++) {
5353
+ while (sj[j] === " " || sj[j] === "\n" || sj[j] === "C" || sj[j] === ",") j++;
5354
+ const prop = ps[j];
5355
+ j++;
5356
+ while (sj[j] === " " || sj[j] === "\n" || sj[j] === "C") j++;
5357
+ if (sj[j] === "a") {
5358
+ j++;
5359
+ while (sj[j] === " " || sj[j] === "\n" || sj[j] === "C") j++;
5360
+ imports[ps[j]] = prop;
5361
+ j++;
5362
+ } else {
5363
+ imports[prop] = prop;
5364
+ }
5365
+ }
5366
+ continue;
5367
+ }
5368
+ case "*": {
5369
+ i2++;
5370
+ skip_spaces();
5371
+ i2++;
5372
+ skip_spaces();
5373
+ star_imports.push(node3.out[i2]);
5374
+ continue;
5375
+ }
5376
+ case "S":
5377
+ for (i2 = m.index + 1; i2 < m.index + imp.length; i2++) {
5378
+ node3.out[i2] = null;
5379
+ }
5380
+ let cjs = "";
5381
+ for (const s2 of import_alls) {
5382
+ cjs += `const ${s2} = require(${src},{requirer:module});
5383
+ `;
5384
+ }
5385
+ for (const s2 of star_imports) {
5386
+ cjs += `const ${s2} = require(${src},{requirer:module, checkExport: ['default']}).default;
5387
+ `;
5388
+ }
5389
+ if (Object.keys(imports).length) {
5390
+ let o = "{";
5391
+ let ls = "[";
5392
+ for (const p in imports) {
5393
+ if (o.length > 1) {
5394
+ o += ",";
5395
+ ls += ",";
5396
+ }
5397
+ if (p === imports[p]) {
5398
+ o += p;
5399
+ ls += `'${p}'`;
5400
+ } else {
5401
+ o += p + ":" + imports[p];
5402
+ ls += `'${imports[p]}'`;
5403
+ }
5404
+ }
5405
+ o += "}";
5406
+ ls += "]";
5407
+ cjs += `const ${o} = require(${src}, {checkExport: ${ls},requirer:module})`;
5408
+ } else {
5409
+ cjs += `require(${src},{requirer:module})`;
5410
+ }
5411
+ node3.out[m.index].cjs = cjs;
5412
+ continue;
5413
+ }
5414
+ }
5415
+ } else {
5416
+ const exp = m[0];
5417
+ node3.out.splice(m.index, 1, {
5418
+ type: "export",
5419
+ begin: begins[m.index],
5420
+ end: begins[m.index + 1]
5421
+ });
5422
+ i2 = m.index - 1;
5423
+ skip_spaces(-1);
5424
+ if (s[i2] === ".") continue;
5425
+ i2 = m.index + 1;
5426
+ skip_spaces();
5427
+ switch (s[i2]) {
5428
+ case "d":
5429
+ node3.out[i2] = null;
5430
+ node3.out[m.index].cjs = "module.exports.default =";
5431
+ continue;
5432
+ case "V":
5433
+ case "F":
5434
+ const j = i2;
5435
+ const type = s[i2] === "F" ? `= ${node3.out[i2]} ` : "";
5436
+ node3.out[i2] = null;
5437
+ i2++;
5438
+ skip_spaces();
5439
+ const name = node3.out[i2];
5440
+ if (s[j] === "V") {
5441
+ node3.out[i2] = null;
5442
+ i2++;
5443
+ }
5444
+ skip_spaces();
5445
+ node3.out[m.index].cjs = `module.exports.${name} ${type}`;
5446
+ continue;
5447
+ case "*":
5448
+ node3.out[i2] = null;
5449
+ i2++;
5450
+ skip_spaces();
5451
+ node3.out[i2] = null;
5452
+ i2++;
5453
+ skip_spaces();
5454
+ const src = jsx2.substring(node3.out[i2].begin, node3.out[i2].end);
5455
+ node3.out[i2] = null;
5456
+ node3.out[m.index].cjs = `Object.assign(module.exports, require(${src},{requirer:module}))`;
5457
+ continue;
5458
+ case "I":
5459
+ node3.out[m.index].cjs = `module.exports.${node3.out[i2]} = `;
5460
+ continue;
5461
+ case "J": {
5462
+ const exports = {};
5463
+ let sj = generateSequence(
5464
+ node3.out[i2].out,
5465
+ labeler.bind(
5466
+ null,
5467
+ { "as": "a", ",": ",", "default": "I" }
5468
+ )
5469
+ );
5470
+ props_regexp.lastIndex = -1;
5471
+ if (!props_regexp.test(sj)) throw "incorrect export properties definition.";
5472
+ const ps = node3.out[i2].out;
5473
+ for (let j2 = 1; j2 < sj.length - 1; j2++) {
5474
+ while (sj[j2] === " " || sj[j2] === "\n" || sj[j2] === "C" || sj[j2] === ",") j2++;
5475
+ const prop = ps[j2];
5476
+ j2++;
5477
+ while (sj[j2] === " " || sj[j2] === "\n" || sj[j2] === "C") j2++;
5478
+ if (sj[j2] === "a") {
5479
+ j2++;
5480
+ while (sj[j2] === " " || sj[j2] === "\n" || sj[j2] === "C") j2++;
5481
+ exports[ps[j2]] = prop;
5482
+ j2++;
5483
+ } else {
5484
+ exports[prop] = prop;
5485
+ }
5486
+ }
5487
+ let o = "{";
5488
+ let ls = "{";
5489
+ for (const p in exports) {
5490
+ if (o.length > 1) {
5491
+ o += ",";
5492
+ ls += ",";
5493
+ }
5494
+ if (p === exports[p]) {
5495
+ o += p;
5496
+ ls += p;
5497
+ } else {
5498
+ o += p + ":" + exports[p];
5499
+ ls += exports[p];
5500
+ }
5501
+ }
5502
+ o += "}";
5503
+ ls += "}";
5504
+ node3.out[i2] = null;
5505
+ i2++;
5506
+ skip_spaces();
5507
+ if (node3.out[i2] === "from") {
5508
+ node3.out[i2] = null;
5509
+ i2++;
5510
+ skip_spaces();
5511
+ const src2 = jsx2.substring(node3.out[i2].begin, node3.out[i2].end);
5512
+ node3.out[i2] = null;
5513
+ node3.out[m.index].cjs = `{ const ${o} = require(${src2},{requirer:module}); Object.assign(module.exports, ${ls}); }`;
5514
+ } else {
5515
+ node3.out[m.index].cjs = `Object.assign(module.exports, ${o})`;
5516
+ }
5517
+ continue;
5518
+ }
5519
+ }
5520
+ }
5521
+ }
5522
+ }
5523
+
5077
5524
  // .tmp/src/jsx.js
5078
5525
  var transpilerConfig = {
5079
- //addons: jsxAddons, // addons are not used anymore
5080
5526
  setBlockLabels: true,
5081
5527
  enableLabelStack: false,
5082
5528
  injectLabels: true,
@@ -5085,9 +5531,9 @@ var transpilerConfig = {
5085
5531
  preprocessorDelimiter: "\u0294"
5086
5532
  // alt+shift+. on apple abc extended layout
5087
5533
  };
5088
- var TRANSPILER_OUTPUT = /* @__PURE__ */ Symbol.for("LILACT:TRANSPILER_OUTPUT");
5089
5534
  var raiseError;
5090
5535
  var tab = 0;
5536
+ var TOKENIZE_RE = /(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/gm;
5091
5537
  function lookAhead(f, code2, index2, ...args) {
5092
5538
  const b2 = f(code2, index2, ...args);
5093
5539
  if (b2) {
@@ -5283,7 +5729,7 @@ function parseString(code2, index2, q, container2) {
5283
5729
  case "$":
5284
5730
  if (q === "`") {
5285
5731
  if (code2[index2 + 1] === "{") {
5286
- [index2] = lookAhead(parseJS, code2, index2 + 1, true, container2);
5732
+ [index2] = lookAhead(parseJS, code2, index2 + 1, true);
5287
5733
  index2--;
5288
5734
  }
5289
5735
  }
@@ -5541,7 +5987,7 @@ function parseParanthesis(code2, index2, container2) {
5541
5987
  case '"':
5542
5988
  case "'":
5543
5989
  case "`":
5544
- [index2] = lookAhead(parseString, code2, index2, ch2);
5990
+ [index2] = lookAhead(parseString, code2, index2, ch2, b2);
5545
5991
  break;
5546
5992
  case "{":
5547
5993
  [index2] = lookAhead(parseJS, code2, index2, true, b2);
@@ -5591,7 +6037,7 @@ function parseJS(code2, index2 = 0, is_block = false, container2) {
5591
6037
  case '"':
5592
6038
  case "'":
5593
6039
  case "`":
5594
- [index2] = lookAhead(parseString, code2, index2, ch2);
6040
+ [index2] = lookAhead(parseString, code2, index2, ch2, b2);
5595
6041
  break;
5596
6042
  case "{": {
5597
6043
  const i2 = index2;
@@ -5742,12 +6188,12 @@ function generateSourceMap(json, path2, jsx_eols, out_eols, mappings2 = []) {
5742
6188
  };
5743
6189
  const scan_leaves = (node3) => {
5744
6190
  var _a;
5745
- if (((_a = node3.out) == null ? void 0 : _a.length) > 0) {
6191
+ if (((_a = node3 == null ? void 0 : node3.out) == null ? void 0 : _a.length) > 0) {
5746
6192
  for (const ch2 of node3.out) {
5747
6193
  scan_leaves(ch2);
5748
6194
  }
5749
6195
  }
5750
- if (node3.begin !== void 0 && node3.out_index !== void 0) {
6196
+ if ((node3 == null ? void 0 : node3.begin) !== void 0 && (node3 == null ? void 0 : node3.out_index) !== void 0) {
5751
6197
  mpps.push([...getRowCol(out_eols, node3.out_index), ...getRowCol(jsx_eols, node3.begin), node3]);
5752
6198
  }
5753
6199
  };
@@ -5787,6 +6233,7 @@ function transpileJSX(jsx2, {
5787
6233
  appendSourcemap = true,
5788
6234
  injectTraceLabels = false,
5789
6235
  discardComments = false,
6236
+ produceCJS = false,
5790
6237
  // lilact internal
5791
6238
  blocks_info: blocks_info2 = {
5792
6239
  labels: {},
@@ -5806,7 +6253,6 @@ function transpileJSX(jsx2, {
5806
6253
  er.lilact_trace = "parse";
5807
6254
  throw er;
5808
6255
  }).bind(null, eols);
5809
- const tokenize_re = /([\{\}\(\),;\[\]\n]|[\s^\n]+)/g;
5810
6256
  const json = parseJS(jsx2);
5811
6257
  json.data = jsx2;
5812
6258
  const prepare = (node3) => {
@@ -5828,7 +6274,7 @@ function transpileJSX(jsx2, {
5828
6274
  if (node3.type === "xml") {
5829
6275
  node3.children.splice(chi, 0, '"' + s.replaceAll("\n", "\\\n").replaceAll('"', '\\"') + '"');
5830
6276
  } else {
5831
- node3.children.splice(chi, 0, ...s.split(tokenize_re));
6277
+ node3.children.splice(chi, 0, ...s.split(TOKENIZE_RE));
5832
6278
  }
5833
6279
  chi++;
5834
6280
  }
@@ -5848,7 +6294,7 @@ function transpileJSX(jsx2, {
5848
6294
  "\n": "\\\n"
5849
6295
  })[m]) + '"');
5850
6296
  } else {
5851
- node3.children.push(...s.split(tokenize_re));
6297
+ node3.children.push(...s.split(TOKENIZE_RE));
5852
6298
  }
5853
6299
  }
5854
6300
  }
@@ -5862,14 +6308,18 @@ function transpileJSX(jsx2, {
5862
6308
  preprocessPragmas(json);
5863
6309
  const codify = (outlen, node3, is_attr = false, is_xml = false) => {
5864
6310
  if (typeof node3 !== "object") return node3;
6311
+ if (node3 === null) return "";
5865
6312
  node3.out_index = outlen;
5866
6313
  if (node3.type === "string") return jsx2.substring(node3.begin, node3.end);
6314
+ if (node3.type === "import") return node3.cjs;
6315
+ if (node3.type === "export") return node3.cjs;
5867
6316
  if (node3.type === "regex") return jsx2.substring(node3.begin, node3.end);
5868
6317
  if (node3.type === "comment") return discardComments || is_attr ? "" : jsx2.substring(node3.begin, node3.end);
5869
6318
  if (node3.type === "directive") return node3.value;
5870
6319
  if (node3.type === "paranthesis") {
5871
6320
  let out2 = "(";
5872
6321
  if (node3.out) {
6322
+ if (produceCJS) processImportExports(node3, jsx2);
5873
6323
  for (const ch2 of node3.out) {
5874
6324
  out2 += codify(outlen + out2.length - 1, ch2);
5875
6325
  }
@@ -5879,6 +6329,7 @@ function transpileJSX(jsx2, {
5879
6329
  if (node3.type === "js") {
5880
6330
  let out2 = "";
5881
6331
  if (node3.out) {
6332
+ if (produceCJS) processImportExports(node3, jsx2);
5882
6333
  for (const ch2 of node3.out) {
5883
6334
  if (is_xml && ch2.type === "comment") continue;
5884
6335
  out2 += codify(outlen + out2.length - (is_attr ? 1 : 0), ch2);
@@ -5947,7 +6398,7 @@ function transpileJSX(jsx2, {
5947
6398
 
5948
6399
  // .tmp/src/lilact.jsx
5949
6400
  var Lilact2 = {
5950
- VERSION: "beta.21",
6401
+ VERSION: "beta.23",
5951
6402
  // Configuration
5952
6403
  defaultTransitionTimeout: 300,
5953
6404
  defaultIsEqual: Object.is,
@@ -5971,9 +6422,17 @@ var Lilact2 = {
5971
6422
  redux: redux_exports,
5972
6423
  emotion: emotion_css_esm_exports
5973
6424
  };
6425
+ Lilact2.default = Lilact2;
6426
+ var lilact_default = Lilact2;
6427
+ Lilact2.importObjectPaths = {
6428
+ "lilact": Lilact2,
6429
+ "@emotion/css": Lilact2.emotion,
6430
+ "redux": Lilact2.redux
6431
+ };
5974
6432
  globalThis.Lilact = Lilact2;
5975
6433
  globalThis.createComponent = Lilact2.createComponent;
5976
6434
  globalThis.Fragment = Lilact2.Fragment;
6435
+ globalThis.require = Lilact2.require;
5977
6436
  document.addEventListener("DOMContentLoaded", () => {
5978
6437
  Lilact2.runScripts();
5979
6438
  });
@@ -5986,7 +6445,6 @@ if (true) {
5986
6445
  console.log(`Lilact (Version: ${Lilact2.VERSION}) - Debug Mode`);
5987
6446
  console.log(`Copyright(C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>`);
5988
6447
  }
5989
- var lilact_default = Lilact2;
5990
6448
  export {
5991
6449
  CSSTransition,
5992
6450
  Children,
@@ -6018,6 +6476,8 @@ export {
6018
6476
  capture_events_set,
6019
6477
  clearInterval,
6020
6478
  clearTimeout2 as clearTimeout,
6479
+ cloneComponent,
6480
+ cloneElement,
6021
6481
  combineReducers2 as combineReducers,
6022
6482
  connect,
6023
6483
  createComponent2 as createComponent,