k3-plugin-api 1.4.3 → 1.5.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/dist/index.cjs +73 -0
- package/{index.ts → dist/index.d.cts} +176 -240
- package/dist/index.d.ts +688 -680
- package/dist/index.js +69 -0
- package/package.json +17 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,110 +1,72 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region index.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
useBOM: () => K3BomEntry[];
|
|
21
|
-
/**
|
|
22
|
-
* React hook to access the current total price.
|
|
23
|
-
* @returns The effective total price (MOV-adjusted or overall price)
|
|
24
|
-
*/
|
|
25
|
-
usePrice: () => number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal hook container that gets mutated by init().
|
|
30
|
-
* This object is shared across Module Federation boundaries.
|
|
6
|
+
* Get plugin-specific settings from the K3 store.
|
|
7
|
+
* Returns a snapshot of the current settings - not reactive.
|
|
8
|
+
* Use this in plugin components that need access to settings configured in the admin.
|
|
9
|
+
*
|
|
10
|
+
* @param pluginId - The unique plugin ID (e.g. "acme.my-plugin")
|
|
11
|
+
* @returns The settings object for this plugin, or `{}` if none are configured
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const settings = getSettings("acme.my-plugin") as { apiKey?: string };
|
|
16
|
+
* if (settings.apiKey) {
|
|
17
|
+
* // Use API key
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
31
20
|
*/
|
|
32
|
-
|
|
33
|
-
useSettings: ((pluginId: string) => {
|
|
34
|
-
throw new Error(
|
|
35
|
-
"k3-plugin-api not initialized. Make sure K3 calls init() before using hooks.",
|
|
36
|
-
);
|
|
37
|
-
}) as K3Hooks["useSettings"],
|
|
38
|
-
|
|
39
|
-
useBOM: (() => {
|
|
40
|
-
throw new Error(
|
|
41
|
-
"k3-plugin-api not initialized. Make sure K3 calls init() before using hooks.",
|
|
42
|
-
);
|
|
43
|
-
}) as K3Hooks["useBOM"],
|
|
44
|
-
|
|
45
|
-
usePrice: (() => {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"k3-plugin-api not initialized. Make sure K3 calls init() before using hooks.",
|
|
48
|
-
);
|
|
49
|
-
}) as K3Hooks["usePrice"],
|
|
50
|
-
};
|
|
51
|
-
|
|
21
|
+
declare function getSettings(pluginId: string): unknown;
|
|
52
22
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
23
|
+
* Get plugin-specific settings from the K3 store as a reactive hook.
|
|
24
|
+
* Re-renders the component whenever the settings change.
|
|
25
|
+
* Use this in plugin React components.
|
|
26
|
+
*
|
|
27
|
+
* @param pluginId - The unique plugin ID (e.g. "acme.my-plugin")
|
|
28
|
+
* @returns The settings object for this plugin, or `{}` if none are configured
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const settings = useK3PluginSettings("acme.my-plugin") as { apiKey?: string };
|
|
33
|
+
* ```
|
|
55
34
|
*/
|
|
56
|
-
|
|
57
|
-
_hooks.useSettings(pluginId);
|
|
58
|
-
export const useBOM: K3Hooks["useBOM"] = () => _hooks.useBOM();
|
|
59
|
-
export const usePrice: K3Hooks["usePrice"] = () => _hooks.usePrice();
|
|
60
|
-
|
|
35
|
+
declare function useK3PluginSettings(pluginId: string): unknown;
|
|
61
36
|
/**
|
|
62
|
-
* Called by K3 when the plugin is loaded to inject runtime
|
|
37
|
+
* Called by K3 when the plugin is loaded to inject runtime API functions.
|
|
63
38
|
* @internal This function is called by K3 automatically - plugins should not call it directly.
|
|
64
39
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ─── HOC type (mirrors K3 internal, no K3 imports) ──────────────────────────
|
|
72
|
-
|
|
40
|
+
declare function init(api: {
|
|
41
|
+
getSettings: (pluginId: string) => unknown;
|
|
42
|
+
usePluginSettings: (pluginId: string) => unknown;
|
|
43
|
+
}): void;
|
|
73
44
|
/** A Higher-Order Component: takes the default component, returns a new one. */
|
|
74
|
-
|
|
75
|
-
comp: React.FC<P>,
|
|
76
|
-
) => React.FC<P>;
|
|
77
|
-
|
|
45
|
+
type HOC<P = Record<string, unknown>> = (comp: React.FC<P>) => React.FC<P>;
|
|
78
46
|
/** Four editor languages supported by K3. */
|
|
79
|
-
|
|
47
|
+
type LocalizedString = {
|
|
80
48
|
de?: string;
|
|
81
49
|
en?: string;
|
|
82
50
|
nl?: string;
|
|
83
51
|
fr?: string;
|
|
84
52
|
};
|
|
85
|
-
|
|
86
53
|
/** An HOC slot with a required description for the admin UI. */
|
|
87
|
-
|
|
54
|
+
interface HOCWithDescription<P = Record<string, unknown>> {
|
|
88
55
|
hoc: HOC<P>;
|
|
89
56
|
/** Describe what this extension point does. Shown in the plugin extensions dialog. */
|
|
90
57
|
description: string | LocalizedString;
|
|
91
58
|
}
|
|
92
|
-
|
|
93
59
|
/** A logic callback with a required description for the admin UI. */
|
|
94
|
-
|
|
60
|
+
interface CallbackWithDescription<T> {
|
|
95
61
|
fn: T;
|
|
96
62
|
/** Describe what this callback does. Shown in the plugin extensions dialog. */
|
|
97
63
|
description: string | LocalizedString;
|
|
98
64
|
}
|
|
99
|
-
|
|
100
|
-
// ─── Public Plugin Descriptor ───────────────────────────────────────────────
|
|
101
|
-
|
|
102
|
-
export interface K3PluginDescriptor {
|
|
65
|
+
interface K3PluginDescriptor {
|
|
103
66
|
/** Unique stable identifier, e.g. "vendor.myplugin". Required for collision detection. */
|
|
104
67
|
id: string;
|
|
105
68
|
/** Semver string, e.g. "1.0.0". */
|
|
106
69
|
version: string;
|
|
107
|
-
|
|
108
70
|
/** UI extension points: layout HOCs, input HOCs, dialog HOCs. */
|
|
109
71
|
ui?: K3UIExtensions;
|
|
110
72
|
/** Viewer / 3D extension points: canvas, scene components, layout components, dynamic models. */
|
|
@@ -115,14 +77,10 @@ export interface K3PluginDescriptor {
|
|
|
115
77
|
settings: unknown;
|
|
116
78
|
onSave: (settings: unknown) => void;
|
|
117
79
|
}>;
|
|
118
|
-
|
|
119
80
|
/** @deprecated Use viewer.models instead. */
|
|
120
81
|
dynamicModels?: DynamicModel[];
|
|
121
82
|
}
|
|
122
|
-
|
|
123
|
-
// ─── UI Extensions ──────────────────────────────────────────────────────────
|
|
124
|
-
|
|
125
|
-
export interface K3UIExtensions {
|
|
83
|
+
interface K3UIExtensions {
|
|
126
84
|
/** Override layout shell components. */
|
|
127
85
|
layout?: K3LayoutExtensions;
|
|
128
86
|
/** Register new variable visualisations (renderers) per variable data type. */
|
|
@@ -130,8 +88,7 @@ export interface K3UIExtensions {
|
|
|
130
88
|
/** Override dialog components. */
|
|
131
89
|
dialogs?: K3DialogExtensions;
|
|
132
90
|
}
|
|
133
|
-
|
|
134
|
-
export interface K3LayoutExtensions {
|
|
91
|
+
interface K3LayoutExtensions {
|
|
135
92
|
/** Wraps the outermost app shell component. */
|
|
136
93
|
root?: HOCWithDescription;
|
|
137
94
|
/** Wraps the top header bar containing branding, navigation buttons, and scene controls. */
|
|
@@ -181,12 +138,11 @@ export interface K3LayoutExtensions {
|
|
|
181
138
|
/** Wraps each individual variable label inside a group panel. */
|
|
182
139
|
variableLabel?: HOCWithDescription;
|
|
183
140
|
}
|
|
184
|
-
|
|
185
141
|
/**
|
|
186
142
|
* Props passed to a plugin variable component (VariableVisualisation.component) at runtime.
|
|
187
143
|
* Use these to render a fully custom variable input UI.
|
|
188
144
|
*/
|
|
189
|
-
|
|
145
|
+
interface K3VariableComponentProps {
|
|
190
146
|
/** The variable definition for which this component is rendered. */
|
|
191
147
|
variable: {
|
|
192
148
|
/** Database ID of the variable. */
|
|
@@ -233,20 +189,18 @@ export interface K3VariableComponentProps {
|
|
|
233
189
|
* Number variables: onChange(values[0].id, { inputValue: numericValue })
|
|
234
190
|
* List/color/boolean: onChange(value.id)
|
|
235
191
|
*/
|
|
236
|
-
onChange: (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
) => void;
|
|
192
|
+
onChange: (valueId: string | number, metadata?: {
|
|
193
|
+
inputValue?: number;
|
|
194
|
+
}) => void;
|
|
240
195
|
/** When `true`, the variable is locked and user interaction should be blocked. */
|
|
241
196
|
disabled?: boolean;
|
|
242
197
|
}
|
|
243
|
-
|
|
244
198
|
/**
|
|
245
199
|
* A plugin-registered variable renderer (VariableVisualisation).
|
|
246
200
|
* Displayed as a selectable option in the admin visualisation chooser.
|
|
247
201
|
* The component owns its full UI — label, input, chrome.
|
|
248
202
|
*/
|
|
249
|
-
|
|
203
|
+
interface VariableVisualisation {
|
|
250
204
|
/**
|
|
251
205
|
* Globally unique template key, e.g. "acme.mySlider".
|
|
252
206
|
* Set variable.settings.template = this key to use this visualisation.
|
|
@@ -260,8 +214,7 @@ export interface VariableVisualisation {
|
|
|
260
214
|
/** Full variable renderer component. Receives K3VariableComponentProps. */
|
|
261
215
|
component: React.ComponentType<K3VariableComponentProps>;
|
|
262
216
|
}
|
|
263
|
-
|
|
264
|
-
export interface K3InputExtensions {
|
|
217
|
+
interface K3InputExtensions {
|
|
265
218
|
/** Register new visualisations for list-type variables. */
|
|
266
219
|
list?: VariableVisualisation[];
|
|
267
220
|
/** Register new visualisations for color-type variables. */
|
|
@@ -281,15 +234,13 @@ export interface K3InputExtensions {
|
|
|
281
234
|
/** Register new visualisations for information-type variables. */
|
|
282
235
|
information?: VariableVisualisation[];
|
|
283
236
|
}
|
|
284
|
-
|
|
285
|
-
export interface K3DialogExtensions {
|
|
237
|
+
interface K3DialogExtensions {
|
|
286
238
|
/** Extension points for the order / summary dialog (contact form, price table, confirmation). */
|
|
287
239
|
order?: K3OrderDialogExtensions;
|
|
288
240
|
/** Extension points for inline selection-warning components shown in the sidebar. */
|
|
289
241
|
warnings?: K3WarningExtensions;
|
|
290
242
|
}
|
|
291
|
-
|
|
292
|
-
export interface K3OrderDialogExtensions {
|
|
243
|
+
interface K3OrderDialogExtensions {
|
|
293
244
|
/** Wraps the entire order dialog modal. */
|
|
294
245
|
root?: HOCWithDescription;
|
|
295
246
|
/** Wraps the dialog headline / title element. */
|
|
@@ -309,8 +260,7 @@ export interface K3OrderDialogExtensions {
|
|
|
309
260
|
/** Wraps the error confirmation screen shown after a failed order submission. */
|
|
310
261
|
confirmationError?: HOCWithDescription;
|
|
311
262
|
}
|
|
312
|
-
|
|
313
|
-
export interface K3WarningExtensions {
|
|
263
|
+
interface K3WarningExtensions {
|
|
314
264
|
/** Wraps the full invalid-selection warning component (red badge next to a variable value). */
|
|
315
265
|
invalidSelection?: HOCWithDescription;
|
|
316
266
|
/** Wraps the icon inside the invalid-selection warning. */
|
|
@@ -320,14 +270,11 @@ export interface K3WarningExtensions {
|
|
|
320
270
|
/** Wraps the tooltip content shown when a number variable value is out of bounds. */
|
|
321
271
|
numberWarningTooltip?: HOCWithDescription;
|
|
322
272
|
}
|
|
323
|
-
|
|
324
|
-
// ─── Viewer Extensions ──────────────────────────────────────────────────────
|
|
325
|
-
|
|
326
273
|
/**
|
|
327
274
|
* A single Bill-of-Materials entry exposed to plugin components.
|
|
328
275
|
* Mirrors the internal BOMEntry shape using only primitive/simple types.
|
|
329
276
|
*/
|
|
330
|
-
|
|
277
|
+
interface K3BomEntry {
|
|
331
278
|
article: {
|
|
332
279
|
id: number;
|
|
333
280
|
/** Article number as defined in the K3 admin. */
|
|
@@ -342,18 +289,20 @@ export interface K3BomEntry {
|
|
|
342
289
|
/** Optional override quantity from the article amount modal. */
|
|
343
290
|
amount?: number | null;
|
|
344
291
|
/** Price of a single unit of this article. */
|
|
345
|
-
price: {
|
|
292
|
+
price: {
|
|
293
|
+
price: number;
|
|
294
|
+
unit?: string;
|
|
295
|
+
};
|
|
346
296
|
/** Whether this is a main article (`true`) or an accessory/surcharge (`false`). */
|
|
347
297
|
main?: boolean;
|
|
348
298
|
}
|
|
349
|
-
|
|
350
299
|
/**
|
|
351
300
|
* Props automatically injected into every `customLayoutComponents` entry.
|
|
352
301
|
*
|
|
353
302
|
* @remarks TODO(WIP) — This interface will grow as more configurator data is
|
|
354
303
|
* exposed to plugins.
|
|
355
304
|
*/
|
|
356
|
-
|
|
305
|
+
interface CustomLayoutComponentProps {
|
|
357
306
|
/** The slot name this component was mounted under. */
|
|
358
307
|
name: string;
|
|
359
308
|
/**
|
|
@@ -369,8 +318,7 @@ export interface CustomLayoutComponentProps {
|
|
|
369
318
|
/** Any additional props forwarded by the layout. */
|
|
370
319
|
[key: string]: unknown;
|
|
371
320
|
}
|
|
372
|
-
|
|
373
|
-
export interface K3ViewerExtensions {
|
|
321
|
+
interface K3ViewerExtensions {
|
|
374
322
|
/** Wraps the root Three.js / R3F canvas element. */
|
|
375
323
|
canvas?: HOCWithDescription;
|
|
376
324
|
/**
|
|
@@ -380,11 +328,7 @@ export interface K3ViewerExtensions {
|
|
|
380
328
|
*
|
|
381
329
|
* Components receive {@link CustomLayoutComponentProps} with BOM and total price data.
|
|
382
330
|
*/
|
|
383
|
-
|
|
384
|
-
customLayoutComponents?: Record<
|
|
385
|
-
string,
|
|
386
|
-
React.ComponentType<CustomLayoutComponentProps>
|
|
387
|
-
>;
|
|
331
|
+
customLayoutComponents?: Record<string, React.ComponentType<CustomLayoutComponentProps>>;
|
|
388
332
|
/** Dynamic 3D model definitions contributed by this plugin. Equivalent to the top-level `dynamicModels`. */
|
|
389
333
|
models?: DynamicModel[];
|
|
390
334
|
/** Override the label / hotspot overlay components rendered on the 3D canvas. */
|
|
@@ -395,21 +339,20 @@ export interface K3ViewerExtensions {
|
|
|
395
339
|
mobile?: HOCWithDescription;
|
|
396
340
|
};
|
|
397
341
|
}
|
|
398
|
-
|
|
399
|
-
// ─── Logic Callback Types ────────────────────────────────────────────────────
|
|
400
|
-
|
|
401
342
|
/** [x, y, z] coordinate tuple used on camera objects. */
|
|
402
|
-
|
|
403
|
-
|
|
343
|
+
type K3Coordinates = [number, number, number];
|
|
404
344
|
/**
|
|
405
345
|
* Restricts a camera to a specific configurator context.
|
|
406
346
|
* `"group"` / `"variable"` — camera activates only when that item is in view; `id` is the entity's database ID.
|
|
407
347
|
* `"general"` — camera is always available regardless of the active group or variable.
|
|
408
348
|
*/
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
349
|
+
type K3CameraScope = {
|
|
350
|
+
type: "group" | "variable";
|
|
351
|
+
id: number;
|
|
352
|
+
} | {
|
|
353
|
+
type: "general";
|
|
354
|
+
id?: null;
|
|
355
|
+
};
|
|
413
356
|
interface K3BaseCamera {
|
|
414
357
|
/** Unique database ID of the camera record. */
|
|
415
358
|
id: string;
|
|
@@ -422,7 +365,10 @@ interface K3BaseCamera {
|
|
|
422
365
|
/** Euler rotation [x, y, z] in radians. */
|
|
423
366
|
rotation: K3Coordinates;
|
|
424
367
|
/** Optional override for the screenshot render resolution in pixels. */
|
|
425
|
-
resolution?: {
|
|
368
|
+
resolution?: {
|
|
369
|
+
width: number;
|
|
370
|
+
height: number;
|
|
371
|
+
};
|
|
426
372
|
/** Transition easing threshold used by the camera animation driver. */
|
|
427
373
|
threshold?: number;
|
|
428
374
|
/**
|
|
@@ -437,16 +383,19 @@ interface K3BaseCamera {
|
|
|
437
383
|
zoom?: number;
|
|
438
384
|
[key: string]: unknown;
|
|
439
385
|
}
|
|
440
|
-
|
|
441
386
|
/** A perspective camera configured in the K3 scene editor. */
|
|
442
|
-
|
|
387
|
+
interface K3PerspectiveCamera extends K3BaseCamera {
|
|
443
388
|
type: "PerspectiveCamera";
|
|
444
389
|
/** Intrinsic perspective parameters: field-of-view in degrees, aspect ratio, near/far clip planes. */
|
|
445
|
-
baseSettings?: {
|
|
390
|
+
baseSettings?: {
|
|
391
|
+
fov: number;
|
|
392
|
+
aspect: number;
|
|
393
|
+
near: number;
|
|
394
|
+
far: number;
|
|
395
|
+
};
|
|
446
396
|
}
|
|
447
|
-
|
|
448
397
|
/** An orthographic camera configured in the K3 scene editor. */
|
|
449
|
-
|
|
398
|
+
interface K3OrthographicCamera extends K3BaseCamera {
|
|
450
399
|
type: "OrthographicCamera";
|
|
451
400
|
/** Intrinsic orthographic parameters: frustum left/right/top/bottom extents and near/far clip planes. */
|
|
452
401
|
baseSettings?: {
|
|
@@ -458,24 +407,20 @@ export interface K3OrthographicCamera extends K3BaseCamera {
|
|
|
458
407
|
far: number;
|
|
459
408
|
};
|
|
460
409
|
}
|
|
461
|
-
|
|
462
410
|
/** A scene camera — perspective or orthographic. Passed to screenshot / camera-list callbacks. */
|
|
463
|
-
|
|
464
|
-
|
|
411
|
+
type K3Camera = K3PerspectiveCamera | K3OrthographicCamera;
|
|
465
412
|
/** Pixel dimensions used for screenshot rendering. */
|
|
466
|
-
|
|
413
|
+
interface K3ScreenshotDimensions {
|
|
467
414
|
width: number;
|
|
468
415
|
height: number;
|
|
469
416
|
}
|
|
470
|
-
|
|
471
417
|
/** AR platform identifier. */
|
|
472
|
-
|
|
473
|
-
|
|
418
|
+
type K3ARPlatform = "iOS" | "AndroidOS";
|
|
474
419
|
/**
|
|
475
420
|
* Minimal structural representation of a Three.js scene graph node.
|
|
476
421
|
* Cast to `import("three").Object3D` for full Three.js access.
|
|
477
422
|
*/
|
|
478
|
-
|
|
423
|
+
interface K3Scene {
|
|
479
424
|
/** Three.js object type string, e.g. `"Scene"`, `"Mesh"`, `"Group"`. */
|
|
480
425
|
type: string;
|
|
481
426
|
/** Direct child nodes of this scene graph node. */
|
|
@@ -485,9 +430,8 @@ export interface K3Scene {
|
|
|
485
430
|
traverse(callback: (object: K3Scene) => void): void;
|
|
486
431
|
getObjectByName(name: string): K3Scene | undefined;
|
|
487
432
|
}
|
|
488
|
-
|
|
489
433
|
/** Context passed to `core.onExportAR`. */
|
|
490
|
-
|
|
434
|
+
interface K3ARExportContext {
|
|
491
435
|
/** Platform the AR export is targeting. */
|
|
492
436
|
platform: K3ARPlatform;
|
|
493
437
|
/**
|
|
@@ -496,9 +440,8 @@ export interface K3ARExportContext {
|
|
|
496
440
|
*/
|
|
497
441
|
scene: K3Scene;
|
|
498
442
|
}
|
|
499
|
-
|
|
500
443
|
/** An uploaded file in a save operation (e.g. a screenshot per camera). */
|
|
501
|
-
|
|
444
|
+
interface K3UploadFile {
|
|
502
445
|
/** Camera name or custom key identifying this file. */
|
|
503
446
|
key: string;
|
|
504
447
|
/** The file data. */
|
|
@@ -506,9 +449,8 @@ export interface K3UploadFile {
|
|
|
506
449
|
/** Optional explicit file name. */
|
|
507
450
|
fileName?: string;
|
|
508
451
|
}
|
|
509
|
-
|
|
510
452
|
/** Result returned to `core.onOpenPdf` after a save/order action. */
|
|
511
|
-
|
|
453
|
+
interface K3SaveResult {
|
|
512
454
|
/** Generated configuration code. */
|
|
513
455
|
code?: string;
|
|
514
456
|
/** Pricing verification info. */
|
|
@@ -529,12 +471,11 @@ export interface K3SaveResult {
|
|
|
529
471
|
pdfName?: string;
|
|
530
472
|
[key: string]: unknown;
|
|
531
473
|
}
|
|
532
|
-
|
|
533
474
|
/**
|
|
534
475
|
* Payload dispatched when a configuration is saved (e.g. "order", "cart", "pdf").
|
|
535
476
|
* Passed to `config.onSaveEvent`.
|
|
536
477
|
*/
|
|
537
|
-
|
|
478
|
+
interface K3ConfigurationSavedEvent {
|
|
538
479
|
type: "K3ConfigurationSaved";
|
|
539
480
|
/** Save action key, e.g. "cart", "pdf", "email". */
|
|
540
481
|
actionKey: string;
|
|
@@ -549,9 +490,8 @@ export interface K3ConfigurationSavedEvent {
|
|
|
549
490
|
};
|
|
550
491
|
[key: string]: unknown;
|
|
551
492
|
}
|
|
552
|
-
|
|
553
493
|
/** A persisted configuration object. Passed to `config.onUpdate` and `config.onSave`. */
|
|
554
|
-
|
|
494
|
+
interface K3Configuration {
|
|
555
495
|
/** Database ID of the saved configuration record. */
|
|
556
496
|
id: number | string;
|
|
557
497
|
/** ID of the K3 app this configuration belongs to. */
|
|
@@ -576,12 +516,10 @@ export interface K3Configuration {
|
|
|
576
516
|
files: Record<string, Record<string, string>>;
|
|
577
517
|
[key: string]: unknown;
|
|
578
518
|
}
|
|
579
|
-
|
|
580
519
|
/** A configuration not yet persisted (no `id` or `code`). */
|
|
581
|
-
|
|
582
|
-
|
|
520
|
+
type K3NewConfiguration = Omit<K3Configuration, "id" | "code">;
|
|
583
521
|
/** An individual variable selection state. */
|
|
584
|
-
|
|
522
|
+
interface K3Selection {
|
|
585
523
|
/** Unique selection ID. */
|
|
586
524
|
id: string;
|
|
587
525
|
/** ID of the variable this selection belongs to. */
|
|
@@ -599,59 +537,81 @@ export interface K3Selection {
|
|
|
599
537
|
};
|
|
600
538
|
[key: string]: unknown;
|
|
601
539
|
}
|
|
602
|
-
|
|
603
540
|
/** Full application snapshot passed to `core.preprocessFullApp` before the store initialises. */
|
|
604
|
-
|
|
605
|
-
app: {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
541
|
+
interface K3FullApp {
|
|
542
|
+
app: {
|
|
543
|
+
id: number;
|
|
544
|
+
[key: string]: unknown;
|
|
545
|
+
};
|
|
546
|
+
client: {
|
|
547
|
+
id: number;
|
|
548
|
+
[key: string]: unknown;
|
|
549
|
+
};
|
|
550
|
+
groups: Array<{
|
|
551
|
+
id: number;
|
|
552
|
+
[key: string]: unknown;
|
|
553
|
+
}>;
|
|
554
|
+
variables: Array<{
|
|
555
|
+
id: number;
|
|
556
|
+
[key: string]: unknown;
|
|
557
|
+
}>;
|
|
558
|
+
values: Array<{
|
|
559
|
+
id: number | string;
|
|
560
|
+
[key: string]: unknown;
|
|
561
|
+
}>;
|
|
562
|
+
articles: Array<{
|
|
563
|
+
id: number;
|
|
564
|
+
[key: string]: unknown;
|
|
565
|
+
}>;
|
|
566
|
+
prices: Array<{
|
|
567
|
+
id: number;
|
|
568
|
+
[key: string]: unknown;
|
|
569
|
+
}>;
|
|
570
|
+
materials: Array<{
|
|
571
|
+
id: number;
|
|
572
|
+
[key: string]: unknown;
|
|
573
|
+
}>;
|
|
574
|
+
models: Array<{
|
|
575
|
+
id: number;
|
|
576
|
+
[key: string]: unknown;
|
|
577
|
+
}>;
|
|
578
|
+
images: Array<{
|
|
579
|
+
id: number;
|
|
580
|
+
[key: string]: unknown;
|
|
581
|
+
}>;
|
|
582
|
+
rules: Array<{
|
|
583
|
+
id: number;
|
|
584
|
+
[key: string]: unknown;
|
|
585
|
+
}>;
|
|
586
|
+
ruleItems: Array<{
|
|
587
|
+
id: number;
|
|
588
|
+
[key: string]: unknown;
|
|
589
|
+
}>;
|
|
617
590
|
[key: string]: unknown;
|
|
618
591
|
}
|
|
619
|
-
|
|
620
|
-
// ─── Logic / Callback Extensions ────────────────────────────────────────────
|
|
621
|
-
|
|
622
|
-
export interface K3LogicExtensions {
|
|
592
|
+
interface K3LogicExtensions {
|
|
623
593
|
/** Hooks into the configuration data lifecycle (create, update, save). */
|
|
624
594
|
config?: {
|
|
625
595
|
/**
|
|
626
596
|
* Called every time the active configuration object is updated in the store (e.g. on every selection change).
|
|
627
597
|
* Return a modified copy to alter prices, codes, or any other configuration field.
|
|
628
598
|
*/
|
|
629
|
-
onUpdate?: CallbackWithDescription<
|
|
630
|
-
(config: K3Configuration) => K3Configuration
|
|
631
|
-
>;
|
|
599
|
+
onUpdate?: CallbackWithDescription<(config: K3Configuration) => K3Configuration>;
|
|
632
600
|
/**
|
|
633
601
|
* Called just before a configuration is persisted (order, cart, email, …).
|
|
634
602
|
* Return a modified copy to inject extra fields or override values before saving.
|
|
635
603
|
*/
|
|
636
|
-
onSave?: CallbackWithDescription<
|
|
637
|
-
(
|
|
638
|
-
config: K3Configuration | K3NewConfiguration,
|
|
639
|
-
) => K3Configuration | K3NewConfiguration
|
|
640
|
-
>;
|
|
604
|
+
onSave?: CallbackWithDescription<(config: K3Configuration | K3NewConfiguration) => K3Configuration | K3NewConfiguration>;
|
|
641
605
|
/**
|
|
642
606
|
* Called with the list of screenshot files that will be uploaded alongside the save.
|
|
643
607
|
* Return a modified array to add, remove, or rename files.
|
|
644
608
|
*/
|
|
645
|
-
onSaveFiles?: CallbackWithDescription<
|
|
646
|
-
(files: K3UploadFile[]) => K3UploadFile[]
|
|
647
|
-
>;
|
|
609
|
+
onSaveFiles?: CallbackWithDescription<(files: K3UploadFile[]) => K3UploadFile[]>;
|
|
648
610
|
/**
|
|
649
611
|
* Called after a successful save action with the dispatched event payload.
|
|
650
612
|
* Return a modified payload to add custom fields consumed by downstream integrations.
|
|
651
613
|
*/
|
|
652
|
-
onSaveEvent?: CallbackWithDescription<
|
|
653
|
-
(payload: K3ConfigurationSavedEvent) => K3ConfigurationSavedEvent
|
|
654
|
-
>;
|
|
614
|
+
onSaveEvent?: CallbackWithDescription<(payload: K3ConfigurationSavedEvent) => K3ConfigurationSavedEvent>;
|
|
655
615
|
};
|
|
656
616
|
/** Hooks into the camera and screenshot pipeline. */
|
|
657
617
|
camera?: {
|
|
@@ -659,23 +619,17 @@ export interface K3LogicExtensions {
|
|
|
659
619
|
* Called with the list of cameras used for automated screenshot capture.
|
|
660
620
|
* Return a modified array to add, remove, or reorder screenshot cameras.
|
|
661
621
|
*/
|
|
662
|
-
onSetScreenshotCameras?: CallbackWithDescription<
|
|
663
|
-
(cameras: K3Camera[]) => K3Camera[]
|
|
664
|
-
>;
|
|
622
|
+
onSetScreenshotCameras?: CallbackWithDescription<(cameras: K3Camera[]) => K3Camera[]>;
|
|
665
623
|
/**
|
|
666
624
|
* Called with the full list of scene cameras available in the viewer.
|
|
667
625
|
* Return a modified array to filter or reorder cameras shown in the UI.
|
|
668
626
|
*/
|
|
669
|
-
onSetCameraList?: CallbackWithDescription<
|
|
670
|
-
(cameras: K3Camera[]) => K3Camera[]
|
|
671
|
-
>;
|
|
627
|
+
onSetCameraList?: CallbackWithDescription<(cameras: K3Camera[]) => K3Camera[]>;
|
|
672
628
|
/**
|
|
673
629
|
* Called to determine the pixel dimensions used when rendering screenshots.
|
|
674
630
|
* Return modified dimensions to override the default canvas size.
|
|
675
631
|
*/
|
|
676
|
-
getScreenshotDimensions?: CallbackWithDescription<
|
|
677
|
-
(dim: K3ScreenshotDimensions) => K3ScreenshotDimensions
|
|
678
|
-
>;
|
|
632
|
+
getScreenshotDimensions?: CallbackWithDescription<(dim: K3ScreenshotDimensions) => K3ScreenshotDimensions>;
|
|
679
633
|
};
|
|
680
634
|
/** Core app lifecycle hooks. */
|
|
681
635
|
core?: {
|
|
@@ -693,19 +647,14 @@ export interface K3LogicExtensions {
|
|
|
693
647
|
* Called when the user triggers an AR export.
|
|
694
648
|
* Receives the target platform and live Three.js scene; must return a `Blob` of the AR file.
|
|
695
649
|
*/
|
|
696
|
-
onExportAR?: CallbackWithDescription<
|
|
697
|
-
(ctx: K3ARExportContext) => Promise<Blob>
|
|
698
|
-
>;
|
|
650
|
+
onExportAR?: CallbackWithDescription<(ctx: K3ARExportContext) => Promise<Blob>>;
|
|
699
651
|
};
|
|
700
652
|
}
|
|
701
|
-
|
|
702
|
-
// ─── Model Slot Types ────────────────────────────────────────────────────────
|
|
703
|
-
|
|
704
653
|
/**
|
|
705
654
|
* Declares a named slot where child models can be placed inside a parent dynamic model.
|
|
706
655
|
* Attach an array of these to `DynamicModel.slotDefinitions`.
|
|
707
656
|
*/
|
|
708
|
-
|
|
657
|
+
interface SlotDefinition {
|
|
709
658
|
/** Unique identifier (UUID) — primary key used in rule columns to reference this slot. */
|
|
710
659
|
id: string;
|
|
711
660
|
/** Human-readable name shown in the admin slot picker. */
|
|
@@ -713,14 +662,16 @@ export interface SlotDefinition {
|
|
|
713
662
|
/** Optional fallback model ID rendered when no rule assigns a model to this slot. */
|
|
714
663
|
defaultModelId?: string | number;
|
|
715
664
|
}
|
|
716
|
-
|
|
717
665
|
/**
|
|
718
666
|
* A resolved model instance placed into a slot at runtime.
|
|
719
667
|
* Received via `DynamicModelComponentProps.slots[slotId]`.
|
|
720
668
|
*/
|
|
721
|
-
|
|
669
|
+
interface SlotModelInstance {
|
|
722
670
|
/** The model data object for this slot instance. */
|
|
723
|
-
model: {
|
|
671
|
+
model: {
|
|
672
|
+
id: string | number;
|
|
673
|
+
[key: string]: unknown;
|
|
674
|
+
};
|
|
724
675
|
/** URL of the model's 3D file, or `undefined` if this is a dynamic model with a component. */
|
|
725
676
|
fileURL: string | undefined;
|
|
726
677
|
/** The React component used to render this model if it is a dynamic model otherwise `undefined`. */
|
|
@@ -744,12 +695,11 @@ export interface SlotModelInstance {
|
|
|
744
695
|
/** Recursively nested slot instances when the slotted model itself has slots. */
|
|
745
696
|
slots?: Record<string, SlotModelInstance[]>;
|
|
746
697
|
}
|
|
747
|
-
|
|
748
698
|
/**
|
|
749
699
|
* Props automatically injected into every `DynamicModel.component` at runtime.
|
|
750
700
|
* Extend this with your custom prop types: `DynamicModelComponentProps & { myProp: string }`.
|
|
751
701
|
*/
|
|
752
|
-
|
|
702
|
+
interface DynamicModelComponentProps {
|
|
753
703
|
/**
|
|
754
704
|
* Resolved child model instances keyed by slot ID.
|
|
755
705
|
* Only present when the model has `slotDefinitions` and at least one slot is filled.
|
|
@@ -757,10 +707,7 @@ export interface DynamicModelComponentProps {
|
|
|
757
707
|
slots?: Record<string, SlotModelInstance[]>;
|
|
758
708
|
[key: string]: unknown;
|
|
759
709
|
}
|
|
760
|
-
|
|
761
|
-
// ─── Legacy types (unchanged) ────────────────────────────────────────────────
|
|
762
|
-
|
|
763
|
-
export interface DynamicModel {
|
|
710
|
+
interface DynamicModel {
|
|
764
711
|
/** Unique type key used to reference this model from rule items, e.g. `"acme.my-model"`. */
|
|
765
712
|
type: string;
|
|
766
713
|
/** Human-readable display name shown in the admin model picker. */
|
|
@@ -787,19 +734,12 @@ export interface DynamicModel {
|
|
|
787
734
|
*/
|
|
788
735
|
defaultProps: {
|
|
789
736
|
slotDefinitions?: SlotDefinition[];
|
|
790
|
-
[key: string]:
|
|
791
|
-
| string
|
|
792
|
-
| number
|
|
793
|
-
| boolean
|
|
794
|
-
| ModelPropDefault
|
|
795
|
-
| undefined
|
|
796
|
-
| SlotDefinition[];
|
|
737
|
+
[key: string]: string | number | boolean | ModelPropDefault | undefined | SlotDefinition[];
|
|
797
738
|
};
|
|
798
739
|
/** Optional tag used to group or filter models in the admin UI. */
|
|
799
740
|
tag?: string;
|
|
800
741
|
}
|
|
801
|
-
|
|
802
|
-
export interface ModelProp {
|
|
742
|
+
interface ModelProp {
|
|
803
743
|
/**
|
|
804
744
|
* Editor widget type for this prop in the admin dialog.
|
|
805
745
|
* `"basic"` — plain text/number input.
|
|
@@ -815,30 +755,26 @@ export interface ModelProp {
|
|
|
815
755
|
/** For type="model": allow selecting multiple models. */
|
|
816
756
|
multiple?: boolean;
|
|
817
757
|
}
|
|
818
|
-
|
|
819
758
|
/** All variable type string literals. */
|
|
820
|
-
|
|
821
|
-
List: "list"
|
|
822
|
-
Color: "color"
|
|
823
|
-
Number: "number"
|
|
824
|
-
Text: "text"
|
|
825
|
-
MultiSelect: "multiSelect"
|
|
826
|
-
Boolean: "boolean"
|
|
827
|
-
Image: "image"
|
|
828
|
-
Upload: "upload"
|
|
829
|
-
Components: "components"
|
|
830
|
-
Information: "information"
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
export interface ModelPropDefault {
|
|
759
|
+
declare const VariableType: {
|
|
760
|
+
readonly List: "list";
|
|
761
|
+
readonly Color: "color";
|
|
762
|
+
readonly Number: "number";
|
|
763
|
+
readonly Text: "text";
|
|
764
|
+
readonly MultiSelect: "multiSelect";
|
|
765
|
+
readonly Boolean: "boolean";
|
|
766
|
+
readonly Image: "image";
|
|
767
|
+
readonly Upload: "upload";
|
|
768
|
+
readonly Components: "components";
|
|
769
|
+
readonly Information: "information";
|
|
770
|
+
};
|
|
771
|
+
type VariableTypes = (typeof VariableType)[keyof typeof VariableType];
|
|
772
|
+
interface ModelPropDefault {
|
|
836
773
|
/** An expression string evaluated at runtime instead of a static value (e.g. `"group.width * 2"`). */
|
|
837
774
|
expression?: string;
|
|
838
775
|
}
|
|
839
|
-
|
|
840
776
|
/** K3 Value object (list / color / boolean selection). */
|
|
841
|
-
|
|
777
|
+
interface Value {
|
|
842
778
|
/** Unique database ID of the value. */
|
|
843
779
|
id: number | string;
|
|
844
780
|
/** Optional stable string key for the value, usable as an alternative identifier. */
|
|
@@ -848,16 +784,16 @@ export interface Value {
|
|
|
848
784
|
/** Human-readable display label shown in the configurator UI. */
|
|
849
785
|
label: string;
|
|
850
786
|
}
|
|
851
|
-
|
|
852
787
|
/**
|
|
853
788
|
* Context passed to plugin dynamic model components at runtime.
|
|
854
789
|
*/
|
|
855
|
-
|
|
790
|
+
interface PluginModelContext {
|
|
856
791
|
/** Only set during screenshot rendering. */
|
|
857
792
|
screenshotCameraName?: string;
|
|
858
793
|
/** The unique ID of the model action this instance is rendered for. */
|
|
859
794
|
modelActionId?: string;
|
|
860
795
|
}
|
|
861
|
-
|
|
862
796
|
/** @deprecated Use K3PluginDescriptor */
|
|
863
|
-
|
|
797
|
+
type K3Plugin = Pick<K3PluginDescriptor, "dynamicModels">;
|
|
798
|
+
//#endregion
|
|
799
|
+
export { CallbackWithDescription, CustomLayoutComponentProps, DynamicModel, DynamicModelComponentProps, HOC, HOCWithDescription, K3ARExportContext, K3ARPlatform, K3BomEntry, K3Camera, K3CameraScope, K3Configuration, K3ConfigurationSavedEvent, K3Coordinates, K3DialogExtensions, K3FullApp, K3InputExtensions, K3LayoutExtensions, K3LogicExtensions, K3NewConfiguration, K3OrderDialogExtensions, K3OrthographicCamera, K3PerspectiveCamera, K3Plugin, K3PluginDescriptor, K3SaveResult, K3Scene, K3ScreenshotDimensions, K3Selection, K3UIExtensions, K3UploadFile, K3VariableComponentProps, K3ViewerExtensions, K3WarningExtensions, LocalizedString, ModelProp, ModelPropDefault, PluginModelContext, SlotDefinition, SlotModelInstance, Value, VariableType, VariableTypes, VariableVisualisation, getSettings, init, useK3PluginSettings };
|