vigla 0.2.0 → 0.2.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.
Files changed (44) hide show
  1. package/dist/compiler/client/script.d.ts.map +1 -1
  2. package/dist/compiler/client/script.js +1 -1
  3. package/dist/compiler/client/script.js.map +1 -1
  4. package/dist/runtime/dom/context.d.ts.map +1 -1
  5. package/dist/runtime/dom/context.js +21 -7
  6. package/dist/runtime/dom/context.js.map +1 -1
  7. package/dist/runtime/dom/events.d.ts.map +1 -1
  8. package/dist/runtime/dom/events.js +2 -1
  9. package/dist/runtime/dom/events.js.map +1 -1
  10. package/dist/runtime/dom/mount.d.ts.map +1 -1
  11. package/dist/runtime/dom/mount.js +1 -2
  12. package/dist/runtime/dom/mount.js.map +1 -1
  13. package/dist/runtime/dom/props.d.ts +1 -2
  14. package/dist/runtime/dom/props.d.ts.map +1 -1
  15. package/dist/runtime/dom/props.js +5 -11
  16. package/dist/runtime/dom/props.js.map +1 -1
  17. package/dist/runtime/reactivity/batch.d.ts +2 -0
  18. package/dist/runtime/reactivity/batch.d.ts.map +1 -1
  19. package/dist/runtime/reactivity/batch.js +22 -6
  20. package/dist/runtime/reactivity/batch.js.map +1 -1
  21. package/dist/runtime/reactivity/effects.d.ts.map +1 -1
  22. package/dist/runtime/reactivity/effects.js +3 -22
  23. package/dist/runtime/reactivity/effects.js.map +1 -1
  24. package/dist/runtime/reactivity/held.d.ts.map +1 -1
  25. package/dist/runtime/reactivity/held.js +1 -0
  26. package/dist/runtime/reactivity/held.js.map +1 -1
  27. package/dist/runtime/reactivity/reads.d.ts.map +1 -1
  28. package/dist/runtime/reactivity/reads.js +8 -6
  29. package/dist/runtime/reactivity/reads.js.map +1 -1
  30. package/dist/runtime/reactivity/siblings.d.ts +5 -0
  31. package/dist/runtime/reactivity/siblings.d.ts.map +1 -0
  32. package/dist/runtime/reactivity/siblings.js +30 -0
  33. package/dist/runtime/reactivity/siblings.js.map +1 -0
  34. package/package.json +1 -1
  35. package/src/compiler/client/script.ts +1 -5
  36. package/src/runtime/dom/context.ts +19 -7
  37. package/src/runtime/dom/events.ts +2 -1
  38. package/src/runtime/dom/mount.ts +1 -2
  39. package/src/runtime/dom/props.ts +5 -11
  40. package/src/runtime/reactivity/batch.ts +31 -6
  41. package/src/runtime/reactivity/effects.ts +2 -16
  42. package/src/runtime/reactivity/held.ts +1 -0
  43. package/src/runtime/reactivity/reads.ts +7 -5
  44. package/src/runtime/reactivity/siblings.ts +25 -0
@@ -54,6 +54,7 @@ import { handlerOf } from './handlers.ts';
54
54
  import { orphan, teardownOrphan } from './errors.ts';
55
55
  import { ownLeaving } from './outgoing.ts';
56
56
  import { presently, retire } from './past.ts';
57
+ import { link, unlink } from './siblings.ts';
57
58
  import {
58
59
  deriving,
59
60
  evaluation,
@@ -265,12 +266,7 @@ function create(kind: Kind, fn: (() => void | (() => void)) | null, parent: Effe
265
266
  slots: null,
266
267
  captured: null
267
268
  };
268
- if (parent !== null) {
269
- effect.prev = parent.last;
270
- if (parent.last === null) parent.first = effect;
271
- else parent.last.next = effect;
272
- parent.last = effect;
273
- }
269
+ if (parent !== null) link(effect, parent);
274
270
  const claimer = ownEffect(effect);
275
271
  if (drafting !== 0 && parent !== null) capture(parent, effect, claimer);
276
272
  return effect;
@@ -544,16 +540,6 @@ function immediately(stop: () => void): void {
544
540
  stop();
545
541
  }
546
542
 
547
- function unlink(effect: Effect): void {
548
- const parent = effect.parent;
549
- if (parent === null) return;
550
- if (effect.prev === null) parent.first = effect.next;
551
- else effect.prev.next = effect.next;
552
- if (effect.next === null) parent.last = effect.prev;
553
- else effect.next.prev = effect.prev;
554
- effect.prev = effect.next = null;
555
- }
556
-
557
543
  type Among = ((child: Effect) => boolean) | null;
558
544
 
559
545
  function doomed(child: Effect, keepBranches: boolean, among: Among): boolean {
@@ -104,6 +104,7 @@ function fold(from: Batch, into: Batch): void {
104
104
  from.work = 0;
105
105
  from.done = true;
106
106
  from.into = into;
107
+ (into.folded ??= []).push(from.order, ...(from.folded ?? []));
107
108
  if (from.merges !== null) {
108
109
  for (const transfer of from.merges) transfer(from, into);
109
110
  (into.merges ??= []).push(...from.merges);
@@ -1,5 +1,5 @@
1
1
  import { DEV } from 'esm-env';
2
- import { processed } from './batch.ts';
2
+ import { foreign, processed } from './batch.ts';
3
3
  import {
4
4
  destroyEffects,
5
5
  discardAside,
@@ -317,16 +317,18 @@ export function changed(reads: ReadonlyMap<Source, unknown>, target: Reaction):
317
317
  }
318
318
 
319
319
  export function stale(target: Reaction, recheck = false): boolean {
320
- if (recheck) {
321
- if (target.deps === null) return true;
320
+ if (recheck && target.deps === null) return true;
321
+ if (recheck && ((target.deps as Source[]).length > 0 || (target as Effect).async)) {
322
322
  const effect = target as Effect;
323
- const own = (view?.batch ?? processed())?.reads?.get(effect);
323
+ const batch = view?.batch ?? processed();
324
+ const own = batch?.reads?.get(effect);
324
325
  if (
325
326
  own === undefined &&
326
327
  effect.kind === BLOCK &&
327
328
  (!effect.async || effect.forked) &&
328
329
  effect.batch !== 0 &&
329
- effect.batch !== (view?.batch.order ?? processed()?.order)
330
+ effect.batch !== batch?.order &&
331
+ (batch === null || effect.forked || foreign(effect.batch, batch))
330
332
  )
331
333
  return true;
332
334
  const reads = own ?? observedReads(target);
@@ -0,0 +1,25 @@
1
+ import type { Effect } from './graph.ts';
2
+
3
+ export function link(effect: Effect, parent: Effect): void {
4
+ effect.prev = parent.last;
5
+ if (parent.last === null) parent.first = effect;
6
+ else parent.last.next = effect;
7
+ parent.last = effect;
8
+ }
9
+
10
+ export function unlink(effect: Effect): void {
11
+ const parent = effect.parent;
12
+ if (parent === null) return;
13
+ if (effect.prev === null) parent.first = effect.next;
14
+ else effect.prev.next = effect.next;
15
+ if (effect.next === null) parent.last = effect.prev;
16
+ else effect.next.prev = effect.prev;
17
+ effect.prev = effect.next = null;
18
+ }
19
+
20
+ export function sendLast(effect: Effect): void {
21
+ const parent = effect.parent;
22
+ if (effect.destroyed || parent === null || parent.last === effect) return;
23
+ unlink(effect);
24
+ link(effect, parent);
25
+ }