@spiffcommerce/core 0.2.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 +12 -0
- package/dist/main.js +98 -0
- package/dist/module.js +98 -0
- package/dist/types.d.ts +1163 -0
- package/package.json +72 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,1163 @@
|
|
|
1
|
+
import { AnyStepData, Step, Asset, AssetType, IServerModel, MaterialResource, VariantResource, Workflow, CameraAnimation, ModelAnimation, OptionResource, StepType, TextStepData } from "papyrus/build/main/generation/Workflow";
|
|
2
|
+
import { PatternImageData, ScaleAxis, UnitOfMeasurement } from "papyrus/build/main/types";
|
|
3
|
+
import { FrameOffsets, ILayout, SerializableStep, StepStorage, Region, LayoutsState as _LayoutsState1, LayoutElement, LayoutsState, TextboxElement, ImageElement } from "papyrus/build/main/LayoutsState/types";
|
|
4
|
+
import { ModuleProduct } from "papyrus/build/main/module/ModuleProduct";
|
|
5
|
+
import { CanvasCommand, CreateElementCommand, FontAlignmentCommand, FontColorCommand, TextChangeCommand } from "papyrus/build/main/command";
|
|
6
|
+
import { CommandState, CommandContext as _CommandContext1, LayoutData as _LayoutData1, CommandContext, LayoutData } from "papyrus/build/main/CommandContext";
|
|
7
|
+
import { Dispatch, FunctionComponent, ReactNode, MouseEvent, PointerEvent } from "react";
|
|
8
|
+
import { ThreeDPreviewService as _ThreeDPreviewService1, SpiffCommerce3DPreviewService } from "spiff-preview";
|
|
9
|
+
import { LayoutElementFactory } from "papyrus/build/main/Elements/factory";
|
|
10
|
+
interface WorkflowScene {
|
|
11
|
+
name: string;
|
|
12
|
+
title: string;
|
|
13
|
+
renderableSteps: Step<AnyStepData>[];
|
|
14
|
+
silentSteps: Step<AnyStepData>[];
|
|
15
|
+
}
|
|
16
|
+
interface WorkflowScenesConfiguration {
|
|
17
|
+
bulkScene: boolean;
|
|
18
|
+
bulkSceneTitle: string;
|
|
19
|
+
finishScene: boolean;
|
|
20
|
+
finishSceneTitle: string;
|
|
21
|
+
}
|
|
22
|
+
declare class FrameService {
|
|
23
|
+
minZoomScale: number;
|
|
24
|
+
maxZoomScale: number;
|
|
25
|
+
constructor(forceImageCover?: boolean);
|
|
26
|
+
/**
|
|
27
|
+
* When we want to connect a workflow manager to the state of the image cropper we
|
|
28
|
+
* can pass it to this function. Inside we'll attach any required event listeners.
|
|
29
|
+
* @param workflowManager The workflow manager to attach.
|
|
30
|
+
* @param stepName The specific step we want to attach to within the manager.
|
|
31
|
+
*/
|
|
32
|
+
connectWorkflowManager(workflowManager: WorkflowManager, stepName?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the elements that should be update when changes are made to
|
|
35
|
+
* the cropper that owns this service.
|
|
36
|
+
* @param targetElements A list of element Ids to track
|
|
37
|
+
*/
|
|
38
|
+
setTargetElements(targetElements: string[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the current calculated frame data
|
|
41
|
+
* @returns A FrameData object or undefined if no frame has been set.
|
|
42
|
+
*/
|
|
43
|
+
getFrameData(): FrameData | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the current frame data
|
|
46
|
+
* @param path The path to lookup in our frame data cache.
|
|
47
|
+
*/
|
|
48
|
+
setFrameData(path: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the currently set image of the frame..
|
|
51
|
+
* @returns A PatternImageData object, or undefined if no image is set.
|
|
52
|
+
*/
|
|
53
|
+
getImageData(): PatternImageData | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current calculated offsets of the pattern within the frame.
|
|
56
|
+
* @returns A FrameOffsets object or undefined if no offsets are defined.
|
|
57
|
+
*/
|
|
58
|
+
getOffsets(): FrameOffsets | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Updates the frame offsets explicitly.
|
|
61
|
+
*/
|
|
62
|
+
setOffsets(offsets: FrameOffsets): void;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the zoom of the cropper that owns this service.
|
|
65
|
+
* @param zoom The new zoom value.
|
|
66
|
+
* @param cX The center of zoom on x axis
|
|
67
|
+
* @param cY The center of zoom on Y axis
|
|
68
|
+
* @param onComplete A function to call when zoom changes have been completed
|
|
69
|
+
*/
|
|
70
|
+
setZoom(zoom: number, cX: number, cY: number, onComplete?: () => void): void;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the image currently contained by this frame.
|
|
73
|
+
* @param value The new image as an ImageData property
|
|
74
|
+
*/
|
|
75
|
+
setPatternData(value: PatternImageData): void;
|
|
76
|
+
/**
|
|
77
|
+
* Modify the offsets of the frame.
|
|
78
|
+
* @param value The new FrameOffsets object.
|
|
79
|
+
* @param onComplete A callback, called when the modification is complete
|
|
80
|
+
*/
|
|
81
|
+
updateOffsets(value: FrameOffsets, onComplete?: () => void): void;
|
|
82
|
+
onFrameDataChanged(newListener: (frameData: FrameData | undefined) => void): void;
|
|
83
|
+
/**
|
|
84
|
+
* Append a new listener to zoom events on this frame.
|
|
85
|
+
* @param newListener
|
|
86
|
+
*/
|
|
87
|
+
onZoom(newListener: (zoomValue: number) => void): void;
|
|
88
|
+
}
|
|
89
|
+
declare class Poller {
|
|
90
|
+
/**
|
|
91
|
+
* Constructs a new polling service.
|
|
92
|
+
* @param predicate An async function that returns true when polling has returned a successful result.
|
|
93
|
+
* @param onSuccess The callback to be called when polling has returned a successful result.
|
|
94
|
+
* @param onFailure The callback to be called when polling has returned a failed result.
|
|
95
|
+
* @param interval The number of milliseconds to wait between each poll.
|
|
96
|
+
* @param maxAttempts The maximum amount of times to check the condition.
|
|
97
|
+
*/
|
|
98
|
+
constructor(predicate: () => Promise<boolean>, onSuccess: () => void, onFailure: () => void, interval?: number, maxAttempts?: number);
|
|
99
|
+
}
|
|
100
|
+
declare class SwaggerServer implements ServerService {
|
|
101
|
+
constructor();
|
|
102
|
+
setUncachedOperations(operationIds: string[]): void;
|
|
103
|
+
execute(operationName: string, parameters?: object): Promise<ServerResponse>;
|
|
104
|
+
}
|
|
105
|
+
export const server: SwaggerServer;
|
|
106
|
+
declare class AssetService {
|
|
107
|
+
constructor();
|
|
108
|
+
/**
|
|
109
|
+
* Allows for retrieving an asset, returns the option from a cache if possible.
|
|
110
|
+
* @param server The server service for making the request.
|
|
111
|
+
* @param id The asset key to be retrieved.
|
|
112
|
+
*/
|
|
113
|
+
getLocalOrFromServer(assetKey: string): Promise<IServerModel<Asset>>;
|
|
114
|
+
/**
|
|
115
|
+
* Allows for retrieving amaterial, returns the option from a cache if possible.
|
|
116
|
+
* @param server The server service for making the request.
|
|
117
|
+
* @param id The option ID to be retrieved.
|
|
118
|
+
*/
|
|
119
|
+
getMaterialLocalOrFromServer(id: string): Promise<IServerModel<MaterialResource>>;
|
|
120
|
+
/**
|
|
121
|
+
* Upload a user asset to the server. Using callbacks to notify important events.
|
|
122
|
+
*/
|
|
123
|
+
uploadAssetWithProgress(file: FileInfo, assetType: AssetType, onProgress: (val: number) => void, onComplete: (asset: IServerModel<Asset>) => void, anonymous?: boolean, partnerId?: string): Promise<IServerModel<Asset>>;
|
|
124
|
+
/**
|
|
125
|
+
* Convert a File object for an image into a FileInfo.
|
|
126
|
+
*/
|
|
127
|
+
loadImageAsFileInfo: (file: File) => Promise<FileInfo>;
|
|
128
|
+
}
|
|
129
|
+
export const assetService: AssetService;
|
|
130
|
+
interface EditedSteps {
|
|
131
|
+
[stepName: string]: boolean;
|
|
132
|
+
}
|
|
133
|
+
interface MandatorySteps {
|
|
134
|
+
[stepName: string]: boolean;
|
|
135
|
+
}
|
|
136
|
+
type StepElements = {
|
|
137
|
+
[key: string]: RegionElement[];
|
|
138
|
+
};
|
|
139
|
+
type StepInitialised = {
|
|
140
|
+
[key: string]: boolean;
|
|
141
|
+
};
|
|
142
|
+
type StepMetadata = FrameMetadata | IllustrationMetadata | ModuleMetadata | TextMetadata;
|
|
143
|
+
interface WorkflowStorage {
|
|
144
|
+
[stepName: string]: StepStorage;
|
|
145
|
+
}
|
|
146
|
+
interface WorkflowMetadata {
|
|
147
|
+
[stepName: string]: StepMetadata;
|
|
148
|
+
}
|
|
149
|
+
interface WorkflowSelections {
|
|
150
|
+
[stepName: string]: {
|
|
151
|
+
groupName?: string;
|
|
152
|
+
optionName: string;
|
|
153
|
+
selections: VariantResource[];
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
interface InformationResult {
|
|
157
|
+
message: string;
|
|
158
|
+
messageType: InformationMessageType;
|
|
159
|
+
stepID: string;
|
|
160
|
+
}
|
|
161
|
+
enum InformationMessageType {
|
|
162
|
+
Error = "Error",
|
|
163
|
+
Warning = "Warning"
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Services required for the operaiton of individual steps.
|
|
167
|
+
*/
|
|
168
|
+
interface StepSpecificServices {
|
|
169
|
+
frameService?: FrameService;
|
|
170
|
+
module?: ModuleProduct;
|
|
171
|
+
}
|
|
172
|
+
type DesignCreationProgressUpdate = (message: string) => void;
|
|
173
|
+
type ConfirmCallback = (isConfirmed: boolean) => void;
|
|
174
|
+
type EditedCallback = (editedSteps: EditedSteps) => void;
|
|
175
|
+
type ElementsCallback = (elements: StepElements) => void;
|
|
176
|
+
type InformationResultCallback = (messages: InformationResult[]) => void;
|
|
177
|
+
type InitCallback = (stepInitialised: StepInitialised) => void;
|
|
178
|
+
type MakingAdjustmentsCallback = (makingAdjustments: string) => void;
|
|
179
|
+
type MandatoryCallback = (mandatorySteps: MandatorySteps) => void;
|
|
180
|
+
type MetadataCallback = (metadata: WorkflowMetadata) => void;
|
|
181
|
+
type SelectionCallback = (callbackOptions: {
|
|
182
|
+
invalidModelVariants: string[];
|
|
183
|
+
selectionCost: number;
|
|
184
|
+
selections: StepSelections;
|
|
185
|
+
traversableScenes: WorkflowScene[];
|
|
186
|
+
}) => void;
|
|
187
|
+
type StepSpecificStorageCallback = (selections: StepStorage) => void;
|
|
188
|
+
type StorageCallback = (storage: WorkflowStorage) => void;
|
|
189
|
+
type UpdateCallback = (isUpdating: boolean) => void;
|
|
190
|
+
type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
|
|
191
|
+
type VariationRecordsCallback = (records: VariationRecord[]) => void;
|
|
192
|
+
interface WorkflowManager {
|
|
193
|
+
addPoller: (poller: Poller) => void;
|
|
194
|
+
addConfirmCallback: (callback: ConfirmCallback) => void;
|
|
195
|
+
addCurrentVariationCallback: (callback: CurrentVariationRecordCallback) => void;
|
|
196
|
+
addEditedCallback: (callback: EditedCallback) => void;
|
|
197
|
+
addElementsCallback: (callback: ElementsCallback) => void;
|
|
198
|
+
addInformationResultCallback: (callback: InformationResultCallback) => void;
|
|
199
|
+
addInitCallback: (callback: InitCallback) => void;
|
|
200
|
+
addMakingAdjustmentsCallback: (callback: MakingAdjustmentsCallback) => void;
|
|
201
|
+
addMandatoryCallback: (callback: MandatoryCallback) => void;
|
|
202
|
+
addMetadataCallback: (callback: MetadataCallback) => void;
|
|
203
|
+
addSelectionCallback: (callback: SelectionCallback) => void;
|
|
204
|
+
addStepSpecificStorageCallback: (callback: StepSpecificStorageCallback, stepName: string) => void;
|
|
205
|
+
addStorageCallback: (callback: StorageCallback) => void;
|
|
206
|
+
addUpdateCallback: (callback: UpdateCallback) => void;
|
|
207
|
+
addVariationRecord: (variationRecord: Omit<VariationRecord, "recordNumber">) => VariationRecord;
|
|
208
|
+
addVariationRecordsCallback: (callback: VariationRecordsCallback) => void;
|
|
209
|
+
getCommandDispatcher: () => (command: CanvasCommand) => void;
|
|
210
|
+
getCurrentVariationRecord: () => VariationRecord | undefined;
|
|
211
|
+
getVariationRecords: () => VariationRecord[];
|
|
212
|
+
getLayouts: () => ILayout[];
|
|
213
|
+
getLayoutPreviewService: () => any;
|
|
214
|
+
getPreviewService: () => ThreeDPreviewService | undefined;
|
|
215
|
+
getProductName: () => string | undefined;
|
|
216
|
+
getProfanities: () => string[];
|
|
217
|
+
getRegionElements: (stepName: string) => RegionElement[];
|
|
218
|
+
getSerializedStep: (stepName: string, serializedSteps: SerializableStep[]) => SerializableStep | undefined;
|
|
219
|
+
getStepSpecificServices: (stepName: string) => StepSpecificServices | undefined;
|
|
220
|
+
getTransaction: () => Transaction;
|
|
221
|
+
getWorkflow: () => Workflow;
|
|
222
|
+
getWorkflowSelections: () => WorkflowSelections;
|
|
223
|
+
markStepsAsInitialised: (stepNames: string[]) => void;
|
|
224
|
+
markUpdateCompleted: (update: string) => void;
|
|
225
|
+
markUpdatePending: (update: string) => void;
|
|
226
|
+
outstandingRequestsPromise: () => Promise<void>;
|
|
227
|
+
removeVariationRecord: (recordNumber: number) => VariationRecord[];
|
|
228
|
+
reset: () => Promise<void>;
|
|
229
|
+
setCurrentAdjustingStepId: (stepId: string) => void;
|
|
230
|
+
setAllScenes: (config: WorkflowScenesConfiguration) => void;
|
|
231
|
+
setCurrentVariationRecord: (variationRecord: null | VariationRecord) => void;
|
|
232
|
+
setEditedStatus: (stepName: string, status: boolean) => void;
|
|
233
|
+
setInformationResults: (results: InformationResult[]) => void;
|
|
234
|
+
setMandatoryFulfilled: (stepName: string, status: boolean) => void;
|
|
235
|
+
setSelectionsAndElements: (stepName: string, variants: VariantResource[], elements: RegionElement[]) => Promise<void>;
|
|
236
|
+
setVariationRecords: (variationRecords: VariationRecord[]) => void;
|
|
237
|
+
toggleDesignConfirmed: () => void;
|
|
238
|
+
updateMetadata: (stepName: string, update: any) => void;
|
|
239
|
+
updateStateWithServer: (getReducerState: () => CommandState) => void;
|
|
240
|
+
updateStateWithServerImmediate: (getReducerState: () => CommandState) => Promise<void>;
|
|
241
|
+
updateStorage: (stepName: string, update: StepStorage) => Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
interface FileInfo {
|
|
244
|
+
/**
|
|
245
|
+
* The name of the file.
|
|
246
|
+
*/
|
|
247
|
+
name: string;
|
|
248
|
+
/**
|
|
249
|
+
* A blob object representing the
|
|
250
|
+
* data of the file.
|
|
251
|
+
*/
|
|
252
|
+
blob: Blob;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The variant selections of a completed step.
|
|
256
|
+
*/
|
|
257
|
+
interface SelectedVariants {
|
|
258
|
+
[stepName: string]: {
|
|
259
|
+
id: string;
|
|
260
|
+
name: string;
|
|
261
|
+
priceModifier: number;
|
|
262
|
+
}[];
|
|
263
|
+
}
|
|
264
|
+
interface ExportedData {
|
|
265
|
+
[name: string]: {
|
|
266
|
+
value: string;
|
|
267
|
+
priceModifier: number;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
export interface DesignCreationMessage {
|
|
271
|
+
baseCost?: number;
|
|
272
|
+
weight?: number;
|
|
273
|
+
designProductId?: string;
|
|
274
|
+
designProductVariantId?: string;
|
|
275
|
+
event: string;
|
|
276
|
+
exportedData: ExportedData;
|
|
277
|
+
lineItemImageUrl: string;
|
|
278
|
+
transactionId: string;
|
|
279
|
+
metadata?: {
|
|
280
|
+
[stepName: string]: string;
|
|
281
|
+
};
|
|
282
|
+
optionsCost: number;
|
|
283
|
+
selectedVariants?: SelectedVariants;
|
|
284
|
+
sku?: string;
|
|
285
|
+
workflowViewerLink: string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Represents a transaction.
|
|
289
|
+
*/
|
|
290
|
+
interface Transaction {
|
|
291
|
+
id: string;
|
|
292
|
+
bulk?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* The workflow associated with this transaction.
|
|
295
|
+
*/
|
|
296
|
+
workflowId?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Temporary ID that grants write permission to the transaction.
|
|
299
|
+
*/
|
|
300
|
+
transactionOwnerId?: string;
|
|
301
|
+
/**
|
|
302
|
+
* The current state of the design.
|
|
303
|
+
*/
|
|
304
|
+
workflowState?: string;
|
|
305
|
+
/**
|
|
306
|
+
* URL to a partner-specific logo intended to display during the workflow experience.
|
|
307
|
+
*/
|
|
308
|
+
customLogoLink?: string;
|
|
309
|
+
/**
|
|
310
|
+
* URL to a logo intended to display at the periphery of the workflow experience.
|
|
311
|
+
*/
|
|
312
|
+
workflowFooterLogoLink?: string;
|
|
313
|
+
/**
|
|
314
|
+
* URL to the corresponding integration in the REST API.
|
|
315
|
+
*/
|
|
316
|
+
restApiIntegrationLink?: string;
|
|
317
|
+
/**
|
|
318
|
+
* URL to redirect to when a workflow is finished.
|
|
319
|
+
*/
|
|
320
|
+
callbackUrl?: string;
|
|
321
|
+
/**
|
|
322
|
+
* Product that this transaction belongs to.
|
|
323
|
+
*/
|
|
324
|
+
product?: Product;
|
|
325
|
+
/**
|
|
326
|
+
* The line item corresponding to this transaction.
|
|
327
|
+
*/
|
|
328
|
+
lineItem?: LineItem;
|
|
329
|
+
/**
|
|
330
|
+
* The external product variant ID representing the design product related
|
|
331
|
+
* to this transaction, null unless the createDesignProduct flag was set
|
|
332
|
+
* and the design was finalized using createDesign operation.
|
|
333
|
+
*/
|
|
334
|
+
externalDesignProductVariantId?: string;
|
|
335
|
+
/**
|
|
336
|
+
* The external product id representing the design product related
|
|
337
|
+
* to this transaction, null unless the createDesignProduct flag was set
|
|
338
|
+
* and the design was finalized using createDesign operation.
|
|
339
|
+
*/
|
|
340
|
+
externalDesignProductId?: string;
|
|
341
|
+
priceModifierTotal?: number;
|
|
342
|
+
/**
|
|
343
|
+
* The amount of variations associated with this transaction.
|
|
344
|
+
*/
|
|
345
|
+
variationsCount?: number;
|
|
346
|
+
/**
|
|
347
|
+
* URL to open the transaction in the workflow viewer.
|
|
348
|
+
*/
|
|
349
|
+
workflowViewerLink?: string;
|
|
350
|
+
bulkSourceUrl?: string;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Fields found in a variant within a line item resource.
|
|
354
|
+
*/
|
|
355
|
+
interface LineItemVariant {
|
|
356
|
+
currencyCode: string;
|
|
357
|
+
optionName: string;
|
|
358
|
+
priceModifier: number;
|
|
359
|
+
stepName: string;
|
|
360
|
+
variantName: string;
|
|
361
|
+
}
|
|
362
|
+
interface LineItem {
|
|
363
|
+
id: string;
|
|
364
|
+
transactionId?: string;
|
|
365
|
+
previewImageUrl?: string;
|
|
366
|
+
product: Product;
|
|
367
|
+
quantity: number;
|
|
368
|
+
metadata?: LineItemMetadata[];
|
|
369
|
+
variants: LineItemVariant[];
|
|
370
|
+
}
|
|
371
|
+
interface LineItemMetadata {
|
|
372
|
+
stepName: string;
|
|
373
|
+
metadata: string;
|
|
374
|
+
}
|
|
375
|
+
interface ProductWorkflow {
|
|
376
|
+
friendlyName: string;
|
|
377
|
+
id: string;
|
|
378
|
+
present?: boolean;
|
|
379
|
+
imageUrl: string;
|
|
380
|
+
workflowName: string;
|
|
381
|
+
}
|
|
382
|
+
interface Product {
|
|
383
|
+
/**
|
|
384
|
+
* ID of the partner owner.
|
|
385
|
+
*/
|
|
386
|
+
partnerId?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Whether a line item for this product is delivered as soon as the order is received.
|
|
389
|
+
*/
|
|
390
|
+
autoprint: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Whether this product can be quickprinted.
|
|
393
|
+
*/
|
|
394
|
+
canQuickprint?: boolean;
|
|
395
|
+
/**
|
|
396
|
+
* The internal identifier for this product.
|
|
397
|
+
*/
|
|
398
|
+
id: string;
|
|
399
|
+
/**
|
|
400
|
+
* The human friendly name of the product.
|
|
401
|
+
*/
|
|
402
|
+
name: string;
|
|
403
|
+
/**
|
|
404
|
+
* A URL to the image asset associated with this product.
|
|
405
|
+
*/
|
|
406
|
+
imageUrl?: string;
|
|
407
|
+
/**
|
|
408
|
+
* A resource url for a 3D model used to represent this product
|
|
409
|
+
* in the 3d editor. If not available we assume the product doesn't support 3D.
|
|
410
|
+
*/
|
|
411
|
+
modelUrl?: string;
|
|
412
|
+
/**
|
|
413
|
+
* A URL for the image used as an overlay on any workflows
|
|
414
|
+
* that incorporate a product overlay step.
|
|
415
|
+
*/
|
|
416
|
+
overlayImageUrl?: string;
|
|
417
|
+
/**
|
|
418
|
+
* Words which can't be used in a workflow for this product.
|
|
419
|
+
*/
|
|
420
|
+
profanities?: {
|
|
421
|
+
id: string;
|
|
422
|
+
createdAt: string;
|
|
423
|
+
userId: string;
|
|
424
|
+
word: string;
|
|
425
|
+
}[];
|
|
426
|
+
/**
|
|
427
|
+
* The max characters that can be typed for quickprint.
|
|
428
|
+
*/
|
|
429
|
+
quickprintMaxLength?: number;
|
|
430
|
+
/**
|
|
431
|
+
* The name of the module to use for quickprint.
|
|
432
|
+
*/
|
|
433
|
+
quickprintModuleName?: string;
|
|
434
|
+
/**
|
|
435
|
+
* If true, the product should be displayed in the client as if it is available.
|
|
436
|
+
* Should be displayed as if it is unavailable otherwise.
|
|
437
|
+
*/
|
|
438
|
+
enabled: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Workflows which have been assigned to this product.
|
|
441
|
+
*/
|
|
442
|
+
workflows?: ProductWorkflow[];
|
|
443
|
+
/**
|
|
444
|
+
* The base price of this product in sub units. Essentially the cost of the
|
|
445
|
+
* product without any customisations applied.
|
|
446
|
+
*/
|
|
447
|
+
basePrice?: number;
|
|
448
|
+
/**
|
|
449
|
+
* The weight of this product.
|
|
450
|
+
*/
|
|
451
|
+
weight?: number;
|
|
452
|
+
/**
|
|
453
|
+
* When specified, represents a pre-rendered image of this product to be
|
|
454
|
+
* displayed to customers while the 3D preview is loading.
|
|
455
|
+
*/
|
|
456
|
+
preloadImageUrl?: string;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Represents a variation as seen in Google sheets.
|
|
460
|
+
* Record number = row# - 1
|
|
461
|
+
*/
|
|
462
|
+
interface VariationRecord {
|
|
463
|
+
recordNumber: number;
|
|
464
|
+
transactionId: string;
|
|
465
|
+
values: {
|
|
466
|
+
stepName: string;
|
|
467
|
+
aspect: string;
|
|
468
|
+
value: string;
|
|
469
|
+
}[];
|
|
470
|
+
}
|
|
471
|
+
interface RegionElement {
|
|
472
|
+
id: string;
|
|
473
|
+
region?: Region;
|
|
474
|
+
}
|
|
475
|
+
interface FrameMetadata {
|
|
476
|
+
image: string;
|
|
477
|
+
}
|
|
478
|
+
interface IllustrationMetadata {
|
|
479
|
+
colors: string[];
|
|
480
|
+
}
|
|
481
|
+
interface ModuleMetadata {
|
|
482
|
+
text: string;
|
|
483
|
+
}
|
|
484
|
+
interface TextMetadata {
|
|
485
|
+
color?: string;
|
|
486
|
+
text: string;
|
|
487
|
+
}
|
|
488
|
+
interface SelectionStorage {
|
|
489
|
+
selectedVariants?: VariantResource[];
|
|
490
|
+
}
|
|
491
|
+
type StepSelections = {
|
|
492
|
+
[key: string]: SelectionStorage;
|
|
493
|
+
};
|
|
494
|
+
interface ServerResponse {
|
|
495
|
+
/**
|
|
496
|
+
* Will contain error information if an error was recieved
|
|
497
|
+
*/
|
|
498
|
+
errors?: string[];
|
|
499
|
+
/**
|
|
500
|
+
* The body of the response containing any return data.
|
|
501
|
+
*/
|
|
502
|
+
body: object;
|
|
503
|
+
headers: {
|
|
504
|
+
"content-type": string;
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
interface ServerService {
|
|
508
|
+
/**
|
|
509
|
+
* Sets the operation names that should be converted to their correspondingun-cached equivelants.
|
|
510
|
+
*/
|
|
511
|
+
setUncachedOperations: (operationIds: string[]) => void;
|
|
512
|
+
/**
|
|
513
|
+
* Execute an operation against the server.
|
|
514
|
+
*/
|
|
515
|
+
execute: (operationId: string, operationParameters?: object, anonymous?: boolean) => Promise<ServerResponse>;
|
|
516
|
+
}
|
|
517
|
+
interface FrameData {
|
|
518
|
+
/**
|
|
519
|
+
* The path data for a frame SVG
|
|
520
|
+
*/
|
|
521
|
+
path: string;
|
|
522
|
+
/**
|
|
523
|
+
* The viewbox width
|
|
524
|
+
*/
|
|
525
|
+
width: number;
|
|
526
|
+
/**
|
|
527
|
+
* The viewbox height.
|
|
528
|
+
*/
|
|
529
|
+
height: number;
|
|
530
|
+
}
|
|
531
|
+
type ThreeDPreviewService = {
|
|
532
|
+
/**
|
|
533
|
+
* Allows listeners to be aware of the camera losing focus of the
|
|
534
|
+
* main product.
|
|
535
|
+
* @param listener A function to be called when focus is lost.
|
|
536
|
+
*/
|
|
537
|
+
registerFocusLostListener(listener: () => void): void;
|
|
538
|
+
/**
|
|
539
|
+
* Removes a listener from the focusLost observers. The listener will
|
|
540
|
+
* no longer be notified
|
|
541
|
+
* @param listener The listener to remove.
|
|
542
|
+
*/
|
|
543
|
+
unregisterFocusLostListener(listener: () => void): void;
|
|
544
|
+
/**
|
|
545
|
+
* Providers listeners with information about load progress when
|
|
546
|
+
* the preview is loading scenes.
|
|
547
|
+
* @param listener A function to get load progress updates
|
|
548
|
+
*/
|
|
549
|
+
registerLoadProgressListener(listener: (e: LoadProgressEventData) => void): void;
|
|
550
|
+
/**
|
|
551
|
+
* Allows you to pass any function that originally called registerLoadProgressListener()
|
|
552
|
+
* to have it excluded from load progress updates.
|
|
553
|
+
* If the function was never registered this call has no effect.
|
|
554
|
+
* @param listener The listener to exclude from load progress.
|
|
555
|
+
*/
|
|
556
|
+
unregisterLoadProgressListener(listener: (e: LoadProgressEventData) => void): void;
|
|
557
|
+
/**
|
|
558
|
+
* Request that the scene renders to a given canvas
|
|
559
|
+
* @param canvas The canvas we should render to.
|
|
560
|
+
*/
|
|
561
|
+
registerView(canvas: HTMLCanvasElement): void;
|
|
562
|
+
/**
|
|
563
|
+
* Returns the number of active viewers of the scene. Useful for
|
|
564
|
+
* avoiding unnecessary rendering when there are no active viewers.
|
|
565
|
+
*/
|
|
566
|
+
getNumViewports(): number;
|
|
567
|
+
/**
|
|
568
|
+
* Tells babylon that we no longer want the given canvas to be rendered to.
|
|
569
|
+
* @param canvas The canvas to be excluded from rendering.
|
|
570
|
+
*/
|
|
571
|
+
unregisterView(canvas: HTMLCanvasElement): void;
|
|
572
|
+
/**
|
|
573
|
+
* Shutdown the preview engine. Noop if the engine is not initialized.
|
|
574
|
+
*/
|
|
575
|
+
shutdown(): void;
|
|
576
|
+
/**
|
|
577
|
+
* Initialize the scene. Also initialize the engine, if it hasn't been done already.
|
|
578
|
+
*/
|
|
579
|
+
initialize(src: string, contextService?: RenderableContextService): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* Executes an animation in the currently loaded scene.
|
|
582
|
+
* @param animation The current animation track to run.
|
|
583
|
+
*/
|
|
584
|
+
executeModelAnimation(animation: ModelAnimation): void;
|
|
585
|
+
/**
|
|
586
|
+
* Executes an animation of the camera.
|
|
587
|
+
* @param animation The animation to execute.
|
|
588
|
+
*/
|
|
589
|
+
executeCameraAnimation(animation: CameraAnimation): void;
|
|
590
|
+
/**
|
|
591
|
+
* Returns the values of the Arc Rotate Camera
|
|
592
|
+
*/
|
|
593
|
+
getCameraPose(): CameraPose | undefined;
|
|
594
|
+
/**
|
|
595
|
+
* Sets the values of the Arc Rotate Camera
|
|
596
|
+
*/
|
|
597
|
+
setCameraPose(cameraPose: CameraPose): void;
|
|
598
|
+
/**
|
|
599
|
+
* Applies a given material modifier to a target material in the scene.
|
|
600
|
+
* @param targetMaterial The material to target.
|
|
601
|
+
* @param key A unique key used to identify this action.
|
|
602
|
+
* @param material The material modifier to apply.
|
|
603
|
+
*/
|
|
604
|
+
applyMaterialVariant(targetMaterial: string, key: string, material: MaterialResource, removeWhenUndefined?: boolean): Promise<void>;
|
|
605
|
+
/**
|
|
606
|
+
* Applies a given model variant to the scene.
|
|
607
|
+
* @param key A unique key used to identify this action.
|
|
608
|
+
* @param modelDetails An asset containing a model file to be loaded into the scene.
|
|
609
|
+
*/
|
|
610
|
+
applyModelVariant(key: string, modelDetails: ModelDetails, replaceProductModel: boolean): Promise<void>;
|
|
611
|
+
/**
|
|
612
|
+
* Controls the current control state of the camera.
|
|
613
|
+
* @param rigType The control type to use.
|
|
614
|
+
*/
|
|
615
|
+
setCameraState(rigType: ProductCameraRig): void;
|
|
616
|
+
/**
|
|
617
|
+
* Restores the product camera to it's last set focus point. If the user has
|
|
618
|
+
* been panning this will animate the camera to the original focus point. If the camera is still
|
|
619
|
+
* focused on it's origin point this function is a noop.
|
|
620
|
+
*/
|
|
621
|
+
animateToLastCameraFocus(): Promise<void>;
|
|
622
|
+
/**
|
|
623
|
+
* When configuration has allowed for auto rotation we
|
|
624
|
+
* can pause the rotation via this function.
|
|
625
|
+
* @param shouldAutoRotate When true rotation is running, paused otherwise.
|
|
626
|
+
*/
|
|
627
|
+
setAutoRotation(shouldAutoRotate: boolean): void;
|
|
628
|
+
/**
|
|
629
|
+
* Get current load progress for the scene.
|
|
630
|
+
*/
|
|
631
|
+
getSceneInitializationProgress(): number;
|
|
632
|
+
/**
|
|
633
|
+
* Returns the current configuration object applied to the scene.
|
|
634
|
+
*/
|
|
635
|
+
getCurrentConfiguration(): PreviewOptions | undefined;
|
|
636
|
+
/**
|
|
637
|
+
* Takes a screenshot of the scene using a given
|
|
638
|
+
* camera animation otherwise using the existing orientation
|
|
639
|
+
* of the camera in the scene. A resolution must be provided
|
|
640
|
+
* to render the scene at.
|
|
641
|
+
*/
|
|
642
|
+
renderSceneScreenshot(resolution: number, cameraAnimation: CameraAnimation): Promise<string>;
|
|
643
|
+
/**
|
|
644
|
+
* Returns true when the current configuration allows the user
|
|
645
|
+
* to rotate around the product.
|
|
646
|
+
*/
|
|
647
|
+
orbitEnabled(): boolean;
|
|
648
|
+
/**
|
|
649
|
+
* When called will trigger the internal engine to match the current
|
|
650
|
+
* canvas size. This ensures the image renders correctly in the view and
|
|
651
|
+
* also prevents performance problems.
|
|
652
|
+
*/
|
|
653
|
+
fireResizeEvent(): void;
|
|
654
|
+
/**
|
|
655
|
+
* A callback when the user clicks in the scene and a material is hit.
|
|
656
|
+
*/
|
|
657
|
+
onMaterialSelected(cb: (material: MaterialHandle) => void): void;
|
|
658
|
+
/**
|
|
659
|
+
* Designed for use when utilizing the 3D preview in an editor format.
|
|
660
|
+
* List named materials that are available in the scene.
|
|
661
|
+
*/
|
|
662
|
+
listMaterials(): readonly MaterialHandle[];
|
|
663
|
+
/**
|
|
664
|
+
* Designed for use when utilizing the 3D preview in an editor format.
|
|
665
|
+
* Given a list of material names, highlights the associated meshes in the scene.
|
|
666
|
+
*/
|
|
667
|
+
setHighlights(materials: readonly MaterialHandle[], color?: readonly [number, number, number]): void;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Details relating to a model for use in the preview.
|
|
671
|
+
*/
|
|
672
|
+
type ModelDetails = {
|
|
673
|
+
readonly model?: string;
|
|
674
|
+
readonly contextService: RenderableContextService;
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* Represents a service capable of managing and returning contexts that
|
|
678
|
+
* can be used for rendering to textures in the 3D preview.
|
|
679
|
+
*/
|
|
680
|
+
type RenderableContextService = {
|
|
681
|
+
/**
|
|
682
|
+
* Returns all managed renderable contexts.
|
|
683
|
+
*/
|
|
684
|
+
getAll(): ReadonlyMap<string, RenderableContext>;
|
|
685
|
+
};
|
|
686
|
+
/**
|
|
687
|
+
* A renderable context represents the relationship of a texture in the 3D preview
|
|
688
|
+
* with an external canvas. This context allows external clients to render to a texture
|
|
689
|
+
* in the 3D preview with a simple interface.
|
|
690
|
+
*/
|
|
691
|
+
type RenderableContext = {
|
|
692
|
+
/**
|
|
693
|
+
* A unique identifier for this renderable context.
|
|
694
|
+
*/
|
|
695
|
+
getID(): string;
|
|
696
|
+
/**
|
|
697
|
+
* A name for this renderable.
|
|
698
|
+
*/
|
|
699
|
+
getName(): string;
|
|
700
|
+
/**
|
|
701
|
+
* Sets the render context associated to this renderable.
|
|
702
|
+
* @param ctx The context to use for rendering.
|
|
703
|
+
*/
|
|
704
|
+
setStaticContext(ctx: CanvasRenderingContext2D): void;
|
|
705
|
+
/**
|
|
706
|
+
* Get the render context associated to this renderable.
|
|
707
|
+
*/
|
|
708
|
+
getStaticContext(): CanvasRenderingContext2D | undefined;
|
|
709
|
+
/**
|
|
710
|
+
* Sets whether or not this renderable is dirty and will need re-rendering.
|
|
711
|
+
* @param value The new value
|
|
712
|
+
*/
|
|
713
|
+
setStaticContextDirty(value: boolean): void;
|
|
714
|
+
/**
|
|
715
|
+
* When this context has been set as dirty, returns true.
|
|
716
|
+
*/
|
|
717
|
+
getStaticContextDirty(): boolean;
|
|
718
|
+
/**
|
|
719
|
+
* A timestamp for the last successful render of the context.
|
|
720
|
+
*/
|
|
721
|
+
getLastCompletedStaticRender(): number | undefined;
|
|
722
|
+
};
|
|
723
|
+
/**
|
|
724
|
+
* Represents a handle to a material in the 3D scene. The underlying complexity of materials is abstracted
|
|
725
|
+
* away so the client doesn't need to know anything more than the ID they're given and the name.
|
|
726
|
+
*/
|
|
727
|
+
type MaterialHandle = {
|
|
728
|
+
/**
|
|
729
|
+
* The identifier for the material.
|
|
730
|
+
*/
|
|
731
|
+
readonly id: string;
|
|
732
|
+
/**
|
|
733
|
+
* The human readable name for the material.
|
|
734
|
+
*/
|
|
735
|
+
readonly name: string;
|
|
736
|
+
};
|
|
737
|
+
/**
|
|
738
|
+
* Settings related to the 3D preview.
|
|
739
|
+
*/
|
|
740
|
+
type PreviewOptions = {
|
|
741
|
+
/**
|
|
742
|
+
* The color expected to be seen in the background of the product. Expects a hexadecimal value.
|
|
743
|
+
*/
|
|
744
|
+
readonly backgroundColor?: string;
|
|
745
|
+
/**
|
|
746
|
+
* Image to be used as a background when running withh transparency, the image
|
|
747
|
+
* will be scaled and centered to fill the preview based on aspect ratio.
|
|
748
|
+
*/
|
|
749
|
+
readonly backgroundImage?: string;
|
|
750
|
+
/**
|
|
751
|
+
* The closest zoom the camera can achieve to the product.
|
|
752
|
+
*/
|
|
753
|
+
readonly maxZoomOverride?: number;
|
|
754
|
+
/**
|
|
755
|
+
* The furthest zoom the camera can achieve to the product.
|
|
756
|
+
*/
|
|
757
|
+
readonly minZoomOverride?: number;
|
|
758
|
+
/**
|
|
759
|
+
* The environment file used to calculate product lighting.
|
|
760
|
+
*/
|
|
761
|
+
readonly environmentFile?: string;
|
|
762
|
+
/**
|
|
763
|
+
* The lowest point, vertically, that the camera can rotate to.
|
|
764
|
+
* https://doc.babylonjs.com/divingDeeper/cameras/camera_introduction
|
|
765
|
+
*/
|
|
766
|
+
readonly lowerBetaLimitDeg?: number;
|
|
767
|
+
/**
|
|
768
|
+
* The highest point, vertically, that the camera can rotate to.
|
|
769
|
+
* https://doc.babylonjs.com/divingDeeper/cameras/camera_introduction
|
|
770
|
+
*/
|
|
771
|
+
readonly upperBetaLimitDeg?: number;
|
|
772
|
+
/**
|
|
773
|
+
* The leftmost point, horizontally, that the camera can rotate to.
|
|
774
|
+
* https://doc.babylonjs.com/divingDeeper/cameras/camera_introduction
|
|
775
|
+
*/
|
|
776
|
+
readonly lowerAlphaLimitDeg?: number;
|
|
777
|
+
/**
|
|
778
|
+
* The rightmost point, horizontally, that the camera can rotate to.
|
|
779
|
+
* https://doc.babylonjs.com/divingDeeper/cameras/camera_introduction
|
|
780
|
+
*/
|
|
781
|
+
readonly upperAlphaLimitDeg?: number;
|
|
782
|
+
/**
|
|
783
|
+
* When set the product while rotate slowly
|
|
784
|
+
*/
|
|
785
|
+
readonly autoRotation?: boolean;
|
|
786
|
+
/**
|
|
787
|
+
* Time in milliseconds before the product starts rotating after a user input has taken control.
|
|
788
|
+
*/
|
|
789
|
+
readonly idleTimeBeforeRotation?: number;
|
|
790
|
+
/**
|
|
791
|
+
* When set the 3D preview won't attempt to orient the product automatically to its front view at load.
|
|
792
|
+
*/
|
|
793
|
+
readonly disableAutomaticOrientation?: boolean;
|
|
794
|
+
/**
|
|
795
|
+
* When true the action bar won't be displayed to the user.
|
|
796
|
+
*/
|
|
797
|
+
readonly disableActionBar?: boolean;
|
|
798
|
+
/**
|
|
799
|
+
* When set, mousing over the model in this preview will highlight the associated mesh/material.
|
|
800
|
+
* When layout contexts are provided, only the materials with matching names will highlight.
|
|
801
|
+
*/
|
|
802
|
+
readonly highlightOnMaterialHover?: boolean;
|
|
803
|
+
/**
|
|
804
|
+
* Sets the color of highlights when enabled. Expects hexadecimal value.
|
|
805
|
+
*/
|
|
806
|
+
readonly highlightColor?: string;
|
|
807
|
+
};
|
|
808
|
+
/**
|
|
809
|
+
* Defines the different behaviors supported by the camera system
|
|
810
|
+
* for control when viewing a product.
|
|
811
|
+
*/
|
|
812
|
+
enum ProductCameraRig {
|
|
813
|
+
Orbit = 0,
|
|
814
|
+
Pan = 1
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Identical to CameraAnimation typing, however the
|
|
818
|
+
* target is always available and hence is not optional.
|
|
819
|
+
*/
|
|
820
|
+
type CameraPose = {
|
|
821
|
+
readonly lonDeg: number;
|
|
822
|
+
readonly radius: number;
|
|
823
|
+
readonly latDeg: number;
|
|
824
|
+
readonly target: {
|
|
825
|
+
readonly x: number;
|
|
826
|
+
readonly y: number;
|
|
827
|
+
readonly z: number;
|
|
828
|
+
};
|
|
829
|
+
};
|
|
830
|
+
type LoadProgressEventData = {
|
|
831
|
+
/**
|
|
832
|
+
* The total load value of the scene, this is an average of all
|
|
833
|
+
* 'in progress' loading events. when all events are fully loaded this value will be 100.
|
|
834
|
+
*/
|
|
835
|
+
readonly loadValue: number;
|
|
836
|
+
/**
|
|
837
|
+
* This value is true when the base model and scene have been initialized.
|
|
838
|
+
*/
|
|
839
|
+
readonly sceneInitialized: boolean;
|
|
840
|
+
};
|
|
841
|
+
declare class OptionService {
|
|
842
|
+
/**
|
|
843
|
+
* Returns a promise that resolves once all options required for a given workflow
|
|
844
|
+
* have been loaded and cached ready for use.
|
|
845
|
+
* @param workflow The workflow to load options for.
|
|
846
|
+
*/
|
|
847
|
+
cacheRequiredOptions(workflow: Workflow): Promise<void>;
|
|
848
|
+
/**
|
|
849
|
+
* Allows for retrieving an option, returns the option from a cache if possible.
|
|
850
|
+
* @param server The server service for making the request.
|
|
851
|
+
* @param id The option ID to be retrieved.
|
|
852
|
+
*/
|
|
853
|
+
getLocalOrFromServer(server: ServerService, id: string): Promise<IServerModel<OptionResource>>;
|
|
854
|
+
/**
|
|
855
|
+
* Returns an option from the cache, or null
|
|
856
|
+
* @param id The ID to search for.
|
|
857
|
+
*/
|
|
858
|
+
getLocalOrUndefined(id?: string): IServerModel<OptionResource>;
|
|
859
|
+
getAssetTileImageForVariant(variant: VariantResource): Promise<string>;
|
|
860
|
+
getDefaultVariant(option: OptionResource): VariantResource | undefined;
|
|
861
|
+
getDisplayImageSource: (variant?: VariantResource) => undefined | string;
|
|
862
|
+
/**
|
|
863
|
+
* Returns the first variant marked as selected. This is used by most steps.
|
|
864
|
+
*/
|
|
865
|
+
getSelectedVariant: (option: OptionResource | undefined, selectedVariantIds: string[]) => VariantResource | undefined;
|
|
866
|
+
/**
|
|
867
|
+
* Returns all selected variants. This is used by the question step as multiple selections can be made.
|
|
868
|
+
*/
|
|
869
|
+
getSelectedVariants: (option: OptionResource | undefined, selectedVariantIds: string[]) => VariantResource[];
|
|
870
|
+
}
|
|
871
|
+
export const optionService: OptionService;
|
|
872
|
+
export const CommandContextContext: import("react").Context<_CommandContext1>;
|
|
873
|
+
export const useLayouts: () => {
|
|
874
|
+
commandDispatcher: (command: CanvasCommand) => void;
|
|
875
|
+
getLayoutById: (id: string) => _LayoutData1;
|
|
876
|
+
getAllLayouts: () => _LayoutData1[];
|
|
877
|
+
getReducerState: () => CommandState;
|
|
878
|
+
lastUpdated: Date;
|
|
879
|
+
flattenSequence: (sequenceId: string, initialState: _LayoutsState1) => void;
|
|
880
|
+
};
|
|
881
|
+
export type CommandDispatcher = (command: CanvasCommand) => void;
|
|
882
|
+
export type LayoutGetter = (layoutId: string) => _LayoutData1;
|
|
883
|
+
export type LayoutsGetter = () => _LayoutData1[];
|
|
884
|
+
enum ElementEventType {
|
|
885
|
+
Translate = "Translate",
|
|
886
|
+
Rotate = "Rotate",
|
|
887
|
+
Resize = "Resize"
|
|
888
|
+
}
|
|
889
|
+
enum KeyEvent {
|
|
890
|
+
ControlLeft = "ControlLeft",
|
|
891
|
+
ControlRight = "ControlRight",
|
|
892
|
+
Equal = "Equal",
|
|
893
|
+
MetaLeft = "MetaLeft",
|
|
894
|
+
MetaRight = "MetaRight",
|
|
895
|
+
Minus = "Minus",
|
|
896
|
+
ArrowLeft = "ArrowLeft",
|
|
897
|
+
ArrowRight = "ArrowRight",
|
|
898
|
+
ArrowUp = "ArrowUp",
|
|
899
|
+
ArrowDown = "ArrowDown",
|
|
900
|
+
AltLeft = "AltLeft",
|
|
901
|
+
AltRight = "AltRight",
|
|
902
|
+
Delete = "Delete",
|
|
903
|
+
Backspace = "Backspace"
|
|
904
|
+
}
|
|
905
|
+
type ElementEvent = {
|
|
906
|
+
type: ElementEventType.Translate;
|
|
907
|
+
} | {
|
|
908
|
+
type: ElementEventType.Rotate;
|
|
909
|
+
} | {
|
|
910
|
+
type: ElementEventType.Resize;
|
|
911
|
+
relativeAxis: ScaleAxis;
|
|
912
|
+
screenAxis: ScaleAxis;
|
|
913
|
+
};
|
|
914
|
+
enum EditorSubMenu {
|
|
915
|
+
None = "None",
|
|
916
|
+
FrameAdjustment = "FrameAdjustment",
|
|
917
|
+
FinalizeDesign = "FinalizeDesign"
|
|
918
|
+
}
|
|
919
|
+
interface UIState {
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* This context stores global state for
|
|
923
|
+
*/
|
|
924
|
+
interface AdvancedEditorState extends UIState {
|
|
925
|
+
/**
|
|
926
|
+
* The layout currently being displayed in the editor.
|
|
927
|
+
*/
|
|
928
|
+
layoutId: string;
|
|
929
|
+
/**
|
|
930
|
+
* Returns the id of the currently selected element. Or undefined if no element is selected.
|
|
931
|
+
*/
|
|
932
|
+
selectedElement?: string;
|
|
933
|
+
/**
|
|
934
|
+
* The current zoom level of the editor.
|
|
935
|
+
*/
|
|
936
|
+
zoom: number;
|
|
937
|
+
/**
|
|
938
|
+
* The maxiumum zoom possible based on current canvas content.
|
|
939
|
+
*/
|
|
940
|
+
maxZoom: number;
|
|
941
|
+
/**
|
|
942
|
+
* The current measurement system used for display of coordinates and dimensions.
|
|
943
|
+
*/
|
|
944
|
+
units: UnitOfMeasurement;
|
|
945
|
+
/**
|
|
946
|
+
* The sub menu to be displayed to the user in place of the canvas.
|
|
947
|
+
*/
|
|
948
|
+
subMenu: EditorSubMenu;
|
|
949
|
+
/**
|
|
950
|
+
* Any modifier keys that are currently pressed
|
|
951
|
+
*/
|
|
952
|
+
activeModifierKeys: KeyEvent[];
|
|
953
|
+
/**
|
|
954
|
+
* WHether or not a meta key is pressed.
|
|
955
|
+
*/
|
|
956
|
+
metaPressed: boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Any active element event.
|
|
959
|
+
*/
|
|
960
|
+
elementEvent?: ElementEvent;
|
|
961
|
+
/**
|
|
962
|
+
* If movement should assume that it's operating in a scrolled environment.
|
|
963
|
+
* FIXME: Can we get rid of this somehow.
|
|
964
|
+
*/
|
|
965
|
+
scrolledMovement: boolean;
|
|
966
|
+
}
|
|
967
|
+
export const getDefaultState: (getLayouts: LayoutsGetter, defaultZoom: number) => {
|
|
968
|
+
layoutId: string;
|
|
969
|
+
selectedElement: any;
|
|
970
|
+
zoom: number;
|
|
971
|
+
maxZoom: number;
|
|
972
|
+
units: UnitOfMeasurement;
|
|
973
|
+
subMenu: EditorSubMenu;
|
|
974
|
+
activeModifierKeys: any[];
|
|
975
|
+
metaPressed: boolean;
|
|
976
|
+
elementEvent: any;
|
|
977
|
+
scrolledMovement: boolean;
|
|
978
|
+
};
|
|
979
|
+
export const commandReducer: (state: AdvancedEditorState, command: UICommand) => AdvancedEditorState;
|
|
980
|
+
export const AdvancedEditorContext: import("react").Context<{
|
|
981
|
+
uiDispatcher: Dispatch<UICommand>;
|
|
982
|
+
state: AdvancedEditorState;
|
|
983
|
+
}>;
|
|
984
|
+
export const AdvancedEditorStateProvider: FunctionComponent<{
|
|
985
|
+
defaultZoom?: number;
|
|
986
|
+
children: ReactNode;
|
|
987
|
+
}>;
|
|
988
|
+
export class UICommand {
|
|
989
|
+
constructor(changes: Partial<AdvancedEditorState>);
|
|
990
|
+
apply(state: AdvancedEditorState): {
|
|
991
|
+
layoutId: string;
|
|
992
|
+
selectedElement?: string;
|
|
993
|
+
zoom: number;
|
|
994
|
+
maxZoom: number;
|
|
995
|
+
units: UnitOfMeasurement;
|
|
996
|
+
subMenu: EditorSubMenu;
|
|
997
|
+
activeModifierKeys: KeyEvent[];
|
|
998
|
+
metaPressed: boolean;
|
|
999
|
+
elementEvent?: ElementEvent;
|
|
1000
|
+
scrolledMovement: boolean;
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
export const useEditorState: () => {
|
|
1004
|
+
uiDispatcher: Dispatch<UICommand>;
|
|
1005
|
+
state: AdvancedEditorState;
|
|
1006
|
+
};
|
|
1007
|
+
/**
|
|
1008
|
+
* The advanced editor encapsulates the logic required to allow users to manipulate a design
|
|
1009
|
+
* with more granular control such as toolbars, direct element manipulation, and more.
|
|
1010
|
+
*/
|
|
1011
|
+
export const AdvancedEditor: FunctionComponent<{
|
|
1012
|
+
color?: string;
|
|
1013
|
+
guidelineColor?: string;
|
|
1014
|
+
borderRadius?: number;
|
|
1015
|
+
handleContextMenu?: (event: MouseEvent) => void;
|
|
1016
|
+
onElementSelected?: (id: string | undefined, element: PointerEvent) => void;
|
|
1017
|
+
}>;
|
|
1018
|
+
interface StorageService {
|
|
1019
|
+
/**
|
|
1020
|
+
* Get a value.
|
|
1021
|
+
* @param key The key to lookup the value with.
|
|
1022
|
+
*/
|
|
1023
|
+
get(key: string): string | undefined;
|
|
1024
|
+
/**
|
|
1025
|
+
* Set a value.
|
|
1026
|
+
* @param key The key to set.
|
|
1027
|
+
* @param val The new value.
|
|
1028
|
+
*/
|
|
1029
|
+
set(key: string, val: string): void;
|
|
1030
|
+
/**
|
|
1031
|
+
* Remove a value.
|
|
1032
|
+
* @param key The key to remove, does nothing if the key doesn't exist.
|
|
1033
|
+
*/
|
|
1034
|
+
remove(key: string): void;
|
|
1035
|
+
getMap(key: string): Map<any, any> | undefined;
|
|
1036
|
+
setMap(key: string, val: Map<any, any>): void;
|
|
1037
|
+
}
|
|
1038
|
+
export const persistenceService: StorageService;
|
|
1039
|
+
/**
|
|
1040
|
+
* A StepHandle allows for managing the state of a specific step in a workflow. This class
|
|
1041
|
+
* abstracts away the complexities of dealing with a step directly and allows for using high level
|
|
1042
|
+
* concepts instead of dealing with the underlying data structures.
|
|
1043
|
+
*/
|
|
1044
|
+
interface StepHandle {
|
|
1045
|
+
/**
|
|
1046
|
+
* Gets the currently selected variant, or undefined if no variant is selected.
|
|
1047
|
+
*/
|
|
1048
|
+
getCurrentVariant(): any;
|
|
1049
|
+
/**
|
|
1050
|
+
* Returns a list of valid variants for this step.
|
|
1051
|
+
*/
|
|
1052
|
+
getAvailableVariants(): Promise<VariantResource[]>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Selects a specific variant for this step.
|
|
1055
|
+
*/
|
|
1056
|
+
selectVariant(variant: VariantResource): any;
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* A Workflow experience encapsulates the workflow manager and command context. It
|
|
1060
|
+
* provides a simplified interface for interacting with the workflow manager. You
|
|
1061
|
+
* should get an instance of this class from a Client you have constructed previously.
|
|
1062
|
+
*/
|
|
1063
|
+
export interface WorkflowExperience {
|
|
1064
|
+
/**
|
|
1065
|
+
* State related to the design of the user.
|
|
1066
|
+
*/
|
|
1067
|
+
getCommandContext(): _CommandContext1;
|
|
1068
|
+
/**
|
|
1069
|
+
* Returns true when the user may only view the design.
|
|
1070
|
+
*/
|
|
1071
|
+
getIsReadOnly(): boolean;
|
|
1072
|
+
/**
|
|
1073
|
+
* Get the low level workflow amanager instance for this experience. Don't touch this unless you're willing to break things.
|
|
1074
|
+
*/
|
|
1075
|
+
getWorkflowManager(): WorkflowManager;
|
|
1076
|
+
/**
|
|
1077
|
+
* Bulk workflow operation, used to update multiple variations at once.
|
|
1078
|
+
*/
|
|
1079
|
+
updateVariationRecords(variationRecords: VariationRecord[]): Promise<void>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Returns the step matching a given name, undefined if not found.
|
|
1082
|
+
* @param id The id the step must match.
|
|
1083
|
+
*/
|
|
1084
|
+
getStepById(id: string): StepHandle | undefined;
|
|
1085
|
+
/**
|
|
1086
|
+
* Returns the step matching a given name, undefined if not found.
|
|
1087
|
+
* @param name The name the step must match.
|
|
1088
|
+
*/
|
|
1089
|
+
getStepByName(name: string): StepHandle | undefined;
|
|
1090
|
+
/**
|
|
1091
|
+
* Returns all steps matching a specific type in the workflow. These steps
|
|
1092
|
+
* may be across multiple scenes and may or may not be active based on condition state.
|
|
1093
|
+
*/
|
|
1094
|
+
getStepsByType(type: StepType): StepHandle[];
|
|
1095
|
+
/**
|
|
1096
|
+
* Creates a data URL preview for the current design.
|
|
1097
|
+
*/
|
|
1098
|
+
createPreviewImage(): Promise<string>;
|
|
1099
|
+
/**
|
|
1100
|
+
* To be called when the workflow experience is considered completed by the user.
|
|
1101
|
+
* @param product
|
|
1102
|
+
* @param onProgressUpdate Progress callback for finalizing the design.
|
|
1103
|
+
* @param selections
|
|
1104
|
+
* @param metadata
|
|
1105
|
+
*/
|
|
1106
|
+
onDesignFinished(product: Product, onProgressUpdate: DesignCreationProgressUpdate, selections: WorkflowSelections, metadata?: WorkflowMetadata | undefined): Promise<DesignCreationMessage>;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Options that can be used during instantiation of the SpiffCommerce Javascript Client.
|
|
1110
|
+
* Please refer to the documentation for more information.
|
|
1111
|
+
*/
|
|
1112
|
+
interface ClientOptions {
|
|
1113
|
+
/**
|
|
1114
|
+
* When set to true, the client will treat the workflow as a bulk order
|
|
1115
|
+
* containing multiple variations of the base design.
|
|
1116
|
+
*/
|
|
1117
|
+
bulk?: boolean;
|
|
1118
|
+
useUncachedEndpoints?: boolean;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* The Spiff Commerce Javascript Client. Required for
|
|
1122
|
+
* creating workflow experiences.
|
|
1123
|
+
*/
|
|
1124
|
+
export class Client {
|
|
1125
|
+
constructor(options: ClientOptions);
|
|
1126
|
+
/**
|
|
1127
|
+
* Initialize the client from an integration product.
|
|
1128
|
+
* @param integrationProductId The integration product to use.
|
|
1129
|
+
*/
|
|
1130
|
+
initFromIntegrationProduct(integrationProductId: string): Promise<void>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Initialize the client from an existing transaction.
|
|
1133
|
+
* @param transactionId The id of the transaction
|
|
1134
|
+
* @returns A promise resolving at initialization completion.
|
|
1135
|
+
*/
|
|
1136
|
+
initFromTransaction(transactionId: string): Promise<void>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Creates a new instance of WorkflowExperience. A high level wrapper for workflows.
|
|
1139
|
+
* @param workflowId The id of the workflow to be run.
|
|
1140
|
+
* @param workflowState An existing workflow state if available.
|
|
1141
|
+
* @param previewServiceConstructor A function called during initialization. Takes a class implementing ThreeDPreviewService in return.
|
|
1142
|
+
* @returns A workflow experience configured as requested.
|
|
1143
|
+
*/
|
|
1144
|
+
getWorkflowExperience(workflowId?: string, workflowState?: string, previewServiceConstructor?: (workflow: Workflow) => _ThreeDPreviewService1): Promise<WorkflowExperience>;
|
|
1145
|
+
/**
|
|
1146
|
+
* @returns The preview service that was provided during construction.
|
|
1147
|
+
*/
|
|
1148
|
+
getPreviewService(): import("types")._ThreeDPreviewService1;
|
|
1149
|
+
/**
|
|
1150
|
+
* @returns The product associated with this client.
|
|
1151
|
+
*/
|
|
1152
|
+
getProduct(): Product;
|
|
1153
|
+
/**
|
|
1154
|
+
* @returns The transaction associated with this client.
|
|
1155
|
+
*/
|
|
1156
|
+
getTransaction(): Transaction;
|
|
1157
|
+
}
|
|
1158
|
+
export { CommandContext };
|
|
1159
|
+
export { CreateElementCommand, TextChangeCommand, FontAlignmentCommand, FontColorCommand, LayoutElementFactory };
|
|
1160
|
+
export { LayoutElement, ImageElement, TextboxElement, TextStepData, LayoutData, LayoutsState };
|
|
1161
|
+
export { SpiffCommerce3DPreviewService };
|
|
1162
|
+
|
|
1163
|
+
//# sourceMappingURL=types.d.ts.map
|