@combeenation/custom-code-sdk 0.0.1-alpha6 → 0.0.1-alpha8
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/bundle.cjs.js +1 -14
- package/dist/bundle.es.js +403 -17173
- package/dist/index.d.ts +478 -109
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
declare type AppLanguage = 'en' | 'de';
|
|
4
|
+
|
|
5
|
+
declare type AssetName = z.infer<typeof ZAssetName>;
|
|
6
|
+
|
|
3
7
|
export declare class Button {
|
|
4
8
|
#private;
|
|
5
9
|
readonly id: CtrlId;
|
|
@@ -14,13 +18,22 @@ declare type CallbackUnsubscribeOption = {
|
|
|
14
18
|
unsubscribe: () => void;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
|
-
declare
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export declare namespace CbnSdk {
|
|
22
|
+
export {
|
|
23
|
+
configuratorIsInIFrame,
|
|
24
|
+
finishConfiguration,
|
|
25
|
+
fireAnalyticsEvent,
|
|
26
|
+
getAssetPaths,
|
|
27
|
+
getParentPageUrl,
|
|
28
|
+
navigateToLogin,
|
|
29
|
+
onAnyCmpValueChanged,
|
|
30
|
+
redirectParentPage,
|
|
31
|
+
sendCustomMsgToParentPage,
|
|
32
|
+
setConfiguratorIFrameSize,
|
|
33
|
+
shareConfiguration,
|
|
34
|
+
createSyncCmpValuesStore,
|
|
35
|
+
version
|
|
36
|
+
}
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
export declare class Checkbox {
|
|
@@ -31,52 +44,27 @@ export declare class Checkbox {
|
|
|
31
44
|
setVisible(visible: boolean): Promise<void>;
|
|
32
45
|
}
|
|
33
46
|
|
|
34
|
-
export declare type CheckoutProductCustomFields = {
|
|
35
|
-
/**
|
|
36
|
-
* Unique identifier
|
|
37
|
-
*/
|
|
38
|
-
id: string;
|
|
39
|
-
/**
|
|
40
|
-
* Label which the user will also see in the cart (if it is visible)
|
|
41
|
-
*/
|
|
42
|
-
label: string;
|
|
43
|
-
/**
|
|
44
|
-
* Value of the custom field
|
|
45
|
-
*/
|
|
46
|
-
value: string;
|
|
47
|
-
/**
|
|
48
|
-
* Position in the cart
|
|
49
|
-
*/
|
|
50
|
-
position: number;
|
|
51
|
-
/**
|
|
52
|
-
* If it should be visible in the cart
|
|
53
|
-
*/
|
|
54
|
-
isVisible: boolean;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
declare const client: CfgrClientApi_v1 | undefined;
|
|
58
|
-
|
|
59
47
|
declare type CmpName = string;
|
|
60
48
|
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
/**
|
|
50
|
+
* All possible typings for component values.
|
|
51
|
+
*
|
|
52
|
+
* Rule of thumb with this type: Limit usages to the bare minimum only when actually needed.
|
|
53
|
+
* Ideally, this type should not be used in the consuming app (cfgr editor etc.) at all but only in the API layer which
|
|
54
|
+
* does all the parsing & conversion of cmp values to raw wire format and vice versa.
|
|
55
|
+
*
|
|
56
|
+
* Why?
|
|
57
|
+
* This is practically an `unknown` ATM (see comment above {@link ZCmpValue}) and dealing with `unknown` in code is very
|
|
58
|
+
* cumbersome and leads to hard to maintain code.
|
|
59
|
+
*/
|
|
63
60
|
declare type CmpValue = z.infer<typeof ZCmpValue>;
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
declare interface CmpValueChangedCondition<T extends CmpValue = CmpValue> {
|
|
68
|
-
(param: T | undefined): Promise<boolean>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
declare interface CmpValueChangedCondition_2<T extends CmpValue_2 = CmpValue_2> {
|
|
62
|
+
/** Interface for value changed condition function */
|
|
63
|
+
export declare interface CmpValueChangedCondition<T extends CmpValue = CmpValue> {
|
|
72
64
|
(param: T | undefined): Promise<boolean>;
|
|
73
65
|
}
|
|
74
66
|
|
|
75
|
-
declare interface CmpValueChangedListener<T extends CmpValue = CmpValue> {
|
|
76
|
-
(param: T | undefined): void;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
declare interface CmpValueChangedListener_2<T extends CmpValue_2 = CmpValue_2> {
|
|
67
|
+
export declare interface CmpValueChangedListener<T extends CmpValue = CmpValue> {
|
|
80
68
|
(param: T | undefined): void;
|
|
81
69
|
}
|
|
82
70
|
|
|
@@ -84,7 +72,11 @@ declare type CmpValueChangedMap<TName extends string = string> = {
|
|
|
84
72
|
[K in TName]: boolean;
|
|
85
73
|
};
|
|
86
74
|
|
|
87
|
-
declare interface CmpValuesChangedListener<TName extends string = string> {
|
|
75
|
+
export declare interface CmpValuesChangedListener<TName extends string = string> {
|
|
76
|
+
/**
|
|
77
|
+
* Returns an object where each key represents the given components, and the corresponding boolean value
|
|
78
|
+
* indicates whether that component has changed or not
|
|
79
|
+
*/
|
|
88
80
|
(changedCmps: CmpValueChangedMap<TName>): void;
|
|
89
81
|
}
|
|
90
82
|
|
|
@@ -96,6 +88,69 @@ export declare class Collapsible {
|
|
|
96
88
|
setVisible(visible: boolean): Promise<void>;
|
|
97
89
|
}
|
|
98
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Checks if the configurator is embedded inside an IFrame.
|
|
93
|
+
*/
|
|
94
|
+
export declare const configuratorIsInIFrame: () => boolean;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Creates a store holding component values which can be accessed synchronously.
|
|
98
|
+
*
|
|
99
|
+
* This is meant as an alternative to the async value access via `await cmp.getValue()` for situations where the async
|
|
100
|
+
* access is especially cumbersome.
|
|
101
|
+
*
|
|
102
|
+
* E.g.:
|
|
103
|
+
* ```ts
|
|
104
|
+
* const amount = await Amount.getValue();
|
|
105
|
+
* // vs.
|
|
106
|
+
* const amount = cmpValues.Amount;
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* !!! Note !!!
|
|
110
|
+
*
|
|
111
|
+
* This shall not be used as the default way of accessing component values.\
|
|
112
|
+
* Using this extensively can have negative impact on the performance of your configurator.
|
|
113
|
+
*
|
|
114
|
+
* Avoid using this with too many components or components that hold very large values which change frequently.
|
|
115
|
+
*
|
|
116
|
+
* @returns An object holding the current value of each of the given `cmps`.\
|
|
117
|
+
* The keys of the properties in the returned object are the same as in the given `cmps`.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* // Create the store once and export for later use:
|
|
122
|
+
* import { Amount, ItemPrice } from './typings/cfgr-defs.generated';
|
|
123
|
+
* export const cmpValues = await createSyncCmpValuesStore({ Amount, ItemPrice });
|
|
124
|
+
*
|
|
125
|
+
* // Later in the code, access the values synchronously like this:
|
|
126
|
+
* const amount = cmpValues.Amount;
|
|
127
|
+
* const itemPrice = cmpValues.ItemPrice;
|
|
128
|
+
* // or:
|
|
129
|
+
* const { Amount: amount, ItemPrice: itemPrice } = cmpValues;
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* !!! Important !!!
|
|
133
|
+
*
|
|
134
|
+
* Once the values of the returned store have been extracted, they will not update anymore.\
|
|
135
|
+
* -> Only extract the values in sync contexts.
|
|
136
|
+
*
|
|
137
|
+
* E.g.:
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { cmpValues } from './path/to/store';
|
|
140
|
+
*
|
|
141
|
+
* const amount = cmpValues.Amount; // Current value of Amount is 10
|
|
142
|
+
*
|
|
143
|
+
* button.onClick(() => {
|
|
144
|
+
* // The value of Amount changed to 20 in the meantime
|
|
145
|
+
* console.log(amount); // 🔥 Stale value 10
|
|
146
|
+
* console.log(cmpValues.Amount); // ✅ Latest value 20
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare const createSyncCmpValuesStore: <TCmps extends {
|
|
151
|
+
[id: CmpName]: ValueComponent;
|
|
152
|
+
}>(cmps: TCmps) => Promise<Readonly<SyncCmpValuesStore<TCmps>>>;
|
|
153
|
+
|
|
99
154
|
declare type CtrlId = z.infer<typeof ZCtrlId>;
|
|
100
155
|
|
|
101
156
|
export declare class CustomControl {
|
|
@@ -103,30 +158,69 @@ export declare class CustomControl {
|
|
|
103
158
|
readonly id: CtrlId;
|
|
104
159
|
constructor(id: CtrlId);
|
|
105
160
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* -
|
|
161
|
+
* This gives custom code full control over what is rendered inside the control. When setting this function, custom
|
|
162
|
+
* code is responsible to actively render/set the content/innerHTML of the given `element` inside the
|
|
163
|
+
* {@link renderFn}.
|
|
164
|
+
*
|
|
165
|
+
* The configurator will not render any content inside the control when a {@link renderFn} is set.
|
|
166
|
+
*
|
|
167
|
+
* For the {@link renderFn} to work, the property `Custom code controlled` needs to be enabled on the control.
|
|
168
|
+
* The {@link renderFn} will be ignored when `Custom code controlled` is not enabled.
|
|
169
|
+
*
|
|
170
|
+
* Good to know:
|
|
171
|
+
* - Setting a new {@link renderFn} does not trigger a re-render.\
|
|
172
|
+
* Use {@link render} if you want to trigger a re-render after setting a new {@link renderFn}.
|
|
173
|
+
* - There can only be one {@link renderFn} per control. Setting a new one will override the existing one.
|
|
174
|
+
* - The {@link renderFn} will be called in the following scenarios:
|
|
175
|
+
* - Everytime the control is being shown. This is on initial show as well as when toggling its visibility.
|
|
176
|
+
* - When forcing a render via the {@link render} method.
|
|
177
|
+
* - Difference to {@link onRendered}:
|
|
178
|
+
* - The {@link renderFn} is meant to control the rendered content whilst {@link onRendered} is a classic event
|
|
179
|
+
* listener which allows you to perform certain actions like installing event listener on DOM nodes etc.
|
|
180
|
+
* **after** the content has been rendered.
|
|
181
|
+
* - You can install multiple {@link onRendered} callbacks.
|
|
182
|
+
* - The {@link renderFn} and {@link onRendered} callbacks can be used side by side.
|
|
183
|
+
* - The {@link renderFn} should always be used instead of manually manipulating the DOM via vanilla JS.\
|
|
184
|
+
* When manipulating the DOM outside of the {@link renderFn}, your changes can always be overridden by the
|
|
185
|
+
* configurator.\
|
|
186
|
+
* Using the {@link renderFn} ensures that your changes are applied in a stable and predictable way.
|
|
119
187
|
*/
|
|
120
188
|
set renderFn(callback: CustomCtrlRenderFn);
|
|
121
189
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
190
|
+
* Forces a re-render of the control.
|
|
191
|
+
*
|
|
192
|
+
* @param renderFn Convenience param which allows setting the {@link renderFn} and triggering a render in one call.
|
|
193
|
+
* The given `renderFn` will be permanently installed and will override any previously set
|
|
194
|
+
* {@link renderFn}.
|
|
124
195
|
*/
|
|
125
196
|
render(renderFn?: CustomCtrlRenderFn): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* This allows custom code to register callbacks in which it can perform certain actions like installing event
|
|
199
|
+
* listeners on DOM nodes or adding CSS classes etc. **after** the control has been rendered.
|
|
200
|
+
*
|
|
201
|
+
* The control can be rendered in the following scenarios:
|
|
202
|
+
* - Everytime the control is being shown. This is on initial show as well as when toggling its visibility.
|
|
203
|
+
* - When forcing a render via the {@link render} method.
|
|
204
|
+
* - When the value of the control's `HTML` property changes e.g. via Hive in controls.
|
|
205
|
+
*
|
|
206
|
+
* !!! Important !!!
|
|
207
|
+
*
|
|
208
|
+
* This is **not** meant to be used for manipulating the rendered content of the control besides simple,
|
|
209
|
+
* non-structural/-behavioral changes like adding CSS classes or data attributes etc.
|
|
210
|
+
*
|
|
211
|
+
* For manipulating/controlling the rendered content, use the {@link renderFn} instead.
|
|
212
|
+
*
|
|
213
|
+
* See {@link renderFn} for more differences between the two.
|
|
214
|
+
*/
|
|
215
|
+
onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
|
|
126
216
|
getElement(): HTMLElement | undefined;
|
|
127
217
|
setVisible(visible: boolean): Promise<void>;
|
|
128
218
|
}
|
|
129
219
|
|
|
220
|
+
/**
|
|
221
|
+
* @param element The root element of the control into which you can render your custom content.
|
|
222
|
+
* @param rawHtml The raw HTML string which is set in the `HTML` property of the control.
|
|
223
|
+
*/
|
|
130
224
|
declare type CustomCtrlRenderFn = (element: HTMLDivElement, rawHtml: string | undefined) => void | Promise<void>;
|
|
131
225
|
|
|
132
226
|
export declare class Dataview {
|
|
@@ -137,26 +231,86 @@ export declare class Dataview {
|
|
|
137
231
|
setVisible(visible: boolean): Promise<void>;
|
|
138
232
|
}
|
|
139
233
|
|
|
140
|
-
|
|
234
|
+
/**
|
|
235
|
+
* Creates a finish of the current configuration by running all the Configurator's finish actions and optionally passes
|
|
236
|
+
* the resulting data to the parent page.
|
|
237
|
+
*/
|
|
238
|
+
export declare const finishConfiguration: (options: (FinishConfigurationBaseOptions & {
|
|
239
|
+
sendDataToParentPage: false;
|
|
240
|
+
}) | (FinishConfigurationBaseOptions & {
|
|
241
|
+
/**
|
|
242
|
+
* If `true`, the data returned by `transformParentPageData` will be passed to the function
|
|
243
|
+
* `window.Combeenation.onConfigurationFinished(data)` on the parent page (or one of its older aliases like
|
|
244
|
+
* `Combeenation.onCheckout` etc.).
|
|
245
|
+
*/
|
|
246
|
+
sendDataToParentPage: true;
|
|
247
|
+
/**
|
|
248
|
+
* Allows transformation of the data that is passed to the parent page after the configuration is finished.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const checkoutData: Shopware6CheckoutJson = { ... };
|
|
253
|
+
*
|
|
254
|
+
* finishConfiguration({
|
|
255
|
+
* transformParentPageData: () => {
|
|
256
|
+
* return {
|
|
257
|
+
* id: cfgnId, // E.g. from Hive's `configuration.id`
|
|
258
|
+
* authentication: authToken, // E.g. from Hive's `configuration.authToken`
|
|
259
|
+
* checkoutParameters: JSON.stringify(checkoutData),
|
|
260
|
+
* queryParameters: Object.fromEntries(new URLSearchParams(window.location.search)),
|
|
261
|
+
* checkoutParametersHash: '123', // Not actually used ATM, will be provided by the server in the future
|
|
262
|
+
* } satisfies ParentPageCheckoutData;
|
|
263
|
+
* },
|
|
264
|
+
* });
|
|
265
|
+
* ```
|
|
266
|
+
*
|
|
267
|
+
* FYI, this is mandatory ATM and does not get any input values which means that the consumer is required to
|
|
268
|
+
* build the return value himself. In the future we'll change this to be optional and provide the data generated
|
|
269
|
+
* on the server as input to the transformation function.
|
|
270
|
+
*/
|
|
271
|
+
transformParentPageData: () => ParentPageCheckoutData & {
|
|
272
|
+
[key: string]: SerializableJsonValue;
|
|
273
|
+
};
|
|
274
|
+
})) => Promise<void>;
|
|
141
275
|
|
|
142
|
-
|
|
276
|
+
declare type FinishConfigurationBaseOptions = {
|
|
277
|
+
input?: string;
|
|
278
|
+
};
|
|
143
279
|
|
|
144
280
|
/**
|
|
145
|
-
*
|
|
281
|
+
* Pushes the given data into the Google Tag Manager data layer on the parent page.
|
|
146
282
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
283
|
+
* If the Configurator is not embedded in an IFrame, the event is pushed directly into the data layer of the current
|
|
284
|
+
* window.
|
|
149
285
|
*
|
|
150
|
-
*
|
|
286
|
+
* If embedded in an IFrame, this requires the Configurator plugin to be installed correctly on the parent page.\
|
|
287
|
+
* See embedding instructions for details.
|
|
151
288
|
*
|
|
152
|
-
*
|
|
153
|
-
* `window.Cbn.getCustomCodeSdkBridge().createCfgrClient` which is responsible for returning the correct versioned API
|
|
154
|
-
* e.g. by "hotpatching" the returned runtime object based on the requested version.
|
|
289
|
+
* @param event Key for event identification
|
|
155
290
|
*/
|
|
156
|
-
declare
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
291
|
+
export declare const fireAnalyticsEvent: (event: string, eventData?: object | string) => Promise<ParentPageComResult<void>>;
|
|
292
|
+
|
|
293
|
+
export declare type FlexShopFinishJson = Shopware6FinishJson;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Returns the resolved 3D asset paths (babylon.js assets, material packs, texture image assets)
|
|
297
|
+
* for all pre-packed asset bundles configured for this Configurator.
|
|
298
|
+
*
|
|
299
|
+
* The result is fetched once and cached — subsequent calls resolve immediately from cache.
|
|
300
|
+
*/
|
|
301
|
+
export declare const getAssetPaths: () => Promise<SdkAssetPaths>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Retrieve the parent page's URI.
|
|
305
|
+
*
|
|
306
|
+
* Requires the Configurator plugin to be installed correctly on the parent page.\
|
|
307
|
+
* See embedding instructions for details.
|
|
308
|
+
*
|
|
309
|
+
* @returns `undefined` if we're not inside an IFrame or the parent page does not respond to our request.
|
|
310
|
+
*/
|
|
311
|
+
export declare const getParentPageUrl: () => Promise<ParentPageComResult<{
|
|
312
|
+
url: string;
|
|
313
|
+
}>>;
|
|
160
314
|
|
|
161
315
|
export declare class Input {
|
|
162
316
|
#private;
|
|
@@ -166,7 +320,66 @@ export declare class Input {
|
|
|
166
320
|
setVisible(visible: boolean): Promise<void>;
|
|
167
321
|
}
|
|
168
322
|
|
|
169
|
-
|
|
323
|
+
declare type JsonArray = Array<SerializableJsonValue>;
|
|
324
|
+
|
|
325
|
+
declare type JsonObject = {
|
|
326
|
+
[key: string]: SerializableJsonValue;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
declare type JsonPrimitive = string | number | boolean | null;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Raw material JSON which can be passed to Babylon.js e.g. via `Material.Parse(material)`
|
|
333
|
+
*/
|
|
334
|
+
declare type MaterialAsset = z.infer<typeof ZMaterialAsset>;
|
|
335
|
+
|
|
336
|
+
declare type MaterialPackName = z.infer<typeof ZMaterialPackName>;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Navigates to the login page of the Configurator.
|
|
340
|
+
*
|
|
341
|
+
* @param options.hideBackNavigation Defaults to `false`.\
|
|
342
|
+
* E.g. can be used if the Configurator immediately redirects to the login and
|
|
343
|
+
* shouldn't be accessible without a successful login.
|
|
344
|
+
* @param options.language Defaults to the browser language.
|
|
345
|
+
*/
|
|
346
|
+
export declare const navigateToLogin: (options?: {
|
|
347
|
+
hideBackNavigation?: boolean;
|
|
348
|
+
language?: AppLanguage;
|
|
349
|
+
}) => void;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @param listener Called whenever the value of at least 1 component has changed.\
|
|
353
|
+
* Returns an object that indicates which components have actually changed.
|
|
354
|
+
* @param components Only call the listener if one of the given cmps have changed
|
|
355
|
+
* @param lazy `false` [default]: Immediately fetch the values of all changed components.\
|
|
356
|
+
* `true`: Trigger the listener but don't fetch values until specifically requested.
|
|
357
|
+
* This could reduce data traffic when only some components are required in the listener, due to
|
|
358
|
+
* conditions or similar.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* [SCENARIO 1] where `lazy: true` could be benefical
|
|
362
|
+
* ```typescript
|
|
363
|
+
* CmpUtils.onAnyCmpValueChanged(() => {
|
|
364
|
+
* const useBigData = CmpSimpleBool.getValue();
|
|
365
|
+
* if(useBigData) {
|
|
366
|
+
* // only now the data will be retrieved from the server
|
|
367
|
+
* const bigData = await CmpBigData.getValue();
|
|
368
|
+
* }
|
|
369
|
+
*
|
|
370
|
+
* }, [CmpBigData, CmpSimpleBool, CmpSimpleText], true);
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* [SCENARIO 2] where `lazy: false` could be benefical
|
|
374
|
+
* ```typescript
|
|
375
|
+
* CmpUtils.onAnyCmpValueChanged(() => {
|
|
376
|
+
* // The data for both values has been fetched in the background, so no further server request is necessary
|
|
377
|
+
* const bigData1 = await CmpBigData1.getValue();
|
|
378
|
+
* const bigData2 = await CmpBigData2.getValue();
|
|
379
|
+
* }, [CmpBigData1, CmpBigData2]);
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
export declare const onAnyCmpValueChanged: <TInput extends ValueComponent>(listener: CmpValuesChangedListener<TInput["name"]>, components: TInput[], lazy?: boolean) => Promise<void>;
|
|
170
383
|
|
|
171
384
|
declare type OnClickCallback = () => void;
|
|
172
385
|
|
|
@@ -180,7 +393,158 @@ export declare class Panel {
|
|
|
180
393
|
setVisible(visible: boolean): Promise<void>;
|
|
181
394
|
}
|
|
182
395
|
|
|
183
|
-
export declare type
|
|
396
|
+
export declare type ParentPageCheckoutData = {
|
|
397
|
+
/** Cfgn id */
|
|
398
|
+
id: string;
|
|
399
|
+
/** Contains the value of the `data` passed to Hive's `OnFinish.CheckoutLegacy(data, key)` as stringified JSON */
|
|
400
|
+
checkoutParameters: string;
|
|
401
|
+
/** SHA256 hash of `checkoutParameters` built with the secret `key` passed to `OnFinish.CheckoutLegacy(data, key)` */
|
|
402
|
+
checkoutParametersHash: string;
|
|
403
|
+
/** Contains all query parameters which are added to the current cfgr URL */
|
|
404
|
+
queryParameters: {
|
|
405
|
+
[key: string]: string;
|
|
406
|
+
};
|
|
407
|
+
/** Cfgn auth token */
|
|
408
|
+
authentication: string;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
declare type ParentPageComErrorPayload<T> = [T] extends [void] ? {} : {
|
|
412
|
+
[K in keyof T]: undefined;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Given `T` must be an object and all its properties are directly spread into the resulting object.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* ParentPageComResult<void>
|
|
421
|
+
* // -> { success: true; } | { success: false; error: Error };
|
|
422
|
+
*
|
|
423
|
+
* ParentPageComResult<{ url: string }>
|
|
424
|
+
* // -> { success: true; url: string; } | { success: false; error: Error; url: undefined; };
|
|
425
|
+
*
|
|
426
|
+
* // Not allowed:
|
|
427
|
+
* ParentPageComResult<number> // `number` is not an object
|
|
428
|
+
* ParentPageComResult<string[]> // `string[]` is not an object
|
|
429
|
+
* ParentPageComResult<{ success: string }> // Property `success` is not allowed
|
|
430
|
+
* ParentPageComResult<{ error: string, name: string }> // Property `error` is not allowed
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
declare type ParentPageComResult<T extends Record<string, unknown> | void> = ({
|
|
434
|
+
success: true;
|
|
435
|
+
error: undefined;
|
|
436
|
+
} & ([T] extends [void] ? {} : T)) | ({
|
|
437
|
+
success: false;
|
|
438
|
+
error: Error;
|
|
439
|
+
} & ParentPageComErrorPayload<T>);
|
|
440
|
+
|
|
441
|
+
export declare type ProductCustomFields = {
|
|
442
|
+
/**
|
|
443
|
+
* Unique identifier
|
|
444
|
+
*/
|
|
445
|
+
id: string;
|
|
446
|
+
/**
|
|
447
|
+
* Label which the user will also see in the cart (if it is visible)
|
|
448
|
+
*/
|
|
449
|
+
label: string;
|
|
450
|
+
/**
|
|
451
|
+
* Value of the custom field
|
|
452
|
+
*/
|
|
453
|
+
value: string;
|
|
454
|
+
/**
|
|
455
|
+
* Position in the cart
|
|
456
|
+
*/
|
|
457
|
+
position: number;
|
|
458
|
+
/**
|
|
459
|
+
* If it should be visible in the cart
|
|
460
|
+
*/
|
|
461
|
+
isVisible: boolean;
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Sets `window.location.href` to the given `url` on the parent page.
|
|
466
|
+
*
|
|
467
|
+
* Requires the Configurator plugin to be installed correctly on the parent page.\
|
|
468
|
+
* See embedding instructions for details.
|
|
469
|
+
*/
|
|
470
|
+
export declare const redirectParentPage: (url: string) => Promise<ParentPageComResult<void>>;
|
|
471
|
+
|
|
472
|
+
declare type SdkAssetPaths = {
|
|
473
|
+
babylonJsAssets: {
|
|
474
|
+
[key: AssetName]: Url;
|
|
475
|
+
};
|
|
476
|
+
materialPacks: {
|
|
477
|
+
[key: MaterialPackName]: {
|
|
478
|
+
[key: AssetName]: MaterialAsset;
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
textureImageAssets: {
|
|
482
|
+
[key: AssetName]: Url;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Send a custom message to the parent page via the "CustomMessage".\
|
|
488
|
+
* The parent page can handle those messages by implementing the function `Combeenation.on{msgName}`.
|
|
489
|
+
*
|
|
490
|
+
* Requires the Configurator plugin to be installed correctly on the parent page.\
|
|
491
|
+
* See embedding instructions for details.
|
|
492
|
+
*/
|
|
493
|
+
export declare const sendCustomMsgToParentPage: (msgName: string, data?: object) => Promise<ParentPageComResult<void>>;
|
|
494
|
+
|
|
495
|
+
/** A JSON-serializable value safe to use as a `postMessage` payload etc. */
|
|
496
|
+
declare type SerializableJsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Changes the width and/or height of the IFrame and/or scroll position of the parent page window.
|
|
500
|
+
*
|
|
501
|
+
* Requires the Configurator plugin to be installed correctly on the parent page.\
|
|
502
|
+
* See embedding instructions for details.
|
|
503
|
+
*
|
|
504
|
+
* @param width If not given or 0, the width is not changed
|
|
505
|
+
* @param height If not given or 0, the height is not changed
|
|
506
|
+
* @param scrollToX New horizontal scroll position of the parent page window
|
|
507
|
+
* @param scrollToY New vertical scroll position of the parent page window
|
|
508
|
+
*/
|
|
509
|
+
export declare const setConfiguratorIFrameSize: (data: {
|
|
510
|
+
width?: string;
|
|
511
|
+
height?: string;
|
|
512
|
+
scrollToX?: number;
|
|
513
|
+
scrollToY?: number;
|
|
514
|
+
}) => Promise<ParentPageComResult<void>>;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Creates a copy of the current configuration and opens a share window for the given platform with the resulting share
|
|
518
|
+
* URL
|
|
519
|
+
*/
|
|
520
|
+
export declare const shareConfiguration: (data: {
|
|
521
|
+
/** If `Custom`, no share window will be opened */
|
|
522
|
+
platform: "Facebook" | "Pinterest" | "Twitter" | "LinkedIn" | "WhatsApp" | "Custom" | "NativeShare";
|
|
523
|
+
ogTitle?: string;
|
|
524
|
+
ogAuthor?: string;
|
|
525
|
+
ogDescription?: string;
|
|
526
|
+
/**
|
|
527
|
+
* URL to an image which will be used as share preview image when supported by the platform.
|
|
528
|
+
*
|
|
529
|
+
* It's recommended to use the URL of a file uploaded via upload tooling of the configurator.
|
|
530
|
+
*/
|
|
531
|
+
imageUrl?: string;
|
|
532
|
+
/**
|
|
533
|
+
* URL of the parent page where the configurator is embedded.
|
|
534
|
+
*
|
|
535
|
+
* Will be integrated into the resulting share URL, so that the share redirects to the parent page, not the standalone
|
|
536
|
+
* configurator.
|
|
537
|
+
*/
|
|
538
|
+
embedUrl?: string;
|
|
539
|
+
}) => Promise<{
|
|
540
|
+
/**
|
|
541
|
+
* Url which is enhanced for sharing on social media by providing required "Open Graph" tags.
|
|
542
|
+
*/
|
|
543
|
+
shareUrl: string;
|
|
544
|
+
shareConfigurationId: string;
|
|
545
|
+
}>;
|
|
546
|
+
|
|
547
|
+
export declare type ShopifyFinishJson = {
|
|
184
548
|
products: {
|
|
185
549
|
main: {
|
|
186
550
|
/**
|
|
@@ -204,7 +568,7 @@ export declare type ShopifyCheckoutJson = {
|
|
|
204
568
|
* New description of your product
|
|
205
569
|
*/
|
|
206
570
|
productText?: string;
|
|
207
|
-
customFields?:
|
|
571
|
+
customFields?: ProductCustomFields[];
|
|
208
572
|
/**
|
|
209
573
|
* Weight of the main product
|
|
210
574
|
*/
|
|
@@ -229,7 +593,7 @@ export declare type ShopifyCheckoutJson = {
|
|
|
229
593
|
}[];
|
|
230
594
|
};
|
|
231
595
|
|
|
232
|
-
export declare type
|
|
596
|
+
export declare type Shopware6FinishJson = {
|
|
233
597
|
products: {
|
|
234
598
|
main: {
|
|
235
599
|
/**
|
|
@@ -253,7 +617,7 @@ export declare type Shopware6CheckoutJson = {
|
|
|
253
617
|
* New description of your product
|
|
254
618
|
*/
|
|
255
619
|
productText?: string;
|
|
256
|
-
customFields?:
|
|
620
|
+
customFields?: ProductCustomFields[];
|
|
257
621
|
};
|
|
258
622
|
/**
|
|
259
623
|
* Additional predefined Shopware products which will be added to the cart (no custom price/image/title)
|
|
@@ -269,6 +633,13 @@ export declare type Shopware6CheckoutJson = {
|
|
|
269
633
|
}[];
|
|
270
634
|
};
|
|
271
635
|
|
|
636
|
+
/**
|
|
637
|
+
* A simple key-value store where key = component name and value = current component value.
|
|
638
|
+
*/
|
|
639
|
+
declare type SyncCmpValuesStore<TCmps extends Record<CmpName, ValueComponent>> = {
|
|
640
|
+
[K in keyof TCmps & CmpName]: TCmps[K] extends ValueComponent<any, infer TValue, any> ? TValue | undefined : never;
|
|
641
|
+
};
|
|
642
|
+
|
|
272
643
|
declare class Text_2 {
|
|
273
644
|
#private;
|
|
274
645
|
readonly id: CtrlId;
|
|
@@ -279,6 +650,8 @@ declare class Text_2 {
|
|
|
279
650
|
}
|
|
280
651
|
export { Text_2 as Text }
|
|
281
652
|
|
|
653
|
+
declare type Url = z.infer<typeof ZUrl>;
|
|
654
|
+
|
|
282
655
|
/**
|
|
283
656
|
* Represents a component of type `Value`
|
|
284
657
|
*/
|
|
@@ -306,39 +679,35 @@ export declare class ValueComponent<TName extends CmpName = CmpName, TValue exte
|
|
|
306
679
|
onValueChanged(listener: CmpValueChangedListener<TValue>, callImmediately?: boolean, condition?: CmpValueChangedCondition<TValue>): void;
|
|
307
680
|
}
|
|
308
681
|
|
|
309
|
-
|
|
310
|
-
* Represents a component of type `Value`
|
|
311
|
-
*/
|
|
312
|
-
declare class ValueComponent_2<TName extends CmpName_2 = CmpName_2, TValue extends CmpValue_2 = CmpValue_2, TInput extends CmpValue_2 = TValue> {
|
|
313
|
-
readonly name: TName;
|
|
314
|
-
readonly zodType: z.ZodType<CmpValue_2>;
|
|
315
|
-
constructor(name: TName, zodType: z.ZodType<CmpValue_2>);
|
|
316
|
-
/**
|
|
317
|
-
* Function for receiving the value of a component.
|
|
318
|
-
*/
|
|
319
|
-
getValue(): Promise<TValue | undefined>;
|
|
320
|
-
/**
|
|
321
|
-
* Sends the ChangeConfigurationValue request to the server
|
|
322
|
-
*/
|
|
323
|
-
setInput(value: TInput | undefined): Promise<void>;
|
|
324
|
-
/**
|
|
325
|
-
* @param listener Called whenever the value of the given cmp has changed
|
|
326
|
-
* @param callImmediately `True:` The listener is immediately called with the current value of the cmp at the
|
|
327
|
-
* time, the listener is added\
|
|
328
|
-
* `False:` The listener will be called for the first time when the value of the cmp
|
|
329
|
-
* actually changes
|
|
330
|
-
* @param condition A predicate function which is given the new cmp value.\
|
|
331
|
-
* The function can decide on whether the listener is called or not by returning true or false.
|
|
332
|
-
*/
|
|
333
|
-
onValueChanged(listener: CmpValueChangedListener_2<TValue>, callImmediately?: boolean, condition?: CmpValueChangedCondition_2<TValue>): void;
|
|
334
|
-
}
|
|
682
|
+
export declare const version: string;
|
|
335
683
|
|
|
336
|
-
|
|
684
|
+
declare const ZAssetName: z.ZodString;
|
|
337
685
|
|
|
338
686
|
declare const ZCmpValue: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodUnknown]>;
|
|
339
687
|
|
|
340
|
-
declare const ZCmpValue_2: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodUnknown]>;
|
|
341
|
-
|
|
342
688
|
declare const ZCtrlId: z.ZodString;
|
|
343
689
|
|
|
690
|
+
/**
|
|
691
|
+
* Raw material JSON which can be passed to Babylon.js e.g. via `Material.Parse(material)`
|
|
692
|
+
*
|
|
693
|
+
* Whilst this is not a full zod schema for Babylon material definitions, we least check for the presence of some
|
|
694
|
+
* required properties like `name` and `id` to avoid passing obviously invalid material definitions.
|
|
695
|
+
*
|
|
696
|
+
* Could be extended as needed.
|
|
697
|
+
*/
|
|
698
|
+
declare const ZMaterialAsset: z.ZodObject<{
|
|
699
|
+
name: z.ZodString;
|
|
700
|
+
id: z.ZodString;
|
|
701
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
702
|
+
name: z.ZodString;
|
|
703
|
+
id: z.ZodString;
|
|
704
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
705
|
+
name: z.ZodString;
|
|
706
|
+
id: z.ZodString;
|
|
707
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
708
|
+
|
|
709
|
+
declare const ZMaterialPackName: z.ZodString;
|
|
710
|
+
|
|
711
|
+
declare const ZUrl: z.ZodBranded<z.ZodString, "Url">;
|
|
712
|
+
|
|
344
713
|
export { }
|