lilact 0.29.1 → 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 +99 -76
- 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/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/lilact.development.js +99 -76
- 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/examples/lilact.development.js +99 -76
- 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 +1 -1
- package/src/run.jsx +142 -119
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -1392,7 +1392,7 @@ export const events_set = new Set([
|
|
|
1392
1392
|
"onafterprint","onbeforeprint","onbeforeunload","onerror","onhashchange","onload","onmessage",
|
|
1393
1393
|
"onoffline","ononline","onpagehide","onpageshow","onpopstate","onresize","onstorage","onunload",
|
|
1394
1394
|
"onblur","onchange","oncontextmenu","onfocus","oninput","oninvalid","onreset","onsearch","onselect",
|
|
1395
|
-
"onsubmit",
|
|
1395
|
+
"onsubmit", "oncancel",
|
|
1396
1396
|
"onkeydown","onkeypress","onkeyup",
|
|
1397
1397
|
"onclick","ondblclick","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel",
|
|
1398
1398
|
"onwheel",
|
package/src/run.jsx
CHANGED
|
@@ -133,37 +133,162 @@ 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
|
|
|
166
|
-
|
|
167
292
|
// ERROR IS FOUND WHEN run IS CALLED, AND NOT REQUIRE.
|
|
168
293
|
// REQUIRE REWRITES MODULE ANYWAY. THAT IS ALSO A PROBLEM.
|
|
169
294
|
|
|
@@ -325,108 +450,6 @@ function loadAsyncResource(path, module) {
|
|
|
325
450
|
return request;
|
|
326
451
|
}
|
|
327
452
|
|
|
328
|
-
export function require(path) {
|
|
329
|
-
let options = {};
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
arguments.length === 2 &&
|
|
333
|
-
arguments[1] &&
|
|
334
|
-
typeof arguments[1] === "object"
|
|
335
|
-
) {
|
|
336
|
-
options = arguments[1];
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (Lilact.importObjectPaths?.[path]) {
|
|
340
|
-
return Lilact.importObjectPaths[path];
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (options?.requirer?.path) {
|
|
344
|
-
path = joinPaths(options.requirer.path, path);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const loadAsync =
|
|
348
|
-
Boolean(Lilact[LAZY]) ||
|
|
349
|
-
Boolean(options.isLazy);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const module = getOrCreateModule(path, {});
|
|
353
|
-
|
|
354
|
-
/*
|
|
355
|
-
* A completed module can be returned synchronously unless the caller
|
|
356
|
-
* explicitly requests lazy loading.
|
|
357
|
-
*/
|
|
358
|
-
if (module.loaded && !options.forceReload) {
|
|
359
|
-
return module.exports;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (path.startsWith("#")) {
|
|
363
|
-
const element = document.getElementById(path.slice(1));
|
|
364
|
-
|
|
365
|
-
if (!element) {
|
|
366
|
-
throw report(
|
|
367
|
-
new Error(`Required element not found (${path})`),
|
|
368
|
-
path
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return run(element.textContent || "", path, {forceReload: options.forceReload});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (loadAsync) {
|
|
376
|
-
Lilact[LAZY] = false;
|
|
377
|
-
|
|
378
|
-
/*
|
|
379
|
-
* Every subsequent lazy require() receives the first request promise.
|
|
380
|
-
* This applies even when the module is still being fetched and even when
|
|
381
|
-
* the first caller used forceReload.
|
|
382
|
-
*/
|
|
383
|
-
if (module.request) {
|
|
384
|
-
return module.request;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return loadAsyncResource(path, module);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const resolved = Lilact.resolver?.(path);
|
|
391
|
-
|
|
392
|
-
if (resolved != null) {
|
|
393
|
-
if (path.endsWith(".css")) {
|
|
394
|
-
injectGlobal(String(resolved));
|
|
395
|
-
module.code = String(resolved);
|
|
396
|
-
module.loaded = true;
|
|
397
|
-
return undefined;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return run(String(resolved), path, {forceReload: options.forceReload});
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
const request = new XMLHttpRequest();
|
|
404
|
-
|
|
405
|
-
try {
|
|
406
|
-
request.open("GET", path, false);
|
|
407
|
-
request.send(null);
|
|
408
|
-
} catch (value) {
|
|
409
|
-
throw report(value, path);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (request.status >= 200 && request.status < 300) {
|
|
413
|
-
if (path.endsWith(".css")) {
|
|
414
|
-
module.code = request.responseText;
|
|
415
|
-
injectGlobal(module.code);
|
|
416
|
-
module.loaded = true;
|
|
417
|
-
return undefined;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return run(request.responseText, path, {forceReload: true});
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
throw report(
|
|
424
|
-
new Error(
|
|
425
|
-
`Unable to load ${path}: HTTP ${request.status || 0}`
|
|
426
|
-
),
|
|
427
|
-
path
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
453
|
|
|
431
454
|
export function lazy(factory) {
|
|
432
455
|
let status = "pending";
|