k3-plugin-api 1.4.5 → 1.6.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/README.md +70 -30
- package/dist/index.cjs +175 -0
- package/{index.ts → dist/index.d.cts} +284 -202
- package/dist/index.d.ts +794 -656
- package/dist/index.js +165 -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,121 @@ 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;
|
|
36
|
+
/**
|
|
37
|
+
* Reactive hook – returns all current configuration variables as a key-value map.
|
|
38
|
+
* Keys are the variable's stable `key` string. Values are resolved (labels, not raw IDs).
|
|
39
|
+
* Re-renders whenever any selection changes.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const variables = useConfigurationVariables();
|
|
44
|
+
* const color = variables["color"] as K3SimplifiedValue;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function useConfigurationVariables(): K3ConfigurationVariables;
|
|
48
|
+
/**
|
|
49
|
+
* Reactive hook – returns the resolved value for a specific variable by its key,
|
|
50
|
+
* or `undefined` if the variable has no active selection.
|
|
51
|
+
*
|
|
52
|
+
* @param variableKey - The stable key of the variable (as defined in the admin)
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const width = useConfigurationVariable("width") as number;
|
|
57
|
+
* const material = useConfigurationVariable("material") as K3SimplifiedValue;
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function useConfigurationVariable(variableKey: string): K3ConfigurationVariableEntry | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Reactive hook – returns the current Bill of Materials (Stückliste).
|
|
63
|
+
* Re-renders whenever the BOM changes (i.e. on any selection change).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const bom = useBOM() as K3BomEntry[];
|
|
68
|
+
* const total = bom.reduce((sum, e) => sum + e.price.price * e.qty, 0);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function useBOM(): K3BomEntry[];
|
|
72
|
+
/**
|
|
73
|
+
* Reactive hook – returns the current total price as a raw number.
|
|
74
|
+
* Re-renders whenever the price changes.
|
|
75
|
+
*/
|
|
76
|
+
declare function useTotalPrice(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Reactive hook – returns the current total price formatted as a locale string
|
|
79
|
+
* (e.g. `"1.299,00 €"`), ready for display.
|
|
80
|
+
* Re-renders whenever the price changes.
|
|
81
|
+
*/
|
|
82
|
+
declare function useFormattedTotalPrice(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Reactive hook – returns the current K3 app metadata, including the booked
|
|
85
|
+
* product identifier. Returns `null` while the app has not yet loaded.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const app = useApp() as K3AppInfo | null;
|
|
90
|
+
* if (app?.product === "k3-pro") {
|
|
91
|
+
* // enable pro-only features
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare function useApp(): K3AppInfo | null;
|
|
35
96
|
/**
|
|
36
97
|
* Called by K3 when the plugin is loaded to inject runtime API functions.
|
|
37
98
|
* @internal This function is called by K3 automatically - plugins should not call it directly.
|
|
38
99
|
*/
|
|
39
|
-
|
|
100
|
+
declare function init(api: {
|
|
40
101
|
getSettings: (pluginId: string) => unknown;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
102
|
+
usePluginSettings: (pluginId: string) => unknown;
|
|
103
|
+
useConfigurationVariables: () => K3ConfigurationVariables;
|
|
104
|
+
useConfigurationVariable: (variableKey: string) => K3ConfigurationVariableEntry | undefined;
|
|
105
|
+
useBOM: () => unknown[];
|
|
106
|
+
useTotalPrice: () => number;
|
|
107
|
+
useFormattedTotalPrice: () => string;
|
|
108
|
+
useApp: () => unknown | null;
|
|
109
|
+
}): void;
|
|
47
110
|
/** A Higher-Order Component: takes the default component, returns a new one. */
|
|
48
|
-
|
|
49
|
-
comp: React.FC<P>,
|
|
50
|
-
) => React.FC<P>;
|
|
51
|
-
|
|
111
|
+
type HOC<P = Record<string, unknown>> = (comp: React.FC<P>) => React.FC<P>;
|
|
52
112
|
/** Four editor languages supported by K3. */
|
|
53
|
-
|
|
113
|
+
type LocalizedString = {
|
|
54
114
|
de?: string;
|
|
55
115
|
en?: string;
|
|
56
116
|
nl?: string;
|
|
57
117
|
fr?: string;
|
|
58
118
|
};
|
|
59
|
-
|
|
60
119
|
/** An HOC slot with a required description for the admin UI. */
|
|
61
|
-
|
|
120
|
+
interface HOCWithDescription<P = Record<string, unknown>> {
|
|
62
121
|
hoc: HOC<P>;
|
|
63
122
|
/** Describe what this extension point does. Shown in the plugin extensions dialog. */
|
|
64
123
|
description: string | LocalizedString;
|
|
65
124
|
}
|
|
66
|
-
|
|
67
125
|
/** A logic callback with a required description for the admin UI. */
|
|
68
|
-
|
|
126
|
+
interface CallbackWithDescription<T> {
|
|
69
127
|
fn: T;
|
|
70
128
|
/** Describe what this callback does. Shown in the plugin extensions dialog. */
|
|
71
129
|
description: string | LocalizedString;
|
|
72
130
|
}
|
|
73
|
-
|
|
74
|
-
// ─── Public Plugin Descriptor ───────────────────────────────────────────────
|
|
75
|
-
|
|
76
|
-
export interface K3PluginDescriptor {
|
|
131
|
+
interface K3PluginDescriptor {
|
|
77
132
|
/** Unique stable identifier, e.g. "vendor.myplugin". Required for collision detection. */
|
|
78
133
|
id: string;
|
|
79
134
|
/** Semver string, e.g. "1.0.0". */
|
|
80
135
|
version: string;
|
|
81
|
-
|
|
82
136
|
/** UI extension points: layout HOCs, input HOCs, dialog HOCs. */
|
|
83
137
|
ui?: K3UIExtensions;
|
|
84
138
|
/** Viewer / 3D extension points: canvas, scene components, layout components, dynamic models. */
|
|
@@ -89,14 +143,10 @@ export interface K3PluginDescriptor {
|
|
|
89
143
|
settings: unknown;
|
|
90
144
|
onSave: (settings: unknown) => void;
|
|
91
145
|
}>;
|
|
92
|
-
|
|
93
146
|
/** @deprecated Use viewer.models instead. */
|
|
94
147
|
dynamicModels?: DynamicModel[];
|
|
95
148
|
}
|
|
96
|
-
|
|
97
|
-
// ─── UI Extensions ──────────────────────────────────────────────────────────
|
|
98
|
-
|
|
99
|
-
export interface K3UIExtensions {
|
|
149
|
+
interface K3UIExtensions {
|
|
100
150
|
/** Override layout shell components. */
|
|
101
151
|
layout?: K3LayoutExtensions;
|
|
102
152
|
/** Register new variable visualisations (renderers) per variable data type. */
|
|
@@ -104,8 +154,7 @@ export interface K3UIExtensions {
|
|
|
104
154
|
/** Override dialog components. */
|
|
105
155
|
dialogs?: K3DialogExtensions;
|
|
106
156
|
}
|
|
107
|
-
|
|
108
|
-
export interface K3LayoutExtensions {
|
|
157
|
+
interface K3LayoutExtensions {
|
|
109
158
|
/** Wraps the outermost app shell component. */
|
|
110
159
|
root?: HOCWithDescription;
|
|
111
160
|
/** Wraps the top header bar containing branding, navigation buttons, and scene controls. */
|
|
@@ -155,12 +204,11 @@ export interface K3LayoutExtensions {
|
|
|
155
204
|
/** Wraps each individual variable label inside a group panel. */
|
|
156
205
|
variableLabel?: HOCWithDescription;
|
|
157
206
|
}
|
|
158
|
-
|
|
159
207
|
/**
|
|
160
208
|
* Props passed to a plugin variable component (VariableVisualisation.component) at runtime.
|
|
161
209
|
* Use these to render a fully custom variable input UI.
|
|
162
210
|
*/
|
|
163
|
-
|
|
211
|
+
interface K3VariableComponentProps {
|
|
164
212
|
/** The variable definition for which this component is rendered. */
|
|
165
213
|
variable: {
|
|
166
214
|
/** Database ID of the variable. */
|
|
@@ -207,20 +255,18 @@ export interface K3VariableComponentProps {
|
|
|
207
255
|
* Number variables: onChange(values[0].id, { inputValue: numericValue })
|
|
208
256
|
* List/color/boolean: onChange(value.id)
|
|
209
257
|
*/
|
|
210
|
-
onChange: (
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
) => void;
|
|
258
|
+
onChange: (valueId: string | number, metadata?: {
|
|
259
|
+
inputValue?: number;
|
|
260
|
+
}) => void;
|
|
214
261
|
/** When `true`, the variable is locked and user interaction should be blocked. */
|
|
215
262
|
disabled?: boolean;
|
|
216
263
|
}
|
|
217
|
-
|
|
218
264
|
/**
|
|
219
265
|
* A plugin-registered variable renderer (VariableVisualisation).
|
|
220
266
|
* Displayed as a selectable option in the admin visualisation chooser.
|
|
221
267
|
* The component owns its full UI — label, input, chrome.
|
|
222
268
|
*/
|
|
223
|
-
|
|
269
|
+
interface VariableVisualisation {
|
|
224
270
|
/**
|
|
225
271
|
* Globally unique template key, e.g. "acme.mySlider".
|
|
226
272
|
* Set variable.settings.template = this key to use this visualisation.
|
|
@@ -234,8 +280,7 @@ export interface VariableVisualisation {
|
|
|
234
280
|
/** Full variable renderer component. Receives K3VariableComponentProps. */
|
|
235
281
|
component: React.ComponentType<K3VariableComponentProps>;
|
|
236
282
|
}
|
|
237
|
-
|
|
238
|
-
export interface K3InputExtensions {
|
|
283
|
+
interface K3InputExtensions {
|
|
239
284
|
/** Register new visualisations for list-type variables. */
|
|
240
285
|
list?: VariableVisualisation[];
|
|
241
286
|
/** Register new visualisations for color-type variables. */
|
|
@@ -255,15 +300,13 @@ export interface K3InputExtensions {
|
|
|
255
300
|
/** Register new visualisations for information-type variables. */
|
|
256
301
|
information?: VariableVisualisation[];
|
|
257
302
|
}
|
|
258
|
-
|
|
259
|
-
export interface K3DialogExtensions {
|
|
303
|
+
interface K3DialogExtensions {
|
|
260
304
|
/** Extension points for the order / summary dialog (contact form, price table, confirmation). */
|
|
261
305
|
order?: K3OrderDialogExtensions;
|
|
262
306
|
/** Extension points for inline selection-warning components shown in the sidebar. */
|
|
263
307
|
warnings?: K3WarningExtensions;
|
|
264
308
|
}
|
|
265
|
-
|
|
266
|
-
export interface K3OrderDialogExtensions {
|
|
309
|
+
interface K3OrderDialogExtensions {
|
|
267
310
|
/** Wraps the entire order dialog modal. */
|
|
268
311
|
root?: HOCWithDescription;
|
|
269
312
|
/** Wraps the dialog headline / title element. */
|
|
@@ -283,8 +326,7 @@ export interface K3OrderDialogExtensions {
|
|
|
283
326
|
/** Wraps the error confirmation screen shown after a failed order submission. */
|
|
284
327
|
confirmationError?: HOCWithDescription;
|
|
285
328
|
}
|
|
286
|
-
|
|
287
|
-
export interface K3WarningExtensions {
|
|
329
|
+
interface K3WarningExtensions {
|
|
288
330
|
/** Wraps the full invalid-selection warning component (red badge next to a variable value). */
|
|
289
331
|
invalidSelection?: HOCWithDescription;
|
|
290
332
|
/** Wraps the icon inside the invalid-selection warning. */
|
|
@@ -294,14 +336,65 @@ export interface K3WarningExtensions {
|
|
|
294
336
|
/** Wraps the tooltip content shown when a number variable value is out of bounds. */
|
|
295
337
|
numberWarningTooltip?: HOCWithDescription;
|
|
296
338
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Simplified app metadata exposed to plugins.
|
|
341
|
+
* Useful for reading the booked product and subscription info.
|
|
342
|
+
*/
|
|
343
|
+
interface K3AppInfo {
|
|
344
|
+
/** Database ID of the app. */
|
|
345
|
+
id: number;
|
|
346
|
+
/** Human-readable app label. */
|
|
347
|
+
label: string;
|
|
348
|
+
/** Unique stable app code. */
|
|
349
|
+
code: string;
|
|
350
|
+
/**
|
|
351
|
+
* Identifier of the booked product (e.g. `"k3-pro"`).
|
|
352
|
+
* Use this to conditionally enable features based on the customer's plan.
|
|
353
|
+
*/
|
|
354
|
+
product?: string;
|
|
355
|
+
/** Subscription billing interval for this app. */
|
|
356
|
+
interval?: "month" | "year";
|
|
357
|
+
/** Feature flags of the currently booked product. */
|
|
358
|
+
productDetails?: Record<string, unknown>;
|
|
359
|
+
[key: string]: unknown;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* A resolved value option (list, color, boolean, image, upload, multiSelect).
|
|
363
|
+
* Contains human-readable labels and the underlying data value.
|
|
364
|
+
*/
|
|
365
|
+
interface K3SimplifiedValue {
|
|
366
|
+
/** Database ID of the value. */
|
|
367
|
+
id: number | string;
|
|
368
|
+
/** Stable key of the value, if defined. */
|
|
369
|
+
key?: string | null;
|
|
370
|
+
/** Translated display label. */
|
|
371
|
+
label: string;
|
|
372
|
+
/** Underlying data: hex color string, boolean flag, or generic string payload. */
|
|
373
|
+
value?: string | boolean | null;
|
|
374
|
+
/** Thumbnail image URL. */
|
|
375
|
+
thumbnail?: string | null;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A single configuration variable entry. The concrete type depends on the variable type:
|
|
379
|
+
* - Number variables → `number`
|
|
380
|
+
* - Text variables → `string`
|
|
381
|
+
* - List / Color / Boolean / Image / Upload → `K3SimplifiedValue`
|
|
382
|
+
* - MultiSelect → `K3SimplifiedValue[]`
|
|
383
|
+
* - Component variables → `K3ComponentInstanceVariables[]` (recursive)
|
|
384
|
+
*/
|
|
385
|
+
type K3ConfigurationVariableEntry = number | string | K3SimplifiedValue | K3SimplifiedValue[] | K3ComponentInstanceVariables[];
|
|
386
|
+
/** A single component instance's variables, keyed by variable key. */
|
|
387
|
+
type K3ComponentInstanceVariables = Record<string, K3ConfigurationVariableEntry>;
|
|
388
|
+
/**
|
|
389
|
+
* The full configuration variables map, keyed by the variable's stable `key` string.
|
|
390
|
+
* Returned by `useConfigurationVariables()`.
|
|
391
|
+
*/
|
|
392
|
+
type K3ConfigurationVariables = Record<string, K3ConfigurationVariableEntry>;
|
|
300
393
|
/**
|
|
301
394
|
* A single Bill-of-Materials entry exposed to plugin components.
|
|
302
395
|
* Mirrors the internal BOMEntry shape using only primitive/simple types.
|
|
303
396
|
*/
|
|
304
|
-
|
|
397
|
+
interface K3BomEntry {
|
|
305
398
|
article: {
|
|
306
399
|
id: number;
|
|
307
400
|
/** Article number as defined in the K3 admin. */
|
|
@@ -316,18 +409,20 @@ export interface K3BomEntry {
|
|
|
316
409
|
/** Optional override quantity from the article amount modal. */
|
|
317
410
|
amount?: number | null;
|
|
318
411
|
/** Price of a single unit of this article. */
|
|
319
|
-
price: {
|
|
412
|
+
price: {
|
|
413
|
+
price: number;
|
|
414
|
+
unit?: string;
|
|
415
|
+
};
|
|
320
416
|
/** Whether this is a main article (`true`) or an accessory/surcharge (`false`). */
|
|
321
417
|
main?: boolean;
|
|
322
418
|
}
|
|
323
|
-
|
|
324
419
|
/**
|
|
325
420
|
* Props automatically injected into every `customLayoutComponents` entry.
|
|
326
421
|
*
|
|
327
422
|
* @remarks TODO(WIP) — This interface will grow as more configurator data is
|
|
328
423
|
* exposed to plugins.
|
|
329
424
|
*/
|
|
330
|
-
|
|
425
|
+
interface CustomLayoutComponentProps {
|
|
331
426
|
/** The slot name this component was mounted under. */
|
|
332
427
|
name: string;
|
|
333
428
|
/**
|
|
@@ -343,8 +438,7 @@ export interface CustomLayoutComponentProps {
|
|
|
343
438
|
/** Any additional props forwarded by the layout. */
|
|
344
439
|
[key: string]: unknown;
|
|
345
440
|
}
|
|
346
|
-
|
|
347
|
-
export interface K3ViewerExtensions {
|
|
441
|
+
interface K3ViewerExtensions {
|
|
348
442
|
/** Wraps the root Three.js / R3F canvas element. */
|
|
349
443
|
canvas?: HOCWithDescription;
|
|
350
444
|
/**
|
|
@@ -354,11 +448,7 @@ export interface K3ViewerExtensions {
|
|
|
354
448
|
*
|
|
355
449
|
* Components receive {@link CustomLayoutComponentProps} with BOM and total price data.
|
|
356
450
|
*/
|
|
357
|
-
|
|
358
|
-
customLayoutComponents?: Record<
|
|
359
|
-
string,
|
|
360
|
-
React.ComponentType<CustomLayoutComponentProps>
|
|
361
|
-
>;
|
|
451
|
+
customLayoutComponents?: Record<string, React.ComponentType<CustomLayoutComponentProps>>;
|
|
362
452
|
/** Dynamic 3D model definitions contributed by this plugin. Equivalent to the top-level `dynamicModels`. */
|
|
363
453
|
models?: DynamicModel[];
|
|
364
454
|
/** Override the label / hotspot overlay components rendered on the 3D canvas. */
|
|
@@ -369,21 +459,20 @@ export interface K3ViewerExtensions {
|
|
|
369
459
|
mobile?: HOCWithDescription;
|
|
370
460
|
};
|
|
371
461
|
}
|
|
372
|
-
|
|
373
|
-
// ─── Logic Callback Types ────────────────────────────────────────────────────
|
|
374
|
-
|
|
375
462
|
/** [x, y, z] coordinate tuple used on camera objects. */
|
|
376
|
-
|
|
377
|
-
|
|
463
|
+
type K3Coordinates = [number, number, number];
|
|
378
464
|
/**
|
|
379
465
|
* Restricts a camera to a specific configurator context.
|
|
380
466
|
* `"group"` / `"variable"` — camera activates only when that item is in view; `id` is the entity's database ID.
|
|
381
467
|
* `"general"` — camera is always available regardless of the active group or variable.
|
|
382
468
|
*/
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
469
|
+
type K3CameraScope = {
|
|
470
|
+
type: "group" | "variable";
|
|
471
|
+
id: number;
|
|
472
|
+
} | {
|
|
473
|
+
type: "general";
|
|
474
|
+
id?: null;
|
|
475
|
+
};
|
|
387
476
|
interface K3BaseCamera {
|
|
388
477
|
/** Unique database ID of the camera record. */
|
|
389
478
|
id: string;
|
|
@@ -396,7 +485,10 @@ interface K3BaseCamera {
|
|
|
396
485
|
/** Euler rotation [x, y, z] in radians. */
|
|
397
486
|
rotation: K3Coordinates;
|
|
398
487
|
/** Optional override for the screenshot render resolution in pixels. */
|
|
399
|
-
resolution?: {
|
|
488
|
+
resolution?: {
|
|
489
|
+
width: number;
|
|
490
|
+
height: number;
|
|
491
|
+
};
|
|
400
492
|
/** Transition easing threshold used by the camera animation driver. */
|
|
401
493
|
threshold?: number;
|
|
402
494
|
/**
|
|
@@ -411,16 +503,19 @@ interface K3BaseCamera {
|
|
|
411
503
|
zoom?: number;
|
|
412
504
|
[key: string]: unknown;
|
|
413
505
|
}
|
|
414
|
-
|
|
415
506
|
/** A perspective camera configured in the K3 scene editor. */
|
|
416
|
-
|
|
507
|
+
interface K3PerspectiveCamera extends K3BaseCamera {
|
|
417
508
|
type: "PerspectiveCamera";
|
|
418
509
|
/** Intrinsic perspective parameters: field-of-view in degrees, aspect ratio, near/far clip planes. */
|
|
419
|
-
baseSettings?: {
|
|
510
|
+
baseSettings?: {
|
|
511
|
+
fov: number;
|
|
512
|
+
aspect: number;
|
|
513
|
+
near: number;
|
|
514
|
+
far: number;
|
|
515
|
+
};
|
|
420
516
|
}
|
|
421
|
-
|
|
422
517
|
/** An orthographic camera configured in the K3 scene editor. */
|
|
423
|
-
|
|
518
|
+
interface K3OrthographicCamera extends K3BaseCamera {
|
|
424
519
|
type: "OrthographicCamera";
|
|
425
520
|
/** Intrinsic orthographic parameters: frustum left/right/top/bottom extents and near/far clip planes. */
|
|
426
521
|
baseSettings?: {
|
|
@@ -432,24 +527,20 @@ export interface K3OrthographicCamera extends K3BaseCamera {
|
|
|
432
527
|
far: number;
|
|
433
528
|
};
|
|
434
529
|
}
|
|
435
|
-
|
|
436
530
|
/** A scene camera — perspective or orthographic. Passed to screenshot / camera-list callbacks. */
|
|
437
|
-
|
|
438
|
-
|
|
531
|
+
type K3Camera = K3PerspectiveCamera | K3OrthographicCamera;
|
|
439
532
|
/** Pixel dimensions used for screenshot rendering. */
|
|
440
|
-
|
|
533
|
+
interface K3ScreenshotDimensions {
|
|
441
534
|
width: number;
|
|
442
535
|
height: number;
|
|
443
536
|
}
|
|
444
|
-
|
|
445
537
|
/** AR platform identifier. */
|
|
446
|
-
|
|
447
|
-
|
|
538
|
+
type K3ARPlatform = "iOS" | "AndroidOS";
|
|
448
539
|
/**
|
|
449
540
|
* Minimal structural representation of a Three.js scene graph node.
|
|
450
541
|
* Cast to `import("three").Object3D` for full Three.js access.
|
|
451
542
|
*/
|
|
452
|
-
|
|
543
|
+
interface K3Scene {
|
|
453
544
|
/** Three.js object type string, e.g. `"Scene"`, `"Mesh"`, `"Group"`. */
|
|
454
545
|
type: string;
|
|
455
546
|
/** Direct child nodes of this scene graph node. */
|
|
@@ -459,9 +550,8 @@ export interface K3Scene {
|
|
|
459
550
|
traverse(callback: (object: K3Scene) => void): void;
|
|
460
551
|
getObjectByName(name: string): K3Scene | undefined;
|
|
461
552
|
}
|
|
462
|
-
|
|
463
553
|
/** Context passed to `core.onExportAR`. */
|
|
464
|
-
|
|
554
|
+
interface K3ARExportContext {
|
|
465
555
|
/** Platform the AR export is targeting. */
|
|
466
556
|
platform: K3ARPlatform;
|
|
467
557
|
/**
|
|
@@ -470,9 +560,8 @@ export interface K3ARExportContext {
|
|
|
470
560
|
*/
|
|
471
561
|
scene: K3Scene;
|
|
472
562
|
}
|
|
473
|
-
|
|
474
563
|
/** An uploaded file in a save operation (e.g. a screenshot per camera). */
|
|
475
|
-
|
|
564
|
+
interface K3UploadFile {
|
|
476
565
|
/** Camera name or custom key identifying this file. */
|
|
477
566
|
key: string;
|
|
478
567
|
/** The file data. */
|
|
@@ -480,9 +569,8 @@ export interface K3UploadFile {
|
|
|
480
569
|
/** Optional explicit file name. */
|
|
481
570
|
fileName?: string;
|
|
482
571
|
}
|
|
483
|
-
|
|
484
572
|
/** Result returned to `core.onOpenPdf` after a save/order action. */
|
|
485
|
-
|
|
573
|
+
interface K3SaveResult {
|
|
486
574
|
/** Generated configuration code. */
|
|
487
575
|
code?: string;
|
|
488
576
|
/** Pricing verification info. */
|
|
@@ -503,12 +591,11 @@ export interface K3SaveResult {
|
|
|
503
591
|
pdfName?: string;
|
|
504
592
|
[key: string]: unknown;
|
|
505
593
|
}
|
|
506
|
-
|
|
507
594
|
/**
|
|
508
595
|
* Payload dispatched when a configuration is saved (e.g. "order", "cart", "pdf").
|
|
509
596
|
* Passed to `config.onSaveEvent`.
|
|
510
597
|
*/
|
|
511
|
-
|
|
598
|
+
interface K3ConfigurationSavedEvent {
|
|
512
599
|
type: "K3ConfigurationSaved";
|
|
513
600
|
/** Save action key, e.g. "cart", "pdf", "email". */
|
|
514
601
|
actionKey: string;
|
|
@@ -523,9 +610,8 @@ export interface K3ConfigurationSavedEvent {
|
|
|
523
610
|
};
|
|
524
611
|
[key: string]: unknown;
|
|
525
612
|
}
|
|
526
|
-
|
|
527
613
|
/** A persisted configuration object. Passed to `config.onUpdate` and `config.onSave`. */
|
|
528
|
-
|
|
614
|
+
interface K3Configuration {
|
|
529
615
|
/** Database ID of the saved configuration record. */
|
|
530
616
|
id: number | string;
|
|
531
617
|
/** ID of the K3 app this configuration belongs to. */
|
|
@@ -550,12 +636,10 @@ export interface K3Configuration {
|
|
|
550
636
|
files: Record<string, Record<string, string>>;
|
|
551
637
|
[key: string]: unknown;
|
|
552
638
|
}
|
|
553
|
-
|
|
554
639
|
/** A configuration not yet persisted (no `id` or `code`). */
|
|
555
|
-
|
|
556
|
-
|
|
640
|
+
type K3NewConfiguration = Omit<K3Configuration, "id" | "code">;
|
|
557
641
|
/** An individual variable selection state. */
|
|
558
|
-
|
|
642
|
+
interface K3Selection {
|
|
559
643
|
/** Unique selection ID. */
|
|
560
644
|
id: string;
|
|
561
645
|
/** ID of the variable this selection belongs to. */
|
|
@@ -573,59 +657,81 @@ export interface K3Selection {
|
|
|
573
657
|
};
|
|
574
658
|
[key: string]: unknown;
|
|
575
659
|
}
|
|
576
|
-
|
|
577
660
|
/** 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
|
-
|
|
661
|
+
interface K3FullApp {
|
|
662
|
+
app: {
|
|
663
|
+
id: number;
|
|
664
|
+
[key: string]: unknown;
|
|
665
|
+
};
|
|
666
|
+
client: {
|
|
667
|
+
id: number;
|
|
668
|
+
[key: string]: unknown;
|
|
669
|
+
};
|
|
670
|
+
groups: Array<{
|
|
671
|
+
id: number;
|
|
672
|
+
[key: string]: unknown;
|
|
673
|
+
}>;
|
|
674
|
+
variables: Array<{
|
|
675
|
+
id: number;
|
|
676
|
+
[key: string]: unknown;
|
|
677
|
+
}>;
|
|
678
|
+
values: Array<{
|
|
679
|
+
id: number | string;
|
|
680
|
+
[key: string]: unknown;
|
|
681
|
+
}>;
|
|
682
|
+
articles: Array<{
|
|
683
|
+
id: number;
|
|
684
|
+
[key: string]: unknown;
|
|
685
|
+
}>;
|
|
686
|
+
prices: Array<{
|
|
687
|
+
id: number;
|
|
688
|
+
[key: string]: unknown;
|
|
689
|
+
}>;
|
|
690
|
+
materials: Array<{
|
|
691
|
+
id: number;
|
|
692
|
+
[key: string]: unknown;
|
|
693
|
+
}>;
|
|
694
|
+
models: Array<{
|
|
695
|
+
id: number;
|
|
696
|
+
[key: string]: unknown;
|
|
697
|
+
}>;
|
|
698
|
+
images: Array<{
|
|
699
|
+
id: number;
|
|
700
|
+
[key: string]: unknown;
|
|
701
|
+
}>;
|
|
702
|
+
rules: Array<{
|
|
703
|
+
id: number;
|
|
704
|
+
[key: string]: unknown;
|
|
705
|
+
}>;
|
|
706
|
+
ruleItems: Array<{
|
|
707
|
+
id: number;
|
|
708
|
+
[key: string]: unknown;
|
|
709
|
+
}>;
|
|
591
710
|
[key: string]: unknown;
|
|
592
711
|
}
|
|
593
|
-
|
|
594
|
-
// ─── Logic / Callback Extensions ────────────────────────────────────────────
|
|
595
|
-
|
|
596
|
-
export interface K3LogicExtensions {
|
|
712
|
+
interface K3LogicExtensions {
|
|
597
713
|
/** Hooks into the configuration data lifecycle (create, update, save). */
|
|
598
714
|
config?: {
|
|
599
715
|
/**
|
|
600
716
|
* Called every time the active configuration object is updated in the store (e.g. on every selection change).
|
|
601
717
|
* Return a modified copy to alter prices, codes, or any other configuration field.
|
|
602
718
|
*/
|
|
603
|
-
onUpdate?: CallbackWithDescription<
|
|
604
|
-
(config: K3Configuration) => K3Configuration
|
|
605
|
-
>;
|
|
719
|
+
onUpdate?: CallbackWithDescription<(config: K3Configuration) => K3Configuration>;
|
|
606
720
|
/**
|
|
607
721
|
* Called just before a configuration is persisted (order, cart, email, …).
|
|
608
722
|
* Return a modified copy to inject extra fields or override values before saving.
|
|
609
723
|
*/
|
|
610
|
-
onSave?: CallbackWithDescription<
|
|
611
|
-
(
|
|
612
|
-
config: K3Configuration | K3NewConfiguration,
|
|
613
|
-
) => K3Configuration | K3NewConfiguration
|
|
614
|
-
>;
|
|
724
|
+
onSave?: CallbackWithDescription<(config: K3Configuration | K3NewConfiguration) => K3Configuration | K3NewConfiguration>;
|
|
615
725
|
/**
|
|
616
726
|
* Called with the list of screenshot files that will be uploaded alongside the save.
|
|
617
727
|
* Return a modified array to add, remove, or rename files.
|
|
618
728
|
*/
|
|
619
|
-
onSaveFiles?: CallbackWithDescription<
|
|
620
|
-
(files: K3UploadFile[]) => K3UploadFile[]
|
|
621
|
-
>;
|
|
729
|
+
onSaveFiles?: CallbackWithDescription<(files: K3UploadFile[]) => K3UploadFile[]>;
|
|
622
730
|
/**
|
|
623
731
|
* Called after a successful save action with the dispatched event payload.
|
|
624
732
|
* Return a modified payload to add custom fields consumed by downstream integrations.
|
|
625
733
|
*/
|
|
626
|
-
onSaveEvent?: CallbackWithDescription<
|
|
627
|
-
(payload: K3ConfigurationSavedEvent) => K3ConfigurationSavedEvent
|
|
628
|
-
>;
|
|
734
|
+
onSaveEvent?: CallbackWithDescription<(payload: K3ConfigurationSavedEvent) => K3ConfigurationSavedEvent>;
|
|
629
735
|
};
|
|
630
736
|
/** Hooks into the camera and screenshot pipeline. */
|
|
631
737
|
camera?: {
|
|
@@ -633,23 +739,17 @@ export interface K3LogicExtensions {
|
|
|
633
739
|
* Called with the list of cameras used for automated screenshot capture.
|
|
634
740
|
* Return a modified array to add, remove, or reorder screenshot cameras.
|
|
635
741
|
*/
|
|
636
|
-
onSetScreenshotCameras?: CallbackWithDescription<
|
|
637
|
-
(cameras: K3Camera[]) => K3Camera[]
|
|
638
|
-
>;
|
|
742
|
+
onSetScreenshotCameras?: CallbackWithDescription<(cameras: K3Camera[]) => K3Camera[]>;
|
|
639
743
|
/**
|
|
640
744
|
* Called with the full list of scene cameras available in the viewer.
|
|
641
745
|
* Return a modified array to filter or reorder cameras shown in the UI.
|
|
642
746
|
*/
|
|
643
|
-
onSetCameraList?: CallbackWithDescription<
|
|
644
|
-
(cameras: K3Camera[]) => K3Camera[]
|
|
645
|
-
>;
|
|
747
|
+
onSetCameraList?: CallbackWithDescription<(cameras: K3Camera[]) => K3Camera[]>;
|
|
646
748
|
/**
|
|
647
749
|
* Called to determine the pixel dimensions used when rendering screenshots.
|
|
648
750
|
* Return modified dimensions to override the default canvas size.
|
|
649
751
|
*/
|
|
650
|
-
getScreenshotDimensions?: CallbackWithDescription<
|
|
651
|
-
(dim: K3ScreenshotDimensions) => K3ScreenshotDimensions
|
|
652
|
-
>;
|
|
752
|
+
getScreenshotDimensions?: CallbackWithDescription<(dim: K3ScreenshotDimensions) => K3ScreenshotDimensions>;
|
|
653
753
|
};
|
|
654
754
|
/** Core app lifecycle hooks. */
|
|
655
755
|
core?: {
|
|
@@ -667,19 +767,14 @@ export interface K3LogicExtensions {
|
|
|
667
767
|
* Called when the user triggers an AR export.
|
|
668
768
|
* Receives the target platform and live Three.js scene; must return a `Blob` of the AR file.
|
|
669
769
|
*/
|
|
670
|
-
onExportAR?: CallbackWithDescription<
|
|
671
|
-
(ctx: K3ARExportContext) => Promise<Blob>
|
|
672
|
-
>;
|
|
770
|
+
onExportAR?: CallbackWithDescription<(ctx: K3ARExportContext) => Promise<Blob>>;
|
|
673
771
|
};
|
|
674
772
|
}
|
|
675
|
-
|
|
676
|
-
// ─── Model Slot Types ────────────────────────────────────────────────────────
|
|
677
|
-
|
|
678
773
|
/**
|
|
679
774
|
* Declares a named slot where child models can be placed inside a parent dynamic model.
|
|
680
775
|
* Attach an array of these to `DynamicModel.slotDefinitions`.
|
|
681
776
|
*/
|
|
682
|
-
|
|
777
|
+
interface SlotDefinition {
|
|
683
778
|
/** Unique identifier (UUID) — primary key used in rule columns to reference this slot. */
|
|
684
779
|
id: string;
|
|
685
780
|
/** Human-readable name shown in the admin slot picker. */
|
|
@@ -687,14 +782,16 @@ export interface SlotDefinition {
|
|
|
687
782
|
/** Optional fallback model ID rendered when no rule assigns a model to this slot. */
|
|
688
783
|
defaultModelId?: string | number;
|
|
689
784
|
}
|
|
690
|
-
|
|
691
785
|
/**
|
|
692
786
|
* A resolved model instance placed into a slot at runtime.
|
|
693
787
|
* Received via `DynamicModelComponentProps.slots[slotId]`.
|
|
694
788
|
*/
|
|
695
|
-
|
|
789
|
+
interface SlotModelInstance {
|
|
696
790
|
/** The model data object for this slot instance. */
|
|
697
|
-
model: {
|
|
791
|
+
model: {
|
|
792
|
+
id: string | number;
|
|
793
|
+
[key: string]: unknown;
|
|
794
|
+
};
|
|
698
795
|
/** URL of the model's 3D file, or `undefined` if this is a dynamic model with a component. */
|
|
699
796
|
fileURL: string | undefined;
|
|
700
797
|
/** The React component used to render this model if it is a dynamic model otherwise `undefined`. */
|
|
@@ -718,12 +815,11 @@ export interface SlotModelInstance {
|
|
|
718
815
|
/** Recursively nested slot instances when the slotted model itself has slots. */
|
|
719
816
|
slots?: Record<string, SlotModelInstance[]>;
|
|
720
817
|
}
|
|
721
|
-
|
|
722
818
|
/**
|
|
723
819
|
* Props automatically injected into every `DynamicModel.component` at runtime.
|
|
724
820
|
* Extend this with your custom prop types: `DynamicModelComponentProps & { myProp: string }`.
|
|
725
821
|
*/
|
|
726
|
-
|
|
822
|
+
interface DynamicModelComponentProps {
|
|
727
823
|
/**
|
|
728
824
|
* Resolved child model instances keyed by slot ID.
|
|
729
825
|
* Only present when the model has `slotDefinitions` and at least one slot is filled.
|
|
@@ -731,10 +827,7 @@ export interface DynamicModelComponentProps {
|
|
|
731
827
|
slots?: Record<string, SlotModelInstance[]>;
|
|
732
828
|
[key: string]: unknown;
|
|
733
829
|
}
|
|
734
|
-
|
|
735
|
-
// ─── Legacy types (unchanged) ────────────────────────────────────────────────
|
|
736
|
-
|
|
737
|
-
export interface DynamicModel {
|
|
830
|
+
interface DynamicModel {
|
|
738
831
|
/** Unique type key used to reference this model from rule items, e.g. `"acme.my-model"`. */
|
|
739
832
|
type: string;
|
|
740
833
|
/** Human-readable display name shown in the admin model picker. */
|
|
@@ -761,19 +854,12 @@ export interface DynamicModel {
|
|
|
761
854
|
*/
|
|
762
855
|
defaultProps: {
|
|
763
856
|
slotDefinitions?: SlotDefinition[];
|
|
764
|
-
[key: string]:
|
|
765
|
-
| string
|
|
766
|
-
| number
|
|
767
|
-
| boolean
|
|
768
|
-
| ModelPropDefault
|
|
769
|
-
| undefined
|
|
770
|
-
| SlotDefinition[];
|
|
857
|
+
[key: string]: string | number | boolean | ModelPropDefault | undefined | SlotDefinition[];
|
|
771
858
|
};
|
|
772
859
|
/** Optional tag used to group or filter models in the admin UI. */
|
|
773
860
|
tag?: string;
|
|
774
861
|
}
|
|
775
|
-
|
|
776
|
-
export interface ModelProp {
|
|
862
|
+
interface ModelProp {
|
|
777
863
|
/**
|
|
778
864
|
* Editor widget type for this prop in the admin dialog.
|
|
779
865
|
* `"basic"` — plain text/number input.
|
|
@@ -789,30 +875,26 @@ export interface ModelProp {
|
|
|
789
875
|
/** For type="model": allow selecting multiple models. */
|
|
790
876
|
multiple?: boolean;
|
|
791
877
|
}
|
|
792
|
-
|
|
793
878
|
/** 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 {
|
|
879
|
+
declare const VariableType: {
|
|
880
|
+
readonly List: "list";
|
|
881
|
+
readonly Color: "color";
|
|
882
|
+
readonly Number: "number";
|
|
883
|
+
readonly Text: "text";
|
|
884
|
+
readonly MultiSelect: "multiSelect";
|
|
885
|
+
readonly Boolean: "boolean";
|
|
886
|
+
readonly Image: "image";
|
|
887
|
+
readonly Upload: "upload";
|
|
888
|
+
readonly Components: "components";
|
|
889
|
+
readonly Information: "information";
|
|
890
|
+
};
|
|
891
|
+
type VariableTypes = (typeof VariableType)[keyof typeof VariableType];
|
|
892
|
+
interface ModelPropDefault {
|
|
810
893
|
/** An expression string evaluated at runtime instead of a static value (e.g. `"group.width * 2"`). */
|
|
811
894
|
expression?: string;
|
|
812
895
|
}
|
|
813
|
-
|
|
814
896
|
/** K3 Value object (list / color / boolean selection). */
|
|
815
|
-
|
|
897
|
+
interface Value {
|
|
816
898
|
/** Unique database ID of the value. */
|
|
817
899
|
id: number | string;
|
|
818
900
|
/** Optional stable string key for the value, usable as an alternative identifier. */
|
|
@@ -822,16 +904,16 @@ export interface Value {
|
|
|
822
904
|
/** Human-readable display label shown in the configurator UI. */
|
|
823
905
|
label: string;
|
|
824
906
|
}
|
|
825
|
-
|
|
826
907
|
/**
|
|
827
908
|
* Context passed to plugin dynamic model components at runtime.
|
|
828
909
|
*/
|
|
829
|
-
|
|
910
|
+
interface PluginModelContext {
|
|
830
911
|
/** Only set during screenshot rendering. */
|
|
831
912
|
screenshotCameraName?: string;
|
|
832
913
|
/** The unique ID of the model action this instance is rendered for. */
|
|
833
914
|
modelActionId?: string;
|
|
834
915
|
}
|
|
835
|
-
|
|
836
916
|
/** @deprecated Use K3PluginDescriptor */
|
|
837
|
-
|
|
917
|
+
type K3Plugin = Pick<K3PluginDescriptor, "dynamicModels">;
|
|
918
|
+
//#endregion
|
|
919
|
+
export { CallbackWithDescription, CustomLayoutComponentProps, DynamicModel, DynamicModelComponentProps, HOC, HOCWithDescription, K3ARExportContext, K3ARPlatform, K3AppInfo, K3BomEntry, K3Camera, K3CameraScope, K3ComponentInstanceVariables, K3Configuration, K3ConfigurationSavedEvent, K3ConfigurationVariableEntry, K3ConfigurationVariables, K3Coordinates, K3DialogExtensions, K3FullApp, K3InputExtensions, K3LayoutExtensions, K3LogicExtensions, K3NewConfiguration, K3OrderDialogExtensions, K3OrthographicCamera, K3PerspectiveCamera, K3Plugin, K3PluginDescriptor, K3SaveResult, K3Scene, K3ScreenshotDimensions, K3Selection, K3SimplifiedValue, K3UIExtensions, K3UploadFile, K3VariableComponentProps, K3ViewerExtensions, K3WarningExtensions, LocalizedString, ModelProp, ModelPropDefault, PluginModelContext, SlotDefinition, SlotModelInstance, Value, VariableType, VariableTypes, VariableVisualisation, getSettings, init, useApp, useBOM, useConfigurationVariable, useConfigurationVariables, useFormattedTotalPrice, useK3PluginSettings, useTotalPrice };
|