lilact 0.28.1 → 0.28.5
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 +36 -22
- package/dist/lilact.development.js.map +2 -2
- package/dist/lilact.development.min.js +31 -31
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +31 -31
- 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 -1
- package/docs/functions/errors.scanBlockLabels.html +1 -1
- package/docs/functions/errors.traceError.html +1 -1
- package/docs/functions/run.lazy.html +1 -1
- package/docs/functions/run.require.html +1 -1
- package/docs/functions/run.run.html +1 -1
- package/docs/functions/run.runScripts.html +1 -1
- package/docs/static/demos/error-nested-5.jsx +2 -3
- package/docs/static/index.html +1 -2
- package/docs/static/lilact.development.js +36 -22
- package/docs/static/lilact.development.js.map +2 -2
- package/docs/static/lilact.development.min.js +31 -31
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +31 -31
- package/docs/variables/components.cloneElement.html +1 -1
- package/docs/variables/errors.blocks_info.html +1 -1
- package/docs/variables/errors.error.html +1 -1
- package/examples/demos/error-nested-5.jsx +2 -3
- package/examples/index.html +1 -2
- package/examples/lilact.development.js +36 -22
- package/examples/lilact.development.js.map +2 -2
- package/examples/lilact.development.min.js +31 -31
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +31 -31
- package/package.json +1 -1
- package/src/components.jsx +21 -14
- package/src/errors.jsx +45 -24
- package/src/jsx.js +3 -1
- package/src/run.jsx +10 -17
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -310,23 +310,29 @@ if(DEBUG) {
|
|
|
310
310
|
i--;
|
|
311
311
|
}
|
|
312
312
|
else {
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
try {
|
|
314
|
+
const core = prepareCore(this, item);
|
|
315
|
+
this.outlet[i] = core;
|
|
315
316
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
if(!core.element) {
|
|
322
|
-
core.element = document.createTextNode(item[TEXT]);
|
|
323
|
-
core[TEXT] = item[TEXT];
|
|
317
|
+
if(core[TEXT]===undefined) {
|
|
318
|
+
core.container = this.element? this : this.container;
|
|
319
|
+
core.apply(item.props);
|
|
324
320
|
}
|
|
325
|
-
else
|
|
326
|
-
core.element
|
|
327
|
-
|
|
321
|
+
else {
|
|
322
|
+
if(!core.element) {
|
|
323
|
+
core.element = document.createTextNode(item[TEXT]);
|
|
324
|
+
core[TEXT] = item[TEXT];
|
|
325
|
+
}
|
|
326
|
+
else if(core[TEXT]!==item[TEXT]) {
|
|
327
|
+
core.element.textContent = item[TEXT];
|
|
328
|
+
core[TEXT] = item[TEXT];
|
|
329
|
+
}
|
|
328
330
|
}
|
|
329
331
|
}
|
|
332
|
+
catch(e) {
|
|
333
|
+
renderErrorHandler(this, e);
|
|
334
|
+
}
|
|
335
|
+
|
|
330
336
|
}
|
|
331
337
|
}
|
|
332
338
|
|
|
@@ -633,10 +639,12 @@ if(DEBUG) {
|
|
|
633
639
|
const renderErrorHandler = (c, e) =>
|
|
634
640
|
{
|
|
635
641
|
const stack = [c];
|
|
642
|
+
|
|
636
643
|
while(c && !c.component?.componentDidCatch) {
|
|
637
644
|
c = c.parent;
|
|
638
645
|
if(c) stack.push(c);
|
|
639
646
|
}
|
|
647
|
+
|
|
640
648
|
if(c?.component?.componentDidCatch) {
|
|
641
649
|
if(c.entity?.getDerivedStateFromError) {
|
|
642
650
|
c.component.setState(c.entity.getDerivedStateFromError.call(c, e));
|
|
@@ -655,7 +663,6 @@ const renderErrorHandler = (c, e) =>
|
|
|
655
663
|
c.component.componentDidCatch(e, {componentStack: stack, componentStackLog: stack_log});
|
|
656
664
|
}
|
|
657
665
|
else throw(e);
|
|
658
|
-
|
|
659
666
|
}
|
|
660
667
|
|
|
661
668
|
|
package/src/errors.jsx
CHANGED
|
@@ -37,6 +37,15 @@ import Lilact from "./lilact.jsx";
|
|
|
37
37
|
import { required_scripts } from "./run.jsx";
|
|
38
38
|
import { css } from "@emotion/css";
|
|
39
39
|
|
|
40
|
+
function isSafari() {
|
|
41
|
+
const userAgent = navigator.userAgent;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
/Safari/.test(userAgent) &&
|
|
45
|
+
!/Chrome|Chromium|CriOS|FxiOS|EdgiOS|OPiOS/.test(userAgent)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
function number(value) {
|
|
41
50
|
const result = Number(value);
|
|
42
51
|
return Number.isFinite(result) ? result : null;
|
|
@@ -87,22 +96,29 @@ function stackLocation(stack) {
|
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
function browserLocation(error) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
const line = number(
|
|
100
|
+
error?.lineNumber ??
|
|
101
|
+
error?.lineno ??
|
|
102
|
+
error?.line
|
|
103
|
+
);
|
|
104
|
+
const column = number(
|
|
105
|
+
error?.columnNumber ??
|
|
106
|
+
error?.colno ??
|
|
107
|
+
error?.column
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const lineOffset = isSafari() ? 0 : 1;
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
line:
|
|
114
|
+
line == null
|
|
115
|
+
? null
|
|
116
|
+
: Math.max(0, line - lineOffset),
|
|
117
|
+
column:
|
|
118
|
+
column == null
|
|
119
|
+
? null
|
|
120
|
+
: Math.max(0, column - 1),
|
|
121
|
+
};
|
|
106
122
|
}
|
|
107
123
|
|
|
108
124
|
function traceBlock(error) {
|
|
@@ -203,15 +219,20 @@ export function traceError(value, runPath) {
|
|
|
203
219
|
runPath ||
|
|
204
220
|
null;
|
|
205
221
|
|
|
222
|
+
const sameSource =
|
|
223
|
+
!source?.path ||
|
|
224
|
+
!stack?.path ||
|
|
225
|
+
source.path === stack.path;
|
|
226
|
+
|
|
206
227
|
let line =
|
|
207
|
-
|
|
208
|
-
browser.line ??
|
|
209
|
-
null;
|
|
228
|
+
sameSource
|
|
229
|
+
? stack?.line ?? browser.line ?? null
|
|
230
|
+
: browser.line ?? null;
|
|
210
231
|
|
|
211
232
|
let column =
|
|
212
|
-
|
|
213
|
-
browser.column ??
|
|
214
|
-
null;
|
|
233
|
+
sameSource
|
|
234
|
+
? stack?.column ?? browser.column ?? null
|
|
235
|
+
: browser.column ?? null;
|
|
215
236
|
|
|
216
237
|
const result = {
|
|
217
238
|
fileName,
|
|
@@ -253,7 +274,7 @@ export function traceError(value, runPath) {
|
|
|
253
274
|
) {
|
|
254
275
|
result.fileName ||= block.path || runPath || null;
|
|
255
276
|
result.lineNumber ??= block.line;
|
|
256
|
-
result.columnNumber ??= block.
|
|
277
|
+
result.columnNumber ??= block.column;
|
|
257
278
|
result.label = block.desc;
|
|
258
279
|
}
|
|
259
280
|
|
|
@@ -390,7 +411,7 @@ export function scanBlockLabels(code, path) {
|
|
|
390
411
|
Lilact.blocks_info.labels[match[1]] = {
|
|
391
412
|
path,
|
|
392
413
|
line: Number(match[2]),
|
|
393
|
-
|
|
414
|
+
column: Number(match[3]),
|
|
394
415
|
desc: match[4],
|
|
395
416
|
};
|
|
396
417
|
}
|
package/src/jsx.js
CHANGED
|
@@ -950,8 +950,10 @@ function generateSourceMap(json, path, jsx_eols, out_eols, mappings=[])
|
|
|
950
950
|
}
|
|
951
951
|
sourcemap.mappings = mstr.substring(1).replace(/;,/g, ";");
|
|
952
952
|
|
|
953
|
-
|
|
953
|
+
let out = "\n\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(JSON.stringify(sourcemap));
|
|
954
|
+
out += `\n//# sourceURL=eval:/${path}`;
|
|
954
955
|
|
|
956
|
+
return out;
|
|
955
957
|
}
|
|
956
958
|
|
|
957
959
|
|
package/src/run.jsx
CHANGED
|
@@ -143,6 +143,7 @@ export function run(
|
|
|
143
143
|
{
|
|
144
144
|
isInline = true,
|
|
145
145
|
isModule = true,
|
|
146
|
+
hotReload = true
|
|
146
147
|
} = {}
|
|
147
148
|
) {
|
|
148
149
|
let module = required_scripts[path];
|
|
@@ -181,20 +182,19 @@ export function run(
|
|
|
181
182
|
path,
|
|
182
183
|
mappings: module.mappings,
|
|
183
184
|
factory: "createComponent",
|
|
184
|
-
appendSourcemap:
|
|
185
|
+
appendSourcemap: true,
|
|
185
186
|
injectTraceLabels: true,
|
|
186
187
|
produceCJS: true,
|
|
187
188
|
blocks_info: Lilact.blocks_info,
|
|
188
189
|
});
|
|
189
|
-
}
|
|
190
|
+
}
|
|
191
|
+
catch (value) {
|
|
190
192
|
const error = asError(value);
|
|
191
|
-
|
|
192
193
|
error.fileName ??= path;
|
|
194
|
+
error.lilact_source ??= {path};
|
|
193
195
|
error.sourcePhase = "transpile";
|
|
194
|
-
|
|
195
196
|
module.error = error;
|
|
196
197
|
Lilact.error = error;
|
|
197
|
-
|
|
198
198
|
throw error;
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -206,30 +206,23 @@ export function run(
|
|
|
206
206
|
* sourceURL helps when the browser includes eval locations in its stack.
|
|
207
207
|
* It is not used as the authoritative source; the catch block below is.
|
|
208
208
|
*/
|
|
209
|
-
processed += `\n//# sourceURL=eval:/${path}`;
|
|
210
209
|
|
|
211
210
|
try {
|
|
211
|
+
new Function(processed);
|
|
212
|
+
|
|
212
213
|
globalThis.Lilact = Lilact;
|
|
213
214
|
globalThis.createComponent = Lilact.createComponent;
|
|
214
215
|
globalThis.Fragment = Lilact.Fragment;
|
|
215
216
|
|
|
216
217
|
const result = eval(processed);
|
|
217
|
-
|
|
218
218
|
module.loaded = true;
|
|
219
219
|
|
|
220
|
-
return isEmpty(module.exports)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
} catch (value) {
|
|
224
|
-
/*
|
|
225
|
-
* This catch executes in the module whose eval failed, including
|
|
226
|
-
* generated-JavaScript syntax errors. Therefore path is authoritative.
|
|
227
|
-
*/
|
|
220
|
+
return isEmpty(module.exports) ? result : module.exports;
|
|
221
|
+
}
|
|
222
|
+
catch (value) {
|
|
228
223
|
const error = report(value, path);
|
|
229
|
-
|
|
230
224
|
error.sourcePhase ??= "runtime";
|
|
231
225
|
module.error = error;
|
|
232
|
-
|
|
233
226
|
throw error;
|
|
234
227
|
}
|
|
235
228
|
}
|