lilact 0.26.4 → 0.26.6
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 +51 -30
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +27 -27
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +27 -27
- package/docs/functions/errors.globalErrorHandler.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.runScripts.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +3 -3
- package/docs/static/demos/lazy.jsx +2 -2
- package/docs/static/index.html +12 -12
- package/docs/static/lilact.development.js +51 -30
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +27 -27
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +27 -27
- package/examples/demos/lazy.jsx +2 -2
- package/examples/index.html +12 -12
- package/examples/lilact.development.js +51 -30
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +27 -27
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +27 -27
- package/package.json +1 -1
- package/src/errors.jsx +4 -2
- package/src/events.jsx +8 -4
- package/src/expscan.js +31 -18
- package/src/run.jsx +33 -21
package/package.json
CHANGED
package/src/errors.jsx
CHANGED
|
@@ -62,7 +62,8 @@ function getErrorLocation(err) // works for both error and error-event, and also
|
|
|
62
62
|
// Firefox: fn@eval:xxx:LINE:COL
|
|
63
63
|
// Safari: @eval:xxx:LINE:COL (sometimes)
|
|
64
64
|
/** @ignore */
|
|
65
|
-
function parseEvalLocationFromStack(stack, urlPrefix = "eval:/")
|
|
65
|
+
function parseEvalLocationFromStack(stack, urlPrefix = "eval:/")
|
|
66
|
+
{
|
|
66
67
|
const raw = typeof stack === "string" ? stack : String(stack || "");
|
|
67
68
|
const lines = raw.split(/\r?\n/);
|
|
68
69
|
|
|
@@ -89,7 +90,8 @@ function parseEvalLocationFromStack(stack, urlPrefix = "eval:/") {
|
|
|
89
90
|
return { url: null, line: null, col: null, matched: null, stackPreview: lines.slice(0, 6).join("\n") };
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
function escapeRegExp(s)
|
|
93
|
+
function escapeRegExp(s)
|
|
94
|
+
{
|
|
93
95
|
return String(s).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
94
96
|
}
|
|
95
97
|
|
package/src/events.jsx
CHANGED
|
@@ -59,7 +59,8 @@ const _pool = [];
|
|
|
59
59
|
const MAX_POOL_SIZE = 10;
|
|
60
60
|
const POINTER_TYPES = ["mouse", "pen", "touch"];
|
|
61
61
|
|
|
62
|
-
export function createSyntheticEvent(nativeEvent, currentTarget)
|
|
62
|
+
export function createSyntheticEvent(nativeEvent, currentTarget)
|
|
63
|
+
{
|
|
63
64
|
const e = _pool.length ? _pool.pop() : {};
|
|
64
65
|
|
|
65
66
|
e.nativeEvent = nativeEvent;
|
|
@@ -181,7 +182,8 @@ export function createSyntheticEvent(nativeEvent, currentTarget) {
|
|
|
181
182
|
return e;
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
export function releaseSyntheticEvent(e)
|
|
185
|
+
export function releaseSyntheticEvent(e)
|
|
186
|
+
{
|
|
185
187
|
if (e && !e.isPersistent) {
|
|
186
188
|
e.nativeEvent = null;
|
|
187
189
|
e.type = null;
|
|
@@ -261,7 +263,8 @@ export function releaseSyntheticEvent(e) {
|
|
|
261
263
|
// Main wrapper factory
|
|
262
264
|
// fn: function(syntheticEvent) { ... }
|
|
263
265
|
// opts: { capture: bool, passive: bool, once: bool, stopPropagationOnTrueReturn: bool }
|
|
264
|
-
export function wrapListener(fn, opts = {})
|
|
266
|
+
export function wrapListener(fn, opts = {})
|
|
267
|
+
{
|
|
265
268
|
const { stopPropagationOnTrueReturn = false } = opts;
|
|
266
269
|
|
|
267
270
|
return function handler(nativeEvent) {
|
|
@@ -284,7 +287,8 @@ export function wrapListener(fn, opts = {}) {
|
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
// Convenience: add/remove wrapper-managed listener
|
|
287
|
-
export function addWrappedEventListener(target, type, fn, options = {})
|
|
290
|
+
export function addWrappedEventListener(target, type, fn, options = {})
|
|
291
|
+
{
|
|
288
292
|
const handler = wrapListener(fn, options);
|
|
289
293
|
|
|
290
294
|
target.addEventListener(type, handler, options);
|
package/src/expscan.js
CHANGED
|
@@ -72,7 +72,8 @@ function isValidIdentifierName(s) {
|
|
|
72
72
|
return !keywords.has(s);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export function labeler(custom_words, x)
|
|
75
|
+
export function labeler(custom_words, x)
|
|
76
|
+
{
|
|
76
77
|
if( typeof(x)==='string' ) {
|
|
77
78
|
if(custom_words && custom_words.hasOwnProperty(x)) return custom_words[x];
|
|
78
79
|
|
|
@@ -269,7 +270,7 @@ export function processImportExports(node, jsx)
|
|
|
269
270
|
|
|
270
271
|
cjs+=`const ${o} = require(${src}, {checkExport: ${ls},requirer:module})`;
|
|
271
272
|
}
|
|
272
|
-
else {
|
|
273
|
+
else if(cjs.length===0) {
|
|
273
274
|
cjs+=`require(${src},{requirer:module})`;
|
|
274
275
|
}
|
|
275
276
|
|
|
@@ -303,22 +304,34 @@ export function processImportExports(node, jsx)
|
|
|
303
304
|
node.out[m.index].cjs = 'module.exports.default =';
|
|
304
305
|
continue;
|
|
305
306
|
|
|
306
|
-
case 'V':
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
307
|
+
case 'V':{
|
|
308
|
+
const tp = node.out[i];
|
|
309
|
+
node.out[i] = null;
|
|
310
|
+
i++;
|
|
311
|
+
skip_spaces();
|
|
312
|
+
const name = node.out[i];
|
|
313
|
+
|
|
314
|
+
node.out[i] = null;
|
|
315
|
+
i++;
|
|
316
|
+
|
|
317
|
+
skip_spaces();
|
|
318
|
+
node.out[m.index].cjs = `${tp} ${name} = module.exports.${name} `;
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
case 'F':{
|
|
322
|
+
const tp = node.out[i];
|
|
323
|
+
node.out[i] = null;
|
|
324
|
+
i++;
|
|
325
|
+
skip_spaces();
|
|
326
|
+
const name = node.out[i];
|
|
327
|
+
|
|
328
|
+
// node.out[i] = null;
|
|
329
|
+
// i++;
|
|
330
|
+
// skip_spaces();
|
|
331
|
+
|
|
332
|
+
node.out[m.index].cjs = `module.exports.${name} = ${tp} `;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
322
335
|
case '*':
|
|
323
336
|
node.out[i] = null;
|
|
324
337
|
i++;
|
package/src/run.jsx
CHANGED
|
@@ -87,7 +87,6 @@ export function run(jsx, path=`InlineJSX-${++Lilact.eval_num}`, {isInline, isMod
|
|
|
87
87
|
|
|
88
88
|
required_scripts[path] = module;
|
|
89
89
|
|
|
90
|
-
|
|
91
90
|
try {
|
|
92
91
|
processed = Lilact.transpileJSX( jsx,
|
|
93
92
|
{
|
|
@@ -180,32 +179,45 @@ export function require(path)
|
|
|
180
179
|
if(Lilact?.[LAZY] || isLazy) {
|
|
181
180
|
Lilact[LAZY]=false;
|
|
182
181
|
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
let p = Lilact.resolver?.(path);
|
|
183
|
+
|
|
184
|
+
if(p) {
|
|
185
|
+
p = Promise.resolve(p);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
p = fetch(path).then(res => {
|
|
185
189
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
186
190
|
return res.text();
|
|
187
|
-
})
|
|
188
|
-
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return p.then(res => {
|
|
194
|
+
if(path.endsWith(".css")) {
|
|
195
|
+
injectGlobal(res);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
res = run(res, path, false);
|
|
199
|
+
return res?.default ?? res;
|
|
200
|
+
})
|
|
201
|
+
.catch(err => {
|
|
202
|
+
throw err;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
const p = Lilact.resolver?.(path);
|
|
207
|
+
if(p) {
|
|
208
|
+
return run(p, path, false);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const request = new XMLHttpRequest();
|
|
212
|
+
request.open("GET", path, {isInline:false});
|
|
213
|
+
request.send(null);
|
|
214
|
+
if (request.status === 200) {
|
|
189
215
|
if(path.endsWith(".css")) {
|
|
190
216
|
injectGlobal(res);
|
|
191
217
|
return;
|
|
192
218
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
})
|
|
196
|
-
.catch(err => {
|
|
197
|
-
throw err;
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
// note: this makes a sync request. this is not advised,
|
|
202
|
-
// but import should be sync. for an async solution use lazy and suspense.
|
|
203
|
-
|
|
204
|
-
const request = new XMLHttpRequest();
|
|
205
|
-
request.open("GET", path, {isInline:false});
|
|
206
|
-
request.send(null);
|
|
207
|
-
if (request.status === 200) {
|
|
208
|
-
return run(request.responseText, path, false);
|
|
219
|
+
return run(request.responseText, path, false);
|
|
220
|
+
}
|
|
209
221
|
}
|
|
210
222
|
}
|
|
211
223
|
}
|