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.
- package/dist/lilact.development.js +459 -324
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +63 -54
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +63 -54
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/accessories.ErrorBoundary.html +8 -8
- package/docs/classes/accessories.Suspense.html +7 -7
- package/docs/classes/components.Component.html +11 -11
- package/docs/classes/components.HTMLComponent.html +11 -11
- package/docs/classes/components.RootComponent.html +11 -11
- package/docs/functions/components.cloneComponent.html +1 -1
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createPortal.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.memo.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/errors.globalErrorHandler.html +1 -8
- package/docs/functions/errors.scanBlockLabels.html +1 -0
- package/docs/functions/errors.traceError.html +1 -7
- package/docs/functions/hooks.startTransition.html +1 -1
- package/docs/functions/hooks.useActionState.html +1 -1
- package/docs/functions/hooks.useDebugValue.html +1 -1
- package/docs/functions/hooks.useDeferredValue.html +1 -1
- package/docs/functions/hooks.useEffect.html +1 -1
- package/docs/functions/hooks.useImperativeHandle.html +1 -1
- package/docs/functions/hooks.useInsertionEffect.html +1 -1
- package/docs/functions/hooks.useMemo.html +1 -1
- package/docs/functions/hooks.useReducer.html +1 -1
- package/docs/functions/run.lazy.html +1 -13
- package/docs/functions/run.require.html +1 -9
- package/docs/functions/run.run.html +1 -5
- package/docs/functions/run.runScripts.html +1 -7
- package/docs/functions/timers.timeoutPromise.html +3 -3
- package/docs/modules/errors.html +1 -1
- package/docs/modules/run.html +1 -1
- package/docs/static/index.html +1 -1
- package/docs/static/lilact.development.js +459 -324
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +63 -54
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +63 -54
- package/docs/variables/components.cloneElement.html +1 -1
- package/docs/variables/errors.blocks_info.html +1 -0
- package/docs/variables/errors.error.html +1 -0
- package/docs/variables/run.required_scripts.html +1 -0
- package/examples/index.html +1 -1
- package/examples/lilact.development.js +459 -324
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +63 -54
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +63 -54
- package/package.json +1 -1
- package/src/components.jsx +10 -4
- package/src/errors.jsx +344 -245
- package/src/expscan.js +1 -1
- package/src/hooks.jsx +8 -5
- package/src/jsx.js +16 -16
- package/src/lilact.jsx +2 -2
- 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==='
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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
|
|
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
|
|
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
|
|
618
|
+
function parseParenthesis(code, index, container)
|
|
619
619
|
{
|
|
620
620
|
const b = { // block
|
|
621
|
-
type: "
|
|
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(
|
|
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
|
|
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(
|
|
716
|
+
[index] = lookAhead( parseParenthesis, code, index, b );
|
|
717
717
|
break;
|
|
718
718
|
|
|
719
719
|
case ')': // this is only for function detection
|
|
720
|
-
raiseError(`Unmatched
|
|
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==='
|
|
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
|
|
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==='
|
|
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
|
|
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 `<
|
|
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 = '
|
|
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==='
|
|
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.
|
|
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
|
|
152
|
+
Lilact.globalErrorHandler(e);
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
window.addEventListener('error', (e) => {
|