lilact 0.26.15 → 0.27.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 (61) hide show
  1. package/dist/lilact.development.js +459 -324
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +63 -54
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +63 -54
  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.globalErrorHandler.html +1 -8
  20. package/docs/functions/errors.scanBlockLabels.html +1 -0
  21. package/docs/functions/errors.traceError.html +1 -7
  22. package/docs/functions/hooks.startTransition.html +1 -1
  23. package/docs/functions/hooks.useActionState.html +1 -1
  24. package/docs/functions/hooks.useDebugValue.html +1 -1
  25. package/docs/functions/hooks.useDeferredValue.html +1 -1
  26. package/docs/functions/hooks.useEffect.html +1 -1
  27. package/docs/functions/hooks.useImperativeHandle.html +1 -1
  28. package/docs/functions/hooks.useInsertionEffect.html +1 -1
  29. package/docs/functions/hooks.useMemo.html +1 -1
  30. package/docs/functions/hooks.useReducer.html +1 -1
  31. package/docs/functions/run.lazy.html +1 -13
  32. package/docs/functions/run.require.html +1 -9
  33. package/docs/functions/run.run.html +1 -5
  34. package/docs/functions/run.runScripts.html +1 -7
  35. package/docs/functions/timers.timeoutPromise.html +3 -3
  36. package/docs/modules/errors.html +1 -1
  37. package/docs/modules/run.html +1 -1
  38. package/docs/static/index.html +1 -1
  39. package/docs/static/lilact.development.js +459 -324
  40. package/docs/static/lilact.development.js.map +3 -3
  41. package/docs/static/lilact.development.min.js +63 -54
  42. package/docs/static/lilact.development.min.js.map +3 -3
  43. package/docs/static/lilact.production.min.js +63 -54
  44. package/docs/variables/components.cloneElement.html +1 -1
  45. package/docs/variables/errors.blocks_info.html +1 -0
  46. package/docs/variables/errors.error.html +1 -0
  47. package/docs/variables/run.required_scripts.html +1 -0
  48. package/examples/index.html +1 -1
  49. package/examples/lilact.development.js +459 -324
  50. package/examples/lilact.development.js.map +3 -3
  51. package/examples/lilact.development.min.js +63 -54
  52. package/examples/lilact.development.min.js.map +3 -3
  53. package/examples/lilact.production.min.js +63 -54
  54. package/package.json +1 -1
  55. package/src/components.jsx +10 -4
  56. package/src/errors.jsx +344 -245
  57. package/src/expscan.js +1 -1
  58. package/src/hooks.jsx +8 -5
  59. package/src/jsx.js +16 -16
  60. package/src/lilact.jsx +2 -2
  61. package/src/run.jsx +313 -267
package/src/expscan.js CHANGED
@@ -91,7 +91,7 @@ export function labeler(custom_words, x)
91
91
  if(x.type==='comment') return 'C';
92
92
  if(x.type==='regexp') return 'R';
93
93
  if(x.type==='js') return 'J';
94
- if(x.type==='paranthesis') return 'P';
94
+ if(x.type==='parenthesis') return 'P';
95
95
  if(x.type==='string') return 'S';
96
96
  if(x.type==='xml') return 'X';
97
97
  }
package/src/hooks.jsx CHANGED
@@ -275,7 +275,7 @@ export function useRef(initialValue = null)
275
275
  */
276
276
  export async function useLayoutEffect(effect, deps=undefined)
277
277
  {
278
- if( deps!==undefined && (typeof(deps)!=='object' || deps.constructor.name!=='Array') ) {
278
+ if( deps!==undefined && (typeof(deps)!=='object' && deps.constructor.name!=='Array') ) {
279
279
  throw new Error("Layout effect dependencies must be an array, object or omitted.");
280
280
  }
281
281
 
@@ -287,7 +287,8 @@ export async function useLayoutEffect(effect, deps=undefined)
287
287
 
288
288
  if(hk?.cleanup) {
289
289
  await hk.cleanup();
290
- }
290
+ hk.cleanup = undefined;
291
+ }
291
292
 
292
293
  hk.deps = deps;
293
294
  Lilact.layout_effects.add( async ()=>{ hk.cleanup = await effect(); });
@@ -306,7 +307,7 @@ export async function useLayoutEffect(effect, deps=undefined)
306
307
  */
307
308
  export async function useEffect(effect, deps=undefined)
308
309
  {
309
- if( deps!==undefined && (typeof(deps)!=='object' || deps.constructor.name!=='Array') ) {
310
+ if( deps!==undefined && (typeof(deps)!=='object' && deps.constructor.name!=='Array') ) {
310
311
  throw new Error("Effect dependencies must be an array, object or omitted.");
311
312
  }
312
313
 
@@ -318,6 +319,7 @@ export async function useEffect(effect, deps=undefined)
318
319
 
319
320
  if(hk?.cleanup) {
320
321
  await hk.cleanup();
322
+ hk.cleanup = undefined;
321
323
  }
322
324
 
323
325
  hk.deps = deps;
@@ -338,7 +340,7 @@ export async function useEffect(effect, deps=undefined)
338
340
  */
339
341
  export async function useInsertionEffect(effect, deps=undefined)
340
342
  {
341
- if( deps!==undefined && (typeof(deps)!=='object' || deps.constructor.name!=='Array') ) {
343
+ if( deps!==undefined && (typeof(deps)!=='object' && deps.constructor.name!=='Array') ) {
342
344
  throw new Error("Insertion effect dependencies must be an array, object, or omitted.");
343
345
  }
344
346
 
@@ -350,6 +352,7 @@ export async function useInsertionEffect(effect, deps=undefined)
350
352
 
351
353
  if(hk?.cleanup) {
352
354
  await hk.cleanup();
355
+ hk.cleanup = undefined;
353
356
  }
354
357
 
355
358
  hk.deps = deps;
@@ -370,7 +373,7 @@ export async function useInsertionEffect(effect, deps=undefined)
370
373
  */
371
374
  export function useMemo(factory,deps=undefined)
372
375
  {
373
- if( deps!==undefined && (typeof(deps)!=='object' || deps.constructor.name!=='Array') ) {
376
+ if( deps!==undefined && (typeof(deps)!=='object' && deps.constructor.name!=='Array') ) {
374
377
  throw new Error("Memo dependencies must be an array or omitted.");
375
378
  }
376
379
 
package/src/jsx.js CHANGED
@@ -44,7 +44,7 @@
44
44
  // to report any bugs, and please include a testable example. Thanks! :)
45
45
 
46
46
  // note: JSX or preprocessors are not processed inside template strings
47
- // todo: injected string try catchs should be generated by a function
47
+ // todo: injected string try/catches should be generated by a function
48
48
 
49
49
  /** @ignore */
50
50
  export const transpilerConfig = {
@@ -88,7 +88,7 @@ function parseRegex(code, index, container)
88
88
 
89
89
  let i = index;
90
90
  let dels = `;=,([{}!^~&|:?*%-+/<>${transpilerConfig.preprocessorDelimiter}`;
91
- while(--i>0) {
91
+ while(--i>=0) {
92
92
  if( ' \t\r'.indexOf(code[i])!==-1 ) continue;
93
93
  if(code[i]==='\n' ) {
94
94
  dels+=")]";
@@ -615,10 +615,10 @@ function parseXML(code, index, container, look_behind=false)
615
615
  }
616
616
 
617
617
 
618
- function parseParanthesis(code, index, container)
618
+ function parseParenthesis(code, index, container)
619
619
  {
620
620
  const b = { // block
621
- type: "paranthesis",
621
+ type: "parenthesis",
622
622
  begin: index,
623
623
  cbegin: ++index,
624
624
  children: [],
@@ -647,7 +647,7 @@ function parseParanthesis(code, index, container)
647
647
  break;
648
648
 
649
649
  case '(':
650
- [index] = lookAhead( parseParanthesis, code, index, b );
650
+ [index] = lookAhead( parseParenthesis, code, index, b );
651
651
  break;
652
652
 
653
653
  case '}':
@@ -674,7 +674,7 @@ function parseParanthesis(code, index, container)
674
674
  }
675
675
  }
676
676
 
677
- raiseError(`Unterminated paranthesis block`, b.begin);
677
+ raiseError(`Unterminated parenthesis block`, b.begin);
678
678
  }
679
679
 
680
680
 
@@ -713,11 +713,11 @@ function parseJS(code, index=0, is_block=false, container)
713
713
  }
714
714
 
715
715
  case '(': // this is only for function detection
716
- [index] = lookAhead( parseParanthesis, code, index, b );
716
+ [index] = lookAhead( parseParenthesis, code, index, b );
717
717
  break;
718
718
 
719
719
  case ')': // this is only for function detection
720
- raiseError(`Unmatched paranthesis`, b.begin);
720
+ raiseError(`Unmatched parenthesis`, b.begin);
721
721
  break;
722
722
 
723
723
  case '}':
@@ -790,7 +790,7 @@ function labelFunctions(node, eols, blocks_info)
790
790
  let i, nxt, prev;
791
791
  for(let chi=0; chi<node.children.length; chi++) {
792
792
 
793
- if(typeof(node.children[chi])==='object' && node.children[chi].type==='paranthesis') {
793
+ if(typeof(node.children[chi])==='object' && node.children[chi].type==='parenthesis') {
794
794
 
795
795
  [i, prev] = getNext(chi, -1);
796
796
  if(prev===null) continue;
@@ -808,7 +808,7 @@ function labelFunctions(node, eols, blocks_info)
808
808
  if(nxt===null) continue;
809
809
 
810
810
  if(transpilerConfig.injectTraceLabels && typeof(nxt)==='object' && nxt.type==='js') {
811
- const begin = getRowCol(eols, chi); // begin is always the location of function args paranthesis
811
+ const begin = getRowCol(eols, chi); // begin is always the location of function args parenthesis
812
812
  nxt.children.splice(1,0, `/*LILACTBLOCK${++blocks_info.counter}:${begin}:${label}*/try{`);
813
813
  if(transpilerConfig.enableLabelStack) {
814
814
  nxt.children.splice(nxt.children.length-1, 0, `} catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info.counter},e.lilact_trace];throw e}`);
@@ -823,9 +823,9 @@ function labelFunctions(node, eols, blocks_info)
823
823
  else if(node.children[chi]==='=>') {
824
824
  [i, prev] = getNext(chi, -1);
825
825
 
826
- if(typeof(prev)==='object' && prev.type==='paranthesis') {
826
+ if(typeof(prev)==='object' && prev.type==='parenthesis') {
827
827
 
828
- const begin = getRowCol(eols, prev.begin); // begin is always the location of function args paranthesis
828
+ const begin = getRowCol(eols, prev.begin); // begin is always the location of function args parenthesis
829
829
 
830
830
  [i, nxt] = getNext(chi);
831
831
 
@@ -958,7 +958,7 @@ function generateSourceMap(json, path, jsx_eols, out_eols, mappings=[])
958
958
  /**
959
959
  * This is the function that transpiles jsx code to js. It is not recommended to use directly.
960
960
  *
961
- * Use `Lilact.require` instead, or `Lilact.run` available in `run`, or add a `<scirpt type="text/jsx" .../>` to your html.
961
+ * Use `Lilact.require` instead, or `Lilact.run` available in `run`, or add a `<script type="text/jsx" .../>` to your html.
962
962
  *
963
963
  * Lilact jsx parser doesn't rely on the Lilact itself, and can be used by other engines. The easiest way
964
964
  * is using the `bin/transpile.js` script. It has its own help.
@@ -994,11 +994,11 @@ export function transpileJSX( jsx, {
994
994
 
995
995
  raiseError = ((eols, msg, index)=>{
996
996
  const rc = getRowCol(eols, index);
997
-
997
+
998
998
  const er = new Error(msg);
999
999
  if(logErrors) console.error(`JSXParserError: ${msg} [file ${path} at line ${rc[0]}]`);
1000
1000
  [er.lineNumber, er.columnNumber] = rc;
1001
- er.name = 'JSXParseError';
1001
+ er.name = 'JSXParserError';
1002
1002
  er.fileName = path;
1003
1003
  er.lilact_trace = 'parse';
1004
1004
  throw er;
@@ -1090,7 +1090,7 @@ export function transpileJSX( jsx, {
1090
1090
  if(node.type==='directive') return node.value;
1091
1091
 
1092
1092
 
1093
- if(node.type==='paranthesis') {
1093
+ if(node.type==='parenthesis') {
1094
1094
  let out = "(";
1095
1095
 
1096
1096
  if(node.out) {
package/src/lilact.jsx CHANGED
@@ -94,7 +94,7 @@ export {transpileJSX, transpilerConfig} from "./jsx";
94
94
  export const Lilact =
95
95
  {
96
96
 
97
- VERSION: "RC.3",
97
+ VERSION: "RC.4",
98
98
 
99
99
  // Configuration
100
100
 
@@ -149,7 +149,7 @@ document.addEventListener('DOMContentLoaded', () => {
149
149
 
150
150
  if(DEBUG) {
151
151
  window.addEventListener('unhandledrejection', (e) => {
152
- Lilact.globalErrorHandler(e.reason);
152
+ Lilact.globalErrorHandler(e);
153
153
  });
154
154
 
155
155
  window.addEventListener('error', (e) => {