lilact 0.26.3 → 0.26.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lilact",
3
- "version": "0.26.3",
3
+ "version": "0.26.5",
4
4
  "description": "A Little React/JSX Runtime Implementation for Browser",
5
5
  "repository": "github:arashkazemi/lilact",
6
6
  "homepage": "https://arashkazemi.github.io/lilact/",
@@ -693,7 +693,7 @@ export const SplitPane = forwardRef(function SplitPane(
693
693
  const computedSplitterStyle = {
694
694
  background: "rgba(0,0,0,0.08)",
695
695
  boxShadow: "inset 0 0 2px rgba(0,0,0,0.25)",
696
- zIndex: 10,
696
+ zIndex: 1000000,
697
697
  position: "absolute",
698
698
  cursor: internalMode === "horizontal" ? "col-resize" : "row-resize",
699
699
  touchAction: "none",
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
 
@@ -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
- case 'F':
308
- const j = i;
309
- const type = s[i]==='F'?`= ${node.out[i]} `:'';
310
- node.out[i] = null;
311
- i++;
312
- skip_spaces();
313
- const name = node.out[i];
314
- if(s[j]==='V') {
315
- node.out[i] = null;
316
- i++;
317
- }
318
- skip_spaces();
319
- node.out[m.index].cjs = `module.exports.${name} ${type}`;
320
- continue;
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/lilact.jsx CHANGED
@@ -63,6 +63,7 @@ import * as misc from './misc.jsx';
63
63
  import * as errors from './errors.jsx';
64
64
  import * as router from './router.jsx';
65
65
  import * as accessories from './accessories.jsx';
66
+ import * as symbols from './symbols.jsx';
66
67
  import {transpileJSX, transpilerConfig} from "./jsx";
67
68
 
68
69
 
@@ -79,6 +80,7 @@ export * from './misc.jsx';
79
80
  export * from './errors.jsx';
80
81
  export * from './router.jsx';
81
82
  export * from './accessories.jsx';
83
+ export * from './symbols.jsx';
82
84
  export {transpileJSX, transpilerConfig} from "./jsx";
83
85
 
84
86
 
@@ -111,6 +113,7 @@ export const Lilact =
111
113
  ...timers,
112
114
  ...events,
113
115
  ...errors,
116
+ ...symbols,
114
117
 
115
118
  ...router,
116
119
  ...accessories,
package/src/run.jsx CHANGED
@@ -30,7 +30,7 @@
30
30
  import Lilact from './lilact.jsx';
31
31
 
32
32
  import { CORE, COMPONENT, LAZY } from "./symbols.jsx"
33
-
33
+ import { injectGlobal } from "@emotion/css"
34
34
 
35
35
  function joinPaths(basePath, relativePath) {
36
36
  const isAbs = relativePath.startsWith("/");
@@ -180,28 +180,45 @@ export function require(path)
180
180
  if(Lilact?.[LAZY] || isLazy) {
181
181
  Lilact[LAZY]=false;
182
182
 
183
- return fetch(path)
184
- .then(res => {
183
+ let p = Lilact.resolver?.(path);
184
+
185
+ if(p) {
186
+ p = Promise.resolve(p);
187
+ }
188
+ else {
189
+ p = fetch(path).then(res => {
185
190
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
186
191
  return res.text();
187
- })
188
- .then(res => {
189
- res = run(res, path, false);
190
- return res?.default ?? res;
191
- })
192
- .catch(err => {
193
- throw err;
194
192
  });
193
+ }
194
+ return p.then(res => {
195
+ if(path.endsWith(".css")) {
196
+ injectGlobal(res);
197
+ return;
198
+ }
199
+ res = run(res, path, false);
200
+ return res?.default ?? res;
201
+ })
202
+ .catch(err => {
203
+ throw err;
204
+ });
195
205
  }
196
206
  else {
197
- // note: this makes a sync request. this is not advised,
198
- // but import should be sync. for an async solution use lazy and suspense.
199
-
200
- const request = new XMLHttpRequest();
201
- request.open("GET", path, {isInline:false});
202
- request.send(null);
203
- if (request.status === 200) {
204
- return run(request.responseText, path, false);
207
+ const p = Lilact.resolver?.(path);
208
+ if(p) {
209
+ return run(p, path, false);
210
+ }
211
+ else {
212
+ const request = new XMLHttpRequest();
213
+ request.open("GET", path, {isInline:false});
214
+ request.send(null);
215
+ if (request.status === 200) {
216
+ if(path.endsWith(".css")) {
217
+ injectGlobal(res);
218
+ return;
219
+ }
220
+ return run(request.responseText, path, false);
221
+ }
205
222
  }
206
223
  }
207
224
  }