lilact 0.27.2 → 0.28.0

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.
Files changed (41) hide show
  1. package/dist/lilact.development.js +214 -203
  2. package/dist/lilact.development.js.map +4 -4
  3. package/dist/lilact.development.min.js +33 -33
  4. package/dist/lilact.development.min.js.map +4 -4
  5. package/dist/lilact.production.min.js +33 -33
  6. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  7. package/docs/classes/accessories.Suspense.html +7 -7
  8. package/docs/classes/components.Component.html +11 -11
  9. package/docs/classes/components.HTMLComponent.html +11 -11
  10. package/docs/classes/components.RootComponent.html +11 -11
  11. package/docs/functions/components.cloneComponent.html +1 -1
  12. package/docs/functions/components.createComponent.html +1 -1
  13. package/docs/functions/components.createPortal.html +1 -1
  14. package/docs/functions/components.createRoot.html +1 -1
  15. package/docs/functions/components.memo.html +1 -1
  16. package/docs/functions/components.render.html +1 -1
  17. package/docs/functions/timers.animationFramePromise.html +1 -1
  18. package/docs/functions/timers.clearInterval.html +1 -1
  19. package/docs/functions/timers.grabTimers.html +1 -1
  20. package/docs/functions/timers.releaseTimers.html +1 -1
  21. package/docs/functions/timers.timeoutPromise.html +4 -4
  22. package/docs/static/lilact.development.js +214 -203
  23. package/docs/static/lilact.development.js.map +4 -4
  24. package/docs/static/lilact.development.min.js +33 -33
  25. package/docs/static/lilact.development.min.js.map +4 -4
  26. package/docs/static/lilact.production.min.js +33 -33
  27. package/docs/variables/components.cloneElement.html +1 -1
  28. package/examples/lilact.development.js +214 -203
  29. package/examples/lilact.development.js.map +4 -4
  30. package/examples/lilact.development.min.js +33 -33
  31. package/examples/lilact.development.min.js.map +4 -4
  32. package/examples/lilact.production.min.js +33 -33
  33. package/package.json +1 -1
  34. package/src/accessories.jsx +1 -1
  35. package/src/components.jsx +22 -17
  36. package/src/expscan.js +2 -2
  37. package/src/hooks.jsx +6 -6
  38. package/src/lilact.jsx +7 -1
  39. package/src/run.jsx +1 -1
  40. package/src/timers.jsx +2 -0
  41. package/src/transition.jsx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lilact",
3
- "version": "0.27.2",
3
+ "version": "0.28.0",
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/",
@@ -32,7 +32,7 @@
32
32
  import { useEffect, useLayoutEffect, useMemo, useRef, useState, useImperativeHandle, useCallback } from "./hooks.jsx";
33
33
  import { Children, forwardRef, isThenable } from "./misc.jsx";
34
34
 
35
- import {setTimeout, clearTimeout} from "./timers.jsx"
35
+ //import {setTimeout, clearTimeout} from "./timers.jsx"
36
36
  import {Component} from "./components.jsx"
37
37
  import {emotion} from "./lilact.jsx"
38
38
  const {css,cx} = emotion;
@@ -283,12 +283,10 @@ if(DEBUG) {
283
283
  }
284
284
  }
285
285
 
286
-
287
286
  if( this?.portal ) {
288
287
  this.element = this.portal;
289
288
  }
290
289
 
291
-
292
290
  if(this.outlet?.constructor?.name!=='Array') {
293
291
  this.outlet = [this.outlet];
294
292
  }
@@ -422,8 +420,18 @@ if(DEBUG) {
422
420
  }
423
421
  }
424
422
  else if(this.entity==="select") {
425
- if(patch?.value!==this.element.value) {
426
- Lilact.setTimeout(()=>this.element.value=String(patch.value), 0);
423
+ const s = String(patch.value);
424
+
425
+ if(s!==this.element.value) {
426
+ this.element.value=s;
427
+ }
428
+ }
429
+ else if(this.entity==="option") {
430
+ if(this.container?.props?.value?.constructor?.name==='Array') {
431
+ patch.selected = this.container.props.value.indexOf(patch.value)!==-1;
432
+ }
433
+ else if(typeof(this.container?.props?.value)==='string') {
434
+ patch.selected = this.container.props.value===patch.value;
427
435
  }
428
436
  }
429
437
 
@@ -489,8 +497,11 @@ if(DEBUG) {
489
497
  }
490
498
  }
491
499
  else if(boolean_html_attributes_set.has(a)) { // not lower cased(al), as it is set as a js property
492
- this.element[a] = toBool(patch[a]);
493
- if(!this.element[a]) this.element.removeAttribute(a);
500
+ const v = toBool(patch[a]);
501
+
502
+ if(v!==this.element[a]) {
503
+ this.element[a] = v;
504
+ }
494
505
  }
495
506
  else if(a==='autoFocus') { // not lower cased(al), as it is set as a js property
496
507
  this.element['autofocus'] = toBool(patch[a]);
@@ -498,10 +509,8 @@ if(DEBUG) {
498
509
  else if(a==='htmlFor') { // not lower cased(al), as it is set as a js property
499
510
  this.element.setAttribute('for', patch[a]);
500
511
  }
501
- else {
502
- if(al!=='value' || ['input', 'textarea', 'select'].indexOf(this.entity)===-1) {
503
- this.element.setAttribute(al, patch[a]);
504
- }
512
+ else if(al!=='value' || ['input', 'textarea', 'select'].indexOf(this.entity)===-1) {
513
+ this.element.setAttribute(al, patch[a]);
505
514
  }
506
515
  }
507
516
  }
@@ -514,10 +523,6 @@ if(DEBUG) {
514
523
  this.element.onsubmit = undefined;
515
524
  }
516
525
 
517
- if(DEBUG) {
518
- //this.element.setAttribute('key', this.props.key);
519
- }
520
-
521
526
  this.updateElementClass(patch);
522
527
  }
523
528
 
@@ -1003,11 +1008,11 @@ export class Component
1003
1008
  */
1004
1009
  forceUpdate(callback)
1005
1010
  {
1006
- Lilact.clearTimeout(Lilact.update_timeout);
1011
+ Lilact._clearTimeout(Lilact.update_timeout);
1007
1012
 
1008
1013
  Lilact.update_set.add(this[CORE].container || this[CORE]);
1009
1014
  if(callback) Lilact.update_cbs.add(callback.bind(this));
1010
- Lilact.update_timeout = Lilact.setTimeout( doUpdates, Lilact.update_interval_margin );
1015
+ Lilact.update_timeout = Lilact._setTimeout( doUpdates, Lilact.update_interval_margin );
1011
1016
  }
1012
1017
 
1013
1018
  /**
@@ -1411,7 +1416,7 @@ export const length_css_attributes_set = new Set([
1411
1416
 
1412
1417
  /** @ignore */
1413
1418
  export const boolean_html_attributes_set = new
1414
- Set(["disabled", "readOnly", "required", "checked", "multiple",
1419
+ Set(["disabled", "readOnly", "required", "checked", "multiple", "selected",
1415
1420
  "hidden","open","loop","muted","controls","playsInline","allowFullScreen"]);
1416
1421
 
1417
1422
 
package/src/expscan.js CHANGED
@@ -240,10 +240,10 @@ export function processImportExports(node, jsx)
240
240
  }
241
241
 
242
242
  let cjs = '';
243
- for(const s of import_alls) {
243
+ for(const s of star_imports) {
244
244
  cjs+=`const ${s} = require(${src},{requirer:module});\n`;
245
245
  }
246
- for(const s of star_imports) {
246
+ for(const s of import_alls) {
247
247
  cjs+=`const ${s} = require(${src},{requirer:module, checkExport: ['default']}).default;\n`;
248
248
  }
249
249
  if(Object.keys(imports).length) {
package/src/hooks.jsx CHANGED
@@ -294,8 +294,8 @@ export async function useLayoutEffect(effect, deps=undefined)
294
294
  hk.deps = deps;
295
295
  Lilact.layout_effects.add( async ()=>{ hk.cleanup = await effect(); });
296
296
 
297
- Lilact.clearTimeout( Lilact.effect_timeout );
298
- Lilact.setTimeout( Lilact.processEffects, 0 );
297
+ Lilact._clearTimeout( Lilact.effect_timeout );
298
+ Lilact._setTimeout( Lilact.processEffects, 0 );
299
299
  }
300
300
 
301
301
  /**
@@ -330,8 +330,8 @@ export async function useEffect(effect, deps=undefined)
330
330
  hk.deps = deps;
331
331
  Lilact.passive_effects.add( async ()=>{ hk.cleanup = await effect(); });
332
332
 
333
- Lilact.clearTimeout( Lilact.effect_timeout );
334
- Lilact.setTimeout( Lilact.processEffects, 0 );
333
+ Lilact._clearTimeout( Lilact.effect_timeout );
334
+ Lilact._setTimeout( Lilact.processEffects, 0 );
335
335
  }
336
336
 
337
337
 
@@ -367,8 +367,8 @@ export async function useInsertionEffect(effect, deps=undefined)
367
367
  hk.deps = deps;
368
368
  Lilact.insertion_effects.add( async ()=>{ hk.cleanup = await effect(); });
369
369
 
370
- Lilact.clearTimeout( Lilact.effect_timeout );
371
- Lilact.setTimeout( Lilact.processEffects, 0 );
370
+ Lilact._clearTimeout( Lilact.effect_timeout );
371
+ Lilact._setTimeout( Lilact.processEffects, 0 );
372
372
  }
373
373
 
374
374
 
package/src/lilact.jsx CHANGED
@@ -126,10 +126,14 @@ export const Lilact =
126
126
  redux,
127
127
  emotion,
128
128
 
129
+ _setTimeout: window.setTimeout.bind(window),
130
+ _setInterval: window.setInterval.bind(window),
131
+ _clearTimeout: window.clearTimeout.bind(window),
132
+ _clearInterval: window.clearInterval.bind(window),
133
+
129
134
  }
130
135
 
131
136
  Lilact.default = Lilact;
132
-
133
137
  export default Lilact;
134
138
 
135
139
  Lilact.importObjectPaths = {
@@ -144,6 +148,8 @@ globalThis.Fragment = Lilact.Fragment;
144
148
  globalThis.require = Lilact.require;
145
149
 
146
150
  document.addEventListener("DOMContentLoaded", () => {
151
+ Lilact.grabTimers();
152
+
147
153
  Lilact.runScripts().catch(error => {
148
154
  Lilact.globalErrorHandler?.(error);
149
155
  });
package/src/run.jsx CHANGED
@@ -341,7 +341,7 @@ export function require(path) {
341
341
  * A completed module can be returned synchronously unless the caller
342
342
  * explicitly requests lazy loading.
343
343
  */
344
- if (module.loaded && !options.forceUpdate && !loadAsync) {
344
+ if (module.loaded && !options.forceUpdate) {
345
345
  return module.exports;
346
346
  }
347
347
 
package/src/timers.jsx CHANGED
@@ -230,6 +230,7 @@ export function setInterval(callback, interval, ...args)
230
230
  export function clearTimeout(id)
231
231
  {
232
232
  if(all_timers[id]) all_timers[id][CLEARED] = true;
233
+ else _clearTimeout(id);
233
234
  }
234
235
 
235
236
  /**
@@ -240,6 +241,7 @@ export function clearTimeout(id)
240
241
  export function clearInterval(id)
241
242
  {
242
243
  if(all_timers[id]) all_timers[id][CLEARED] = true;
244
+ else _clearInterval(id);
243
245
  }
244
246
 
245
247
  /**
@@ -29,7 +29,7 @@
29
29
  */
30
30
  import Lilact from './lilact.jsx';
31
31
 
32
- import { setTimeout, clearTimeout } from "./timers.jsx"
32
+ //import { setTimeout, clearTimeout } from "./timers.jsx"
33
33
  import { Children } from "./misc.jsx"
34
34
  import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "./hooks.jsx"
35
35