@zcomponent/core 1.29.0 → 2.0.0-alpha.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 (168) hide show
  1. package/README.md +1 -0
  2. package/css/zcomponent.css +121 -122
  3. package/index.js +0 -3
  4. package/lib/actionbehavior.d.ts +3 -3
  5. package/lib/actionbehavior.js +20 -19
  6. package/lib/animation/animation.d.ts +13 -6
  7. package/lib/animation/animation.js +56 -43
  8. package/lib/animation/bezier.d.ts +6 -0
  9. package/lib/animation/bezier.js +8 -2
  10. package/lib/animation/clips/clip.d.ts +13 -1
  11. package/lib/animation/clips/clip.js +34 -14
  12. package/lib/animation/index.d.ts +4 -4
  13. package/lib/animation/index.js +4 -4
  14. package/lib/animation/layer.d.ts +9 -0
  15. package/lib/animation/layer.js +28 -12
  16. package/lib/animation/layerclip.d.ts +21 -0
  17. package/lib/animation/layerclip.js +82 -45
  18. package/lib/animation/tracks/cliptrack.d.ts +18 -0
  19. package/lib/animation/tracks/cliptrack.js +27 -6
  20. package/lib/animation/tracks/functiontrack.d.ts +9 -0
  21. package/lib/animation/tracks/functiontrack.js +16 -3
  22. package/lib/animation/tracks/propertytrack.d.ts +20 -1
  23. package/lib/animation/tracks/propertytrack.js +48 -11
  24. package/lib/animation/tracks/streamtrack.d.ts +18 -0
  25. package/lib/animation/tracks/streamtrack.js +32 -6
  26. package/lib/animation/tracks/track.d.ts +8 -2
  27. package/lib/animation/tracks/track.js +3 -2
  28. package/lib/behavior.js +13 -10
  29. package/lib/behaviors/ActivateState.d.ts +22 -24
  30. package/lib/behaviors/ActivateState.js +145 -35
  31. package/lib/behaviors/CallFunction.d.ts +2 -4
  32. package/lib/behaviors/CallFunction.js +69 -11
  33. package/lib/behaviors/ChangeRootScene.d.ts +35 -0
  34. package/lib/behaviors/ChangeRootScene.js +123 -0
  35. package/lib/behaviors/ConsoleLog.d.ts +6 -5
  36. package/lib/behaviors/ConsoleLog.js +95 -12
  37. package/lib/behaviors/DownloadSnapshot.d.ts +7 -12
  38. package/lib/behaviors/DownloadSnapshot.js +70 -19
  39. package/lib/behaviors/EmitComponentPropEvent.d.ts +1 -3
  40. package/lib/behaviors/EmitComponentPropEvent.js +80 -12
  41. package/lib/behaviors/LaunchURL.d.ts +5 -5
  42. package/lib/behaviors/LaunchURL.js +92 -10
  43. package/lib/behaviors/LogAnalyticsEvent.d.ts +10 -4
  44. package/lib/behaviors/LogAnalyticsEvent.js +88 -7
  45. package/lib/behaviors/PauseLayerClip.d.ts +7 -9
  46. package/lib/behaviors/PauseLayerClip.js +89 -21
  47. package/lib/behaviors/PlayLayerClip.d.ts +35 -32
  48. package/lib/behaviors/PlayLayerClip.js +202 -48
  49. package/lib/behaviors/PlaySound.d.ts +19 -25
  50. package/lib/behaviors/PlaySound.js +122 -28
  51. package/lib/behaviors/SetLayerOff.d.ts +7 -9
  52. package/lib/behaviors/SetLayerOff.js +88 -21
  53. package/lib/behaviors/ShareSnapshot.d.ts +5 -9
  54. package/lib/behaviors/ShareSnapshot.js +70 -17
  55. package/lib/behaviors/ShowTextAlert.d.ts +16 -29
  56. package/lib/behaviors/ShowTextAlert.js +116 -48
  57. package/lib/behaviors/TakeSnapshot.d.ts +22 -26
  58. package/lib/behaviors/TakeSnapshot.js +131 -56
  59. package/lib/behaviors/ToggleLayerClips.d.ts +45 -62
  60. package/lib/behaviors/ToggleLayerClips.js +233 -64
  61. package/lib/behaviors/stream/PauseStream.d.ts +5 -16
  62. package/lib/behaviors/stream/PauseStream.js +94 -34
  63. package/lib/behaviors/stream/PlayStream.d.ts +14 -27
  64. package/lib/behaviors/stream/PlayStream.js +123 -34
  65. package/lib/behaviors/stream/SeekStream.d.ts +8 -18
  66. package/lib/behaviors/stream/SeekStream.js +97 -31
  67. package/lib/behaviors/stream/StopStream.d.ts +6 -15
  68. package/lib/behaviors/stream/StopStream.js +89 -27
  69. package/lib/component.d.ts +36 -13
  70. package/lib/component.js +237 -151
  71. package/lib/components/AnimatedLoader.d.ts +51 -0
  72. package/lib/components/AnimatedLoader.js +159 -0
  73. package/lib/components/Audio.d.ts +35 -37
  74. package/lib/components/Audio.js +264 -151
  75. package/lib/components/AudioLayerSettings.d.ts +13 -11
  76. package/lib/components/AudioLayerSettings.js +76 -18
  77. package/lib/components/Children.d.ts +2 -1
  78. package/lib/components/Children.js +66 -13
  79. package/lib/components/ConditionalConstruct.d.ts +44 -0
  80. package/lib/components/ConditionalConstruct.js +142 -0
  81. package/lib/components/DefaultCookieConsent.d.ts +53 -73
  82. package/lib/components/DefaultCookieConsent.js +382 -264
  83. package/lib/components/DefaultLoader.d.ts +40 -28
  84. package/lib/components/DefaultLoader.js +198 -46
  85. package/lib/components/Gamepad.d.ts +5 -26
  86. package/lib/components/Gamepad.js +201 -65
  87. package/lib/components/LoaderScope.d.ts +15 -0
  88. package/lib/components/LoaderScope.js +71 -0
  89. package/lib/components/LongLoad.d.ts +11 -15
  90. package/lib/components/LongLoad.js +89 -34
  91. package/lib/components/SnapshotUI.d.ts +19 -24
  92. package/lib/components/SnapshotUI.js +202 -105
  93. package/lib/context.d.ts +23 -5
  94. package/lib/context.js +12 -6
  95. package/lib/contexts/analyticscontext.d.ts +12 -2
  96. package/lib/contexts/analyticscontext.js +68 -10
  97. package/lib/contexts/audiocontextcontext.d.ts +1 -1
  98. package/lib/contexts/audiocontextcontext.js +9 -8
  99. package/lib/contexts/canvascontext.d.ts +32 -18
  100. package/lib/contexts/canvascontext.js +195 -120
  101. package/lib/contexts/cookieconsentcontext.d.ts +38 -28
  102. package/lib/contexts/cookieconsentcontext.js +35 -32
  103. package/lib/contexts/documentflagmanager.js +15 -11
  104. package/lib/contexts/environmentcontext.d.ts +22 -6
  105. package/lib/contexts/environmentcontext.js +135 -21
  106. package/lib/contexts/gamepadcontext.d.ts +29 -26
  107. package/lib/contexts/gamepadcontext.js +46 -46
  108. package/lib/contexts/gesturecontext.d.ts +31 -6
  109. package/lib/contexts/gesturecontext.js +110 -85
  110. package/lib/contexts/globaltagcontext.d.ts +1 -1
  111. package/lib/contexts/globaltagcontext.js +8 -11
  112. package/lib/contexts/loadcontext.d.ts +45 -8
  113. package/lib/contexts/loadcontext.js +232 -82
  114. package/lib/contexts/orientationcontext.d.ts +13 -15
  115. package/lib/contexts/orientationcontext.js +150 -67
  116. package/lib/contexts/rootcomponentscontext.d.ts +16 -0
  117. package/lib/contexts/rootcomponentscontext.js +65 -0
  118. package/lib/contexts/snapshotContext.d.ts +0 -3
  119. package/lib/contexts/snapshotContext.js +78 -23
  120. package/lib/contexts/tagcontext.d.ts +5 -5
  121. package/lib/contexts/tagcontext.js +16 -16
  122. package/lib/contexts/textalertcontext.d.ts +1 -5
  123. package/lib/contexts/textalertcontext.js +1 -5
  124. package/lib/contexts/usereventcontext.d.ts +1 -1
  125. package/lib/contexts/usereventcontext.js +12 -12
  126. package/lib/data/animation.d.ts +10 -2
  127. package/lib/data/change.d.ts +1 -1
  128. package/lib/data/change.js +7 -0
  129. package/lib/data/core.d.ts +9 -1
  130. package/lib/data/index.d.ts +1 -1
  131. package/lib/data/index.js +1 -1
  132. package/lib/decorators.d.ts +348 -0
  133. package/lib/decorators.js +239 -0
  134. package/lib/decoratorutils.d.ts +3 -0
  135. package/lib/decoratorutils.js +8 -0
  136. package/lib/emitter.d.ts +15 -2
  137. package/lib/emitter.js +15 -6
  138. package/lib/entity.d.ts +43 -25
  139. package/lib/entity.js +104 -71
  140. package/lib/event.d.ts +2 -1
  141. package/lib/event.js +1 -4
  142. package/lib/groups.d.ts +18 -0
  143. package/lib/groups.js +19 -0
  144. package/lib/icons.d.ts +3372 -0
  145. package/lib/icons.js +1 -0
  146. package/lib/index.d.ts +18 -13
  147. package/lib/index.js +17 -13
  148. package/lib/inflate.d.ts +7 -7
  149. package/lib/inflate.js +5 -5
  150. package/lib/observable.d.ts +9 -2
  151. package/lib/observable.js +5 -4
  152. package/lib/observe.d.ts +18 -0
  153. package/lib/observe.js +177 -0
  154. package/lib/profile.d.ts +9 -5
  155. package/lib/profile.js +27 -17
  156. package/lib/selectors.d.ts +1 -1
  157. package/lib/selectors.js +5 -4
  158. package/lib/types.d.ts +161 -19
  159. package/lib/types.js +22 -1
  160. package/lib/values/values.d.ts +7 -8
  161. package/lib/values/values.js +1 -2
  162. package/lib/values/valuesmutator.d.ts +4 -1
  163. package/lib/values/valuesmutator.js +10 -8
  164. package/lib/zcomponent.d.ts +21 -10
  165. package/lib/zcomponent.js +717 -540
  166. package/package.json +22 -5
  167. package/lib/behaviors/ChangeCursor.d.ts +0 -39
  168. package/lib/behaviors/ChangeCursor.js +0 -44
@@ -5,18 +5,18 @@ import { Observable } from '../observable';
5
5
  * Manages and tracks user events within the application context.
6
6
  */
7
7
  export class UserEventContext extends Context {
8
- constructor() {
9
- super(...arguments);
10
- /**
11
- * Event triggered when a user event occurs.
12
- */
13
- this.onUserEvent = new EventClass();
14
- /**
15
- * An observable that emits the next user event as a promise.
16
- * It gets resolved with the event object when a user event occurs.
17
- */
18
- this.nextUserEvent = new Observable(new Promise(resolve => (this._resolveNextUserEvent = resolve)), undefined, false);
19
- }
8
+ /**
9
+ * Event triggered when a user event occurs.
10
+ */
11
+ onUserEvent = new EventClass();
12
+ _resolveNextUserEvent;
13
+ /**
14
+ * An observable that emits the next user event as a promise.
15
+ * It gets resolved with the event object when a user event occurs.
16
+ */
17
+ nextUserEvent = new Observable(new Promise(resolve => {
18
+ this._resolveNextUserEvent = resolve;
19
+ }), undefined, false);
20
20
  /**
21
21
  * Registers and emits a user event.
22
22
  * @param evt The user event to register.
@@ -112,14 +112,22 @@ export type Easing = null | keyof typeof predefinedCurve | string;
112
112
  /**
113
113
  * Type representing a point in a Bezier curve.
114
114
  */
115
- export type Point = [number, number];
115
+ export type Point = [
116
+ number,
117
+ number
118
+ ];
116
119
  /**
117
120
  * Type representing a Bezier curve.
118
121
  *
119
122
  * @note
120
123
  * Bezier represents the four control points between this keyframe and the next
121
124
  */
122
- export type Bezier = [Point, Point, Point, Point];
125
+ export type Bezier = [
126
+ Point,
127
+ Point,
128
+ Point,
129
+ Point
130
+ ];
123
131
  /**
124
132
  * Type representing a curve, which is a collection of Bezier segments.
125
133
  */
@@ -1,5 +1,5 @@
1
- import { BehaviorByID, BehaviorData, ComputedHierarchy, EntityPropOverride, NodeByID, NodeData, ZComponentData } from './core';
2
1
  import { Prop } from '../types';
2
+ import { BehaviorByID, BehaviorData, ComputedHierarchy, EntityPropOverride, NodeByID, NodeData, ZComponentData } from './core';
3
3
  /**
4
4
  * Computes and memoizes the hierarchy of nodes.
5
5
  *
@@ -134,6 +134,11 @@ export function addNode(zcomp, info) {
134
134
  addNodeScriptNameToRegister(zcomp, info.data.id);
135
135
  addEntity(zcomp, info.data.id, info);
136
136
  computedHierarchies.delete(zcomp.nodes);
137
+ if (!info.data.parent) {
138
+ if (!zcomp.topLevelComponents)
139
+ zcomp.topLevelComponents = {};
140
+ zcomp.topLevelComponents[info.data.id] = true;
141
+ }
137
142
  }
138
143
  /**
139
144
  * Adds a new behavior to the specified ZComponentData.
@@ -310,6 +315,8 @@ export function deleteNode(zcomp, id) {
310
315
  removeNodeLabelFromRegister(zcomp, id);
311
316
  removeNodeScriptNameFromRegister(zcomp, id);
312
317
  delete zcomp.nodes[id];
318
+ if (zcomp.topLevelComponents)
319
+ delete zcomp.topLevelComponents[id];
313
320
  computedHierarchies.delete(zcomp.nodes);
314
321
  }
315
322
  /**
@@ -22,7 +22,10 @@ export type ComputedHierarchy = {
22
22
  [id: string]: string[];
23
23
  };
24
24
  export type Import = string;
25
- export type ParsedImport = [string, string];
25
+ export type ParsedImport = [
26
+ string,
27
+ string
28
+ ];
26
29
  export type ElementType = Import;
27
30
  export type PropType = string;
28
31
  export interface ZComponentData {
@@ -54,6 +57,9 @@ export interface ZComponentData {
54
57
  tags?: string[];
55
58
  allowedParents?: string[];
56
59
  comments?: string[];
60
+ topLevelComponents?: {
61
+ [id: string]: boolean;
62
+ };
57
63
  }
58
64
  export interface NodeData {
59
65
  id: string;
@@ -61,6 +67,8 @@ export interface NodeData {
61
67
  scriptName?: string;
62
68
  type: ElementType;
63
69
  locked?: boolean;
70
+ excludeRuntime?: boolean;
71
+ excludeDesignTime?: boolean;
64
72
  parent?: {
65
73
  id: string;
66
74
  order: string;
@@ -1,3 +1,3 @@
1
- export * from './core';
2
1
  export * from './animation';
3
2
  export * from './change';
3
+ export * from './core';
package/lib/data/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './core';
2
1
  export * from './animation';
3
2
  export * from './change';
3
+ export * from './core';
@@ -0,0 +1,348 @@
1
+ import { Behavior } from './behavior';
2
+ import type { Component } from './component';
3
+ import { Context, ContextManager } from './context';
4
+ import type { Entity, RegisterOptions } from './entity';
5
+ import { Event } from './event';
6
+ import { MaterialSymbol } from './icons';
7
+ import { Observable } from './observable';
8
+ import { TypeHint, ValuesType } from './types';
9
+ /**
10
+ * Creates an observable property that automatically triggers a callback when its value changes.
11
+ * This enables reactive programming patterns where property changes can update UI elements,
12
+ * trigger side effects, or synchronize state across components.
13
+ *
14
+ * @decorator
15
+ * @param withHandler - Optional callback function that executes when the property value changes.
16
+ * Receives the new value, the entity instance, and the property name.
17
+ * @param deep - Whether to observe nested object changes (default: true)
18
+ * @returns A property decorator that makes the property observable
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Simple observer that updates element visibility
23
+ * @zObserve((val, instance) => (instance.element.visible = val))
24
+ * public visible = true;
25
+ *
26
+ * // Observer that calls a method on change
27
+ * @zObserve((v, instance: Audio) => {
28
+ * instance._updateVolume();
29
+ * })
30
+ * public muted = false;
31
+ *
32
+ * // Observer without handler (just makes property observable)
33
+ * @zObserve()
34
+ * public position = { x: 0, y: 0, z: 0 };
35
+ * ```
36
+ */
37
+ export declare function zObserve<EntityType extends Entity, ValueType>(withHandler?: (this: EntityType, v: ValueType, entity: EntityType, propName: string) => void, deep?: boolean): (value: undefined, context: any) => (this: EntityType, initialValue: ValueType) => ValueType;
38
+ /**
39
+ * Configuration for property groups in the Mattercraft UI.
40
+ * Groups help organize related properties under collapsible sections.
41
+ */
42
+ export interface ZPropGroup {
43
+ /** The display name of the group in the UI */
44
+ name: string;
45
+ /** Display order priority - higher values appear first */
46
+ priority?: number;
47
+ /** Whether the group should be collapsed by default */
48
+ collapsed?: boolean;
49
+ }
50
+ /**
51
+ * Configuration options for properties exposed to the Mattercraft UI.
52
+ */
53
+ export interface ZPropOptions {
54
+ /** Property group - either a string name or full group configuration */
55
+ group?: string | ZPropGroup;
56
+ /** Display order priority within the group - higher values appear first */
57
+ priority?: number;
58
+ /** UI widget type (e.g., 'proportion', 'color-hex', 'angle-degrees', 'time-seconds') */
59
+ type?: keyof typeof TypeHint;
60
+ /** Constrains values to specific types (e.g., 'layerclipids', 'streamids', 'easings') */
61
+ values?: keyof typeof ValuesType | [
62
+ type: keyof typeof ValuesType,
63
+ param: string
64
+ ] | [
65
+ type: keyof typeof ValuesType,
66
+ param: string
67
+ ][];
68
+ }
69
+ /**
70
+ * Exposes a property to the Mattercraft UI editor, allowing users to configure it visually.
71
+ * Supports various UI widget types, grouping, and value constraints.
72
+ *
73
+ * @decorator
74
+ * @param opts - Configuration options for how the property appears in the UI
75
+ * @returns A property decorator that exposes the property to the UI
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Simple UI property
80
+ * @zUI()
81
+ * public volume = 1;
82
+ *
83
+ * // UI property with group and priority
84
+ * @zUI({ group: 'Audio', priority: 20 })
85
+ * public muted = false;
86
+ *
87
+ * // UI property with specific widget type
88
+ * @zUI({ type: 'proportion' })
89
+ * public opacity = 0.8;
90
+ *
91
+ * // UI property with value constraints
92
+ * @zUI({ values: 'layerclipids' })
93
+ * public state?: string;
94
+ *
95
+ * // Combined with @zObserve for reactive updates
96
+ * @zUI({ group: 'Appearance', type: 'color-hex' })
97
+ * @zObserve((val, instance) => instance.updateColor(val))
98
+ * public color = '#FF0000';
99
+ * ```
100
+ */
101
+ export declare function zUI<T>(opts?: ZPropOptions): (val: any, context: any) => any;
102
+ /**
103
+ * Excludes a property from serialization and the Mattercraft UI.
104
+ * Use this for internal properties that shouldn't be exposed to users or persisted.
105
+ *
106
+ * @decorator
107
+ * @returns A property decorator that marks the property as ignored
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Internal element reference
112
+ * @zIgnore()
113
+ * public element: HTMLElement;
114
+ *
115
+ * // Private cache that shouldn't be serialized
116
+ * @zIgnore()
117
+ * private _cache: Map<string, any>;
118
+ *
119
+ * // Temporary state
120
+ * @zIgnore()
121
+ * public isProcessing = false;
122
+ * ```
123
+ */
124
+ export declare function zIgnore(): (val: any, context: any) => void;
125
+ export type UnwrapObservable<T> = T extends Observable<infer U, any> ? U : T;
126
+ export type ExtractComponentConstructorProps<T extends new (...args: any[]) => Component> = T extends new (contextManager: ContextManager, props: infer P) => any ? P : {};
127
+ export type ExtractComponentProps<T extends new (...args: any[]) => Component> = Partial<{
128
+ [K in keyof InstanceType<T> as K extends keyof Component | 'contextManager' | 'constructor' ? never : InstanceType<T>[K] extends Function ? never : K extends `_${string}` ? never : K]: UnwrapObservable<InstanceType<T>[K]>;
129
+ }>;
130
+ export type DefaultChildProps<T extends new (...args: any[]) => Component> = Partial<ExtractComponentProps<T> & ExtractComponentConstructorProps<T>>;
131
+ /**
132
+ * Base configuration options for registering entities (components and behaviors) with Mattercraft.
133
+ */
134
+ export interface ZEntityDecOptions {
135
+ /**
136
+ * A list of tags that can be used elsewhere to reference this type of entity.
137
+ * Tags help with categorization and search in the Mattercraft UI.
138
+ */
139
+ tags?: string[];
140
+ /**
141
+ * Set to a list of tags to limit where Mattercraft's user interface will allow the user to create a new instance
142
+ * of this entity. It's possible to use a glob pattern, e.g.: 'three/Object3D/**'
143
+ */
144
+ parents?: string[];
145
+ /**
146
+ * The icon to show for this entity when it appears in the trees and menus of Mattercraft's user interface.
147
+ * Icons can be chosen from the [Material Symbols icon set](https://fonts.google.com/icons).
148
+ */
149
+ icon?: MaterialSymbol;
150
+ /**
151
+ * If supplied, Mattercraft's 'New' menu will list this entity under a group of this name.
152
+ */
153
+ group?: string;
154
+ }
155
+ /**
156
+ * Configuration for default child nodes that are automatically added when a component is created.
157
+ */
158
+ export interface DefaultChild {
159
+ /**
160
+ * A name for this node in the Hierarchy.
161
+ */
162
+ label: string;
163
+ /**
164
+ * The type of the node to initialize. This should be of the form of the import file, a `#`, then the export name from that file.
165
+ *
166
+ * @example `@zcomponent/three/lib/components/meshes/Box#Box`
167
+ */
168
+ type: string;
169
+ /**
170
+ * An object containing any initial values to set as props of the created node.
171
+ */
172
+ props?: {
173
+ [id: string]: any;
174
+ };
175
+ }
176
+ /**
177
+ * Configuration options specific to components registered with @zComponent.
178
+ */
179
+ export interface ZComponentDecOptions extends ZEntityDecOptions {
180
+ /**
181
+ * An array of children to automatically add under this entity when it's added to the Hierarchy.
182
+ * Useful for creating complex components with a predefined structure.
183
+ */
184
+ defaultChildren?: DefaultChild[];
185
+ }
186
+ /**
187
+ * Configuration options specific to behaviors registered with @zBehavior.
188
+ */
189
+ export interface ZBehaviorDecOptions extends ZEntityDecOptions {
190
+ /**
191
+ * If true, this behavior will be constructed and run in the editor at design time.
192
+ * Useful for behaviors that provide preview functionality or editor-specific features.
193
+ */
194
+ runAtDesignTime?: boolean;
195
+ }
196
+ type ClassDecorator<TFunction extends Function> = (target: TFunction) => TFunction | void;
197
+ /**
198
+ * Registers a class as a component in Mattercraft, making it available in the editor's UI.
199
+ * Components are the primary building blocks for creating interactive experiences.
200
+ *
201
+ * @decorator
202
+ * @param opts - Configuration options for the component
203
+ * @returns A class decorator that registers the component
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * // Basic component registration
208
+ * @zComponent({ icon: 'deployed_code', group: 'Meshes' })
209
+ * export class Box extends Mesh {
210
+ * // Component implementation
211
+ * }
212
+ *
213
+ * // Component with tags and parent restrictions
214
+ * @zComponent({
215
+ * icon: 'music_note',
216
+ * group: 'Media',
217
+ * tags: ['core/audio'],
218
+ * })
219
+ * export class Audio extends Component {
220
+ * // Audio component implementation
221
+ * }
222
+ *
223
+ * // Component with default children
224
+ * @zComponent({
225
+ * icon: 'view_in_ar',
226
+ * group: '3D Objects',
227
+ * defaultChildren: [
228
+ * {
229
+ * label: 'Material',
230
+ * type: '@zcomponent/three/lib/components/materials/MeshStandardMaterial#MeshStandardMaterial',
231
+ * props: { color: '#FF0000' }
232
+ * }
233
+ * ]
234
+ * })
235
+ * export class CustomMesh extends Component {
236
+ * // Mesh with default material
237
+ * }
238
+ * ```
239
+ */
240
+ export declare function zComponent<T extends new (...args: any[]) => Component>(opts?: ZComponentDecOptions): ClassDecorator<T>;
241
+ /**
242
+ * Registers a class as a behavior that can be attached to components.
243
+ * Behaviors add functionality to existing components without modifying their structure.
244
+ *
245
+ * @decorator
246
+ * @param opts - Configuration options for the behavior
247
+ * @returns A class decorator that registers the behavior
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * // Basic behavior registration
252
+ * @zBehavior({ icon: 'directions_run', parents: ['three/Object3D/**'] })
253
+ * export class Animation extends Behavior {
254
+ * // Animation behavior implementation
255
+ * }
256
+ *
257
+ * // Behavior that runs in the editor
258
+ * @zBehavior({
259
+ * icon: 'visibility',
260
+ * group: 'Actions',
261
+ * runAtDesignTime: true,
262
+ * parents: ['three/Object3D/**']
263
+ * })
264
+ * export class PreviewMode extends Behavior {
265
+ * // Provides preview functionality in the editor
266
+ * }
267
+ *
268
+ * // Action behavior with specific parent restrictions
269
+ * @zBehavior({
270
+ * icon: 'play_circle',
271
+ * group: 'Animation Actions',
272
+ * parents: ['three/Object3D/GLTF'],
273
+ * tags: ['animation/control']
274
+ * })
275
+ * export class PlayAnimation extends ActionBehavior {
276
+ * // Plays animations on GLTF models
277
+ * }
278
+ * ```
279
+ */
280
+ export declare function zBehavior<T extends new (...args: any[]) => Behavior>(opts?: ZBehaviorDecOptions): ClassDecorator<T>;
281
+ type KeysOfType<T, KT> = Exclude<{
282
+ [K in keyof T]: T[K] extends KT ? K : never;
283
+ }[keyof T], undefined>;
284
+ type EventArgs<E> = E extends Event<infer X> ? X : never;
285
+ /**
286
+ * Automatically registers a method as an event listener during entity initialization.
287
+ * The decorated method will be called whenever the specified event is emitted.
288
+ * Supports three patterns: direct event objects, events from contexts, and events from the entity itself.
289
+ *
290
+ * @decorator
291
+ * @param event - Direct event object to listen to
292
+ * @param opts - Optional registration options (e.g., priority, once)
293
+ * @returns A method decorator that registers the event listener
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * // Listen to a direct event object
298
+ * @zRegister(someEvent)
299
+ * private handleEvent(data: EventData) {
300
+ * console.log('Event received:', data);
301
+ * }
302
+ * ```
303
+ */
304
+ export declare function zRegister<EntityType extends Entity, EventType extends Event<any>, EventArgsType extends EventArgs<EventType>>(event: EventType, opts?: RegisterOptions): (originalMethod: (...args: EventArgsType) => void, context: ClassMethodDecoratorContext<EntityType>) => any;
305
+ /**
306
+ * Registers a method to listen to an event from a context.
307
+ *
308
+ * @decorator
309
+ * @param contextConstructor - The context class constructor
310
+ * @param prop - The property name of the event in the context
311
+ * @param opts - Optional registration options
312
+ * @returns A method decorator that registers the event listener
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * // Listen to an event from a context
317
+ * @zRegister(AudioContext, 'onVolumeChange')
318
+ * private handleVolumeChange(volume: number) {
319
+ * this.updateVolume(volume);
320
+ * }
321
+ * ```
322
+ */
323
+ export declare function zRegister<EntityType extends Entity, ContextType extends Context, PropType extends KeysOfType<ContextType, Event<any>>, EventArgsType extends EventArgs<ContextType[PropType]>>(contextConstructor: new (...args: any[]) => ContextType, prop: PropType, opts?: RegisterOptions): (originalMethod: (...args: EventArgsType) => void, context: ClassMethodDecoratorContext<EntityType>) => any;
324
+ /**
325
+ * Registers a method to listen to an event from the entity itself.
326
+ *
327
+ * @decorator
328
+ * @param prop - The property name of the event in the entity
329
+ * @param opts - Optional registration options
330
+ * @returns A method decorator that registers the event listener
331
+ *
332
+ * @example
333
+ * ```typescript
334
+ * // Listen to an event from the same entity
335
+ * @zRegister('onStateChange')
336
+ * private handleStateChange(newState: State) {
337
+ * this.processStateChange(newState);
338
+ * }
339
+ *
340
+ * // With registration options
341
+ * @zRegister('onClick', { once: true })
342
+ * private handleFirstClick() {
343
+ * this.initializeOnFirstInteraction();
344
+ * }
345
+ * ```
346
+ */
347
+ export declare function zRegister<EntityType extends Entity, PropType extends KeysOfType<EntityType, Event<any>>, EventArgsType extends EventArgs<EntityType[PropType]>>(prop: PropType, opts?: RegisterOptions): (originalMethod: (...args: EventArgsType) => void, context: ClassMethodDecoratorContext<EntityType>) => any;
348
+ export {};