k3-plugin-api 1.2.0 → 1.3.0
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.ts +70 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -627,6 +627,65 @@ export interface K3LogicExtensions {
|
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
// ─── Model Slot Types ────────────────────────────────────────────────────────
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Declares a named slot where child models can be placed inside a parent dynamic model.
|
|
634
|
+
* Attach an array of these to `DynamicModel.slotDefinitions`.
|
|
635
|
+
*/
|
|
636
|
+
export interface SlotDefinition {
|
|
637
|
+
/** Unique identifier (UUID) — primary key used in rule columns to reference this slot. */
|
|
638
|
+
id: string;
|
|
639
|
+
/** Human-readable name shown in the admin slot picker. */
|
|
640
|
+
name: string;
|
|
641
|
+
/** Optional fallback model ID rendered when no rule assigns a model to this slot. */
|
|
642
|
+
defaultModelId?: string | number;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* A resolved model instance placed into a slot at runtime.
|
|
647
|
+
* Received via `DynamicModelComponentProps.slots[slotId]`.
|
|
648
|
+
*/
|
|
649
|
+
export interface SlotModelInstance {
|
|
650
|
+
/** The model data object for this slot instance. */
|
|
651
|
+
model: { id: string | number; [key: string]: unknown };
|
|
652
|
+
/** URL of the model's 3D file, or `undefined` if this is a dynamic model with a component. */
|
|
653
|
+
fileURL: string | undefined;
|
|
654
|
+
/** The React component used to render this model if it is a dynamic model otherwise `undefined`. */
|
|
655
|
+
component: React.ComponentType<any> | undefined;
|
|
656
|
+
/** Evaluated props passed to the model component. */
|
|
657
|
+
props: Record<string, unknown>;
|
|
658
|
+
/** The rule-engine action that placed this model into the scene. */
|
|
659
|
+
modelAction: {
|
|
660
|
+
/** Unique ID of the model action record. */
|
|
661
|
+
id: string;
|
|
662
|
+
/** ID of the model referenced by this action. */
|
|
663
|
+
modelId: string | number;
|
|
664
|
+
/** Props overrides defined on the action. */
|
|
665
|
+
props?: Record<string, unknown>;
|
|
666
|
+
/** ID of the slot this action targets. */
|
|
667
|
+
slotId?: string;
|
|
668
|
+
[key: string]: unknown;
|
|
669
|
+
};
|
|
670
|
+
/** The slot definition this instance was placed into. */
|
|
671
|
+
slotDefinition: SlotDefinition;
|
|
672
|
+
/** Recursively nested slot instances when the slotted model itself has slots. */
|
|
673
|
+
slots?: Record<string, SlotModelInstance[]>;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Props automatically injected into every `DynamicModel.component` at runtime.
|
|
678
|
+
* Extend this with your custom prop types: `DynamicModelComponentProps & { myProp: string }`.
|
|
679
|
+
*/
|
|
680
|
+
export interface DynamicModelComponentProps {
|
|
681
|
+
/**
|
|
682
|
+
* Resolved child model instances keyed by slot ID.
|
|
683
|
+
* Only present when the model has `slotDefinitions` and at least one slot is filled.
|
|
684
|
+
*/
|
|
685
|
+
slots?: Record<string, SlotModelInstance[]>;
|
|
686
|
+
[key: string]: unknown;
|
|
687
|
+
}
|
|
688
|
+
|
|
630
689
|
// ─── Legacy types (unchanged) ────────────────────────────────────────────────
|
|
631
690
|
|
|
632
691
|
export interface DynamicModel {
|
|
@@ -652,8 +711,18 @@ export interface DynamicModel {
|
|
|
652
711
|
/**
|
|
653
712
|
* Default prop values used when a new model action is created.
|
|
654
713
|
* Each key matches a `propsDialog` key; values may be plain data or `{ expression: string }`.
|
|
714
|
+
* Include `slotDefinitions` here to declare named slots for child models.
|
|
655
715
|
*/
|
|
656
|
-
defaultProps:
|
|
716
|
+
defaultProps: {
|
|
717
|
+
slotDefinitions?: SlotDefinition[];
|
|
718
|
+
[key: string]:
|
|
719
|
+
| string
|
|
720
|
+
| number
|
|
721
|
+
| boolean
|
|
722
|
+
| ModelPropDefault
|
|
723
|
+
| undefined
|
|
724
|
+
| SlotDefinition[];
|
|
725
|
+
};
|
|
657
726
|
/** Optional tag used to group or filter models in the admin UI. */
|
|
658
727
|
tag?: string;
|
|
659
728
|
}
|