canvasengine 2.0.0-beta.19 → 2.0.0-beta.20

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/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as _signe_reactive from '@signe/reactive';
2
2
  import { WritableSignal, Signal } from '@signe/reactive';
3
3
  export * from '@signe/reactive';
4
- import { Subscription, Subject, Observable } from 'rxjs';
4
+ import { BehaviorSubject, Subscription, Subject, Observable } from 'rxjs';
5
5
  export { isObservable } from 'rxjs';
6
6
  import * as PIXI from 'pixi.js';
7
- import { FederatedPointerEvent, ObservablePoint, Graphics as Graphics$1, Texture, TextStyle, Application, Matrix } from 'pixi.js';
7
+ import { FederatedPointerEvent, ObservablePoint, Graphics as Graphics$1, Geometry, Shader, Texture, TextStyle, Application, Matrix } from 'pixi.js';
8
8
  import * as howler from 'howler';
9
9
  export { howler as Howl };
10
10
  export { Howler } from 'howler';
@@ -221,10 +221,13 @@ declare function DisplayObject(extendClass: any): {
221
221
  layout: any;
222
222
  onBeforeDestroy: OnHook | null;
223
223
  onAfterMount: OnHook | null;
224
+ subjectInit: BehaviorSubject<any>;
225
+ disableLayout: boolean;
224
226
  readonly deltaRatio: any;
225
- onInit(props: any): void;
227
+ readonly parentIsFlex: any;
228
+ onInit(props: Props): void;
226
229
  onMount({ parent, props }: Element</*elided*/ any>, index?: number): Promise<void>;
227
- onUpdate(props: any): void;
230
+ onUpdate(props: Props): void;
228
231
  onDestroy(parent: Element, afterDestroy?: () => void): Promise<void>;
229
232
  setFlexDirection(direction: FlexDirection): void;
230
233
  setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
@@ -427,7 +430,7 @@ interface ContainerProps extends DisplayObjectProps {
427
430
  declare const Container: ComponentFunction<ContainerProps>;
428
431
 
429
432
  interface GraphicsProps extends DisplayObjectProps {
430
- draw?: (graphics: Graphics$1) => void;
433
+ draw?: (graphics: Graphics$1, width: number, height: number) => void;
431
434
  }
432
435
  interface RectProps extends DisplayObjectProps {
433
436
  color: SignalOrPrimitive<string>;
@@ -444,15 +447,95 @@ interface TriangleProps extends DisplayObjectProps {
444
447
  color: SignalOrPrimitive<string>;
445
448
  }
446
449
  interface SvgProps extends DisplayObjectProps {
447
- svg: string;
450
+ /** SVG content as string (legacy prop) */
451
+ svg?: string;
452
+ /** URL source of the SVG file to load */
453
+ src?: string;
454
+ /** Direct SVG content as string */
455
+ content?: string;
448
456
  }
449
457
  declare function Graphics(props: GraphicsProps): Element<ComponentInstance>;
450
458
  declare function Rect(props: RectProps): Element<ComponentInstance>;
451
459
  declare function Circle(props: CircleProps): Element<ComponentInstance>;
452
460
  declare function Ellipse(props: EllipseProps): Element<ComponentInstance>;
453
461
  declare function Triangle(props: TriangleProps): Element<ComponentInstance>;
462
+ /**
463
+ * Creates an SVG component that can render SVG graphics from URL, content, or legacy svg prop.
464
+ *
465
+ * This component provides three ways to display SVG graphics:
466
+ * - **src**: Load SVG from a URL using Assets.load with parseAsGraphicsContext option
467
+ * - **content**: Render SVG directly from string content using Graphics.svg() method
468
+ * - **svg**: Legacy prop for SVG content (for backward compatibility)
469
+ *
470
+ * @param props - Component properties including src, content, or svg
471
+ * @returns A reactive SVG component
472
+ * @example
473
+ * ```typescript
474
+ * // Load from URL
475
+ * const svgFromUrl = Svg({ src: "/assets/logo.svg" });
476
+ *
477
+ * // Direct content
478
+ * const svgFromContent = Svg({
479
+ * content: `<svg viewBox="0 0 100 100">
480
+ * <circle cx="50" cy="50" r="40" fill="blue"/>
481
+ * </svg>`
482
+ * });
483
+ *
484
+ * // Legacy usage
485
+ * const svgLegacy = Svg({ svg: "<svg>...</svg>" });
486
+ * ```
487
+ */
454
488
  declare function Svg(props: SvgProps): Element<ComponentInstance>;
455
489
 
490
+ /**
491
+ * Interface defining the properties for a Mesh component.
492
+ * Extends DisplayObjectProps to inherit common display object properties.
493
+ */
494
+ interface MeshProps extends DisplayObjectProps {
495
+ /** The geometry defining the mesh structure (vertices, indices, UVs, etc.) */
496
+ geometry?: Geometry;
497
+ /** The shader to render the mesh with */
498
+ shader?: Shader;
499
+ /** The texture to apply to the mesh */
500
+ texture?: Texture | string;
501
+ /** The image URL to load as texture */
502
+ image?: string;
503
+ /** The tint color to apply to the mesh */
504
+ tint?: SignalOrPrimitive<number>;
505
+ /** Whether to round pixels for sharper rendering */
506
+ roundPixels?: SignalOrPrimitive<boolean>;
507
+ }
508
+ /**
509
+ * Creates a Mesh component with the specified properties.
510
+ * This is the main function used to create mesh instances in your application.
511
+ *
512
+ * @param props - The properties for the mesh component
513
+ * @returns A mesh component element
514
+ * @example
515
+ * ```typescript
516
+ * import { Mesh } from 'canvasengine';
517
+ *
518
+ * // Create a basic textured mesh
519
+ * const myMesh = Mesh({
520
+ * geometry: triangleGeometry,
521
+ * texture: "assets/texture.png",
522
+ * x: 100,
523
+ * y: 100,
524
+ * tint: 0xff0000
525
+ * });
526
+ *
527
+ * // Create a mesh with custom shader
528
+ * const shaderMesh = Mesh({
529
+ * geometry: planeGeometry,
530
+ * shader: customShader,
531
+ * draw: (mesh) => {
532
+ * mesh.rotation += 0.01;
533
+ * }
534
+ * });
535
+ * ```
536
+ */
537
+ declare const Mesh: ComponentFunction<MeshProps>;
538
+
456
539
  declare function Scene(props: any): Element<ComponentInstance> | Promise<Element<ComponentInstance>>;
457
540
 
458
541
  declare function ParticlesEmitter(props: any): Element<ComponentInstance>;
@@ -899,6 +982,25 @@ interface NineSliceSpriteProps extends DisplayObjectProps {
899
982
  }
900
983
  declare function NineSliceSprite(props: NineSliceSpriteProps): Element<ComponentInstance>;
901
984
 
985
+ interface DOMContainerProps extends DisplayObjectProps {
986
+ element: string | {
987
+ value: HTMLElement;
988
+ };
989
+ textContent?: string;
990
+ attrs?: Record<string, any> & {
991
+ class?: string | string[] | Record<string, boolean> | {
992
+ items?: string[];
993
+ } | {
994
+ value?: string | string[] | Record<string, boolean>;
995
+ };
996
+ style?: string | Record<string, string | number> | {
997
+ value?: string | Record<string, string | number>;
998
+ };
999
+ };
1000
+ sortableChildren?: boolean;
1001
+ }
1002
+ declare const DOMContainer: ComponentFunction<DOMContainerProps>;
1003
+
902
1004
  interface Listen<T = any> {
903
1005
  config: T | undefined;
904
1006
  seed: {
@@ -1106,9 +1208,16 @@ declare function arrayEquals(a: any[], b: any[]): boolean;
1106
1208
  */
1107
1209
  declare function isFunction(val: unknown): boolean;
1108
1210
  /**
1109
- * Checks if a value is a plain object
1211
+ * Checks if a value is a plain object (not an instance of a class)
1110
1212
  * @param {unknown} val - Value to check
1111
- * @returns {boolean} True if value is an object (not null and not array), false otherwise
1213
+ * @returns {boolean} True if value is a plain object (not null, not array, not instance), false otherwise
1214
+ * @example
1215
+ * ```ts
1216
+ * isObject({}) // true
1217
+ * isObject(new Date()) // false
1218
+ * isObject([]) // false
1219
+ * isObject(null) // false
1220
+ * ```
1112
1221
  */
1113
1222
  declare function isObject(val: unknown): boolean;
1114
1223
  /**
@@ -1173,4 +1282,4 @@ declare namespace utils {
1173
1282
  export { utils_arrayEquals as arrayEquals, utils_calculateDistance as calculateDistance, utils_error as error, utils_fps2ms as fps2ms, utils_get as get, utils_isBrowser as isBrowser, utils_isFunction as isFunction, utils_isObject as isObject, utils_isPromise as isPromise, utils_log as log, utils_preciseNow as preciseNow, utils_set as set, utils_setObservablePoint as setObservablePoint };
1174
1283
  }
1175
1284
 
1176
- export { type AnimateOptions, type AnimatedSignal, type AnimatedState, Canvas, Circle, type ComponentFunction, type ComponentInstance, Container, DisplayObject, EVENTS, Easing, type Element, Ellipse, Graphics, NineSliceSprite, ParticlesEmitter, type Props, RadialGradient, Rect, Scene, Sprite, Text, TilingSprite, Triangle, utils as Utils, Video, Viewport, animatedSequence, animatedSignal, bootstrapCanvas, cond, createComponent, currentSubscriptionsTracker, h, isAnimatedSignal, isElement, isPrimitive, isTrigger, loop, mount, mountTracker, on, registerComponent, Svg as svg, tick, trigger, useDefineProps, useProps };
1285
+ export { type AnimateOptions, type AnimatedSignal, type AnimatedState, Canvas, Circle, type ComponentFunction, type ComponentInstance, Container, DOMContainer, DisplayObject, EVENTS, Easing, type Element, Ellipse, Graphics, Mesh, NineSliceSprite, ParticlesEmitter, type Props, RadialGradient, Rect, Scene, Sprite, Svg, Text, TilingSprite, Triangle, utils as Utils, Video, Viewport, animatedSequence, animatedSignal, bootstrapCanvas, cond, createComponent, currentSubscriptionsTracker, h, isAnimatedSignal, isElement, isPrimitive, isTrigger, loop, mount, mountTracker, on, registerComponent, tick, trigger, useDefineProps, useProps };