lilact 0.29.0 → 0.29.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.
- package/dist/lilact.development.js +110 -82
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +17 -17
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +17 -17
- 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/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/index.html +1 -1
- package/docs/static/lilact.development.js +110 -82
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +17 -17
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +17 -17
- package/docs/variables/components.cloneElement.html +1 -1
- package/examples/index.html +1 -1
- package/examples/lilact.development.js +110 -82
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +17 -17
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +17 -17
- package/package.json +1 -1
- package/src/components.jsx +19 -7
- package/src/lilact.jsx +1 -1
- package/src/run.jsx +146 -119
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
import Lilact from './lilact.jsx';
|
|
32
32
|
|
|
33
33
|
import { CORE, COMPONENT, TEXT, IS_ZOMBIE, IDX, CHILD_CLASS_ADDENDUM, MEMOIZED } from "./symbols.jsx"
|
|
34
|
-
import { shallowEqual, toBool, isClass } from "./misc.jsx";
|
|
34
|
+
import { shallowEqual, toBool, isClass, isThenable } from "./misc.jsx";
|
|
35
35
|
|
|
36
36
|
import { PropTypes } from './proptypes.jsx';
|
|
37
37
|
|
|
@@ -627,6 +627,18 @@ class ComponentCore
|
|
|
627
627
|
|
|
628
628
|
const renderErrorHandler = (c, e) =>
|
|
629
629
|
{
|
|
630
|
+
const value =
|
|
631
|
+
e?.error instanceof Error
|
|
632
|
+
? e.error
|
|
633
|
+
: e?.reason !== undefined
|
|
634
|
+
? e.reason
|
|
635
|
+
: e;
|
|
636
|
+
|
|
637
|
+
const error = Lilact.isThenable(e)? e : Lilact.traceError(
|
|
638
|
+
value,
|
|
639
|
+
e?.fileName || null
|
|
640
|
+
);
|
|
641
|
+
|
|
630
642
|
const stack = [c];
|
|
631
643
|
|
|
632
644
|
while(c && !c.component?.componentDidCatch) {
|
|
@@ -636,7 +648,7 @@ const renderErrorHandler = (c, e) =>
|
|
|
636
648
|
|
|
637
649
|
if(c?.component?.componentDidCatch) {
|
|
638
650
|
if(c.entity?.getDerivedStateFromError) {
|
|
639
|
-
c.component.setState(c.entity.getDerivedStateFromError.call(c,
|
|
651
|
+
c.component.setState(c.entity.getDerivedStateFromError.call(c, error));
|
|
640
652
|
}
|
|
641
653
|
}
|
|
642
654
|
|
|
@@ -645,13 +657,13 @@ const renderErrorHandler = (c, e) =>
|
|
|
645
657
|
x.component.displayName():x.component.displayName}` ) )
|
|
646
658
|
.join('\n');
|
|
647
659
|
|
|
648
|
-
|
|
649
|
-
|
|
660
|
+
error.componentStack = stack;
|
|
661
|
+
error.componentStackLog = stack_log;
|
|
650
662
|
|
|
651
663
|
if(c?.component?.componentDidCatch) {
|
|
652
|
-
c.component.componentDidCatch(
|
|
664
|
+
c.component.componentDidCatch(error, {componentStack: stack, componentStackLog: stack_log});
|
|
653
665
|
}
|
|
654
|
-
else throw(e);
|
|
666
|
+
else throw(e); // should be e not error
|
|
655
667
|
}
|
|
656
668
|
|
|
657
669
|
|
|
@@ -1380,7 +1392,7 @@ export const events_set = new Set([
|
|
|
1380
1392
|
"onafterprint","onbeforeprint","onbeforeunload","onerror","onhashchange","onload","onmessage",
|
|
1381
1393
|
"onoffline","ononline","onpagehide","onpageshow","onpopstate","onresize","onstorage","onunload",
|
|
1382
1394
|
"onblur","onchange","oncontextmenu","onfocus","oninput","oninvalid","onreset","onsearch","onselect",
|
|
1383
|
-
"onsubmit",
|
|
1395
|
+
"onsubmit", "oncancel",
|
|
1384
1396
|
"onkeydown","onkeypress","onkeyup",
|
|
1385
1397
|
"onclick","ondblclick","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel",
|
|
1386
1398
|
"onwheel",
|
package/src/lilact.jsx
CHANGED
package/src/run.jsx
CHANGED
|
@@ -133,36 +133,165 @@ function createModule(path, {
|
|
|
133
133
|
return module;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
function loadModule(path, options = {}) {
|
|
137
|
+
if (Lilact.importObjectPaths?.[path]) {
|
|
138
|
+
return Lilact.importObjectPaths[path];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (options.requirer?.path) {
|
|
142
|
+
path = joinPaths(options.requirer.path, path);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const loadAsync =
|
|
146
|
+
Boolean(Lilact[LAZY]) ||
|
|
147
|
+
Boolean(options.isLazy);
|
|
148
|
+
|
|
149
|
+
const module = getOrCreateModule(path, {});
|
|
150
|
+
|
|
151
|
+
if (module.loaded && !options.forceReload) {
|
|
152
|
+
return module.exports;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (path.startsWith("#")) {
|
|
156
|
+
const element = document.getElementById(path.slice(1));
|
|
157
|
+
|
|
158
|
+
if (!element) {
|
|
159
|
+
throw report(
|
|
160
|
+
new Error(`Required element not found (${path})`),
|
|
161
|
+
path
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return run(
|
|
166
|
+
element.textContent || "",
|
|
167
|
+
path,
|
|
168
|
+
{forceReload: options.forceReload}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (loadAsync) {
|
|
173
|
+
Lilact[LAZY] = false;
|
|
174
|
+
|
|
175
|
+
if (module.request) {
|
|
176
|
+
return module.request;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return loadAsyncResource(path, module);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const resolved = Lilact.resolver?.(path);
|
|
183
|
+
|
|
184
|
+
if (resolved != null) {
|
|
185
|
+
if (path.endsWith(".css")) {
|
|
186
|
+
injectGlobal(String(resolved));
|
|
187
|
+
module.code = String(resolved);
|
|
188
|
+
module.loaded = true;
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return run(
|
|
193
|
+
String(resolved),
|
|
194
|
+
path,
|
|
195
|
+
{forceReload: options.forceReload}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const request = new XMLHttpRequest();
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
request.open("GET", path, false);
|
|
203
|
+
request.send(null);
|
|
204
|
+
} catch (value) {
|
|
205
|
+
throw report(value, path);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (request.status >= 200 && request.status < 300) {
|
|
209
|
+
if (path.endsWith(".css")) {
|
|
210
|
+
module.code = request.responseText;
|
|
211
|
+
injectGlobal(module.code);
|
|
212
|
+
module.loaded = true;
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return run(
|
|
217
|
+
request.responseText,
|
|
218
|
+
path,
|
|
219
|
+
{forceReload: true}
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
throw report(
|
|
224
|
+
new Error(
|
|
225
|
+
`Unable to load ${path}: HTTP ${request.status || 0}`
|
|
226
|
+
),
|
|
227
|
+
path
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function require(path)
|
|
232
|
+
{
|
|
233
|
+
let options = {};
|
|
234
|
+
|
|
235
|
+
if (
|
|
236
|
+
arguments.length === 2 &&
|
|
237
|
+
arguments[1] &&
|
|
238
|
+
typeof arguments[1] === "object"
|
|
239
|
+
) {
|
|
240
|
+
options = arguments[1];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return loadModule(path, options);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
|
|
136
247
|
function makeImportsObject(mod)
|
|
137
248
|
{
|
|
138
|
-
mod.importsObject
|
|
249
|
+
mod.importsObject = {};
|
|
139
250
|
|
|
140
|
-
for(const path in mod.meta.imports) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
251
|
+
for (const path in mod.meta.imports) {
|
|
252
|
+
const imps = mod.meta.imports[path];
|
|
253
|
+
|
|
254
|
+
/*
|
|
255
|
+
* Do not use require() here. loadModule() resolves and loads the
|
|
256
|
+
* dependency, then evaluates it directly through run().
|
|
257
|
+
*/
|
|
258
|
+
const exps = loadModule(path, {
|
|
259
|
+
requirer: mod,
|
|
260
|
+
});
|
|
146
261
|
|
|
147
|
-
for(const i in imps.named_imports) {
|
|
148
|
-
if(i==='') continue;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
262
|
+
for (const i in imps.named_imports) {
|
|
263
|
+
if (i === '') continue;
|
|
264
|
+
|
|
265
|
+
const exportedName = imps.named_imports[i];
|
|
266
|
+
|
|
267
|
+
if (!Object.prototype.hasOwnProperty.call(exps, exportedName)) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
`Imported module does not export any "${i}".`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
mod.importsObject[i] = exps[exportedName];
|
|
152
274
|
}
|
|
153
275
|
|
|
154
|
-
for(const i of imps.import_defaults) {
|
|
155
|
-
if(!
|
|
276
|
+
for (const i of imps.import_defaults) {
|
|
277
|
+
if (!Object.prototype.hasOwnProperty.call(exps, 'default')) {
|
|
278
|
+
throw new Error(
|
|
279
|
+
`Imported module does not export a default.`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
156
283
|
mod.importsObject[i] = exps.default;
|
|
157
284
|
}
|
|
158
285
|
|
|
159
|
-
|
|
160
|
-
for(const i of imps.import_stars) {
|
|
286
|
+
for (const i of imps.import_stars) {
|
|
161
287
|
mod.importsObject[i] = {...exps};
|
|
162
288
|
}
|
|
163
289
|
}
|
|
164
290
|
}
|
|
165
291
|
|
|
292
|
+
// ERROR IS FOUND WHEN run IS CALLED, AND NOT REQUIRE.
|
|
293
|
+
// REQUIRE REWRITES MODULE ANYWAY. THAT IS ALSO A PROBLEM.
|
|
294
|
+
|
|
166
295
|
export function run(
|
|
167
296
|
jsx,
|
|
168
297
|
path = `InlineJSX-${++Lilact.eval_num}`,
|
|
@@ -234,7 +363,7 @@ export function run(
|
|
|
234
363
|
globalThis.createComponent = Lilact.createComponent;
|
|
235
364
|
globalThis.Fragment = Lilact.Fragment;
|
|
236
365
|
|
|
237
|
-
|
|
366
|
+
makeImportsObject(module);
|
|
238
367
|
|
|
239
368
|
Lilact.scriptImportsObject = module.importsObject;
|
|
240
369
|
const result = eval(processed);
|
|
@@ -321,108 +450,6 @@ function loadAsyncResource(path, module) {
|
|
|
321
450
|
return request;
|
|
322
451
|
}
|
|
323
452
|
|
|
324
|
-
export function require(path) {
|
|
325
|
-
let options = {};
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
arguments.length === 2 &&
|
|
329
|
-
arguments[1] &&
|
|
330
|
-
typeof arguments[1] === "object"
|
|
331
|
-
) {
|
|
332
|
-
options = arguments[1];
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (Lilact.importObjectPaths?.[path]) {
|
|
336
|
-
return Lilact.importObjectPaths[path];
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (options?.requirer?.path) {
|
|
340
|
-
path = joinPaths(options.requirer.path, path);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const loadAsync =
|
|
344
|
-
Boolean(Lilact[LAZY]) ||
|
|
345
|
-
Boolean(options.isLazy);
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const module = getOrCreateModule(path, {});
|
|
349
|
-
|
|
350
|
-
/*
|
|
351
|
-
* A completed module can be returned synchronously unless the caller
|
|
352
|
-
* explicitly requests lazy loading.
|
|
353
|
-
*/
|
|
354
|
-
if (module.loaded && !options.forceReload) {
|
|
355
|
-
return module.exports;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (path.startsWith("#")) {
|
|
359
|
-
const element = document.getElementById(path.slice(1));
|
|
360
|
-
|
|
361
|
-
if (!element) {
|
|
362
|
-
throw report(
|
|
363
|
-
new Error(`Required element not found (${path})`),
|
|
364
|
-
path
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
return run(element.textContent || "", path, {forceReload: options.forceReload});
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (loadAsync) {
|
|
372
|
-
Lilact[LAZY] = false;
|
|
373
|
-
|
|
374
|
-
/*
|
|
375
|
-
* Every subsequent lazy require() receives the first request promise.
|
|
376
|
-
* This applies even when the module is still being fetched and even when
|
|
377
|
-
* the first caller used forceReload.
|
|
378
|
-
*/
|
|
379
|
-
if (module.request) {
|
|
380
|
-
return module.request;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return loadAsyncResource(path, module);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const resolved = Lilact.resolver?.(path);
|
|
387
|
-
|
|
388
|
-
if (resolved != null) {
|
|
389
|
-
if (path.endsWith(".css")) {
|
|
390
|
-
injectGlobal(String(resolved));
|
|
391
|
-
module.code = String(resolved);
|
|
392
|
-
module.loaded = true;
|
|
393
|
-
return undefined;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return run(String(resolved), path, {forceReload: options.forceReload});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
const request = new XMLHttpRequest();
|
|
400
|
-
|
|
401
|
-
try {
|
|
402
|
-
request.open("GET", path, false);
|
|
403
|
-
request.send(null);
|
|
404
|
-
} catch (value) {
|
|
405
|
-
throw report(value, path);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (request.status >= 200 && request.status < 300) {
|
|
409
|
-
if (path.endsWith(".css")) {
|
|
410
|
-
module.code = request.responseText;
|
|
411
|
-
injectGlobal(module.code);
|
|
412
|
-
module.loaded = true;
|
|
413
|
-
return undefined;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return run(request.responseText, path, {forceReload: options.forceReload});
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
throw report(
|
|
420
|
-
new Error(
|
|
421
|
-
`Unable to load ${path}: HTTP ${request.status || 0}`
|
|
422
|
-
),
|
|
423
|
-
path
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
453
|
|
|
427
454
|
export function lazy(factory) {
|
|
428
455
|
let status = "pending";
|