lilact 0.5.1 → 0.6.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.min.js +1 -1
  2. package/dist/lilact.development.min.js.map +1 -1
  3. package/dist/lilact.production.min.js +1 -1
  4. package/dist/lilact.production.min.js.map +1 -1
  5. package/docs/assets/hierarchy.js +1 -1
  6. package/docs/assets/search.js +1 -1
  7. package/docs/classes/accessories.ErrorBoundary.html +13 -10
  8. package/docs/classes/accessories.Suspense.html +13 -10
  9. package/docs/classes/components.Component.html +14 -11
  10. package/docs/classes/components.HTMLComponent.html +14 -11
  11. package/docs/classes/components.RootComponent.html +13 -10
  12. package/docs/functions/components.createComponent.html +1 -1
  13. package/docs/functions/components.createRoot.html +1 -1
  14. package/docs/functions/components.render.html +1 -1
  15. package/docs/functions/errors.globalErrorHandler.html +1 -1
  16. package/docs/functions/errors.traceError.html +2 -2
  17. package/docs/functions/misc.Fragment.html +1 -1
  18. package/docs/functions/misc.classNames.html +1 -1
  19. package/docs/functions/misc.deepEqual.html +1 -1
  20. package/docs/functions/misc.getComponentByPointer.html +1 -1
  21. package/docs/functions/misc.isAsync.html +1 -1
  22. package/docs/functions/misc.isClass.html +1 -1
  23. package/docs/functions/misc.isEmpty.html +1 -1
  24. package/docs/functions/misc.isError.html +1 -1
  25. package/docs/functions/misc.isThenable.html +1 -1
  26. package/docs/functions/misc.shallowEqual.html +1 -1
  27. package/docs/functions/misc.toBool.html +1 -1
  28. package/docs/functions/run.lazy.html +1 -1
  29. package/docs/functions/run.require.html +1 -1
  30. package/docs/functions/run.runScripts.html +1 -1
  31. package/docs/hierarchy.html +1 -1
  32. package/{root/demos/error-3.jsx → docs/static/demos/error-callback.jsx} +9 -9
  33. package/docs/static/demos/error-component-stack.jsx +39 -0
  34. package/{root/demos/error-2.jsx → docs/static/demos/error-init.jsx} +1 -1
  35. package/docs/static/demos/form-elements.jsx +9 -9
  36. package/docs/static/icon.png +0 -0
  37. package/docs/static/index.html +25 -21
  38. package/docs/static/lilact.development.min.js +1 -1
  39. package/docs/static/lilact.production.min.js +1 -1
  40. package/docs/variables/misc.Children.html +2 -2
  41. package/package.json +1 -1
  42. package/{docs/static/demos/error-3.jsx → root/demos/error-callback.jsx} +9 -9
  43. package/root/demos/error-component-stack.jsx +39 -0
  44. package/{docs/static/demos/error-2.jsx → root/demos/error-init.jsx} +1 -1
  45. package/root/demos/form-elements.jsx +9 -9
  46. package/root/icon.png +0 -0
  47. package/root/index.html +25 -21
  48. package/root/lilact.development.min.js +1 -1
  49. package/root/lilact.production.min.js +1 -1
  50. package/src/accessories.jsx +2 -0
  51. package/src/components.jsx +27 -18
  52. package/src/errors.jsx +19 -11
  53. package/src/jsx.js +2 -2
  54. package/src/lilact.jsx +1 -1
  55. package/src/misc.jsx +0 -3
  56. package/src/pane.jsx +4 -0
  57. package/src/run.jsx +0 -1
  58. package/docs/static/demos/error-4.jsx +0 -7
  59. package/root/demos/error-4.jsx +0 -7
  60. /package/docs/static/demos/{error-1.jsx → error-parser.jsx} +0 -0
  61. /package/root/demos/{error-1.jsx → error-parser.jsx} +0 -0
package/src/errors.jsx CHANGED
@@ -35,8 +35,8 @@
35
35
  export function getErrorLocation(err) // works for both error and error-event, and also in node env
36
36
  {
37
37
  if(err.lineno!==undefined || err.line!==undefined || err.lineNumber!==undefined) {
38
- const l = err.lineno || err.line || err.lineNumber;
39
- const c = err.colno || err.column || err.columnNumber;
38
+ const l = err.lineNumber || err.lineno || err.line;
39
+ const c = err.columnNumber || err.colno || err.column;
40
40
 
41
41
  return [l, c];
42
42
  }
@@ -56,7 +56,7 @@ export function getErrorLocation(err) // works for both error and error-event, a
56
56
  /** @ignore */
57
57
  export function mapLocation(mps, r,c)
58
58
  {
59
- let map = [0,0,0,0];
59
+ let map = null;
60
60
 
61
61
  for(const i in mps) {
62
62
  if(mps[i][0]<r) continue;
@@ -65,7 +65,7 @@ export function mapLocation(mps, r,c)
65
65
  break;
66
66
  }
67
67
  }
68
-
68
+ if(!map) map = mps[mps.length-1];
69
69
  return [r-map[0]+map[2], ((r-map[0]===0)?map[3]:0)];
70
70
  }
71
71
 
@@ -75,13 +75,13 @@ export function scanBlockLabels(code, path)
75
75
  {
76
76
  const ls = Array.from( code.matchAll(/LILACTBLOCK(\d+):(\d+),(\d+):([^*]+)\*\//mg) );
77
77
 
78
+ // todo: this is not memory efficient, the structure should be upside-down
78
79
  ls.forEach(
79
80
  (x) => {
80
81
  Lilact.blocks_info.labels[x[1]] = {
81
82
  path,
82
83
  desc: x[4]
83
84
  }
84
- //console.log(Lilact.blocks_info.labels[x[1]]);
85
85
  } );
86
86
  }
87
87
 
@@ -96,6 +96,10 @@ export function scanBlockLabels(code, path)
96
96
  */
97
97
  export function traceError(err)
98
98
  {
99
+ if(err?.is_traced) {
100
+ return err;
101
+ }
102
+
99
103
  const loc = Lilact.getErrorLocation(err);
100
104
 
101
105
  const obj = {
@@ -109,12 +113,12 @@ export function traceError(err)
109
113
  name: err.name,
110
114
 
111
115
  stack: null,
112
- error: err,
116
+ _error: err,
113
117
 
114
118
  is_traced: true
115
119
  };
116
120
 
117
- if(err.lilact_trace!==undefined) {
121
+ if( err.name!=='JSXParseError' && err.lilact_trace!==undefined ) {
118
122
 
119
123
  // to be able to trace, we assume that all of the scripts are running inside lilact.
120
124
  // if not, the error is returned unchanged and stack and label would remain null.
@@ -135,7 +139,7 @@ export function traceError(err)
135
139
 
136
140
  mps = Lilact.required_scripts[blk.path].mappings;
137
141
 
138
- [obj.lineNumber, obj.columnNumber] = Lilact.mapLocation(mps, obj.lineNumber,obj.columnNumber);
142
+ [obj.lineNumber, obj.columnNumber] = Lilact.mapLocation(mps, obj.lineNumber-1,obj.columnNumber-1);
139
143
 
140
144
  //const rm = Lilact.block_labels[block_num].required;
141
145
 
@@ -152,6 +156,7 @@ export function traceError(err)
152
156
  }
153
157
 
154
158
  }
159
+
155
160
  Lilact.error = obj;
156
161
  return obj;
157
162
 
@@ -175,10 +180,9 @@ export function traceError(err)
175
180
  */
176
181
  export function globalErrorHandler(err)
177
182
  {
178
- //console.log(err);
179
183
  if(err.error) err = err.error;
180
184
 
181
- if(!err?.is_traced && err.name!=='JSXParseError') err = Lilact.traceError(err);
185
+ err = Lilact.traceError(err);
182
186
  const cls = Lilact.emotion.css(`
183
187
  background: linear-gradient(135deg, #fff2f2d4, #ffffffd4);
184
188
  backdrop-filter: blur(10px);
@@ -194,19 +198,23 @@ export function globalErrorHandler(err)
194
198
  code {
195
199
  border: 1px solid #0003;
196
200
  overflow: auto;
201
+ padding: 10px;
197
202
  }
198
203
  `);
199
204
 
200
205
  const el = document.createElement('dialog');
201
206
 
202
-
203
207
  el.className=cls;
208
+ //<b>⚠</b>
204
209
  el.innerHTML =
205
210
  `<h3 style=""><red>Error!</red></h3>
206
211
  At <b>${err.fileName}: Line ${err.lineNumber+1}</b><br><br>
207
212
  <b>${err.name}</b>:&nbsp;<span>${err.message}</span><br><br>
208
213
  <code><pre></pre><pre><red></red></pre><pre></pre></code>
214
+ ${err._error.componentStackLog?'<br>Component Stack:<br><code><pre>'+err._error.componentStackLog+'</pre></code>':''}
209
215
  `;
216
+
217
+
210
218
  document.body.appendChild(el);
211
219
 
212
220
 
package/src/jsx.js CHANGED
@@ -1130,8 +1130,8 @@ export function transpileJSX( jsx, {
1130
1130
  if(injectTraceLabels) {
1131
1131
  out=`/*LILACTBLOCK${++blocks_info.counter}:0,0:<EXEC>*/try{`
1132
1132
  }
1133
- out+=codify(0, json);
1134
- //console.log(json);
1133
+ out+=codify(out.length, json);
1134
+
1135
1135
  if(injectTraceLabels) {
1136
1136
  if(transpilerConfig.enableLabelStack) {
1137
1137
  out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocks_info.counter},e.lilact_trace];throw e}`;
package/src/lilact.jsx CHANGED
@@ -64,7 +64,7 @@ import {transpileJSX, transpilerConfig} from "./jsx";
64
64
  export const Lilact =
65
65
  {
66
66
 
67
- VERSION: "beta.5",
67
+ VERSION: "beta.6",
68
68
 
69
69
  // Configuration
70
70
 
package/src/misc.jsx CHANGED
@@ -78,9 +78,6 @@ export const findDOMNode = (comp)=>{
78
78
 
79
79
  Unlike React, in Lilact findDOMNode can also be used on function components.
80
80
  */
81
-
82
- console.warn("NOT IMPLEMENTED YET")
83
-
84
81
  if(!comp[CORE]?.element?.parentNode) throw "findDOMNode only works on mounted components.";
85
82
  return comp[CORE].element;
86
83
  }
package/src/pane.jsx CHANGED
@@ -80,6 +80,8 @@ export const ResizablePane = forwardRef(function ResizablePane(
80
80
  },
81
81
  ref
82
82
  ) {
83
+ this.displayName = 'ResizablePane';
84
+
83
85
  const containerRef = useRef(null);
84
86
  const panes = Children.toArray(children);
85
87
  const leftChild = panes[0] ?? null;
@@ -266,3 +268,5 @@ export const ResizablePane = forwardRef(function ResizablePane(
266
268
  </div>
267
269
  );
268
270
  });
271
+
272
+
package/src/run.jsx CHANGED
@@ -81,7 +81,6 @@ export function run(jsx, path=`<string input ${++Lilact.eval_num}>`, is_inline=t
81
81
  throw e;
82
82
  }
83
83
 
84
-
85
84
  ʔ if(DEBUG) {
86
85
  Lilact.required_scripts[path].processed = processed;
87
86
  ʔ }
@@ -1,7 +0,0 @@
1
- module.exports = function() {
2
-
3
- return <>
4
- <NotDefined/>
5
- </>
6
-
7
- }
@@ -1,7 +0,0 @@
1
- module.exports = function() {
2
-
3
- return <>
4
- <NotDefined/>
5
- </>
6
-
7
- }
File without changes