canvasengine 2.0.0-beta.37 → 2.0.0-beta.38

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.
@@ -14,6 +14,7 @@ import {
14
14
  bufferTime,
15
15
  filter,
16
16
  throttleTime,
17
+ combineLatest,
17
18
  } from "rxjs";
18
19
  import { ComponentInstance } from "../components/DisplayObject";
19
20
  import { Directive, applyDirective } from "./directive";
@@ -181,8 +182,8 @@ export function createComponent(tag: string, props?: Props): Element {
181
182
  instance.onUpdate?.(
182
183
  path == ""
183
184
  ? {
184
- [key]: value,
185
- }
185
+ [key]: value,
186
+ }
186
187
  : set({}, path + "." + key, value)
187
188
  );
188
189
  })
@@ -217,9 +218,79 @@ export function createComponent(tag: string, props?: Props): Element {
217
218
  }
218
219
  }
219
220
 
220
- function onMount(parent: Element, element: Element, index?: number) {
221
- element.props.context = parent.props.context;
222
- element.parent = parent;
221
+ /**
222
+ * Checks if all dependencies are ready (not undefined).
223
+ * Handles signals synchronously and promises asynchronously.
224
+ * For reactive signals, sets up subscriptions to mount when all become ready.
225
+ *
226
+ * @param deps - Array of signals, promises, or direct values
227
+ * @returns Promise<boolean> - true if all dependencies are ready
228
+ */
229
+ async function checkDependencies(
230
+ deps: any[]
231
+ ): Promise<boolean> {
232
+ const values = await Promise.all(
233
+ deps.map(async (dep) => {
234
+ if (isSignal(dep)) {
235
+ return dep(); // Read current signal value
236
+ } else if (isPromise(dep)) {
237
+ return await dep; // Await promise resolution
238
+ }
239
+ return dep; // Direct value
240
+ })
241
+ );
242
+ return values.every((v) => v !== undefined);
243
+ }
244
+
245
+ /**
246
+ * Sets up subscriptions to reactive signal dependencies.
247
+ * When all signals become defined, mounts the component.
248
+ */
249
+ function setupDependencySubscriptions(
250
+ parent: Element,
251
+ element: Element,
252
+ deps: any[],
253
+ index?: number
254
+ ) {
255
+ const signalDeps = deps.filter((dep) => isSignal(dep));
256
+ const promiseDeps = deps.filter((dep) => isPromise(dep));
257
+
258
+ if (signalDeps.length === 0) {
259
+ // No reactive signals, nothing to subscribe to
260
+ return;
261
+ }
262
+
263
+ // Create observables from signals
264
+ const signalObservables = signalDeps.map((sig) => sig.observable);
265
+
266
+ // Combine all signal observables
267
+ const subscription = combineLatest(signalObservables).subscribe(
268
+ async () => {
269
+ // Check if all dependencies are now ready
270
+ const allReady = await checkDependencies(deps);
271
+ if (allReady) {
272
+ // Unsubscribe - we only need to mount once
273
+ subscription.unsubscribe();
274
+ // Remove from subscriptions
275
+ const idx = element.propSubscriptions.indexOf(subscription);
276
+ if (idx > -1) {
277
+ element.propSubscriptions.splice(idx, 1);
278
+ }
279
+ // Now mount the component
280
+ performMount(parent, element, index);
281
+ propagateContext(element);
282
+ }
283
+ }
284
+ );
285
+
286
+ // Store subscription for cleanup
287
+ element.propSubscriptions.push(subscription);
288
+ }
289
+
290
+ /**
291
+ * Performs the actual mounting of the component.
292
+ */
293
+ function performMount(parent: Element, element: Element, index?: number) {
223
294
  element.componentInstance.onMount?.(element, index);
224
295
  for (let name in element.directives) {
225
296
  element.directives[name].onMount?.(element);
@@ -227,6 +298,24 @@ export function createComponent(tag: string, props?: Props): Element {
227
298
  element.effectMounts.forEach((fn: any) => {
228
299
  element.effectUnmounts.push(fn(element));
229
300
  });
301
+ }
302
+
303
+ async function onMount(parent: Element, element: Element, index?: number) {
304
+ element.props.context = parent.props.context;
305
+ element.parent = parent;
306
+
307
+ // Check dependencies before mounting
308
+ if (element.props.dependencies && Array.isArray(element.props.dependencies)) {
309
+ const deps = element.props.dependencies;
310
+ const ready = await checkDependencies(deps);
311
+ if (!ready) {
312
+ // Set up subscriptions for reactive signals to trigger mount later
313
+ setupDependencySubscriptions(parent, element, deps, index);
314
+ return;
315
+ }
316
+ }
317
+
318
+ performMount(parent, element, index);
230
319
  };
231
320
 
232
321
  async function propagateContext(element) {
@@ -237,19 +326,19 @@ export function createComponent(tag: string, props?: Props): Element {
237
326
  }
238
327
  else {
239
328
  await new Promise((resolve) => {
240
- let lastElement = null
241
- element.propSubscriptions.push(element.propObservables.attach.observable.subscribe(async (args) => {
242
- const value = args?.value ?? args
243
- if (!value) {
244
- throw new Error(`attach in ${element.tag} is undefined or null, add a component`)
245
- }
246
- if (lastElement) {
247
- destroyElement(lastElement)
248
- }
249
- lastElement = value
250
- await createElement(element, value)
251
- resolve(undefined)
252
- }))
329
+ let lastElement = null
330
+ element.propSubscriptions.push(element.propObservables.attach.observable.subscribe(async (args) => {
331
+ const value = args?.value ?? args
332
+ if (!value) {
333
+ throw new Error(`attach in ${element.tag} is undefined or null, add a component`)
334
+ }
335
+ if (lastElement) {
336
+ destroyElement(lastElement)
337
+ }
338
+ lastElement = value
339
+ await createElement(element, value)
340
+ resolve(undefined)
341
+ }))
253
342
  })
254
343
  }
255
344
  }
@@ -262,39 +351,39 @@ export function createComponent(tag: string, props?: Props): Element {
262
351
  }
263
352
  };
264
353
 
265
- /**
266
- * Creates and mounts a child element to a parent element.
267
- * Handles different types of children: Elements, Promises resolving to Elements, and Observables.
268
- *
269
- * @description This function is designed to handle reactive child components that can be:
270
- * - Direct Element instances
271
- * - Promises that resolve to Elements (for async components)
272
- * - Observables that emit Elements, arrays of Elements, or FlowObservable results
273
- * - Nested observables within arrays or FlowObservable results (handled recursively)
274
- *
275
- * For Observables, it subscribes to the stream and automatically mounts/unmounts elements
276
- * as they are emitted. The function handles nested observables recursively, ensuring that
277
- * observables within arrays or FlowObservable results are also properly subscribed to.
278
- * All subscriptions are stored in the parent's effectSubscriptions for automatic cleanup.
279
- *
280
- * @param {Element} parent - The parent element to mount the child to
281
- * @param {Element | Observable<any> | Promise<Element>} child - The child to create and mount
282
- *
283
- * @example
284
- * ```typescript
285
- * // Direct element
286
- * await createElement(parent, childElement);
287
- *
288
- * // Observable of elements (from cond, loop, etc.)
289
- * await createElement(parent, cond(signal(visible), () => h(Container)));
290
- *
291
- * // Observable that emits arrays containing other observables
292
- * await createElement(parent, observableOfObservables);
293
- *
294
- * // Promise resolving to element
295
- * await createElement(parent, import('./MyComponent').then(mod => h(mod.default)));
296
- * ```
297
- */
354
+ /**
355
+ * Creates and mounts a child element to a parent element.
356
+ * Handles different types of children: Elements, Promises resolving to Elements, and Observables.
357
+ *
358
+ * @description This function is designed to handle reactive child components that can be:
359
+ * - Direct Element instances
360
+ * - Promises that resolve to Elements (for async components)
361
+ * - Observables that emit Elements, arrays of Elements, or FlowObservable results
362
+ * - Nested observables within arrays or FlowObservable results (handled recursively)
363
+ *
364
+ * For Observables, it subscribes to the stream and automatically mounts/unmounts elements
365
+ * as they are emitted. The function handles nested observables recursively, ensuring that
366
+ * observables within arrays or FlowObservable results are also properly subscribed to.
367
+ * All subscriptions are stored in the parent's effectSubscriptions for automatic cleanup.
368
+ *
369
+ * @param {Element} parent - The parent element to mount the child to
370
+ * @param {Element | Observable<any> | Promise<Element>} child - The child to create and mount
371
+ *
372
+ * @example
373
+ * ```typescript
374
+ * // Direct element
375
+ * await createElement(parent, childElement);
376
+ *
377
+ * // Observable of elements (from cond, loop, etc.)
378
+ * await createElement(parent, cond(signal(visible), () => h(Container)));
379
+ *
380
+ * // Observable that emits arrays containing other observables
381
+ * await createElement(parent, observableOfObservables);
382
+ *
383
+ * // Promise resolving to element
384
+ * await createElement(parent, import('./MyComponent').then(mod => h(mod.default)));
385
+ * ```
386
+ */
298
387
  async function createElement(parent: Element, child: Element | Observable<any> | Promise<Element>) {
299
388
  if (isPromise(child)) {
300
389
  child = await child;
@@ -313,62 +402,62 @@ export function createComponent(tag: string, props?: Props): Element {
313
402
  elements: Element[];
314
403
  prev?: Element;
315
404
  } = value;
316
-
405
+
317
406
  const components = comp.filter((c) => c !== null);
318
- if (prev) {
319
- components.forEach(async (c) => {
320
- const index = parent.props.children.indexOf(prev.props.key);
321
- if (c instanceof Observable) {
322
- // Handle observable component recursively
323
- await createElement(parent, c);
324
- } else if (isElement(c)) {
325
- onMount(parent, c, index + 1);
326
- propagateContext(c);
327
- }
328
- });
329
- return;
330
- }
331
- components.forEach(async (component) => {
332
- if (!Array.isArray(component)) {
333
- if (component instanceof Observable) {
334
- // Handle observable component recursively
335
- await createElement(parent, component);
336
- } else if (isElement(component)) {
337
- onMount(parent, component);
338
- propagateContext(component);
339
- }
340
- } else {
341
- component.forEach(async (comp) => {
342
- if (comp instanceof Observable) {
343
- // Handle observable component recursively
344
- await createElement(parent, comp);
345
- } else if (isElement(comp)) {
346
- onMount(parent, comp);
347
- propagateContext(comp);
348
- }
349
- });
350
- }
351
- });
407
+ if (prev) {
408
+ components.forEach(async (c) => {
409
+ const index = parent.props.children.indexOf(prev.props.key);
410
+ if (c instanceof Observable) {
411
+ // Handle observable component recursively
412
+ await createElement(parent, c);
413
+ } else if (isElement(c)) {
414
+ onMount(parent, c, index + 1);
415
+ propagateContext(c);
416
+ }
417
+ });
418
+ return;
419
+ }
420
+ components.forEach(async (component) => {
421
+ if (!Array.isArray(component)) {
422
+ if (component instanceof Observable) {
423
+ // Handle observable component recursively
424
+ await createElement(parent, component);
425
+ } else if (isElement(component)) {
426
+ onMount(parent, component);
427
+ propagateContext(component);
428
+ }
429
+ } else {
430
+ component.forEach(async (comp) => {
431
+ if (comp instanceof Observable) {
432
+ // Handle observable component recursively
433
+ await createElement(parent, comp);
434
+ } else if (isElement(comp)) {
435
+ onMount(parent, comp);
436
+ propagateContext(comp);
437
+ }
438
+ });
439
+ }
440
+ });
352
441
  } else if (isElement(value)) {
353
442
  // Handle direct Element emission
354
443
  onMount(parent, value);
355
444
  propagateContext(value);
356
- } else if (Array.isArray(value)) {
357
- // Handle array of elements (which can also be observables)
358
- value.forEach(async (element) => {
359
- if (element instanceof Observable) {
360
- // Handle observable element recursively
361
- await createElement(parent, element);
362
- } else if (isElement(element)) {
363
- onMount(parent, element);
364
- propagateContext(element);
365
- }
366
- });
367
- }
445
+ } else if (Array.isArray(value)) {
446
+ // Handle array of elements (which can also be observables)
447
+ value.forEach(async (element) => {
448
+ if (element instanceof Observable) {
449
+ // Handle observable element recursively
450
+ await createElement(parent, element);
451
+ } else if (isElement(element)) {
452
+ onMount(parent, element);
453
+ propagateContext(element);
454
+ }
455
+ });
456
+ }
368
457
  elementsListen.next(undefined);
369
458
  }
370
459
  );
371
-
460
+
372
461
  // Store subscription for cleanup
373
462
  parent.effectSubscriptions.push(subscription);
374
463
  } else if (isElement(child)) {
@@ -405,170 +494,174 @@ export function loop<T>(
405
494
  let elementMap = new Map<string | number, Element>();
406
495
  let isFirstSubscription = true;
407
496
 
408
- const isArraySignal = (signal: any): signal is WritableArraySignal<T[]> =>
497
+ const isArraySignal = (signal: any): signal is WritableArraySignal<T[]> =>
409
498
  Array.isArray(signal());
410
499
 
411
500
  return new Observable<FlowResult>(subscriber => {
412
501
  const subscription = isArraySignal(itemsSubject)
413
502
  ? itemsSubject.observable.subscribe(change => {
414
- if (isFirstSubscription) {
415
- isFirstSubscription = false;
416
- elements.forEach(el => el.destroy());
417
- elements = [];
418
- elementMap.clear();
419
-
420
- const items = itemsSubject();
421
- if (items) {
422
- items.forEach((item, index) => {
423
- const element = createElementFn(item, index);
424
- if (element) {
425
- elements.push(element);
426
- elementMap.set(index, element);
427
- }
428
- });
429
- }
430
- subscriber.next({
431
- elements: [...elements]
503
+ if (isFirstSubscription) {
504
+ isFirstSubscription = false;
505
+ elements.forEach(el => el.destroy());
506
+ elements = [];
507
+ elementMap.clear();
508
+
509
+ const items = itemsSubject();
510
+ if (items) {
511
+ items.forEach((item, index) => {
512
+ const element = createElementFn(item, index);
513
+ if (element) {
514
+ elements.push(element);
515
+ elementMap.set(index, element);
516
+ }
432
517
  });
433
- return;
434
518
  }
519
+ subscriber.next({
520
+ elements: [...elements]
521
+ });
522
+ return;
523
+ }
435
524
 
436
- if (change.type === 'init' || change.type === 'reset') {
437
- elements.forEach(el => destroyElement(el));
438
- elements = [];
439
- elementMap.clear();
440
-
441
- const items = itemsSubject();
442
- if (items) {
443
- items.forEach((item, index) => {
444
- const element = createElementFn(item, index);
445
- if (element) {
446
- elements.push(element);
447
- elementMap.set(index, element);
448
- }
449
- });
450
- }
451
- } else if (change.type === 'add' && change.index !== undefined) {
452
- const newElements = change.items.map((item, i) => {
453
- const element = createElementFn(item as T, change.index! + i);
525
+ // Handle computed signals that emit array values directly (not ArrayChange objects)
526
+ // When a computed emits, `change` is the array itself, not an object with `type`
527
+ const isDirectArrayChange = Array.isArray(change) || (change && typeof change === 'object' && !('type' in change));
528
+
529
+ if (change.type === 'init' || change.type === 'reset' || isDirectArrayChange) {
530
+ elements.forEach(el => destroyElement(el));
531
+ elements = [];
532
+ elementMap.clear();
533
+
534
+ const items = itemsSubject();
535
+ if (items) {
536
+ items.forEach((item, index) => {
537
+ const element = createElementFn(item, index);
454
538
  if (element) {
455
- elementMap.set(change.index! + i, element);
539
+ elements.push(element);
540
+ elementMap.set(index, element);
456
541
  }
457
- return element;
458
- }).filter((el): el is Element => el !== null);
459
-
460
- elements.splice(change.index, 0, ...newElements);
461
- } else if (change.type === 'remove' && change.index !== undefined) {
462
- const removed = elements.splice(change.index, 1);
463
- removed.forEach(el => {
464
- destroyElement(el)
465
- elementMap.delete(change.index!);
466
542
  });
467
- } else if (change.type === 'update' && change.index !== undefined && change.items.length === 1) {
468
- const index = change.index;
469
- const newItem = change.items[0];
470
-
471
- // Check if the previous item at this index was effectively undefined or non-existent
472
- if (index >= elements.length || elements[index] === undefined || !elementMap.has(index)) {
473
- // Treat as add operation
474
- const newElement = createElementFn(newItem as T, index);
475
- if (newElement) {
476
- elements.splice(index, 0, newElement); // Insert at the correct index
477
- elementMap.set(index, newElement);
478
- // Adjust indices in elementMap for subsequent elements might be needed if map relied on exact indices
479
- // This simple implementation assumes keys are stable or createElementFn handles context correctly
480
- } else {
481
- console.warn(`Element creation returned null for index ${index} during add-like update.`);
482
- }
543
+ }
544
+ } else if (change.type === 'add' && change.index !== undefined) {
545
+ const newElements = change.items.map((item, i) => {
546
+ const element = createElementFn(item as T, change.index! + i);
547
+ if (element) {
548
+ elementMap.set(change.index! + i, element);
549
+ }
550
+ return element;
551
+ }).filter((el): el is Element => el !== null);
552
+
553
+ elements.splice(change.index, 0, ...newElements);
554
+ } else if (change.type === 'remove' && change.index !== undefined) {
555
+ const removed = elements.splice(change.index, 1);
556
+ removed.forEach(el => {
557
+ destroyElement(el)
558
+ elementMap.delete(change.index!);
559
+ });
560
+ } else if (change.type === 'update' && change.index !== undefined && change.items.length === 1) {
561
+ const index = change.index;
562
+ const newItem = change.items[0];
563
+
564
+ // Check if the previous item at this index was effectively undefined or non-existent
565
+ if (index >= elements.length || elements[index] === undefined || !elementMap.has(index)) {
566
+ // Treat as add operation
567
+ const newElement = createElementFn(newItem as T, index);
568
+ if (newElement) {
569
+ elements.splice(index, 0, newElement); // Insert at the correct index
570
+ elementMap.set(index, newElement);
571
+ // Adjust indices in elementMap for subsequent elements might be needed if map relied on exact indices
572
+ // This simple implementation assumes keys are stable or createElementFn handles context correctly
483
573
  } else {
484
- // Treat as a standard update operation
485
- const oldElement = elements[index];
486
- destroyElement(oldElement)
487
- const newElement = createElementFn(newItem as T, index);
488
- if (newElement) {
489
- elements[index] = newElement;
490
- elementMap.set(index, newElement);
491
- } else {
492
- // Handle case where new element creation returns null
493
- elements.splice(index, 1);
494
- elementMap.delete(index);
495
- }
574
+ console.warn(`Element creation returned null for index ${index} during add-like update.`);
575
+ }
576
+ } else {
577
+ // Treat as a standard update operation
578
+ const oldElement = elements[index];
579
+ destroyElement(oldElement)
580
+ const newElement = createElementFn(newItem as T, index);
581
+ if (newElement) {
582
+ elements[index] = newElement;
583
+ elementMap.set(index, newElement);
584
+ } else {
585
+ // Handle case where new element creation returns null
586
+ elements.splice(index, 1);
587
+ elementMap.delete(index);
496
588
  }
497
589
  }
590
+ }
498
591
 
499
- subscriber.next({
500
- elements: [...elements] // Create a new array to ensure change detection
501
- });
502
- })
592
+ subscriber.next({
593
+ elements: [...elements] // Create a new array to ensure change detection
594
+ });
595
+ })
503
596
  : (itemsSubject as WritableObjectSignal<T>).observable.subscribe(change => {
504
- const key = change.key as string | number
505
- if (isFirstSubscription) {
506
- isFirstSubscription = false;
507
- elements.forEach(el => destroyElement(el));
508
- elements = [];
509
- elementMap.clear();
510
-
511
- const items = (itemsSubject as WritableObjectSignal<T>)();
512
- if (items) {
513
- Object.entries(items).forEach(([key, value]) => {
514
- const element = createElementFn(value, key);
515
- if (element) {
516
- elements.push(element);
517
- elementMap.set(key, element);
518
- }
519
- });
520
- }
521
- subscriber.next({
522
- elements: [...elements]
597
+ const key = change.key as string | number
598
+ if (isFirstSubscription) {
599
+ isFirstSubscription = false;
600
+ elements.forEach(el => destroyElement(el));
601
+ elements = [];
602
+ elementMap.clear();
603
+
604
+ const items = (itemsSubject as WritableObjectSignal<T>)();
605
+ if (items) {
606
+ Object.entries(items).forEach(([key, value]) => {
607
+ const element = createElementFn(value, key);
608
+ if (element) {
609
+ elements.push(element);
610
+ elementMap.set(key, element);
611
+ }
523
612
  });
524
- return;
525
613
  }
614
+ subscriber.next({
615
+ elements: [...elements]
616
+ });
617
+ return;
618
+ }
526
619
 
527
- if (change.type === 'init' || change.type === 'reset') {
528
- elements.forEach(el => destroyElement(el));
529
- elements = [];
530
- elementMap.clear();
531
-
532
- const items = (itemsSubject as WritableObjectSignal<T>)();
533
- if (items) {
534
- Object.entries(items).forEach(([key, value]) => {
535
- const element = createElementFn(value, key);
536
- if (element) {
537
- elements.push(element);
538
- elementMap.set(key, element);
539
- }
540
- });
541
- }
542
- } else if (change.type === 'add' && change.key && change.value !== undefined) {
543
- const element = createElementFn(change.value as T, key);
544
- if (element) {
545
- elements.push(element);
546
- elementMap.set(key, element);
547
- }
548
- } else if (change.type === 'remove' && change.key) {
549
- const index = elements.findIndex(el => elementMap.get(key) === el);
550
- if (index !== -1) {
551
- const [removed] = elements.splice(index, 1);
552
- destroyElement(removed)
553
- elementMap.delete(key);
554
- }
555
- } else if (change.type === 'update' && change.key && change.value !== undefined) {
556
- const index = elements.findIndex(el => elementMap.get(key) === el);
557
- if (index !== -1) {
558
- const oldElement = elements[index];
559
- destroyElement(oldElement)
560
- const newElement = createElementFn(change.value as T, key);
561
- if (newElement) {
562
- elements[index] = newElement;
563
- elementMap.set(key, newElement);
620
+ if (change.type === 'init' || change.type === 'reset') {
621
+ elements.forEach(el => destroyElement(el));
622
+ elements = [];
623
+ elementMap.clear();
624
+
625
+ const items = (itemsSubject as WritableObjectSignal<T>)();
626
+ if (items) {
627
+ Object.entries(items).forEach(([key, value]) => {
628
+ const element = createElementFn(value, key);
629
+ if (element) {
630
+ elements.push(element);
631
+ elementMap.set(key, element);
564
632
  }
633
+ });
634
+ }
635
+ } else if (change.type === 'add' && change.key && change.value !== undefined) {
636
+ const element = createElementFn(change.value as T, key);
637
+ if (element) {
638
+ elements.push(element);
639
+ elementMap.set(key, element);
640
+ }
641
+ } else if (change.type === 'remove' && change.key) {
642
+ const index = elements.findIndex(el => elementMap.get(key) === el);
643
+ if (index !== -1) {
644
+ const [removed] = elements.splice(index, 1);
645
+ destroyElement(removed)
646
+ elementMap.delete(key);
647
+ }
648
+ } else if (change.type === 'update' && change.key && change.value !== undefined) {
649
+ const index = elements.findIndex(el => elementMap.get(key) === el);
650
+ if (index !== -1) {
651
+ const oldElement = elements[index];
652
+ destroyElement(oldElement)
653
+ const newElement = createElementFn(change.value as T, key);
654
+ if (newElement) {
655
+ elements[index] = newElement;
656
+ elementMap.set(key, newElement);
565
657
  }
566
658
  }
659
+ }
567
660
 
568
- subscriber.next({
569
- elements: [...elements] // Create a new array to ensure change detection
570
- });
661
+ subscriber.next({
662
+ elements: [...elements] // Create a new array to ensure change detection
571
663
  });
664
+ });
572
665
 
573
666
  return subscription;
574
667
  });
@@ -660,7 +753,7 @@ export function cond(
660
753
  ];
661
754
 
662
755
  // All conditions are now signals, so we always use the reactive path
663
- return new Observable<{elements: Element[], type?: "init" | "remove"}>(subscriber => {
756
+ return new Observable<{ elements: Element[], type?: "init" | "remove" }>(subscriber => {
664
757
  const subscriptions: Subscription[] = [];
665
758
 
666
759
  const evaluateConditions = () => {
@@ -669,7 +762,7 @@ export function cond(
669
762
  for (let i = 0; i < allConditions.length; i++) {
670
763
  const condition = allConditions[i].condition;
671
764
  const conditionValue = condition();
672
-
765
+
673
766
  if (conditionValue) {
674
767
  matchingIndex = i;
675
768
  break;