@cesdk/engine 1.62.0-rc.1 → 1.63.0-nightly.20251014

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/index.d.ts CHANGED
@@ -5517,6 +5517,32 @@ export declare type Color = RGBAColor | CMYKColor | SpotColor;
5517
5517
  */
5518
5518
  export declare type ColorSpace = 'sRGB' | 'CMYK' | 'SpotColor';
5519
5519
 
5520
+ /**
5521
+ * Combines multiple reactive properties into a single reactive property.
5522
+ *
5523
+ * Similar to `combineLatest` from RxJS but simpler. Emits whenever any source emits.
5524
+ *
5525
+ * @example
5526
+ * ```typescript
5527
+ * const x = createReactiveProperty(0);
5528
+ * const y = createReactiveProperty(0);
5529
+ *
5530
+ * const position = combineProperties([x, y]);
5531
+ *
5532
+ * position.subscribe(([xVal, yVal]) => {
5533
+ * console.log(`Position: (${xVal}, ${yVal})`);
5534
+ * });
5535
+ * ```
5536
+ *
5537
+ * @param properties - Array of reactive properties to combine
5538
+ * @param options - Configuration options
5539
+ * @returns A reactive property containing an array of values
5540
+ * @public
5541
+ */
5542
+ export declare function _combineProperties<T extends any[]>(properties: {
5543
+ [K in keyof T]: _ReadonlyReactiveProperty<T[K]>;
5544
+ }, options?: Pick<_ReactivePropertyOptions<T>, 'equals'>): _ReadonlyReactiveProperty<T>;
5545
+
5520
5546
  /**
5521
5547
  * Asset results that are returned from the engine.
5522
5548
  *
@@ -5600,6 +5626,69 @@ export declare interface Configuration {
5600
5626
  */
5601
5627
  export declare type ContentFillMode = 'Crop' | 'Cover' | 'Contain';
5602
5628
 
5629
+ /**
5630
+ * Creates a derived reactive property from one or more sources.
5631
+ *
5632
+ * The value is computed from source values using a derivation function.
5633
+ * Updates are memoized (only emit when derived value changes).
5634
+ *
5635
+ * @example
5636
+ * ```typescript
5637
+ * const width = createReactiveProperty(800);
5638
+ * const height = createReactiveProperty(600);
5639
+ *
5640
+ * const area = createDerivedProperty(
5641
+ * [width, height],
5642
+ * (w, h) => w * h
5643
+ * );
5644
+ *
5645
+ * area.subscribe((value) => console.log('Area:', value));
5646
+ * width.update(1000); // Logs: "Area: 600000"
5647
+ * ```
5648
+ *
5649
+ * @param sources - Array of reactive properties or sources to track
5650
+ * @param derive - Function that computes the derived value from source values
5651
+ * @param options - Configuration options
5652
+ * @returns A read-only reactive property
5653
+ * @public
5654
+ */
5655
+ export declare function _createDerivedProperty<T, S extends any[]>(sources: {
5656
+ [K in keyof S]: _ReadonlyReactiveProperty<S[K]> | _Source<S[K]>;
5657
+ }, derive: (...values: S) => T, options?: Pick<_ReactivePropertyOptions<T>, 'equals'>): _ReadonlyReactiveProperty<T>;
5658
+
5659
+ /**
5660
+ * Creates a reactive property with subscribe, value, and update methods.
5661
+ *
5662
+ * This is the main utility for managing state with change notifications.
5663
+ * Values are memoized by default (only emit when value changes).
5664
+ *
5665
+ * @example
5666
+ * ```typescript
5667
+ * // Simple value
5668
+ * const zoom = createReactiveProperty(1.0);
5669
+ * zoom.subscribe((value) => console.log('Zoom:', value));
5670
+ * zoom.update(2.0); // Logs: "Zoom: 2.0"
5671
+ *
5672
+ * // With custom equality for objects
5673
+ * const settings = createReactiveProperty(
5674
+ * { width: 800, height: 600 },
5675
+ * { equals: isEqual }
5676
+ * );
5677
+ *
5678
+ * // With initial value emission
5679
+ * const formats = createReactiveProperty(
5680
+ * defaultFormats,
5681
+ * { emitOnSubscribe: true }
5682
+ * );
5683
+ * ```
5684
+ *
5685
+ * @param initialValue - The initial value of the property
5686
+ * @param options - Configuration options
5687
+ * @returns A reactive property with subscribe, value, and update methods
5688
+ * @public
5689
+ */
5690
+ export declare function _createReactiveProperty<T>(initialValue: T, options?: _ReactivePropertyOptions<T>): _ReactiveProperty<T>;
5691
+
5603
5692
  /**
5604
5693
  * Options for creating a video scene.
5605
5694
  * @public
@@ -5617,6 +5706,44 @@ export declare type CreateSceneOptions = {
5617
5706
  };
5618
5707
  };
5619
5708
 
5709
+ /**
5710
+ * Creates a reactive property that tracks a source and updates based on a getter/setter.
5711
+ *
5712
+ * This is useful for wrapping engine properties or complex state logic.
5713
+ *
5714
+ * @example
5715
+ * ```typescript
5716
+ * const settings = createTrackedProperty(
5717
+ * // Getter
5718
+ * () => {
5719
+ * const camera = engine.block.findByType('camera')[0];
5720
+ * return {
5721
+ * width: engine.block.getFloat(camera, 'camera/resolution/width'),
5722
+ * height: engine.block.getFloat(camera, 'camera/resolution/height')
5723
+ * };
5724
+ * },
5725
+ * // Setter
5726
+ * ({ width, height }) => {
5727
+ * const camera = engine.block.findByType('camera')[0];
5728
+ * engine.block.setFloat(camera, 'camera/resolution/width', width);
5729
+ * engine.block.setFloat(camera, 'camera/resolution/height', height);
5730
+ * },
5731
+ * // Source to track
5732
+ * onCameraUpdated,
5733
+ * // Options
5734
+ * { equals: isEqual }
5735
+ * );
5736
+ * ```
5737
+ *
5738
+ * @param getter - Function to get current value
5739
+ * @param setter - Function to update value
5740
+ * @param source - Source to track for updates
5741
+ * @param options - Configuration options
5742
+ * @returns A reactive property
5743
+ * @public
5744
+ */
5745
+ export declare function _createTrackedProperty<T, U = any>(getter: () => T, setter: (value: T) => void, source: (listener: _Listener<U>) => _Unsubscribe, options?: Pick<_ReactivePropertyOptions<T>, 'equals'>): _ReactiveProperty<T>;
5746
+
5620
5747
  /**
5621
5748
  * The CreativeEngine is the core processing unit of CE.SDK and handles state management, rendering, input handling, and much more.
5622
5749
  * It provides APIs to directly interact with assets, blocks, scenes, and variables. These APIs can be used in a headless environment
@@ -6831,6 +6958,12 @@ export declare type EnginePluginContext = {
6831
6958
  engine: CreativeEngine;
6832
6959
  };
6833
6960
 
6961
+ /**
6962
+ * A function that compares two values for equality
6963
+ * @public
6964
+ */
6965
+ export declare type _EqualsFn<T> = (a: T, b: T | undefined) => boolean;
6966
+
6834
6967
  /**
6835
6968
  * @public Subscribe to block lifecycle events in the design engine.
6836
6969
  *
@@ -7192,6 +7325,28 @@ export declare function isRGBAColor(color: Color): color is RGBAColor;
7192
7325
  */
7193
7326
  export declare function isSpotColor(color: Color): color is SpotColor;
7194
7327
 
7328
+ /**
7329
+ * A simplified source type for legacy API streams
7330
+ * @public
7331
+ */
7332
+ export declare type _LegacySource<T> = (handler: (value: T) => void) => () => void;
7333
+
7334
+ /**
7335
+ * Lightweight reactive state utilities for managing subscriptions and state updates.
7336
+ *
7337
+ * This module provides a set of composable utilities for creating reactive properties
7338
+ * without the overhead of a full reactive framework. It's designed to replace the
7339
+ * previous Channel abstraction with simpler, more focused primitives.
7340
+ *
7341
+ * @module reactiveState
7342
+ * @public
7343
+ */
7344
+ /**
7345
+ * A listener function that receives value updates
7346
+ * @public
7347
+ */
7348
+ export declare type _Listener<T> = (value: T) => void;
7349
+
7195
7350
  /**
7196
7351
  * e.g. `en`, `de`, etc.
7197
7352
  * @public
@@ -7247,6 +7402,58 @@ export declare const LogLevel: {
7247
7402
  readonly Error: "Error";
7248
7403
  };
7249
7404
 
7405
+ /**
7406
+ * Creates a simple event source that can emit values to subscribed listeners.
7407
+ *
7408
+ * This is the most basic building block - a pub/sub pattern without state management.
7409
+ *
7410
+ * @example
7411
+ * ```typescript
7412
+ * const onResize = makeSource<{ width: number; height: number }>();
7413
+ *
7414
+ * // Subscribe
7415
+ * const unsubscribe = onResize((size) => {
7416
+ * console.log('New size:', size);
7417
+ * });
7418
+ *
7419
+ * // Emit
7420
+ * onResize.emit({ width: 800, height: 600 });
7421
+ *
7422
+ * // Cleanup
7423
+ * unsubscribe();
7424
+ * ```
7425
+ *
7426
+ * @returns A source function with an emit method
7427
+ * @public
7428
+ */
7429
+ export declare function _makeSource<T>(): _Source<T>;
7430
+
7431
+ /**
7432
+ * Merges multiple event sources into a single source that emits when any source emits.
7433
+ *
7434
+ * This is useful for tracking properties that depend on multiple independent events.
7435
+ *
7436
+ * @example
7437
+ * ```typescript
7438
+ * const zoomChanged = engine.scene.onZoomLevelChanged;
7439
+ * const dpiChanged = engine.scene.onDpiChanged;
7440
+ *
7441
+ * const zoomOrDpiChanged = mergeSources(zoomChanged, dpiChanged);
7442
+ *
7443
+ * // Now use with createTrackedProperty
7444
+ * const normalizedZoom = createTrackedProperty(
7445
+ * () => engine.scene.getZoomLevel() / getDpi(),
7446
+ * (value) => engine.scene.setZoomLevel(value * getDpi()),
7447
+ * zoomOrDpiChanged
7448
+ * );
7449
+ * ```
7450
+ *
7451
+ * @param sources - Event source functions to merge
7452
+ * @returns A merged source that emits when any source emits
7453
+ * @public
7454
+ */
7455
+ export declare function _mergeSources(...sources: Array<(listener: _Listener<any>) => _Unsubscribe>): (listener: _Listener<void>) => _Unsubscribe;
7456
+
7250
7457
  /**
7251
7458
  * Represents the MIME types used in the editor.
7252
7459
  *
@@ -7429,6 +7636,46 @@ export declare interface Reaction {
7429
7636
  dispose(): void;
7430
7637
  }
7431
7638
 
7639
+ /**
7640
+ * A reactive property with subscribe, value, and update methods
7641
+ * @public
7642
+ */
7643
+ export declare interface _ReactiveProperty<T> {
7644
+ /**
7645
+ * Subscribe to value changes
7646
+ * @param listener - Function to call when value changes
7647
+ * @returns Unsubscribe function
7648
+ */
7649
+ subscribe: (listener: _Listener<T>) => _Unsubscribe;
7650
+ /**
7651
+ * Get current value
7652
+ */
7653
+ value: () => T;
7654
+ /**
7655
+ * Update the value (will notify listeners if changed)
7656
+ */
7657
+ update: (newValue: T) => void;
7658
+ }
7659
+
7660
+ /**
7661
+ * Options for creating a reactive property
7662
+ * @public
7663
+ */
7664
+ export declare interface _ReactivePropertyOptions<T> {
7665
+ /**
7666
+ * Equality comparison function (default: strict equality)
7667
+ */
7668
+ equals?: _EqualsFn<T>;
7669
+ /**
7670
+ * If true, emit the initial value to new subscribers
7671
+ */
7672
+ emitOnSubscribe?: boolean;
7673
+ /**
7674
+ * Optional source to track (will subscribe and forward updates)
7675
+ */
7676
+ trackSource?: (listener: _Listener<any>) => _Unsubscribe;
7677
+ }
7678
+
7432
7679
  /**
7433
7680
  * The reactor coordinates the update of registered _Reactions_.
7434
7681
  *
@@ -7468,6 +7715,23 @@ export declare interface Reactor {
7468
7715
  nextReaction: Promise<void>;
7469
7716
  }
7470
7717
 
7718
+ /**
7719
+ * A read-only reactive property with subscribe and value methods
7720
+ * @public
7721
+ */
7722
+ export declare interface _ReadonlyReactiveProperty<T> {
7723
+ /**
7724
+ * Subscribe to value changes
7725
+ * @param listener - Function to call when value changes
7726
+ * @returns Unsubscribe function
7727
+ */
7728
+ subscribe: (listener: _Listener<T>) => _Unsubscribe;
7729
+ /**
7730
+ * Get current value
7731
+ */
7732
+ value: () => T;
7733
+ }
7734
+
7471
7735
  /**
7472
7736
  * Dispatched on the engine canvas right before the engine will refocus its text
7473
7737
  * input after a blur. Call `preventDefault()` to prevent the refocusing.
@@ -8453,6 +8717,15 @@ export declare interface Source {
8453
8717
  height: number;
8454
8718
  }
8455
8719
 
8720
+ /**
8721
+ * A source that can emit values to subscribed listeners
8722
+ * @public
8723
+ */
8724
+ export declare interface _Source<T> {
8725
+ (listener: _Listener<T>): _Unsubscribe;
8726
+ emit: (value: T) => void;
8727
+ }
8728
+
8456
8729
  /**
8457
8730
  * Options for configuring block split operations.
8458
8731
  * @public
@@ -8731,6 +9004,12 @@ export declare interface _UBQSplitOptions {
8731
9004
  selectNewBlock: boolean;
8732
9005
  }
8733
9006
 
9007
+ /**
9008
+ * An unsubscribe function that removes a listener
9009
+ * @public
9010
+ */
9011
+ export declare type _Unsubscribe = () => void;
9012
+
8734
9013
  /**
8735
9014
  * @public Manage text variables within design templates.
8736
9015
  *