lilact 0.5.0 → 0.5.2

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 (70) hide show
  1. package/README.md +1 -1
  2. package/dist/lilact.development.min.js +1 -1
  3. package/dist/lilact.development.min.js.map +1 -1
  4. package/dist/lilact.production.min.js +1 -1
  5. package/dist/lilact.production.min.js.map +1 -1
  6. package/docs/assets/highlight.css +42 -0
  7. package/docs/assets/navigation.js +1 -1
  8. package/docs/assets/search.js +1 -1
  9. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  10. package/docs/classes/accessories.Suspense.html +7 -7
  11. package/docs/classes/components.Component.html +10 -10
  12. package/docs/classes/components.HTMLComponent.html +10 -10
  13. package/docs/classes/components.RootComponent.html +10 -10
  14. package/docs/functions/components.createComponent.html +1 -1
  15. package/docs/functions/components.createRoot.html +1 -1
  16. package/docs/functions/components.render.html +1 -1
  17. package/docs/functions/errors.globalErrorHandler.html +7 -0
  18. package/docs/functions/errors.traceError.html +6 -0
  19. package/docs/functions/jsx.transpileJSX.html +1 -1
  20. package/docs/functions/misc.Fragment.html +1 -1
  21. package/docs/functions/misc.classNames.html +1 -1
  22. package/docs/functions/misc.deepEqual.html +1 -1
  23. package/docs/functions/misc.getComponentByPointer.html +1 -1
  24. package/docs/functions/misc.isAsync.html +1 -1
  25. package/docs/functions/misc.isClass.html +1 -1
  26. package/docs/functions/misc.isEmpty.html +1 -1
  27. package/docs/functions/misc.isError.html +1 -1
  28. package/docs/functions/misc.isThenable.html +1 -1
  29. package/docs/functions/misc.shallowEqual.html +1 -1
  30. package/docs/functions/misc.toBool.html +1 -1
  31. package/docs/functions/run.lazy.html +1 -1
  32. package/docs/functions/run.require.html +1 -1
  33. package/docs/functions/run.runScripts.html +1 -1
  34. package/docs/index.html +1 -1
  35. package/docs/modules/errors.html +1 -0
  36. package/docs/modules/misc.html +1 -1
  37. package/docs/modules/pane.html +1 -0
  38. package/docs/modules.html +1 -1
  39. package/docs/static/demos/error-callback.jsx +20 -0
  40. package/docs/static/demos/error-component-stack.jsx +39 -0
  41. package/docs/static/demos/form-elements.jsx +9 -9
  42. package/docs/static/icon.png +0 -0
  43. package/docs/static/index.html +25 -20
  44. package/docs/static/lilact.development.min.js +1 -1
  45. package/docs/static/lilact.production.min.js +1 -1
  46. package/docs/variables/misc.Children.html +2 -2
  47. package/docs/variables/pane.ResizablePane.html +48 -0
  48. package/package.json +5 -2
  49. package/root/demos/error-callback.jsx +20 -0
  50. package/root/demos/error-component-stack.jsx +39 -0
  51. package/root/demos/form-elements.jsx +9 -9
  52. package/root/icon.png +0 -0
  53. package/root/index.html +25 -20
  54. package/root/lilact.development.min.js +1 -1
  55. package/root/lilact.production.min.js +1 -1
  56. package/src/components.jsx +3 -7
  57. package/src/errors.jsx +36 -14
  58. package/src/jsx.js +5 -5
  59. package/src/lilact.jsx +2 -0
  60. package/src/misc.jsx +1 -3
  61. package/src/pane.jsx +52 -9
  62. package/src/run.jsx +0 -1
  63. package/typedoc.json +2 -0
  64. package/docs/static/demos/error-3.jsx +0 -9
  65. package/docs/variables/misc.required_scripts.html +0 -1
  66. package/root/demos/error-3.jsx +0 -9
  67. /package/docs/static/demos/{error-2.jsx → error-init.jsx} +0 -0
  68. /package/docs/static/demos/{error-1.jsx → error-parser.jsx} +0 -0
  69. /package/root/demos/{error-2.jsx → error-init.jsx} +0 -0
  70. /package/root/demos/{error-1.jsx → error-parser.jsx} +0 -0
@@ -0,0 +1,20 @@
1
+ module.exports = function() {
2
+
3
+ return <>
4
+ <button onClick={()=>{doUnknown()}}>
5
+ Press to get Error!
6
+ </button>
7
+
8
+ <p>Notice that the onClick arrow handler body is wrapped in curly brackets. <br/><br/>
9
+
10
+ {"<button onClick={()=>{doUnknown()}}>"}<br/><br/>
11
+
12
+ JS runtimes currently lack a consistent reporting mechanism for errors produced in eval,
13
+ and as Lilact runs the transpiled JSX in eval, tracing errors is very difficult.
14
+ I implemented a tracking mechanism to overcome this, but for the sake of efficiency,
15
+ it is block-based and only locates the code that is in {" {} "} blocks. As a result, the callbacks
16
+ should be wrapped in a {" {} "} to be tracable. It works otherwise, and the error itself will still
17
+ be shown, but it is not possible to display the exact location of the error.</p>
18
+ </>
19
+
20
+ }
@@ -0,0 +1,39 @@
1
+ const { ErrorBoundary, useState } = Lilact;
2
+
3
+ function Demo() {
4
+ const [mode, setMode] = useState("safe"); // "safe" | "direct" | "deep"
5
+
6
+ return (
7
+ <div>
8
+ <p>
9
+ This is the same as ErrorBoundary demo, but without boundary.
10
+ </p>
11
+ <div style={{ marginBottom: 12 }}>
12
+ <button onClick={() => setMode("direct")}>Direct-child throws</button>{" "}
13
+ <button onClick={() => setMode("deep")}>Deep-child throws</button>
14
+ </div>
15
+ {mode === "direct" && <ExplodingChild />}
16
+ {mode === "deep" && <DeepTree />}
17
+ </div>
18
+ );
19
+ }
20
+
21
+ /* Direct descendant that throws during render */
22
+ function ExplodingChild() {
23
+ throw new Error("Direct child error");
24
+ // return <div>won't render</div>;
25
+ }
26
+
27
+ /* Deeply nested tree where a leaf throws */
28
+ function Leaf() {
29
+ throw new Error("Deep child error");
30
+ // return <div>leaf</div>;
31
+ }
32
+ function Middle() {
33
+ return <div><Leaf /></div>;
34
+ }
35
+ function DeepTree() {
36
+ return <section><Middle /></section>;
37
+ }
38
+
39
+ module.exports = Demo;
@@ -2,7 +2,7 @@ module.exports = function() {
2
2
 
3
3
  return <>
4
4
 
5
- <p>Boolean attributes: literal JSX -> Lilact correct; pasted-as-HTML examples below intentionally look wrong</p>
5
+ <p>Boolean attributes: literal JSX -> Lilact correct; HTML examples below intentionally look wrong</p>
6
6
  <div style={{ fontFamily: "sans-serif" }}>
7
7
  <h3>Boolean: disabled={false} (should NOT render disabled)</h3>
8
8
  <input disabled={false} />
@@ -76,17 +76,17 @@ module.exports = function() {
76
76
  <hr />
77
77
 
78
78
  {/* JSX camelCase: works in Lilact; if pasted literally into HTML it’s “visibly wrong” because HTML won’t interpret JSX props */}
79
- <h3>JSX attribute casing: className="..." (Lilact applies class; pasted HTML uses className literally)</h3>
79
+ <h3>JSX attribute casing: className="..." (Lilact applies class; HTML uses className literally)</h3>
80
80
  <div className="demo" style={{ padding: 8, border: "1px solid #888" }}>
81
81
  className target
82
82
  </div>
83
83
 
84
- <h3>HTML uses class; Lilact uses className (pasted HTML would ignore className)</h3>
84
+ <h3>HTML uses class; Lilact uses className (HTML would ignore className)</h3>
85
85
  <div class="demo" style={{ padding: 8, border: "1px solid #888" }}>
86
- (This one uses class, so pasted HTML is correct.)
86
+ (This one uses class, so HTML is correct.)
87
87
  </div>
88
88
 
89
- <h3>JSX attribute casing: htmlFor="x" (Lilact links label; pasted HTML uses htmlFor literally)</h3>
89
+ <h3>JSX attribute casing: htmlFor="x" (Lilact links label; HTML uses htmlFor literally)</h3>
90
90
  <label htmlFor="x_Lilact">Click label (Lilact should focus input)</label>
91
91
  <input id="x_Lilact" type="text" placeholder="Focus target" />
92
92
 
@@ -94,16 +94,16 @@ module.exports = function() {
94
94
  <label htmlFor="y_html">Click label (HTML should focus input)</label>
95
95
  <input id="y_html" type="text" placeholder="Focus target" />
96
96
 
97
- <h3>JSX: tabIndex={2} (Lilact sets focus order; pasted HTML won’t)</h3>
97
+ <h3>JSX: tabIndex={2} (Lilact sets focus order; HTML won’t)</h3>
98
98
  <input tabIndex={2} defaultValue="tabIndex Lilact" />
99
99
 
100
- <h3>JSX: readOnly={true} (Lilact makes readonly; pasted HTML won’t interpret readonly={true})</h3>
100
+ <h3>JSX: readOnly={true} (Lilact makes readonly; HTML won’t interpret readonly={true})</h3>
101
101
  <input readOnly={true} defaultValue="readonly (Lilact)" />
102
102
 
103
- <h3>JSX: maxLength={5} (Lilact enforces length; pasted HTML won’t parse maxLength={5})</h3>
103
+ <h3>JSX: maxLength={5} (Lilact enforces length; HTML won’t parse maxLength={5})</h3>
104
104
  <input maxLength={5} defaultValue="123456789" />
105
105
  <p style={{ margin: "4px 0 0" }}>
106
- Type/try to enter more: Lilact will limit to 5 chars; pasted HTML won’t.
106
+ Type/try to enter more: Lilact will limit to 5 chars; HTML won’t.
107
107
  </p>
108
108
  </div>
109
109
  </>
package/root/icon.png ADDED
Binary file
package/root/index.html CHANGED
@@ -65,7 +65,9 @@ injectGlobal({ code: { whiteSpace: "pre !important",
65
65
  padding: "10px 0",
66
66
  fontSize: "14px !important",
67
67
  display: "block",
68
- overflowWrap: "anywhere" }
68
+ overflowWrap: "anywhere" },
69
+ p: {padding: "10px"},
70
+ body: {padding: "20px"}
69
71
  });
70
72
 
71
73
  const outer = css({
@@ -125,7 +127,7 @@ function DemoView({ file })
125
127
  }
126
128
 
127
129
  return <>
128
- <button onClick={()=>setOpen(!isOpen)} className={collapsible}>
130
+ <button onClick={()=>setOpen(!isOpen)} className={collapsible} type="button">
129
131
  <span className={left}>{ (isOpen?'- ':'+ ') + file[0] + ' '}</span>
130
132
  <b className={right}>{file[1]}</b>
131
133
  </button>
@@ -145,14 +147,11 @@ function DemoView({ file })
145
147
 
146
148
  function DemoBlock({file})
147
149
  {
148
- return <>
149
- <div>
150
+ return <div key={file[0]}>
150
151
  <Suspense fallback={<Spinner/>}>
151
152
  <DemoView file={file} />
152
153
  </Suspense>
153
- </div>
154
- </>
155
- ;
154
+ </div>
156
155
  }
157
156
 
158
157
 
@@ -175,35 +174,41 @@ function App()
175
174
  ['transition.jsx', '( useState, Transition )'],
176
175
  ['lazy.jsx', '( lazy, require, Suspene, Spinner )'],
177
176
  ['form-elements.jsx', '()'],
178
- ['error-boundary.jsx', '( ErrorBoundary, useState )'],
179
- ['error-1.jsx', '(JSX Parser Error)'],
180
- ['error-2.jsx', '(Error in Component)'],
181
- ['error-3.jsx', '(Error in Callback)'],
177
+ ['error-boundary.jsx', '( ErrorBoundary, useState )'],
178
+ ['error-parser.jsx', '-- JSX Parser Error --'],
179
+ ['error-init.jsx', '-- Error in Component initialization --'],
180
+ ['error-component-stack.jsx', '-- Error Component Stack --'],
181
+ ['error-callback.jsx', '-- Error in Callback --'],
182
182
  ];
183
183
 
184
184
  return <>
185
- <h3>Lilact Demos</h3>
186
-
185
+ <center>
186
+ <img src="icon.png" width="128"/><br/>
187
+ <h1>Lilact Demos</h1>
188
+
187
189
  <p>These scripts are transpiled and run directly in your browser. You have already loaded Lilact completely!</p>
188
190
 
189
191
  <p>These examples are not meant to be pretty.
190
192
 
191
193
  These are bare minimum examples of the React API implemented in Lilact.</p>
192
194
 
193
- <p>Note that we are using the development version here to have proptypes warnings.
194
- If you switch to production mode proptypes won't check anything.</p>
195
+ <p>Note that we are using the development version here to have PropTypes warnings.
196
+ If you switch to production mode PropTypes won't check anything.</p>
197
+
198
+ <p>In many examples like boundary or PropTypes you should have your browser console opened to see the logs.</p>
195
199
 
196
- <p>In many examples like boundary or proptypes you should have your browser console opened to see the logs.</p>
200
+ <p><b>Error examples other than ErrorBoundary demo will cause the page to stop working, as there is no
201
+ boundary in place.<br/>It is natural of course, and you should refresh the page to continue testing.</b></p>
197
202
 
198
203
  <p>See the{" "}<a href="../">Lilact Documentation</a>{" "}for more info.</p>
199
-
204
+ </center>
200
205
  {demos.map((x)=><DemoBlock file={x}/>)}
201
206
 
202
207
  <hr/>
203
208
  <p>
204
- Copyright (C) 2024-2026 Arash Kazemi {" <contact.arash.kazemi@gmail.com>"}. All rights reserved.
205
- <br/><br/>
206
- Lilact project is subject to the terms of BSD-2-Clause License. See the `LICENSE.TXT` file for more details.
209
+ Copyright (C) 2024-2026 Arash Kazemi {" <contact.arash.kazemi@gmail.com>"}. All rights reserved.
210
+ <br/><br/>
211
+ Lilact project is subject to the terms of BSD-2-Clause License. See the `LICENSE.TXT` file for more details.
207
212
  </p>
208
213
  </>
209
214
  }