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